[llvm] [LLVM][Intrinsics] Refactor IIT encoding generation (PR #189790)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 01:26:02 PDT 2026


================
@@ -442,15 +426,54 @@ class LLVMQualPointerType<int addrspace>
     ]);
 }
 
-class LLVMAnyPointerType : LLVMAnyType<pAny> {
-  assert isAny, "pAny should have isOverloaded";
+// Note: CodeGenIntrinsics.cpp seems to check this class to check pointers.
+class LLVMAnyPointerType : LLVMAnyType<pAny>;
+
+// Dependent types: These are types that depend on another LLVMAnyType overload
+// type. There are 2 subclasses of dependent types:
+// 1. Fully dependent types: dependent type can be completely derived from
+//    another overload type.
+// 2. Partially dependent types: dependent type is constrained by another
+//    overload type, but cannot be fully derived from it. Such types get
+//    assigned an overload index and are a part of the overloaded types for an
+//    intrinsics.
+class LLVMDependentType<int oidx> : LLVMType<OtherVT> {
+  // Overload index of the overload type that this dependent type is dependent
+  // on.
+  int OverloadIndex = oidx;
+}
+
+class LLVMFullyDependentType<int oidx, IIT_Base IIT_Info>
+  : LLVMDependentType<oidx> {
+  // For fully dependent overload types, the type signature is just the IIT code
+  // followed by the overload index of the overload type it depends on.
+  let Sig = [
+    IIT_Info.Number,
+    PackOverloadIndex<OverloadIndex, ArgKind.MatchType>.ret
+  ];
+}
+
+class LLVMPartiallyDependentType<int oidx, IIT_Base IIT_Info>
+  : LLVMDependentType<oidx> {
+  // For partially dependent type, the type signature is the IIT code, followed
+  // by this type's oveerload index, followed by the overload index of the
+  // overload type its depends on.
+  let Sig = [
+    IIT_Info.Number,
+    // This types overload index, arg kind ignored.
+    PatchOverloadIndex<0>.ret,
+    // Overload index of the reference overload type, arg kind ignored.
+    PackOverloadIndex<OverloadIndex, 0>.ret,
+  ];
 }
 
-// Match the type of another intrinsic parameter. Number is an index into the
-// list of overloaded types for the intrinsic (i.e, the overload index),
-// excluding all the fixed types and all fully dependent types (i.e., all
-// sub-classes of LLVMMatchType, except LLVMMatchTypeNextArg). The Number
-// value must refer to a previously listed type. For example:
+// ----------------------------------------------------------------------------
+// Various sub-classes of fully dependent types.
+
+// Match the type of another intrinsic parameter. `oidx` is an index of the
+// overloaded types that this type is dependent on. Overload types either
----------------
nikic wrote:

```suggestion
// overloaded types that this type is dependent on. Overload types are either
```

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


More information about the llvm-commits mailing list