From 4add0e3db94af001fccb5f0d8e8b279d78084f36 Mon Sep 17 00:00:00 2001 From: V Donaldson Date: Thu, 13 Apr 2023 18:33:29 -0700 Subject: [PATCH] Revert "[flang] REAL(KIND=3) and COMPLEX(KIND=3) descriptors" This reverts commit 17a4fcecf40ee5191ab05b27a58ac37e5f57261d. --- flang/include/flang/ISO_Fortran_binding.h | 9 +- flang/include/flang/Optimizer/Support/TypeCode.h | 76 +++++++++++- flang/lib/Optimizer/CodeGen/CodeGen.cpp | 131 ++++++++++++++++----- flang/lib/Optimizer/Support/CMakeLists.txt | 1 - flang/lib/Optimizer/Support/TypeCode.cpp | 107 ----------------- .../Transforms/PolymorphicOpConversion.cpp | 26 +++- flang/test/Fir/convert-to-llvm.fir | 10 +- flang/test/Lower/real-descriptors.f90 | 98 --------------- 8 files changed, 211 insertions(+), 247 deletions(-) delete mode 100644 flang/lib/Optimizer/Support/TypeCode.cpp delete mode 100644 flang/test/Lower/real-descriptors.f90 diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h index b4a5e7c..dbfc882 100644 --- a/flang/include/flang/ISO_Fortran_binding.h +++ b/flang/include/flang/ISO_Fortran_binding.h @@ -43,7 +43,8 @@ typedef unsigned char CFI_attribute_t; typedef signed char CFI_type_t; /* These codes are required to be macros (i.e., #ifdef will work). * They are not required to be distinct, but neither are they required - * to have had their synonyms combined. + * to have had their synonyms combined. Codes marked as extensions may be + * place holders for as yet unimplemented types. */ #define CFI_type_signed_char 1 #define CFI_type_short 2 @@ -55,7 +56,7 @@ typedef signed char CFI_type_t; #define CFI_type_int16_t 8 #define CFI_type_int32_t 9 #define CFI_type_int64_t 10 -#define CFI_type_int128_t 11 /* extension kind=16 */ +#define CFI_type_int128_t 11 /* extension */ #define CFI_type_int_least8_t 12 #define CFI_type_int_least16_t 13 #define CFI_type_int_least32_t 14 @@ -87,8 +88,8 @@ typedef signed char CFI_type_t; #define CFI_type_char 40 #define CFI_type_cptr 41 #define CFI_type_struct 42 -#define CFI_type_char16_t 43 /* extension kind=2 */ -#define CFI_type_char32_t 44 /* extension kind=4 */ +#define CFI_type_char16_t 43 /* extension */ +#define CFI_type_char32_t 44 /* extension */ #define CFI_TYPE_LAST CFI_type_char32_t #define CFI_type_other (-1) // must be negative diff --git a/flang/include/flang/Optimizer/Support/TypeCode.h b/flang/include/flang/Optimizer/Support/TypeCode.h index c2539e5..fef937b 100644 --- a/flang/include/flang/Optimizer/Support/TypeCode.h +++ b/flang/include/flang/Optimizer/Support/TypeCode.h @@ -13,12 +13,80 @@ #ifndef FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H #define FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H -#include "flang/Optimizer/Dialect/Support/KindMapping.h" -#include "mlir/IR/Types.h" +#include "flang/ISO_Fortran_binding.h" +#include "llvm/Support/ErrorHandling.h" namespace fir { -/// Return the ISO_Fortran_binding.h type code for mlir type \p ty. -int getTypeCode(mlir::Type ty, KindMapping &kindMap); + +//===----------------------------------------------------------------------===// +// Translations of category and bitwidths to the type codes defined in flang's +// ISO_Fortran_binding.h. +//===----------------------------------------------------------------------===// + +inline int characterBitsToTypeCode(unsigned bitwidth) { + // clang-format off + switch (bitwidth) { + case 8: return CFI_type_char; + case 16: return CFI_type_char16_t; + case 32: return CFI_type_char32_t; + default: llvm_unreachable("unsupported character size"); + } + // clang-format on +} + +inline int complexBitsToTypeCode(unsigned bitwidth) { + // clang-format off + switch (bitwidth) { + case 16: return CFI_type_half_float_Complex; // CFI_type_bfloat_Complex ? + case 32: return CFI_type_float_Complex; + case 64: return CFI_type_double_Complex; + case 80: return CFI_type_extended_double_Complex; + case 128: return CFI_type_float128_Complex; + default: llvm_unreachable("unsupported complex size"); + } + // clang-format on +} + +inline int integerBitsToTypeCode(unsigned bitwidth) { + // clang-format off + switch (bitwidth) { + case 8: return CFI_type_int8_t; + case 16: return CFI_type_int16_t; + case 32: return CFI_type_int32_t; + case 64: return CFI_type_int64_t; + case 128: return CFI_type_int128_t; + default: llvm_unreachable("unsupported integer size"); + } + // clang-format on +} + +inline int logicalBitsToTypeCode(unsigned bitwidth) { + // clang-format off + switch (bitwidth) { + case 8: return CFI_type_Bool; + case 16: return CFI_type_int_least16_t; + case 32: return CFI_type_int_least32_t; + case 64: return CFI_type_int_least64_t; + default: llvm_unreachable("unsupported logical size"); + } + // clang-format on +} + +inline int realBitsToTypeCode(unsigned bitwidth) { + // clang-format off + switch (bitwidth) { + case 16: return CFI_type_half_float; // CFI_type_bfloat ? + case 32: return CFI_type_float; + case 64: return CFI_type_double; + case 80: return CFI_type_extended_double; + case 128: return CFI_type_float128; + default: llvm_unreachable("unsupported real size"); + } + // clang-format on +} + +static constexpr int derivedToTypeCode() { return CFI_type_struct; } + } // namespace fir #endif // FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp index 1410379..bbec5fc 100644 --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -1272,42 +1272,119 @@ struct EmboxCommonConversion : public FIROpConversion { mlir::Location loc, mlir::ConversionPatternRewriter &rewriter, mlir::Type boxEleTy, mlir::ValueRange lenParams = {}) const { auto i64Ty = mlir::IntegerType::get(rewriter.getContext(), 64); - if (auto eleTy = fir::dyn_cast_ptrEleTy(boxEleTy)) - boxEleTy = eleTy; - if (auto seqTy = boxEleTy.dyn_cast()) - return getSizeAndTypeCode(loc, rewriter, seqTy.getEleTy(), lenParams); - if (boxEleTy.isa()) // unlimited polymorphic or assumed type - return {rewriter.create(loc, i64Ty, 0), - this->genConstantOffset(loc, rewriter, CFI_type_other)}; - mlir::Value typeCodeVal = this->genConstantOffset( - loc, rewriter, - fir::getTypeCode(boxEleTy, this->lowerTy().getKindMap())); - if (fir::isa_integer(boxEleTy) || boxEleTy.dyn_cast() || - fir::isa_real(boxEleTy) || fir::isa_complex(boxEleTy)) - return {genTypeStrideInBytes(loc, i64Ty, rewriter, - this->convertType(boxEleTy)), - typeCodeVal}; - if (auto charTy = boxEleTy.dyn_cast()) { - mlir::Value size = - genTypeStrideInBytes(loc, i64Ty, rewriter, this->convertType(charTy)); - if (charTy.getLen() == fir::CharacterType::unknownLen()) { - // Multiply the single character size by the length. + auto getKindMap = [&]() -> fir::KindMapping & { + return this->lowerTy().getKindMap(); + }; + auto doInteger = + [&](mlir::Type type, + unsigned width) -> std::tuple { + int typeCode = fir::integerBitsToTypeCode(width); + return { + genTypeStrideInBytes(loc, i64Ty, rewriter, this->convertType(type)), + this->genConstantOffset(loc, rewriter, typeCode)}; + }; + auto doLogical = + [&](mlir::Type type, + unsigned width) -> std::tuple { + int typeCode = fir::logicalBitsToTypeCode(width); + return { + genTypeStrideInBytes(loc, i64Ty, rewriter, this->convertType(type)), + this->genConstantOffset(loc, rewriter, typeCode)}; + }; + auto doFloat = [&](mlir::Type type, + unsigned width) -> std::tuple { + int typeCode = fir::realBitsToTypeCode(width); + return { + genTypeStrideInBytes(loc, i64Ty, rewriter, this->convertType(type)), + this->genConstantOffset(loc, rewriter, typeCode)}; + }; + auto doComplex = + [&](mlir::Type type, + unsigned width) -> std::tuple { + auto typeCode = fir::complexBitsToTypeCode(width); + return { + genTypeStrideInBytes(loc, i64Ty, rewriter, this->convertType(type)), + this->genConstantOffset(loc, rewriter, typeCode)}; + }; + auto doCharacter = [&](fir::CharacterType type, mlir::ValueRange lenParams) + -> std::tuple { + unsigned bitWidth = getKindMap().getCharacterBitsize(type.getFKind()); + auto typeCode = fir::characterBitsToTypeCode(bitWidth); + auto typeCodeVal = this->genConstantOffset(loc, rewriter, typeCode); + + bool lengthIsConst = (type.getLen() != fir::CharacterType::unknownLen()); + mlir::Value eleSize = + genTypeStrideInBytes(loc, i64Ty, rewriter, this->convertType(type)); + + if (!lengthIsConst) { + // If length is constant, then the fir::CharacterType will be + // represented as an array of known size of elements having + // the corresponding LLVM type. In this case eleSize already + // holds correct memory size. If length is not constant, then + // the fir::CharacterType will decay to a scalar type, + // so we have to multiply it by the non-constant length + // to get its size in memory. assert(!lenParams.empty()); auto len64 = FIROpConversion::integerCast(loc, rewriter, i64Ty, lenParams.back()); - size = rewriter.create(loc, i64Ty, size, len64); + eleSize = + rewriter.create(loc, i64Ty, eleSize, len64); } - return {size, typeCodeVal}; + return {eleSize, typeCodeVal}; }; + // Pointer-like types. + if (auto eleTy = fir::dyn_cast_ptrEleTy(boxEleTy)) + boxEleTy = eleTy; + // Integer types. + if (fir::isa_integer(boxEleTy)) { + if (auto ty = boxEleTy.dyn_cast()) + return doInteger(ty, ty.getWidth()); + auto ty = boxEleTy.cast(); + return doInteger(ty, getKindMap().getIntegerBitsize(ty.getFKind())); + } + // Floating point types. + if (fir::isa_real(boxEleTy)) { + if (auto ty = boxEleTy.dyn_cast()) + return doFloat(ty, ty.getWidth()); + auto ty = boxEleTy.cast(); + return doFloat(ty, getKindMap().getRealBitsize(ty.getFKind())); + } + // Complex types. + if (fir::isa_complex(boxEleTy)) { + if (auto ty = boxEleTy.dyn_cast()) + return doComplex( + ty, ty.getElementType().cast().getWidth()); + auto ty = boxEleTy.cast(); + return doComplex(ty, getKindMap().getRealBitsize(ty.getFKind())); + } + // Character types. + if (auto ty = boxEleTy.dyn_cast()) + return doCharacter(ty, lenParams); + // Logical type. + if (auto ty = boxEleTy.dyn_cast()) + return doLogical(ty, getKindMap().getLogicalBitsize(ty.getFKind())); + // Array types. + if (auto seqTy = boxEleTy.dyn_cast()) + return getSizeAndTypeCode(loc, rewriter, seqTy.getEleTy(), lenParams); + // Derived-type types. + if (boxEleTy.isa()) { + auto eleSize = genTypeStrideInBytes(loc, i64Ty, rewriter, + this->convertType(boxEleTy)); + return {eleSize, + this->genConstantOffset(loc, rewriter, fir::derivedToTypeCode())}; + } + // Reference type. if (fir::isa_ref_type(boxEleTy)) { auto ptrTy = mlir::LLVM::LLVMPointerType::get( mlir::LLVM::LLVMVoidType::get(rewriter.getContext())); - return {genTypeStrideInBytes(loc, i64Ty, rewriter, ptrTy), typeCodeVal}; + mlir::Value size = genTypeStrideInBytes(loc, i64Ty, rewriter, ptrTy); + return {size, this->genConstantOffset(loc, rewriter, CFI_type_cptr)}; } - if (boxEleTy.isa()) - return {genTypeStrideInBytes(loc, i64Ty, rewriter, - this->convertType(boxEleTy)), - typeCodeVal}; + // Unlimited polymorphic or assumed type. Use 0 and CFI_type_other since the + // information is not none at this point. + if (boxEleTy.isa()) + return {rewriter.create(loc, i64Ty, 0), + this->genConstantOffset(loc, rewriter, CFI_type_other)}; fir::emitFatalError(loc, "unhandled type in fir.box code generation"); } diff --git a/flang/lib/Optimizer/Support/CMakeLists.txt b/flang/lib/Optimizer/Support/CMakeLists.txt index 58c30dd..348ef24 100644 --- a/flang/lib/Optimizer/Support/CMakeLists.txt +++ b/flang/lib/Optimizer/Support/CMakeLists.txt @@ -3,7 +3,6 @@ get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) add_flang_library(FIRSupport InitFIR.cpp InternalNames.cpp - TypeCode.cpp DEPENDS FIROpsIncGen diff --git a/flang/lib/Optimizer/Support/TypeCode.cpp b/flang/lib/Optimizer/Support/TypeCode.cpp deleted file mode 100644 index f1e4f89..0000000 --- a/flang/lib/Optimizer/Support/TypeCode.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//===-- Optimizer/Support/TypeCode.cpp ------------------------------------===// -// -// 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 "flang/Optimizer/Support/TypeCode.h" -#include "flang/ISO_Fortran_binding.h" -#include "flang/Optimizer/Dialect/FIRType.h" -#include "llvm/Support/ErrorHandling.h" - -namespace fir { - -/// Return the ISO_C_BINDING intrinsic module value of type \p ty. -int getTypeCode(mlir::Type ty, fir::KindMapping &kindMap) { - unsigned width = 0; - if (mlir::IntegerType intTy = ty.dyn_cast()) { - switch (intTy.getWidth()) { - case 8: - return CFI_type_int8_t; - case 16: - return CFI_type_int16_t; - case 32: - return CFI_type_int32_t; - case 64: - return CFI_type_int64_t; - case 128: - return CFI_type_int128_t; - } - llvm_unreachable("unsupported integer type"); - } - if (fir::LogicalType logicalTy = ty.dyn_cast()) { - switch (kindMap.getLogicalBitsize(logicalTy.getFKind())) { - case 8: - return CFI_type_Bool; - case 16: - return CFI_type_int_least16_t; - case 32: - return CFI_type_int_least32_t; - case 64: - return CFI_type_int_least64_t; - } - llvm_unreachable("unsupported logical type"); - } - if (mlir::FloatType floatTy = ty.dyn_cast()) { - switch (floatTy.getWidth()) { - case 16: - return floatTy.isBF16() ? CFI_type_bfloat : CFI_type_half_float; - case 32: - return CFI_type_float; - case 64: - return CFI_type_double; - case 80: - return CFI_type_extended_double; - case 128: - return CFI_type_float128; - } - llvm_unreachable("unsupported real type"); - } - if (fir::isa_complex(ty)) { - if (mlir::ComplexType complexTy = ty.dyn_cast()) { - mlir::FloatType floatTy = - complexTy.getElementType().cast(); - if (floatTy.isBF16()) - return CFI_type_bfloat_Complex; - width = floatTy.getWidth(); - } else if (fir::ComplexType complexTy = ty.dyn_cast()) { - auto FKind = complexTy.getFKind(); - if (FKind == 3) - return CFI_type_bfloat_Complex; - width = kindMap.getRealBitsize(FKind); - } - switch (width) { - case 16: - return CFI_type_half_float_Complex; - case 32: - return CFI_type_float_Complex; - case 64: - return CFI_type_double_Complex; - case 80: - return CFI_type_extended_double_Complex; - case 128: - return CFI_type_float128_Complex; - } - llvm_unreachable("unsupported complex size"); - } - if (fir::CharacterType charTy = ty.dyn_cast()) { - switch (kindMap.getCharacterBitsize(charTy.getFKind())) { - case 8: - return CFI_type_char; - case 16: - return CFI_type_char16_t; - case 32: - return CFI_type_char32_t; - } - llvm_unreachable("unsupported character type"); - } - if (fir::isa_ref_type(ty)) - return CFI_type_cptr; - if (ty.isa()) - return CFI_type_struct; - llvm_unreachable("unsupported type"); -} - -} // namespace fir diff --git a/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp b/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp index c562139..2f8cdf7 100644 --- a/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp +++ b/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp @@ -62,6 +62,8 @@ private: mlir::Type ty, mlir::ModuleOp mod, mlir::PatternRewriter &rewriter) const; + static int getTypeCode(mlir::Type ty, fir::KindMapping &kindMap); + mlir::LogicalResult genTypeLadderStep(mlir::Location loc, mlir::Value selector, mlir::Attribute attr, mlir::Block *dest, @@ -360,7 +362,7 @@ mlir::LogicalResult SelectTypeConv::genTypeLadderStep( a.getType().isa()) { // For type guard statement with Intrinsic type spec the type code of // the descriptor is compared. - int code = fir::getTypeCode(a.getType(), kindMap); + int code = getTypeCode(a.getType(), kindMap); if (code == 0) return mlir::emitError(loc) << "type code unavailable for " << a.getType(); @@ -459,6 +461,28 @@ SelectTypeConv::genTypeDescCompare(mlir::Location loc, mlir::Value selector, loc, mlir::arith::CmpIPredicate::eq, typeDescInt, selectorTdescInt); } +int SelectTypeConv::getTypeCode(mlir::Type ty, fir::KindMapping &kindMap) { + if (auto intTy = ty.dyn_cast()) + return fir::integerBitsToTypeCode(intTy.getWidth()); + if (auto floatTy = ty.dyn_cast()) + return fir::realBitsToTypeCode(floatTy.getWidth()); + if (auto logicalTy = ty.dyn_cast()) + return fir::logicalBitsToTypeCode( + kindMap.getLogicalBitsize(logicalTy.getFKind())); + if (fir::isa_complex(ty)) { + if (auto cmplxTy = ty.dyn_cast()) + return fir::complexBitsToTypeCode( + cmplxTy.getElementType().cast().getWidth()); + auto cmplxTy = ty.cast(); + return fir::complexBitsToTypeCode( + kindMap.getRealBitsize(cmplxTy.getFKind())); + } + if (auto charTy = ty.dyn_cast()) + return fir::characterBitsToTypeCode( + kindMap.getCharacterBitsize(charTy.getFKind())); + return 0; +} + llvm::SmallSet SelectTypeConv::collectAncestors(fir::DispatchTableOp dt, mlir::ModuleOp mod) const { diff --git a/flang/test/Fir/convert-to-llvm.fir b/flang/test/Fir/convert-to-llvm.fir index 866d8eb..6eac945 100644 --- a/flang/test/Fir/convert-to-llvm.fir +++ b/flang/test/Fir/convert-to-llvm.fir @@ -1563,10 +1563,10 @@ func.func @embox0(%arg0: !fir.ref>) { // CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr> // CHECK: %[[C1:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: %[[ALLOCA:.*]] = llvm.alloca %[[C1]] x !llvm.struct<(ptr>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})> {alignment = 8 : i64} : (i32) -> !llvm.ptr>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})>> -// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(9 : i32) : i32 // CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr // CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1] // CHECK: %[[I64_ELEM_SIZE:.*]] = llvm.ptrtoint %[[GEP]] : !llvm.ptr to i64 +// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(9 : i32) : i32 // CHECK: %[[DESC:.*]] = llvm.mlir.undef : !llvm.struct<(ptr>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})> // CHECK: %[[DESC0:.*]] = llvm.insertvalue %[[I64_ELEM_SIZE]], %[[DESC]][1] : !llvm.struct<(ptr>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})> // CHECK: %[[CFI_VERSION:.*]] = llvm.mlir.constant(20180515 : i32) : i32 @@ -1786,10 +1786,10 @@ func.func @xembox0(%arg0: !fir.ref>) { // CHECK: %[[ALLOCA_SIZE:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: %[[ALLOCA:.*]] = llvm.alloca %[[ALLOCA_SIZE]] x !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)>> // CHECK: %[[C0:.*]] = llvm.mlir.constant(0 : i64) : i64 -// CHECK: %[[TYPE:.*]] = llvm.mlir.constant(9 : i32) : i32 // CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr // CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1] // CHECK: %[[ELEM_LEN_I64:.*]] = llvm.ptrtoint %[[GEP]] : !llvm.ptr to i64 +// CHECK: %[[TYPE:.*]] = llvm.mlir.constant(9 : i32) : i32 // CHECK: %[[BOX0:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)> // CHECK: %[[BOX1:.*]] = llvm.insertvalue %[[ELEM_LEN_I64]], %[[BOX0]][1] : !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)> // CHECK: %[[VERSION:.*]] = llvm.mlir.constant(20180515 : i32) : i32 @@ -1885,10 +1885,10 @@ func.func private @_QPxb(!fir.box>) // CHECK: %[[ARR_SIZE_TMP1:.*]] = llvm.mul %[[C1_0]], %[[N1]] : i64 // CHECK: %[[ARR_SIZE:.*]] = llvm.mul %[[ARR_SIZE_TMP1]], %[[N2]] : i64 // CHECK: %[[ARR:.*]] = llvm.alloca %[[ARR_SIZE]] x f64 {bindc_name = "arr", in_type = !fir.array, operand_segment_sizes = array, uniq_name = "_QFsbEarr"} : (i64) -> !llvm.ptr -// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(28 : i32) : i32 // CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr // CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1] // CHECK: %[[ELEM_LEN_I64:.*]] = llvm.ptrtoint %[[GEP]] : !llvm.ptr to i64 +// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(28 : i32) : i32 // CHECK: %[[BOX0:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<2 x array<3 x i64>>)> // CHECK: %[[BOX1:.*]] = llvm.insertvalue %[[ELEM_LEN_I64]], %[[BOX0]][1] : !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<2 x array<3 x i64>>)> // CHECK: %[[VERSION:.*]] = llvm.mlir.constant(20180515 : i32) : i32 @@ -1964,10 +1964,10 @@ func.func private @_QPtest_dt_callee(%arg0: !fir.box>) // CHECK: %[[V:.*]] = llvm.alloca %[[ALLOCA_SIZE_V]] x i32 {bindc_name = "v", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFtest_dt_sliceEv"} : (i64) -> !llvm.ptr // CHECK: %[[ALLOCA_SIZE_X:.*]] = llvm.mlir.constant(1 : i64) : i64 // CHECK: %[[X:.*]] = llvm.alloca %[[ALLOCA_SIZE_X]] x !llvm.array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>> {bindc_name = "x", in_type = !fir.array<20x!fir.type<_QFtest_dt_sliceTt{i:i32,j:i32}>>, operand_segment_sizes = array, uniq_name = "_QFtest_dt_sliceEx"} : (i64) -> !llvm.ptr>> -// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(9 : i32) : i32 // CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr // CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1] // CHECK: %[[ELEM_LEN_I64:.*]] = llvm.ptrtoint %[[GEP]] : !llvm.ptr to i64 +// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(9 : i32) : i32 // CHECK: %[[BOX0:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)> // CHECK: %[[BOX1:.*]] = llvm.insertvalue %[[ELEM_LEN_I64]], %[[BOX0]][1] : !llvm.struct<(ptr, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)> // CHECK: %[[VERSION:.*]] = llvm.mlir.constant(20180515 : i32) : i32 @@ -2240,10 +2240,10 @@ func.func @test_rebox_1(%arg0: !fir.box>) { //CHECK: %[[FIVE:.*]] = llvm.mlir.constant(5 : index) : i64 //CHECK: %[[SIX:.*]] = llvm.mlir.constant(6 : index) : i64 //CHECK: %[[EIGHTY:.*]] = llvm.mlir.constant(80 : index) : i64 -//CHECK: %[[FLOAT_TYPE:.*]] = llvm.mlir.constant(27 : i32) : i32 //CHECK: %[[NULL:.*]] = llvm.mlir.null : !llvm.ptr //CHECK: %[[GEP:.*]] = llvm.getelementptr %[[NULL]][1] //CHECK: %[[ELEM_SIZE_I64:.*]] = llvm.ptrtoint %[[GEP]] : !llvm.ptr to i64 +//CHECK: %[[FLOAT_TYPE:.*]] = llvm.mlir.constant(27 : i32) : i32 //CHECK: %[[RBOX:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> //CHECK: %[[RBOX_TMP1:.*]] = llvm.insertvalue %[[ELEM_SIZE_I64]], %[[RBOX]][1] : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> //CHECK: %[[CFI_VERSION:.*]] = llvm.mlir.constant(20180515 : i32) : i32 diff --git a/flang/test/Lower/real-descriptors.f90 b/flang/test/Lower/real-descriptors.f90 deleted file mode 100644 index ff7fdc6..0000000 --- a/flang/test/Lower/real-descriptors.f90 +++ /dev/null @@ -1,98 +0,0 @@ -! RUN: bbc %s -o - | tco | FileCheck %s - -! CHECK-LABEL: define void @_QQmain() -program p - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8 - ! CHECK-DAG: alloca { x86_fp80, x86_fp80 }, i64 1, align 16 - ! CHECK-DAG: alloca { fp128, fp128 }, i64 1, align 16 - ! CHECK-DAG: alloca { half, half }, i64 1, align 8 - ! CHECK-DAG: alloca { bfloat, bfloat }, i64 1, align 8 - ! CHECK-DAG: alloca { float, float }, i64 1, align 8 - ! CHECK-DAG: alloca { double, double }, i64 1, align 8 - ! CHECK-DAG: alloca x86_fp80, i64 1, align 16 - ! CHECK-DAG: alloca fp128, i64 1, align 16 - ! CHECK-DAG: alloca half, i64 1, align 2 - ! CHECK-DAG: alloca bfloat, i64 1, align 2 - ! CHECK-DAG: alloca float, i64 1, align 4 - ! CHECK-DAG: alloca double, i64 1, align 8 - - character(10) :: in = 'NaN NaN' - - real(kind=2) :: x2 - real(kind=3) :: x3 - real(kind=4) :: x4 - real(kind=8) :: x8 - real(kind=10) :: x10 - real(kind=16) :: x16 - - complex(kind=2) :: c2 - complex(kind=3) :: c3 - complex(kind=4) :: c4 - complex(kind=8) :: c8 - complex(kind=10) :: c10 - complex(kind=16) :: c16 - - read(in,*) x2 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr (half, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 25, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z4)", x2 - - read(in,*) x3 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr (bfloat, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 26, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z4)", x3 - - read(in,*) x4 - ! CHECK: call i1 @_FortranAioOutputReal32(ptr %{{[0-9]*}}, float %{{[0-9]*}}) - print "(z8)", x4 - - read(in,*) x8 - ! CHECK: call i1 @_FortranAioOutputReal64(ptr %{{[0-9]*}}, double %{{[0-9]*}}) - print "(z16)", x8 - - read(in,*) x10 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr (x86_fp80, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 29, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z20)", x10 - - read(in,*) x16 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr (fp128, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 31, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z32)", x16 - - print* - read(in,*) c2 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr ({ half, half }, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 32, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z4,' ',z4)", c2 - - read(in,*) c3 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr ({ bfloat, bfloat }, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 33, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z4,' ',z4)", c3 - - read(in,*) c4 - ! CHECK: call i1 @_FortranAioOutputComplex32(ptr %{{[0-9]*}}, float %{{[0-9]*}}, float %{{[0-9]*}}) - print "(z8,' ',z8)", c4 - - read(in,*) c8 - ! CHECK: call i1 @_FortranAioOutputComplex64(ptr %{{[0-9]*}}, double %{{[0-9]*}}, double %{{[0-9]*}}) - print "(z16,' ',z16)", c8 - - read(in,*) c10 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr ({ x86_fp80, x86_fp80 }, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 36, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z20,' ',z20)", c10 - - read(in,*) c16 - ! CHECK: insertvalue { ptr, i64, i32, i8, i8, i8, i8 } { ptr undef, i64 ptrtoint (ptr getelementptr ({ fp128, fp128 }, ptr null, i32 1) to i64), i32 {{[0-9]*}}, i8 0, i8 38, i8 0, i8 0 }, ptr %{{[0-9]*}}, 0 - ! CHECK: call i1 @_FortranAioOutputDescriptor(ptr %{{[0-9]*}}, ptr %{{[0-9]*}}) - print "(z32,' ',z32)", c16 -end -- 2.7.4