[llvm] [SandboxIR] Implement LoadInst (PR #99597)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 21:24:49 PDT 2024


================
@@ -553,6 +557,50 @@ class Instruction : public sandboxir::User {
 #endif
 };
 
+class LoadInst : public Instruction {
+  /// Use Context::createLoadInst(). Don't call the
+  /// constructor directly.
+  LoadInst(llvm::LoadInst *LI, Context &Ctx)
+      : Instruction(ClassID::Load, Opcode::Load, LI, Ctx) {}
+  friend Context; // for LoadInst()
+  Use getOperandUseInternal(unsigned OpIdx, bool Verify) const final {
+    return getOperandUseDefault(OpIdx, Verify);
+  }
+  SmallVector<llvm::Instruction *, 1> getLLVMInstrs() const final {
+    return {cast<llvm::Instruction>(Val)};
+  }
+
+public:
+  unsigned getUseOperandNo(const Use &Use) const final {
----------------
tschuett wrote:

True. But `getUseOperandNo` overrides a virtual = 0 from `User`. Once you mark it `override` the compiler will do checks for you. `override final`.

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


More information about the llvm-commits mailing list