[flang][NFC] Rename complex type.

This change renames the CplxType class to ComplexType.
This commit is contained in:
Eric Schweitz 2021-01-30 15:51:37 -08:00
parent 9d09db941f
commit 5918690255
10 changed files with 40 additions and 40 deletions

View File

@ -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>()">,

View File

@ -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 @@ public:
/// 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 @@ public:
/// 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

View File

@ -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);
}

View File

@ -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 {};
}

View File

@ -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);
}

View File

@ -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));

View File

@ -439,7 +439,7 @@ private:
// - 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 @@ private:
? 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

View File

@ -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>()}) {

View File

@ -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<

View File

@ -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 @@ private:
};
/// `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 @@ protected:
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;
}