From 1ee6dfd5a131aefb4c5e44431622a5c498abdaf8 Mon Sep 17 00:00:00 2001 From: Sirui Mu Date: Tue, 16 Apr 2024 20:59:01 +0800 Subject: [PATCH] Remove !cir.f128 and !cir.ppc_doubledouble --- .../include/clang/CIR/Dialect/IR/CIRTypes.td | 18 +------- clang/lib/CIR/CodeGen/CIRGenBuilder.h | 5 +-- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 -- clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 2 - clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 45 +------------------ .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 7 --- clang/test/CIR/IR/invalid.cir | 7 +++ clang/test/CIR/Lowering/float.cir | 4 +- 8 files changed, 13 insertions(+), 78 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index f5abef32da2e..fdcfada09859 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -173,20 +173,6 @@ def CIR_FP80 : CIR_FloatType<"FP80", "f80"> { }]; } -def CIR_FP128 : CIR_FloatType<"FP128", "f128"> { - let summary = "CIR type that represents IEEE-754 binary128 format"; - let description = [{ - Floating-point type that represents the IEEE-754 binary128 format";. - }]; -} - -def CIR_PPCDoubleDouble : CIR_FloatType<"PPCDoubleDouble", "ppc_doubledouble"> { - let summary = "CIR type that represents PowerPC double-double format"; - let description = [{ - Floating-point type that represents the PowerPC double-double format. - }]; -} - def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> { let summary = "CIR extended-precision float type"; let description = [{ @@ -194,8 +180,8 @@ def CIR_LongDouble : CIR_FloatType<"LongDouble", "long_double"> { The underlying floating-point format of a long double value depends on the implementation. The `underlying` parameter specifies the CIR floating-point - type that corresponds to this format. It can be one of `!cir.double`, - `!cir.f80`, `!cir.f128`, or `!cir.ppc_doubledouble`. + type that corresponds to this format. For now, it can only be either + `!cir.double` or `!cir.fp80`. }]; let parameters = (ins "mlir::Type":$underlying); diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index bbf40275292c..14d3e66f14cb 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -380,10 +380,9 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { if (&format == &llvm::APFloat::x87DoubleExtended()) return mlir::cir::LongDoubleType::get(getContext(), typeCache.FP80Ty); if (&format == &llvm::APFloat::IEEEquad()) - return mlir::cir::LongDoubleType::get(getContext(), typeCache.FP128Ty); + llvm_unreachable("NYI"); if (&format == &llvm::APFloat::PPCDoubleDouble()) - return mlir::cir::LongDoubleType::get(getContext(), - typeCache.PPCDoubleDoubleTy); + llvm_unreachable("NYI"); llvm_unreachable("unsupported long double format"); } diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index aac947f98f99..0188a8dc9189 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -136,9 +136,6 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &context, FloatTy = ::mlir::cir::SingleType::get(builder.getContext()); DoubleTy = ::mlir::cir::DoubleType::get(builder.getContext()); FP80Ty = ::mlir::cir::FP80Type::get(builder.getContext()); - FP128Ty = ::mlir::cir::FP128Type::get(builder.getContext()); - PPCDoubleDoubleTy = - ::mlir::cir::PPCDoubleDoubleType::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. diff --git a/clang/lib/CIR/CodeGen/CIRGenTypeCache.h b/clang/lib/CIR/CodeGen/CIRGenTypeCache.h index 6f446072356a..abd7d9d03603 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypeCache.h +++ b/clang/lib/CIR/CodeGen/CIRGenTypeCache.h @@ -40,8 +40,6 @@ struct CIRGenTypeCache { mlir::cir::SingleType FloatTy; mlir::cir::DoubleType DoubleTy; mlir::cir::FP80Type FP80Ty; - mlir::cir::FP128Type FP128Ty; - mlir::cir::PPCDoubleDoubleType PPCDoubleDoubleTy; /// int mlir::Type UIntTy; diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index 92e02d808b44..7d3bae036ff3 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -724,49 +724,6 @@ FP80Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout, return 16; } -const llvm::fltSemantics &FP128Type::getFloatSemantics() const { - return llvm::APFloat::IEEEquad(); -} - -llvm::TypeSize -FP128Type::getTypeSizeInBits(const mlir::DataLayout &dataLayout, - mlir::DataLayoutEntryListRef params) const { - return llvm::TypeSize::getFixed(getWidth()); -} - -uint64_t FP128Type::getABIAlignment(const mlir::DataLayout &dataLayout, - mlir::DataLayoutEntryListRef params) const { - return (uint64_t)(getWidth() / 8); -} - -uint64_t -FP128Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout, - ::mlir::DataLayoutEntryListRef params) const { - return (uint64_t)(getWidth() / 8); -} - -const llvm::fltSemantics &PPCDoubleDoubleType::getFloatSemantics() const { - return llvm::APFloat::PPCDoubleDouble(); -} - -llvm::TypeSize PPCDoubleDoubleType::getTypeSizeInBits( - const mlir::DataLayout &dataLayout, - mlir::DataLayoutEntryListRef params) const { - return llvm::TypeSize::getFixed(getWidth()); -} - -uint64_t PPCDoubleDoubleType::getABIAlignment( - const mlir::DataLayout &dataLayout, - mlir::DataLayoutEntryListRef params) const { - return (uint64_t)(getWidth() / 8); -} - -uint64_t PPCDoubleDoubleType::getPreferredAlignment( - const ::mlir::DataLayout &dataLayout, - ::mlir::DataLayoutEntryListRef params) const { - return (uint64_t)(getWidth() / 8); -} - const llvm::fltSemantics &LongDoubleType::getFloatSemantics() const { return getUnderlying() .cast() @@ -799,7 +756,7 @@ uint64_t LongDoubleType::getPreferredAlignment( LogicalResult LongDoubleType::verify(function_ref emitError, mlir::Type underlying) { - if (!underlying.isa()) { + if (!underlying.isa()) { emitError() << "invalid underlying type for long double"; return failure(); } diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index f6d7c281f72d..13e02c7b559c 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -3129,13 +3129,6 @@ void prepareTypeConverter(mlir::LLVMTypeConverter &converter, converter.addConversion([&](mlir::cir::FP80Type type) -> mlir::Type { return mlir::FloatType::getF80(type.getContext()); }); - converter.addConversion([&](mlir::cir::FP128Type type) -> mlir::Type { - return mlir::FloatType::getF128(type.getContext()); - }); - converter.addConversion( - [&](mlir::cir::PPCDoubleDoubleType type) -> mlir::Type { - return mlir::LLVM::LLVMPPCFP128Type::get(type.getContext()); - }); converter.addConversion([&](mlir::cir::LongDoubleType type) -> mlir::Type { return converter.convertType(type.getUnderlying()); }); diff --git a/clang/test/CIR/IR/invalid.cir b/clang/test/CIR/IR/invalid.cir index 0246b47b934e..0ec99921e6de 100644 --- a/clang/test/CIR/IR/invalid.cir +++ b/clang/test/CIR/IR/invalid.cir @@ -1042,3 +1042,10 @@ cir.func @bad_fetch(%x: !cir.ptr, %y: !cir.float) -> () { %12 = cir.atomic.fetch(xor, %x : !cir.ptr, %y : !cir.float, seq_cst) : !cir.float cir.return } + +// ----- + +// expected-error@+1 {{invalid underlying type for long double}} +cir.func @bad_long_double(%arg0 : !cir.long_double) -> () { + cir.return +} diff --git a/clang/test/CIR/Lowering/float.cir b/clang/test/CIR/Lowering/float.cir index 60f437bc3357..463768a35935 100644 --- a/clang/test/CIR/Lowering/float.cir +++ b/clang/test/CIR/Lowering/float.cir @@ -9,9 +9,7 @@ module { // 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(#cir.fp<1.0> : !cir.long_double) : !cir.long_double - // CHECK: %{{.+}} = llvm.mlir.constant(1.000000e+00 : f128) : f128 - %4 = cir.const(#cir.fp<1.0> : !cir.long_double) : !cir.long_double + %3 = cir.const(#cir.fp<1.0> : !cir.long_double) : !cir.long_double // 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