From a51efc266cfe338b88aab5ae77f04acbe16cbb07 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Mon, 25 Jun 2018 13:12:02 +0000 Subject: [llvm-exegesis] Generate snippet setup code. Summary: This ensures that the snippet always sees the same values for registers, making measurements reproducible. This will also allow exploring different values. Reviewers: gchatelet Subscribers: tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D48542 llvm-svn: 335465 --- llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp') diff --git a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp index 5678fcea94d..fc0d5b327b8 100644 --- a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp +++ b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp @@ -99,11 +99,22 @@ llvm::MCOperand &InstructionInstance::getValueFor(const Variable &Var) { return VariableValues[Var.Index]; } +const llvm::MCOperand & +InstructionInstance::getValueFor(const Variable &Var) const { + return VariableValues[Var.Index]; +} + llvm::MCOperand &InstructionInstance::getValueFor(const Operand &Op) { assert(Op.VariableIndex >= 0); return getValueFor(Instr.Variables[Op.VariableIndex]); } +const llvm::MCOperand & +InstructionInstance::getValueFor(const Operand &Op) const { + assert(Op.VariableIndex >= 0); + return getValueFor(Instr.Variables[Op.VariableIndex]); +} + // forward declaration. static void randomize(const Instruction &Instr, const Variable &Var, llvm::MCOperand &AssignedValue); @@ -118,12 +129,15 @@ bool InstructionInstance::hasImmediateVariables() const { }); } -llvm::MCInst InstructionInstance::randomizeUnsetVariablesAndBuild() { +void InstructionInstance::randomizeUnsetVariables() { for (const Variable &Var : Instr.Variables) { llvm::MCOperand &AssignedValue = getValueFor(Var); if (!AssignedValue.isValid()) randomize(Instr, Var, AssignedValue); } +} + +llvm::MCInst InstructionInstance::build() const { llvm::MCInst Result; Result.setOpcode(Instr.Description->Opcode); for (const auto &Op : Instr.Operands) -- cgit v1.2.3