diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -334,6 +334,16 @@ return new PPC32TargetInfo(Triple, Opts); } + case llvm::Triple::ppcle: + switch (os) { + case llvm::Triple::Linux: + return new LinuxTargetInfo(Triple, Opts); + case llvm::Triple::FreeBSD: + return new FreeBSDTargetInfo(Triple, Opts); + default: + return new PPC32TargetInfo(Triple, Opts); + } + case llvm::Triple::ppc64: if (Triple.isOSDarwin()) return new DarwinPPC64TargetInfo(Triple, Opts); diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -253,6 +253,7 @@ case llvm::Triple::mips: case llvm::Triple::mipsel: case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: this->MCountName = "_mcount"; @@ -413,6 +414,7 @@ case llvm::Triple::mips64: case llvm::Triple::mips64el: case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: this->MCountName = "_mcount"; diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -355,6 +355,8 @@ : PPCTargetInfo(Triple, Opts) { if (Triple.isOSAIX()) resetDataLayout("E-m:a-p:32:32-i64:64-n32"); + else if ((Triple.getArch() == llvm::Triple::ppcle)) + resetDataLayout("e-m:e-p:32:32-i64:64-n32"); else resetDataLayout("E-m:e-p:32:32-i64:64-n32"); diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -92,7 +92,8 @@ } // Target properties. - if (getTriple().getArch() == llvm::Triple::ppc64le) { + if (getTriple().getArch() == llvm::Triple::ppc64le || + getTriple().getArch() == llvm::Triple::ppcle) { Builder.defineMacro("_LITTLE_ENDIAN"); } else { if (!getTriple().isOSNetBSD() && diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -5041,6 +5041,7 @@ case llvm::Triple::x86_64: return CGF->EmitX86BuiltinExpr(BuiltinID, E); case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: return CGF->EmitPPCBuiltinExpr(BuiltinID, E); diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -4858,7 +4858,7 @@ bool PPC32TargetCodeGenInfo::isStructReturnInRegABI( const llvm::Triple &Triple, const CodeGenOptions &Opts) { - assert(Triple.getArch() == llvm::Triple::ppc); + assert(Triple.isPPC32()); switch (Opts.getStructReturnConvention()) { case CodeGenOptions::SRCK_Default: @@ -10934,6 +10934,13 @@ return SetCGInfo( new PPC32TargetCodeGenInfo(Types, IsSoftFloat, RetSmallStructInRegABI)); } + case llvm::Triple::ppcle: { + bool IsSoftFloat = CodeGenOpts.FloatABI == "soft"; + bool RetSmallStructInRegABI = + PPC32TargetCodeGenInfo::isStructReturnInRegABI(Triple, CodeGenOpts); + return SetCGInfo( + new PPC32TargetCodeGenInfo(Types, IsSoftFloat, RetSmallStructInRegABI)); + } case llvm::Triple::ppc64: if (Triple.isOSAIX()) return SetCGInfo(new AIXTargetCodeGenInfo(Types, /*Is64Bit*/ true)); diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -5111,9 +5111,7 @@ !Target.hasEnvironment()) TC = std::make_unique(*this, Target, Args); - else if (Target.getArch() == llvm::Triple::ppc || - Target.getArch() == llvm::Triple::ppc64 || - Target.getArch() == llvm::Triple::ppc64le) + else if (Target.isPPC()) TC = std::make_unique(*this, Target, Args); else if (Target.getArch() == llvm::Triple::ve) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -241,6 +241,8 @@ return "arm64_32"; case llvm::Triple::ppc: return "ppc"; + case llvm::Triple::ppcle: + return "ppcle"; case llvm::Triple::ppc64: return "ppc64"; case llvm::Triple::ppc64le: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -332,6 +332,7 @@ break; case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: ppc::getPPCTargetFeatures(D, Triple, Args, Features); @@ -528,6 +529,7 @@ // WebAssembly never wants frame pointers. return false; case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: case llvm::Triple::riscv32: @@ -1386,6 +1388,7 @@ return false; case llvm::Triple::hexagon: + case llvm::Triple::ppcle: case llvm::Triple::ppc64le: case llvm::Triple::riscv32: case llvm::Triple::riscv64: @@ -1602,6 +1605,7 @@ break; case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: AddPPCTargetArgs(Args, CmdArgs); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -389,6 +389,7 @@ return ""; case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: { std::string TargetCPUName = ppc::getPPCTargetCPU(Args); diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -42,6 +42,7 @@ CmdArgs.push_back("--32"); break; case llvm::Triple::ppc: + case llvm::Triple::ppcle: CmdArgs.push_back("-a32"); break; case llvm::Triple::mips: @@ -192,6 +193,11 @@ CmdArgs.push_back("-m"); CmdArgs.push_back("elf32ppc_fbsd"); break; + case llvm::Triple::ppcle: + CmdArgs.push_back("-m"); + // Use generic -- only usage is for freestanding. + CmdArgs.push_back("elf32lppc"); + break; case llvm::Triple::mips: CmdArgs.push_back("-m"); CmdArgs.push_back("elf32btsmip_fbsd"); @@ -374,7 +380,7 @@ // When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall // back to '/usr/lib' if it doesn't exist. if ((Triple.getArch() == llvm::Triple::x86 || Triple.isMIPS32() || - Triple.getArch() == llvm::Triple::ppc) && + Triple.isPPC32()) && D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o")) getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32"); else diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -99,6 +99,7 @@ break; case llvm::Triple::x86: case llvm::Triple::ppc: + case llvm::Triple::ppcle: CmdArgs.push_back("-m32"); break; case llvm::Triple::x86_64: @@ -255,6 +256,8 @@ return isArmBigEndian(T, Args) ? "armelfb_linux_eabi" : "armelf_linux_eabi"; case llvm::Triple::ppc: return "elf32ppclinux"; + case llvm::Triple::ppcle: + return "elf32lppc"; case llvm::Triple::ppc64: return "elf64ppc"; case llvm::Triple::ppc64le: @@ -728,6 +731,14 @@ ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple()))); break; } + case llvm::Triple::ppcle: { + CmdArgs.push_back("-a32"); + CmdArgs.push_back("-mppc"); + CmdArgs.push_back("-mlittle-endian"); + CmdArgs.push_back( + ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple()))); + break; + } case llvm::Triple::ppc64: { CmdArgs.push_back("-a64"); CmdArgs.push_back("-mppc64"); @@ -2133,6 +2144,12 @@ // On 32-bit PowerPC systems running SUSE Linux, gcc is configured as a // 64-bit compiler which defaults to "-m32", hence "powerpc64-suse-linux". "powerpc64-suse-linux", "powerpc-montavista-linuxspe"}; + // PPCLE is only used in niche situations such as bootloaders + // and compatibility shims. + static const char *const PPCLELibDirs[] = {"/lib32", "/lib"}; + static const char *const PPCLETriples[] = {"powerpcle-unknown-elf", + "powerpcle-unknown-linux-gnu", + "powerpcle-unknown-freebsd"}; static const char *const PPC64LibDirs[] = {"/lib64", "/lib"}; static const char *const PPC64Triples[] = { "powerpc64-linux-gnu", "powerpc64-unknown-linux-gnu", @@ -2373,6 +2390,12 @@ BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs)); BiarchTripleAliases.append(begin(PPC64Triples), end(PPC64Triples)); break; + case llvm::Triple::ppcle: + LibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs)); + TripleAliases.append(begin(PPCLETriples), end(PPCLETriples)); + BiarchLibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs)); + BiarchTripleAliases.append(begin(PPC64LETriples), end(PPC64LETriples)); + break; case llvm::Triple::ppc64: LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs)); TripleAliases.append(begin(PPC64Triples), end(PPC64Triples)); @@ -2382,6 +2405,8 @@ case llvm::Triple::ppc64le: LibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs)); TripleAliases.append(begin(PPC64LETriples), end(PPC64LETriples)); + BiarchLibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs)); + BiarchTripleAliases.append(begin(PPCLETriples), end(PPCLETriples)); break; case llvm::Triple::riscv32: LibDirs.append(begin(RISCV32LibDirs), end(RISCV32LibDirs)); @@ -2716,6 +2741,7 @@ case llvm::Triple::thumb: case llvm::Triple::thumbeb: case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: case llvm::Triple::riscv32: diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -142,6 +142,10 @@ if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnu")) return "powerpc-linux-gnu"; break; + case llvm::Triple::ppcle: + if (D.getVFS().exists(SysRoot + "/lib/powerpcle-linux-gnu")) + return "powerpcle-linux-gnu"; + break; case llvm::Triple::ppc64: if (D.getVFS().exists(SysRoot + "/lib/powerpc64-linux-gnu")) return "powerpc64-linux-gnu"; @@ -194,8 +198,7 @@ // FIXME: This is a bit of a hack. We should really unify this code for // reasoning about oslibdir spellings with the lib dir spellings in the // GCCInstallationDetector, but that is a more significant refactoring. - if (Triple.getArch() == llvm::Triple::x86 || - Triple.getArch() == llvm::Triple::ppc || + if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() || Triple.getArch() == llvm::Triple::sparc) return "lib32"; @@ -496,6 +499,10 @@ LibDir = "lib"; Loader = "ld.so.1"; break; + case llvm::Triple::ppcle: + LibDir = "lib32"; // 32 bit LE is never a native arch. + Loader = "ld.so.1"; + break; case llvm::Triple::ppc64: LibDir = "lib64"; Loader = @@ -643,6 +650,8 @@ const StringRef PPCMultiarchIncludeDirs[] = { "/usr/include/powerpc-linux-gnu", "/usr/include/powerpc-linux-gnuspe"}; + const StringRef PPCLEMultiarchIncludeDirs[] = { + "/usr/include/powerpcle-linux-gnu"}; const StringRef PPC64MultiarchIncludeDirs[] = { "/usr/include/powerpc64-linux-gnu"}; const StringRef PPC64LEMultiarchIncludeDirs[] = { @@ -716,6 +725,9 @@ case llvm::Triple::ppc: MultiarchIncludeDirs = PPCMultiarchIncludeDirs; break; + case llvm::Triple::ppcle: + MultiarchIncludeDirs = PPCLEMultiarchIncludeDirs; + break; case llvm::Triple::ppc64: MultiarchIncludeDirs = PPC64MultiarchIncludeDirs; break; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3294,9 +3294,7 @@ if (TT.getArch() == llvm::Triple::UnknownArch || !(TT.getArch() == llvm::Triple::aarch64 || - TT.getArch() == llvm::Triple::ppc || - TT.getArch() == llvm::Triple::ppc64 || - TT.getArch() == llvm::Triple::ppc64le || + TT.isPPC() || TT.getArch() == llvm::Triple::nvptx || TT.getArch() == llvm::Triple::nvptx64 || TT.getArch() == llvm::Triple::amdgcn || diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1422,6 +1422,7 @@ case llvm::Triple::x86_64: return CheckX86BuiltinFunctionCall(TI, BuiltinID, TheCall); case llvm::Triple::ppc: + case llvm::Triple::ppcle: case llvm::Triple::ppc64: case llvm::Triple::ppc64le: return CheckPPCBuiltinFunctionCall(TI, BuiltinID, TheCall); diff --git a/clang/test/CodeGen/altivec.c b/clang/test/CodeGen/altivec.c --- a/clang/test/CodeGen/altivec.c +++ b/clang/test/CodeGen/altivec.c @@ -1,15 +1,18 @@ -// RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE +// RUN: %clang_cc1 -target-feature +altivec -triple powerpcle-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE +// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE +// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE +// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple powerpc-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR // RUN: not %clang_cc1 -target-feature +altivec -mabi=vec-default -triple powerpc64-unknown-aix -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR -// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target powerpc-unknown-aix %s -o - | FileCheck %s +// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target powerpc-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE // RUN: not %clang -S -emit-llvm -maltivec -target powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR // RUN: not %clang -S -emit-llvm -maltivec -target powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR // RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ATVER // RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ATVER -// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target powerpc64-unknown-aix %s -o - | FileCheck %s +// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target powerpc64-unknown-aix %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE // RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ATVER // RUN: not %clang -S -emit-llvm -mabi=vec-extabi -target powerpc64-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ATVER // RUN: not %clang -S -mabi=vec-default -target powerpc-unknown-aix %s 2>&1 | FileCheck %s --check-prefix=AIX-ATVER @@ -21,13 +24,17 @@ vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> vector float test1 = (vector float)(1.0); // CHECK: @test1 = global <4 x float> -// CHECK: @v1 = global <16 x i8> +// CHECK-BE: @v1 = global <16 x i8> +// CHECK-LE: @v1 = global <16 x i8> vector char v1 = (vector char)((vector int)(1, 2, 3, 4)); -// CHECK: @v2 = global <16 x i8> +// CHECK-BE: @v2 = global <16 x i8> +// CHECK-LE: @v2 = global <16 x i8> vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f)); -// CHECK: @v3 = global <16 x i8> +// CHECK-BE: @v3 = global <16 x i8> +// CHECK-LE: @v3 = global <16 x i8> vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd')); -// CHECK: @v4 = global <4 x i32> +// CHECK-BE: @v4 = global <4 x i32> +// CHECK-LE: @v4 = global <4 x i32> vector int v4 = (vector char){1, 2, 3, 4}; void test2() diff --git a/clang/test/CodeGen/builtins-ppc-altivec.c b/clang/test/CodeGen/builtins-ppc-altivec.c --- a/clang/test/CodeGen/builtins-ppc-altivec.c +++ b/clang/test/CodeGen/builtins-ppc-altivec.c @@ -1,6 +1,8 @@ // REQUIRES: powerpc-registered-target // RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown -emit-llvm %s \ // RUN: -flax-vector-conversions=none -o - | FileCheck %s +// RUN: %clang_cc1 -target-feature +altivec -triple powerpcle-unknown-unknown -emit-llvm %s \ +// RUN: -flax-vector-conversions=none -o - | FileCheck %s -check-prefix=CHECK-LE // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \ // RUN: -flax-vector-conversions=none -o - | FileCheck %s // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64le-unknown-unknown -emit-llvm %s \ diff --git a/clang/test/CodeGen/ppc32-and-aix-struct-return.c b/clang/test/CodeGen/ppc32-and-aix-struct-return.c --- a/clang/test/CodeGen/ppc32-and-aix-struct-return.c +++ b/clang/test/CodeGen/ppc32-and-aix-struct-return.c @@ -1,6 +1,8 @@ // REQUIRES: powerpc-registered-target // RUN: %clang_cc1 -triple powerpc-unknown-freebsd \ // RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-SVR4 +// RUN: %clang_cc1 -triple powerpcle-unknown-freebsd \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-SVR4 // RUN: %clang_cc1 -triple powerpc-unknown-aix \ // RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-AIX // RUN: %clang_cc1 -triple powerpc64-unknown-aix \ @@ -11,6 +13,12 @@ // RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-AIX // RUN: %clang_cc1 -triple powerpc-unknown-linux -msvr4-struct-return \ // RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-SVR4 +// RUN: %clang_cc1 -triple powerpcle-unknown-linux \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-AIX +// RUN: %clang_cc1 -triple powerpcle-unknown-linux -maix-struct-return \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-AIX +// RUN: %clang_cc1 -triple powerpcle-unknown-linux -msvr4-struct-return \ +// RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-SVR4 // RUN: %clang_cc1 -triple powerpc-unknown-netbsd \ // RUN: -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-SVR4 // RUN: %clang_cc1 -triple powerpc-unknown-openbsd \ diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c --- a/clang/test/CodeGen/target-data.c +++ b/clang/test/CodeGen/target-data.c @@ -126,6 +126,10 @@ // RUN: FileCheck %s -check-prefix=PPC // PPC: target datalayout = "E-m:e-p:32:32-i64:64-n32" +// RUN: %clang_cc1 -triple powerpcle-unknown -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=PPCLE +// PPCLE: target datalayout = "e-m:e-p:32:32-i64:64-n32" + // RUN: %clang_cc1 -triple powerpc64-freebsd -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=PPC64-FREEBSD // PPC64-FREEBSD: target datalayout = "E-m:e-i64:64-n32:64" diff --git a/clang/test/Driver/ppc-endian.c b/clang/test/Driver/ppc-endian.c --- a/clang/test/Driver/ppc-endian.c +++ b/clang/test/Driver/ppc-endian.c @@ -1,9 +1,19 @@ -// RUN: %clang -target powerpc64le -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE %s -// RUN: %clang -target powerpc64le -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE %s -// RUN: %clang -target powerpc64 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE %s -// CHECK-LE: "-cc1"{{.*}} "-triple" "powerpc64le{{.*}}" +// RUN: %clang -target powerpc-unknown -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE32 %s +// RUN: %clang -target powerpc-unknown -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE32 %s +// RUN: %clang -target powerpcle-unknown -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE32 %s +// CHECK-BE32: "-cc1"{{.*}} "-triple" "powerpc-{{.*}}" -// RUN: %clang -target powerpc64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE %s -// RUN: %clang -target powerpc64 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE %s -// RUN: %clang -target powerpc64le -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE %s -// CHECK-BE: "-cc1"{{.*}} "-triple" "powerpc64{{.*}}" +// RUN: %clang -target powerpcle-unknown -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE32 %s +// RUN: %clang -target powerpcle-unknown -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE32 %s +// RUN: %clang -target powerpc-unknown -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE32 %s +// CHECK-LE32: "-cc1"{{.*}} "-triple" "powerpcle-{{.*}}" + +// RUN: %clang -target powerpc64-unknown -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE64 %s +// RUN: %clang -target powerpc64-unknown -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE64 %s +// RUN: %clang -target powerpc64le-unknown -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE64 %s +// CHECK-BE64: "-cc1"{{.*}} "-triple" "powerpc64-{{.*}}" + +// RUN: %clang -target powerpc64le-unknown -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE64 %s +// RUN: %clang -target powerpc64le-unknown -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE64 %s +// RUN: %clang -target powerpc64-unknown -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-LE64 %s +// CHECK-LE64: "-cc1"{{.*}} "-triple" "powerpc64le-{{.*}}" diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -152,6 +152,7 @@ .Cases("elf32ltsmip", "elf32ltsmipn32", {ELF32LEKind, EM_MIPS}) .Case("elf32lriscv", {ELF32LEKind, EM_RISCV}) .Cases("elf32ppc", "elf32ppclinux", {ELF32BEKind, EM_PPC}) + .Cases("elf32lppc", "elf32lppclinux", {ELF32LEKind, EM_PPC}) .Case("elf64btsmip", {ELF64BEKind, EM_MIPS}) .Case("elf64ltsmip", {ELF64LEKind, EM_MIPS}) .Case("elf64lriscv", {ELF64LEKind, EM_RISCV}) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1621,6 +1621,7 @@ case Triple::msp430: return EM_MSP430; case Triple::ppc: + case Triple::ppcle: return EM_PPC; case Triple::ppc64: case Triple::ppc64le: diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -413,6 +413,7 @@ .Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64}) .Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64}) .Case("elf32-powerpc", {ELF32BEKind, EM_PPC}) + .Case("elf32-powerpcle", {ELF32LEKind, EM_PPC}) .Case("elf64-powerpc", {ELF64BEKind, EM_PPC64}) .Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64}) .Case("elf64-x86-64", {ELF64LEKind, EM_X86_64}) diff --git a/lld/test/ELF/emulation-ppc.s b/lld/test/ELF/emulation-ppc.s --- a/lld/test/ELF/emulation-ppc.s +++ b/lld/test/ELF/emulation-ppc.s @@ -1,144 +1,106 @@ # REQUIRES: ppc # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %tppc64 # RUN: ld.lld -m elf64ppc %tppc64 -o %t2ppc64 -# RUN: llvm-readobj --file-headers %t2ppc64 | FileCheck --check-prefix=PPC64 %s +# RUN: llvm-readobj --file-headers %t2ppc64 | FileCheck --check-prefixes=CHECK,PPC64,LINUX,PPCBE %s # RUN: ld.lld %tppc64 -o %t3ppc64 -# RUN: llvm-readobj --file-headers %t3ppc64 | FileCheck --check-prefix=PPC64 %s +# RUN: llvm-readobj --file-headers %t3ppc64 | FileCheck --check-prefixes=CHECK,PPC64,LINUX,PPCBE %s # RUN: echo 'OUTPUT_FORMAT(elf64-powerpc)' > %tppc64.script # RUN: ld.lld %tppc64.script %tppc64 -o %t4ppc64 -# RUN: llvm-readobj --file-headers %t4ppc64 | FileCheck --check-prefix=PPC64 %s - -# PPC64: ElfHeader { -# PPC64-NEXT: Ident { -# PPC64-NEXT: Magic: (7F 45 4C 46) -# PPC64-NEXT: Class: 64-bit (0x2) -# PPC64-NEXT: DataEncoding: BigEndian (0x2) -# PPC64-NEXT: FileVersion: 1 -# PPC64-NEXT: OS/ABI: SystemV (0x0) -# PPC64-NEXT: ABIVersion: 0 -# PPC64-NEXT: Unused: (00 00 00 00 00 00 00) -# PPC64-NEXT: } -# PPC64-NEXT: Type: Executable (0x2) -# PPC64-NEXT: Machine: EM_PPC64 (0x15) -# PPC64-NEXT: Version: 1 -# PPC64-NEXT: Entry: -# PPC64-NEXT: ProgramHeaderOffset: 0x40 -# PPC64-NEXT: SectionHeaderOffset: -# PPC64-NEXT: Flags [ (0x2) -# PPC64-NEXT: 0x2 -# PPC64-NEXT: ] -# PPC64-NEXT: HeaderSize: 64 -# PPC64-NEXT: ProgramHeaderEntrySize: 56 -# PPC64-NEXT: ProgramHeaderCount: -# PPC64-NEXT: SectionHeaderEntrySize: 64 -# PPC64-NEXT: SectionHeaderCount: -# PPC64-NEXT: StringTableSectionIndex: -# PPC64-NEXT: } - -# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd %s -o %tppc64fbsd -# RUN: echo 'OUTPUT_FORMAT(elf64-powerpc-freebsd)' > %tppc64fbsd.script -# RUN: ld.lld %tppc64fbsd.script %tppc64fbsd -o %t2ppc64fbsd -# RUN: llvm-readobj --file-headers %t2ppc64fbsd | FileCheck --check-prefix=PPC64-FBSD %s - -# PPC64-FBSD: ElfHeader { -# PPC64-FBSD-NEXT: Ident { -# PPC64-FBSD-NEXT: Magic: (7F 45 4C 46) -# PPC64-FBSD-NEXT: Class: 64-bit (0x2) -# PPC64-FBSD-NEXT: DataEncoding: BigEndian (0x2) -# PPC64-FBSD-NEXT: FileVersion: 1 -# PPC64-FBSD-NEXT: OS/ABI: FreeBSD (0x9) -# PPC64-FBSD-NEXT: ABIVersion: 0 -# PPC64-FBSD-NEXT: Unused: (00 00 00 00 00 00 00) -# PPC64-FBSD-NEXT: } -# PPC64-FBSD-NEXT: Type: Executable (0x2) -# PPC64-FBSD-NEXT: Machine: EM_PPC64 (0x15) -# PPC64-FBSD-NEXT: Version: 1 -# PPC64-FBSD-NEXT: Entry: -# PPC64-FBSD-NEXT: ProgramHeaderOffset: 0x40 -# PPC64-FBSD-NEXT: SectionHeaderOffset: -# PPC64-FBSD-NEXT: Flags [ (0x2) -# PPC64-FBSD-NEXT: 0x2 -# PPC64-FBSD-NEXT: ] -# PPC64-FBSD-NEXT: HeaderSize: 64 -# PPC64-FBSD-NEXT: ProgramHeaderEntrySize: 56 -# PPC64-FBSD-NEXT: ProgramHeaderCount: -# PPC64-FBSD-NEXT: SectionHeaderEntrySize: 64 -# PPC64-FBSD-NEXT: SectionHeaderCount: -# PPC64-FBSD-NEXT: StringTableSectionIndex: -# PPC64-FBSD-NEXT: } +# RUN: llvm-readobj --file-headers %t4ppc64 | FileCheck --check-prefixes=CHECK,PPC64,LINUX,PPCBE %s # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %tppc64le # RUN: ld.lld -m elf64lppc %tppc64le -o %t2ppc64le -# RUN: llvm-readobj --file-headers %t2ppc64le | FileCheck --check-prefix=PPC64LE %s +# RUN: llvm-readobj --file-headers %t2ppc64le | FileCheck --check-prefixes=CHECK,PPC64,LINUX,PPCLE %s # RUN: ld.lld %tppc64le -o %t3ppc64le -# RUN: llvm-readobj --file-headers %t3ppc64le | FileCheck --check-prefix=PPC64LE %s +# RUN: llvm-readobj --file-headers %t3ppc64le | FileCheck --check-prefixes=CHECK,PPC64,LINUX,PPCLE %s # RUN: echo 'OUTPUT_FORMAT(elf64-powerpcle)' > %tppc64le.script # RUN: ld.lld %tppc64le.script %tppc64le -o %t4ppc64le -# RUN: llvm-readobj --file-headers %t4ppc64le | FileCheck --check-prefix=PPC64LE %s - -# PPC64LE: ElfHeader { -# PPC64LE-NEXT: Ident { -# PPC64LE-NEXT: Magic: (7F 45 4C 46) -# PPC64LE-NEXT: Class: 64-bit (0x2) -# PPC64LE-NEXT: DataEncoding: LittleEndian (0x1) -# PPC64LE-NEXT: FileVersion: 1 -# PPC64LE-NEXT: OS/ABI: SystemV (0x0) -# PPC64LE-NEXT: ABIVersion: 0 -# PPC64LE-NEXT: Unused: (00 00 00 00 00 00 00) -# PPC64LE-NEXT: } -# PPC64LE-NEXT: Type: Executable (0x2) -# PPC64LE-NEXT: Machine: EM_PPC64 (0x15) -# PPC64LE-NEXT: Version: 1 -# PPC64LE-NEXT: Entry: -# PPC64LE-NEXT: ProgramHeaderOffset: 0x40 -# PPC64LE-NEXT: SectionHeaderOffset: -# PPC64LE-NEXT: Flags [ (0x2) -# PPC64LE-NEXT: 0x2 -# PPC64LE-NEXT: ] -# PPC64LE-NEXT: HeaderSize: 64 -# PPC64LE-NEXT: ProgramHeaderEntrySize: 56 -# PPC64LE-NEXT: ProgramHeaderCount: -# PPC64LE-NEXT: SectionHeaderEntrySize: 64 -# PPC64LE-NEXT: SectionHeaderCount: -# PPC64LE-NEXT: StringTableSectionIndex: -# PPC64LE-NEXT: } +# RUN: llvm-readobj --file-headers %t4ppc64le | FileCheck --check-prefixes=CHECK,PPC64,LINUX,PPCLE %s # RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-linux %s -o %tppc32 # RUN: ld.lld -m elf32ppc %tppc32 -o %t2ppc32 -# RUN: llvm-readobj --file-headers %t2ppc32 | FileCheck --check-prefix=PPC32 %s +# RUN: llvm-readobj --file-headers %t2ppc32 | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCBE %s # RUN: ld.lld %tppc32 -o %t3ppc32 -# RUN: llvm-readobj --file-headers %t3ppc32 | FileCheck --check-prefix=PPC32 %s +# RUN: llvm-readobj --file-headers %t3ppc32 | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCBE %s # RUN: echo 'OUTPUT_FORMAT(elf32-powerpc)' > %tppc32.script # RUN: ld.lld %tppc32.script %tppc32 -o %t4ppc32 -# RUN: llvm-readobj --file-headers %t4ppc32 | FileCheck --check-prefix=PPC32 %s +# RUN: llvm-readobj --file-headers %t4ppc32 | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCBE %s # RUN: ld.lld -m elf32ppclinux %tppc32 -o %t5ppc32 -# RUN: llvm-readobj --file-headers %t5ppc32 | FileCheck --check-prefix=PPC32 %s +# RUN: llvm-readobj --file-headers %t5ppc32 | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCBE %s + +# RUN: llvm-mc -filetype=obj -triple=powerpcle-unknown-linux %s -o %tppc32le +# RUN: ld.lld -m elf32lppc %tppc32le -o %t2ppc32le +# RUN: llvm-readobj --file-headers %t2ppc32le | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCLE %s +# RUN: ld.lld %tppc32le -o %t3ppc32le +# RUN: llvm-readobj --file-headers %t3ppc32le | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCLE %s +# RUN: echo 'OUTPUT_FORMAT(elf32-powerpcle)' > %tppc32le.script +# RUN: ld.lld %tppc32le.script %tppc32le -o %t4ppc32le +# RUN: llvm-readobj --file-headers %t4ppc32le | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCLE %s +# RUN: ld.lld -m elf32lppclinux %tppc32le -o %t5ppc32le +# RUN: llvm-readobj --file-headers %t5ppc32le | FileCheck --check-prefixes=CHECK,PPC32,LINUX,PPCLE %s + +# RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-freebsd %s -o %tppc32fbsd +# RUN: echo 'OUTPUT_FORMAT(elf32-powerpc-freebsd)' > %tppc32fbsd.script +# RUN: ld.lld %tppc32fbsd.script %tppc32fbsd -o %t2ppc32fbsd +# RUN: llvm-readobj --file-headers %t2ppc32fbsd | FileCheck --check-prefixes=CHECK,PPC32,FBSD,PPCBE %s + +# RUN: llvm-mc -filetype=obj -triple=powerpcle-unknown-freebsd %s -o %tppc32fbsdle +# RUN: echo 'OUTPUT_FORMAT(elf32-powerpcle-freebsd)' > %tppc32fbsdle.script +# RUN: ld.lld %tppc32fbsdle.script %tppc32fbsdle -o %t2ppc32fbsdle +# RUN: llvm-readobj --file-headers %t2ppc32fbsdle | FileCheck --check-prefixes=CHECK,PPC32,FBSD,PPCLE %s + +# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd %s -o %tppc64fbsd +# RUN: echo 'OUTPUT_FORMAT(elf64-powerpc-freebsd)' > %tppc64fbsd.script +# RUN: ld.lld %tppc64fbsd.script %tppc64fbsd -o %t2ppc64fbsd +# RUN: llvm-readobj --file-headers %t2ppc64fbsd | FileCheck --check-prefixes=CHECK,PPC64,FBSD,PPCBE %s + +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-freebsd %s -o %tppc64fbsdle +# RUN: echo 'OUTPUT_FORMAT(elf64-powerpcle-freebsd)' > %tppc64fbsdle.script +# RUN: ld.lld %tppc64fbsdle.script %tppc64fbsdle -o %t2ppc64fbsdle +# RUN: llvm-readobj --file-headers %t2ppc64fbsdle | FileCheck --check-prefixes=CHECK,PPC64,FBSD,PPCLE %s -# PPC32: ElfHeader { -# PPC32-NEXT: Ident { -# PPC32-NEXT: Magic: (7F 45 4C 46) +# CHECK: ElfHeader { +# CHECK-NEXT: Ident { +# CHECK-NEXT: Magic: (7F 45 4C 46) + +# PPC64-NEXT: Class: 64-bit (0x2) # PPC32-NEXT: Class: 32-bit (0x1) -# PPC32-NEXT: DataEncoding: BigEndian (0x2) -# PPC32-NEXT: FileVersion: 1 -# PPC32-NEXT: OS/ABI: SystemV (0x0) -# PPC32-NEXT: ABIVersion: 0 -# PPC32-NEXT: Unused: (00 00 00 00 00 00 00) -# PPC32-NEXT: } -# PPC32-NEXT: Type: Executable (0x2) + +# PPCBE-NEXT: DataEncoding: BigEndian (0x2) +# PPCLE-NEXT: DataEncoding: LittleEndian (0x1) + +# CHECK-NEXT: FileVersion: 1 + +# LINUX-NEXT: OS/ABI: SystemV (0x0) +# FBSD-NEXT: OS/ABI: FreeBSD (0x9) + +# CHECK-NEXT: ABIVersion: 0 +# CHECK-NEXT: Unused: (00 00 00 00 00 00 00) +# CHECK-NEXT: } +# CHECK-NEXT: Type: Executable (0x2) + +# PPC64-NEXT: Machine: EM_PPC64 (0x15) # PPC32-NEXT: Machine: EM_PPC (0x14) -# PPC32-NEXT: Version: 1 -# PPC32-NEXT: Entry: + +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: Entry: +# PPC64-NEXT: ProgramHeaderOffset: 0x40 # PPC32-NEXT: ProgramHeaderOffset: 0x34 -# PPC32-NEXT: SectionHeaderOffset: +# CHECK-NEXT: SectionHeaderOffset: +# PPC64-NEXT: Flags [ (0x2) # PPC32-NEXT: Flags [ (0x0) -# PPC32-NEXT: ] +# PPC64-NEXT: 0x2 +# CHECK-NEXT: ] +# PPC64-NEXT: HeaderSize: 64 # PPC32-NEXT: HeaderSize: 52 +# PPC64-NEXT: ProgramHeaderEntrySize: 56 # PPC32-NEXT: ProgramHeaderEntrySize: 32 -# PPC32-NEXT: ProgramHeaderCount: +# CHECK-NEXT: ProgramHeaderCount: +# PPC64-NEXT: SectionHeaderEntrySize: 64 # PPC32-NEXT: SectionHeaderEntrySize: 40 -# PPC32-NEXT: SectionHeaderCount: -# PPC32-NEXT: StringTableSectionIndex: -# PPC32-NEXT: } +# CHECK-NEXT: SectionHeaderCount: +# CHECK-NEXT: StringTableSectionIndex: +# CHECK-NEXT: } .globl _start _start: diff --git a/lld/test/ELF/ppc32-gnu-ifunc.s b/lld/test/ELF/ppc32-gnu-ifunc.s --- a/lld/test/ELF/ppc32-gnu-ifunc.s +++ b/lld/test/ELF/ppc32-gnu-ifunc.s @@ -5,6 +5,12 @@ # RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=SEC,SYM %s # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s +# RUN: llvm-mc -filetype=obj -triple=powerpcle %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s +# RUN: llvm-readelf -S -s %t | FileCheck --check-prefixes=SEC,SYM %s +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s + # RELOC: .rela.dyn { # RELOC-NEXT: 0x10020118 R_PPC_IRELATIVE - 0x100100E0 # RELOC-NEXT: } diff --git a/lld/test/ELF/ppc32-reloc-rel.s b/lld/test/ELF/ppc32-reloc-rel.s --- a/lld/test/ELF/ppc32-reloc-rel.s +++ b/lld/test/ELF/ppc32-reloc-rel.s @@ -1,6 +1,10 @@ # REQUIRES: ppc -# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o -# RUN: ld.lld %t.o -o %t +# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.be.o +# RUN: ld.lld %t.be.o -o %t +# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s + +# RUN: llvm-mc -filetype=obj -triple=powerpcle %s -o %t.le.o +# RUN: ld.lld %t.le.o -o %t # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s .section .R_PPC_REL14,"ax",@progbits diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -1033,6 +1033,7 @@ __OMP_TRAIT_PROPERTY(device, arch, aarch64_be) __OMP_TRAIT_PROPERTY(device, arch, aarch64_32) __OMP_TRAIT_PROPERTY(device, arch, ppc) +__OMP_TRAIT_PROPERTY(device, arch, ppcle) __OMP_TRAIT_PROPERTY(device, arch, ppc64) __OMP_TRAIT_PROPERTY(device, arch, ppc64le) __OMP_TRAIT_PROPERTY(device, arch, x86) diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -1169,7 +1169,7 @@ case ELF::EM_MSP430: return "elf32-msp430"; case ELF::EM_PPC: - return "elf32-powerpc"; + return (IsLittleEndian ? "elf32-powerpcle" : "elf32-powerpc"); case ELF::EM_RISCV: return "elf32-littleriscv"; case ELF::EM_CSKY: @@ -1245,7 +1245,7 @@ case ELF::EM_MSP430: return Triple::msp430; case ELF::EM_PPC: - return Triple::ppc; + return IsLittleEndian ? Triple::ppcle : Triple::ppc; case ELF::EM_PPC64: return IsLittleEndian ? Triple::ppc64le : Triple::ppc64; case ELF::EM_RISCV: diff --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp b/llvm/lib/Frontend/OpenMP/OMPContext.cpp --- a/llvm/lib/Frontend/OpenMP/OMPContext.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPContext.cpp @@ -40,6 +40,7 @@ case Triple::mips64: case Triple::mips64el: case Triple::ppc: + case Triple::ppcle: case Triple::ppc64: case Triple::ppc64le: case Triple::x86: diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -688,6 +688,7 @@ case Triple::x86: return {supportsX86, resolveX86}; case Triple::ppc: + case Triple::ppcle: return {supportsPPC32, resolvePPC32}; case Triple::arm: case Triple::armeb: diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test @@ -15,8 +15,17 @@ # RUN: llvm-objcopy -I binary -O elf32-bigmips %t.txt %t.mips.o # RUN: llvm-readobj --file-headers %t.mips.o | FileCheck %s --check-prefixes=CHECK,BE,MIPS,32 +# RUN: llvm-objcopy -I binary -O elf32-powerpc %t.txt %t.ppc32be.o +# RUN: llvm-readobj --file-headers %t.ppc32be.o | FileCheck %s --check-prefixes=CHECK,BE,PPC32,PPC32BE,32 + +# RUN: llvm-objcopy -I binary -O elf32-powerpcle %t.txt %t.ppc32le.o +# RUN: llvm-readobj --file-headers %t.ppc32le.o | FileCheck %s --check-prefixes=CHECK,LE,PPC32,PPC32LE,32 + +# RUN: llvm-objcopy -I binary -O elf64-powerpc %t.txt %t.ppc64be.o +# RUN: llvm-readobj --file-headers %t.ppc64be.o | FileCheck %s --check-prefixes=CHECK,BE,PPC64,PPC64BE,64 + # RUN: llvm-objcopy -I binary -O elf64-powerpcle %t.txt %t.ppc64le.o -# RUN: llvm-readobj --file-headers %t.ppc64le.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64,64 +# RUN: llvm-readobj --file-headers %t.ppc64le.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64,PPC64LE,64 # RUN: llvm-objcopy -I binary -O elf32-littleriscv %t.txt %t.rv32.o # RUN: llvm-readobj --file-headers %t.rv32.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32 @@ -43,8 +52,8 @@ # MIPS-SAME: mips{{$}} # RISCV32-SAME: riscv{{$}} # RISCV64-SAME: riscv{{$}} -# PPC-SAME: powerpc{{$}} -# PPC64le-SAME: powerpc{{$}} +# PPCBE-SAME: powerpc{{$}} +# PPCLE-SAME: powerpcle{{$}} # SPARC-SAME: sparc # SPARCEL-SAME: sparc # X86-64-SAME: x86-64 @@ -54,8 +63,10 @@ # HEXAGON-NEXT: Arch: hexagon # I386-NEXT: Arch: i386 # MIPS-NEXT: Arch: mips{{$}} -# PPC-NEXT: Arch: powerpc{{$}} -# PPC64-NEXT: Arch: powerpc64le +# PPC32BE-NEXT: Arch: powerpc{{$}} +# PPC32LE-NEXT: Arch: powerpcle{{$}} +# PPC64BE-NEXT: Arch: powerpc64{{$}} +# PPC64LE-NEXT: Arch: powerpc64le{{$}} # RISCV32-NEXT: Arch: riscv32 # RISCV64-NEXT: Arch: riscv64 # SPARC-NEXT: Arch: sparc{{$}} @@ -87,7 +98,7 @@ # HEXAGON-NEXT: Machine: EM_HEXAGON (0xA4) # I386-NEXT: Machine: EM_386 (0x3) # MIPS-NEXT: Machine: EM_MIPS (0x8) -# PPC-NEXT: Machine: EM_PPC (0x14) +# PPC32-NEXT: Machine: EM_PPC (0x14) # PPC64-NEXT: Machine: EM_PPC64 (0x15) # RISCV32-NEXT: Machine: EM_RISCV (0xF3) # RISCV64-NEXT: Machine: EM_RISCV (0xF3) diff --git a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test --- a/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test +++ b/llvm/test/tools/llvm-objcopy/ELF/cross-arch-headers.test @@ -34,25 +34,25 @@ # RUN: llvm-readobj --file-headers %t.elf64_littleaarch64.dwo | FileCheck %s --check-prefixes=CHECK,LE,AARCH,64,SYSV # RUN: llvm-objcopy %t.o -O elf32-powerpc %t.elf32_powerpc.o --split-dwo=%t.elf32_powerpc.dwo -# RUN: llvm-readobj --file-headers %t.elf32_powerpc.o | FileCheck %s --check-prefixes=CHECK,BE,PPC,32,SYSV -# RUN: llvm-readobj --file-headers %t.elf32_powerpc.dwo | FileCheck %s --check-prefixes=CHECK,BE,PPC,32,SYSV +# RUN: llvm-readobj --file-headers %t.elf32_powerpc.o | FileCheck %s --check-prefixes=CHECK,BE,PPC32,PPCBE,PPC32BE,32,SYSV +# RUN: llvm-readobj --file-headers %t.elf32_powerpc.dwo | FileCheck %s --check-prefixes=CHECK,BE,PPC32,PPCBE,PPC32BE,32,SYSV # RUN: llvm-objcopy %t.o -O elf64-powerpc %t.elf64_powerpc.o --split-dwo=%t.elf64_powerpc.dwo -# RUN: llvm-readobj --file-headers %t.elf64_powerpc.o | FileCheck %s --check-prefixes=CHECK,BE,PPC64BE,64,SYSV -# RUN: llvm-readobj --file-headers %t.elf64_powerpc.dwo | FileCheck %s --check-prefixes=CHECK,BE,PPC64BE,64,SYSV +# RUN: llvm-readobj --file-headers %t.elf64_powerpc.o | FileCheck %s --check-prefixes=CHECK,BE,PPC64,PPCBE,PPC64BE,64,SYSV +# RUN: llvm-readobj --file-headers %t.elf64_powerpc.dwo | FileCheck %s --check-prefixes=CHECK,BE,PPC64,PPCBE,PPC64BE,64,SYSV # RUN: llvm-objcopy %t.o -O elf32-powerpcle %t.elf32_ppcle.o --split-dwo=%t.elf32_ppcle.dwo -# RUN: llvm-readobj --file-headers %t.elf32_ppcle.o | FileCheck %s --check-prefixes=CHECK,LE,PPC,32,SYSV -# RUN: llvm-readobj --file-headers %t.elf32_ppcle.dwo | FileCheck %s --check-prefixes=CHECK,LE,PPC,32,SYSV +# RUN: llvm-readobj --file-headers %t.elf32_ppcle.o | FileCheck %s --check-prefixes=CHECK,LE,PPC32,PPCLE,PPC32LE,32,SYSV +# RUN: llvm-readobj --file-headers %t.elf32_ppcle.dwo | FileCheck %s --check-prefixes=CHECK,LE,PPC32,PPCLE,PPC32LE,32,SYSV + +# RUN: llvm-objcopy %t.o -O elf64-powerpcle %t.elf64_ppcle.o --split-dwo=%t.elf64_ppcle.dwo +# RUN: llvm-readobj --file-headers %t.elf64_ppcle.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64,PPCLE,PPC64LE,64,SYSV +# RUN: llvm-readobj --file-headers %t.elf64_ppcle.dwo | FileCheck %s --check-prefixes=CHECK,LE,PPC64,PPCLE,PPC64LE,64,SYSV # RUN: llvm-objcopy %t.o -O elf32-x86-64 %t.elf32_x86_64.o --split-dwo=%t.elf32_x86_64.dwo # RUN: llvm-readobj --file-headers %t.elf32_x86_64.o | FileCheck %s --check-prefixes=CHECK,LE,X86-64,32,SYSV # RUN: llvm-readobj --file-headers %t.elf32_x86_64.dwo | FileCheck %s --check-prefixes=CHECK,LE,X86-64,32,SYSV -# RUN: llvm-objcopy %t.o -O elf64-powerpcle %t.elf64_ppcle.o --split-dwo=%t.elf64_ppcle.dwo -# RUN: llvm-readobj --file-headers %t.elf64_ppcle.o | FileCheck %s --check-prefixes=CHECK,LE,PPC64LE,64,SYSV -# RUN: llvm-readobj --file-headers %t.elf64_ppcle.dwo | FileCheck %s --check-prefixes=CHECK,LE,PPC64LE,64,SYSV - # RUN: llvm-objcopy %t.o -O elf32-littleriscv %t.elf32_littleriscv.o --split-dwo=%t.elf32_littleriscv.dwo # RUN: llvm-readobj --file-headers %t.elf32_littleriscv.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32,SYSV # RUN: llvm-readobj --file-headers %t.elf32_littleriscv.dwo | FileCheck %s --check-prefixes=CHECK,LE,RISCV32,32,SYSV @@ -145,9 +145,8 @@ # ARM-SAME: littlearm # HEXAGON-SAME: hexagon # MIPS-SAME: mips -# PPC-SAME: powerpc{{$}} -# PPC64BE-SAME: powerpc{{$}} -# PPC64LE-SAME: powerpcle{{$}} +# PPCBE-SAME: powerpc{{$}} +# PPCLE-SAME: powerpcle{{$}} # RISCV32-SAME: riscv{{$}} # RISCV64-SAME: riscv{{$}} # SPARC-SAME: sparc @@ -163,9 +162,10 @@ # MIPSLE-NEXT: Arch: mipsel{{$}} # MIPS64BE-NEXT: Arch: mips64{{$}} # MIPS64LE-NEXT: Arch: mips64el{{$}} -# PPC-NEXT: Arch: powerpc{{$}} +# PPC32BE-NEXT: Arch: powerpc{{$}} +# PPC32LE-NEXT: Arch: powerpcle{{$}} # PPC64BE-NEXT: Arch: powerpc64{{$}} -# PPC64LE-NEXT: Arch: powerpc64le +# PPC64LE-NEXT: Arch: powerpc64le{{$}} # RISCV32-NEXT: Arch: riscv32 # RISCV64-NEXT: Arch: riscv64 # SPARC-NEXT: Arch: sparc{{$}} @@ -191,7 +191,7 @@ # I386: Machine: EM_386 (0x3) # IAMCU: Machine: EM_IAMCU (0x6) # MIPS: Machine: EM_MIPS (0x8) -# PPC: Machine: EM_PPC (0x14) +# PPC32: Machine: EM_PPC (0x14) # PPC64: Machine: EM_PPC64 (0x15) # RISCV32: Machine: EM_RISCV (0xF3) # RISCV64: Machine: EM_RISCV (0xF3) diff --git a/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s b/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s --- a/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s +++ b/llvm/test/tools/llvm-objdump/ELF/PowerPC/branch-offset.s @@ -1,11 +1,14 @@ -# RUN: llvm-mc -triple=powerpc -filetype=obj %s -o %t.32.o -# RUN: llvm-objdump -d --no-show-raw-insn %t.32.o | FileCheck --check-prefixes=ELF32,CHECK %s +# RUN: llvm-mc -triple=powerpc -filetype=obj %s -o %t.32be.o +# RUN: llvm-objdump -d --no-show-raw-insn %t.32be.o | FileCheck --check-prefixes=ELF32,CHECK %s -# RUN: llvm-mc -triple=powerpc64le -filetype=obj %s -o %t.64.o -# RUN: llvm-objdump -d --no-show-raw-insn %t.64.o | FileCheck --check-prefixes=ELF64,CHECK %s +# RUN: llvm-mc -triple=powerpcle -filetype=obj %s -o %t.32le.o +# RUN: llvm-objdump -d --no-show-raw-insn %t.32le.o | FileCheck --check-prefixes=ELF32,CHECK %s -# RUN: llvm-mc -triple=powerpc64 -filetype=obj %s -o %t.64.o -# RUN: llvm-objdump -d --no-show-raw-insn %t.64.o | FileCheck --check-prefixes=ELF64,CHECK %s +# RUN: llvm-mc -triple=powerpc64 -filetype=obj %s -o %t.64be.o +# RUN: llvm-objdump -d --no-show-raw-insn %t.64be.o | FileCheck --check-prefixes=ELF64,CHECK %s + +# RUN: llvm-mc -triple=powerpc64le -filetype=obj %s -o %t.64le.o +# RUN: llvm-objdump -d --no-show-raw-insn %t.64le.o | FileCheck --check-prefixes=ELF64,CHECK %s # CHECK-LABEL: : # ELF32-NEXT: bl 0xfffffffc