mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user