[PATCH] D69836: [MIR] Target specific MIR formating and parsing

Peng Guo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 16:23:05 PST 2019


pguo marked an inline comment as done.
pguo added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/MIRFormatter.h:36
+  /// value of OpIdx is ~0 which means the index is unknown.
+  virtual void printImm(raw_ostream &OS, const MachineInstr &MI, unsigned OpIdx,
+                        int64_t Imm) const {
----------------
dsanders wrote:
> This is just an optional nitpick. Using ~0 is fine but if you used Optional<unsigned> then you wouldn't have to explain that. It does take a little more storage though so I don't mind if you stick to ~0
I think the OpIdx here is not optional but required to get the correct functionally.  The tuple <OpCode, OpIdx> will uniquely tell formatter how to format the immediate in a target specific way.  While since we can do dump() on any MachineOperand object inside debugger, in this case we don't know the Index, so we have to pass ~0 to the real print function to mark it as unknown.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69836/new/

https://reviews.llvm.org/D69836





More information about the llvm-commits mailing list