[llvm] [SandboxIR] More boilerplate: Function, Argument, Constant, Instruction, OpaqueInst (PR #97343)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 2 10:52:02 PDT 2024


================
@@ -58,8 +58,127 @@ void Value::printAsOperandCommon(raw_ostream &OS) const {
     OS << "NULL ";
 }
 
+void Argument::printAsOperand(raw_ostream &OS) const {
+  printAsOperandCommon(OS);
+}
+void Argument::dump(raw_ostream &OS) const {
+  dumpCommonPrefix(OS);
+  dumpCommonSuffix(OS);
+}
+void Argument::dump() const {
+  dump(dbgs());
+  dbgs() << "\n";
+}
+
+bool User::classof(const Value *From) {
+  switch (From->getSubclassID()) {
+#define DEF_VALUE(ID, CLASS)
+#define DEF_USER(ID, CLASS)                                                    \
+  case ClassID::ID:                                                            \
+    return true;
+#define DEF_INSTR(ID, OPC, CLASS)                                              \
+  case ClassID::ID:                                                            \
+    return true;
+#include "llvm/SandboxIR/SandboxIRValues.def"
+  default:
+    return false;
+  }
+  return false;
+}
+
 void User::dumpCommonHeader(raw_ostream &OS) const {
   Value::dumpCommonHeader(OS);
   // TODO: This is incomplete
 }
 #endif // NDEBUG
+
+const char *Instruction::getOpcodeName(Opcode Opc) {
+  switch (Opc) {
+#define DEF_VALUE(ID, CLASS)
+#define DEF_USER(ID, CLASS)
+#define OP(OPC)                                                                \
+  case Opcode::OPC:                                                            \
+    return #OPC;
+#define OPCODES(...) __VA_ARGS__
----------------
aeubanks wrote:

what is this used for?

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


More information about the llvm-commits mailing list