Index: flang/lib/Optimizer/CodeGen/Target.cpp =================================================================== --- flang/lib/Optimizer/CodeGen/Target.cpp +++ flang/lib/Optimizer/CodeGen/Target.cpp @@ -465,6 +465,46 @@ }; } // namespace +//===----------------------------------------------------------------------===// +// AMDGPU linux target specifics. +//===----------------------------------------------------------------------===// + +namespace { +struct TargetAMDGPU : public GenericTarget { + using GenericTarget::GenericTarget; + + static constexpr int defaultWidth = 64; + + CodeGenSpecifics::Marshalling + complexArgumentType(mlir::Location loc, mlir::Type eleTy) const override { + CodeGenSpecifics::Marshalling marshal; + const auto *sem = &floatToSemantics(kindMap, eleTy); + if (sem == &llvm::APFloat::IEEEsingle() || + sem == &llvm::APFloat::IEEEdouble()) { + // <2 x eleTy> vector of 2 eleTy + marshal.emplace_back(fir::VectorType::get(2, eleTy), AT{}); + } else { + TODO(loc, "complex for this precision"); + } + return marshal; + } + + CodeGenSpecifics::Marshalling + complexReturnType(mlir::Location loc, mlir::Type eleTy) const override { + CodeGenSpecifics::Marshalling marshal; + const auto *sem = &floatToSemantics(kindMap, eleTy); + if (sem == &llvm::APFloat::IEEEsingle() || + sem == &llvm::APFloat::IEEEdouble()) { + // <2 x eleTy> vector of 2 eleTy + marshal.emplace_back(fir::VectorType::get(2, eleTy), AT{}); + } else { + TODO(loc, "complex for this precision"); + } + return marshal; + } +}; +} // namespace + // Instantiate the overloaded target instance based on the triple value. // TODO: Add other targets to this file as needed. std::unique_ptr @@ -497,6 +537,9 @@ case llvm::Triple::ArchType::riscv64: return std::make_unique(ctx, std::move(trp), std::move(kindMap)); + case llvm::Triple::ArchType::amdgcn: + return std::make_unique(ctx, std::move(trp), + std::move(kindMap)); } TODO(mlir::UnknownLoc::get(ctx), "target not implemented"); } Index: flang/test/Driver/target-gpu-features.f90 =================================================================== --- /dev/null +++ flang/test/Driver/target-gpu-features.f90 @@ -0,0 +1,10 @@ +! REQUIRES: amdgpu-registered-target + +! Test that -mcpu are used and that the -target-cpu and -target-features +! are also added to the fc1 command. + +! RUN: %flang --target=amdgcn-amd-amdhsa -mcpu=gfx902 -c %s -### 2>&1 \ +! RUN: | FileCheck %s -check-prefix=CHECK-AMDGCN + +! CHECK-AMDGCN: "-fc1" "-triple" "amdgcn-amd-amdhsa" +! CHECK-AMDGCN-SAME: "-target-cpu" "gfx902"