summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-06-25 13:12:02 +0000
committerClement Courbet <courbet@google.com>2018-06-25 13:12:02 +0000
commita51efc266cfe338b88aab5ae77f04acbe16cbb07 (patch)
tree4592ffe49cd902ac437c2f8db7e032866dac5d24 /llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp
parent19f4f392c209ec82c5ec88e1f7273243208cd77f (diff)
downloadbcm5719-llvm-a51efc266cfe338b88aab5ae77f04acbe16cbb07.tar.gz
bcm5719-llvm-a51efc266cfe338b88aab5ae77f04acbe16cbb07.zip
[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
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp16
1 files changed, 15 insertions, 1 deletions
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)
OpenPOWER on IntegriCloud