[PATCH] D105751: GlobalISel: Introduce GenericMachineInstr classes and derivatives for idiomatic LLVM RTTI.

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 12 15:24:29 PDT 2021


arsenm added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h:24
+/// A base class for all GenericMachineInstrs.
+class GenericMachineInstr : public MachineInstr {
+public:
----------------
aemerson wrote:
> arsenm wrote:
> > Can we get away with allocating these as regular MachineInstrs since there are no real members?
> Not sure what you mean. Have the others inherit directly from MachineInstr? If so we wouldn't be able to declare GISel helpers like `getReg()`, unless we add those to MachineInstr. Even then, it would be useful to have this to enforce more type safety in future for places which only expect to deal with generic instructions.
I mean is it legal C++ to do:

X = new MachineInstr()
Y = cast<GenericMachineInstr>(X)

with guaranteed sizeof(*X) == sizeof(*Y), or would we need to allocate these initially as GenericMachineInstr?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105751



More information about the llvm-commits mailing list