diff options
author | dim <dim@FreeBSD.org> | 2014-02-20 21:59:15 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-02-20 21:59:15 +0000 |
commit | 71b05635f0af9304195bb237ed6f5777d29020b2 (patch) | |
tree | 50d5ccda787645225336cebf0ac01094ca35224f /contrib/llvm | |
parent | 882a15c9c203706f0c18c3358b30a7219c039b85 (diff) | |
download | FreeBSD-src-71b05635f0af9304195bb237ed6f5777d29020b2.zip FreeBSD-src-71b05635f0af9304195bb237ed6f5777d29020b2.tar.gz |
Import a whole bunch of clang trunk commits to enable self-hosting clang
3.4 on Sparc64 (commit descriptions left out for brevity):
r198311 r198312 r198911 r198912 r198918 r198923 r199012 r199034 r199037
r199188 r199399 r200452
Submitted by: rdivacky
Diffstat (limited to 'contrib/llvm')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/Targets.cpp | 7 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp | 5 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp | 28 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/Tools.cpp | 45 |
4 files changed, 79 insertions, 6 deletions
diff --git a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp index bccd0d7..70b7ac5 100644 --- a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp @@ -4529,6 +4529,13 @@ public: UIntMaxType = UnsignedLong; } Int64Type = IntMaxType; + + // The SPARCv8 System V ABI has long double 128-bits in size, but 64-bit + // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned. + LongDoubleWidth = 128; + LongDoubleAlign = 128; + LongDoubleFormat = &llvm::APFloat::IEEEquad; + MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; } virtual void getTargetDefines(const LangOptions &Opts, diff --git a/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp b/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp index 76acf87..578cea6 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp @@ -5349,6 +5349,11 @@ SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit) const { if (!isAggregateTypeForABI(Ty)) return ABIArgInfo::getDirect(); + // If a C++ object has either a non-trivial copy constructor or a non-trivial + // destructor, it is passed with an explicit indirect pointer / sret pointer. + if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) + return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory); + // This is a small aggregate type that should be passed in registers. // Build a coercion type from the LLVM struct type. llvm::StructType *StrTy = dyn_cast<llvm::StructType>(CGT.ConvertType(Ty)); diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp index 8a47e76..f5dc3dfb 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp @@ -1164,6 +1164,13 @@ void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const { "powerpc64le-suse-linux", "ppc64le-redhat-linux" }; + static const char *const SPARCv8LibDirs[] = { "/lib32", "/lib" }; + static const char *const SPARCv8Triples[] = { "sparc-linux-gnu", + "sparcv8-linux-gnu" }; + static const char *const SPARCv9LibDirs[] = { "/lib64", "/lib" }; + static const char *const SPARCv9Triples[] = { "sparc64-linux-gnu", + "sparcv9-linux-gnu" }; + static const char *const SystemZLibDirs[] = { "/lib64", "/lib" }; static const char *const SystemZTriples[] = { "s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu", @@ -1283,6 +1290,26 @@ void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const { TripleAliases.append(PPC64LETriples, PPC64LETriples + llvm::array_lengthof(PPC64LETriples)); break; + case llvm::Triple::sparc: + LibDirs.append(SPARCv8LibDirs, + SPARCv8LibDirs + llvm::array_lengthof(SPARCv8LibDirs)); + TripleAliases.append(SPARCv8Triples, + SPARCv8Triples + llvm::array_lengthof(SPARCv8Triples)); + BiarchLibDirs.append(SPARCv9LibDirs, + SPARCv9LibDirs + llvm::array_lengthof(SPARCv9LibDirs)); + BiarchTripleAliases.append( + SPARCv9Triples, SPARCv9Triples + llvm::array_lengthof(SPARCv9Triples)); + break; + case llvm::Triple::sparcv9: + LibDirs.append(SPARCv9LibDirs, + SPARCv9LibDirs + llvm::array_lengthof(SPARCv9LibDirs)); + TripleAliases.append(SPARCv9Triples, + SPARCv9Triples + llvm::array_lengthof(SPARCv9Triples)); + BiarchLibDirs.append(SPARCv8LibDirs, + SPARCv8LibDirs + llvm::array_lengthof(SPARCv8LibDirs)); + BiarchTripleAliases.append( + SPARCv8Triples, SPARCv8Triples + llvm::array_lengthof(SPARCv8Triples)); + break; case llvm::Triple::systemz: LibDirs.append(SystemZLibDirs, SystemZLibDirs + llvm::array_lengthof(SystemZLibDirs)); @@ -1379,6 +1406,7 @@ static bool findTargetBiarchSuffix(std::string &Suffix, StringRef Path, Suffix = "/n32"; else if (TargetArch == llvm::Triple::x86_64 || TargetArch == llvm::Triple::ppc64 || + TargetArch == llvm::Triple::sparcv9 || TargetArch == llvm::Triple::systemz || TargetArch == llvm::Triple::mips64 || TargetArch == llvm::Triple::mips64el) diff --git a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp index 3529fc7..fe62a03 100644 --- a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp @@ -5785,6 +5785,19 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, default: CmdArgs.push_back("-matpcs"); } + } else if (getToolChain().getArch() == llvm::Triple::sparc || + getToolChain().getArch() == llvm::Triple::sparcv9) { + Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC, + options::OPT_fpic, options::OPT_fno_pic, + options::OPT_fPIE, options::OPT_fno_PIE, + options::OPT_fpie, options::OPT_fno_pie); + if (LastPICArg && + (LastPICArg->getOption().matches(options::OPT_fPIC) || + LastPICArg->getOption().matches(options::OPT_fpic) || + LastPICArg->getOption().matches(options::OPT_fPIE) || + LastPICArg->getOption().matches(options::OPT_fpie))) { + CmdArgs.push_back("-KPIC"); + } } Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, @@ -6194,6 +6207,7 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, const ArgList &Args, const char *LinkingOutput) const { ArgStringList CmdArgs; + bool NeedsKPIC = false; // Add --32/--64 to make sure we get the format we want. // This is incomplete @@ -6213,6 +6227,14 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-a64"); CmdArgs.push_back("-mppc64le"); CmdArgs.push_back("-many"); + } else if (getToolChain().getArch() == llvm::Triple::sparc) { + CmdArgs.push_back("-32"); + CmdArgs.push_back("-Av8plusa"); + NeedsKPIC = true; + } else if (getToolChain().getArch() == llvm::Triple::sparcv9) { + CmdArgs.push_back("-64"); + CmdArgs.push_back("-Av9a"); + NeedsKPIC = true; } else if (getToolChain().getArch() == llvm::Triple::arm) { StringRef MArch = getToolChain().getArchName(); if (MArch == "armv7" || MArch == "armv7a" || MArch == "armv7-a") @@ -6272,6 +6294,15 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString("-mmsa")); } + NeedsKPIC = true; + } else if (getToolChain().getArch() == llvm::Triple::systemz) { + // Always pass an -march option, since our default of z10 is later + // than the GNU assembler's default. + StringRef CPUName = getSystemZTargetCPU(Args); + CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName)); + } + + if (NeedsKPIC) { Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC, options::OPT_fpic, options::OPT_fno_pic, options::OPT_fPIE, options::OPT_fno_PIE, @@ -6283,11 +6314,6 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, LastPICArg->getOption().matches(options::OPT_fpie))) { CmdArgs.push_back("-KPIC"); } - } else if (getToolChain().getArch() == llvm::Triple::systemz) { - // Always pass an -march option, since our default of z10 is later - // than the GNU assembler's default. - StringRef CPUName = getSystemZTargetCPU(Args); - CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName)); } Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, @@ -6357,7 +6383,8 @@ static StringRef getLinuxDynamicLinker(const ArgList &Args, const toolchains::Linux &ToolChain) { if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) return "/system/bin/linker"; - else if (ToolChain.getArch() == llvm::Triple::x86) + else if (ToolChain.getArch() == llvm::Triple::x86 || + ToolChain.getArch() == llvm::Triple::sparc) return "/lib/ld-linux.so.2"; else if (ToolChain.getArch() == llvm::Triple::aarch64) return "/lib/ld-linux-aarch64.so.1"; @@ -6382,6 +6409,8 @@ static StringRef getLinuxDynamicLinker(const ArgList &Args, ToolChain.getArch() == llvm::Triple::ppc64le || ToolChain.getArch() == llvm::Triple::systemz) return "/lib64/ld64.so.1"; + else if (ToolChain.getArch() == llvm::Triple::sparcv9) + return "/lib64/ld-linux.so.2"; else return "/lib64/ld-linux-x86-64.so.2"; } @@ -6444,6 +6473,10 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("elf32ppclinux"); else if (ToolChain.getArch() == llvm::Triple::ppc64) CmdArgs.push_back("elf64ppc"); + else if (ToolChain.getArch() == llvm::Triple::sparc) + CmdArgs.push_back("elf32_sparc"); + else if (ToolChain.getArch() == llvm::Triple::sparcv9) + CmdArgs.push_back("elf64_sparc"); else if (ToolChain.getArch() == llvm::Triple::mips) CmdArgs.push_back("elf32btsmip"); else if (ToolChain.getArch() == llvm::Triple::mipsel) |