[PATCH] D82090: [MC] Pass the symbol rather than its name to onSymbolStart()

Ronak Chauhan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 06:30:09 PDT 2020


rochauha created this revision.
rochauha added reviewers: scott.linder, jhenderson, MaskRay, aardappel.
Herald added subscribers: llvm-commits, rupprecht, aheejin, hiraditya, jgravelle-google, sbc100, dschuff.
Herald added a project: LLVM.

This allows targets to also consider the symbol's type and/or address if needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82090

Files:
  llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
  llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
  llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp


Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1429,7 +1429,7 @@
         continue;
       }
 
-      auto Status = DisAsm->onSymbolStart(SymbolName, Size,
+      auto Status = DisAsm->onSymbolStart(Symbols[SI], Size,
                                           Bytes.slice(Start, End - Start),
                                           SectionAddr + Start, CommentStream);
       // To have round trippable disassembly, we fall back to decoding the
Index: llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
+++ llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp
@@ -46,7 +46,7 @@
   DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
                               ArrayRef<uint8_t> Bytes, uint64_t Address,
                               raw_ostream &CStream) const override;
-  Optional<DecodeStatus> onSymbolStart(StringRef Name, uint64_t &Size,
+  Optional<DecodeStatus> onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
                                        ArrayRef<uint8_t> Bytes,
                                        uint64_t Address,
                                        raw_ostream &CStream) const override;
@@ -122,8 +122,8 @@
 }
 
 Optional<MCDisassembler::DecodeStatus> WebAssemblyDisassembler::onSymbolStart(
-    StringRef Name, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address,
-    raw_ostream &CStream) const {
+    SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes,
+    uint64_t Address, raw_ostream &CStream) const {
   Size = 0;
   if (Address == 0) {
     // Start of a code section: we're parsing only the function count.
Index: llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
===================================================================
--- llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
+++ llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
@@ -17,7 +17,7 @@
 MCDisassembler::~MCDisassembler() = default;
 
 Optional<MCDisassembler::DecodeStatus>
-MCDisassembler::onSymbolStart(StringRef Name, uint64_t &Size,
+MCDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
                               ArrayRef<uint8_t> Bytes, uint64_t Address,
                               raw_ostream &CStream) const {
   return None;
Index: llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
===================================================================
--- llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
+++ llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h
@@ -135,7 +135,7 @@
   /// Base implementation returns None. So all targets by default ignore to
   /// treat symbols separately.
   ///
-  /// \param Name     - The name of the symbol.
+  /// \param Symbol   - The symbol.
   /// \param Size     - The number of bytes consumed.
   /// \param Address  - The address, in the memory space of region, of the first
   ///                   byte of the symbol.
@@ -150,10 +150,9 @@
   ///                   done by buffering the output if needed.
   ///                 - None if the target doesn't want to handle the symbol
   ///                   separately. Value of Size is ignored in this case.
-  virtual Optional<DecodeStatus> onSymbolStart(StringRef Name, uint64_t &Size,
-                                               ArrayRef<uint8_t> Bytes,
-                                               uint64_t Address,
-                                               raw_ostream &CStream) const;
+  virtual Optional<DecodeStatus>
+  onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> Bytes,
+                uint64_t Address, raw_ostream &CStream) const;
   // TODO:
   // Implement similar hooks that can be used at other points during
   // disassembly. Something along the following lines:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82090.271693.patch
Type: text/x-patch
Size: 4035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200618/f055cfa0/attachment-0001.bin>


More information about the llvm-commits mailing list