Skip to content

[CIR] Make PoisonAttr use AttrBuilderWithInferredContext #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,20 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
//===----------------------------------------------------------------------===//

def PoisonAttr : CIR_Attr<"Poison", "poison", [TypedAttrInterface]> {
let summary = "Represent an poison constant";
let summary = "Represent a typed poison constant";
let description = [{
The PoisonAttr represents an poison constant, corresponding to LLVM's notion
of poison.
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
4 changes: 2 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,8 +2201,8 @@ static void vecExtendIntValue(CIRGenFunction &cgf, cir::VectorType argVTy,
// it before inserting.
arg = builder.createIntCast(arg, eltTy);
mlir::Value zero = builder.getConstInt(loc, cgf.SizeTy, 0);
mlir::Value poison = builder.create<cir::ConstantOp>(
loc, builder.getAttr<cir::PoisonAttr>(eltTy));
mlir::Value poison =
builder.create<cir::ConstantOp>(loc, cir::PoisonAttr::get(eltTy));
arg = builder.create<cir::VecInsertOp>(
loc, builder.create<cir::VecSplatOp>(loc, argVTy, poison), arg, zero);
}
Expand Down
Loading