From f582e0cd8c7cdcd10a6d789ff3f5df5119c37b14 Mon Sep 17 00:00:00 2001 From: Sirui Mu Date: Thu, 25 Jan 2024 22:07:34 +0800 Subject: [PATCH] Revert removing builtin floating point support --- .../include/clang/CIR/Dialect/IR/CIRTypes.td | 3 +- clang/lib/CIR/CodeGen/CIRGenBuilder.h | 16 +++-- clang/lib/CIR/CodeGen/CIRGenExprConst.cpp | 4 +- clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 16 +++-- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 15 ++-- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 72 ++++++++++++------- .../test/CIR/CodeGen/builtin-floating-point.c | 56 +++++++-------- clang/test/CIR/CodeGen/types.c | 4 +- clang/test/CIR/Lowering/float.cir | 8 +-- 9 files changed, 116 insertions(+), 78 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index fee00be628b5..5350fe1b28c5 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -123,7 +123,8 @@ def CIR_Double : CIR_FloatType<"Double", "double"> { // Constraints -def CIR_AnyFloat: Type()">>; +def CIR_AnyFloat: Type< + CPred<"$_self.isa<::mlir::FloatType, ::mlir::cir::FloatType>()">>; //===----------------------------------------------------------------------===// // PointerType diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 6cbe2396c2ed..ac4b6856a663 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -224,6 +224,8 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { mlir::TypedAttr getZeroInitAttr(mlir::Type ty) { if (ty.isa()) return mlir::cir::IntAttr::get(ty, 0); + if (ty.isa()) + return mlir::FloatAttr::get(ty, 0.0); if (auto fltType = ty.dyn_cast()) return mlir::cir::FloatAttr::getZero(fltType); if (auto arrTy = ty.dyn_cast()) @@ -250,12 +252,18 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { if (const auto intVal = attr.dyn_cast()) return intVal.isNullValue(); - if (const auto fpVal = attr.dyn_cast()) { + if (attr.isa()) { + auto fpVal = [&attr] { + if (auto fpAttr = attr.dyn_cast()) + return fpAttr.getValue(); + return attr.cast().getValue(); + }(); + bool ignored; llvm::APFloat FV(+0.0); - FV.convert(fpVal.getValue().getSemantics(), - llvm::APFloat::rmNearestTiesToEven, &ignored); - return FV.bitwiseIsEqual(fpVal.getValue()); + FV.convert(fpVal.getSemantics(), llvm::APFloat::rmNearestTiesToEven, + &ignored); + return FV.bitwiseIsEqual(fpVal); } if (const auto structVal = attr.dyn_cast()) { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp index 1baa869b9f8f..889bf241f327 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp @@ -1479,7 +1479,9 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value, assert(0 && "not implemented"); else { mlir::Type ty = CGM.getCIRType(DestType); - return CGM.getBuilder().getAttr(ty, Init); + if (ty.isa()) + return CGM.getBuilder().getAttr(ty, Init); + return builder.getFloatAttr(ty, Init); } } case APValue::Array: { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 2bf07696c4d9..58099020cd96 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -164,9 +164,13 @@ class ScalarExprEmitter : public StmtVisitor { } mlir::Value VisitFloatingLiteral(const FloatingLiteral *E) { mlir::Type Ty = CGF.getCIRType(E->getType()); + if (Ty.isa()) + return Builder.create( + CGF.getLoc(E->getExprLoc()), Ty, + Builder.getAttr(Ty, E->getValue())); return Builder.create( CGF.getLoc(E->getExprLoc()), Ty, - Builder.getAttr(Ty, E->getValue())); + Builder.getFloatAttr(Ty, E->getValue())); } mlir::Value VisitCharacterLiteral(const CharacterLiteral *E) { mlir::Type Ty = CGF.getCIRType(E->getType()); @@ -1200,7 +1204,7 @@ mlir::Value ScalarExprEmitter::buildSub(const BinOpInfo &Ops) { llvm_unreachable("NYI"); assert(!UnimplementedFeature::cirVectorType()); - if (Ops.LHS.getType().isa()) { + if (Ops.LHS.getType().isa()) { CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(CGF, Ops.FPFeatures); return Builder.createFSub(Ops.LHS, Ops.RHS); } @@ -1668,7 +1672,7 @@ mlir::Value ScalarExprEmitter::buildScalarCast( llvm_unreachable("NYI: signed bool"); if (CGF.getBuilder().isInt(DstTy)) { CastKind = mlir::cir::CastKind::bool_to_int; - } else if (DstTy.isa()) { + } else if (DstTy.isa()) { CastKind = mlir::cir::CastKind::bool_to_float; } else { llvm_unreachable("Internal error: Cast to unexpected type"); @@ -1676,12 +1680,12 @@ mlir::Value ScalarExprEmitter::buildScalarCast( } else if (CGF.getBuilder().isInt(SrcTy)) { if (CGF.getBuilder().isInt(DstTy)) { CastKind = mlir::cir::CastKind::integral; - } else if (DstTy.isa()) { + } else if (DstTy.isa()) { CastKind = mlir::cir::CastKind::int_to_float; } else { llvm_unreachable("Internal error: Cast to unexpected type"); } - } else if (SrcTy.isa()) { + } else if (SrcTy.isa()) { if (CGF.getBuilder().isInt(DstTy)) { // If we can't recognize overflow as undefined behavior, assume that // overflow saturates. This protects against normal optimizations if we @@ -1691,7 +1695,7 @@ mlir::Value ScalarExprEmitter::buildScalarCast( if (Builder.getIsFPConstrained()) llvm_unreachable("NYI"); CastKind = mlir::cir::CastKind::float_to_int; - } else if (DstTy.isa()) { + } else if (DstTy.isa()) { // TODO: split this to createFPExt/createFPTrunc return Builder.createFloatingCast(Src, DstTy); } else { diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 3f6543d3c3d5..250a46fd4e51 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -299,7 +299,8 @@ static LogicalResult checkConstantTypes(mlir::Operation *op, mlir::Type opType, return success(); } - if (attrType.isa()) { + if (attrType + .isa()) { auto at = attrType.cast(); if (at.getType() != opType) { return op->emitOpError("result type (") @@ -422,13 +423,13 @@ LogicalResult CastOp::verify() { return success(); } case cir::CastKind::floating: { - if (!srcType.dyn_cast() || - !resType.dyn_cast()) + if (!srcType.isa() || + !resType.isa()) return emitOpError() << "requries floating for source and result"; return success(); } case cir::CastKind::float_to_int: { - if (!srcType.dyn_cast()) + if (!srcType.isa()) return emitOpError() << "requires floating for source"; if (!resType.dyn_cast()) return emitOpError() << "requires !IntegerType for result"; @@ -449,7 +450,7 @@ LogicalResult CastOp::verify() { return success(); } case cir::CastKind::float_to_bool: { - if (!srcType.isa()) + if (!srcType.isa()) return emitOpError() << "requires float for source"; if (!resType.isa()) return emitOpError() << "requires !cir.bool for result"; @@ -465,14 +466,14 @@ LogicalResult CastOp::verify() { case cir::CastKind::int_to_float: { if (!srcType.isa()) return emitOpError() << "requires !cir.int for source"; - if (!resType.isa()) + if (!resType.isa()) return emitOpError() << "requires !cir.float for result"; return success(); } case cir::CastKind::bool_to_float: { if (!srcType.isa()) return emitOpError() << "requires !cir.bool for source"; - if (!resType.isa()) + if (!resType.isa()) return emitOpError() << "requires !cir.float for result"; return success(); } diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 25efe44c99c0..ef6fd46ae1f6 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -134,6 +134,15 @@ lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::cir::ConstPtrAttr ptrAttr, } /// FloatAttr visitor. +inline mlir::Value +lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::FloatAttr fltAttr, + mlir::ConversionPatternRewriter &rewriter, + const mlir::TypeConverter *converter) { + auto loc = parentOp->getLoc(); + return rewriter.create( + loc, converter->convertType(fltAttr.getType()), fltAttr.getValue()); +} + inline mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::cir::FloatAttr fltAttr, mlir::ConversionPatternRewriter &rewriter, @@ -304,6 +313,8 @@ lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::Attribute attr, const mlir::TypeConverter *converter) { if (const auto intAttr = attr.dyn_cast()) return lowerCirAttrAsValue(parentOp, intAttr, rewriter, converter); + if (const auto fltAttr = attr.dyn_cast()) + return lowerCirAttrAsValue(parentOp, fltAttr, rewriter, converter); if (const auto fltAttr = attr.dyn_cast()) return lowerCirAttrAsValue(parentOp, fltAttr, rewriter, converter); if (const auto ptrAttr = attr.dyn_cast()) @@ -573,23 +584,33 @@ class CIRCastOpLowering : public mlir::OpConversionPattern { break; } case mlir::cir::CastKind::floating: { - auto dstTy = castOp.getResult().getType().cast(); + auto dstTy = castOp.getResult().getType(); auto srcTy = castOp.getSrc().getType(); - auto llvmSrcVal = adaptor.getOperands().front(); - auto llvmDstTy = - getTypeConverter()->convertType(dstTy).cast(); - if (auto fpSrcTy = srcTy.dyn_cast()) { - if (fpSrcTy.getWidth() > dstTy.getWidth()) - rewriter.replaceOpWithNewOp(castOp, llvmDstTy, - llvmSrcVal); - else - rewriter.replaceOpWithNewOp(castOp, llvmDstTy, - llvmSrcVal); - return mlir::success(); - } + if (!dstTy.isa() || + !srcTy.isa()) + return castOp.emitError() + << "NYI cast from " << srcTy << " to " << dstTy; - return castOp.emitError() << "NYI cast from " << srcTy << " to " << dstTy; + auto llvmSrcVal = adaptor.getOperands().front(); + auto llvmDstTy = dstTy.dyn_cast(); + if (!llvmDstTy) + llvmDstTy = + getTypeConverter()->convertType(dstTy).cast(); + + auto getFloatWidth = [](mlir::Type ty) -> unsigned { + if (auto fltTy = ty.dyn_cast()) + return fltTy.getWidth(); + return ty.cast().getWidth(); + }; + + if (getFloatWidth(srcTy) > getFloatWidth(dstTy)) + rewriter.replaceOpWithNewOp(castOp, llvmDstTy, + llvmSrcVal); + else + rewriter.replaceOpWithNewOp(castOp, llvmDstTy, + llvmSrcVal); + return mlir::success(); } case mlir::cir::CastKind::int_to_ptr: { auto dstTy = castOp.getType().cast(); @@ -993,13 +1014,12 @@ lowerConstArrayAttr(mlir::cir::ConstArrayAttr constArr, if (type.isa()) return convertToDenseElementsAttr( constArr, dims, converter->convertType(type)); - if (auto fltTy = type.dyn_cast()) { - // TODO(lancern): convert all elements in the constant array to proper - // format. - + if (type.isa()) + return convertToDenseElementsAttr( + constArr, dims, converter->convertType(type)); + if (type.isa()) return convertToDenseElementsAttr( constArr, dims, converter->convertType(type)); - } return std::nullopt; } @@ -1025,10 +1045,9 @@ class CIRConstantLowering attr = rewriter.getIntegerAttr( typeConverter->convertType(op.getType()), op.getValue().cast().getValue()); + } else if (op.getType().isa()) { + attr = op.getValue(); } else if (op.getType().isa()) { - // TODO(cir): ppcfp128 format floating-point type is lowered to the - // llvm.ppc_fp128 type, which is not supported by mlir::FloatAttr. How to - // lower a constant op with a value of such type to LLVMIR? attr = rewriter.getFloatAttr( typeConverter->convertType(op.getType()), op.getValue().cast().getValue()); @@ -1478,6 +1497,9 @@ class CIRGlobalOpLowering << constArr.getElts(); return mlir::failure(); } + } else if (llvm::isa(init.value())) { + // Nothing to do since LLVM already supports these types as + // initializers. } else if (auto fltAttr = init.value().dyn_cast()) { // Initializer is a constant floating-point number: convert to MLIR // builtin constant. @@ -1622,7 +1644,7 @@ class CIRUnaryOpLowering } // Floating point unary operations: + - ++ -- - if (elementType.isa()) { + if (elementType.isa()) { switch (op.getKind()) { case mlir::cir::UnaryOpKind::Inc: { assert(!IsVector && "++ not allowed on vector types"); @@ -1701,7 +1723,7 @@ class CIRBinOpLowering : public mlir::OpConversionPattern { assert((op.getLhs().getType() == op.getRhs().getType()) && "inconsistent operands' types not supported yet"); mlir::Type type = op.getRhs().getType(); - assert((type.isa()) && "operand type not supported yet"); @@ -1922,7 +1944,7 @@ class CIRCmpOpLowering : public mlir::OpConversionPattern { auto kind = convertToICmpPredicate(cmpOp.getKind(), /* isSigned=*/false); llResult = rewriter.create( cmpOp.getLoc(), kind, adaptor.getLhs(), adaptor.getRhs()); - } else if (type.isa()) { + } else if (type.isa()) { auto kind = convertToFCmpPredicate(cmpOp.getKind()); llResult = rewriter.create( cmpOp.getLoc(), kind, adaptor.getLhs(), adaptor.getRhs()); diff --git a/clang/test/CIR/CodeGen/builtin-floating-point.c b/clang/test/CIR/CodeGen/builtin-floating-point.c index 0276a6f21214..f09959eabc77 100644 --- a/clang/test/CIR/CodeGen/builtin-floating-point.c +++ b/clang/test/CIR/CodeGen/builtin-floating-point.c @@ -17,7 +17,7 @@ double my_ceil(double f) { long double my_ceill(long double f) { return __builtin_ceill(f); // CHECK: cir.func @my_ceill - // CHECK: {{.+}} = cir.ceil {{.+}} : !cir.float + // CHECK: {{.+}} = cir.ceil {{.+}} : f80 } float ceilf(float); @@ -39,7 +39,7 @@ double call_ceil(double f) { long double call_ceill(long double f) { return ceill(f); // CHECK: cir.func @call_ceill - // CHECK: {{.+}} = cir.ceil {{.+}} : !cir.float + // CHECK: {{.+}} = cir.ceil {{.+}} : f80 } // cos @@ -59,7 +59,7 @@ double my_cos(double f) { long double my_cosl(long double f) { return __builtin_cosl(f); // CHECK: cir.func @my_cosl - // CHECK: {{.+}} = cir.cos {{.+}} : !cir.float + // CHECK: {{.+}} = cir.cos {{.+}} : f80 } float cosf(float); @@ -81,7 +81,7 @@ double call_cos(double f) { long double call_cosl(long double f) { return cosl(f); // CHECK: cir.func @call_cosl - // CHECK: {{.+}} = cir.cos {{.+}} : !cir.float + // CHECK: {{.+}} = cir.cos {{.+}} : f80 } // exp @@ -101,7 +101,7 @@ double my_exp(double f) { long double my_expl(long double f) { return __builtin_expl(f); // CHECK: cir.func @my_expl - // CHECK: {{.+}} = cir.exp {{.+}} : !cir.float + // CHECK: {{.+}} = cir.exp {{.+}} : f80 } float expf(float); @@ -123,7 +123,7 @@ double call_exp(double f) { long double call_expl(long double f) { return expl(f); // CHECK: cir.func @call_expl - // CHECK: {{.+}} = cir.exp {{.+}} : !cir.float + // CHECK: {{.+}} = cir.exp {{.+}} : f80 } // exp2 @@ -143,7 +143,7 @@ double my_exp2(double f) { long double my_exp2l(long double f) { return __builtin_exp2l(f); // CHECK: cir.func @my_exp2l - // CHECK: {{.+}} = cir.exp2 {{.+}} : !cir.float + // CHECK: {{.+}} = cir.exp2 {{.+}} : f80 } float exp2f(float); @@ -165,7 +165,7 @@ double call_exp2(double f) { long double call_exp2l(long double f) { return exp2l(f); // CHECK: cir.func @call_exp2l - // CHECK: {{.+}} = cir.exp2 {{.+}} : !cir.float + // CHECK: {{.+}} = cir.exp2 {{.+}} : f80 } // floor @@ -185,7 +185,7 @@ double my_floor(double f) { long double my_floorl(long double f) { return __builtin_floorl(f); // CHECK: cir.func @my_floorl - // CHECK: {{.+}} = cir.floor {{.+}} : !cir.float + // CHECK: {{.+}} = cir.floor {{.+}} : f80 } float floorf(float); @@ -207,7 +207,7 @@ double call_floor(double f) { long double call_floorl(long double f) { return floorl(f); // CHECK: cir.func @call_floorl - // CHECK: {{.+}} = cir.floor {{.+}} : !cir.float + // CHECK: {{.+}} = cir.floor {{.+}} : f80 } // log @@ -227,7 +227,7 @@ double my_log(double f) { long double my_logl(long double f) { return __builtin_logl(f); // CHECK: cir.func @my_logl - // CHECK: {{.+}} = cir.log {{.+}} : !cir.float + // CHECK: {{.+}} = cir.log {{.+}} : f80 } float logf(float); @@ -249,7 +249,7 @@ double call_log(double f) { long double call_logl(long double f) { return logl(f); // CHECK: cir.func @call_logl - // CHECK: {{.+}} = cir.log {{.+}} : !cir.float + // CHECK: {{.+}} = cir.log {{.+}} : f80 } // log10 @@ -269,7 +269,7 @@ double my_log10(double f) { long double my_log10l(long double f) { return __builtin_log10l(f); // CHECK: cir.func @my_log10l - // CHECK: {{.+}} = cir.log10 {{.+}} : !cir.float + // CHECK: {{.+}} = cir.log10 {{.+}} : f80 } float log10f(float); @@ -291,7 +291,7 @@ double call_log10(double f) { long double call_log10l(long double f) { return log10l(f); // CHECK: cir.func @call_log10l - // CHECK: {{.+}} = cir.log10 {{.+}} : !cir.float + // CHECK: {{.+}} = cir.log10 {{.+}} : f80 } // log2 @@ -311,7 +311,7 @@ double my_log2(double f) { long double my_log2l(long double f) { return __builtin_log2l(f); // CHECK: cir.func @my_log2l - // CHECK: {{.+}} = cir.log2 {{.+}} : !cir.float + // CHECK: {{.+}} = cir.log2 {{.+}} : f80 } float log2f(float); @@ -333,7 +333,7 @@ double call_log2(double f) { long double call_log2l(long double f) { return log2l(f); // CHECK: cir.func @call_log2l - // CHECK: {{.+}} = cir.log2 {{.+}} : !cir.float + // CHECK: {{.+}} = cir.log2 {{.+}} : f80 } // nearbyint @@ -353,7 +353,7 @@ double my_nearbyint(double f) { long double my_nearbyintl(long double f) { return __builtin_nearbyintl(f); // CHECK: cir.func @my_nearbyintl - // CHECK: {{.+}} = cir.nearbyint {{.+}} : !cir.float + // CHECK: {{.+}} = cir.nearbyint {{.+}} : f80 } float nearbyintf(float); @@ -375,7 +375,7 @@ double call_nearbyint(double f) { long double call_nearbyintl(long double f) { return nearbyintl(f); // CHECK: cir.func @call_nearbyintl - // CHECK: {{.+}} = cir.nearbyint {{.+}} : !cir.float + // CHECK: {{.+}} = cir.nearbyint {{.+}} : f80 } // rint @@ -395,7 +395,7 @@ double my_rint(double f) { long double my_rintl(long double f) { return __builtin_rintl(f); // CHECK: cir.func @my_rintl - // CHECK: {{.+}} = cir.rint {{.+}} : !cir.float + // CHECK: {{.+}} = cir.rint {{.+}} : f80 } float rintf(float); @@ -417,7 +417,7 @@ double call_rint(double f) { long double call_rintl(long double f) { return rintl(f); // CHECK: cir.func @call_rintl - // CHECK: {{.+}} = cir.rint {{.+}} : !cir.float + // CHECK: {{.+}} = cir.rint {{.+}} : f80 } // round @@ -437,7 +437,7 @@ double my_round(double f) { long double my_roundl(long double f) { return __builtin_roundl(f); // CHECK: cir.func @my_roundl - // CHECK: {{.+}} = cir.round {{.+}} : !cir.float + // CHECK: {{.+}} = cir.round {{.+}} : f80 } float roundf(float); @@ -459,7 +459,7 @@ double call_round(double f) { long double call_roundl(long double f) { return roundl(f); // CHECK: cir.func @call_roundl - // CHECK: {{.+}} = cir.round {{.+}} : !cir.float + // CHECK: {{.+}} = cir.round {{.+}} : f80 } // sin @@ -479,7 +479,7 @@ double my_sin(double f) { long double my_sinl(long double f) { return __builtin_sinl(f); // CHECK: cir.func @my_sinl - // CHECK: {{.+}} = cir.sin {{.+}} : !cir.float + // CHECK: {{.+}} = cir.sin {{.+}} : f80 } float sinf(float); @@ -501,7 +501,7 @@ double call_sin(double f) { long double call_sinl(long double f) { return sinl(f); // CHECK: cir.func @call_sinl - // CHECK: {{.+}} = cir.sin {{.+}} : !cir.float + // CHECK: {{.+}} = cir.sin {{.+}} : f80 } // sqrt @@ -521,7 +521,7 @@ double my_sqrt(double f) { long double my_sqrtl(long double f) { return __builtin_sqrtl(f); // CHECK: cir.func @my_sqrtl - // CHECK: {{.+}} = cir.sqrt {{.+}} : !cir.float + // CHECK: {{.+}} = cir.sqrt {{.+}} : f80 } float sqrtf(float); @@ -543,7 +543,7 @@ double call_sqrt(double f) { long double call_sqrtl(long double f) { return sqrtl(f); // CHECK: cir.func @call_sqrtl - // CHECK: {{.+}} = cir.sqrt {{.+}} : !cir.float + // CHECK: {{.+}} = cir.sqrt {{.+}} : f80 } // trunc @@ -563,7 +563,7 @@ double my_trunc(double f) { long double my_truncl(long double f) { return __builtin_truncl(f); // CHECK: cir.func @my_truncl - // CHECK: {{.+}} = cir.trunc {{.+}} : !cir.float + // CHECK: {{.+}} = cir.trunc {{.+}} : f80 } float truncf(float); @@ -585,5 +585,5 @@ double call_trunc(double f) { long double call_truncl(long double f) { return truncl(f); // CHECK: cir.func @call_truncl - // CHECK: {{.+}} = cir.trunc {{.+}} : !cir.float + // CHECK: {{.+}} = cir.trunc {{.+}} : f80 } diff --git a/clang/test/CIR/CodeGen/types.c b/clang/test/CIR/CodeGen/types.c index 2afdb01d59e9..ab20bd4a483d 100644 --- a/clang/test/CIR/CodeGen/types.c +++ b/clang/test/CIR/CodeGen/types.c @@ -30,7 +30,7 @@ bool t9(bool b) { return b; } // CHECK: cir.func @t5(%arg0: !u16i loc({{.*}})) -> !u16i // CHECK: cir.func @t6(%arg0: !cir.float loc({{.*}})) -> !cir.float // CHECK: cir.func @t7(%arg0: !cir.double loc({{.*}})) -> !cir.double -// CHECK: cir.func @t10(%arg0: !cir.float loc({{.*}})) -> !cir.float +// CHECK: cir.func @t10(%arg0: f80 loc({{.*}})) -> f80 // CHECK: cir.func @t8() // CHECK-CPP: cir.func @_Z2t0i(%arg0: !s32i loc({{.*}})) -> !s32i @@ -41,6 +41,6 @@ bool t9(bool b) { return b; } // CHECK-CPP: cir.func @_Z2t5t(%arg0: !u16i loc({{.*}})) -> !u16i // CHECK-CPP: cir.func @_Z2t6f(%arg0: !cir.float loc({{.*}})) -> !cir.float // CHECK-CPP: cir.func @_Z2t7d(%arg0: !cir.double loc({{.*}})) -> !cir.double -// CHECK-CPP: cir.func @{{.+}}t10{{.+}}(%arg0: !cir.float loc({{.*}})) -> !cir.float +// CHECK-CPP: cir.func @{{.+}}t10{{.+}}(%arg0: f80 loc({{.*}})) -> f80 // CHECK-CPP: cir.func @_Z2t8v() // CHECK-CPP: cir.func @_Z2t9b(%arg0: !cir.bool loc({{.*}})) -> !cir.bool diff --git a/clang/test/CIR/Lowering/float.cir b/clang/test/CIR/Lowering/float.cir index cd8924de2fab..f8aed73dc3c9 100644 --- a/clang/test/CIR/Lowering/float.cir +++ b/clang/test/CIR/Lowering/float.cir @@ -3,17 +3,17 @@ module { cir.func @test() { - %0 = cir.const(#cir.float<1.0> : !cir.float) : !cir.float + %0 = cir.const(1.0 : f16) : f16 // CHECK: %0 = llvm.mlir.constant(1.000000e+00 : f16) : f16 %1 = cir.const(#cir.float<1.0> : !cir.float) : !cir.float // CHECK: %1 = llvm.mlir.constant(1.000000e+00 : f32) : f32 %2 = cir.const(#cir.float<1.0> : !cir.double) : !cir.double // CHECK: %2 = llvm.mlir.constant(1.000000e+00 : f64) : f64 - %3 = cir.const(#cir.float<1.0> : !cir.float) : !cir.float + %3 = cir.const(1.0 : f128) : f128 // CHECK: %3 = llvm.mlir.constant(1.000000e+00 : f128) : f128 - %4 = cir.const(#cir.float<1.0> : !cir.float) : !cir.float + %4 = cir.const(1.0 : f80) : f80 // CHECK: %4 = llvm.mlir.constant(1.000000e+00 : f80) : f80 - %5 = cir.const(#cir.float<1.0> : !cir.float) : !cir.float + %5 = cir.const(1.0 : bf16) : bf16 // CHECK: %5 = llvm.mlir.constant(1.000000e+00 : bf16) : bf16 cir.return }