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

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 19 10:01:06 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 {
----------------
vporpo wrote:

Aren't they still useful though? If you misspell a `final` function name you will still get an error, but you won't get one if you just rely on the class being marked `final`.
Well, I think I would prefer to stick with `final` because it conveys both that it's overriden and that it's final.

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


More information about the llvm-commits mailing list