[PATCH] D52718: [llvm-exegesis][NFC] Make randomizeUnsetVariables a free function.
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 1 04:40:06 PDT 2018
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, tschuett.
This is prelimineary to moving random functions to SnippetGenerator.
Repository:
rL LLVM
https://reviews.llvm.org/D52718
Files:
tools/llvm-exegesis/lib/CodeTemplate.cpp
tools/llvm-exegesis/lib/CodeTemplate.h
tools/llvm-exegesis/lib/SnippetGenerator.cpp
Index: tools/llvm-exegesis/lib/SnippetGenerator.cpp
===================================================================
--- tools/llvm-exegesis/lib/SnippetGenerator.cpp
+++ tools/llvm-exegesis/lib/SnippetGenerator.cpp
@@ -35,16 +35,17 @@
SnippetGenerator::generateConfigurations(unsigned Opcode) const {
if (auto E = generateCodeTemplate(Opcode)) {
CodeTemplate &CT = E.get();
+ const llvm::BitVector &ForbiddenRegs =
+ CT.ScratchSpacePointerInReg
+ ? RATC.getRegister(CT.ScratchSpacePointerInReg).aliasedBits()
+ : RATC.emptyRegisters();
std::vector<BenchmarkCode> Output;
// TODO: Generate as many BenchmarkCode as needed.
{
BenchmarkCode BC;
BC.Info = CT.Info;
for (InstructionTemplate &IT : CT.Instructions) {
- IT.randomizeUnsetVariables(
- CT.ScratchSpacePointerInReg
- ? RATC.getRegister(CT.ScratchSpacePointerInReg).aliasedBits()
- : RATC.emptyRegisters());
+ randomizeUnsetVariables(ForbiddenRegs, IT);
BC.Instructions.push_back(IT.build());
}
if (CT.ScratchSpacePointerInReg)
Index: tools/llvm-exegesis/lib/CodeTemplate.h
===================================================================
--- tools/llvm-exegesis/lib/CodeTemplate.h
+++ tools/llvm-exegesis/lib/CodeTemplate.h
@@ -36,10 +36,6 @@
const llvm::MCOperand &getValueFor(const Operand &Op) const;
bool hasImmediateVariables() const;
- // Assigns a Random Value to all Variables that are still Invalid.
- // Do not use any of the registers in `ForbiddenRegs`.
- void randomizeUnsetVariables(const llvm::BitVector &ForbiddenRegs);
-
// Builds an llvm::MCInst from this InstructionTemplate setting its operands
// to the corresponding variable values. Precondition: All VariableValues must
// be set.
@@ -84,6 +80,11 @@
void setRandomAliasing(const AliasingConfigurations &AliasingConfigurations,
InstructionTemplate &DefIB, InstructionTemplate &UseIB);
+// Assigns a Random Value to all Variables in IT that are still Invalid.
+// Do not use any of the registers in `ForbiddenRegs`.
+void randomizeUnsetVariables(const llvm::BitVector &ForbiddenRegs,
+ InstructionTemplate &IT);
+
} // namespace exegesis
#endif // LLVM_TOOLS_LLVM_EXEGESIS_CODETEMPLATE_H
Index: tools/llvm-exegesis/lib/CodeTemplate.cpp
===================================================================
--- tools/llvm-exegesis/lib/CodeTemplate.cpp
+++ tools/llvm-exegesis/lib/CodeTemplate.cpp
@@ -67,15 +67,6 @@
});
}
-void InstructionTemplate::randomizeUnsetVariables(
- const llvm::BitVector &ForbiddenRegs) {
- for (const Variable &Var : Instr.Variables) {
- llvm::MCOperand &AssignedValue = getValueFor(Var);
- if (!AssignedValue.isValid())
- randomize(Instr, Var, AssignedValue, ForbiddenRegs);
- }
-}
-
llvm::MCInst InstructionTemplate::build() const {
llvm::MCInst Result;
Result.setOpcode(Instr.Description->Opcode);
@@ -161,4 +152,13 @@
setRegisterOperandValue(randomElement(RandomConf.Uses), UseIB);
}
+void randomizeUnsetVariables(const llvm::BitVector &ForbiddenRegs,
+ InstructionTemplate &IT) {
+ for (const Variable &Var : IT.Instr.Variables) {
+ llvm::MCOperand &AssignedValue = IT.getValueFor(Var);
+ if (!AssignedValue.isValid())
+ randomize(IT.Instr, Var, AssignedValue, ForbiddenRegs);
+ }
+}
+
} // namespace exegesis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52718.167699.patch
Type: text/x-patch
Size: 3485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181001/db526a94/attachment.bin>
More information about the llvm-commits
mailing list