Skip to content

Commit 50c07db

Browse files
committed
[llvm-exegesis] [AArch64] Implement different register initialization for subprocess execution mode
1 parent 21cd653 commit 50c07db

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

llvm/tools/llvm-exegesis/lib/Assembler.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static bool generateSnippetSetupCode(const ExegesisTarget &ET,
6666
assert(MM.Address % getpagesize() == 0 &&
6767
"Memory mappings need to be aligned to page boundaries.");
6868
#endif
69+
// FIXME: file descriptor for aux memory seems not initialized.
70+
// TODO: Invoke openat syscall to get correct fd for aux memory
6971
const MemoryValue &MemVal = Key.MemoryValues.at(MM.MemoryValueName);
7072
BBF.addInstructions(ET.generateMmap(
7173
MM.Address, MemVal.SizeBytes,
@@ -78,15 +80,47 @@ static bool generateSnippetSetupCode(const ExegesisTarget &ET,
7880
Register StackPointerRegister = BBF.MF.getSubtarget()
7981
.getTargetLowering()
8082
->getStackPointerRegisterToSaveRestore();
83+
#define DEBUG_TYPE "register-initial-values"
84+
// FIXME: Only loading first register with memory address is hacky.
85+
bool isFirstRegister = true;
8186
for (const RegisterValue &RV : Key.RegisterInitialValues) {
87+
// Debug: register name and class name and value from BenchmarkKey
88+
const MCRegisterInfo *RegInfo = BBF.MF.getTarget().getMCRegisterInfo();
89+
const char *RegName = RegInfo->getName(RV.Register);
90+
const char *regClassName = "Unknown";
91+
for (unsigned i = 0, e = RegInfo->getNumRegClasses(); i < e; ++i) {
92+
const MCRegisterClass &RC = RegInfo->getRegClass(i);
93+
if (RC.contains(RV.Register)) {
94+
regClassName = RegInfo->getRegClassName(&RC);
95+
break;
96+
}
97+
}
98+
LLVM_DEBUG(
99+
dbgs() << "Setting register (Class: " << regClassName << ") " << RegName
100+
<< std::string(
101+
std::max(0, 3 - static_cast<int>(strlen(RegName))), ' '));
102+
82103
if (GenerateMemoryInstructions) {
83104
// If we're generating memory instructions, don't load in the value for
84105
// the register with the stack pointer as it will be used later to finish
85106
// the setup.
86107
if (Register(RV.Register) == StackPointerRegister)
87108
continue;
109+
#if defined(__aarch64__)
110+
auto StackLoadInsts = ET._generateRegisterStackPop(RV.Register, 16);
111+
if (!StackLoadInsts.empty() && isFirstRegister) {
112+
for (const auto &Inst : StackLoadInsts)
113+
BBF.addInstruction(Inst);
114+
isFirstRegister = false;
115+
LLVM_DEBUG(dbgs() << "from stack with post-increment offset of " << 16
116+
<< " bytes\n");
117+
continue;
118+
}
119+
#endif
88120
}
89121
// Load a constant in the register.
122+
LLVM_DEBUG(dbgs() << " to " << RV.Value << "\n");
123+
#undef DEBUG_TYPE
90124
const auto SetRegisterCode = ET.setRegTo(*MSI, RV.Register, RV.Value);
91125
if (SetRegisterCode.empty())
92126
IsSnippetSetupComplete = false;

0 commit comments

Comments
 (0)