diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 22058c8cb8e5..f862f3453947 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -215,6 +215,33 @@ def IntAttr : CIR_Attr<"Int", "int", [TypedAttrInterface]> { let hasCustomAssemblyFormat = 1; } +//===----------------------------------------------------------------------===// +// FPAttr +//===----------------------------------------------------------------------===// + +def FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> { + let summary = "An attribute containing a floating-point value"; + let description = [{ + An fp attribute is a literal attribute that represents a floating-point + value of the specified floating-point type. + }]; + let parameters = (ins AttributeSelfTypeParameter<"">:$type, "APFloat":$value); + let builders = [ + AttrBuilderWithInferredContext<(ins "Type":$type, + "const APFloat &":$value), [{ + return $_get(type.getContext(), type, value); + }]>, + ]; + let extraClassDeclaration = [{ + static FPAttr getZero(mlir::Type type); + }]; + let genVerifyDecl = 1; + + let assemblyFormat = [{ + `<` custom($value, ref($type)) `>` + }]; +} + //===----------------------------------------------------------------------===// // ConstPointerAttr //===----------------------------------------------------------------------===// diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 2aa58a38f3fa..ca9b786aadf6 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -2615,8 +2615,8 @@ def IterEndOp : CIR_Op<"iterator_end"> { class UnaryFPToFPBuiltinOp : CIR_Op { - let arguments = (ins AnyFloat:$src); - let results = (outs AnyFloat:$result); + let arguments = (ins CIR_AnyFloat:$src); + let results = (outs CIR_AnyFloat:$result); let summary = "libc builtin equivalent ignoring " "floating point exceptions and errno"; let assemblyFormat = "$src `:` type($src) attr-dict"; diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h index 301c7178cfbf..e62a77ed4269 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.h @@ -16,6 +16,7 @@ #include "mlir/IR/BuiltinAttributes.h" #include "mlir/IR/Types.h" #include "mlir/Interfaces/DataLayoutInterfaces.h" +#include "clang/CIR/Interfaces/CIRFPTypeInterface.h" #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index 06d4b378f80b..442ce90cc54a 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -15,15 +15,18 @@ include "clang/CIR/Dialect/IR/CIRDialect.td" include "clang/CIR/Interfaces/ASTAttrInterfaces.td" +include "clang/CIR/Interfaces/CIRFPTypeInterface.td" include "mlir/Interfaces/DataLayoutInterfaces.td" include "mlir/IR/AttrTypeBase.td" +include "mlir/IR/EnumAttr.td" //===----------------------------------------------------------------------===// // CIR Types //===----------------------------------------------------------------------===// -class CIR_Type traits = []> : - TypeDef { +class CIR_Type traits = [], + string baseCppClass = "::mlir::Type"> + : TypeDef { let mnemonic = typeMnemonic; } @@ -94,6 +97,37 @@ def SInt16 : SInt<16>; def SInt32 : SInt<32>; def SInt64 : SInt<64>; +//===----------------------------------------------------------------------===// +// FloatType +//===----------------------------------------------------------------------===// + +class CIR_FloatType + : CIR_Type, + DeclareTypeInterfaceMethods, + ]> {} + +def CIR_Single : CIR_FloatType<"Single", "float"> { + let summary = "CIR single-precision float type"; + let description = [{ + Floating-point type that represents the `float` type in C/C++. Its + underlying floating-point format is the IEEE-754 binary32 format. + }]; +} + +def CIR_Double : CIR_FloatType<"Double", "double"> { + let summary = "CIR double-precision float type"; + let description = [{ + Floating-point type that represents the `double` type in C/C++. Its + underlying floating-point format is the IEEE-754 binar64 format. + }]; +} + +// Constraints + +def CIR_AnyFloat: AnyTypeOf<[CIR_Single, CIR_Double]>; + //===----------------------------------------------------------------------===// // PointerType //===----------------------------------------------------------------------===// @@ -318,7 +352,7 @@ def CIR_StructType : Type()">, def CIR_AnyType : AnyTypeOf<[ CIR_IntType, CIR_PointerType, CIR_BoolType, CIR_ArrayType, CIR_VectorType, - CIR_FuncType, CIR_VoidType, CIR_StructType, CIR_ExceptionInfo, AnyFloat, + CIR_FuncType, CIR_VoidType, CIR_StructType, CIR_ExceptionInfo, CIR_AnyFloat, ]>; #endif // MLIR_CIR_DIALECT_CIR_TYPES diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h b/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h new file mode 100644 index 000000000000..b2d75d40496f --- /dev/null +++ b/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.h @@ -0,0 +1,22 @@ +//===- CIRFPTypeInterface.h - Interface for CIR FP types -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------------===// +// +// Defines the interface to generically handle CIR floating-point types. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H +#define CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H + +#include "mlir/IR/Types.h" +#include "llvm/ADT/APFloat.h" + +/// Include the tablegen'd interface declarations. +#include "clang/CIR/Interfaces/CIRFPTypeInterface.h.inc" + +#endif // CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H diff --git a/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td b/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td new file mode 100644 index 000000000000..7438c8be52d9 --- /dev/null +++ b/clang/include/clang/CIR/Interfaces/CIRFPTypeInterface.td @@ -0,0 +1,52 @@ +//===- CIRFPTypeInterface.td - CIR FP Interface Definitions -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE +#define MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE + +include "mlir/IR/OpBase.td" + +def CIRFPTypeInterface : TypeInterface<"CIRFPTypeInterface"> { + let description = [{ + Contains helper functions to query properties about a floating-point type. + }]; + let cppNamespace = "::mlir::cir"; + + let methods = [ + InterfaceMethod<[{ + Returns the bit width of this floating-point type. + }], + /*retTy=*/"unsigned", + /*methodName=*/"getWidth", + /*args=*/(ins), + /*methodBody=*/"", + /*defaultImplementation=*/[{ + return llvm::APFloat::semanticsSizeInBits($_type.getFloatSemantics()); + }] + >, + InterfaceMethod<[{ + Return the mantissa width. + }], + /*retTy=*/"unsigned", + /*methodName=*/"getFPMantissaWidth", + /*args=*/(ins), + /*methodBody=*/"", + /*defaultImplementation=*/[{ + return llvm::APFloat::semanticsPrecision($_type.getFloatSemantics()); + }] + >, + InterfaceMethod<[{ + Return the float semantics of this floating-point type. + }], + /*retTy=*/"const llvm::fltSemantics &", + /*methodName=*/"getFloatSemantics" + >, + ]; +} + +#endif // MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE diff --git a/clang/include/clang/CIR/Interfaces/CMakeLists.txt b/clang/include/clang/CIR/Interfaces/CMakeLists.txt index c7132abca833..86fffa3f9307 100644 --- a/clang/include/clang/CIR/Interfaces/CMakeLists.txt +++ b/clang/include/clang/CIR/Interfaces/CMakeLists.txt @@ -20,6 +20,15 @@ function(add_clang_mlir_op_interface interface) add_dependencies(mlir-generic-headers MLIR${interface}IncGen) endfunction() +function(add_clang_mlir_type_interface interface) + set(LLVM_TARGET_DEFINITIONS ${interface}.td) + mlir_tablegen(${interface}.h.inc -gen-type-interface-decls) + mlir_tablegen(${interface}.cpp.inc -gen-type-interface-defs) + add_public_tablegen_target(MLIR${interface}IncGen) + add_dependencies(mlir-generic-headers MLIR${interface}IncGen) +endfunction() + add_clang_mlir_attr_interface(ASTAttrInterfaces) add_clang_mlir_op_interface(CIROpInterfaces) add_clang_mlir_op_interface(CIRLoopOpInterface) +add_clang_mlir_type_interface(CIRFPTypeInterface) diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 19b01c5405b2..c585ac70cffb 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -224,8 +224,10 @@ 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::FPAttr::getZero(fltType); + if (auto fltType = ty.dyn_cast()) + return mlir::cir::FPAttr::getZero(fltType); if (auto arrTy = ty.dyn_cast()) return getZeroAttr(arrTy); if (auto ptrTy = ty.dyn_cast()) @@ -256,12 +258,13 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { if (const auto boolVal = attr.dyn_cast()) return !boolVal.getValue(); - if (const auto fpVal = attr.dyn_cast()) { + if (auto fpAttr = attr.dyn_cast()) { + auto fpVal = fpAttr.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()) { @@ -348,13 +351,11 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { } bool isInt(mlir::Type i) { return i.isa(); } - mlir::FloatType getLongDouble80BitsTy() const { - return typeCache.LongDouble80BitsTy; - } + mlir::Type getLongDouble80BitsTy() const { llvm_unreachable("NYI"); } /// Get the proper floating point type for the given semantics. - mlir::FloatType getFloatTyForFormat(const llvm::fltSemantics &format, - bool useNativeHalf) const { + mlir::Type getFloatTyForFormat(const llvm::fltSemantics &format, + bool useNativeHalf) const { if (&format == &llvm::APFloat::IEEEhalf()) { llvm_unreachable("IEEEhalf float format is NYI"); } @@ -362,9 +363,9 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { if (&format == &llvm::APFloat::BFloat()) llvm_unreachable("BFloat float format is NYI"); if (&format == &llvm::APFloat::IEEEsingle()) - llvm_unreachable("IEEEsingle float format is NYI"); + return typeCache.FloatTy; if (&format == &llvm::APFloat::IEEEdouble()) - llvm_unreachable("IEEEdouble float format is NYI"); + return typeCache.DoubleTy; if (&format == &llvm::APFloat::IEEEquad()) llvm_unreachable("IEEEquad float format is NYI"); if (&format == &llvm::APFloat::PPCDoubleDouble()) @@ -491,9 +492,9 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { } bool isSized(mlir::Type ty) { - if (ty.isIntOrFloat() || - ty.isa()) + if (ty.isa()) return true; assert(0 && "Unimplemented size for type"); return false; diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp index 411e77b6d699..4903c9a8a0f4 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprConst.cpp @@ -1706,7 +1706,9 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const APValue &Value, assert(0 && "not implemented"); else { mlir::Type ty = CGM.getCIRType(DestType); - return builder.getFloatAttr(ty, Init); + assert(ty.isa() && + "expected floating-point type"); + return CGM.getBuilder().getAttr(ty, Init); } } case APValue::Array: { diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 4799f68726c8..bcca17b17e31 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -165,9 +165,11 @@ class ScalarExprEmitter : public StmtVisitor { } mlir::Value VisitFloatingLiteral(const FloatingLiteral *E) { mlir::Type Ty = CGF.getCIRType(E->getType()); + assert(Ty.isa() && + "expect floating-point type"); return Builder.create( CGF.getLoc(E->getExprLoc()), Ty, - Builder.getFloatAttr(Ty, E->getValue())); + Builder.getAttr(Ty, E->getValue())); } mlir::Value VisitCharacterLiteral(const CharacterLiteral *E) { mlir::Type Ty = CGF.getCIRType(E->getType()); @@ -1227,7 +1229,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); } @@ -1701,7 +1703,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"); @@ -1709,12 +1711,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 @@ -1724,7 +1726,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/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index b45a4aa5c8e6..9a00b060c1f2 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -133,11 +133,10 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &context, // TODO: HalfTy // TODO: BFloatTy - FloatTy = builder.getF32Type(); - DoubleTy = builder.getF64Type(); + FloatTy = ::mlir::cir::SingleType::get(builder.getContext()); + DoubleTy = ::mlir::cir::DoubleType::get(builder.getContext()); // TODO(cir): perhaps we should abstract long double variations into a custom // cir.long_double type. Said type would also hold the semantics for lowering. - LongDouble80BitsTy = builder.getF80Type(); // TODO: PointerWidthInBits PointerAlignInBytes = diff --git a/clang/lib/CIR/CodeGen/CIRGenTypeCache.h b/clang/lib/CIR/CodeGen/CIRGenTypeCache.h index 91290001d683..d5900694c43c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypeCache.h +++ b/clang/lib/CIR/CodeGen/CIRGenTypeCache.h @@ -37,7 +37,8 @@ struct CIRGenTypeCache { // mlir::Type HalfTy, BFloatTy; // TODO(cir): perhaps we should abstract long double variations into a custom // cir.long_double type. Said type would also hold the semantics for lowering. - mlir::FloatType FloatTy, DoubleTy, LongDouble80BitsTy; + mlir::cir::SingleType FloatTy; + mlir::cir::DoubleType DoubleTy; /// int mlir::Type UIntTy; diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp index e6362b34b24c..c3fe61896c62 100644 --- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp @@ -37,6 +37,12 @@ static void printStructMembers(mlir::AsmPrinter &p, mlir::ArrayAttr members); static mlir::ParseResult parseStructMembers(::mlir::AsmParser &parser, mlir::ArrayAttr &members); +static void printFloatLiteral(mlir::AsmPrinter &p, llvm::APFloat value, + mlir::Type ty); +static mlir::ParseResult +parseFloatLiteral(mlir::AsmParser &parser, + mlir::FailureOr &value, mlir::Type ty); + #define GET_ATTRDEF_CLASSES #include "clang/CIR/Dialect/IR/CIROpsAttributes.cpp.inc" @@ -295,6 +301,62 @@ LogicalResult IntAttr::verify(function_ref emitError, return success(); } +//===----------------------------------------------------------------------===// +// FPAttr definitions +//===----------------------------------------------------------------------===// + +static void printFloatLiteral(mlir::AsmPrinter &p, llvm::APFloat value, + mlir::Type ty) { + p << value; +} + +static mlir::ParseResult +parseFloatLiteral(mlir::AsmParser &parser, + mlir::FailureOr &value, mlir::Type ty) { + double rawValue; + if (parser.parseFloat(rawValue)) { + return parser.emitError(parser.getCurrentLocation(), + "expected floating-point value"); + } + + auto losesInfo = false; + value.emplace(rawValue); + + auto tyFpInterface = ty.dyn_cast(); + if (!tyFpInterface) { + // Parsing of the current floating-point literal has succeeded, but the + // given attribute type is invalid. This error will be reported later when + // the attribute is being verified. + return success(); + } + + value->convert(tyFpInterface.getFloatSemantics(), + llvm::RoundingMode::TowardZero, &losesInfo); + return success(); +} + +cir::FPAttr cir::FPAttr::getZero(mlir::Type type) { + return get(type, + APFloat::getZero( + type.cast().getFloatSemantics())); +} + +LogicalResult cir::FPAttr::verify(function_ref emitError, + Type type, APFloat value) { + auto fltTypeInterface = type.dyn_cast(); + if (!fltTypeInterface) { + emitError() << "expected floating-point type"; + return failure(); + } + if (APFloat::SemanticsToEnum(fltTypeInterface.getFloatSemantics()) != + APFloat::SemanticsToEnum(value.getSemantics())) { + emitError() << "floating-point semantics mismatch"; + return failure(); + } + + return success(); +} + //===----------------------------------------------------------------------===// // CIR Dialect //===----------------------------------------------------------------------===// diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 3186c5573527..0efaa67df396 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -305,7 +305,7 @@ 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 (") @@ -428,13 +428,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"; @@ -455,7 +455,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"; @@ -471,14 +471,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/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index b87305305097..c4c6b105d9bc 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -25,6 +25,7 @@ #include "mlir/Support/LogicalResult.h" #include "clang/CIR/Interfaces/ASTAttrInterfaces.h" +#include "llvm/ADT/APFloat.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/TypeSwitch.h" @@ -625,6 +626,54 @@ IntType::verify(llvm::function_ref emitError, return mlir::success(); } +//===----------------------------------------------------------------------===// +// Floating-point type definitions +//===----------------------------------------------------------------------===// + +const llvm::fltSemantics &SingleType::getFloatSemantics() const { + return llvm::APFloat::IEEEsingle(); +} + +llvm::TypeSize +SingleType::getTypeSizeInBits(const mlir::DataLayout &dataLayout, + mlir::DataLayoutEntryListRef params) const { + return llvm::TypeSize::getFixed(getWidth()); +} + +uint64_t +SingleType::getABIAlignment(const mlir::DataLayout &dataLayout, + mlir::DataLayoutEntryListRef params) const { + return (uint64_t)(getWidth() / 8); +} + +uint64_t +SingleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout, + ::mlir::DataLayoutEntryListRef params) const { + return (uint64_t)(getWidth() / 8); +} + +const llvm::fltSemantics &DoubleType::getFloatSemantics() const { + return llvm::APFloat::IEEEdouble(); +} + +llvm::TypeSize +DoubleType::getTypeSizeInBits(const mlir::DataLayout &dataLayout, + mlir::DataLayoutEntryListRef params) const { + return llvm::TypeSize::getFixed(getWidth()); +} + +uint64_t +DoubleType::getABIAlignment(const mlir::DataLayout &dataLayout, + mlir::DataLayoutEntryListRef params) const { + return (uint64_t)(getWidth() / 8); +} + +uint64_t +DoubleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout, + ::mlir::DataLayoutEntryListRef params) const { + return (uint64_t)(getWidth() / 8); +} + //===----------------------------------------------------------------------===// // FuncType Definitions //===----------------------------------------------------------------------===// diff --git a/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp b/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp new file mode 100644 index 000000000000..6062a39be7fa --- /dev/null +++ b/clang/lib/CIR/Interfaces/CIRFPTypeInterface.cpp @@ -0,0 +1,14 @@ +//====- CIRFPTypeInterface.cpp - Interface for floating-point types -------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang/CIR/Interfaces/CIRFPTypeInterface.h" + +using namespace mlir::cir; + +/// Include the generated interfaces. +#include "clang/CIR/Interfaces/CIRFPTypeInterface.cpp.inc" diff --git a/clang/lib/CIR/Interfaces/CMakeLists.txt b/clang/lib/CIR/Interfaces/CMakeLists.txt index 84322f4836e0..2f4886d6a93a 100644 --- a/clang/lib/CIR/Interfaces/CMakeLists.txt +++ b/clang/lib/CIR/Interfaces/CMakeLists.txt @@ -2,6 +2,7 @@ add_clang_library(MLIRCIRInterfaces ASTAttrInterfaces.cpp CIROpInterfaces.cpp CIRLoopOpInterface.cpp + CIRFPTypeInterface.cpp ADDITIONAL_HEADER_DIRS ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces @@ -10,6 +11,7 @@ add_clang_library(MLIRCIRInterfaces MLIRCIRASTAttrInterfacesIncGen MLIRCIROpInterfacesIncGen MLIRCIRLoopOpInterfaceIncGen + MLIRCIRFPTypeInterfaceIncGen LINK_LIBS ${dialect_libs} diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index e6cc2664ccb7..b414b5247b0b 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -189,9 +189,9 @@ lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::cir::ConstPtrAttr ptrAttr, loc, converter->convertType(ptrAttr.getType()), ptrVal); } -/// FloatAttr visitor. +/// FPAttr visitor. inline mlir::Value -lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::FloatAttr fltAttr, +lowerCirAttrAsValue(mlir::Operation *parentOp, mlir::cir::FPAttr fltAttr, mlir::ConversionPatternRewriter &rewriter, const mlir::TypeConverter *converter) { auto loc = parentOp->getLoc(); @@ -368,7 +368,7 @@ 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()) + if (const auto fltAttr = attr.dyn_cast()) return lowerCirAttrAsValue(parentOp, fltAttr, rewriter, converter); if (const auto ptrAttr = attr.dyn_cast()) return lowerCirAttrAsValue(parentOp, ptrAttr, rewriter, converter); @@ -621,21 +621,29 @@ 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(); + + if (!dstTy.isa() || + !srcTy.isa()) + return castOp.emitError() + << "NYI cast from " << srcTy << " to " << dstTy; + 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, dstTy, - llvmSrcVal); - else - rewriter.replaceOpWithNewOp(castOp, dstTy, - llvmSrcVal); - return mlir::success(); - } + auto getFloatWidth = [](mlir::Type ty) -> unsigned { + return ty.cast().getWidth(); + }; - return castOp.emitError() << "NYI cast from " << srcTy << " to " << dstTy; + 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(); @@ -1002,10 +1010,11 @@ template <> mlir::APInt getZeroInitFromType(mlir::Type Ty) { } template <> mlir::APFloat getZeroInitFromType(mlir::Type Ty) { - assert((Ty.isF32() || Ty.isF64()) && "only float and double supported"); - if (Ty.isF32()) + assert((Ty.isa()) && + "only float and double supported"); + if (Ty.isF32() || Ty.isa()) return mlir::APFloat(0.f); - if (Ty.isF64()) + if (Ty.isF64() || Ty.isa()) return mlir::APFloat(0.0); llvm_unreachable("NYI"); } @@ -1086,8 +1095,8 @@ lowerConstArrayAttr(mlir::cir::ConstArrayAttr constArr, if (type.isa()) return convertToDenseElementsAttr( constArr, dims, converter->convertType(type)); - if (type.isa()) - return convertToDenseElementsAttr( + if (type.isa()) + return convertToDenseElementsAttr( constArr, dims, converter->convertType(type)); return std::nullopt; @@ -1123,8 +1132,10 @@ 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()) { + attr = rewriter.getFloatAttr( + typeConverter->convertType(op.getType()), + op.getValue().cast().getValue()); } else if (op.getType().isa()) { // Optimize with dedicated LLVM op for null pointers. if (op.getValue().isa()) { @@ -1277,7 +1288,7 @@ class CIRVectorCmpOpLowering op.getLoc(), convertCmpKindToICmpPredicate(op.getKind(), intType.isSigned()), adaptor.getLhs(), adaptor.getRhs()); - } else if (elementType.isa()) { + } else if (elementType.isa()) { bitResult = rewriter.create( op.getLoc(), convertCmpKindToFCmpPredicate(op.getKind()), adaptor.getLhs(), adaptor.getRhs()); @@ -1621,9 +1632,10 @@ 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. + init = rewriter.getFloatAttr(llvmType, fltAttr.getValue()); } // Initializer is a constant integer: convert to MLIR builtin constant. else if (auto intAttr = init.value().dyn_cast()) { @@ -1766,7 +1778,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"); @@ -1845,7 +1857,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"); @@ -2024,7 +2036,7 @@ class CIRCmpOpLowering : public mlir::OpConversionPattern { /* isSigned=*/false); llResult = rewriter.create( cmpOp.getLoc(), kind, adaptor.getLhs(), adaptor.getRhs()); - } else if (type.isa()) { + } else if (type.isa()) { auto kind = convertCmpKindToFCmpPredicate(cmpOp.getKind()); llResult = rewriter.create( cmpOp.getLoc(), kind, adaptor.getLhs(), adaptor.getRhs()); @@ -2261,6 +2273,12 @@ void prepareTypeConverter(mlir::LLVMTypeConverter &converter, // LLVM doesn't work with signed types, so we drop the CIR signs here. return mlir::IntegerType::get(type.getContext(), type.getWidth()); }); + converter.addConversion([&](mlir::cir::SingleType type) -> mlir::Type { + return mlir::FloatType::getF32(type.getContext()); + }); + converter.addConversion([&](mlir::cir::DoubleType type) -> mlir::Type { + return mlir::FloatType::getF64(type.getContext()); + }); converter.addConversion([&](mlir::cir::FuncType type) -> mlir::Type { auto result = converter.convertType(type.getReturnType()); llvm::SmallVector arguments; diff --git a/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp b/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp index 6437664e932f..d413307ce7ba 100644 --- a/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp +++ b/clang/lib/CIR/Lowering/ThroughMLIR/LowerCIRToMLIR.cpp @@ -639,6 +639,12 @@ static mlir::TypeConverter prepareTypeConverter() { converter.addConversion([&](mlir::cir::BoolType type) -> mlir::Type { return mlir::IntegerType::get(type.getContext(), 8); }); + converter.addConversion([&](mlir::cir::SingleType type) -> mlir::Type { + return mlir::FloatType::getF32(type.getContext()); + }); + converter.addConversion([&](mlir::cir::DoubleType type) -> mlir::Type { + return mlir::FloatType::getF64(type.getContext()); + }); converter.addConversion([&](mlir::cir::ArrayType type) -> mlir::Type { auto elementType = converter.convertType(type.getEltType()); return mlir::MemRefType::get(type.getSize(), elementType); diff --git a/clang/test/CIR/CodeGen/array-init.c b/clang/test/CIR/CodeGen/array-init.c index 0caf767a51d5..cdba1e30cb4b 100644 --- a/clang/test/CIR/CodeGen/array-init.c +++ b/clang/test/CIR/CodeGen/array-init.c @@ -30,10 +30,9 @@ void foo() { double bar[] = {9,8,7}; } -// CHECK: %0 = cir.alloca !cir.array, cir.ptr >, ["bar"] {alignment = 16 : i64} -// CHECK-NEXT: %1 = cir.const(#cir.const_array<[9.000000e+00, 8.000000e+00, 7.000000e+00]> : !cir.array) : !cir.array -// CHECK-NEXT: cir.store %1, %0 : !cir.array, cir.ptr > - +// CHECK: %0 = cir.alloca !cir.array, cir.ptr >, ["bar"] {alignment = 16 : i64} +// CHECK-NEXT: %1 = cir.const(#cir.const_array<[#cir.fp<9.000000e+00> : !cir.double, #cir.fp<8.000000e+00> : !cir.double, #cir.fp<7.000000e+00> : !cir.double]> : !cir.array) : !cir.array +// CHECK-NEXT: cir.store %1, %0 : !cir.array, cir.ptr > void bar(int a, int b, int c) { int arr[] = {a,b,c}; } diff --git a/clang/test/CIR/CodeGen/binop.c b/clang/test/CIR/CodeGen/binop.c index c646935de071..02848483a53f 100644 --- a/clang/test/CIR/CodeGen/binop.c +++ b/clang/test/CIR/CodeGen/binop.c @@ -9,5 +9,5 @@ void conditionalResultIimplicitCast(int a, int b, float f) { float y = f && f; // CHECK: %[[#BOOL:]] = cir.ternary // CHECK: %[[#INT:]] = cir.cast(bool_to_int, %[[#BOOL]] : !cir.bool), !s32i - // CHECK: %{{.+}} = cir.cast(int_to_float, %[[#INT]] : !s32i), f32 + // CHECK: %{{.+}} = cir.cast(int_to_float, %[[#INT]] : !s32i), !cir.float } diff --git a/clang/test/CIR/CodeGen/binop.cpp b/clang/test/CIR/CodeGen/binop.cpp index 32aece0f8501..9412146b8658 100644 --- a/clang/test/CIR/CodeGen/binop.cpp +++ b/clang/test/CIR/CodeGen/binop.cpp @@ -103,11 +103,11 @@ void b3(int a, int b, int c, int d) { void testFloatingPointBinOps(float a, float b) { a * b; - // CHECK: cir.binop(mul, %{{.+}}, %{{.+}}) : f32 + // CHECK: cir.binop(mul, %{{.+}}, %{{.+}}) : !cir.float a / b; - // CHECK: cir.binop(div, %{{.+}}, %{{.+}}) : f32 + // CHECK: cir.binop(div, %{{.+}}, %{{.+}}) : !cir.float a + b; - // CHECK: cir.binop(add, %{{.+}}, %{{.+}}) : f32 + // CHECK: cir.binop(add, %{{.+}}, %{{.+}}) : !cir.float a - b; - // CHECK: cir.binop(sub, %{{.+}}, %{{.+}}) : f32 + // CHECK: cir.binop(sub, %{{.+}}, %{{.+}}) : !cir.float } diff --git a/clang/test/CIR/CodeGen/builtin-floating-point.c b/clang/test/CIR/CodeGen/builtin-floating-point.c index 18e268f15785..0b037714247b 100644 --- a/clang/test/CIR/CodeGen/builtin-floating-point.c +++ b/clang/test/CIR/CodeGen/builtin-floating-point.c @@ -5,585 +5,585 @@ float my_ceilf(float f) { return __builtin_ceilf(f); // CHECK: cir.func @my_ceilf - // CHECK: {{.+}} = cir.ceil {{.+}} : f32 + // CHECK: {{.+}} = cir.ceil {{.+}} : !cir.float } double my_ceil(double f) { return __builtin_ceil(f); // CHECK: cir.func @my_ceil - // CHECK: {{.+}} = cir.ceil {{.+}} : f64 + // CHECK: {{.+}} = cir.ceil {{.+}} : !cir.double } -long double my_ceill(long double f) { - return __builtin_ceill(f); - // CHECK: cir.func @my_ceill - // CHECK: {{.+}} = cir.ceil {{.+}} : f80 -} +// long double my_ceill(long double f) { +// return __builtin_ceill(f); +// // DISABLED-CHECK: cir.func @my_ceill +// // DISABLED-CHECK: {{.+}} = cir.ceil {{.+}} : f80 +// } float ceilf(float); double ceil(double); -long double ceill(long double); +// long double ceill(long double); float call_ceilf(float f) { return ceilf(f); // CHECK: cir.func @call_ceilf - // CHECK: {{.+}} = cir.ceil {{.+}} : f32 + // CHECK: {{.+}} = cir.ceil {{.+}} : !cir.float } double call_ceil(double f) { return ceil(f); // CHECK: cir.func @call_ceil - // CHECK: {{.+}} = cir.ceil {{.+}} : f64 + // CHECK: {{.+}} = cir.ceil {{.+}} : !cir.double } -long double call_ceill(long double f) { - return ceill(f); - // CHECK: cir.func @call_ceill - // CHECK: {{.+}} = cir.ceil {{.+}} : f80 -} +// long double call_ceill(long double f) { +// return ceill(f); +// // DISABLED-CHECK: cir.func @call_ceill +// // DISABLED-CHECK: {{.+}} = cir.ceil {{.+}} : f80 +// } // cos float my_cosf(float f) { return __builtin_cosf(f); // CHECK: cir.func @my_cosf - // CHECK: {{.+}} = cir.cos {{.+}} : f32 + // CHECK: {{.+}} = cir.cos {{.+}} : !cir.float } double my_cos(double f) { return __builtin_cos(f); // CHECK: cir.func @my_cos - // CHECK: {{.+}} = cir.cos {{.+}} : f64 + // CHECK: {{.+}} = cir.cos {{.+}} : !cir.double } -long double my_cosl(long double f) { - return __builtin_cosl(f); - // CHECK: cir.func @my_cosl - // CHECK: {{.+}} = cir.cos {{.+}} : f80 -} +// long double my_cosl(long double f) { +// return __builtin_cosl(f); +// // DISABLED-CHECK: cir.func @my_cosl +// // DISABLED-CHECK: {{.+}} = cir.cos {{.+}} : f80 +// } float cosf(float); double cos(double); -long double cosl(long double); +// long double cosl(long double); float call_cosf(float f) { return cosf(f); // CHECK: cir.func @call_cosf - // CHECK: {{.+}} = cir.cos {{.+}} : f32 + // CHECK: {{.+}} = cir.cos {{.+}} : !cir.float } double call_cos(double f) { return cos(f); // CHECK: cir.func @call_cos - // CHECK: {{.+}} = cir.cos {{.+}} : f64 + // CHECK: {{.+}} = cir.cos {{.+}} : !cir.double } -long double call_cosl(long double f) { - return cosl(f); - // CHECK: cir.func @call_cosl - // CHECK: {{.+}} = cir.cos {{.+}} : f80 -} +// long double call_cosl(long double f) { +// return cosl(f); +// // DISABLED-CHECK: cir.func @call_cosl +// // DISABLED-CHECK: {{.+}} = cir.cos {{.+}} : f80 +// } // exp float my_expf(float f) { return __builtin_expf(f); // CHECK: cir.func @my_expf - // CHECK: {{.+}} = cir.exp {{.+}} : f32 + // CHECK: {{.+}} = cir.exp {{.+}} : !cir.float } double my_exp(double f) { return __builtin_exp(f); // CHECK: cir.func @my_exp - // CHECK: {{.+}} = cir.exp {{.+}} : f64 + // CHECK: {{.+}} = cir.exp {{.+}} : !cir.double } -long double my_expl(long double f) { - return __builtin_expl(f); - // CHECK: cir.func @my_expl - // CHECK: {{.+}} = cir.exp {{.+}} : f80 -} +// long double my_expl(long double f) { +// return __builtin_expl(f); +// // DISABLED-CHECK: cir.func @my_expl +// // DISABLED-CHECK: {{.+}} = cir.exp {{.+}} : f80 +// } float expf(float); double exp(double); -long double expl(long double); +// long double expl(long double); float call_expf(float f) { return expf(f); // CHECK: cir.func @call_expf - // CHECK: {{.+}} = cir.exp {{.+}} : f32 + // CHECK: {{.+}} = cir.exp {{.+}} : !cir.float } double call_exp(double f) { return exp(f); // CHECK: cir.func @call_exp - // CHECK: {{.+}} = cir.exp {{.+}} : f64 + // CHECK: {{.+}} = cir.exp {{.+}} : !cir.double } -long double call_expl(long double f) { - return expl(f); - // CHECK: cir.func @call_expl - // CHECK: {{.+}} = cir.exp {{.+}} : f80 -} +// long double call_expl(long double f) { +// return expl(f); +// // DISABLED-CHECK: cir.func @call_expl +// // DISABLED-CHECK: {{.+}} = cir.exp {{.+}} : f80 +// } // exp2 float my_exp2f(float f) { return __builtin_exp2f(f); // CHECK: cir.func @my_exp2f - // CHECK: {{.+}} = cir.exp2 {{.+}} : f32 + // CHECK: {{.+}} = cir.exp2 {{.+}} : !cir.float } double my_exp2(double f) { return __builtin_exp2(f); // CHECK: cir.func @my_exp2 - // CHECK: {{.+}} = cir.exp2 {{.+}} : f64 + // CHECK: {{.+}} = cir.exp2 {{.+}} : !cir.double } -long double my_exp2l(long double f) { - return __builtin_exp2l(f); - // CHECK: cir.func @my_exp2l - // CHECK: {{.+}} = cir.exp2 {{.+}} : f80 -} +// long double my_exp2l(long double f) { +// return __builtin_exp2l(f); +// // DISABLED-CHECK: cir.func @my_exp2l +// // DISABLED-CHECK: {{.+}} = cir.exp2 {{.+}} : f80 +// } float exp2f(float); double exp2(double); -long double exp2l(long double); +// long double exp2l(long double); float call_exp2f(float f) { return exp2f(f); // CHECK: cir.func @call_exp2f - // CHECK: {{.+}} = cir.exp2 {{.+}} : f32 + // CHECK: {{.+}} = cir.exp2 {{.+}} : !cir.float } double call_exp2(double f) { return exp2(f); // CHECK: cir.func @call_exp2 - // CHECK: {{.+}} = cir.exp2 {{.+}} : f64 + // CHECK: {{.+}} = cir.exp2 {{.+}} : !cir.double } -long double call_exp2l(long double f) { - return exp2l(f); - // CHECK: cir.func @call_exp2l - // CHECK: {{.+}} = cir.exp2 {{.+}} : f80 -} +// long double call_exp2l(long double f) { +// return exp2l(f); +// // DISABLED-CHECK: cir.func @call_exp2l +// // DISABLED-CHECK: {{.+}} = cir.exp2 {{.+}} : f80 +// } // floor float my_floorf(float f) { return __builtin_floorf(f); // CHECK: cir.func @my_floorf - // CHECK: {{.+}} = cir.floor {{.+}} : f32 + // CHECK: {{.+}} = cir.floor {{.+}} : !cir.float } double my_floor(double f) { return __builtin_floor(f); // CHECK: cir.func @my_floor - // CHECK: {{.+}} = cir.floor {{.+}} : f64 + // CHECK: {{.+}} = cir.floor {{.+}} : !cir.double } -long double my_floorl(long double f) { - return __builtin_floorl(f); - // CHECK: cir.func @my_floorl - // CHECK: {{.+}} = cir.floor {{.+}} : f80 -} +// long double my_floorl(long double f) { +// return __builtin_floorl(f); +// // DISABLED-CHECK: cir.func @my_floorl +// // DISABLED-CHECK: {{.+}} = cir.floor {{.+}} : f80 +// } float floorf(float); double floor(double); -long double floorl(long double); +// long double floorl(long double); float call_floorf(float f) { return floorf(f); // CHECK: cir.func @call_floorf - // CHECK: {{.+}} = cir.floor {{.+}} : f32 + // CHECK: {{.+}} = cir.floor {{.+}} : !cir.float } double call_floor(double f) { return floor(f); // CHECK: cir.func @call_floor - // CHECK: {{.+}} = cir.floor {{.+}} : f64 + // CHECK: {{.+}} = cir.floor {{.+}} : !cir.double } -long double call_floorl(long double f) { - return floorl(f); - // CHECK: cir.func @call_floorl - // CHECK: {{.+}} = cir.floor {{.+}} : f80 -} +// long double call_floorl(long double f) { +// return floorl(f); +// // DISABLED-CHECK: cir.func @call_floorl +// // DISABLED-CHECK: {{.+}} = cir.floor {{.+}} : f80 +// } // log float my_logf(float f) { return __builtin_logf(f); // CHECK: cir.func @my_logf - // CHECK: {{.+}} = cir.log {{.+}} : f32 + // CHECK: {{.+}} = cir.log {{.+}} : !cir.float } double my_log(double f) { return __builtin_log(f); // CHECK: cir.func @my_log - // CHECK: {{.+}} = cir.log {{.+}} : f64 + // CHECK: {{.+}} = cir.log {{.+}} : !cir.double } -long double my_logl(long double f) { - return __builtin_logl(f); - // CHECK: cir.func @my_logl - // CHECK: {{.+}} = cir.log {{.+}} : f80 -} +// long double my_logl(long double f) { +// return __builtin_logl(f); +// // DISABLED-CHECK: cir.func @my_logl +// // DISABLED-CHECK: {{.+}} = cir.log {{.+}} : f80 +// } float logf(float); double log(double); -long double logl(long double); +// long double logl(long double); float call_logf(float f) { return logf(f); // CHECK: cir.func @call_logf - // CHECK: {{.+}} = cir.log {{.+}} : f32 + // CHECK: {{.+}} = cir.log {{.+}} : !cir.float } double call_log(double f) { return log(f); // CHECK: cir.func @call_log - // CHECK: {{.+}} = cir.log {{.+}} : f64 + // CHECK: {{.+}} = cir.log {{.+}} : !cir.double } -long double call_logl(long double f) { - return logl(f); - // CHECK: cir.func @call_logl - // CHECK: {{.+}} = cir.log {{.+}} : f80 -} +// long double call_logl(long double f) { +// return logl(f); +// // DISABLED-CHECK: cir.func @call_logl +// // DISABLED-CHECK: {{.+}} = cir.log {{.+}} : f80 +// } // log10 float my_log10f(float f) { return __builtin_log10f(f); // CHECK: cir.func @my_log10f - // CHECK: {{.+}} = cir.log10 {{.+}} : f32 + // CHECK: {{.+}} = cir.log10 {{.+}} : !cir.float } double my_log10(double f) { return __builtin_log10(f); // CHECK: cir.func @my_log10 - // CHECK: {{.+}} = cir.log10 {{.+}} : f64 + // CHECK: {{.+}} = cir.log10 {{.+}} : !cir.double } -long double my_log10l(long double f) { - return __builtin_log10l(f); - // CHECK: cir.func @my_log10l - // CHECK: {{.+}} = cir.log10 {{.+}} : f80 -} +// long double my_log10l(long double f) { +// return __builtin_log10l(f); +// // DISABLED-CHECK: cir.func @my_log10l +// // DISABLED-CHECK: {{.+}} = cir.log10 {{.+}} : f80 +// } float log10f(float); double log10(double); -long double log10l(long double); +// long double log10l(long double); float call_log10f(float f) { return log10f(f); // CHECK: cir.func @call_log10f - // CHECK: {{.+}} = cir.log10 {{.+}} : f32 + // CHECK: {{.+}} = cir.log10 {{.+}} : !cir.float } double call_log10(double f) { return log10(f); // CHECK: cir.func @call_log10 - // CHECK: {{.+}} = cir.log10 {{.+}} : f64 + // CHECK: {{.+}} = cir.log10 {{.+}} : !cir.double } -long double call_log10l(long double f) { - return log10l(f); - // CHECK: cir.func @call_log10l - // CHECK: {{.+}} = cir.log10 {{.+}} : f80 -} +// long double call_log10l(long double f) { +// return log10l(f); +// // DISABLED-CHECK: cir.func @call_log10l +// // DISABLED-CHECK: {{.+}} = cir.log10 {{.+}} : f80 +// } // log2 float my_log2f(float f) { return __builtin_log2f(f); // CHECK: cir.func @my_log2f - // CHECK: {{.+}} = cir.log2 {{.+}} : f32 + // CHECK: {{.+}} = cir.log2 {{.+}} : !cir.float } double my_log2(double f) { return __builtin_log2(f); // CHECK: cir.func @my_log2 - // CHECK: {{.+}} = cir.log2 {{.+}} : f64 + // CHECK: {{.+}} = cir.log2 {{.+}} : !cir.double } -long double my_log2l(long double f) { - return __builtin_log2l(f); - // CHECK: cir.func @my_log2l - // CHECK: {{.+}} = cir.log2 {{.+}} : f80 -} +// long double my_log2l(long double f) { +// return __builtin_log2l(f); +// // DISABLED-CHECK: cir.func @my_log2l +// // DISABLED-CHECK: {{.+}} = cir.log2 {{.+}} : f80 +// } float log2f(float); double log2(double); -long double log2l(long double); +// long double log2l(long double); float call_log2f(float f) { return log2f(f); // CHECK: cir.func @call_log2f - // CHECK: {{.+}} = cir.log2 {{.+}} : f32 + // CHECK: {{.+}} = cir.log2 {{.+}} : !cir.float } double call_log2(double f) { return log2(f); // CHECK: cir.func @call_log2 - // CHECK: {{.+}} = cir.log2 {{.+}} : f64 + // CHECK: {{.+}} = cir.log2 {{.+}} : !cir.double } -long double call_log2l(long double f) { - return log2l(f); - // CHECK: cir.func @call_log2l - // CHECK: {{.+}} = cir.log2 {{.+}} : f80 -} +// long double call_log2l(long double f) { +// return log2l(f); +// // DISABLED-CHECK: cir.func @call_log2l +// // DISABLED-CHECK: {{.+}} = cir.log2 {{.+}} : f80 +// } // nearbyint float my_nearbyintf(float f) { return __builtin_nearbyintf(f); // CHECK: cir.func @my_nearbyintf - // CHECK: {{.+}} = cir.nearbyint {{.+}} : f32 + // CHECK: {{.+}} = cir.nearbyint {{.+}} : !cir.float } double my_nearbyint(double f) { return __builtin_nearbyint(f); // CHECK: cir.func @my_nearbyint - // CHECK: {{.+}} = cir.nearbyint {{.+}} : f64 + // CHECK: {{.+}} = cir.nearbyint {{.+}} : !cir.double } -long double my_nearbyintl(long double f) { - return __builtin_nearbyintl(f); - // CHECK: cir.func @my_nearbyintl - // CHECK: {{.+}} = cir.nearbyint {{.+}} : f80 -} +// long double my_nearbyintl(long double f) { +// return __builtin_nearbyintl(f); +// // DISABLED-CHECK: cir.func @my_nearbyintl +// // DISABLED-CHECK: {{.+}} = cir.nearbyint {{.+}} : f80 +// } float nearbyintf(float); double nearbyint(double); -long double nearbyintl(long double); +// long double nearbyintl(long double); float call_nearbyintf(float f) { return nearbyintf(f); // CHECK: cir.func @call_nearbyintf - // CHECK: {{.+}} = cir.nearbyint {{.+}} : f32 + // CHECK: {{.+}} = cir.nearbyint {{.+}} : !cir.float } double call_nearbyint(double f) { return nearbyint(f); // CHECK: cir.func @call_nearbyint - // CHECK: {{.+}} = cir.nearbyint {{.+}} : f64 + // CHECK: {{.+}} = cir.nearbyint {{.+}} : !cir.double } -long double call_nearbyintl(long double f) { - return nearbyintl(f); - // CHECK: cir.func @call_nearbyintl - // CHECK: {{.+}} = cir.nearbyint {{.+}} : f80 -} +// long double call_nearbyintl(long double f) { +// return nearbyintl(f); +// // DISABLED-CHECK: cir.func @call_nearbyintl +// // DISABLED-CHECK: {{.+}} = cir.nearbyint {{.+}} : f80 +// } // rint float my_rintf(float f) { return __builtin_rintf(f); // CHECK: cir.func @my_rintf - // CHECK: {{.+}} = cir.rint {{.+}} : f32 + // CHECK: {{.+}} = cir.rint {{.+}} : !cir.float } double my_rint(double f) { return __builtin_rint(f); // CHECK: cir.func @my_rint - // CHECK: {{.+}} = cir.rint {{.+}} : f64 + // CHECK: {{.+}} = cir.rint {{.+}} : !cir.double } -long double my_rintl(long double f) { - return __builtin_rintl(f); - // CHECK: cir.func @my_rintl - // CHECK: {{.+}} = cir.rint {{.+}} : f80 -} +// long double my_rintl(long double f) { +// return __builtin_rintl(f); +// // DISABLED-CHECK: cir.func @my_rintl +// // DISABLED-CHECK: {{.+}} = cir.rint {{.+}} : f80 +// } float rintf(float); double rint(double); -long double rintl(long double); +// long double rintl(long double); float call_rintf(float f) { return rintf(f); // CHECK: cir.func @call_rintf - // CHECK: {{.+}} = cir.rint {{.+}} : f32 + // CHECK: {{.+}} = cir.rint {{.+}} : !cir.float } double call_rint(double f) { return rint(f); // CHECK: cir.func @call_rint - // CHECK: {{.+}} = cir.rint {{.+}} : f64 + // CHECK: {{.+}} = cir.rint {{.+}} : !cir.double } -long double call_rintl(long double f) { - return rintl(f); - // CHECK: cir.func @call_rintl - // CHECK: {{.+}} = cir.rint {{.+}} : f80 -} +// long double call_rintl(long double f) { +// return rintl(f); +// // DISABLED-CHECK: cir.func @call_rintl +// // DISABLED-CHECK: {{.+}} = cir.rint {{.+}} : f80 +// } // round float my_roundf(float f) { return __builtin_roundf(f); // CHECK: cir.func @my_roundf - // CHECK: {{.+}} = cir.round {{.+}} : f32 + // CHECK: {{.+}} = cir.round {{.+}} : !cir.float } double my_round(double f) { return __builtin_round(f); // CHECK: cir.func @my_round - // CHECK: {{.+}} = cir.round {{.+}} : f64 + // CHECK: {{.+}} = cir.round {{.+}} : !cir.double } -long double my_roundl(long double f) { - return __builtin_roundl(f); - // CHECK: cir.func @my_roundl - // CHECK: {{.+}} = cir.round {{.+}} : f80 -} +// long double my_roundl(long double f) { +// return __builtin_roundl(f); +// // DISABLED-CHECK: cir.func @my_roundl +// // DISABLED-CHECK: {{.+}} = cir.round {{.+}} : f80 +// } float roundf(float); double round(double); -long double roundl(long double); +// long double roundl(long double); float call_roundf(float f) { return roundf(f); // CHECK: cir.func @call_roundf - // CHECK: {{.+}} = cir.round {{.+}} : f32 + // CHECK: {{.+}} = cir.round {{.+}} : !cir.float } double call_round(double f) { return round(f); // CHECK: cir.func @call_round - // CHECK: {{.+}} = cir.round {{.+}} : f64 + // CHECK: {{.+}} = cir.round {{.+}} : !cir.double } -long double call_roundl(long double f) { - return roundl(f); - // CHECK: cir.func @call_roundl - // CHECK: {{.+}} = cir.round {{.+}} : f80 -} +// long double call_roundl(long double f) { +// return roundl(f); +// // DISABLED-CHECK: cir.func @call_roundl +// // DISABLED-CHECK: {{.+}} = cir.round {{.+}} : f80 +// } // sin float my_sinf(float f) { return __builtin_sinf(f); // CHECK: cir.func @my_sinf - // CHECK: {{.+}} = cir.sin {{.+}} : f32 + // CHECK: {{.+}} = cir.sin {{.+}} : !cir.float } double my_sin(double f) { return __builtin_sin(f); // CHECK: cir.func @my_sin - // CHECK: {{.+}} = cir.sin {{.+}} : f64 + // CHECK: {{.+}} = cir.sin {{.+}} : !cir.double } -long double my_sinl(long double f) { - return __builtin_sinl(f); - // CHECK: cir.func @my_sinl - // CHECK: {{.+}} = cir.sin {{.+}} : f80 -} +// long double my_sinl(long double f) { +// return __builtin_sinl(f); +// // DISABLED-CHECK: cir.func @my_sinl +// // DISABLED-CHECK: {{.+}} = cir.sin {{.+}} : f80 +// } float sinf(float); double sin(double); -long double sinl(long double); +// long double sinl(long double); float call_sinf(float f) { return sinf(f); // CHECK: cir.func @call_sinf - // CHECK: {{.+}} = cir.sin {{.+}} : f32 + // CHECK: {{.+}} = cir.sin {{.+}} : !cir.float } double call_sin(double f) { return sin(f); // CHECK: cir.func @call_sin - // CHECK: {{.+}} = cir.sin {{.+}} : f64 + // CHECK: {{.+}} = cir.sin {{.+}} : !cir.double } -long double call_sinl(long double f) { - return sinl(f); - // CHECK: cir.func @call_sinl - // CHECK: {{.+}} = cir.sin {{.+}} : f80 -} +// long double call_sinl(long double f) { +// return sinl(f); +// // DISABLED-CHECK: cir.func @call_sinl +// // DISABLED-CHECK: {{.+}} = cir.sin {{.+}} : f80 +// } // sqrt float my_sqrtf(float f) { return __builtin_sqrtf(f); // CHECK: cir.func @my_sqrtf - // CHECK: {{.+}} = cir.sqrt {{.+}} : f32 + // CHECK: {{.+}} = cir.sqrt {{.+}} : !cir.float } double my_sqrt(double f) { return __builtin_sqrt(f); // CHECK: cir.func @my_sqrt - // CHECK: {{.+}} = cir.sqrt {{.+}} : f64 + // CHECK: {{.+}} = cir.sqrt {{.+}} : !cir.double } -long double my_sqrtl(long double f) { - return __builtin_sqrtl(f); - // CHECK: cir.func @my_sqrtl - // CHECK: {{.+}} = cir.sqrt {{.+}} : f80 -} +// long double my_sqrtl(long double f) { +// return __builtin_sqrtl(f); +// // DISABLED-CHECK: cir.func @my_sqrtl +// // DISABLED-CHECK: {{.+}} = cir.sqrt {{.+}} : f80 +// } float sqrtf(float); double sqrt(double); -long double sqrtl(long double); +// long double sqrtl(long double); float call_sqrtf(float f) { return sqrtf(f); // CHECK: cir.func @call_sqrtf - // CHECK: {{.+}} = cir.sqrt {{.+}} : f32 + // CHECK: {{.+}} = cir.sqrt {{.+}} : !cir.float } double call_sqrt(double f) { return sqrt(f); // CHECK: cir.func @call_sqrt - // CHECK: {{.+}} = cir.sqrt {{.+}} : f64 + // CHECK: {{.+}} = cir.sqrt {{.+}} : !cir.double } -long double call_sqrtl(long double f) { - return sqrtl(f); - // CHECK: cir.func @call_sqrtl - // CHECK: {{.+}} = cir.sqrt {{.+}} : f80 -} +// long double call_sqrtl(long double f) { +// return sqrtl(f); +// // DISABLED-CHECK: cir.func @call_sqrtl +// // DISABLED-CHECK: {{.+}} = cir.sqrt {{.+}} : f80 +// } // trunc float my_truncf(float f) { return __builtin_truncf(f); // CHECK: cir.func @my_truncf - // CHECK: {{.+}} = cir.trunc {{.+}} : f32 + // CHECK: {{.+}} = cir.trunc {{.+}} : !cir.float } double my_trunc(double f) { return __builtin_trunc(f); // CHECK: cir.func @my_trunc - // CHECK: {{.+}} = cir.trunc {{.+}} : f64 + // CHECK: {{.+}} = cir.trunc {{.+}} : !cir.double } -long double my_truncl(long double f) { - return __builtin_truncl(f); - // CHECK: cir.func @my_truncl - // CHECK: {{.+}} = cir.trunc {{.+}} : f80 -} +// long double my_truncl(long double f) { +// return __builtin_truncl(f); +// // DISABLED-CHECK: cir.func @my_truncl +// // DISABLED-CHECK: {{.+}} = cir.trunc {{.+}} : f80 +// } float truncf(float); double trunc(double); -long double truncl(long double); +// long double truncl(long double); float call_truncf(float f) { return truncf(f); // CHECK: cir.func @call_truncf - // CHECK: {{.+}} = cir.trunc {{.+}} : f32 + // CHECK: {{.+}} = cir.trunc {{.+}} : !cir.float } double call_trunc(double f) { return trunc(f); // CHECK: cir.func @call_trunc - // CHECK: {{.+}} = cir.trunc {{.+}} : f64 + // CHECK: {{.+}} = cir.trunc {{.+}} : !cir.double } -long double call_truncl(long double f) { - return truncl(f); - // CHECK: cir.func @call_truncl - // CHECK: {{.+}} = cir.trunc {{.+}} : f80 -} +// long double call_truncl(long double f) { +// return truncl(f); +// // DISABLED-CHECK: cir.func @call_truncl +// // DISABLED-CHECK: {{.+}} = cir.trunc {{.+}} : f80 +// } diff --git a/clang/test/CIR/CodeGen/call.c b/clang/test/CIR/CodeGen/call.c index 6030f1c0dc00..cb2ac6df5b65 100644 --- a/clang/test/CIR/CodeGen/call.c +++ b/clang/test/CIR/CodeGen/call.c @@ -31,18 +31,18 @@ void d(void) { // CHECK: %6 = cir.load %2 : cir.ptr , !s32i // CHECK: cir.return %6 // CHECK: } -// CHECK: cir.func @c(%arg0: f64 {{.*}}, %arg1: f64 {{.*}}) -> f64 -// CHECK: %0 = cir.alloca f64, cir.ptr , ["a", init] -// CHECK: %1 = cir.alloca f64, cir.ptr , ["b", init] -// CHECK: %2 = cir.alloca f64, cir.ptr , ["__retval"] -// CHECK: cir.store %arg0, %0 : f64, cir.ptr -// CHECK: cir.store %arg1, %1 : f64, cir.ptr -// CHECK: %3 = cir.load %0 : cir.ptr , f64 -// CHECK: %4 = cir.load %1 : cir.ptr , f64 -// CHECK: %5 = cir.binop(add, %3, %4) : f64 -// CHECK: cir.store %5, %2 : f64, cir.ptr -// CHECK: %6 = cir.load %2 : cir.ptr , f64 -// CHECK: cir.return %6 : f64 +// CHECK: cir.func @c(%arg0: !cir.double {{.*}}, %arg1: !cir.double {{.*}}) -> !cir.double +// CHECK: %0 = cir.alloca !cir.double, cir.ptr , ["a", init] +// CHECK: %1 = cir.alloca !cir.double, cir.ptr , ["b", init] +// CHECK: %2 = cir.alloca !cir.double, cir.ptr , ["__retval"] +// CHECK: cir.store %arg0, %0 : !cir.double, cir.ptr +// CHECK: cir.store %arg1, %1 : !cir.double, cir.ptr +// CHECK: %3 = cir.load %0 : cir.ptr , !cir.double +// CHECK: %4 = cir.load %1 : cir.ptr , !cir.double +// CHECK: %5 = cir.binop(add, %3, %4) : !cir.double +// CHECK: cir.store %5, %2 : !cir.double, cir.ptr +// CHECK: %6 = cir.load %2 : cir.ptr , !cir.double +// CHECK: cir.return %6 : !cir.double // CHECK: } // CHECK: cir.func @d() // CHECK: call @a() : () -> () @@ -69,18 +69,18 @@ void d(void) { // CXX-NEXT: %6 = cir.load %2 : cir.ptr , !s32i // CXX-NEXT: cir.return %6 // CXX-NEXT: } -// CXX-NEXT: cir.func @_Z1cdd(%arg0: f64 {{.*}}, %arg1: f64 {{.*}}) -> f64 -// CXX-NEXT: %0 = cir.alloca f64, cir.ptr , ["a", init] -// CXX-NEXT: %1 = cir.alloca f64, cir.ptr , ["b", init] -// CXX-NEXT: %2 = cir.alloca f64, cir.ptr , ["__retval"] -// CXX-NEXT: cir.store %arg0, %0 : f64, cir.ptr -// CXX-NEXT: cir.store %arg1, %1 : f64, cir.ptr -// CXX-NEXT: %3 = cir.load %0 : cir.ptr , f64 -// CXX-NEXT: %4 = cir.load %1 : cir.ptr , f64 -// CXX-NEXT: %5 = cir.binop(add, %3, %4) : f64 -// CXX-NEXT: cir.store %5, %2 : f64, cir.ptr -// CXX-NEXT: %6 = cir.load %2 : cir.ptr , f64 -// CXX-NEXT: cir.return %6 : f64 +// CXX-NEXT: cir.func @_Z1cdd(%arg0: !cir.double {{.*}}, %arg1: !cir.double {{.*}}) -> !cir.double +// CXX-NEXT: %0 = cir.alloca !cir.double, cir.ptr , ["a", init] +// CXX-NEXT: %1 = cir.alloca !cir.double, cir.ptr , ["b", init] +// CXX-NEXT: %2 = cir.alloca !cir.double, cir.ptr , ["__retval"] +// CXX-NEXT: cir.store %arg0, %0 : !cir.double, cir.ptr +// CXX-NEXT: cir.store %arg1, %1 : !cir.double, cir.ptr +// CXX-NEXT: %3 = cir.load %0 : cir.ptr , !cir.double +// CXX-NEXT: %4 = cir.load %1 : cir.ptr , !cir.double +// CXX-NEXT: %5 = cir.binop(add, %3, %4) : !cir.double +// CXX-NEXT: cir.store %5, %2 : !cir.double, cir.ptr +// CXX-NEXT: %6 = cir.load %2 : cir.ptr , !cir.double +// CXX-NEXT: cir.return %6 : !cir.double // CXX-NEXT: } // CXX-NEXT: cir.func @_Z1dv() // CXX-NEXT: call @_Z1av() : () -> () diff --git a/clang/test/CIR/CodeGen/cast.cpp b/clang/test/CIR/CodeGen/cast.cpp index 10acddb47bf9..e8458dd1d216 100644 --- a/clang/test/CIR/CodeGen/cast.cpp +++ b/clang/test/CIR/CodeGen/cast.cpp @@ -46,10 +46,10 @@ int cStyleCasts_0(unsigned x1, int x2, float x3, short x4, double x5) { // CHECK: %{{[0-9]+}} = cir.cast(array_to_ptrdecay, %{{[0-9]+}} : !cir.ptr>), !cir.ptr int f = (int)x3; - // CHECK: %{{[0-9]+}} = cir.cast(float_to_int, %{{[0-9]+}} : f32), !s32i + // CHECK: %{{[0-9]+}} = cir.cast(float_to_int, %{{[0-9]+}} : !cir.float), !s32i double g = (double)x3; // FP extension - // %{{[0-9]+}} = cir.cast(floating, %{{[0-9]+}} : f32), f64 + // %{{[0-9]+}} = cir.cast(floating, %{{[0-9]+}} : !cir.float), !cir.double long l = (long)(void*)x4; // Must sign extend before casting to pointer // CHECK: %[[TMP:[0-9]+]] = cir.cast(integral, %{{[0-9]+}} : !s16i), !u64i @@ -57,16 +57,16 @@ int cStyleCasts_0(unsigned x1, int x2, float x3, short x4, double x5) { // CHECK: %{{[0-9]+}} = cir.cast(ptr_to_int, %[[TMP2]] : !cir.ptr), !s64i float sitofp = (float)x2; // Signed integer to floating point - // CHECK: %{{.+}} = cir.cast(int_to_float, %{{[0-9]+}} : !s32i), f32 + // CHECK: %{{.+}} = cir.cast(int_to_float, %{{[0-9]+}} : !s32i), !cir.float float uitofp = (float)x1; // Unsigned integer to floating point - // CHECK: %{{.+}} = cir.cast(int_to_float, %{{[0-9]+}} : !u32i), f32 + // CHECK: %{{.+}} = cir.cast(int_to_float, %{{[0-9]+}} : !u32i), !cir.float int fptosi = (int)x3; // Floating point to signed integer - // CHECK: %{{.+}} = cir.cast(float_to_int, %{{[0-9]+}} : f32), !s32i + // CHECK: %{{.+}} = cir.cast(float_to_int, %{{[0-9]+}} : !cir.float), !s32i unsigned fptoui = (unsigned)x3; // Floating point to unsigned integer - // CHECK: %{{.+}} = cir.cast(float_to_int, %{{[0-9]+}} : f32), !u32i + // CHECK: %{{.+}} = cir.cast(float_to_int, %{{[0-9]+}} : !cir.float), !u32i bool ib = (bool)x1; // No checking, because this isn't a regular cast. @@ -74,14 +74,14 @@ int cStyleCasts_0(unsigned x1, int x2, float x3, short x4, double x5) { // CHECK: %{{[0-9]+}} = cir.cast(bool_to_int, %{{[0-9]+}} : !cir.bool), !s32i float bf = (float)ib; // bool to float - // CHECK: %{{[0-9]+}} = cir.cast(bool_to_float, %{{[0-9]+}} : !cir.bool), f32 + // CHECK: %{{[0-9]+}} = cir.cast(bool_to_float, %{{[0-9]+}} : !cir.bool), !cir.float void* bpv = (void*)ib; // bool to pointer, which is done in two steps // CHECK: %[[TMP:[0-9]+]] = cir.cast(bool_to_int, %{{[0-9]+}} : !cir.bool), !u64i // CHECK: %{{[0-9]+}} = cir.cast(int_to_ptr, %[[TMP]] : !u64i), !cir.ptr float dptofp = (float)x5; - // CHECK: %{{.+}} = cir.cast(floating, %{{[0-9]+}} : f64), f32 + // CHECK: %{{.+}} = cir.cast(floating, %{{[0-9]+}} : !cir.double), !cir.float return 0; } diff --git a/clang/test/CIR/CodeGen/globals.c b/clang/test/CIR/CodeGen/globals.c index 522687aac53f..e576fb30fc65 100644 --- a/clang/test/CIR/CodeGen/globals.c +++ b/clang/test/CIR/CodeGen/globals.c @@ -15,7 +15,7 @@ int filler_sint[4] = {1, 2}; // Ensure missing elements are zero-initialized. int excess_sint[2] = {1, 2, 3, 4}; // Ensure excess elements are ignored. // CHECK: cir.global external @excess_sint = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i]> : !cir.array float flt[] = {1.0, 2.0}; -// CHECK: cir.global external @flt = #cir.const_array<[1.000000e+00 : f32, 2.000000e+00 : f32]> : !cir.array +// CHECK: cir.global external @flt = #cir.const_array<[#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.000000e+00> : !cir.float]> : !cir.array // Tentative definition is just a declaration. int tentativeB; @@ -90,7 +90,7 @@ struct Glob { } glob; double *const glob_ptr = &glob.b[1]; -// CHECK: cir.global external @glob_ptr = #cir.global_view<@glob, [2 : i32, 1 : i32]> : !cir.ptr +// CHECK: cir.global external @glob_ptr = #cir.global_view<@glob, [2 : i32, 1 : i32]> : !cir.ptr // TODO: test tentatives with internal linkage. @@ -100,6 +100,6 @@ float tentativeC; int tentativeD[]; float zeroInitFlt[2]; // CHECK: cir.global external @tentativeA = #cir.int<0> : !s32i -// CHECK: cir.global external @tentativeC = 0.000000e+00 : f32 +// CHECK: cir.global external @tentativeC = #cir.fp<0.000000e+00> : !cir.float // CHECK: cir.global external @tentativeD = #cir.zero : !cir.array -// CHECK: cir.global external @zeroInitFlt = #cir.zero : !cir.array +// CHECK: cir.global external @zeroInitFlt = #cir.zero : !cir.array diff --git a/clang/test/CIR/CodeGen/globals.cpp b/clang/test/CIR/CodeGen/globals.cpp index e9f04db19280..c71467d45c90 100644 --- a/clang/test/CIR/CodeGen/globals.cpp +++ b/clang/test/CIR/CodeGen/globals.cpp @@ -43,8 +43,8 @@ int use_func() { return func(); } // CHECK-NEXT: cir.store [[TMP2]], [[TMP0]] : !s32i, cir.ptr // CHECK: cir.global external @e = #false -// CHECK-NEXT: cir.global external @y = 3.400000e+00 : f32 -// CHECK-NEXT: cir.global external @w = 4.300000e+00 : f64 +// CHECK-NEXT: cir.global external @y = #cir.fp<3.400000e+00> : !cir.float +// CHECK-NEXT: cir.global external @w = #cir.fp<4.300000e+00> : !cir.double // CHECK-NEXT: cir.global external @x = #cir.int<51> : !s8i // CHECK-NEXT: cir.global external @rgb = #cir.const_array<[#cir.int<0> : !u8i, #cir.int<233> : !u8i, #cir.int<33> : !u8i]> : !cir.array // CHECK-NEXT: cir.global external @alpha = #cir.const_array<"abc\00" : !cir.array> : !cir.array diff --git a/clang/test/CIR/CodeGen/lalg.c b/clang/test/CIR/CodeGen/lalg.c index 20d36d9c1aa7..b7747ee3f7ff 100644 --- a/clang/test/CIR/CodeGen/lalg.c +++ b/clang/test/CIR/CodeGen/lalg.c @@ -7,14 +7,14 @@ double dot() { return result; } -// CHECK: %1 = cir.alloca f64, cir.ptr , ["x", init] -// CHECK-NEXT: %2 = cir.alloca f64, cir.ptr , ["y", init] -// CHECK-NEXT: %3 = cir.alloca f64, cir.ptr , ["result", init] -// CHECK-NEXT: %4 = cir.const(0.000000e+00 : f64) : f64 -// CHECK-NEXT: cir.store %4, %1 : f64, cir.ptr -// CHECK-NEXT: %5 = cir.const(0.000000e+00 : f32) : f32 -// CHECK-NEXT: %6 = cir.cast(floating, %5 : f32), f64 -// CHECK-NEXT: cir.store %6, %2 : f64, cir.ptr -// CHECK-NEXT: %7 = cir.load %1 : cir.ptr , f64 -// CHECK-NEXT: %8 = cir.load %2 : cir.ptr , f64 -// CHECK-NEXT: %9 = cir.binop(mul, %7, %8) : f64 +// CHECK: %1 = cir.alloca !cir.double, cir.ptr , ["x", init] +// CHECK-NEXT: %2 = cir.alloca !cir.double, cir.ptr , ["y", init] +// CHECK-NEXT: %3 = cir.alloca !cir.double, cir.ptr , ["result", init] +// CHECK-NEXT: %4 = cir.const(#cir.fp<0.000000e+00> : !cir.double) : !cir.double +// CHECK-NEXT: cir.store %4, %1 : !cir.double, cir.ptr +// CHECK-NEXT: %5 = cir.const(#cir.fp<0.000000e+00> : !cir.float) : !cir.float +// CHECK-NEXT: %6 = cir.cast(floating, %5 : !cir.float), !cir.double +// CHECK-NEXT: cir.store %6, %2 : !cir.double, cir.ptr +// CHECK-NEXT: %7 = cir.load %1 : cir.ptr , !cir.double +// CHECK-NEXT: %8 = cir.load %2 : cir.ptr , !cir.double +// CHECK-NEXT: %9 = cir.binop(mul, %7, %8) : !cir.double diff --git a/clang/test/CIR/CodeGen/libc.c b/clang/test/CIR/CodeGen/libc.c index 1a17483f9e35..29e6563c7c93 100644 --- a/clang/test/CIR/CodeGen/libc.c +++ b/clang/test/CIR/CodeGen/libc.c @@ -11,11 +11,11 @@ void testMemcpy(void *src, const void *dst, unsigned long size) { double fabs(double); double testFabs(double x) { return fabs(x); - // CHECK: cir.fabs %{{.+}} : f64 + // CHECK: cir.fabs %{{.+}} : !cir.double } float fabsf(float); float testFabsf(float x) { return fabsf(x); - // CHECK: cir.fabs %{{.+}} : f32 + // CHECK: cir.fabs %{{.+}} : !cir.float } diff --git a/clang/test/CIR/CodeGen/static-vars.c b/clang/test/CIR/CodeGen/static-vars.c index a5f9ca0efbf1..f8a57b18aae6 100644 --- a/clang/test/CIR/CodeGen/static-vars.c +++ b/clang/test/CIR/CodeGen/static-vars.c @@ -33,7 +33,7 @@ void func2(void) { static char i; // CHECK-DAG: cir.global "private" internal @func2.i = #cir.int<0> : !s8i static float j; - // CHECK-DAG: cir.global "private" internal @func2.j = 0.000000e+00 : f32 + // CHECK-DAG: cir.global "private" internal @func2.j = #cir.fp<0.000000e+00> : !cir.float } // Should const initialize static vars with constant addresses. diff --git a/clang/test/CIR/CodeGen/static-vars.cpp b/clang/test/CIR/CodeGen/static-vars.cpp index 3d63eec8616f..55c68067c93d 100644 --- a/clang/test/CIR/CodeGen/static-vars.cpp +++ b/clang/test/CIR/CodeGen/static-vars.cpp @@ -33,5 +33,5 @@ void func2(void) { static char i; // CHECK-DAG: cir.global "private" internal @_ZZ5func2vE1i = #cir.int<0> : !s8i static float j; - // CHECK-DAG: cir.global "private" internal @_ZZ5func2vE1j = 0.000000e+00 : f32 + // CHECK-DAG: cir.global "private" internal @_ZZ5func2vE1j = #cir.fp<0.000000e+00> : !cir.float } diff --git a/clang/test/CIR/CodeGen/struct.c b/clang/test/CIR/CodeGen/struct.c index 06450b0e9ea7..dabc36ba20e5 100644 --- a/clang/test/CIR/CodeGen/struct.c +++ b/clang/test/CIR/CodeGen/struct.c @@ -52,7 +52,7 @@ struct S1 { float f; int *p; } s1 = {1, .1, 0}; -// CHECK-DAG: cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.ptr : !cir.ptr}> : !ty_22S122 +// CHECK-DAG: cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_22S122 // Should initialize global nested structs. struct S2 { diff --git a/clang/test/CIR/CodeGen/try-catch.cpp b/clang/test/CIR/CodeGen/try-catch.cpp index a9522a241e66..23b8062d3cd4 100644 --- a/clang/test/CIR/CodeGen/try-catch.cpp +++ b/clang/test/CIR/CodeGen/try-catch.cpp @@ -18,7 +18,7 @@ unsigned long long tc() { // CHECK: %[[local_a:.*]] = cir.alloca !s32i, cir.ptr , ["a", init] int a = 4; z = division(x, y); - // CHECK: %[[div_res:.*]] = cir.try_call exception(%[[eh_info]]) @_Z8divisionii({{.*}}) : (!cir.ptr>, !s32i, !s32i) -> f64 + // CHECK: %[[div_res:.*]] = cir.try_call exception(%[[eh_info]]) @_Z8divisionii({{.*}}) : (!cir.ptr>, !s32i, !s32i) -> !cir.double a++; // CHECK: cir.catch(%[[try_eh]] : !cir.ptr, [ diff --git a/clang/test/CIR/CodeGen/types.c b/clang/test/CIR/CodeGen/types.c index 63c9c205e4a9..50bfdfa5fd72 100644 --- a/clang/test/CIR/CodeGen/types.c +++ b/clang/test/CIR/CodeGen/types.c @@ -14,7 +14,7 @@ unsigned short t5(unsigned short i) { return i; } float t6(float i) { return i; } double t7(double i) { return i; } -long double t10(long double i) { return i; } +// long double t10(long double i) { return i; } void t8(void) {} @@ -28,9 +28,9 @@ bool t9(bool b) { return b; } // CHECK: cir.func @t3(%arg0: !u8i loc({{.*}})) -> !u8i // CHECK: cir.func @t4(%arg0: !s16i loc({{.*}})) -> !s16i // CHECK: cir.func @t5(%arg0: !u16i loc({{.*}})) -> !u16i -// CHECK: cir.func @t6(%arg0: f32 loc({{.*}})) -> f32 -// CHECK: cir.func @t7(%arg0: f64 loc({{.*}})) -> f64 -// CHECK: cir.func @t10(%arg0: f80 loc({{.*}})) -> f80 +// CHECK: cir.func @t6(%arg0: !cir.float loc({{.*}})) -> !cir.float +// CHECK: cir.func @t7(%arg0: !cir.double loc({{.*}})) -> !cir.double +// DISABLED-CHECK: cir.func @t10(%arg0: f80 loc({{.*}})) -> f80 // CHECK: cir.func @t8() // CHECK-CPP: cir.func @_Z2t0i(%arg0: !s32i loc({{.*}})) -> !s32i @@ -39,8 +39,8 @@ bool t9(bool b) { return b; } // CHECK-CPP: cir.func @_Z2t3h(%arg0: !u8i loc({{.*}})) -> !u8i // CHECK-CPP: cir.func @_Z2t4s(%arg0: !s16i loc({{.*}})) -> !s16i // CHECK-CPP: cir.func @_Z2t5t(%arg0: !u16i loc({{.*}})) -> !u16i -// CHECK-CPP: cir.func @_Z2t6f(%arg0: f32 loc({{.*}})) -> f32 -// CHECK-CPP: cir.func @_Z2t7d(%arg0: f64 loc({{.*}})) -> f64 -// CHECK-CPP: cir.func @{{.+}}t10{{.+}}(%arg0: f80 loc({{.*}})) -> f80 +// CHECK-CPP: cir.func @_Z2t6f(%arg0: !cir.float loc({{.*}})) -> !cir.float +// CHECK-CPP: cir.func @_Z2t7d(%arg0: !cir.double loc({{.*}})) -> !cir.double +// DISABLED-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/CodeGen/unary.c b/clang/test/CIR/CodeGen/unary.c index dacd0ab27dfc..3f237b7de599 100644 --- a/clang/test/CIR/CodeGen/unary.c +++ b/clang/test/CIR/CodeGen/unary.c @@ -16,13 +16,13 @@ void valueNegation(int i, short s, long l, float f, double d) { // CHECK: %[[#LONG_TO_BOOL:]] = cir.cast(int_to_bool, %[[#LONG]] : !s64i), !cir.bool // CHECK: = cir.unary(not, %[[#LONG_TO_BOOL]]) : !cir.bool, !cir.bool !f; - // CHECK: %[[#FLOAT:]] = cir.load %{{[0-9]+}} : cir.ptr , f32 - // CHECK: %[[#FLOAT_TO_BOOL:]] = cir.cast(float_to_bool, %[[#FLOAT]] : f32), !cir.bool + // CHECK: %[[#FLOAT:]] = cir.load %{{[0-9]+}} : cir.ptr , !cir.float + // CHECK: %[[#FLOAT_TO_BOOL:]] = cir.cast(float_to_bool, %[[#FLOAT]] : !cir.float), !cir.bool // CHECK: %[[#FLOAT_NOT:]] = cir.unary(not, %[[#FLOAT_TO_BOOL]]) : !cir.bool, !cir.bool // CHECK: = cir.cast(bool_to_int, %[[#FLOAT_NOT]] : !cir.bool), !s32i !d; - // CHECK: %[[#DOUBLE:]] = cir.load %{{[0-9]+}} : cir.ptr , f64 - // CHECK: %[[#DOUBLE_TO_BOOL:]] = cir.cast(float_to_bool, %[[#DOUBLE]] : f64), !cir.bool + // CHECK: %[[#DOUBLE:]] = cir.load %{{[0-9]+}} : cir.ptr , !cir.double + // CHECK: %[[#DOUBLE_TO_BOOL:]] = cir.cast(float_to_bool, %[[#DOUBLE]] : !cir.double), !cir.bool // CHECK: %[[#DOUBLE_NOT:]] = cir.unary(not, %[[#DOUBLE_TO_BOOL]]) : !cir.bool, !cir.bool // CHECK: = cir.cast(bool_to_int, %[[#DOUBLE_NOT]] : !cir.bool), !s32i } diff --git a/clang/test/CIR/CodeGen/unary.cpp b/clang/test/CIR/CodeGen/unary.cpp index 9bb82b6f2e12..37d44fa3917c 100644 --- a/clang/test/CIR/CodeGen/unary.cpp +++ b/clang/test/CIR/CodeGen/unary.cpp @@ -155,29 +155,29 @@ int *inc_p(int *i) { void floats(float f) { // CHECK: cir.func @{{.+}}floats{{.+}} - +f; // CHECK: %{{[0-9]+}} = cir.unary(plus, %{{[0-9]+}}) : f32, f32 - -f; // CHECK: %{{[0-9]+}} = cir.unary(minus, %{{[0-9]+}}) : f32, f32 - ++f; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : f32, f32 - --f; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : f32, f32 - f++; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : f32, f32 - f--; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : f32, f32 + +f; // CHECK: %{{[0-9]+}} = cir.unary(plus, %{{[0-9]+}}) : !cir.float, !cir.float + -f; // CHECK: %{{[0-9]+}} = cir.unary(minus, %{{[0-9]+}}) : !cir.float, !cir.float + ++f; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : !cir.float, !cir.float + --f; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : !cir.float, !cir.float + f++; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : !cir.float, !cir.float + f--; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : !cir.float, !cir.float !f; - // CHECK: %[[#F_BOOL:]] = cir.cast(float_to_bool, %{{[0-9]+}} : f32), !cir.bool + // CHECK: %[[#F_BOOL:]] = cir.cast(float_to_bool, %{{[0-9]+}} : !cir.float), !cir.bool // CHECK: = cir.unary(not, %[[#F_BOOL]]) : !cir.bool, !cir.bool } void doubles(double d) { // CHECK: cir.func @{{.+}}doubles{{.+}} - +d; // CHECK: %{{[0-9]+}} = cir.unary(plus, %{{[0-9]+}}) : f64, f64 - -d; // CHECK: %{{[0-9]+}} = cir.unary(minus, %{{[0-9]+}}) : f64, f64 - ++d; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : f64, f64 - --d; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : f64, f64 - d++; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : f64, f64 - d--; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : f64, f64 + +d; // CHECK: %{{[0-9]+}} = cir.unary(plus, %{{[0-9]+}}) : !cir.double, !cir.double + -d; // CHECK: %{{[0-9]+}} = cir.unary(minus, %{{[0-9]+}}) : !cir.double, !cir.double + ++d; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : !cir.double, !cir.double + --d; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : !cir.double, !cir.double + d++; // CHECK: = cir.unary(inc, %{{[0-9]+}}) : !cir.double, !cir.double + d--; // CHECK: = cir.unary(dec, %{{[0-9]+}}) : !cir.double, !cir.double !d; - // CHECK: %[[#D_BOOL:]] = cir.cast(float_to_bool, %{{[0-9]+}} : f64), !cir.bool + // CHECK: %[[#D_BOOL:]] = cir.cast(float_to_bool, %{{[0-9]+}} : !cir.double), !cir.bool // CHECK: = cir.unary(not, %[[#D_BOOL]]) : !cir.bool, !cir.bool } diff --git a/clang/test/CIR/CodeGen/union.cpp b/clang/test/CIR/CodeGen/union.cpp index e3751a96c644..2f90229eb6a7 100644 --- a/clang/test/CIR/CodeGen/union.cpp +++ b/clang/test/CIR/CodeGen/union.cpp @@ -6,7 +6,7 @@ typedef union { yolo y; struct { int lifecnt; }; } yolm; typedef union { yolo y; struct { int *lifecnt; int genpad; }; } yolm2; typedef union { yolo y; struct { bool life; int genpad; }; } yolm3; -// CHECK-DAG: !ty_22U23A3ADummy22 = !cir.struct, f32} #cir.record.decl.ast> +// CHECK-DAG: !ty_22U23A3ADummy22 = !cir.struct, !cir.float} #cir.record.decl.ast> // CHECK-DAG: !ty_22anon2E522 = !cir.struct} #cir.record.decl.ast> // CHECK-DAG: !ty_22anon2E122 = !cir.struct} #cir.record.decl.ast> // CHECK-DAG: !ty_22yolo22 = !cir.struct} #cir.record.decl.ast> @@ -24,7 +24,7 @@ union U { float f; double d; }; -// CHECK-DAG: !ty_22U22 = !cir.struct, !cir.int, f32, f64}> +// CHECK-DAG: !ty_22U22 = !cir.struct, !cir.int, !cir.float, !cir.double}> // Should generate unions with complex members. union U2 { @@ -34,14 +34,14 @@ union U2 { float f; } s; } u2; -// CHECK-DAG: !cir.struct, f32} #cir.record.decl.ast>} #cir.record.decl.ast> +// CHECK-DAG: !cir.struct, !cir.float} #cir.record.decl.ast>} #cir.record.decl.ast> // Should genereate unions without padding. union U3 { short b; U u; } u3; -// CHECK-DAG: !ty_22U322 = !cir.struct, !cir.struct, !cir.int, f32, f64}>} #cir.record.decl.ast> +// CHECK-DAG: !ty_22U322 = !cir.struct, !cir.struct, !cir.int, !cir.float, !cir.double}>} #cir.record.decl.ast> void m() { yolm q; @@ -66,13 +66,13 @@ void shouldGenerateUnionAccess(union U u) { u.i; // CHECK: %[[#BASE:]] = cir.get_member %0[2] {name = "i"} : !cir.ptr -> !cir.ptr u.f = 0.1F; - // CHECK: %[[#BASE:]] = cir.get_member %0[3] {name = "f"} : !cir.ptr -> !cir.ptr - // CHECK: cir.store %{{.+}}, %[[#BASE]] : f32, cir.ptr + // CHECK: %[[#BASE:]] = cir.get_member %0[3] {name = "f"} : !cir.ptr -> !cir.ptr + // CHECK: cir.store %{{.+}}, %[[#BASE]] : !cir.float, cir.ptr u.f; - // CHECK: %[[#BASE:]] = cir.get_member %0[3] {name = "f"} : !cir.ptr -> !cir.ptr + // CHECK: %[[#BASE:]] = cir.get_member %0[3] {name = "f"} : !cir.ptr -> !cir.ptr u.d = 0.1; - // CHECK: %[[#BASE:]] = cir.get_member %0[4] {name = "d"} : !cir.ptr -> !cir.ptr - // CHECK: cir.store %{{.+}}, %[[#BASE]] : f64, cir.ptr + // CHECK: %[[#BASE:]] = cir.get_member %0[4] {name = "d"} : !cir.ptr -> !cir.ptr + // CHECK: cir.store %{{.+}}, %[[#BASE]] : !cir.double, cir.ptr u.d; - // CHECK: %[[#BASE:]] = cir.get_member %0[4] {name = "d"} : !cir.ptr -> !cir.ptr + // CHECK: %[[#BASE:]] = cir.get_member %0[4] {name = "d"} : !cir.ptr -> !cir.ptr } diff --git a/clang/test/CIR/CodeGen/vectype.cpp b/clang/test/CIR/CodeGen/vectype.cpp index 012ea983fe48..ef9e8ce72b09 100644 --- a/clang/test/CIR/CodeGen/vectype.cpp +++ b/clang/test/CIR/CodeGen/vectype.cpp @@ -70,49 +70,49 @@ void vector_double_test(int x, double y) { // Vector constant. Not yet implemented. Expected results will change from // cir.vec.create to cir.const. vd2 a = { 1.5, 2.5 }; - // CHECK: %{{[0-9]+}} = cir.vec.create(%{{[0-9]+}}, %{{[0-9]+}} : f64, f64) : + // CHECK: %{{[0-9]+}} = cir.vec.create(%{{[0-9]+}}, %{{[0-9]+}} : !cir.double, !cir.double) : // Non-const vector initialization. vd2 b = { y, y + 1.0 }; - // CHECK: %{{[0-9]+}} = cir.vec.create(%{{[0-9]+}}, %{{[0-9]+}} : f64, f64) : + // CHECK: %{{[0-9]+}} = cir.vec.create(%{{[0-9]+}}, %{{[0-9]+}} : !cir.double, !cir.double) : // Extract element double c = a[x]; - // CHECK: %{{[0-9]+}} = cir.vec.extract %{{[0-9]+}}[%{{[0-9]+}} : !s32i] : + // CHECK: %{{[0-9]+}} = cir.vec.extract %{{[0-9]+}}[%{{[0-9]+}} : !s32i] : // Insert element a[x] = y; - // CHECK: %[[#LOADEDVF:]] = cir.load %[[#STORAGEVF:]] : cir.ptr >, !cir.vector - // CHECK: %[[#UPDATEDVF:]] = cir.vec.insert %{{[0-9]+}}, %[[#LOADEDVF]][%{{[0-9]+}} : !s32i] : - // CHECK: cir.store %[[#UPDATEDVF]], %[[#STORAGEVF]] : !cir.vector, cir.ptr > + // CHECK: %[[#LOADEDVF:]] = cir.load %[[#STORAGEVF:]] : cir.ptr >, !cir.vector + // CHECK: %[[#UPDATEDVF:]] = cir.vec.insert %{{[0-9]+}}, %[[#LOADEDVF]][%{{[0-9]+}} : !s32i] : + // CHECK: cir.store %[[#UPDATEDVF]], %[[#STORAGEVF]] : !cir.vector, cir.ptr > // Binary arithmetic operations vd2 d = a + b; - // CHECK: %{{[0-9]+}} = cir.binop(add, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector + // CHECK: %{{[0-9]+}} = cir.binop(add, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector vd2 e = a - b; - // CHECK: %{{[0-9]+}} = cir.binop(sub, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector + // CHECK: %{{[0-9]+}} = cir.binop(sub, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector vd2 f = a * b; - // CHECK: %{{[0-9]+}} = cir.binop(mul, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector + // CHECK: %{{[0-9]+}} = cir.binop(mul, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector vd2 g = a / b; - // CHECK: %{{[0-9]+}} = cir.binop(div, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector + // CHECK: %{{[0-9]+}} = cir.binop(div, %{{[0-9]+}}, %{{[0-9]+}}) : !cir.vector // Unary arithmetic operations vd2 l = +a; - // CHECK: %{{[0-9]+}} = cir.unary(plus, %{{[0-9]+}}) : !cir.vector, !cir.vector + // CHECK: %{{[0-9]+}} = cir.unary(plus, %{{[0-9]+}}) : !cir.vector, !cir.vector vd2 m = -a; - // CHECK: %{{[0-9]+}} = cir.unary(minus, %{{[0-9]+}}) : !cir.vector, !cir.vector + // CHECK: %{{[0-9]+}} = cir.unary(minus, %{{[0-9]+}}) : !cir.vector, !cir.vector // Comparisons vll2 o = a == b; - // CHECK: %{{[0-9]+}} = cir.vec.cmp(eq, %{{[0-9]+}}, %{{[0-9]+}}) : , + // CHECK: %{{[0-9]+}} = cir.vec.cmp(eq, %{{[0-9]+}}, %{{[0-9]+}}) : , vll2 p = a != b; - // CHECK: %{{[0-9]+}} = cir.vec.cmp(ne, %{{[0-9]+}}, %{{[0-9]+}}) : , + // CHECK: %{{[0-9]+}} = cir.vec.cmp(ne, %{{[0-9]+}}, %{{[0-9]+}}) : , vll2 q = a < b; - // CHECK: %{{[0-9]+}} = cir.vec.cmp(lt, %{{[0-9]+}}, %{{[0-9]+}}) : , + // CHECK: %{{[0-9]+}} = cir.vec.cmp(lt, %{{[0-9]+}}, %{{[0-9]+}}) : , vll2 r = a > b; - // CHECK: %{{[0-9]+}} = cir.vec.cmp(gt, %{{[0-9]+}}, %{{[0-9]+}}) : , + // CHECK: %{{[0-9]+}} = cir.vec.cmp(gt, %{{[0-9]+}}, %{{[0-9]+}}) : , vll2 s = a <= b; - // CHECK: %{{[0-9]+}} = cir.vec.cmp(le, %{{[0-9]+}}, %{{[0-9]+}}) : , + // CHECK: %{{[0-9]+}} = cir.vec.cmp(le, %{{[0-9]+}}, %{{[0-9]+}}) : , vll2 t = a >= b; - // CHECK: %{{[0-9]+}} = cir.vec.cmp(ge, %{{[0-9]+}}, %{{[0-9]+}}) : , + // CHECK: %{{[0-9]+}} = cir.vec.cmp(ge, %{{[0-9]+}}, %{{[0-9]+}}) : , } diff --git a/clang/test/CIR/IR/invalid.cir b/clang/test/CIR/IR/invalid.cir index f8f746128998..f9dce3a1ed05 100644 --- a/clang/test/CIR/IR/invalid.cir +++ b/clang/test/CIR/IR/invalid.cir @@ -101,7 +101,7 @@ cir.func @s1() { cir.func @badstride(%x: !cir.ptr>) { %idx = cir.const(#cir.int<2> : !cir.int) : !cir.int - %4 = cir.ptr_stride(%x : !cir.ptr>, %idx : !cir.int), !cir.ptr // expected-error {{requires the same type for first operand and result}} + %4 = cir.ptr_stride(%x : !cir.ptr>, %idx : !cir.int), !cir.ptr // expected-error {{requires the same type for first operand and result}} cir.return } @@ -115,8 +115,8 @@ cir.func @cast0(%arg0: !u32i) { // ----- -cir.func @cast1(%arg1: f32) { - %1 = cir.cast(int_to_bool, %arg1 : f32), !cir.bool // expected-error {{requires integral type for source}} +cir.func @cast1(%arg1: !cir.float) { + %1 = cir.cast(int_to_bool, %arg1 : !cir.float), !cir.bool // expected-error {{requires integral type for source}} cir.return } @@ -133,7 +133,7 @@ cir.func @cast2(%p: !cir.ptr) { !u32i = !cir.int cir.func @cast3(%p: !cir.ptr) { %0 = cir.alloca !cir.array, cir.ptr >, ["x", init] - %2 = cir.cast(array_to_ptrdecay, %0 : !cir.ptr>), !cir.ptr // expected-error {{requires same type for array element and pointee result}} + %2 = cir.cast(array_to_ptrdecay, %0 : !cir.ptr>), !cir.ptr // expected-error {{requires same type for array element and pointee result}} cir.return } @@ -147,8 +147,8 @@ cir.func @cast4(%p: !cir.ptr) { // ----- -cir.func @cast5(%p: f32) { - %2 = cir.cast(bool_to_float, %p : f32), f32 // expected-error {{requires !cir.bool for source}} +cir.func @cast5(%p: !cir.float) { + %2 = cir.cast(bool_to_float, %p : !cir.float), !cir.float // expected-error {{requires !cir.bool for source}} cir.return } @@ -179,23 +179,23 @@ cir.func @cast8(%p: !u32i) { !u32i = !cir.int cir.func @cast9(%p : !u32i) { - %2 = cir.cast(integral, %p : !u32i), f32 // expected-error {{requires !IntegerType for result}} + %2 = cir.cast(integral, %p : !u32i), !cir.float // expected-error {{requires !IntegerType for result}} cir.return } // ----- !u32i = !cir.int -cir.func @cast10(%p : f32) { - %2 = cir.cast(integral, %p : f32), !u32i // expected-error {{requires !IntegerType for source}} +cir.func @cast10(%p : !cir.float) { + %2 = cir.cast(integral, %p : !cir.float), !u32i // expected-error {{requires !IntegerType for source}} cir.return } // ----- !u32i = !cir.int -cir.func @cast11(%p : f32) { - %2 = cir.cast(floating, %p : f32), !u32i // expected-error {{requries floating for source and result}} +cir.func @cast11(%p : !cir.float) { + %2 = cir.cast(floating, %p : !cir.float), !u32i // expected-error {{requries floating for source and result}} cir.return } @@ -203,7 +203,7 @@ cir.func @cast11(%p : f32) { !u32i = !cir.int cir.func @cast12(%p : !u32i) { - %2 = cir.cast(floating, %p : !u32i), f32 // expected-error {{requries floating for source and result}} + %2 = cir.cast(floating, %p : !u32i), !cir.float // expected-error {{requries floating for source and result}} cir.return } @@ -217,8 +217,8 @@ cir.func @cast13(%p : !u32i) { // ----- -cir.func @cast14(%p : f32) { - %2 = cir.cast(float_to_int, %p : f32), f32 // expected-error {{requires !IntegerType for result}} +cir.func @cast14(%p : !cir.float) { + %2 = cir.cast(float_to_int, %p : !cir.float), !cir.float // expected-error {{requires !IntegerType for result}} cir.return } @@ -265,8 +265,8 @@ cir.func @cast19(%p : !u32i) { // ----- !u32i = !cir.int -cir.func @cast20(%p : f32) { - %2 = cir.cast(float_to_bool, %p : f32), !u32i // expected-error {{requires !cir.bool for result}} +cir.func @cast20(%p : !cir.float) { + %2 = cir.cast(float_to_bool, %p : !cir.float), !u32i // expected-error {{requires !cir.bool for result}} cir.return } @@ -281,14 +281,14 @@ cir.func @cast21(%p : !u32i) { // ----- cir.func @cast22(%p : !cir.bool) { - %2 = cir.cast(bool_to_int, %p : !cir.bool), f32 // expected-error {{requires !cir.int for result}} + %2 = cir.cast(bool_to_int, %p : !cir.bool), !cir.float // expected-error {{requires !cir.int for result}} cir.return } // ----- cir.func @cast23(%p : !cir.bool) { - %2 = cir.cast(int_to_float, %p : !cir.bool), f32 // expected-error {{requires !cir.int for source}} + %2 = cir.cast(int_to_float, %p : !cir.bool), !cir.float // expected-error {{requires !cir.int for source}} cir.return } @@ -752,9 +752,9 @@ module { // ----- !s32i = !cir.int module { - cir.func @tmp(%arg0: f32) { + cir.func @tmp(%arg0: !cir.float) { // expected-error@+1 {{operand #0 must be Integer type}} - %0 = cir.alloca !s32i, cir.ptr , %arg0 : f32, ["tmp"] + %0 = cir.alloca !s32i, cir.ptr , %arg0 : !cir.float, ["tmp"] cir.return } } diff --git a/clang/test/CIR/IR/libc-fabs.cir b/clang/test/CIR/IR/libc-fabs.cir index cfd5129b6350..691849e0c3a5 100644 --- a/clang/test/CIR/IR/libc-fabs.cir +++ b/clang/test/CIR/IR/libc-fabs.cir @@ -2,8 +2,8 @@ !u32i = !cir.int module { - cir.func @foo(%arg0: f64) -> f64 { - %0 = cir.fabs %arg0 : f64 - cir.return %0 : f64 + cir.func @foo(%arg0: !cir.double) -> !cir.double { + %0 = cir.fabs %arg0 : !cir.double + cir.return %0 : !cir.double } } diff --git a/clang/test/CIR/Lowering/ThroughMLIR/binop-fp.cir b/clang/test/CIR/Lowering/ThroughMLIR/binop-fp.cir index f6dfda5fa435..790d50d5510d 100644 --- a/clang/test/CIR/Lowering/ThroughMLIR/binop-fp.cir +++ b/clang/test/CIR/Lowering/ThroughMLIR/binop-fp.cir @@ -3,44 +3,44 @@ module { cir.func @foo() { - %0 = cir.alloca f32, cir.ptr , ["c"] {alignment = 4 : i64} - %1 = cir.alloca f32, cir.ptr , ["d"] {alignment = 4 : i64} - %2 = cir.alloca f32, cir.ptr , ["y", init] {alignment = 4 : i64} - %3 = cir.alloca f64, cir.ptr , ["e"] {alignment = 8 : i64} - %4 = cir.alloca f64, cir.ptr , ["f"] {alignment = 8 : i64} - %5 = cir.alloca f64, cir.ptr , ["g", init] {alignment = 8 : i64} - %6 = cir.load %0 : cir.ptr , f32 - %7 = cir.load %1 : cir.ptr , f32 - %8 = cir.binop(mul, %6, %7) : f32 - cir.store %8, %2 : f32, cir.ptr - %9 = cir.load %2 : cir.ptr , f32 - %10 = cir.load %1 : cir.ptr , f32 - %11 = cir.binop(div, %9, %10) : f32 - cir.store %11, %2 : f32, cir.ptr - %12 = cir.load %2 : cir.ptr , f32 - %13 = cir.load %1 : cir.ptr , f32 - %14 = cir.binop(add, %12, %13) : f32 - cir.store %14, %2 : f32, cir.ptr - %15 = cir.load %2 : cir.ptr , f32 - %16 = cir.load %1 : cir.ptr , f32 - %17 = cir.binop(sub, %15, %16) : f32 - cir.store %17, %2 : f32, cir.ptr - %18 = cir.load %3 : cir.ptr , f64 - %19 = cir.load %4 : cir.ptr , f64 - %20 = cir.binop(add, %18, %19) : f64 - cir.store %20, %5 : f64, cir.ptr - %21 = cir.load %3 : cir.ptr , f64 - %22 = cir.load %4 : cir.ptr , f64 - %23 = cir.binop(sub, %21, %22) : f64 - cir.store %23, %5 : f64, cir.ptr - %24 = cir.load %3 : cir.ptr , f64 - %25 = cir.load %4 : cir.ptr , f64 - %26 = cir.binop(mul, %24, %25) : f64 - cir.store %26, %5 : f64, cir.ptr - %27 = cir.load %3 : cir.ptr , f64 - %28 = cir.load %4 : cir.ptr , f64 - %29 = cir.binop(div, %27, %28) : f64 - cir.store %29, %5 : f64, cir.ptr + %0 = cir.alloca !cir.float, cir.ptr , ["c"] {alignment = 4 : i64} + %1 = cir.alloca !cir.float, cir.ptr , ["d"] {alignment = 4 : i64} + %2 = cir.alloca !cir.float, cir.ptr , ["y", init] {alignment = 4 : i64} + %3 = cir.alloca !cir.double, cir.ptr , ["e"] {alignment = 8 : i64} + %4 = cir.alloca !cir.double, cir.ptr , ["f"] {alignment = 8 : i64} + %5 = cir.alloca !cir.double, cir.ptr , ["g", init] {alignment = 8 : i64} + %6 = cir.load %0 : cir.ptr , !cir.float + %7 = cir.load %1 : cir.ptr , !cir.float + %8 = cir.binop(mul, %6, %7) : !cir.float + cir.store %8, %2 : !cir.float, cir.ptr + %9 = cir.load %2 : cir.ptr , !cir.float + %10 = cir.load %1 : cir.ptr , !cir.float + %11 = cir.binop(div, %9, %10) : !cir.float + cir.store %11, %2 : !cir.float, cir.ptr + %12 = cir.load %2 : cir.ptr , !cir.float + %13 = cir.load %1 : cir.ptr , !cir.float + %14 = cir.binop(add, %12, %13) : !cir.float + cir.store %14, %2 : !cir.float, cir.ptr + %15 = cir.load %2 : cir.ptr , !cir.float + %16 = cir.load %1 : cir.ptr , !cir.float + %17 = cir.binop(sub, %15, %16) : !cir.float + cir.store %17, %2 : !cir.float, cir.ptr + %18 = cir.load %3 : cir.ptr , !cir.double + %19 = cir.load %4 : cir.ptr , !cir.double + %20 = cir.binop(add, %18, %19) : !cir.double + cir.store %20, %5 : !cir.double, cir.ptr + %21 = cir.load %3 : cir.ptr , !cir.double + %22 = cir.load %4 : cir.ptr , !cir.double + %23 = cir.binop(sub, %21, %22) : !cir.double + cir.store %23, %5 : !cir.double, cir.ptr + %24 = cir.load %3 : cir.ptr , !cir.double + %25 = cir.load %4 : cir.ptr , !cir.double + %26 = cir.binop(mul, %24, %25) : !cir.double + cir.store %26, %5 : !cir.double, cir.ptr + %27 = cir.load %3 : cir.ptr , !cir.double + %28 = cir.load %4 : cir.ptr , !cir.double + %29 = cir.binop(div, %27, %28) : !cir.double + cir.store %29, %5 : !cir.double, cir.ptr cir.return } } diff --git a/clang/test/CIR/Lowering/ThroughMLIR/cmp.cir b/clang/test/CIR/Lowering/ThroughMLIR/cmp.cir index 190d8a2256d4..99eea2260c26 100644 --- a/clang/test/CIR/Lowering/ThroughMLIR/cmp.cir +++ b/clang/test/CIR/Lowering/ThroughMLIR/cmp.cir @@ -6,8 +6,8 @@ module { cir.func @foo() { %0 = cir.alloca !s32i, cir.ptr , ["a"] {alignment = 4 : i64} %1 = cir.alloca !s32i, cir.ptr , ["b"] {alignment = 4 : i64} - %2 = cir.alloca f32, cir.ptr , ["c"] {alignment = 4 : i64} - %3 = cir.alloca f32, cir.ptr , ["d"] {alignment = 4 : i64} + %2 = cir.alloca !cir.float, cir.ptr , ["c"] {alignment = 4 : i64} + %3 = cir.alloca !cir.float, cir.ptr , ["d"] {alignment = 4 : i64} %4 = cir.alloca !cir.bool, cir.ptr , ["e"] {alignment = 1 : i64} %5 = cir.load %0 : cir.ptr , !s32i %6 = cir.load %1 : cir.ptr , !s32i @@ -27,24 +27,24 @@ module { %20 = cir.load %0 : cir.ptr , !s32i %21 = cir.load %1 : cir.ptr , !s32i %22 = cir.cmp(le, %20, %21) : !s32i, !cir.bool - %23 = cir.load %2 : cir.ptr , f32 - %24 = cir.load %3 : cir.ptr , f32 - %25 = cir.cmp(gt, %23, %24) : f32, !cir.bool - %26 = cir.load %2 : cir.ptr , f32 - %27 = cir.load %3 : cir.ptr , f32 - %28 = cir.cmp(eq, %26, %27) : f32, !cir.bool - %29 = cir.load %2 : cir.ptr , f32 - %30 = cir.load %3 : cir.ptr , f32 - %31 = cir.cmp(lt, %29, %30) : f32, !cir.bool - %32 = cir.load %2 : cir.ptr , f32 - %33 = cir.load %3 : cir.ptr , f32 - %34 = cir.cmp(ge, %32, %33) : f32, !cir.bool - %35 = cir.load %2 : cir.ptr , f32 - %36 = cir.load %3 : cir.ptr , f32 - %37 = cir.cmp(ne, %35, %36) : f32, !cir.bool - %38 = cir.load %2 : cir.ptr , f32 - %39 = cir.load %3 : cir.ptr , f32 - %40 = cir.cmp(le, %38, %39) : f32, !cir.bool + %23 = cir.load %2 : cir.ptr , !cir.float + %24 = cir.load %3 : cir.ptr , !cir.float + %25 = cir.cmp(gt, %23, %24) : !cir.float, !cir.bool + %26 = cir.load %2 : cir.ptr , !cir.float + %27 = cir.load %3 : cir.ptr , !cir.float + %28 = cir.cmp(eq, %26, %27) : !cir.float, !cir.bool + %29 = cir.load %2 : cir.ptr , !cir.float + %30 = cir.load %3 : cir.ptr , !cir.float + %31 = cir.cmp(lt, %29, %30) : !cir.float, !cir.bool + %32 = cir.load %2 : cir.ptr , !cir.float + %33 = cir.load %3 : cir.ptr , !cir.float + %34 = cir.cmp(ge, %32, %33) : !cir.float, !cir.bool + %35 = cir.load %2 : cir.ptr , !cir.float + %36 = cir.load %3 : cir.ptr , !cir.float + %37 = cir.cmp(ne, %35, %36) : !cir.float, !cir.bool + %38 = cir.load %2 : cir.ptr , !cir.float + %39 = cir.load %3 : cir.ptr , !cir.float + %40 = cir.cmp(le, %38, %39) : !cir.float, !cir.bool cir.return } } diff --git a/clang/test/CIR/Lowering/binop-fp.cir b/clang/test/CIR/Lowering/binop-fp.cir index 33a9c6f2a20b..cb08205231e5 100644 --- a/clang/test/CIR/Lowering/binop-fp.cir +++ b/clang/test/CIR/Lowering/binop-fp.cir @@ -3,44 +3,44 @@ module { cir.func @foo() { - %0 = cir.alloca f32, cir.ptr , ["c"] {alignment = 4 : i64} - %1 = cir.alloca f32, cir.ptr , ["d"] {alignment = 4 : i64} - %2 = cir.alloca f32, cir.ptr , ["y", init] {alignment = 4 : i64} - %3 = cir.alloca f64, cir.ptr , ["e"] {alignment = 8 : i64} - %4 = cir.alloca f64, cir.ptr , ["f"] {alignment = 8 : i64} - %5 = cir.alloca f64, cir.ptr , ["g", init] {alignment = 8 : i64} - %6 = cir.load %0 : cir.ptr , f32 - %7 = cir.load %1 : cir.ptr , f32 - %8 = cir.binop(mul, %6, %7) : f32 - cir.store %8, %2 : f32, cir.ptr - %9 = cir.load %2 : cir.ptr , f32 - %10 = cir.load %1 : cir.ptr , f32 - %11 = cir.binop(div, %9, %10) : f32 - cir.store %11, %2 : f32, cir.ptr - %12 = cir.load %2 : cir.ptr , f32 - %13 = cir.load %1 : cir.ptr , f32 - %14 = cir.binop(add, %12, %13) : f32 - cir.store %14, %2 : f32, cir.ptr - %15 = cir.load %2 : cir.ptr , f32 - %16 = cir.load %1 : cir.ptr , f32 - %17 = cir.binop(sub, %15, %16) : f32 - cir.store %17, %2 : f32, cir.ptr - %18 = cir.load %3 : cir.ptr , f64 - %19 = cir.load %4 : cir.ptr , f64 - %20 = cir.binop(add, %18, %19) : f64 - cir.store %20, %5 : f64, cir.ptr - %21 = cir.load %3 : cir.ptr , f64 - %22 = cir.load %4 : cir.ptr , f64 - %23 = cir.binop(sub, %21, %22) : f64 - cir.store %23, %5 : f64, cir.ptr - %24 = cir.load %3 : cir.ptr , f64 - %25 = cir.load %4 : cir.ptr , f64 - %26 = cir.binop(mul, %24, %25) : f64 - cir.store %26, %5 : f64, cir.ptr - %27 = cir.load %3 : cir.ptr , f64 - %28 = cir.load %4 : cir.ptr , f64 - %29 = cir.binop(div, %27, %28) : f64 - cir.store %29, %5 : f64, cir.ptr + %0 = cir.alloca !cir.float, cir.ptr , ["c"] {alignment = 4 : i64} + %1 = cir.alloca !cir.float, cir.ptr , ["d"] {alignment = 4 : i64} + %2 = cir.alloca !cir.float, cir.ptr , ["y", init] {alignment = 4 : i64} + %3 = cir.alloca !cir.double, cir.ptr , ["e"] {alignment = 8 : i64} + %4 = cir.alloca !cir.double, cir.ptr , ["f"] {alignment = 8 : i64} + %5 = cir.alloca !cir.double, cir.ptr , ["g", init] {alignment = 8 : i64} + %6 = cir.load %0 : cir.ptr , !cir.float + %7 = cir.load %1 : cir.ptr , !cir.float + %8 = cir.binop(mul, %6, %7) : !cir.float + cir.store %8, %2 : !cir.float, cir.ptr + %9 = cir.load %2 : cir.ptr , !cir.float + %10 = cir.load %1 : cir.ptr , !cir.float + %11 = cir.binop(div, %9, %10) : !cir.float + cir.store %11, %2 : !cir.float, cir.ptr + %12 = cir.load %2 : cir.ptr , !cir.float + %13 = cir.load %1 : cir.ptr , !cir.float + %14 = cir.binop(add, %12, %13) : !cir.float + cir.store %14, %2 : !cir.float, cir.ptr + %15 = cir.load %2 : cir.ptr , !cir.float + %16 = cir.load %1 : cir.ptr , !cir.float + %17 = cir.binop(sub, %15, %16) : !cir.float + cir.store %17, %2 : !cir.float, cir.ptr + %18 = cir.load %3 : cir.ptr , !cir.double + %19 = cir.load %4 : cir.ptr , !cir.double + %20 = cir.binop(add, %18, %19) : !cir.double + cir.store %20, %5 : !cir.double, cir.ptr + %21 = cir.load %3 : cir.ptr , !cir.double + %22 = cir.load %4 : cir.ptr , !cir.double + %23 = cir.binop(sub, %21, %22) : !cir.double + cir.store %23, %5 : !cir.double, cir.ptr + %24 = cir.load %3 : cir.ptr , !cir.double + %25 = cir.load %4 : cir.ptr , !cir.double + %26 = cir.binop(mul, %24, %25) : !cir.double + cir.store %26, %5 : !cir.double, cir.ptr + %27 = cir.load %3 : cir.ptr , !cir.double + %28 = cir.load %4 : cir.ptr , !cir.double + %29 = cir.binop(div, %27, %28) : !cir.double + cir.store %29, %5 : !cir.double, cir.ptr cir.return } } diff --git a/clang/test/CIR/Lowering/cast.cir b/clang/test/CIR/Lowering/cast.cir index 16e8ab968fc5..60ad48e4a644 100644 --- a/clang/test/CIR/Lowering/cast.cir +++ b/clang/test/CIR/Lowering/cast.cir @@ -10,7 +10,7 @@ !u64i = !cir.int module { - cir.func @cStyleCasts(%arg0: !u32i, %arg1: !s32i, %arg2: f32, %arg3: f64) -> !s32i { + cir.func @cStyleCasts(%arg0: !u32i, %arg1: !s32i, %arg2: !cir.float, %arg3: !cir.double) -> !s32i { // CHECK: llvm.func @cStyleCasts %0 = cir.alloca !u32i, cir.ptr , ["x1", init] {alignment = 4 : i64} %1 = cir.alloca !s32i, cir.ptr , ["x2", init] {alignment = 4 : i64} @@ -65,17 +65,17 @@ module { %29 = cir.cast(ptr_to_bool, %23 : !cir.ptr), !cir.bool // Floating point casts. - %25 = cir.cast(int_to_float, %arg1 : !s32i), f32 + %25 = cir.cast(int_to_float, %arg1 : !s32i), !cir.float // CHECK: %{{.+}} = llvm.sitofp %{{.+}} : i32 to f32 - %26 = cir.cast(int_to_float, %arg0 : !u32i), f32 + %26 = cir.cast(int_to_float, %arg0 : !u32i), !cir.float // CHECK: %{{.+}} = llvm.uitofp %{{.+}} : i32 to f32 - %27 = cir.cast(float_to_int, %arg2 : f32), !s32i + %27 = cir.cast(float_to_int, %arg2 : !cir.float), !s32i // CHECK: %{{.+}} = llvm.fptosi %{{.+}} : f32 to i32 - %28 = cir.cast(float_to_int, %arg2 : f32), !u32i + %28 = cir.cast(float_to_int, %arg2 : !cir.float), !u32i // CHECK: %{{.+}} = llvm.fptoui %{{.+}} : f32 to i32 %18 = cir.const(#cir.int<0> : !s32i) : !s32i // CHECK: %{{.+}} = llvm.fptrunc %{{.+}} : f64 to f32 - %34 = cir.cast(floating, %arg3 : f64), f32 + %34 = cir.cast(floating, %arg3 : !cir.double), !cir.float cir.store %18, %2 : !s32i, cir.ptr %19 = cir.load %2 : cir.ptr , !s32i diff --git a/clang/test/CIR/Lowering/class.cir b/clang/test/CIR/Lowering/class.cir index afaacbec1bac..6a390485eec5 100644 --- a/clang/test/CIR/Lowering/class.cir +++ b/clang/test/CIR/Lowering/class.cir @@ -6,7 +6,7 @@ !u32i = !cir.int !ty_22S22 = !cir.struct !ty_22S2A22 = !cir.struct -!ty_22S122 = !cir.struct} #cir.record.decl.ast> +!ty_22S122 = !cir.struct} #cir.record.decl.ast> !ty_22S222 = !cir.struct !ty_22S322 = !cir.struct @@ -39,12 +39,12 @@ module { // CHECK: } // Should lower basic #cir.const_struct initializer. - cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.ptr : !cir.ptr}> : !ty_22S122 + cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_22S122 // CHECK: llvm.mlir.global external @s1() {addr_space = 0 : i32} : !llvm.struct<"class.S1", (i32, f32, ptr)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"class.S1", (i32, f32, ptr)> // CHECK: %1 = llvm.mlir.constant(1 : i32) : i32 // CHECK: %2 = llvm.insertvalue %1, %0[0] : !llvm.struct<"class.S1", (i32, f32, ptr)> - // CHECK: %3 = llvm.mlir.constant(1.000000e-01 : f32) : f32 + // CHECK: %3 = llvm.mlir.constant(0.099999994 : f32) : f32 // CHECK: %4 = llvm.insertvalue %3, %2[1] : !llvm.struct<"class.S1", (i32, f32, ptr)> // CHECK: %5 = llvm.mlir.zero : !llvm.ptr // CHECK: %6 = llvm.insertvalue %5, %4[2] : !llvm.struct<"class.S1", (i32, f32, ptr)> diff --git a/clang/test/CIR/Lowering/cmp.cir b/clang/test/CIR/Lowering/cmp.cir index 94b4b2cdd8a0..06dd60ff5453 100644 --- a/clang/test/CIR/Lowering/cmp.cir +++ b/clang/test/CIR/Lowering/cmp.cir @@ -6,8 +6,8 @@ module { cir.func @foo() { %0 = cir.alloca !s32i, cir.ptr , ["a"] {alignment = 4 : i64} %1 = cir.alloca !s32i, cir.ptr , ["b"] {alignment = 4 : i64} - %2 = cir.alloca f32, cir.ptr , ["c"] {alignment = 4 : i64} - %3 = cir.alloca f32, cir.ptr , ["d"] {alignment = 4 : i64} + %2 = cir.alloca !cir.float, cir.ptr , ["c"] {alignment = 4 : i64} + %3 = cir.alloca !cir.float, cir.ptr , ["d"] {alignment = 4 : i64} %4 = cir.alloca !cir.bool, cir.ptr , ["e"] {alignment = 1 : i64} %5 = cir.load %0 : cir.ptr , !s32i %6 = cir.load %1 : cir.ptr , !s32i @@ -33,29 +33,29 @@ module { %21 = cir.load %1 : cir.ptr , !s32i %22 = cir.cmp(le, %20, %21) : !s32i, !cir.bool // CHECK: llvm.icmp "sle" - %23 = cir.load %2 : cir.ptr , f32 - %24 = cir.load %3 : cir.ptr , f32 - %25 = cir.cmp(gt, %23, %24) : f32, !cir.bool + %23 = cir.load %2 : cir.ptr , !cir.float + %24 = cir.load %3 : cir.ptr , !cir.float + %25 = cir.cmp(gt, %23, %24) : !cir.float, !cir.bool // CHECK: llvm.fcmp "ogt" - %26 = cir.load %2 : cir.ptr , f32 - %27 = cir.load %3 : cir.ptr , f32 - %28 = cir.cmp(eq, %26, %27) : f32, !cir.bool + %26 = cir.load %2 : cir.ptr , !cir.float + %27 = cir.load %3 : cir.ptr , !cir.float + %28 = cir.cmp(eq, %26, %27) : !cir.float, !cir.bool // CHECK: llvm.fcmp "oeq" - %29 = cir.load %2 : cir.ptr , f32 - %30 = cir.load %3 : cir.ptr , f32 - %31 = cir.cmp(lt, %29, %30) : f32, !cir.bool + %29 = cir.load %2 : cir.ptr , !cir.float + %30 = cir.load %3 : cir.ptr , !cir.float + %31 = cir.cmp(lt, %29, %30) : !cir.float, !cir.bool // CHECK: llvm.fcmp "olt" - %32 = cir.load %2 : cir.ptr , f32 - %33 = cir.load %3 : cir.ptr , f32 - %34 = cir.cmp(ge, %32, %33) : f32, !cir.bool + %32 = cir.load %2 : cir.ptr , !cir.float + %33 = cir.load %3 : cir.ptr , !cir.float + %34 = cir.cmp(ge, %32, %33) : !cir.float, !cir.bool // CHECK: llvm.fcmp "oge" - %35 = cir.load %2 : cir.ptr , f32 - %36 = cir.load %3 : cir.ptr , f32 - %37 = cir.cmp(ne, %35, %36) : f32, !cir.bool + %35 = cir.load %2 : cir.ptr , !cir.float + %36 = cir.load %3 : cir.ptr , !cir.float + %37 = cir.cmp(ne, %35, %36) : !cir.float, !cir.bool // CHECK: llvm.fcmp "une" - %38 = cir.load %2 : cir.ptr , f32 - %39 = cir.load %3 : cir.ptr , f32 - %40 = cir.cmp(le, %38, %39) : f32, !cir.bool + %38 = cir.load %2 : cir.ptr , !cir.float + %39 = cir.load %3 : cir.ptr , !cir.float + %40 = cir.cmp(le, %38, %39) : !cir.float, !cir.bool // CHECK: llvm.fcmp "ole" // Pointer comparisons. diff --git a/clang/test/CIR/Lowering/const.cir b/clang/test/CIR/Lowering/const.cir index 5cbcb757ddb6..76ec616bed21 100644 --- a/clang/test/CIR/Lowering/const.cir +++ b/clang/test/CIR/Lowering/const.cir @@ -11,7 +11,7 @@ module { // CHECK: llvm.mlir.constant(dense<[115, 116, 114, 105, 110, 103, 0]> : tensor<7xi8>) : !llvm.array<7 x i8> %1 = cir.const(#cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i]> : !cir.array) : !cir.array // CHECK: llvm.mlir.constant(dense<[1, 2]> : tensor<2xi32>) : !llvm.array<2 x i32> - %3 = cir.const(#cir.const_array<[1.000000e+00 : f32, 2.000000e+00 : f32]> : !cir.array) : !cir.array + %3 = cir.const(#cir.const_array<[#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.000000e+00> : !cir.float]> : !cir.array) : !cir.array // CHECK: llvm.mlir.constant(dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf32>) : !llvm.array<2 x f32> %4 = cir.const(#cir.zero : !cir.array) : !cir.array // CHECK: cir.llvmir.zeroinit : !llvm.array<3 x i32> @@ -21,8 +21,8 @@ module { cir.func @testConvertConstArrayToDenseConst() { %0 = cir.const(#cir.const_array<[#cir.const_array<[#cir.int<1> : !s32i]> : !cir.array, #cir.zero : !cir.array]> : !cir.array x 2>) : !cir.array x 2> %1 = cir.const(#cir.const_array<[#cir.const_array<[#cir.int<1> : !s64i]> : !cir.array, #cir.zero : !cir.array]> : !cir.array x 2>) : !cir.array x 2> - %2 = cir.const(#cir.const_array<[#cir.const_array<[1.000000e+00 : f32]> : !cir.array, #cir.zero : !cir.array]> : !cir.array x 2>) : !cir.array x 2> - %3 = cir.const(#cir.const_array<[#cir.const_array<[1.000000e+00]> : !cir.array, #cir.zero : !cir.array]> : !cir.array x 2>) : !cir.array x 2> + %2 = cir.const(#cir.const_array<[#cir.const_array<[#cir.fp<1.000000e+00> : !cir.float]> : !cir.array, #cir.zero : !cir.array]> : !cir.array x 2>) : !cir.array x 2> + %3 = cir.const(#cir.const_array<[#cir.const_array<[#cir.fp<1.000000e+00> : !cir.double]> : !cir.array, #cir.zero : !cir.array]> : !cir.array x 2>) : !cir.array x 2> %4 = cir.const(#cir.const_array<[#cir.const_array<[#cir.const_array<[#cir.int<1> : !s32i, #cir.int<1> : !s32i, #cir.int<1> : !s32i]> : !cir.array]> : !cir.array x 1>, #cir.zero : !cir.array x 1>]> : !cir.array x 1> x 2>) : !cir.array x 1> x 2> cir.return diff --git a/clang/test/CIR/Lowering/dot.cir b/clang/test/CIR/Lowering/dot.cir index 401399f054a8..02fb1c92affb 100644 --- a/clang/test/CIR/Lowering/dot.cir +++ b/clang/test/CIR/Lowering/dot.cir @@ -3,17 +3,17 @@ !s32i = !cir.int module { - cir.func @dot(%arg0: !cir.ptr, %arg1: !cir.ptr, %arg2: !s32i) -> f64 { - %0 = cir.alloca !cir.ptr, cir.ptr >, ["a", init] {alignment = 8 : i64} - %1 = cir.alloca !cir.ptr, cir.ptr >, ["b", init] {alignment = 8 : i64} + cir.func @dot(%arg0: !cir.ptr, %arg1: !cir.ptr, %arg2: !s32i) -> !cir.double { + %0 = cir.alloca !cir.ptr, cir.ptr >, ["a", init] {alignment = 8 : i64} + %1 = cir.alloca !cir.ptr, cir.ptr >, ["b", init] {alignment = 8 : i64} %2 = cir.alloca !s32i, cir.ptr , ["size", init] {alignment = 4 : i64} - %3 = cir.alloca f64, cir.ptr , ["__retval"] {alignment = 8 : i64} - %4 = cir.alloca f64, cir.ptr , ["q", init] {alignment = 8 : i64} - cir.store %arg0, %0 : !cir.ptr, cir.ptr > - cir.store %arg1, %1 : !cir.ptr, cir.ptr > + %3 = cir.alloca !cir.double, cir.ptr , ["__retval"] {alignment = 8 : i64} + %4 = cir.alloca !cir.double, cir.ptr , ["q", init] {alignment = 8 : i64} + cir.store %arg0, %0 : !cir.ptr, cir.ptr > + cir.store %arg1, %1 : !cir.ptr, cir.ptr > cir.store %arg2, %2 : !s32i, cir.ptr - %5 = cir.const(0.000000e+00 : f64) : f64 - cir.store %5, %4 : f64, cir.ptr + %5 = cir.const(#cir.fp<0.000000e+00> : !cir.double) : !cir.double + cir.store %5, %4 : !cir.double, cir.ptr cir.scope { %8 = cir.alloca !s32i, cir.ptr , ["i", init] {alignment = 4 : i64} %9 = cir.const(#cir.int<0> : !s32i) : !s32i @@ -25,18 +25,18 @@ module { %13 = cir.cast(int_to_bool, %12 : !s32i), !cir.bool cir.condition(%13) } body { - %10 = cir.load %0 : cir.ptr >, !cir.ptr + %10 = cir.load %0 : cir.ptr >, !cir.ptr %11 = cir.load %8 : cir.ptr , !s32i - %12 = cir.ptr_stride(%10 : !cir.ptr, %11 : !s32i), !cir.ptr - %13 = cir.load %12 : cir.ptr , f64 - %14 = cir.load %1 : cir.ptr >, !cir.ptr + %12 = cir.ptr_stride(%10 : !cir.ptr, %11 : !s32i), !cir.ptr + %13 = cir.load %12 : cir.ptr , !cir.double + %14 = cir.load %1 : cir.ptr >, !cir.ptr %15 = cir.load %8 : cir.ptr , !s32i - %16 = cir.ptr_stride(%14 : !cir.ptr, %15 : !s32i), !cir.ptr - %17 = cir.load %16 : cir.ptr , f64 - %18 = cir.binop(mul, %13, %17) : f64 - %19 = cir.load %4 : cir.ptr , f64 - %20 = cir.binop(add, %19, %18) : f64 - cir.store %20, %4 : f64, cir.ptr + %16 = cir.ptr_stride(%14 : !cir.ptr, %15 : !s32i), !cir.ptr + %17 = cir.load %16 : cir.ptr , !cir.double + %18 = cir.binop(mul, %13, %17) : !cir.double + %19 = cir.load %4 : cir.ptr , !cir.double + %20 = cir.binop(add, %19, %18) : !cir.double + cir.store %20, %4 : !cir.double, cir.ptr cir.yield } step { %10 = cir.load %8 : cir.ptr , !s32i @@ -45,10 +45,10 @@ module { cir.yield } } - %6 = cir.load %4 : cir.ptr , f64 - cir.store %6, %3 : f64, cir.ptr - %7 = cir.load %3 : cir.ptr , f64 - cir.return %7 : f64 + %6 = cir.load %4 : cir.ptr , !cir.double + cir.store %6, %3 : !cir.double, cir.ptr + %7 = cir.load %3 : cir.ptr , !cir.double + cir.return %7 : !cir.double } } diff --git a/clang/test/CIR/Lowering/float.cir b/clang/test/CIR/Lowering/float.cir new file mode 100644 index 000000000000..ea30674ff7fe --- /dev/null +++ b/clang/test/CIR/Lowering/float.cir @@ -0,0 +1,20 @@ +// RUN: cir-opt %s -cir-to-llvm -o %t.mlir +// RUN: FileCheck %s --input-file=%t.mlir + +module { + cir.func @test() { + // %0 = cir.const(1.0 : f16) : f16 + // DISABLED-CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : f16) : f16 + %1 = cir.const(#cir.fp<1.0> : !cir.float) : !cir.float + // CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : f32) : f32 + %2 = cir.const(#cir.fp<1.0> : !cir.double) : !cir.double + // CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : f64) : f64 + // %3 = cir.const(1.0 : f128) : f128 + // DISABLED-CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : f128) : f128 + // %4 = cir.const(1.0 : f80) : f80 + // DISABLED-CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : f80) : f80 + // %5 = cir.const(1.0 : bf16) : bf16 + // DISABLED-CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : bf16) : bf16 + cir.return + } +} \ No newline at end of file diff --git a/clang/test/CIR/Lowering/globals.cir b/clang/test/CIR/Lowering/globals.cir index 99bfa76dd3a8..dde8087fada6 100644 --- a/clang/test/CIR/Lowering/globals.cir +++ b/clang/test/CIR/Lowering/globals.cir @@ -20,8 +20,8 @@ module { cir.global external @a = #cir.int<3> : !s32i cir.global external @c = #cir.int<2> : !u64i - cir.global external @y = 3.400000e+00 : f32 - cir.global external @w = 4.300000e+00 : f64 + cir.global external @y = #cir.fp<3.400000e+00> : !cir.float + cir.global external @w = #cir.fp<4.300000e+00> : !cir.double cir.global external @x = #cir.int<51> : !s8i cir.global external @rgb = #cir.const_array<[#cir.int<0> : !u8i, #cir.int<233> : !u8i, #cir.int<33> : !u8i]> : !cir.array cir.global external @alpha = #cir.const_array<[#cir.int<97> : !s8i, #cir.int<98> : !s8i, #cir.int<99> : !s8i, #cir.int<0> : !s8i]> : !cir.array @@ -130,8 +130,8 @@ module { cir.store %14, %4 : !cir.ptr, cir.ptr > cir.return } - cir.global external @flt = #cir.const_array<[1.000000e+00 : f32, 2.000000e+00 : f32]> : !cir.array - cir.global external @zeroInitFlt = #cir.const_array<[0.000000e+00 : f32, 0.000000e+00 : f32]> : !cir.array + cir.global external @flt = #cir.const_array<[#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.000000e+00> : !cir.float]> : !cir.array + cir.global external @zeroInitFlt = #cir.const_array<[#cir.fp<0.000000e+00> : !cir.float, #cir.fp<0.000000e+00> : !cir.float]> : !cir.array // MLIR: llvm.mlir.global external @flt(dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf32>) {addr_space = 0 : i32} : !llvm.array<2 x f32> // MLIR: llvm.mlir.global external @zeroInitFlt(dense<0.000000e+00> : tensor<2xf32>) {addr_space = 0 : i32} : !llvm.array<2 x f32> cir.global "private" internal @staticVar = #cir.int<0> : !s32i diff --git a/clang/test/CIR/Lowering/libc.cir b/clang/test/CIR/Lowering/libc.cir index 70a066854d46..5be5d44cd3c6 100644 --- a/clang/test/CIR/Lowering/libc.cir +++ b/clang/test/CIR/Lowering/libc.cir @@ -10,9 +10,9 @@ module { cir.return } - cir.func @shouldLowerLibcFAbsBuiltin(%arg0: f64) -> f64 { - %0 = cir.fabs %arg0 : f64 + cir.func @shouldLowerLibcFAbsBuiltin(%arg0: !cir.double) -> !cir.double { + %0 = cir.fabs %arg0 : !cir.double // CHECK: %0 = llvm.intr.fabs(%arg0) : (f64) -> f64 - cir.return %0 : f64 + cir.return %0 : !cir.double } } diff --git a/clang/test/CIR/Lowering/struct.cir b/clang/test/CIR/Lowering/struct.cir index 207aa6d47031..642bb1e53f60 100644 --- a/clang/test/CIR/Lowering/struct.cir +++ b/clang/test/CIR/Lowering/struct.cir @@ -6,7 +6,7 @@ !u32i = !cir.int !ty_22S22 = !cir.struct !ty_22S2A22 = !cir.struct -!ty_22S122 = !cir.struct} #cir.record.decl.ast> +!ty_22S122 = !cir.struct} #cir.record.decl.ast> !ty_22S222 = !cir.struct !ty_22S322 = !cir.struct @@ -39,12 +39,12 @@ module { // CHECK: } // Should lower basic #cir.const_struct initializer. - cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.ptr : !cir.ptr}> : !ty_22S122 + cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, #cir.fp<1.000000e-01> : !cir.float, #cir.ptr : !cir.ptr}> : !ty_22S122 // CHECK: llvm.mlir.global external @s1() {addr_space = 0 : i32} : !llvm.struct<"struct.S1", (i32, f32, ptr)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"struct.S1", (i32, f32, ptr)> // CHECK: %1 = llvm.mlir.constant(1 : i32) : i32 // CHECK: %2 = llvm.insertvalue %1, %0[0] : !llvm.struct<"struct.S1", (i32, f32, ptr)> - // CHECK: %3 = llvm.mlir.constant(1.000000e-01 : f32) : f32 + // CHECK: %3 = llvm.mlir.constant(0.099999994 : f32) : f32 // CHECK: %4 = llvm.insertvalue %3, %2[1] : !llvm.struct<"struct.S1", (i32, f32, ptr)> // CHECK: %5 = llvm.mlir.zero : !llvm.ptr // CHECK: %6 = llvm.insertvalue %5, %4[2] : !llvm.struct<"struct.S1", (i32, f32, ptr)> diff --git a/clang/test/CIR/Lowering/unary-inc-dec.cir b/clang/test/CIR/Lowering/unary-inc-dec.cir index 2b4a001dfc7c..a5ea94324b55 100644 --- a/clang/test/CIR/Lowering/unary-inc-dec.cir +++ b/clang/test/CIR/Lowering/unary-inc-dec.cir @@ -27,34 +27,34 @@ module { // LLVM: = add i32 %[[#]], 1 // LLVM: = sub i32 %[[#]], 1 - cir.func @floatingPoint(%arg0: f32, %arg1: f64) { + cir.func @floatingPoint(%arg0: !cir.float, %arg1: !cir.double) { // MLIR: llvm.func @floatingPoint - %0 = cir.alloca f32, cir.ptr , ["f", init] {alignment = 4 : i64} - %1 = cir.alloca f64, cir.ptr , ["d", init] {alignment = 8 : i64} - cir.store %arg0, %0 : f32, cir.ptr - cir.store %arg1, %1 : f64, cir.ptr - - %2 = cir.load %0 : cir.ptr , f32 - %3 = cir.unary(inc, %2) : f32, f32 - cir.store %3, %0 : f32, cir.ptr + %0 = cir.alloca !cir.float, cir.ptr , ["f", init] {alignment = 4 : i64} + %1 = cir.alloca !cir.double, cir.ptr , ["d", init] {alignment = 8 : i64} + cir.store %arg0, %0 : !cir.float, cir.ptr + cir.store %arg1, %1 : !cir.double, cir.ptr + + %2 = cir.load %0 : cir.ptr , !cir.float + %3 = cir.unary(inc, %2) : !cir.float, !cir.float + cir.store %3, %0 : !cir.float, cir.ptr // MLIR: %[[#F_ONE:]] = llvm.mlir.constant(1.000000e+00 : f32) : f32 // MLIR: = llvm.fadd %[[#F_ONE]], %{{[0-9]+}} : f32 - %4 = cir.load %0 : cir.ptr , f32 - %5 = cir.unary(dec, %4) : f32, f32 - cir.store %5, %0 : f32, cir.ptr + %4 = cir.load %0 : cir.ptr , !cir.float + %5 = cir.unary(dec, %4) : !cir.float, !cir.float + cir.store %5, %0 : !cir.float, cir.ptr // MLIR: %[[#D_ONE:]] = llvm.mlir.constant(-1.000000e+00 : f32) : f32 // MLIR: = llvm.fsub %[[#D_ONE]], %{{[0-9]+}} : f32 - %6 = cir.load %1 : cir.ptr , f64 - %7 = cir.unary(inc, %6) : f64, f64 - cir.store %7, %1 : f64, cir.ptr + %6 = cir.load %1 : cir.ptr , !cir.double + %7 = cir.unary(inc, %6) : !cir.double, !cir.double + cir.store %7, %1 : !cir.double, cir.ptr // MLIR: %[[#D_ONE:]] = llvm.mlir.constant(1.000000e+00 : f64) : f64 // MLIR: = llvm.fadd %[[#D_ONE]], %{{[0-9]+}} : f64 - %8 = cir.load %1 : cir.ptr , f64 - %9 = cir.unary(dec, %8) : f64, f64 - cir.store %9, %1 : f64, cir.ptr + %8 = cir.load %1 : cir.ptr , !cir.double + %9 = cir.unary(dec, %8) : !cir.double, !cir.double + cir.store %9, %1 : !cir.double, cir.ptr // MLIR: %[[#D_ONE:]] = llvm.mlir.constant(-1.000000e+00 : f64) : f64 // MLIR: = llvm.fsub %[[#D_ONE]], %{{[0-9]+}} : f64 diff --git a/clang/test/CIR/Lowering/unary-not.cir b/clang/test/CIR/Lowering/unary-not.cir index 58f3357c9df2..21b12755ae02 100644 --- a/clang/test/CIR/Lowering/unary-not.cir +++ b/clang/test/CIR/Lowering/unary-not.cir @@ -21,22 +21,22 @@ module { // LLVM: = xor i32 -1, %[[#]] - cir.func @floatingPoint(%arg0: f32, %arg1: f64) { + cir.func @floatingPoint(%arg0: !cir.float, %arg1: !cir.double) { // MLIR: llvm.func @floatingPoint - %0 = cir.alloca f32, cir.ptr , ["f", init] {alignment = 4 : i64} - %1 = cir.alloca f64, cir.ptr , ["d", init] {alignment = 8 : i64} - cir.store %arg0, %0 : f32, cir.ptr - cir.store %arg1, %1 : f64, cir.ptr - %2 = cir.load %0 : cir.ptr , f32 - %3 = cir.cast(float_to_bool, %2 : f32), !cir.bool + %0 = cir.alloca !cir.float, cir.ptr , ["f", init] {alignment = 4 : i64} + %1 = cir.alloca !cir.double, cir.ptr , ["d", init] {alignment = 8 : i64} + cir.store %arg0, %0 : !cir.float, cir.ptr + cir.store %arg1, %1 : !cir.double, cir.ptr + %2 = cir.load %0 : cir.ptr , !cir.float + %3 = cir.cast(float_to_bool, %2 : !cir.float), !cir.bool // MLIR: %[[#F_ZERO:]] = llvm.mlir.constant(0.000000e+00 : f32) : f32 // MLIR: %[[#F_BOOL:]] = llvm.fcmp "une" %{{.+}}, %[[#F_ZERO]] : f32 // MLIR: %[[#F_ZEXT:]] = llvm.zext %[[#F_BOOL]] : i1 to i8 %4 = cir.unary(not, %3) : !cir.bool, !cir.bool // MLIR: %[[#F_ONE:]] = llvm.mlir.constant(1 : i8) : i8 // MLIR: = llvm.xor %[[#F_ZEXT]], %[[#F_ONE]] : i8 - %5 = cir.load %1 : cir.ptr , f64 - %6 = cir.cast(float_to_bool, %5 : f64), !cir.bool + %5 = cir.load %1 : cir.ptr , !cir.double + %6 = cir.cast(float_to_bool, %5 : !cir.double), !cir.bool // MLIR: %[[#D_ZERO:]] = llvm.mlir.constant(0.000000e+00 : f64) : f64 // MLIR: %[[#D_BOOL:]] = llvm.fcmp "une" %{{.+}}, %[[#D_ZERO]] : f64 // MLIR: %[[#D_ZEXT:]] = llvm.zext %[[#D_BOOL]] : i1 to i8 @@ -46,12 +46,12 @@ module { cir.return } - cir.func @CStyleValueNegation(%arg0: !s32i, %arg1: f32) { + cir.func @CStyleValueNegation(%arg0: !s32i, %arg1: !cir.float) { // MLIR: llvm.func @CStyleValueNegation %0 = cir.alloca !s32i, cir.ptr , ["i", init] {alignment = 4 : i64} - %3 = cir.alloca f32, cir.ptr , ["f", init] {alignment = 4 : i64} + %3 = cir.alloca !cir.float, cir.ptr , ["f", init] {alignment = 4 : i64} cir.store %arg0, %0 : !s32i, cir.ptr - cir.store %arg1, %3 : f32, cir.ptr + cir.store %arg1, %3 : !cir.float, cir.ptr %5 = cir.load %0 : cir.ptr , !s32i %6 = cir.cast(int_to_bool, %5 : !s32i), !cir.bool @@ -65,8 +65,8 @@ module { // MLIR: %[[#IXOR:]] = llvm.xor %[[#IEXT]], %[[#IONE]] : i8 // MLIR: = llvm.zext %[[#IXOR]] : i8 to i32 - %17 = cir.load %3 : cir.ptr , f32 - %18 = cir.cast(float_to_bool, %17 : f32), !cir.bool + %17 = cir.load %3 : cir.ptr , !cir.float + %18 = cir.cast(float_to_bool, %17 : !cir.float), !cir.bool %19 = cir.unary(not, %18) : !cir.bool, !cir.bool %20 = cir.cast(bool_to_int, %19 : !cir.bool), !s32i // MLIR: %[[#FLOAT:]] = llvm.load %{{.+}} : !llvm.ptr diff --git a/clang/test/CIR/Lowering/unary-plus-minus.cir b/clang/test/CIR/Lowering/unary-plus-minus.cir index a4e254939912..dbf71c2833bd 100644 --- a/clang/test/CIR/Lowering/unary-plus-minus.cir +++ b/clang/test/CIR/Lowering/unary-plus-minus.cir @@ -26,16 +26,16 @@ module { // MLIR: %[[ZERO:[a-z0-9_]+]] = llvm.mlir.constant(0 : i32) // MLIR: llvm.sub %[[ZERO]], %[[#INPUT_MINUS]] - cir.func @floatingPoints(%arg0: f64) { + cir.func @floatingPoints(%arg0: !cir.double) { // MLIR: llvm.func @floatingPoints(%arg0: f64) - %0 = cir.alloca f64, cir.ptr , ["X", init] {alignment = 8 : i64} - cir.store %arg0, %0 : f64, cir.ptr - %1 = cir.load %0 : cir.ptr , f64 - %2 = cir.unary(plus, %1) : f64, f64 + %0 = cir.alloca !cir.double, cir.ptr , ["X", init] {alignment = 8 : i64} + cir.store %arg0, %0 : !cir.double, cir.ptr + %1 = cir.load %0 : cir.ptr , !cir.double + %2 = cir.unary(plus, %1) : !cir.double, !cir.double // MLIR: llvm.store %arg0, %[[#F_PLUS:]] : f64, !llvm.ptr // MLIR: %{{[0-9]}} = llvm.load %[[#F_PLUS]] : !llvm.ptr -> f64 - %3 = cir.load %0 : cir.ptr , f64 - %4 = cir.unary(minus, %3) : f64, f64 + %3 = cir.load %0 : cir.ptr , !cir.double + %4 = cir.unary(minus, %3) : !cir.double, !cir.double // MLIR: %[[#F_MINUS:]] = llvm.load %{{[0-9]}} : !llvm.ptr -> f64 // MLIR: %{{[0-9]}} = llvm.fneg %[[#F_MINUS]] : f64 cir.return