[clang] [CIR]Upstream support for IITDescriptor::Pointer and Vector types (PR #182112)
Priyanshu Kumar via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 20:09:44 PST 2026
https://github.com/Priyanshu3820 updated https://github.com/llvm/llvm-project/pull/182112
>From 5a6d5820d0fa6a7a300b527b7cfae1d57a6a9936 Mon Sep 17 00:00:00 2001
From: Priyanshu <10b.priyanshu at gmail.com>
Date: Thu, 19 Feb 2026 01:21:27 +0530
Subject: [PATCH 1/2] Upstream support for IITDescriptor::Pointer and Vector
types
---
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp | 11 ++++++++++
clang/test/CIR/CodeGen/builtins-x86.c | 27 +++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 87c50585c1afb..049708c0603f9 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -817,6 +817,17 @@ decodeFixedType(CIRGenFunction &cgf,
case IITDescriptor::Integer:
return cir::IntType::get(context, descriptor.Integer_Width,
/*isSigned=*/true);
+ case IITDescriptor::Vector: {
+ mlir::Type elementType = decodeFixedType(cgf, infos, context);
+ unsigned numElements = descriptor.Vector_Width.getFixedValue();
+ return cir::VectorType::get(elementType, numElements);
+ }
+ case IITDescriptor::Pointer: {
+ mlir::Builder builder(context);
+ auto addrSpace = cir::TargetAddressSpaceAttr::get(
+ context, builder.getUI32IntegerAttr(descriptor.Pointer_AddressSpace));
+ return cir::PointerType::get(cir::VoidType::get(context), addrSpace);
+ }
default:
cgf.cgm.errorNYI("Unimplemented intrinsic type descriptor");
return cir::VoidType::get(context);
diff --git a/clang/test/CIR/CodeGen/builtins-x86.c b/clang/test/CIR/CodeGen/builtins-x86.c
index e03cd64e063dc..6c38b02609ed6 100644
--- a/clang/test/CIR/CodeGen/builtins-x86.c
+++ b/clang/test/CIR/CodeGen/builtins-x86.c
@@ -40,3 +40,30 @@ void test_pause(void) {
// OGCG: call void @llvm.x86.sse2.pause()
__builtin_ia32_pause();
}
+
+void test_clflush(void* a){
+ // CIR-LABEL: test_clflush
+ // CIR: cir.call_llvm_intrinsic "x86.sse2.clflush" %{{.*}} : (!cir.ptr<!void, target_address_space(0)>) -> !void
+
+ // LLVM-LABEL: @test_clflush
+ // LLVM: call void @llvm.x86.sse2.clflush(ptr {{.*}})
+
+ // OGCG-LABEL: @test_clflush
+ // OGCG: call void @llvm.x86.sse2.clflush(ptr {{.*}})
+ __builtin_ia32_clflush(a);
+}
+
+typedef float v4f __attribute__((vector_size(16)));
+typedef int v4i __attribute__((vector_size(16)));
+
+v4i test_convertvector(v4f a) {
+ // CIR-LABEL: test_convertvector
+ // CIR: cir.cast float_to_int %{{.*}} : !cir.vector<4 x !cir.float> -> !cir.vector<4 x !s32i>
+
+ // LLVM-LABEL: @test_convertvector
+ // LLVM: fptosi <4 x float> %{{.*}} to <4 x i32>
+
+ // OGCG-LABEL: @test_convertvector
+ // OGCG: fptosi <4 x float> %{{.*}} to <4 x i32>
+ return __builtin_convertvector(a, v4i);
+}
\ No newline at end of file
>From ed23c90210172e858b1f33a7612fbe22acc1f50b Mon Sep 17 00:00:00 2001
From: Priyanshu <10b.priyanshu at gmail.com>
Date: Thu, 19 Feb 2026 09:39:27 +0530
Subject: [PATCH 2/2] Add newline
---
clang/test/CIR/CodeGen/builtins-x86.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/builtins-x86.c b/clang/test/CIR/CodeGen/builtins-x86.c
index 6c38b02609ed6..e56794b566192 100644
--- a/clang/test/CIR/CodeGen/builtins-x86.c
+++ b/clang/test/CIR/CodeGen/builtins-x86.c
@@ -66,4 +66,4 @@ v4i test_convertvector(v4f a) {
// OGCG-LABEL: @test_convertvector
// OGCG: fptosi <4 x float> %{{.*}} to <4 x i32>
return __builtin_convertvector(a, v4i);
-}
\ No newline at end of file
+}
More information about the cfe-commits
mailing list