[clang] 903f114 - [CIR] Implement lowering of vectors of _BitInt (#244412)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 16:00:06 PST 2026


Author: Andy Kaylor
Date: 2026-12-02T00:00:00Z
New Revision: 903f11428b60996553f451639ddbe708bbd57545

URL: https://github.com/llvm/llvm-project/commit/903f11428b60996553f451639ddbe708bbd57545
DIFF: https://github.com/llvm/llvm-project/commit/903f11428b60996553f451639ddbe708bbd57545.diff

LOG: [CIR] Implement lowering of vectors of _BitInt (#244412)

Sema allows vectors of _BitInt(N) as long as N is a power-of-two. This
change adds a power-of-two check for _BitInt elements in vector types
and implements lowering of such vectors to LLVM.

This change eliminated most of the unsupported cases in
`unsupported-initializer-types.cir` and
`unsupported-type-conversions.cir` so those tests are being deleted. The
test cases from those files that are still relevant were moved into
`unlowered-address-spaces.cir`.

Assisted-by: Cursor / claude-opus-5.5

Added: 
    clang/test/CIR/CodeGen/bitint-vector.c

Modified: 
    clang/lib/CIR/Dialect/IR/CIRTypes.cpp
    clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
    clang/test/CIR/IR/invalid-vector.cir
    clang/test/CIR/Lowering/unlowered-address-spaces.cir

Removed: 
    clang/test/CIR/Lowering/unsupported-initializer-types.cir
    clang/test/CIR/Lowering/unsupported-type-conversions.cir


################################################################################
diff  --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
index cdb649056365c4..4f4d63de2d510e 100644
--- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
@@ -1702,6 +1702,13 @@ mlir::LogicalResult cir::VectorType::verify(
     if (mlir::isa<cir::MFloat8Type>(elementType) && size.getFixedValue() != 8 &&
         size.getFixedValue() != 16)
       return emitError() << "a NEON mfp8 vector must have 8 or 16 elements";
+    if (auto intTy = mlir::dyn_cast<cir::IntType>(elementType)) {
+      unsigned width = intTy.getWidth();
+      if (intTy.isBitInt() && !llvm::isPowerOf2_32(width))
+        return emitError() << "a _BitInt vector element type must have a "
+                              "power-of-2 width, got "
+                           << elementType;
+    }
     return success();
   case cir::VectorAbiKind::SVEData: {
     if (auto intTy = mlir::dyn_cast<cir::IntType>(elementType)) {

diff  --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 60cf5efce1e613..a426648bc1645d 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -4948,10 +4948,14 @@ static void prepareTypeConverter(mlir::LLVMTypeConverter &converter,
                                               "aarch64.svcount", {}, {});
   });
   converter.addConversion([&](cir::VectorType type) -> mlir::Type {
-    // Vector-of-_BitInt memory layout is not modeled here (the element would
-    // stay at its literal width); report a conversion failure rather than emit
-    // an unvalidated vector.
-    if (cir::isBitIntType(type.getElementType()))
+    // Sema and the CIR type verifier allow vectors of _BitInt where
+    // the width of the _BitInt is any power of two, but there is an
+    // ongoing problem with the handling of sub-byte _BitInts
+    // (see https://github.com/llvm/llvm-project/issues/244489).
+    // While that is being resolved, we skip the conversion here.
+    // This will result in an NYI diagnostic.
+    if (auto intTy = mlir::dyn_cast<cir::IntType>(type.getElementType());
+        intTy && intTy.isBitInt() && (intTy.getWidth() < 8))
       return {};
     mlir::Type ty = converter.convertType(type.getElementType());
     if (!ty)

diff  --git a/clang/test/CIR/CodeGen/bitint-vector.c b/clang/test/CIR/CodeGen/bitint-vector.c
new file mode 100644
index 00000000000000..f3d0dee2373951
--- /dev/null
+++ b/clang/test/CIR/CodeGen/bitint-vector.c
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefixes=LLVM,LLVMCIR --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefixes=LLVM,OGCG --input-file=%t.ll %s
+
+// A vector of _BitInt(N) lowers to a vector of iN in both its value and its
+// memory form.
+
+typedef _BitInt(32) v4s32 __attribute__((ext_vector_type(4)));
+typedef unsigned _BitInt(16) v4u16 __attribute__((ext_vector_type(4)));
+typedef unsigned _BitInt(8) v8u8 __attribute__((ext_vector_type(8)));
+typedef _BitInt(128) v2s128 __attribute__((ext_vector_type(2)));
+typedef float v4f __attribute__((ext_vector_type(4)));
+
+v4s32 g32 = {1, 2, -3, 4};
+v8u8 g8 = {0, 1, 2, 3, 252, 253, 254, 255};
+v2s128 g128;
+
+// CIR-DAG: cir.global external @g32 = #cir.const_vector<[#cir.int<1> : !s32i_bitint, #cir.int<2> : !s32i_bitint, #cir.int<-3> : !s32i_bitint, #cir.int<4> : !s32i_bitint]> : !cir.vector<4 x !s32i_bitint> align(16)
+// CIR-DAG: cir.global external @g8 = #cir.const_vector<[#cir.int<0> : !u8i_bitint, #cir.int<1> : !u8i_bitint, #cir.int<2> : !u8i_bitint, #cir.int<3> : !u8i_bitint, #cir.int<252> : !u8i_bitint, #cir.int<253> : !u8i_bitint, #cir.int<254> : !u8i_bitint, #cir.int<255> : !u8i_bitint]> : !cir.vector<8 x !u8i_bitint> align(8)
+// CIR-DAG: cir.global external @g128 = #cir.zero : !cir.vector<2 x !s128i_bitint> align(16)
+
+// LLVM-DAG: @g32 = global <4 x i32> <i32 1, i32 2, i32 -3, i32 4>, align 16
+// LLVM-DAG: @g8 = global <8 x i8> <i8 0, i8 1, i8 2, i8 3, i8 -4, i8 -3, i8 -2, i8 -1>, align 8
+// LLVM-DAG: @g128 = global <2 x i128> zeroinitializer, align 16
+
+void arith(v8u8 *p, v2s128 *q) {
+  *p = *p * *p;
+  v2s128 v = *q;
+  v[1] = v[0] + 3;
+  *q = v;
+}
+
+// CIR-LABEL: cir.func {{.*}} @arith
+// CIR:   cir.load {{.*}} : !cir.ptr<!cir.vector<8 x !u8i_bitint>>, !cir.vector<8 x !u8i_bitint>
+// CIR:   cir.mul %{{.*}}, %{{.*}} : !cir.vector<8 x !u8i_bitint>
+// CIR:   cir.vec.extract %{{.*}}[%{{.*}} : !s32i] : !cir.vector<2 x !s128i_bitint>
+// CIR:   cir.vec.insert %{{.*}}, %{{.*}}[%{{.*}} : !s32i] : !cir.vector<2 x !s128i_bitint>
+
+// LLVM-LABEL: define {{.*}} void @arith
+// LLVM:   %[[A:.*]] = load <8 x i8>, ptr %{{.*}}, align 8
+// LLVM:   %[[B:.*]] = load <8 x i8>, ptr %{{.*}}, align 8
+// LLVM:   %[[MUL:.*]] = mul <8 x i8> %[[A]], %[[B]]
+// LLVM:   store <8 x i8> %[[MUL]], ptr %{{.*}}, align 8
+// LLVM:   %[[V:.*]] = load <2 x i128>, ptr %{{.*}}, align 16
+// LLVM:   store <2 x i128> %[[V]], ptr %{{.*}}, align 16
+// LLVM:   %[[V0:.*]] = extractelement <2 x i128> %{{.*}}, i32 0
+// LLVM:   %[[ADD:.*]] = add nsw i128 %[[V0]], 3
+// LLVM:   insertelement <2 x i128> %{{.*}}, i128 %[[ADD]], i32 1
+
+v4s32 select_min(v4s32 a, v4s32 b) { return a < b ? a : b; }
+
+// CIR-LABEL: cir.func {{.*}} @select_min(%{{.*}}: !cir.vector<4 x !s32i_bitint> {{.*}}, %{{.*}}: !cir.vector<4 x !s32i_bitint> {{.*}}) -> !cir.vector<4 x !s32i_bitint>
+// CIR:   cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !s32i_bitint>, !cir.vector<4 x !s32i>
+// CIR:   cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i_bitint>
+
+// LLVM-LABEL: define {{.*}} <4 x i32> @select_min(<4 x i32> {{.*}}, <4 x i32> {{.*}})
+// LLVM:   %[[CMP:.*]] = icmp slt <4 x i32> %{{.*}}, %{{.*}}
+// LLVM:   %[[MASK:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
+// LLVMCIR: %[[COND:.*]] = icmp ne <4 x i32> %[[MASK]], zeroinitializer
+// OGCG:    %[[COND:.*]] = icmp slt <4 x i32> %[[MASK]], zeroinitializer
+// LLVM:   select <4 x i1> %[[COND]], <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
+
+v4f convert(v4s32 a) {
+  v4u16 t = __builtin_convertvector(a, v4u16);
+  return __builtin_convertvector(t, v4f);
+}
+
+// CIR-LABEL: cir.func {{.*}} @convert
+// CIR:   cir.cast integral %{{.*}} : !cir.vector<4 x !s32i_bitint> -> !cir.vector<4 x !u16i_bitint>
+// CIR:   cir.cast int_to_float %{{.*}} : !cir.vector<4 x !u16i_bitint> -> !cir.vector<4 x !cir.float>
+
+// LLVM-LABEL: define {{.*}} <4 x float> @convert(<4 x i32> {{.*}})
+// LLVM:   %[[T:.*]] = trunc <4 x i32> %{{.*}} to <4 x i16>
+// LLVM:   store <4 x i16> %[[T]], ptr %{{.*}}, align 8
+// LLVM:   %[[T2:.*]] = load <4 x i16>, ptr %{{.*}}, align 8
+// LLVM:   uitofp <4 x i16> %[[T2]] to <4 x float>

diff  --git a/clang/test/CIR/IR/invalid-vector.cir b/clang/test/CIR/IR/invalid-vector.cir
index f025365573f955..8ad6309ae03ac8 100644
--- a/clang/test/CIR/IR/invalid-vector.cir
+++ b/clang/test/CIR/IR/invalid-vector.cir
@@ -199,6 +199,17 @@ cir.global external @vec_a = #cir.zero : !cir.vector<0 x !s32i>
 
 // -----
 
+!s24i_bitint = !cir.int<s, 24, bitint>
+
+module  {
+
+// expected-error @below {{a _BitInt vector element type must have a power-of-2 width, got '!cir.int<s, 24, bitint>'}}
+cir.global external @vec_bitint = #cir.zero : !cir.vector<4 x !s24i_bitint>
+
+}
+
+// -----
+
 !s32i = !cir.int<s, 32>
 
 // expected-error @below {{a scalable vector must have a vector kind}}

diff  --git a/clang/test/CIR/Lowering/unlowered-address-spaces.cir b/clang/test/CIR/Lowering/unlowered-address-spaces.cir
index 8a94b7b0457a44..f42f2c0394ac69 100644
--- a/clang/test/CIR/Lowering/unlowered-address-spaces.cir
+++ b/clang/test/CIR/Lowering/unlowered-address-spaces.cir
@@ -1,4 +1,4 @@
-// RUN: cir-opt %s --split-input-file --cir-to-llvm -verify-diagnostics
+// RUN: cir-opt %s --split-input-file --cir-to-llvm -verify-diagnostics | FileCheck %s
 
 !s32i = !cir.int<s, 32>
 
@@ -139,6 +139,29 @@ module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
 
 // -----
 
+!langptr = !cir.ptr<!cir.int<s, 32>, lang_address_space(offload_global)>
+!array = !cir.array<!langptr x 1>
+!ptr = !cir.ptr<!cir.void>
+
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
+  // Conversion failure rolls back the unresolved block address. Stop before
+  // attempting to resolve it against a label that has not been lowered.
+  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.array<!cir.ptr<!cir.int<s, 32>, lang_address_space(offload_global)> x 1>' for symbol @target}}
+  // expected-error @below {{failed to legalize operation 'cir.global'}}
+  cir.global external @view = #cir.const_array<[#cir.block_addr_info<@f, "L"> : !ptr, #cir.global_view<@target, [0 : i32]> : !ptr]> : !cir.array<!ptr x 2>
+
+  cir.func @f() {
+    cir.br ^bb1
+  ^bb1:
+    cir.label "L"
+    cir.return
+  }
+
+  cir.global external @target = #cir.zero : !array
+}
+
+// -----
+
 !s32i = !cir.int<s, 32>
 
 module attributes {cir.triple = "spirv64-unknown-unknown"} {
@@ -330,6 +353,19 @@ module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
 
 // -----
 
+!s64i = !cir.int<s, 64>
+!langptr = !cir.ptr<!cir.void, lang_address_space(offload_global)>
+!rec_U = !cir.union<"U" {data !s64i, data !langptr}>
+
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
+  // An inactive member that cannot be converted does not prevent lowering the
+  // union's integer storage.
+  // CHECK: llvm.mlir.global external @union_inactive_member_language_address_space
+  cir.global external @union_inactive_member_language_address_space = #cir.const_record<{#cir.int<0> : !s64i}> : !rec_U
+}
+
+// -----
+
 !s32i = !cir.int<s, 32>
 
 module attributes {cir.triple = "spirv64-unknown-unknown"} {

diff  --git a/clang/test/CIR/Lowering/unsupported-initializer-types.cir b/clang/test/CIR/Lowering/unsupported-initializer-types.cir
deleted file mode 100644
index 850bb8c7b486ff..00000000000000
--- a/clang/test/CIR/Lowering/unsupported-initializer-types.cir
+++ /dev/null
@@ -1,70 +0,0 @@
-// RUN: cir-opt %s --split-input-file --cir-to-llvm -verify-diagnostics | FileCheck %s
-
-// Vector-of-_BitInt conversion is unsupported; propagate its failure to the
-// enclosing operation and diagnose the active initializer's type.
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!union = !cir.union<"U" {data !cir.int<s, 128>, data !vec}>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // The union's integer storage converts, but its active initializer does not.
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.global'}}
-  cir.global external @global_union = #cir.const_record<{#cir.zero : !vec}> : !union
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!union = !cir.union<"U" {data !cir.int<s, 128>, data !vec}>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  cir.func @constant_union() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.const_record<{#cir.zero : !vec}> : !union
-    cir.return
-  }
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!union = !cir.union<"U" {data !cir.int<s, 128>, data !vec}>
-!outer = !cir.union<"Outer" {data !cir.int<s, 128>, data !union}>
-!record = !cir.struct<"Record" {data !outer}>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Propagate adjustment failure through both the enclosing union and struct.
-  cir.func @nested_union() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.const_record<{#cir.const_record<{#cir.const_record<{#cir.zero : !vec}> : !union}> : !outer}> : !record
-    cir.return
-  }
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!union = !cir.union<"U" {data !cir.int<s, 128>, data !vec}>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  cir.func @array_union() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.const_array<[#cir.const_record<{#cir.zero : !vec}> : !union]> : !cir.array<!union x 1>
-    cir.return
-  }
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!union = !cir.union<"U" {data !cir.int<s, 128>, data !vec}>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // An inactive unsupported member does not prevent lowering integer storage.
-  // CHECK: llvm.mlir.global external @integer_initializer
-  cir.global external @integer_initializer = #cir.const_record<{#cir.int<0> : !cir.int<s, 128>}> : !union
-}

diff  --git a/clang/test/CIR/Lowering/unsupported-type-conversions.cir b/clang/test/CIR/Lowering/unsupported-type-conversions.cir
deleted file mode 100644
index 1a75410dc1a358..00000000000000
--- a/clang/test/CIR/Lowering/unsupported-type-conversions.cir
+++ /dev/null
@@ -1,223 +0,0 @@
-// RUN: cir-opt %s --split-input-file --cir-to-llvm -verify-diagnostics
-
-// Vector-of-_BitInt conversion is unsupported; propagate its failure to the
-// enclosing operation and diagnose the type that cannot be converted.
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.func'}}
-  cir.func private @function_result() -> !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 32, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 32, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.func'}}
-  cir.func private @function_argument(!vec)
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // The initializer requests FuncType conversion before the function lowers.
-  cir.global external @function_view = #cir.global_view<@callee> : !cir.ptr<!cir.void>
-
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.func'}}
-  cir.func private @callee() -> !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  cir.func @constant_result() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.zero : !vec
-    cir.return
-  }
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  cir.func @cast_result() {
-    %0 = cir.const #cir.zero : !cir.vector<4 x !cir.int<s, 7>>
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.cast'}}
-    %1 = cir.cast bitcast %0 : !cir.vector<4 x !cir.int<s, 7>> -> !vec
-    cir.return
-  }
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  cir.func @asm_result() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.asm'}}
-    %0 = cir.asm(x86_att, out = [], in = [], in_out = [], {"" "=r"}) -> !vec
-    cir.return
-  }
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Lower the constant before its target to exercise symbol-type failure.
-  cir.func @constant_global_view() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.global_view<@target, [0 : i32]> : !ptr
-    cir.return
-  }
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Lower the constant before its target to exercise symbol-type failure.
-  cir.func @constant_array_view() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.const_array<[#cir.global_view<@target, [0 : i32]> : !ptr]> : !cir.array<!ptr x 1>
-    cir.return
-  }
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Lower the constant before its target to exercise symbol-type failure.
-  cir.func @constant_record_view() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-    // expected-error @below {{failed to legalize operation 'cir.const'}}
-    %0 = cir.const #cir.const_record<{#cir.global_view<@target, [0 : i32]> : !ptr}> : !cir.struct<{data !ptr}>
-    cir.return
-  }
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Propagate initializer failure before lowering the referenced global.
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.global'}}
-  cir.global external @global_view = #cir.global_view<@target, [0 : i32]> : !ptr
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Conversion failure rolls back the unresolved block address. Stop before
-  // attempting to resolve it against a label that has not been lowered.
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.global'}}
-  cir.global external @block_address_view = #cir.const_array<[#cir.block_addr_info<@f, "L"> : !ptr, #cir.global_view<@target, [0 : i32]> : !ptr]> : !cir.array<!ptr x 2>
-
-  cir.func @f() {
-    cir.br ^bb1
-  ^bb1:
-    cir.label "L"
-    cir.return
-  }
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Propagate initializer failure before lowering the referenced global.
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.global'}}
-  cir.global external @typeinfo_view = #cir.typeinfo<{#cir.global_view<@target, [0 : i32]> : !ptr}> : !cir.struct<{data !ptr}>
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // Propagate initializer failure before lowering the referenced global.
-  // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}}
-  // expected-error @below {{failed to legalize operation 'cir.global'}}
-  cir.global external @vtable_view = #cir.vtable<{#cir.const_array<[#cir.global_view<@target, [0 : i32]> : !ptr]> : !cir.array<!ptr x 1>}, address_points = [#cir.address_point<index = 0, offset = 0>]> : !cir.struct<{data !cir.array<!ptr x 1>}>
-
-  cir.global external @target = #cir.zero : !vec
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // The address point requests the symbol type before the global lowers.
-  cir.func @vtable_symbol() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.struct<{data !cir.array<!cir.vector<4 x !cir.int<s, 7, bitint>> x 1>}>' for vtable symbol @target}}
-    // expected-error @below {{failed to legalize operation 'cir.vtable.address_point'}}
-    %0 = cir.vtable.address_point(@target, address_point = <index = 0, offset = 0>) : !cir.vptr
-    cir.return
-  }
-
-  cir.global "private" external @target : !cir.struct<{data !cir.array<!vec x 1>}>
-}
-
-// -----
-
-!vec = !cir.vector<4 x !cir.int<s, 7, bitint>>
-!ptr = !cir.ptr<!cir.void>
-
-module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
-  // The address point requests the symbol type before the global lowers.
-  cir.func @vtt_symbol() {
-    // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.array<!cir.vector<4 x !cir.int<s, 7, bitint>> x 1>' for vtable symbol @target}}
-    // expected-error @below {{failed to legalize operation 'cir.vtt.address_point'}}
-    %0 = cir.vtt.address_point @target, offset = 0 -> !cir.ptr<!ptr>
-    cir.return
-  }
-
-  cir.global "private" external @target : !cir.array<!vec x 1>
-}


        


More information about the cfe-commits mailing list