[clang] [CIR]Upstream support for IITDescriptor::Pointer and Vector types (PR #182112)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 12:07:50 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
Author: Priyanshu Kumar (Priyanshu3820)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/182112.diff
2 Files Affected:
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+11)
- (modified) clang/test/CIR/CodeGen/builtins-x86.c (+27)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/182112
More information about the cfe-commits
mailing list