Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 17 additions & 33 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ class CIR_Attr<string name, string attrMnemonic, list<Trait> traits = [],
let mnemonic = attrMnemonic;
}

class CIR_TypedAttr<string name, string attrMnemonic, list<Trait> traits = []>
: CIR_Attr<name, attrMnemonic, !listconcat(traits, [TypedAttrInterface])> {

let parameters = (ins AttributeSelfTypeParameter<"">:$type);

let builders = [
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
return $_get(type.getContext(), type);
}]>
];

let assemblyFormat = [{}];
}

class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
: CIR_Attr<name, attrMnemonic, traits> {
let returnType = "bool";
Expand Down Expand Up @@ -224,65 +238,35 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
// ZeroAttr
//===----------------------------------------------------------------------===//

def ZeroAttr : CIR_Attr<"Zero", "zero", [TypedAttrInterface]> {
def ZeroAttr : CIR_TypedAttr<"Zero", "zero"> {
let summary = "Attribute to represent zero initialization";
let description = [{
The ZeroAttr is used to indicate zero initialization on structs.
}];

let parameters = (ins AttributeSelfTypeParameter<"">:$type);

let builders = [
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
return $_get(type.getContext(), type);
}]>
];

let assemblyFormat = [{}];
}

//===----------------------------------------------------------------------===//
// UndefAttr
//===----------------------------------------------------------------------===//

def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
def UndefAttr : CIR_TypedAttr<"Undef", "undef"> {
let summary = "Represent an undef constant";
let description = [{
The UndefAttr represents an undef constant, corresponding to LLVM's notion
of undef.
}];

let parameters = (ins AttributeSelfTypeParameter<"">:$type);

let builders = [
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
return $_get(type.getContext(), type);
}]>
];

let assemblyFormat = [{}];
}

//===----------------------------------------------------------------------===//
// PoisonAttr
//===----------------------------------------------------------------------===//

def PoisonAttr : CIR_Attr<"Poison", "poison", [TypedAttrInterface]> {
def PoisonAttr : CIR_TypedAttr<"Poison", "poison"> {
let summary = "Represent a typed poison constant";
let description = [{
The PoisonAttr represents a typed poison constant, corresponding to LLVM's
notion of poison.
}];

let parameters = (ins AttributeSelfTypeParameter<"">:$type);

let builders = [
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
return $_get(type.getContext(), type);
}]>
];

let assemblyFormat = [{}];
}

//===----------------------------------------------------------------------===//
Expand Down
Loading