[llvm] [C API] Add getters for Target Extension Types to C API (PR #96447)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 02:41:11 PDT 2024


================
@@ -157,8 +157,26 @@ struct TypeCloner {
         return LLVMX86MMXTypeInContext(Ctx);
       case LLVMTokenTypeKind:
         return LLVMTokenTypeInContext(Ctx);
-      case LLVMTargetExtTypeKind:
-        assert(false && "Implement me");
+      case LLVMTargetExtTypeKind: {
+        const char *Name = LLVMGetTargetExtTypeName(Src);
+        unsigned NumTypeParams = LLVMGetTargetExtTypeNumTypeParams(Src);
+        unsigned NumIntParams = LLVMGetTargetExtTypeNumIntParams(Src);
+
+        SmallVector<LLVMTypeRef, 4> TypeParams((size_t)NumTypeParams);
+        SmallVector<unsigned, 4> IntParams((size_t)NumIntParams);
+
+        for (unsigned i = 0; i < TypeParams.size(); i++)
+          TypeParams[i] = Clone(LLVMGetTargetExtTypeTypeParam(Src, i));
+
+        for (unsigned i = 0; i < IntParams.size(); i++)
+          IntParams[i] = LLVMGetTargetExtTypeIntParam(Src, i);
+
+        LLVMTypeRef TargtExtTy = LLVMTargetExtTypeInContext(
----------------
nikic wrote:

```suggestion
        LLVMTypeRef TargetExtTy = LLVMTargetExtTypeInContext(
```
Weird place to save a character :)

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


More information about the llvm-commits mailing list