From b2326784776e428407dc8a4dca50100c5bb17ac4 Mon Sep 17 00:00:00 2001 From: Alessandro Di Federico Date: Fri, 1 Mar 2019 20:10:21 +0100 Subject: [PATCH] GCBI: collect and expose ABI registers --- include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h | 5 +++++ include/revng/Support/revng.h | 2 +- lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h b/include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h index 9f9ee5593..803faf068 100644 --- a/include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h +++ b/include/revng/BasicAnalyses/GeneratedCodeBasicInfo.h @@ -380,6 +380,10 @@ public: return Result; } + const std::vector &abiRegisters() const { + return ABIRegisters; + } + private: static std::vector extractCSVs(llvm::CallInst *Call, const char *MetadataKind) { @@ -414,6 +418,7 @@ private: unsigned PCRegSize; llvm::Function *RootFunction; std::vector CSVs; + std::vector ABIRegisters; }; template<> diff --git a/include/revng/Support/revng.h b/include/revng/Support/revng.h index 9e0caec06..ef27a7ad8 100644 --- a/include/revng/Support/revng.h +++ b/include/revng/Support/revng.h @@ -266,7 +266,7 @@ public: llvm::StringRef stackPointerRegister() const { return StackPointerRegister; } llvm::ArrayRef noReturnSyscalls() const { return NoReturnSyscalls; } uint32_t delaySlotSize() const { return DelaySlotSize; } - llvm::SmallVector abiRegisters() const { + const llvm::SmallVector &abiRegisters() const { return ABIRegisters; } const char *name() const { diff --git a/lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp b/lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp index 179c69989..6f945b861 100644 --- a/lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp +++ b/lib/BasicAnalyses/GeneratedCodeBasicInfo.cpp @@ -40,6 +40,11 @@ bool GeneratedCodeBasicInfo::runOnModule(llvm::Module &M) { DelaySlotSize = QMD.extract(Tuple, 1); PC = M.getGlobalVariable(QMD.extract(Tuple, 2), true); SP = M.getGlobalVariable(QMD.extract(Tuple, 3), true); + auto Operands = QMD.extract(Tuple, 4)->operands(); + for (const MDOperand &Operand : Operands) { + StringRef Name = QMD.extract(Operand.get()); + ABIRegisters.push_back(M.getGlobalVariable(Name, true)); + } Type *PCType = PC->getType()->getPointerElementType(); PCRegSize = M.getDataLayout().getTypeAllocSize(PCType);