diff options
author | Alex Bradbury <asb@lowrisc.org> | 2018-01-11 13:36:56 +0000 |
---|---|---|
committer | Alex Bradbury <asb@lowrisc.org> | 2018-01-11 13:36:56 +0000 |
commit | 71f45455e1bab13226eddfae5ee93e82aaf4b975 (patch) | |
tree | d5c410b904cae491f1adf9869cf9de4e8fdd96c7 /clang/lib/Driver/ToolChains/Linux.cpp | |
parent | 9b395a12edf98f6e0944f9a037862a3c022b3da3 (diff) | |
download | bcm5719-llvm-71f45455e1bab13226eddfae5ee93e82aaf4b975.tar.gz bcm5719-llvm-71f45455e1bab13226eddfae5ee93e82aaf4b975.zip |
[RISCV] Add the RISCV target and compiler driver
As RV64 codegen has not yet been upstreamed into LLVM, we focus on RV32 driver
support (RV64 to follow).
Differential Revision: https://reviews.llvm.org/D39963
llvm-svn: 322276
Diffstat (limited to 'clang/lib/Driver/ToolChains/Linux.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChains/Linux.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 1301cdf114a..9ce2407d991 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -11,6 +11,7 @@ #include "Arch/ARM.h" #include "Arch/Mips.h" #include "Arch/PPC.h" +#include "Arch/RISCV.h" #include "CommonArgs.h" #include "clang/Basic/VirtualFileSystem.h" #include "clang/Config/config.h" @@ -176,6 +177,9 @@ static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) { Triple.getEnvironment() == llvm::Triple::GNUX32) return "libx32"; + if (Triple.getArch() == llvm::Triple::riscv32) + return "lib32"; + return Triple.isArch32Bit() ? "lib" : "lib64"; } @@ -226,6 +230,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) const bool IsAndroid = Triple.isAndroid(); const bool IsMips = tools::isMipsArch(Arch); const bool IsHexagon = Arch == llvm::Triple::hexagon; + const bool IsRISCV = + Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64; if (IsMips && !SysRoot.empty()) ExtraOpts.push_back("--sysroot=" + SysRoot); @@ -333,6 +339,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths); addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); + if (IsRISCV) { + StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); + addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths); + addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths); + } // Try walking via the GCC triple path in case of biarch or multiarch GCC // installations with strange symlinks. @@ -511,6 +522,18 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const { Loader = (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2"; break; + case llvm::Triple::riscv32: { + StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); + LibDir = "lib"; + Loader = ("ld-linux-riscv32-" + ABIName + ".so.1").str(); + break; + } + case llvm::Triple::riscv64: { + StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); + LibDir = "lib"; + Loader = ("ld-linux-riscv64-" + ABIName + ".so.1").str(); + break; + } case llvm::Triple::sparc: case llvm::Triple::sparcel: LibDir = "lib"; |