[flang-commits] [flang] 5918690 - [flang][NFC] Rename complex type.
Eric Schweitz via flang-commits
flang-commits at lists.llvm.org
Mon Feb 1 15:32:03 PST 2021
Author: Eric Schweitz
Date: 2021-02-01T15:31:48-08:00
New Revision: 59186902555546b9d864065d03eb1c79cb041409
URL: https://github.com/llvm/llvm-project/commit/59186902555546b9d864065d03eb1c79cb041409
DIFF: https://github.com/llvm/llvm-project/commit/59186902555546b9d864065d03eb1c79cb041409.diff
LOG: [flang][NFC] Rename complex type.
This change renames the CplxType class to ComplexType.
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/include/flang/Optimizer/Dialect/FIRType.h
flang/lib/Lower/ComplexExpr.cpp
flang/lib/Lower/ConvertType.cpp
flang/lib/Lower/FIRBuilder.cpp
flang/lib/Lower/IO.cpp
flang/lib/Lower/IntrinsicCall.cpp
flang/lib/Lower/Mangler.cpp
flang/lib/Optimizer/Dialect/FIRDialect.cpp
flang/lib/Optimizer/Dialect/FIRType.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index cecd1cbbb46b..f6658f670a57 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -32,7 +32,7 @@ def fir_Type : Type<CPred<"fir::isa_fir_or_std_type($_self)">,
// Fortran intrinsic types
def fir_CharacterType : Type<CPred<"$_self.isa<fir::CharacterType>()">,
"FIR character type">;
-def fir_ComplexType : Type<CPred<"$_self.isa<fir::CplxType>()">,
+def fir_ComplexType : Type<CPred<"$_self.isa<fir::ComplexType>()">,
"FIR complex type">;
def fir_IntegerType : Type<CPred<"$_self.isa<fir::IntType>()">,
"FIR integer type">;
@@ -2427,7 +2427,7 @@ def fir_ConstcOp : fir_Op<"constc", [NoSideEffect]> {
}];
let verifier = [{
- if (!getType().isa<fir::CplxType>())
+ if (!getType().isa<fir::ComplexType>())
return emitOpError("must be a !fir.complex type");
return mlir::success();
}];
@@ -2563,7 +2563,7 @@ def fir_ConvertOp : fir_OneResultOp<"convert", [NoSideEffect]> {
def FortranTypeAttr : Attr<And<[CPred<"$_self.isa<TypeAttr>()">,
Or<[CPred<"$_self.cast<TypeAttr>().getValue().isa<fir::CharacterType>()">,
- CPred<"$_self.cast<TypeAttr>().getValue().isa<fir::CplxType>()">,
+ CPred<"$_self.cast<TypeAttr>().getValue().isa<fir::ComplexType>()">,
CPred<"$_self.cast<TypeAttr>().getValue().isa<fir::IntType>()">,
CPred<"$_self.cast<TypeAttr>().getValue().isa<fir::LogicalType>()">,
CPred<"$_self.cast<TypeAttr>().getValue().isa<fir::RealType>()">,
diff --git a/flang/include/flang/Optimizer/Dialect/FIRType.h b/flang/include/flang/Optimizer/Dialect/FIRType.h
index 6484ca5156bd..2a77d53ef71d 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRType.h
+++ b/flang/include/flang/Optimizer/Dialect/FIRType.h
@@ -39,7 +39,7 @@ struct BoxTypeStorage;
struct BoxCharTypeStorage;
struct BoxProcTypeStorage;
struct CharacterTypeStorage;
-struct CplxTypeStorage;
+struct ComplexTypeStorage;
struct DimsTypeStorage;
struct FieldTypeStorage;
struct HeapTypeStorage;
@@ -105,11 +105,11 @@ class CharacterType
/// Model of a Fortran COMPLEX intrinsic type, including the KIND type
/// parameter. COMPLEX is a floating point type with a real and imaginary
/// member.
-class CplxType : public mlir::Type::TypeBase<CplxType, mlir::Type,
- detail::CplxTypeStorage> {
+class ComplexType : public mlir::Type::TypeBase<fir::ComplexType, mlir::Type,
+ detail::ComplexTypeStorage> {
public:
using Base::Base;
- static CplxType get(mlir::MLIRContext *ctxt, KindTy kind);
+ static fir::ComplexType get(mlir::MLIRContext *ctxt, KindTy kind);
/// Get the corresponding fir.real<k> type.
mlir::Type getElementType() const;
@@ -129,9 +129,8 @@ class IntType
/// Model of a Fortran LOGICAL intrinsic type, including the KIND type
/// parameter.
-class LogicalType
- : public mlir::Type::TypeBase<LogicalType, mlir::Type,
- detail::LogicalTypeStorage> {
+class LogicalType : public mlir::Type::TypeBase<LogicalType, mlir::Type,
+ detail::LogicalTypeStorage> {
public:
using Base::Base;
static LogicalType get(mlir::MLIRContext *ctxt, KindTy kind);
@@ -394,7 +393,7 @@ inline bool isa_integer(mlir::Type t) {
/// Is `t` a FIR or MLIR Complex type?
inline bool isa_complex(mlir::Type t) {
- return t.isa<fir::CplxType>() || t.isa<mlir::ComplexType>();
+ return t.isa<fir::ComplexType>() || t.isa<mlir::ComplexType>();
}
} // namespace fir
diff --git a/flang/lib/Lower/ComplexExpr.cpp b/flang/lib/Lower/ComplexExpr.cpp
index 1a66c95f8ed8..03a91dc00e26 100644
--- a/flang/lib/Lower/ComplexExpr.cpp
+++ b/flang/lib/Lower/ComplexExpr.cpp
@@ -16,7 +16,7 @@
mlir::Type
Fortran::lower::ComplexExprHelper::getComplexPartType(mlir::Type complexType) {
return Fortran::lower::convertReal(
- builder.getContext(), complexType.cast<fir::CplxType>().getFKind());
+ builder.getContext(), complexType.cast<fir::ComplexType>().getFKind());
}
mlir::Type
@@ -27,7 +27,7 @@ Fortran::lower::ComplexExprHelper::getComplexPartType(mlir::Value cplx) {
mlir::Value Fortran::lower::ComplexExprHelper::createComplex(fir::KindTy kind,
mlir::Value real,
mlir::Value imag) {
- auto complexTy = fir::CplxType::get(builder.getContext(), kind);
+ auto complexTy = fir::ComplexType::get(builder.getContext(), kind);
mlir::Value und = builder.create<fir::UndefOp>(loc, complexTy);
return insert<Part::Imag>(insert<Part::Real>(und, real), imag);
}
diff --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index b3fa85d4691d..917de78b61b8 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -167,7 +167,7 @@ genFIRType<Fortran::common::TypeCategory::Complex>(mlir::MLIRContext *context,
int KIND) {
if (Fortran::evaluate::IsValidKindOfIntrinsicType(
Fortran::common::TypeCategory::Complex, KIND))
- return fir::CplxType::get(context, KIND);
+ return fir::ComplexType::get(context, KIND);
return {};
}
diff --git a/flang/lib/Lower/FIRBuilder.cpp b/flang/lib/Lower/FIRBuilder.cpp
index 8e1df8a2e0b4..3f470d61c286 100644
--- a/flang/lib/Lower/FIRBuilder.cpp
+++ b/flang/lib/Lower/FIRBuilder.cpp
@@ -149,7 +149,7 @@ mlir::Value Fortran::lower::FirOpBuilder::convertWithSemantics(
auto eleTy = helper.getComplexPartType(toTy);
auto cast = createConvert(loc, eleTy, val);
llvm::APFloat zero{
- kindMap.getFloatSemantics(toTy.cast<fir::CplxType>().getFKind()), 0};
+ kindMap.getFloatSemantics(toTy.cast<fir::ComplexType>().getFKind()), 0};
auto imag = createRealConstant(loc, eleTy, zero);
return helper.createComplex(toTy, cast, imag);
}
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index ab7387dd3ce6..973c1c270895 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -202,7 +202,7 @@ static mlir::FuncOp getOutputFunc(mlir::Location loc,
return ty.getWidth() <= 32
? getIORuntimeFunc<mkIOKey(OutputReal32)>(loc, builder)
: getIORuntimeFunc<mkIOKey(OutputReal64)>(loc, builder);
- if (auto ty = type.dyn_cast<fir::CplxType>())
+ if (auto ty = type.dyn_cast<fir::ComplexType>())
return ty.getFKind() <= 4
? getIORuntimeFunc<mkIOKey(OutputComplex32)>(loc, builder)
: getIORuntimeFunc<mkIOKey(OutputComplex64)>(loc, builder);
@@ -274,7 +274,7 @@ static mlir::FuncOp getInputFunc(mlir::Location loc,
return ty.getWidth() <= 32
? getIORuntimeFunc<mkIOKey(InputReal32)>(loc, builder)
: getIORuntimeFunc<mkIOKey(InputReal64)>(loc, builder);
- if (auto ty = type.dyn_cast<fir::CplxType>())
+ if (auto ty = type.dyn_cast<fir::ComplexType>())
return ty.getFKind() <= 4
? getIORuntimeFunc<mkIOKey(InputReal32)>(loc, builder)
: getIORuntimeFunc<mkIOKey(InputReal64)>(loc, builder);
@@ -314,7 +314,7 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
auto argType = inputFunc.getType().getInput(1);
auto originalItemAddr = itemAddr;
mlir::Type complexPartType;
- if (itemType.isa<fir::CplxType>())
+ if (itemType.isa<fir::ComplexType>())
complexPartType = builder.getRefType(
Fortran::lower::ComplexExprHelper{builder, loc}.getComplexPartType(
itemType));
diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 7053cd976566..688cd91a610a 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -439,7 +439,7 @@ class FunctionDistance {
// - or use evaluate/type.h
if (auto r{t.dyn_cast<fir::RealType>()})
return r.getFKind() * 4;
- if (auto cplx{t.dyn_cast<fir::CplxType>()})
+ if (auto cplx{t.dyn_cast<fir::ComplexType>()})
return cplx.getFKind() * 4;
llvm_unreachable("not a floating-point type");
}
@@ -459,8 +459,8 @@ class FunctionDistance {
? Conversion::Narrow
: Conversion::Extend;
}
- if (auto fromCplxTy{from.dyn_cast<fir::CplxType>()}) {
- if (auto toCplxTy{to.dyn_cast<fir::CplxType>()}) {
+ if (auto fromCplxTy{from.dyn_cast<fir::ComplexType>()}) {
+ if (auto toCplxTy{to.dyn_cast<fir::ComplexType>()}) {
return getFloatingPointWidth(fromCplxTy) >
getFloatingPointWidth(toCplxTy)
? Conversion::Narrow
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 656a01ca0bd8..b590fc932441 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -134,7 +134,7 @@ static std::string typeToString(mlir::Type t) {
if (auto i{t.dyn_cast<mlir::IntegerType>()}) {
return "i" + std::to_string(i.getWidth());
}
- if (auto cplx{t.dyn_cast<fir::CplxType>()}) {
+ if (auto cplx{t.dyn_cast<fir::ComplexType>()}) {
return "z" + std::to_string(cplx.getFKind());
}
if (auto real{t.dyn_cast<fir::RealType>()}) {
diff --git a/flang/lib/Optimizer/Dialect/FIRDialect.cpp b/flang/lib/Optimizer/Dialect/FIRDialect.cpp
index ab6b07b3ca5b..8957bb710d2d 100644
--- a/flang/lib/Optimizer/Dialect/FIRDialect.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRDialect.cpp
@@ -15,9 +15,10 @@ using namespace fir;
fir::FIROpsDialect::FIROpsDialect(mlir::MLIRContext *ctx)
: mlir::Dialect("fir", ctx, mlir::TypeID::get<FIROpsDialect>()) {
- addTypes<BoxType, BoxCharType, BoxProcType, CharacterType, CplxType, DimsType,
- FieldType, HeapType, IntType, LenType, LogicalType, PointerType,
- RealType, RecordType, ReferenceType, SequenceType, TypeDescType>();
+ addTypes<BoxType, BoxCharType, BoxProcType, CharacterType, fir::ComplexType,
+ DimsType, FieldType, HeapType, IntType, LenType, LogicalType,
+ PointerType, RealType, RecordType, ReferenceType, SequenceType,
+ TypeDescType>();
addAttributes<ClosedIntervalAttr, ExactTypeAttr, LowerBoundAttr,
PointIntervalAttr, RealAttr, SubclassAttr, UpperBoundAttr>();
addOperations<
diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp
index e4c548035d4a..65c54764f486 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -87,8 +87,8 @@ CharacterType parseCharacter(mlir::DialectAsmParser &parser) {
}
// `complex` `<` kind `>`
-CplxType parseComplex(mlir::DialectAsmParser &parser) {
- return parseKindSingleton<CplxType>(parser);
+fir::ComplexType parseComplex(mlir::DialectAsmParser &parser) {
+ return parseKindSingleton<fir::ComplexType>(parser);
}
// `dims` `<` rank `>`
@@ -493,17 +493,17 @@ struct IntTypeStorage : public mlir::TypeStorage {
};
/// `COMPLEX` storage
-struct CplxTypeStorage : public mlir::TypeStorage {
+struct ComplexTypeStorage : public mlir::TypeStorage {
using KeyTy = KindTy;
static unsigned hashKey(const KeyTy &key) { return llvm::hash_combine(key); }
bool operator==(const KeyTy &key) const { return key == getFKind(); }
- static CplxTypeStorage *construct(mlir::TypeStorageAllocator &allocator,
- KindTy kind) {
- auto *storage = allocator.allocate<CplxTypeStorage>();
- return new (storage) CplxTypeStorage{kind};
+ static ComplexTypeStorage *construct(mlir::TypeStorageAllocator &allocator,
+ KindTy kind) {
+ auto *storage = allocator.allocate<ComplexTypeStorage>();
+ return new (storage) ComplexTypeStorage{kind};
}
KindTy getFKind() const { return kind; }
@@ -512,8 +512,8 @@ struct CplxTypeStorage : public mlir::TypeStorage {
KindTy kind;
private:
- CplxTypeStorage() = delete;
- explicit CplxTypeStorage(KindTy kind) : kind{kind} {}
+ ComplexTypeStorage() = delete;
+ explicit ComplexTypeStorage(KindTy kind) : kind{kind} {}
};
/// `REAL` storage (for reals of unsupported sizes)
@@ -833,8 +833,8 @@ bool isa_std_type(mlir::Type t) {
bool isa_fir_or_std_type(mlir::Type t) {
if (auto funcType = t.dyn_cast<mlir::FunctionType>())
- return llvm::all_of(funcType.getInputs(), isa_fir_or_std_type) &&
- llvm::all_of(funcType.getResults(), isa_fir_or_std_type);
+ return llvm::all_of(funcType.getInputs(), isa_fir_or_std_type) &&
+ llvm::all_of(funcType.getResults(), isa_fir_or_std_type);
return isa_fir_type(t) || isa_std_type(t);
}
@@ -909,15 +909,15 @@ int fir::IntType::getFKind() const { return getImpl()->getFKind(); }
// COMPLEX
-CplxType fir::CplxType::get(mlir::MLIRContext *ctxt, KindTy kind) {
+fir::ComplexType fir::ComplexType::get(mlir::MLIRContext *ctxt, KindTy kind) {
return Base::get(ctxt, kind);
}
-mlir::Type fir::CplxType::getElementType() const {
+mlir::Type fir::ComplexType::getElementType() const {
return fir::RealType::get(getContext(), getFKind());
}
-KindTy fir::CplxType::getFKind() const { return getImpl()->getFKind(); }
+KindTy fir::ComplexType::getFKind() const { return getImpl()->getFKind(); }
// REAL
@@ -1245,7 +1245,7 @@ void fir::printFirType(FIROpsDialect *, mlir::Type ty,
os << "char<" << type.getFKind() << '>';
return;
}
- if (auto type = ty.dyn_cast<CplxType>()) {
+ if (auto type = ty.dyn_cast<fir::ComplexType>()) {
os << "complex<" << type.getFKind() << '>';
return;
}
More information about the flang-commits
mailing list