Skip to content

Commit e2c3823

Browse files
authored
[flang] Add 32-bit AIX target specific in order to build 32-bit flang-rt (#136051)
1 parent 8b46b98 commit e2c3823

File tree

3 files changed

+139
-1
lines changed

3 files changed

+139
-1
lines changed

Diff for: flang/lib/Optimizer/CodeGen/Target.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,37 @@ struct TargetAArch64 : public GenericTarget<TargetAArch64> {
10201020
};
10211021
} // namespace
10221022

1023+
//===----------------------------------------------------------------------===//
1024+
// PPC (AIX 32 bit) target specifics.
1025+
//===----------------------------------------------------------------------===//
1026+
namespace {
1027+
struct TargetPPC : public GenericTarget<TargetPPC> {
1028+
using GenericTarget::GenericTarget;
1029+
1030+
static constexpr int defaultWidth = 32;
1031+
1032+
CodeGenSpecifics::Marshalling
1033+
complexArgumentType(mlir::Location, mlir::Type eleTy) const override {
1034+
CodeGenSpecifics::Marshalling marshal;
1035+
// two distinct element type arguments (re, im)
1036+
marshal.emplace_back(eleTy, AT{});
1037+
marshal.emplace_back(eleTy, AT{});
1038+
return marshal;
1039+
}
1040+
1041+
CodeGenSpecifics::Marshalling
1042+
complexReturnType(mlir::Location, mlir::Type eleTy) const override {
1043+
CodeGenSpecifics::Marshalling marshal;
1044+
// Use a type that will be translated into LLVM as:
1045+
// { t, t } struct of 2 element type
1046+
marshal.emplace_back(
1047+
mlir::TupleType::get(eleTy.getContext(), mlir::TypeRange{eleTy, eleTy}),
1048+
AT{});
1049+
return marshal;
1050+
}
1051+
};
1052+
} // namespace
1053+
10231054
//===----------------------------------------------------------------------===//
10241055
// PPC64 (AIX 64 bit) target specifics.
10251056
//===----------------------------------------------------------------------===//
@@ -1847,6 +1878,9 @@ fir::CodeGenSpecifics::get(mlir::MLIRContext *ctx, llvm::Triple &&trp,
18471878
case llvm::Triple::ArchType::aarch64:
18481879
return std::make_unique<TargetAArch64>(
18491880
ctx, std::move(trp), std::move(kindMap), targetCPU, targetFeatures, dl);
1881+
case llvm::Triple::ArchType::ppc:
1882+
return std::make_unique<TargetPPC>(ctx, std::move(trp), std::move(kindMap),
1883+
targetCPU, targetFeatures, dl);
18501884
case llvm::Triple::ArchType::ppc64:
18511885
return std::make_unique<TargetPPC64>(
18521886
ctx, std::move(trp), std::move(kindMap), targetCPU, targetFeatures, dl);

Diff for: flang/test/Fir/comdat.fir

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: fir-opt %s --fir-to-llvm-ir="target=x86_64-pc-windows-msvc" | FileCheck %s --check-prefixes="CHECK-COMDAT"
44
// RUN: fir-opt %s --fir-to-llvm-ir="target=aarch64-apple-darwin" | FileCheck %s --check-prefixes="CHECK-NOCOMDAT"
55
// RUN: fir-opt %s --fir-to-llvm-ir="target=powerpc64-ibm-aix" | FileCheck %s --check-prefixes="CHECK-NOCOMDAT"
6+
// RUN: fir-opt %s --fir-to-llvm-ir="target=powerpc-ibm-aix" | FileCheck %s --check-prefixes="CHECK-NOCOMDAT"
67

78
// CHECK-COMDAT: llvm.func linkonce @fun_linkonce(%arg0: i32) -> i32 comdat(@__llvm_comdat::@fun_linkonce)
89
// CHECK-NOCOMDAT: llvm.func linkonce @fun_linkonce(%arg0: i32) -> i32 {
@@ -38,4 +39,4 @@ fir.global linkonce @global_linkonce constant : i32 {
3839
fir.global linkonce_odr @global_linkonce_odr constant : i32 {
3940
%0 = arith.constant 0 : i32
4041
fir.has_value %0 : i32
41-
}
42+
}

0 commit comments

Comments
 (0)