[llvm] [SandboxIR] Implement ConstantPointerNull (PR #107320)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 15:45:12 PDT 2024


================
@@ -987,6 +989,35 @@ class ConstantAggregateZero final : public Constant {
 #endif
 };
 
+// TODO: Inherit from ConstantData.
+class ConstantPointerNull final : public Constant {
+  ConstantPointerNull(llvm::ConstantPointerNull *C, Context &Ctx)
+      : Constant(ClassID::ConstantPointerNull, C, Ctx) {}
+  friend class Context; // For constructor.
+
+public:
+  static ConstantPointerNull *get(PointerType *Ty);
+
+  PointerType *getType() const;
+
+  /// For isa/dyn_cast.
+  static bool classof(const sandboxir::Value *From) {
+    return From->getSubclassID() == ClassID::ConstantPointerNull;
+  }
+  unsigned getUseOperandNo(const Use &Use) const final {
+    llvm_unreachable("ConstantAggregateZero has no operands!");
----------------
vporpo wrote:

Good catch!

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


More information about the llvm-commits mailing list