[clang] [CIR] Unify alignment representation (PR #249266)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 5 10:00:31 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clangir
Author: Robert Konicar (Jezurko)
<details>
<summary>Changes</summary>
Introduce cir::AlignmentAttr as the single alignment attribute on CIR ops, replacing the various I64Attr forms. It unifies verification (the value must be a positive power of two) and access across ops via the setAlignment / getAlignmentValue helpers.
---
Patch is 85.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/249266.diff
28 Files Affected:
- (modified) clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h (+11-11)
- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+34-1)
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+70-37)
- (modified) clang/lib/CIR/CodeGen/CIRGenAtomic.cpp (+8-5)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuilder.h (+17-16)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+4-3)
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinNVPTX.cpp (+4-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenCUDANV.cpp (+6-5)
- (modified) clang/lib/CIR/CodeGen/CIRGenDecl.cpp (+1-1)
- (modified) clang/lib/CIR/CodeGen/CIRGenExpr.cpp (+13-9)
- (modified) clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp (+2-1)
- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+6-3)
- (modified) clang/lib/CIR/CodeGen/CIRGenFunction.h (+2-2)
- (modified) clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp (+1-1)
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+12-10)
- (modified) clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.cpp (+13-7)
- (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp (+4-2)
- (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+12)
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+11-8)
- (modified) clang/lib/CIR/Dialect/Transforms/EHABILowering.cpp (+3-3)
- (modified) clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp (+4-4)
- (modified) clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp (+15-10)
- (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp (+51-40)
- (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerItaniumCXXABI.cpp (+4-2)
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+54-34)
- (modified) clang/test/CIR/IR/func.cir (+6-6)
- (added) clang/test/CIR/IR/invalid-alignment.cir (+23)
- (modified) clang/unittests/CIR/PointerLikeTest.cpp (+2-2)
``````````diff
diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
index 0d831af4eb54ec..eac1396bef29fd 100644
--- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
+++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h
@@ -378,7 +378,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
cir::LoadOp createLoad(mlir::Location loc, mlir::Value ptr,
bool isVolatile = false, uint64_t alignment = 0,
bool isNontemporal = false) {
- mlir::IntegerAttr alignmentAttr = getAlignmentAttr(alignment);
+ cir::AlignmentAttr alignmentAttr = getAlignmentAttr(alignment);
return cir::LoadOp::create(*this, loc, ptr, /*isDeref=*/false, isVolatile,
isNontemporal, alignmentAttr,
cir::SyncScopeKindAttr{}, cir::MemOrderAttr{},
@@ -479,7 +479,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
}
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType,
- llvm::StringRef name, mlir::IntegerAttr alignment,
+ llvm::StringRef name, cir::AlignmentAttr alignment,
mlir::Value dynAllocSize) {
return cir::AllocaOp::create(*this, loc, addrType, name, alignment,
dynAllocSize);
@@ -489,18 +489,18 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
mlir::Type type, llvm::StringRef name,
clang::CharUnits alignment,
mlir::Value dynAllocSize) {
- mlir::IntegerAttr alignmentAttr = getAlignmentAttr(alignment);
+ cir::AlignmentAttr alignmentAttr = getAlignmentAttr(alignment);
return createAlloca(loc, addrType, name, alignmentAttr, dynAllocSize);
}
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType,
- llvm::StringRef name, mlir::IntegerAttr alignment) {
+ llvm::StringRef name, cir::AlignmentAttr alignment) {
return cir::AllocaOp::create(*this, loc, addrType, name, alignment);
}
mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType,
llvm::StringRef name, clang::CharUnits alignment) {
- mlir::IntegerAttr alignmentAttr = getAlignmentAttr(alignment);
+ cir::AlignmentAttr alignmentAttr = getAlignmentAttr(alignment);
return createAlloca(loc, addrType, name, alignmentAttr);
}
@@ -558,7 +558,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, mlir::Value dst,
bool isVolatile = false, bool isNontemporal = false,
- mlir::IntegerAttr align = {},
+ cir::AlignmentAttr align = {},
cir::SyncScopeKindAttr scope = {},
cir::MemOrderAttr order = {},
cir::TBAATagAttr tbaa = {}) {
@@ -601,7 +601,7 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
mlir::Value createDummyValue(mlir::Location loc, mlir::Type type,
clang::CharUnits alignment) {
- mlir::IntegerAttr alignmentAttr = getAlignmentAttr(alignment);
+ cir::AlignmentAttr alignmentAttr = getAlignmentAttr(alignment);
auto addr = createAlloca(loc, getPointerTo(type), {}, alignmentAttr);
return cir::LoadOp::create(*this, loc, addr, /*isDeref=*/false,
/*isVolatile=*/false, /*nontemporal=*/false,
@@ -1128,16 +1128,16 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
// For 0 alignment, any overload of `getAlignmentAttr` returns an empty
// attribute.
- mlir::IntegerAttr getAlignmentAttr(clang::CharUnits alignment) {
+ cir::AlignmentAttr getAlignmentAttr(clang::CharUnits alignment) {
return getAlignmentAttr(alignment.getQuantity());
}
- mlir::IntegerAttr getAlignmentAttr(llvm::Align alignment) {
+ cir::AlignmentAttr getAlignmentAttr(llvm::Align alignment) {
return getAlignmentAttr(alignment.value());
}
- mlir::IntegerAttr getAlignmentAttr(int64_t alignment) {
- return alignment ? getI64IntegerAttr(alignment) : mlir::IntegerAttr();
+ cir::AlignmentAttr getAlignmentAttr(int64_t alignment) {
+ return cir::AlignmentAttr::getOrEmpty(this->getContext(), alignment);
}
// Materialize an alignment value as a CIR integer constant of the given
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 3ce42fb32f1a8f..7fd87fa869bccf 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -1535,7 +1535,7 @@ def CIR_TargetAddressSpaceAttr : CIR_Attr< "TargetAddressSpace",
The TargetAddressSpaceAttr represents a target-specific numeric address space,
corresponding to the LLVM IR `addrspace` qualifier and the clang
`address_space` attribute.
-
+
A value of zero represents the default address space. The semantics of non-zero
address spaces are target-specific.
@@ -2991,4 +2991,37 @@ def CIR_CXXModuleInitAttr : CIR_Attr<"CXXModuleInit", "cxx_module_init"> {
let canHaveIllegalCXXABIType = 0;
}
+//===----------------------------------------------------------------------===//
+// AlignmentAttr
+//===----------------------------------------------------------------------===//
+
+def CIR_AlignmentAttr : CIR_Attr<"Alignment", "alignment"> {
+ let summary = "Memory alignment in bytes";
+ let description = [{
+ Represents the alignment, in bytes, of memory accesses, allocations and
+ globals. The value must be a positive power of 2; the verifier rejects
+ anything else, including zero. "Alignment unspecified" should be represented
+ by the absence of the attribute.
+
+ ```
+ #cir<alignment 16>
+ ```
+ }];
+
+ let parameters = (ins "uint64_t":$align);
+ let assemblyFormat = "$align";
+ let canHaveIllegalCXXABIType = 0;
+
+ let genVerifyDecl = 1;
+
+ let extraClassDeclaration = [{
+ /// Returns an AlignmentAttr for `align`, or an empty (null) attribute when
+ /// `align` is 0.
+ static AlignmentAttr getOrEmpty(mlir::MLIRContext *ctx,
+ uint64_t align) {
+ return align ? AlignmentAttr::get(ctx, align) : AlignmentAttr();
+ }
+ }];
+}
+
#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 20d1f61eb347f2..e714823b38bbcc 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -253,6 +253,21 @@ defvar CIR_VolatileOrAtomicAccessDecl = [{
}
}];
+// Declares alignment helpers on ops with a CIR_AlignmentAttr.
+defvar CIR_AlignmentDecls = [{
+ /// Set the alignment attribute from a plain integer.
+ void setAlignment(uint64_t align) {
+ getProperties().alignment =
+ cir::AlignmentAttr::getOrEmpty(this->getContext(), align);
+ }
+
+ /// Returns the alignment integer value or 0 if the attribute is not set.
+ uint64_t getAlignmentValue() {
+ auto attr = getProperties().alignment;
+ return attr ? attr.getAlign() : 0;
+ }
+}];
+
//===----------------------------------------------------------------------===//
// CastOp
//===----------------------------------------------------------------------===//
@@ -858,7 +873,7 @@ def CIR_AllocaOp : CIR_Op<"alloca", [
UnitAttr:$constant,
UnitAttr:$cleanup_dest_slot,
UnitAttr:$return_slot,
- ConfinedAttr<I64Attr, [IntMinValue<1>]>:$alignment
+ CIR_AlignmentAttr:$alignment
);
let results = (outs Res<CIR_PointerType, "",
@@ -868,11 +883,11 @@ def CIR_AllocaOp : CIR_Op<"alloca", [
let builders = [
OpBuilder<(ins "mlir::Type":$addr,
"llvm::StringRef":$name,
- "mlir::IntegerAttr":$alignment)>,
+ "cir::AlignmentAttr":$alignment)>,
OpBuilder<(ins "mlir::Type":$addr,
"llvm::StringRef":$name,
- "mlir::IntegerAttr":$alignment,
+ "cir::AlignmentAttr":$alignment,
"mlir::Value":$dynAllocSize),
[{
if (dynAllocSize)
@@ -881,7 +896,7 @@ def CIR_AllocaOp : CIR_Op<"alloca", [
}]>
];
- let extraClassDeclaration = [{
+ let extraClassDeclaration = CIR_AlignmentDecls # [{
mlir::Type getAllocaType() {
return mlir::cast<cir::PointerType>(getAddr().getType()).getPointee();
}
@@ -957,7 +972,7 @@ def CIR_LoadOp : CIR_Op<"load", [
UnitAttr:$isDeref,
UnitAttr:$is_volatile,
UnitAttr:$is_nontemporal,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
OptionalAttr<CIR_SyncScopeKindAttr>:$sync_scope,
OptionalAttr<CIR_MemOrderAttr>:$mem_order,
UnitAttr:$invariant,
@@ -980,18 +995,18 @@ def CIR_LoadOp : CIR_Op<"load", [
OpBuilder<(ins "mlir::Value":$addr), [{
build($_builder, $_state, addr, /*isDeref=*/false,
/*is_volatile=*/false, /*is_nontemporal=*/false,
- /*alignment=*/mlir::IntegerAttr{}, cir::SyncScopeKindAttr{},
+ /*alignment=*/cir::AlignmentAttr{}, cir::SyncScopeKindAttr{},
cir::MemOrderAttr{}, /*invariant=*/false, /*tbaa=*/{});
}]>,
OpBuilder<(ins "mlir::Type":$result, "mlir::Value":$addr), [{
build($_builder, $_state, result, addr, /*isDeref=*/false,
/*is_volatile=*/false, /*is_nontemporal=*/false,
- /*alignment=*/mlir::IntegerAttr{}, cir::SyncScopeKindAttr{},
+ /*alignment=*/cir::AlignmentAttr{}, cir::SyncScopeKindAttr{},
cir::MemOrderAttr{}, /*invariant=*/false, /*tbaa=*/{});
}]>
];
- let extraClassDeclaration = CIR_VolatileOrAtomicAccessDecl;
+ let extraClassDeclaration = !strconcat(CIR_VolatileOrAtomicAccessDecl, CIR_AlignmentDecls);
let customLLVMLoweringConstructorDecl =
LoweringBuilders<(ins "LLVMTBAALowering &":$tbaaLowering)>;
@@ -1029,7 +1044,7 @@ def CIR_VecMaskedLoadOp : CIR_Op<"vec.masked_load", [
Arg<CIR_PointerType, "base address (points to element type)", [MemRead]>:$addr,
CIR_VectorType:$mask,
CIR_VectorType:$pass_thru,
- OptionalAttr<IntValidAlignment<I64Attr>>:$alignment
+ OptionalAttr<CIR_AlignmentAttr>:$alignment
);
let results = (outs CIR_AnyType:$result);
@@ -1084,7 +1099,7 @@ def CIR_StoreOp : CIR_Op<"store", [
[MemWrite]>:$addr,
UnitAttr:$is_volatile,
UnitAttr:$is_nontemporal,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
OptionalAttr<CIR_SyncScopeKindAttr>:$sync_scope,
OptionalAttr<CIR_MemOrderAttr>:$mem_order,
OptionalAttr<CIR_TBAATagAttr>:$tbaa);
@@ -1104,13 +1119,13 @@ def CIR_StoreOp : CIR_Op<"store", [
OpBuilder<(ins "mlir::Value":$value, "mlir::Value":$addr), [{
build($_builder, $_state, value, addr, /*is_volatile=*/mlir::UnitAttr(),
/*is_nontemporal=*/mlir::UnitAttr(),
- /*alignment=*/mlir::IntegerAttr(),
+ /*alignment=*/cir::AlignmentAttr(),
/*sync_scope=*/cir::SyncScopeKindAttr(),
/*mem_order=*/cir::MemOrderAttr(), /*tbaa=*/cir::TBAATagAttr());
}]>
];
- let extraClassDeclaration = CIR_VolatileOrAtomicAccessDecl;
+ let extraClassDeclaration = !strconcat(CIR_VolatileOrAtomicAccessDecl, CIR_AlignmentDecls);
let customLLVMLoweringConstructorDecl =
LoweringBuilders<(ins "LLVMTBAALowering &":$tbaaLowering)>;
@@ -3749,7 +3764,7 @@ def CIR_GlobalOp : CIR_RegionBranchOpBase<"global", [
UnitProp:$dso_local,
UnitAttr:$unnamed_addr,
OptionalAttr<CIR_DynamicInitGuardAttr>:$dynamic_init_guard,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
OptionalAttr<ASTVarDeclInterface>:$ast,
OptionalAttr<CIR_DynamicInitInfoAttr>:$dynamic_init_info,
OptionalAttr<StrAttr>:$section,
@@ -3790,7 +3805,7 @@ def CIR_GlobalOp : CIR_RegionBranchOpBase<"global", [
attr-dict
}];
- let extraClassDeclaration = [{
+ let extraClassDeclaration = CIR_AlignmentDecls # [{
bool isDeclaration() {
// Aliases are always definitions.
if (getAliasee())
@@ -4305,7 +4320,7 @@ def CIR_SetBitfieldOp : CIR_Op<"set_bitfield"> {
Arg<CIR_PointerType, "the address to store the value", [MemWrite]>:$addr,
CIR_AnyType:$src,
CIR_BitfieldInfoAttr:$bitfield_info,
- DefaultValuedOptionalAttr<I64Attr, "0">:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
UnitAttr:$is_volatile
);
@@ -4334,9 +4349,13 @@ def CIR_SetBitfieldOp : CIR_Op<"set_bitfield"> {
BitfieldInfoAttr::get($_builder.getContext(),
name, storage_type,
size, offset, is_signed);
- build($_builder, $_state, type, addr, src, info, alignment, is_volatile);
+ cir::AlignmentAttr alignAttr =
+ cir::AlignmentAttr::getOrEmpty($_builder.getContext(), alignment);
+ build($_builder, $_state, type, addr, src, info, alignAttr, is_volatile);
}]>
];
+
+ let extraClassDeclaration = CIR_AlignmentDecls;
}
//===----------------------------------------------------------------------===//
@@ -4396,7 +4415,7 @@ def CIR_GetBitfieldOp : CIR_Op<"get_bitfield", [
let arguments = (ins
Arg<CIR_PointerType, "the address to load from">:$addr,
CIR_BitfieldInfoAttr:$bitfield_info,
- DefaultValuedOptionalAttr<I64Attr, "0">:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
UnitAttr:$is_volatile
);
@@ -4424,9 +4443,13 @@ def CIR_GetBitfieldOp : CIR_Op<"get_bitfield", [
BitfieldInfoAttr::get($_builder.getContext(),
name, storage_type,
size, offset, is_signed);
- build($_builder, $_state, type, addr, info, alignment, is_volatile);
+ cir::AlignmentAttr alignAttr =
+ cir::AlignmentAttr::getOrEmpty($_builder.getContext(), alignment);
+ build($_builder, $_state, type, addr, info, alignAttr, is_volatile);
}]>
];
+
+ let extraClassDeclaration = CIR_AlignmentDecls;
}
//===----------------------------------------------------------------------===//
@@ -4822,8 +4845,8 @@ def CIR_FuncOp : CIR_Op<"func", [
>:$calling_conv,
OptionalAttr<StrAttr>:$sym_visibility,
OptionalAttr<StrAttr>:$comdat,
- OptionalAttr<I64Attr>:$alignment,
- OptionalAttr<I64Attr>:$preferred_alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$preferred_alignment,
OptionalAttr<DictArrayAttr>:$arg_attrs,
OptionalAttr<DictArrayAttr>:$res_attrs,
OptionalAttr<FlatSymbolRefAttr>:$aliasee,
@@ -4847,7 +4870,7 @@ def CIR_FuncOp : CIR_Op<"func", [
CArg<"cir::CallingConv", "cir::CallingConv::C">:$callingConv)
>];
- let extraClassDeclaration = [{
+ let extraClassDeclaration = CIR_AlignmentDecls # [{
/// Returns the region on the current operation that is callable. This may
/// return null in the case of an external callable object, e.g. an external
/// function.
@@ -4900,7 +4923,7 @@ def CIR_FuncOp : CIR_Op<"func", [
/// trivial default constructor, copy/move constructor, copy/move assignment,
/// or destructor.
bool isCxxTrivialMemberFunction();
-}];
+ }];
let hasCustomAssemblyFormat = 1;
let hasVerifier = 1;
@@ -5958,8 +5981,8 @@ def CIR_CopyOp : CIR_Op<"copy",[
let arguments = (ins
Arg<CIR_PointerType, "", [MemWrite]>:$dst,
Arg<CIR_PointerType, "", [MemRead]>:$src,
- OptionalAttr<I64Attr>:$dst_alignment,
- OptionalAttr<I64Attr>:$src_alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$dst_alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$src_alignment,
UnitAttr:$is_volatile,
UnitAttr:$skip_tail_padding,
OptionalAttr<CIR_TBAAStructFieldArrayAttr>:$tbaa_struct
@@ -5977,8 +6000,8 @@ def CIR_CopyOp : CIR_Op<"copy",[
let builders = [
OpBuilder<(ins "mlir::Value":$dst, "mlir::Value":$src,
- "mlir::IntegerAttr":$dst_alignment,
- "mlir::IntegerAttr":$src_alignment,
+ "cir::AlignmentAttr":$dst_alignment,
+ "cir::AlignmentAttr":$src_alignment,
CArg<"bool", "false">:$is_volatile,
CArg<"bool", "false">:$skip_tail_padding), [{
build($_builder, $_state, dst, src, dst_alignment, src_alignment,
@@ -6044,8 +6067,8 @@ def CIR_MemCpyOp : CIR_MemOp<"libc.memcpy"> {
let arguments = !con(commonArgs, (ins
CIR_AnyFundamentalUIntType:$len,
- OptionalAttr<I64Attr>:$dst_alignment,
- OptionalAttr<I64Attr>:$src_alignment
+ OptionalAttr<CIR_AlignmentAttr>:$dst_alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$src_alignment
));
let assemblyFormat = [{
@@ -6079,8 +6102,8 @@ def CIR_MemMoveOp : CIR_MemOp<"libc.memmove"> {
let arguments = !con(commonArgs, (ins
CIR_AnyFundamentalUIntType:$len,
- OptionalAttr<I64Attr>:$dst_alignment,
- OptionalAttr<I64Attr>:$src_alignment
+ OptionalAttr<CIR_AlignmentAttr>:$dst_alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$src_alignment
));
let assemblyFormat = [{
@@ -6118,7 +6141,7 @@ def CIR_MemSetOp : CIR_Op<"libc.memset"> {
let arguments = (ins
Arg<CIR_VoidPtrType, "", [MemWrite]>:$dst,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
CIR_UInt8:$val,
CIR_AnyFundamentalUIntType:$len
);
@@ -10775,7 +10798,7 @@ def CIR_AtomicFetchOp : CIR_Op<"atomic.fetch", [
CIR_AtomicFetchKindAttr:$binop,
Arg<CIR_MemOrderAttr, "memory order">:$mem_order,
Arg<CIR_SyncScopeKindAttr, "synchronization scope">:$sync_scope,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
UnitAttr:$is_volatile,
UnitAttr:$fetch_first
);
@@ -10803,6 +10826,8 @@ def CIR_AtomicFetchOp : CIR_Op<"atomic.fetch", [
mlir::Value rmwVal, bool isInt,
bool isSigned) const;
}];
+
+ let extraClassDeclaration = CIR_AlignmentDecls;
}
def CIR_AtomicXchgOp : CIR_Op<"atomic.xchg", [
@@ -10833,7 +10858,7 @@ def CIR_AtomicXchgOp : CIR_Op<"atomic.xchg", [
CIR_AnyType:$val,
Arg<CIR_MemOrderAttr, "memory order">:$mem_order,
CIR_SyncScopeKindAttr:$sync_scope,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
UnitAttr:$is_volatile
);
@@ -10900,7 +10925,7 @@ def CIR_AtomicCmpXchgOp : CIR_Op<"atomic.cmpxchg", [
Arg<CIR_MemOrderAttr, "success memory order">:$succ_order,
Arg<CIR_MemOrderAttr, "failure memory order">:$fail_order,
CIR_SyncScopeKindAttr:$sync_scope,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
UnitAttr:$weak,
UnitAttr:$is_volatile);
@@ -10913,6 +10938,8 @@ def CIR_AtomicCmpXchgOp : CIR_Op<"atomic.cmpxchg", [
(`volatile` $is_volatile^)?
`:` functional-type(operands, results) attr-dict
}];
+
+ let extraClassDeclaration = CIR_AlignmentDecls;
}
def CIR_AtomicTestAndSetOp : CIR_Op<"atomic.test_and_set"> {
@@ -10935,7 +10962,7 @@ def CIR_AtomicTestAndSetOp : CIR_Op<"atomic.test_and_set"> {
let arguments = (ins
Arg<CIR_PtrToType<CIR_SInt8>, "", [MemRead, MemWrite]>:$ptr,
Arg<CIR_MemOrderAttr, "memory order">:$mem_order,
- OptionalAttr<I64Attr>:$alignment,
+ OptionalAttr<CIR_AlignmentAttr>:$alignment,
UnitAttr:$is_volatile
);
@@ -10947,6 +10974,8 @@ def CIR_AtomicTestAndSetOp : CIR_Op<"atomic.test_and_set"> {
(`volatile` $is_volatile^)?
`:` qualified(type...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/249266
More information about the cfe-commits
mailing list