Let GeneratedCodeBasicInfo provide more info

`GeneratedCodeBasicInfo` now exposes the instruction alignment of the
current architecture, the stack pointer register, the size of the PC
register, a reference to `anyPC` and correctly handles the
`DispatcherFail` basic block.
This commit is contained in:
Alessandro Di Federico
2017-08-12 15:22:46 +02:00
parent 1729ab6d0b
commit 00f7016c70
2 changed files with 49 additions and 9 deletions
+11 -2
View File
@@ -35,8 +35,13 @@ bool GeneratedCodeBasicInfo::runOnFunction(llvm::Function &F) {
auto *Tuple = dyn_cast<MDTuple>(InputArchMD->getOperand(0));
QuickMetadata QMD(M->getContext());
DelaySlotSize = QMD.extract<uint32_t>(Tuple, 0);
PC = M->getGlobalVariable(QMD.extract<StringRef>(Tuple, 1));
InstructionAlignment = QMD.extract<uint32_t>(Tuple, 0);
DelaySlotSize = QMD.extract<uint32_t>(Tuple, 1);
PC = M->getGlobalVariable(QMD.extract<StringRef>(Tuple, 2), true);
SP = M->getGlobalVariable(QMD.extract<StringRef>(Tuple, 3), true);
Type *PCType = PC->getType()->getPointerElementType();
PCRegSize = M->getDataLayout().getTypeSizeInBits(PCType) / 8;
for (BasicBlock &BB : F) {
if (!BB.empty()) {
@@ -45,6 +50,10 @@ bool GeneratedCodeBasicInfo::runOnFunction(llvm::Function &F) {
assert(Dispatcher == nullptr);
Dispatcher = &BB;
break;
case DispatcherFailure:
assert(DispatcherFail == nullptr);
DispatcherFail = &BB;
break;
case AnyPCBlock:
assert(AnyPC == nullptr);
AnyPC = &BB;