Index: tools/clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- tools/clang/lib/CodeGen/TargetInfo.cpp +++ tools/clang/lib/CodeGen/TargetInfo.cpp @@ -6843,6 +6843,39 @@ //===----------------------------------------------------------------------===// +// SPARC v8 ABI Implementation. +// Based on the SPARC Compliance Definition version 2.4.1. +// +// Ensures that complex values are passed in registers. +// +namespace { +class SparcV8ABIInfo : public DefaultABIInfo { +public: + SparcV8ABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {} + +private: + void computeInfo(CGFunctionInfo &FI) const override; +}; +} // end anonymous namespace + + +void SparcV8ABIInfo::computeInfo(CGFunctionInfo &FI) const { + DefaultABIInfo::computeInfo(FI); + + if (FI.getReturnType()->isAnyComplexType()) { + FI.getReturnInfo() = ABIArgInfo::getDirect(); + } +} + +namespace { +class SparcV8TargetCodeGenInfo : public TargetCodeGenInfo { +public: + SparcV8TargetCodeGenInfo(CodeGenTypes &CGT) + : TargetCodeGenInfo(new SparcV8ABIInfo(CGT)) {} +}; +} // end anonymous namespace + +//===----------------------------------------------------------------------===// // SPARC v9 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1. // @@ -7965,6 +7998,8 @@ return SetCGInfo(new AMDGPUTargetCodeGenInfo(Types)); case llvm::Triple::amdgcn: return SetCGInfo(new AMDGPUTargetCodeGenInfo(Types)); + case llvm::Triple::sparc: + return SetCGInfo(new SparcV8TargetCodeGenInfo(Types)); case llvm::Triple::sparcv9: return SetCGInfo(new SparcV9TargetCodeGenInfo(Types)); case llvm::Triple::xcore: Index: tools/clang/test/CodeGen/sparcv8-abi.c =================================================================== --- tools/clang/test/CodeGen/sparcv8-abi.c +++ tools/clang/test/CodeGen/sparcv8-abi.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple sparc-unknown-unknown -emit-llvm %s -o - | FileCheck %s + +// CHECK-LABEL: define { float, float } @p({ float, float }* byval align 4 %a, { float, float }* byval align 4 %b) #0 { +float __complex__ +p (float __complex__ a, float __complex__ b) +{ +}