Index: cfe/trunk/lib/Basic/Targets.cpp =================================================================== --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -5477,6 +5477,15 @@ } }; +// SPARCV8el is the 32-bit little-endian mode selected by Triple::sparcel. +class SparcV8elTargetInfo : public SparcV8TargetInfo { + public: + SparcV8elTargetInfo(const llvm::Triple &Triple) : SparcV8TargetInfo(Triple) { + DescriptionString = "e-m:e-p:32:32-i64:64-f128:64-n32-S64"; + BigEndian = false; + } +}; + // SPARC v9 is the 64-bit mode selected by Triple::sparcv9. class SparcV9TargetInfo : public SparcTargetInfo { public: @@ -6998,6 +7007,21 @@ return new SparcV8TargetInfo(Triple); } + // The 'sparcel' architecture copies all the above cases except for Solaris. + case llvm::Triple::sparcel: + switch (os) { + case llvm::Triple::Linux: + return new LinuxTargetInfo(Triple); + case llvm::Triple::NetBSD: + return new NetBSDTargetInfo(Triple); + case llvm::Triple::OpenBSD: + return new OpenBSDTargetInfo(Triple); + case llvm::Triple::RTEMS: + return new RTEMSTargetInfo(Triple); + default: + return new SparcV8elTargetInfo(Triple); + } + case llvm::Triple::sparcv9: switch (os) { case llvm::Triple::Linux: Index: cfe/trunk/lib/Driver/ToolChains.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -2078,6 +2078,7 @@ getTriple().getArch() == llvm::Triple::ppc64 || getTriple().getArch() == llvm::Triple::ppc64le || getTriple().getArch() == llvm::Triple::sparc || + getTriple().getArch() == llvm::Triple::sparcel || getTriple().getArch() == llvm::Triple::sparcv9 || getTriple().getArch() == llvm::Triple::systemz; } Index: cfe/trunk/lib/Driver/Tools.cpp =================================================================== --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -1568,6 +1568,7 @@ } case llvm::Triple::sparc: + case llvm::Triple::sparcel: case llvm::Triple::sparcv9: if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) return A->getValue(); @@ -1946,6 +1947,7 @@ getPPCTargetFeatures(Args, Features); break; case llvm::Triple::sparc: + case llvm::Triple::sparcel: case llvm::Triple::sparcv9: getSparcTargetFeatures(Args, Features); break; @@ -2833,6 +2835,7 @@ case llvm::Triple::mips64: case llvm::Triple::mips64el: case llvm::Triple::sparc: + case llvm::Triple::sparcel: case llvm::Triple::x86: case llvm::Triple::x86_64: IsPICLevelTwo = false; // "-fpie" @@ -3269,6 +3272,7 @@ break; case llvm::Triple::sparc: + case llvm::Triple::sparcel: case llvm::Triple::sparcv9: AddSparcTargetArgs(Args, CmdArgs); break; @@ -6580,6 +6584,7 @@ break; case llvm::Triple::sparc: + case llvm::Triple::sparcel: CmdArgs.push_back("-32"); NeedsKPIC = true; break; @@ -6958,6 +6963,7 @@ CmdArgs.push_back("-matpcs"); } } else if (getToolChain().getArch() == llvm::Triple::sparc || + getToolChain().getArch() == llvm::Triple::sparcel || getToolChain().getArch() == llvm::Triple::sparcv9) { if (getToolChain().getArch() == llvm::Triple::sparc) CmdArgs.push_back("-Av8plusa"); @@ -7212,6 +7218,7 @@ } case llvm::Triple::sparc: + case llvm::Triple::sparcel: CmdArgs.push_back("-32"); addAssemblerKPIC(Args, CmdArgs); break; @@ -7489,6 +7496,7 @@ CmdArgs.push_back("-mlittle-endian"); break; case llvm::Triple::sparc: + case llvm::Triple::sparcel: CmdArgs.push_back("-32"); CmdArgs.push_back("-Av8plusa"); NeedsKPIC = true; @@ -7696,7 +7704,8 @@ else return "/system/bin/linker"; } else if (ToolChain.getArch() == llvm::Triple::x86 || - ToolChain.getArch() == llvm::Triple::sparc) + ToolChain.getArch() == llvm::Triple::sparc || + ToolChain.getArch() == llvm::Triple::sparcel) return "/lib/ld-linux.so.2"; else if (ToolChain.getArch() == llvm::Triple::aarch64) return "/lib/ld-linux-aarch64.so.1"; @@ -7798,6 +7807,7 @@ case llvm::Triple::ppc64le: return "elf64lppc"; case llvm::Triple::sparc: + case llvm::Triple::sparcel: return "elf32_sparc"; case llvm::Triple::sparcv9: return "elf64_sparc"; Index: cfe/trunk/test/Driver/linux-as.c =================================================================== --- cfe/trunk/test/Driver/linux-as.c +++ cfe/trunk/test/Driver/linux-as.c @@ -131,6 +131,14 @@ // CHECK-SPARCV8: -Av8plusa // CHECK-SPARCV8: -o // +// RUN: %clang -target sparcel-linux -mcpu=invalid-cpu -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-SPARCV8EL %s +// CHECK-SPARCV8EL: as +// CHECK-SPARCV8EL: -32 +// CHECK-SPARCV8EL: -Av8plusa +// CHECK-SPARCV8EL: -o +// // RUN: %clang -target s390x-linux -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-Z-DEFAULT-ARCH %s // CHECK-Z-DEFAULT-ARCH: as{{.*}} "-march=z10" Index: cfe/trunk/test/Driver/linux-ld.c =================================================================== --- cfe/trunk/test/Driver/linux-ld.c +++ cfe/trunk/test/Driver/linux-ld.c @@ -756,14 +756,21 @@ // CHECK-MIPS64EL-N32-NAN2008-NOT: "--hash-style={{gnu|both}}" // // RUN: %clang %s -### -o %t.o 2>&1 \ -// RUN: --target=sparc-linux-gnu \ +// RUN: --target=sparc-unknown-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-SPARCV8 %s // CHECK-SPARCV8: "{{.*}}ld{{(.exe)?}}" // CHECK-SPARCV8: "-m" "elf32_sparc" // CHECK-SPARCV8: "-dynamic-linker" "/lib/ld-linux.so.2" // // RUN: %clang %s -### -o %t.o 2>&1 \ -// RUN: --target=sparcv9-linux-gnu \ +// RUN: --target=sparcel-unknown-linux-gnu \ +// RUN: | FileCheck --check-prefix=CHECK-SPARCV8EL %s +// CHECK-SPARCV8EL: "{{.*}}ld{{(.exe)?}}" +// CHECK-SPARCV8EL: "-m" "elf32_sparc" +// CHECK-SPARCV8EL: "-dynamic-linker" "/lib/ld-linux.so.2" +// +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=sparcv9-unknown-linux-gnu \ // RUN: | FileCheck --check-prefix=CHECK-SPARCV9 %s // CHECK-SPARCV9: "{{.*}}ld{{(.exe)?}}" // CHECK-SPARCV9: "-m" "elf64_sparc" Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c =================================================================== --- cfe/trunk/test/Preprocessor/predefined-arch-macros.c +++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c @@ -1676,6 +1676,39 @@ // CHECK_PPC_CRYPTO_M64: #define __CRYPTO__ // +// Begin Sparc/GCC/Linux tests ---------------- +// +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target sparc-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_SPARC +// +// CHECK_SPARC: #define __BIG_ENDIAN__ 1 +// CHECK_SPARC: #define __sparc 1 +// CHECK_SPARC: #define __sparc__ 1 +// CHECK_SPARC: #define __sparcv8 1 + +// +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target sparcel-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_SPARCEL +// +// CHECK_SPARCEL: #define __LITTLE_ENDIAN__ 1 +// CHECK_SPARCEL: #define __sparc 1 +// CHECK_SPARCEL: #define __sparc__ 1 +// CHECK_SPARCEL: #define __sparcv8 1 +// +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target sparcv9-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_SPARCV9 +// +// CHECK_SPARCV9: #define __BIG_ENDIAN__ 1 +// CHECK_SPARCV9: #define __sparc 1 +// CHECK_SPARCV9: #define __sparc64__ 1 +// CHECK_SPARCV9: #define __sparc__ 1 +// CHECK_SPARCV9: #define __sparc_v9__ 1 +// CHECK_SPARCV9: #define __sparcv9 1 +// CHECK_SPARCV9: #define __sparcv9__ 1 + // Begin SystemZ/GCC/Linux tests ---------------- // // RUN: %clang -march=z10 -E -dM %s -o - 2>&1 \