[flang-commits] [flang] 0b626df - [flang][NFC] Reorder conversions
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Wed Feb 9 02:28:08 PST 2022
Author: Valentin Clement
Date: 2022-02-09T11:27:23+01:00
New Revision: 0b626df1bc4e5b9f9ce326d4766465588315da36
URL: https://github.com/llvm/llvm-project/commit/0b626df1bc4e5b9f9ce326d4766465588315da36
DIFF: https://github.com/llvm/llvm-project/commit/0b626df1bc4e5b9f9ce326d4766465588315da36.diff
LOG: [flang][NFC] Reorder conversions
During upstreaming the alphabetical order was not respected.
Added:
Modified:
flang/lib/Optimizer/CodeGen/TypeConverter.h
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h
index 38105e18e62ae..10a30bfd86a26 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -66,11 +66,22 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
});
addConversion(
[&](fir::CharacterType charTy) { return convertCharType(charTy); });
+ addConversion(
+ [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); });
+ addConversion([&](fir::FieldType field) {
+ // Convert to i32 because of LLVM GEP indexing restriction.
+ return mlir::IntegerType::get(field.getContext(), 32);
+ });
addConversion([&](HeapType heap) { return convertPointerLike(heap); });
addConversion([&](fir::IntegerType intTy) {
return mlir::IntegerType::get(
&getContext(), kindMapping.getIntegerBitsize(intTy.getFKind()));
});
+ addConversion([&](fir::LenType field) {
+ // Get size of len paramter from the descriptor.
+ return getModel<Fortran::runtime::typeInfo::TypeParameterValue>()(
+ &getContext());
+ });
addConversion([&](fir::LogicalType boolTy) {
return mlir::IntegerType::get(
&getContext(), kindMapping.getLogicalBitsize(boolTy.getFKind()));
@@ -80,21 +91,11 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
});
addConversion(
[&](fir::PointerType pointer) { return convertPointerLike(pointer); });
- addConversion([&](fir::RecordType derived, SmallVectorImpl<Type> &results,
- ArrayRef<Type> callStack) {
+ addConversion([&](fir::RecordType derived,
+ SmallVectorImpl<mlir::Type> &results,
+ ArrayRef<mlir::Type> callStack) {
return convertRecordType(derived, results, callStack);
});
- addConversion([&](fir::FieldType field) {
- // Convert to i32 because of LLVM GEP indexing restriction.
- return mlir::IntegerType::get(field.getContext(), 32);
- });
- addConversion([&](fir::LenType field) {
- // Get size of len paramter from the descriptor.
- return getModel<Fortran::runtime::typeInfo::TypeParameterValue>()(
- &getContext());
- });
- addConversion(
- [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); });
addConversion(
[&](fir::RealType real) { return convertRealType(real.getFKind()); });
addConversion(
@@ -134,8 +135,9 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
// fir.type<name(p : TY'...){f : TY...}> --> llvm<"%name = { ty... }">
llvm::Optional<LogicalResult>
- convertRecordType(fir::RecordType derived, SmallVectorImpl<Type> &results,
- ArrayRef<Type> callStack) {
+ convertRecordType(fir::RecordType derived,
+ SmallVectorImpl<mlir::Type> &results,
+ ArrayRef<mlir::Type> callStack) {
auto name = derived.getName();
auto st = mlir::LLVM::LLVMStructType::getIdentified(&getContext(), name);
if (llvm::count(callStack, derived) > 1) {
@@ -269,12 +271,6 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
return convertType(specifics->complexMemoryType(eleTy));
}
- // convert a front-end kind value to either a std or LLVM IR dialect type
- // fir.real<n> --> llvm.anyfloat where anyfloat is a kind mapping
- mlir::Type convertRealType(fir::KindTy kind) {
- return fromRealTypeID(kindMapping.getRealTypeID(kind), kind);
- }
-
template <typename A>
mlir::Type convertPointerLike(A &ty) {
mlir::Type eleTy = ty.getEleTy();
@@ -302,6 +298,12 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
return mlir::LLVM::LLVMPointerType::get(convertType(eleTy));
}
+ // convert a front-end kind value to either a std or LLVM IR dialect type
+ // fir.real<n> --> llvm.anyfloat where anyfloat is a kind mapping
+ mlir::Type convertRealType(fir::KindTy kind) {
+ return fromRealTypeID(kindMapping.getRealTypeID(kind), kind);
+ }
+
// fir.array<c ... :any> --> llvm<"[...[c x any]]">
mlir::Type convertSequenceType(SequenceType seq) {
auto baseTy = convertType(seq.getEleTy());
More information about the flang-commits
mailing list