[llvm] [feature][riscv] handle target address calculation in llvm-objdump disassembly for riscv (PR #109914)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 15:28:39 PST 2024


================
@@ -181,6 +181,12 @@ class MCInstrAnalysis {
   evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
                  uint64_t &Target) const;
 
+  /// Given an instruction that accesses a menory address, try to compute
+  /// the target address. Return true success, and the address in Target.
+  virtual bool
+  evaluateInstruction(const MCInst &Inst, uint64_t Addr, uint64_t Size,
+                      uint64_t &Target, int ArchRegWidth) const;
----------------
lenary wrote:

The `ArchRegWidth` parameter here feels strange given it shouldn't really change between instructions. I realise changing the signature of `Target::MCInstrAnalysisCtorFnTy` to pass the triple (most other construction functions have some kind of access to it) is pretty invasive and so out of the question - maybe instead we could pass the width to the constructor and use two different `createRISCVInstrAnalysis` functions, one for rv32 and one for rv64? Then we wouldn't need it as a parameter.

https://github.com/llvm/llvm-project/pull/109914


More information about the llvm-commits mailing list