[clang] [CIR] Add preserve_vec_3_type to LangOptions in #cir.lowering_lang_opts (PR #233125)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 17 11:36:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Amr Hesham (AmrDeveloper)
<details>
<summary>Changes</summary>
Add preserve_vec_3_type LangOptions to the lowering_lang_options to be used when lowering the built-in vector type of 3 elements
---
Full diff: https://github.com/llvm/llvm-project/pull/233125.diff
5 Files Affected:
- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+8-6)
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+1)
- (modified) clang/test/CIR/CodeGen/lowering-lang-options.cpp (+1)
- (modified) clang/test/CIR/IR/lowering-lang-options.cir (+2-2)
- (modified) clang/test/CIR/Transforms/lowering-prepare.cir (+1-1)
``````````diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index aa9562586d2f55..ad37e6631c1256 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -2500,10 +2500,10 @@ def CIR_LoweringLangOptionsAttr
Each bool field mirrors the like-named `LangOptions` member: `exceptions`,
`threadsafe_statics`, `cuda`, `cuda_is_device`, `hip`, `hlsl`, `gpu_rdc`,
- `openmp` (`LangOpts.OpenMP != 0`; only its on/off state matters), and
+ `openmp` (`LangOpts.OpenMP != 0`; only its on/off state matters),
`openmp_is_target_device`. `clang_abi_compat` is an `i32` mirroring
- `LangOptions::ClangABI`; it is an `i32` rather than a CIR enum because
- `ClangABI` gains an enumerator every Clang release (see
+ `LangOptions::ClangABI` and `preserve_vec_3_type`; it is an `i32` rather than a
+ CIR enum because `ClangABI` gains an enumerator every Clang release (see
`clang/Basic/ABIVersions.def`), and the ordinal round-trips fine within a
single toolchain.
@@ -2512,7 +2512,8 @@ def CIR_LoweringLangOptionsAttr
module attributes {cir.lowering_lang_options = #cir.lowering_lang_options<
exceptions = false, threadsafe_statics = true, cuda = false,
cuda_is_device = false, hip = false, gpu_rdc = false, openmp = false,
- openmp_is_target_device = false, clang_abi_compat = 17>} { }
+ openmp_is_target_device = false, preserve_vec_3_type = false,
+ clang_abi_compat = 17>} { }
```
}];
@@ -2526,13 +2527,14 @@ def CIR_LoweringLangOptionsAttr
"bool":$gpu_rdc,
"bool":$openmp,
"bool":$openmp_is_target_device,
+ "bool":$preserve_vec_3_type,
"int32_t":$clang_abi_compat
);
let assemblyFormat = [{
`<` struct($exceptions, $threadsafe_statics, $cuda, $cuda_is_device, $hip,
- $hlsl, $gpu_rdc, $openmp, $openmp_is_target_device,
- $clang_abi_compat) `>`
+ $hlsl, $gpu_rdc, $openmp, $openmp_is_target_device,
+ $preserve_vec_3_type, $clang_abi_compat) `>`
}];
let canHaveIllegalCXXABIType = 0;
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 614a731158e455..be297e4267644c 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -195,6 +195,7 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &mlirContext,
/*gpu_rdc=*/langOpts.GPURelocatableDeviceCode,
/*openmp=*/langOpts.OpenMP != 0,
/*openmp_is_target_device=*/langOpts.OpenMPIsTargetDevice,
+ /*preserve_vec_3_type=*/langOpts.PreserveVec3Type,
/*clang_abi_compat=*/
static_cast<int32_t>(langOpts.getClangABICompat())));
diff --git a/clang/test/CIR/CodeGen/lowering-lang-options.cpp b/clang/test/CIR/CodeGen/lowering-lang-options.cpp
index d547e3dce47810..be1a7a546d124b 100644
--- a/clang/test/CIR/CodeGen/lowering-lang-options.cpp
+++ b/clang/test/CIR/CodeGen/lowering-lang-options.cpp
@@ -24,6 +24,7 @@ int x;
// PLAIN-SAME: gpu_rdc = false
// PLAIN-SAME: openmp = false
// PLAIN-SAME: openmp_is_target_device = false
+// PLAIN-SAME: preserve_vec_3_type = false
// PLAIN-SAME: clang_abi_compat = {{[0-9]+}}>
// -fexceptions -fcxx-exceptions flips exceptions. (OpenMP is exercised in the
diff --git a/clang/test/CIR/IR/lowering-lang-options.cir b/clang/test/CIR/IR/lowering-lang-options.cir
index cb1c82eb3d1019..7a67ccb815c2cf 100644
--- a/clang/test/CIR/IR/lowering-lang-options.cir
+++ b/clang/test/CIR/IR/lowering-lang-options.cir
@@ -7,10 +7,10 @@
module attributes {cir.lowering_lang_options = #cir.lowering_lang_options<
exceptions = true, threadsafe_statics = false, cuda = true,
cuda_is_device = true, hip = true, hlsl = true, gpu_rdc = true, openmp = true,
- openmp_is_target_device = true, clang_abi_compat = 9>} {
+ openmp_is_target_device = true, preserve_vec_3_type = true, clang_abi_compat = 9>} {
}
// CHECK: cir.lowering_lang_options = #cir.lowering_lang_options<
// CHECK-SAME: exceptions = true, threadsafe_statics = false, cuda = true,
// CHECK-SAME: cuda_is_device = true, hip = true, hlsl = true, gpu_rdc = true, openmp = true,
-// CHECK-SAME: openmp_is_target_device = true, clang_abi_compat = 9>
+// CHECK-SAME: openmp_is_target_device = true, preserve_vec_3_type = true, clang_abi_compat = 9>
diff --git a/clang/test/CIR/Transforms/lowering-prepare.cir b/clang/test/CIR/Transforms/lowering-prepare.cir
index d535eb0df67687..004af8c606673b 100644
--- a/clang/test/CIR/Transforms/lowering-prepare.cir
+++ b/clang/test/CIR/Transforms/lowering-prepare.cir
@@ -12,7 +12,7 @@ module attributes {
cir.lowering_lang_options = #cir.lowering_lang_options<
exceptions = false, threadsafe_statics = true, cuda = false,
cuda_is_device = false, hip = false, hlsl = false, gpu_rdc = false, openmp = false,
- openmp_is_target_device = false, clang_abi_compat = 16>
+ openmp_is_target_device = false, preserve_vec_3_type = false, clang_abi_compat = 16>
} {
cir.global "private" internal dso_local dynamic_init_guard<"_ZGVZ1gvE1x"> @_ZZ1gvE1x = #cir.int<0> : !s32i align(4) dynamic_init_info<local = true, tls = none, is_inline = false, tsk = undeclared>
``````````
</details>
https://github.com/llvm/llvm-project/pull/233125
More information about the cfe-commits
mailing list