llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Amr Hesham (AmrDeveloper) <details> <summary>Changes</summary> Mark sizeof & alignof as NYI for scalable Vector as it depends on using llvm.vscale not just the vector size --- Full diff: https://github.com/llvm/llvm-project/pull/172861.diff 2 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+13) - (modified) clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp (+20-8) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 60884aefbfb1f..1954e20ef9b25 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -2559,6 +2559,19 @@ mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( return builder.getConstant( loc, cir::IntAttr::get(cgf.cgm.uInt64Ty, llvm::APSInt(llvm::APInt(64, 1), true))); + } else if (e->getKind() == UETT_VectorElements) { + auto vecTy = cast<cir::VectorType>(convertType(e->getTypeOfArgument())); + if (vecTy.getIsScalable()) { + cgf.getCIRGenModule().errorNYI( + e->getSourceRange(), + "VisitUnaryExprOrTypeTraitExpr: sizeOf scalable vector"); + return builder.getConstant( + loc, cir::IntAttr::get(cgf.cgm.uInt64Ty, + e->EvaluateKnownConstInt(cgf.getContext()))); + } + + return builder.getConstant( + loc, cir::IntAttr::get(cgf.cgm.uInt64Ty, vecTy.getSize())); } return builder.getConstant( diff --git a/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp b/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp index 071c52a0918e3..3669c45059bd4 100644 --- a/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp +++ b/clang/test/CIR/CodeGen/unary-expr-or-type-trait.cpp @@ -7,20 +7,26 @@ void foo() { unsigned long i = sizeof(int); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long l = sizeof(long); + unsigned long l = sizeof(long); // CHECK: cir.const #cir.int<8> : !u64i - unsigned long f = sizeof(float); + unsigned long f = sizeof(float); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long d = sizeof(double); + unsigned long d = sizeof(double); // CHECK: cir.const #cir.int<8> : !u64i unsigned long iArr = sizeof(int[5]); // CHECK: cir.const #cir.int<20> : !u64i - unsigned long dArr = sizeof(double[5]); + unsigned long dArr = sizeof(double[5]); // CHECK: cir.const #cir.int<40> : !u64i + + unsigned long vi4 = sizeof(int __attribute__((vector_size(4)))); + // CHECK: cir.const #cir.int<4> : !u64i + + unsigned long evi4 = sizeof(int __attribute__((ext_vector_type(4)))); + // CHECK: cir.const #cir.int<16> : !u64i } void foo2() { @@ -30,18 +36,24 @@ void foo2() { unsigned long i = alignof(int); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long l = alignof(long); + unsigned long l = alignof(long); // CHECK: cir.const #cir.int<8> : !u64i - unsigned long f = alignof(float); + unsigned long f = alignof(float); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long d = alignof(double); + unsigned long d = alignof(double); // CHECK: cir.const #cir.int<8> : !u64i unsigned long iArr = alignof(int[5]); // CHECK: cir.const #cir.int<4> : !u64i - unsigned long dArr = alignof(double[5]); + unsigned long dArr = alignof(double[5]); // CHECK: cir.const #cir.int<8> : !u64i + + unsigned long vi4 = alignof(int __attribute__((vector_size(4)))); + // CHECK: cir.const #cir.int<4> : !u64i + + unsigned long evi4 = alignof(int __attribute__((ext_vector_type(4)))); + // CHECK: cir.const #cir.int<16> : !u64i } `````````` </details> https://github.com/llvm/llvm-project/pull/172861 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
