[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
xlauko wrote: ### Merge activity * **Apr 22, 2:26 AM EDT**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/136606). https://github.com/llvm/llvm-project/pull/136606 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
xlauko wrote: ### Merge activity * **Apr 22, 2:26 AM EDT**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/136605). https://github.com/llvm/llvm-project/pull/136605 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/136605 >From acad78ff14ab0cd18f8e65a279b0ad5fd13d0c89 Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:03:35 +0200 Subject: [PATCH] [CIR] Make UndefAttr use AttrBuilderWithInferredContext --- clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 7 +++ clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 214db1b1caeeb..dfe15a10fa54e 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -93,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> { }]; let parameters = (ins AttributeSelfTypeParameter<"">:$type); + + let builders = [ +AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{ + return $_get(type.getContext(), type); +}]> + ]; + let assemblyFormat = [{}]; } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index 9cd5c54e6c19e..fe8a5e7428a81 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,8 +34,8 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create( - getLoc(), slot.elemType, builder.getAttr(slot.elemType)); + return builder.create(getLoc(), slot.elemType, + cir::UndefAttr::get(slot.elemType)); } void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/136606 >From 045977803f6459a62ac15a873416730e9e962e77 Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:23:40 +0200 Subject: [PATCH] [CIR] Let ConstantOp builder infer its type automatically --- clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 4 ++-- clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 - clang/lib/CIR/CodeGen/CIRGenBuilder.h| 2 +- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 4 ++-- clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index b303aa07838ee..0385b4f476c3b 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ, const llvm::APInt &val) { -return create(loc, typ, getAttr(typ, val)); +return create(loc, getAttr(typ, val)); } cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) { -return create(loc, attr.getType(), attr); +return create(loc, attr); } cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index b526d077a910c..577cb8db41f57 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const", ``` }]; - // The constant operation takes an attribute as the only input. let arguments = (ins TypedAttrInterface:$value); - - // The constant operation returns a single value of CIR_AnyType. let results = (outs CIR_AnyType:$res); - let builders = [ -OpBuilder<(ins "cir::BoolAttr":$value), [{ - build($_builder, $_state, value.getType(), value); -}]> - ]; - let assemblyFormat = "attr-dict $value"; let hasVerifier = 1; diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 4f7ff5128d914..7d9988cc52c5a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -185,7 +185,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { // Creates constant nullptr for pointer type ty. cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) { assert(!cir::MissingFeatures::targetCodeGenInfoGetNullPointer()); -return create(loc, ty, getConstPtrAttr(ty, 0)); +return create(loc, getConstPtrAttr(ty, 0)); } mlir::Value createNeg(mlir::Value value) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index f1561d1b26fc0..1e69ecae831e9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -138,7 +138,7 @@ class ScalarExprEmitter : public StmtVisitor { mlir::Value VisitIntegerLiteral(const IntegerLiteral *e) { mlir::Type type = cgf.convertType(e->getType()); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } @@ -147,7 +147,7 @@ class ScalarExprEmitter : public StmtVisitor { assert(mlir::isa(type) && "expect floating-point type"); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index fe8a5e7428a81..20b086ffdd850 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,7 +34,7 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create(getLoc(), slot.elemType, + return builder.create(getLoc(), cir::UndefAttr::get(slot.elemType)); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/136606 >From 045977803f6459a62ac15a873416730e9e962e77 Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:23:40 +0200 Subject: [PATCH] [CIR] Let ConstantOp builder infer its type automatically --- clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 4 ++-- clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 - clang/lib/CIR/CodeGen/CIRGenBuilder.h| 2 +- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 4 ++-- clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index b303aa07838ee..0385b4f476c3b 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ, const llvm::APInt &val) { -return create(loc, typ, getAttr(typ, val)); +return create(loc, getAttr(typ, val)); } cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) { -return create(loc, attr.getType(), attr); +return create(loc, attr); } cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index b526d077a910c..577cb8db41f57 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const", ``` }]; - // The constant operation takes an attribute as the only input. let arguments = (ins TypedAttrInterface:$value); - - // The constant operation returns a single value of CIR_AnyType. let results = (outs CIR_AnyType:$res); - let builders = [ -OpBuilder<(ins "cir::BoolAttr":$value), [{ - build($_builder, $_state, value.getType(), value); -}]> - ]; - let assemblyFormat = "attr-dict $value"; let hasVerifier = 1; diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 4f7ff5128d914..7d9988cc52c5a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -185,7 +185,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { // Creates constant nullptr for pointer type ty. cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) { assert(!cir::MissingFeatures::targetCodeGenInfoGetNullPointer()); -return create(loc, ty, getConstPtrAttr(ty, 0)); +return create(loc, getConstPtrAttr(ty, 0)); } mlir::Value createNeg(mlir::Value value) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index f1561d1b26fc0..1e69ecae831e9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -138,7 +138,7 @@ class ScalarExprEmitter : public StmtVisitor { mlir::Value VisitIntegerLiteral(const IntegerLiteral *e) { mlir::Type type = cgf.convertType(e->getType()); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } @@ -147,7 +147,7 @@ class ScalarExprEmitter : public StmtVisitor { assert(mlir::isa(type) && "expect floating-point type"); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index fe8a5e7428a81..20b086ffdd850 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,7 +34,7 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create(getLoc(), slot.elemType, + return builder.create(getLoc(), cir::UndefAttr::get(slot.elemType)); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/136605 >From acad78ff14ab0cd18f8e65a279b0ad5fd13d0c89 Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:03:35 +0200 Subject: [PATCH] [CIR] Make UndefAttr use AttrBuilderWithInferredContext --- clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 7 +++ clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 214db1b1caeeb..dfe15a10fa54e 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -93,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> { }]; let parameters = (ins AttributeSelfTypeParameter<"">:$type); + + let builders = [ +AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{ + return $_get(type.getContext(), type); +}]> + ]; + let assemblyFormat = [{}]; } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index 9cd5c54e6c19e..fe8a5e7428a81 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,8 +34,8 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create( - getLoc(), slot.elemType, builder.getAttr(slot.elemType)); + return builder.create(getLoc(), slot.elemType, + cir::UndefAttr::get(slot.elemType)); } void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/136606 >From 166bf478dde94b6dac144a43a7ececa6cbcb8223 Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:23:40 +0200 Subject: [PATCH] [CIR] Let ConstantOp builder infer its type automatically --- clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 4 ++-- clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 - clang/lib/CIR/CodeGen/CIRGenBuilder.h| 2 +- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 4 ++-- clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index b303aa07838ee..0385b4f476c3b 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ, const llvm::APInt &val) { -return create(loc, typ, getAttr(typ, val)); +return create(loc, getAttr(typ, val)); } cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) { -return create(loc, attr.getType(), attr); +return create(loc, attr); } cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index b526d077a910c..577cb8db41f57 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const", ``` }]; - // The constant operation takes an attribute as the only input. let arguments = (ins TypedAttrInterface:$value); - - // The constant operation returns a single value of CIR_AnyType. let results = (outs CIR_AnyType:$res); - let builders = [ -OpBuilder<(ins "cir::BoolAttr":$value), [{ - build($_builder, $_state, value.getType(), value); -}]> - ]; - let assemblyFormat = "attr-dict $value"; let hasVerifier = 1; diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 4f7ff5128d914..7d9988cc52c5a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -185,7 +185,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { // Creates constant nullptr for pointer type ty. cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) { assert(!cir::MissingFeatures::targetCodeGenInfoGetNullPointer()); -return create(loc, ty, getConstPtrAttr(ty, 0)); +return create(loc, getConstPtrAttr(ty, 0)); } mlir::Value createNeg(mlir::Value value) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index f1561d1b26fc0..1e69ecae831e9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -138,7 +138,7 @@ class ScalarExprEmitter : public StmtVisitor { mlir::Value VisitIntegerLiteral(const IntegerLiteral *e) { mlir::Type type = cgf.convertType(e->getType()); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } @@ -147,7 +147,7 @@ class ScalarExprEmitter : public StmtVisitor { assert(mlir::isa(type) && "expect floating-point type"); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index fe8a5e7428a81..20b086ffdd850 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,7 +34,7 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create(getLoc(), slot.elemType, + return builder.create(getLoc(), cir::UndefAttr::get(slot.elemType)); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/136606 >From 7a8311eddc12d1119338261721de7561297037cb Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:23:40 +0200 Subject: [PATCH] [CIR] Let ConstantOp builder infer its type automatically --- clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 4 ++-- clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 - clang/lib/CIR/CodeGen/CIRGenBuilder.h| 2 +- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 4 ++-- clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index b303aa07838ee..0385b4f476c3b 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ, const llvm::APInt &val) { -return create(loc, typ, getAttr(typ, val)); +return create(loc, getAttr(typ, val)); } cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) { -return create(loc, attr.getType(), attr); +return create(loc, attr); } cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index b526d077a910c..577cb8db41f57 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const", ``` }]; - // The constant operation takes an attribute as the only input. let arguments = (ins TypedAttrInterface:$value); - - // The constant operation returns a single value of CIR_AnyType. let results = (outs CIR_AnyType:$res); - let builders = [ -OpBuilder<(ins "cir::BoolAttr":$value), [{ - build($_builder, $_state, value.getType(), value); -}]> - ]; - let assemblyFormat = "attr-dict $value"; let hasVerifier = 1; diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 4f7ff5128d914..7d9988cc52c5a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -185,7 +185,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { // Creates constant nullptr for pointer type ty. cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) { assert(!cir::MissingFeatures::targetCodeGenInfoGetNullPointer()); -return create(loc, ty, getConstPtrAttr(ty, 0)); +return create(loc, getConstPtrAttr(ty, 0)); } mlir::Value createNeg(mlir::Value value) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index f1561d1b26fc0..1e69ecae831e9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -138,7 +138,7 @@ class ScalarExprEmitter : public StmtVisitor { mlir::Value VisitIntegerLiteral(const IntegerLiteral *e) { mlir::Type type = cgf.convertType(e->getType()); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } @@ -147,7 +147,7 @@ class ScalarExprEmitter : public StmtVisitor { assert(mlir::isa(type) && "expect floating-point type"); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index fe8a5e7428a81..20b086ffdd850 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,7 +34,7 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create(getLoc(), slot.elemType, + return builder.create(getLoc(), cir::UndefAttr::get(slot.elemType)); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/138112 - This cleans up moves cir floating point type constraints to dedicated constraints file, and fixes long double verifier to use constraints directly. - Renames `CIR_AnyFloat` to `CIR_AnyFloatType`. This mirrors inbubator changes from https://github.com/llvm/clangir/pull/1594 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support โ https://githubstatus.com";>GitHub Status โ https://twitter.com/githubstatus";>@githubstatus ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
xlauko wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/138112?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#138112** https://app.graphite.dev/github/pr/llvm/llvm-project/138112?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> ๐ https://app.graphite.dev/github/pr/llvm/llvm-project/138112?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#138106** https://app.graphite.dev/github/pr/llvm/llvm-project/138106?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/138112 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
https://github.com/xlauko ready_for_review https://github.com/llvm/llvm-project/pull/138112 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/138112 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support โ https://githubstatus.com";>GitHub Status โ https://twitter.com/githubstatus";>@githubstatus ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/138112 >From 88149b4832f7a162854edde12975d877f0958ff8 Mon Sep 17 00:00:00 2001 From: xlauko Date: Thu, 1 May 2025 12:48:17 +0200 Subject: [PATCH] [CIR] Refactor floating point type constraints - This cleans up moves cir floating point type constraints to dedicated constraints file, and fixes long double verifier to use constraints directly. - Renames `CIR_AnyFloat` to `CIR_AnyFloatType`. This mirrors inbubator changes from https://github.com/llvm/clangir/pull/1594 --- .../CIR/Dialect/IR/CIRTypeConstraints.td | 31 +++ clang/include/clang/CIR/Dialect/IR/CIRTypes.h | 1 - .../include/clang/CIR/Dialect/IR/CIRTypes.td | 23 +- clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 20 clang/test/CIR/IR/invalid-long-double.cir | 6 5 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 clang/test/CIR/IR/invalid-long-double.cir diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td index 3b8cb20da8edb..10e5d15ff9fa8 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td @@ -110,4 +110,35 @@ def CIR_AnyFundamentalSIntType let cppFunctionName = "isFundamentalSIntType"; } +//===--===// +// Float Type predicates +//===--===// + +def CIR_AnySingleType : CIR_TypeBase<"::cir::SingleType", "single float type">; +def CIR_AnyFP32Type : TypeAlias; + +def CIR_AnyDoubleType : CIR_TypeBase<"::cir::DoubleType", "double float type">; +def CIR_AnyFP64Type : TypeAlias; + +def CIR_AnyFP16Type : CIR_TypeBase<"::cir::FP16Type", "f16 type">; +def CIR_AnyBFloat16Type : CIR_TypeBase<"::cir::BF16Type", "bf16 type">; +def CIR_AnyFP80Type : CIR_TypeBase<"::cir::FP80Type", "f80 type">; +def CIR_AnyFP128Type : CIR_TypeBase<"::cir::FP128Type", "f128 type">; +def CIR_AnyLongDoubleType : CIR_TypeBase<"::cir::LongDoubleType", +"long double type">; + +def CIR_AnyFloatType : AnyTypeOf<[ +CIR_AnySingleType, CIR_AnyDoubleType, CIR_AnyFP16Type, +CIR_AnyBFloat16Type, CIR_AnyFP80Type, CIR_AnyFP128Type, +CIR_AnyLongDoubleType +]> { +let cppFunctionName = "isAnyFloatingPointType"; +} + +def CIR_AnyIntOrFloatType : AnyTypeOf<[CIR_AnyFloatType, CIR_AnyIntType], +"integer or floating point type" +> { +let cppFunctionName = "isAnyIntegerOrFloatingPointType"; +} + #endif // CLANG_CIR_DIALECT_IR_CIRTYPECONSTRAINTS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h index 2e32765c1e941..3845fd2a4b67d 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h @@ -26,7 +26,6 @@ struct RecordTypeStorage; bool isValidFundamentalIntWidth(unsigned width); -bool isAnyFloatingPointType(mlir::Type t); bool isFPOrFPVectorTy(mlir::Type); } // namespace cir diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index d9f05c9aea63d..959e2cd822e76 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -80,12 +80,10 @@ def CIR_IntType : CIR_Type<"Int", "int", // FloatType //===--===// -class CIR_FloatType -: CIR_Type, -DeclareTypeInterfaceMethods, - ]> {} +class CIR_FloatType : CIR_Type, + DeclareTypeInterfaceMethods +]>; def CIR_Single : CIR_FloatType<"Single", "float"> { let summary = "CIR single-precision 32-bit float type"; @@ -155,21 +153,14 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> { format are all in use. }]; - let parameters = (ins "mlir::Type":$underlying); + let parameters = (ins AnyTypeOf<[CIR_Double, CIR_FP80, CIR_FP128], +"expects !cir.double, !cir.fp80 or !cir.fp128">:$underlying); let assemblyFormat = [{ `<` $underlying `>` }]; - - let genVerifyDecl = 1; } -// Constraints - -def CIR_AnyFloat: AnyTypeOf<[CIR_Single, CIR_Double, CIR_FP80, CIR_FP128, - CIR_LongDouble, CIR_FP16, CIR_BFloat16]>; -def CIR_AnyIntOrFloat: AnyTypeOf<[CIR_AnyFloat, CIR_IntType]>; - //===--===// // PointerType //===--===// @@ -518,7 +509,7 @@ def CIRRecordType : Type< def CIR_AnyType : AnyTypeOf<[ CIR_VoidType, CIR_BoolType, CIR_ArrayType, CIR_VectorType, CIR_IntType, - CIR_AnyFloat, CIR_PointerType, CIR_FuncType, CIR_RecordType + CIR_AnyFloatType, CIR_PointerType, CIR_FuncType, CIR_RecordType ]>; #endif // MLIR_CIR_DIALECT_CIR_TYPES diff --git a/cl
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
https://github.com/xlauko updated https://github.com/llvm/llvm-project/pull/138112 >From 88149b4832f7a162854edde12975d877f0958ff8 Mon Sep 17 00:00:00 2001 From: xlauko Date: Thu, 1 May 2025 12:48:17 +0200 Subject: [PATCH] [CIR] Refactor floating point type constraints - This cleans up moves cir floating point type constraints to dedicated constraints file, and fixes long double verifier to use constraints directly. - Renames `CIR_AnyFloat` to `CIR_AnyFloatType`. This mirrors inbubator changes from https://github.com/llvm/clangir/pull/1594 --- .../CIR/Dialect/IR/CIRTypeConstraints.td | 31 +++ clang/include/clang/CIR/Dialect/IR/CIRTypes.h | 1 - .../include/clang/CIR/Dialect/IR/CIRTypes.td | 23 +- clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 20 clang/test/CIR/IR/invalid-long-double.cir | 6 5 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 clang/test/CIR/IR/invalid-long-double.cir diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td index 3b8cb20da8edb..10e5d15ff9fa8 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypeConstraints.td @@ -110,4 +110,35 @@ def CIR_AnyFundamentalSIntType let cppFunctionName = "isFundamentalSIntType"; } +//===--===// +// Float Type predicates +//===--===// + +def CIR_AnySingleType : CIR_TypeBase<"::cir::SingleType", "single float type">; +def CIR_AnyFP32Type : TypeAlias; + +def CIR_AnyDoubleType : CIR_TypeBase<"::cir::DoubleType", "double float type">; +def CIR_AnyFP64Type : TypeAlias; + +def CIR_AnyFP16Type : CIR_TypeBase<"::cir::FP16Type", "f16 type">; +def CIR_AnyBFloat16Type : CIR_TypeBase<"::cir::BF16Type", "bf16 type">; +def CIR_AnyFP80Type : CIR_TypeBase<"::cir::FP80Type", "f80 type">; +def CIR_AnyFP128Type : CIR_TypeBase<"::cir::FP128Type", "f128 type">; +def CIR_AnyLongDoubleType : CIR_TypeBase<"::cir::LongDoubleType", +"long double type">; + +def CIR_AnyFloatType : AnyTypeOf<[ +CIR_AnySingleType, CIR_AnyDoubleType, CIR_AnyFP16Type, +CIR_AnyBFloat16Type, CIR_AnyFP80Type, CIR_AnyFP128Type, +CIR_AnyLongDoubleType +]> { +let cppFunctionName = "isAnyFloatingPointType"; +} + +def CIR_AnyIntOrFloatType : AnyTypeOf<[CIR_AnyFloatType, CIR_AnyIntType], +"integer or floating point type" +> { +let cppFunctionName = "isAnyIntegerOrFloatingPointType"; +} + #endif // CLANG_CIR_DIALECT_IR_CIRTYPECONSTRAINTS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h index 2e32765c1e941..3845fd2a4b67d 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h @@ -26,7 +26,6 @@ struct RecordTypeStorage; bool isValidFundamentalIntWidth(unsigned width); -bool isAnyFloatingPointType(mlir::Type t); bool isFPOrFPVectorTy(mlir::Type); } // namespace cir diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index d9f05c9aea63d..959e2cd822e76 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -80,12 +80,10 @@ def CIR_IntType : CIR_Type<"Int", "int", // FloatType //===--===// -class CIR_FloatType -: CIR_Type, -DeclareTypeInterfaceMethods, - ]> {} +class CIR_FloatType : CIR_Type, + DeclareTypeInterfaceMethods +]>; def CIR_Single : CIR_FloatType<"Single", "float"> { let summary = "CIR single-precision 32-bit float type"; @@ -155,21 +153,14 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> { format are all in use. }]; - let parameters = (ins "mlir::Type":$underlying); + let parameters = (ins AnyTypeOf<[CIR_Double, CIR_FP80, CIR_FP128], +"expects !cir.double, !cir.fp80 or !cir.fp128">:$underlying); let assemblyFormat = [{ `<` $underlying `>` }]; - - let genVerifyDecl = 1; } -// Constraints - -def CIR_AnyFloat: AnyTypeOf<[CIR_Single, CIR_Double, CIR_FP80, CIR_FP128, - CIR_LongDouble, CIR_FP16, CIR_BFloat16]>; -def CIR_AnyIntOrFloat: AnyTypeOf<[CIR_AnyFloat, CIR_IntType]>; - //===--===// // PointerType //===--===// @@ -518,7 +509,7 @@ def CIRRecordType : Type< def CIR_AnyType : AnyTypeOf<[ CIR_VoidType, CIR_BoolType, CIR_ArrayType, CIR_VectorType, CIR_IntType, - CIR_AnyFloat, CIR_PointerType, CIR_FuncType, CIR_RecordType + CIR_AnyFloatType, CIR_PointerType, CIR_FuncType, CIR_RecordType ]>; #endif // MLIR_CIR_DIALECT_CIR_TYPES diff --git a/cl
[llvm-branch-commits] [clang] [CIR] Refactor floating point type constraints (PR #138112)
@@ -110,4 +110,35 @@ def CIR_AnyFundamentalSIntType let cppFunctionName = "isFundamentalSIntType"; } +//===--===// +// Float Type predicates +//===--===// + +def CIR_AnySingleType : CIR_TypeBase<"::cir::SingleType", "single float type">; xlauko wrote: I believe it used to make problems when core mlir dialects where included in out of tree projects/dialects. Thats why entire mlir has explicit global scope, though I cannot remember the issue it was causing. https://github.com/llvm/llvm-project/pull/138112 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko edited https://github.com/llvm/llvm-project/pull/136606 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko ready_for_review https://github.com/llvm/llvm-project/pull/136606 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
https://github.com/xlauko edited https://github.com/llvm/llvm-project/pull/136605 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
https://github.com/xlauko ready_for_review https://github.com/llvm/llvm-project/pull/136605 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/136605 None >From 40e72ddd5b2afc2fd83070822bb6aa1294e873fe Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:03:35 +0200 Subject: [PATCH] [CIR] Make UndefAttr use AttrBuilderWithInferredContext --- clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 7 +++ clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 214db1b1caeeb..dfe15a10fa54e 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -93,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> { }]; let parameters = (ins AttributeSelfTypeParameter<"">:$type); + + let builders = [ +AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{ + return $_get(type.getContext(), type); +}]> + ]; + let assemblyFormat = [{}]; } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index 9cd5c54e6c19e..fe8a5e7428a81 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,8 +34,8 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create( - getLoc(), slot.elemType, builder.getAttr(slot.elemType)); + return builder.create(getLoc(), slot.elemType, + cir::UndefAttr::get(slot.elemType)); } void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/136606 None >From 93d5397e3a90d05cb89c6c5fd622cfb01f425321 Mon Sep 17 00:00:00 2001 From: xlauko Date: Mon, 21 Apr 2025 22:23:40 +0200 Subject: [PATCH] [CIR] Let ConstantOp builder infer its type automatically --- clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h | 4 ++-- clang/include/clang/CIR/Dialect/IR/CIROps.td | 9 - clang/lib/CIR/CodeGen/CIRGenBuilder.h| 2 +- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 4 ++-- clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 2 +- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index b303aa07838ee..0385b4f476c3b 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -61,11 +61,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { mlir::Value getConstAPInt(mlir::Location loc, mlir::Type typ, const llvm::APInt &val) { -return create(loc, typ, getAttr(typ, val)); +return create(loc, getAttr(typ, val)); } cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr) { -return create(loc, attr.getType(), attr); +return create(loc, attr); } cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index b526d077a910c..577cb8db41f57 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -288,18 +288,9 @@ def ConstantOp : CIR_Op<"const", ``` }]; - // The constant operation takes an attribute as the only input. let arguments = (ins TypedAttrInterface:$value); - - // The constant operation returns a single value of CIR_AnyType. let results = (outs CIR_AnyType:$res); - let builders = [ -OpBuilder<(ins "cir::BoolAttr":$value), [{ - build($_builder, $_state, value.getType(), value); -}]> - ]; - let assemblyFormat = "attr-dict $value"; let hasVerifier = 1; diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 4f7ff5128d914..7d9988cc52c5a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -185,7 +185,7 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy { // Creates constant nullptr for pointer type ty. cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) { assert(!cir::MissingFeatures::targetCodeGenInfoGetNullPointer()); -return create(loc, ty, getConstPtrAttr(ty, 0)); +return create(loc, getConstPtrAttr(ty, 0)); } mlir::Value createNeg(mlir::Value value) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index f1561d1b26fc0..1e69ecae831e9 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -138,7 +138,7 @@ class ScalarExprEmitter : public StmtVisitor { mlir::Value VisitIntegerLiteral(const IntegerLiteral *e) { mlir::Type type = cgf.convertType(e->getType()); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } @@ -147,7 +147,7 @@ class ScalarExprEmitter : public StmtVisitor { assert(mlir::isa(type) && "expect floating-point type"); return builder.create( -cgf.getLoc(e->getExprLoc()), type, +cgf.getLoc(e->getExprLoc()), builder.getAttr(type, e->getValue())); } diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp index fe8a5e7428a81..20b086ffdd850 100644 --- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp @@ -34,7 +34,7 @@ llvm::SmallVector cir::AllocaOp::getPromotableSlots() { Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot, OpBuilder &builder) { - return builder.create(getLoc(), slot.elemType, + return builder.create(getLoc(), cir::UndefAttr::get(slot.elemType)); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
xlauko wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/136605?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#136606** https://app.graphite.dev/github/pr/llvm/llvm-project/136606?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#136605** https://app.graphite.dev/github/pr/llvm/llvm-project/136605?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> ๐ https://app.graphite.dev/github/pr/llvm/llvm-project/136605?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#136604** https://app.graphite.dev/github/pr/llvm/llvm-project/136604?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/136605 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Let ConstantOp builder infer its type automatically (PR #136606)
xlauko wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/136606?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#136606** https://app.graphite.dev/github/pr/llvm/llvm-project/136606?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> ๐ https://app.graphite.dev/github/pr/llvm/llvm-project/136606?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * **#136605** https://app.graphite.dev/github/pr/llvm/llvm-project/136605?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#136604** https://app.graphite.dev/github/pr/llvm/llvm-project/136604?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/136606 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Remove implicit options from tablegen files (PR #138860)
xlauko wrote: ### Merge activity * **May 7, 1:16 PM EDT**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/138860). https://github.com/llvm/llvm-project/pull/138860 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Refactor VoidPtr constraint to CIR_VoidPtrType (PR #138859)
xlauko wrote: ### Merge activity * **May 7, 1:16 PM EDT**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/138859). https://github.com/llvm/llvm-project/pull/138859 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits