-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Add clang driver changes to support MTI RISC-V #134065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
513b1ae
8c1ca6a
bf3b7d4
dbe6546
eb87612
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -402,6 +402,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, | |
| CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); | ||
| } | ||
|
|
||
| if (Triple.isRISCV() && Triple.getVendor() == llvm::Triple::MipsTechnologies) | ||
| CmdArgs.push_back("-EL"); | ||
|
|
||
| // Most Android ARM64 targets should enable the linker fix for erratum | ||
| // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. | ||
| if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily)) { | ||
|
|
@@ -765,7 +768,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C, | |
| } | ||
| case llvm::Triple::riscv32: | ||
| case llvm::Triple::riscv64: { | ||
| StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple()); | ||
| const llvm::Triple &Triple = getToolChain().getTriple(); | ||
| StringRef ABIName = riscv::getRISCVABI(Args, Triple); | ||
| CmdArgs.push_back("-mabi"); | ||
| CmdArgs.push_back(ABIName.data()); | ||
| std::string MArchName = | ||
|
|
@@ -774,6 +778,10 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C, | |
| CmdArgs.push_back(Args.MakeArgString(MArchName)); | ||
| if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true)) | ||
| Args.addOptOutFlag(CmdArgs, options::OPT_mrelax, options::OPT_mno_relax); | ||
|
|
||
| if (Triple.getVendor() == llvm::Triple::MipsTechnologies) | ||
| CmdArgs.push_back("-EL"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
|
|
||
| break; | ||
| } | ||
| case llvm::Triple::sparc: | ||
|
|
@@ -1824,9 +1832,19 @@ static void findRISCVBareMetalMultilibs(const Driver &D, | |
| .flag(Twine("-march=", Element.march).str()) | ||
| .flag(Twine("-mabi=", Element.mabi).str())); | ||
| } | ||
| SmallVector<MultilibBuilder, 2> Endian; | ||
| bool IsMIPS = TargetTriple.getVendor() == llvm::Triple::MipsTechnologies; | ||
| if (IsMIPS) { | ||
| Endian.push_back( | ||
| MultilibBuilder("/riscv").flag("-EL").flag("-EB", /*Disallow=*/true)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
| Endian.push_back( | ||
| MultilibBuilder("/riscveb").flag("-EB").flag("-EL", /*Disallow=*/true)); | ||
| } | ||
| MultilibSet RISCVMultilibs = | ||
| MultilibSetBuilder() | ||
| .Either(Ms) | ||
| .Either(Endian) | ||
| .Either(ArrayRef<MultilibBuilder>(Ms)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this got to do with MIPS? |
||
| .makeMultilibSet() | ||
| .FilterOut(NonExistent) | ||
| .setFilePathsCallback([](const Multilib &M) { | ||
|
|
@@ -1850,6 +1868,8 @@ static void findRISCVBareMetalMultilibs(const Driver &D, | |
| } | ||
| } | ||
|
|
||
| addMultilibFlag(IsMIPS, "-EL", Flags); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or all of the rest of these... there are a lot of changes here that I don't understand the need for |
||
|
|
||
| if (selectRISCVMultilib(D, RISCVMultilibs, MArch, Flags, | ||
| Result.SelectedMultilibs)) | ||
| Result.Multilibs = RISCVMultilibs; | ||
|
|
@@ -1874,15 +1894,26 @@ static void findRISCVMultilibs(const Driver &D, | |
| MultilibBuilder("lib64/lp64f").flag("-m64").flag("-mabi=lp64f"); | ||
| MultilibBuilder Lp64d = | ||
| MultilibBuilder("lib64/lp64d").flag("-m64").flag("-mabi=lp64d"); | ||
|
|
||
| SmallVector<MultilibBuilder, 2> Endian; | ||
| if (TargetTriple.getVendor() == llvm::Triple::MipsTechnologies) { | ||
| Endian.push_back( | ||
| MultilibBuilder("/riscv").flag("-EL").flag("-EB", /*Disallow=*/true)); | ||
| Endian.push_back( | ||
| MultilibBuilder("/riscveb").flag("-EB").flag("-EL", /*Disallow=*/true)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be part of a non-vendor specific patch that adds big endian multilib support?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, makes sense |
||
| } | ||
|
|
||
| MultilibSet RISCVMultilibs = | ||
| MultilibSetBuilder() | ||
| .Either(Endian) | ||
| .Either({Ilp32, Ilp32f, Ilp32d, Lp64, Lp64f, Lp64d}) | ||
| .makeMultilibSet() | ||
| .FilterOut(NonExistent); | ||
|
|
||
| Multilib::flags_list Flags; | ||
| bool IsRV64 = TargetTriple.getArch() == llvm::Triple::riscv64; | ||
| StringRef ABIName = tools::riscv::getRISCVABI(Args, TargetTriple); | ||
| bool IsMIPS = TargetTriple.getVendor() == llvm::Triple::MipsTechnologies; | ||
|
|
||
| addMultilibFlag(!IsRV64, "-m32", Flags); | ||
| addMultilibFlag(IsRV64, "-m64", Flags); | ||
|
|
@@ -1892,6 +1923,7 @@ static void findRISCVMultilibs(const Driver &D, | |
| addMultilibFlag(ABIName == "lp64", "-mabi=lp64", Flags); | ||
| addMultilibFlag(ABIName == "lp64f", "-mabi=lp64f", Flags); | ||
| addMultilibFlag(ABIName == "lp64d", "-mabi=lp64d", Flags); | ||
| addMultilibFlag(IsMIPS, "-EL", Flags); | ||
|
|
||
| if (RISCVMultilibs.select(D, Flags, Result.SelectedMultilibs)) | ||
| Result.Multilibs = RISCVMultilibs; | ||
|
|
@@ -2516,8 +2548,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( | |
| static const char *const RISCV32Triples[] = {"riscv32-unknown-linux-gnu", | ||
| "riscv32-unknown-elf"}; | ||
| static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; | ||
| static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", | ||
| "riscv64-unknown-elf"}; | ||
| static const char *const RISCV64Triples[] = { | ||
| "riscv64-unknown-linux-gnu", "riscv64-unknown-elf", "riscv64-mti-elf"}; | ||
|
|
||
| static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; | ||
| static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -173,6 +173,9 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA, | |||
| } | ||||
| CmdArgs.push_back("-X"); | ||||
|
|
||||
| if (ToolChain.getTriple().getVendor() == llvm::Triple::MipsTechnologies) | ||||
| CmdArgs.push_back("-EL"); | ||||
|
|
||||
| std::string Linker = getToolChain().GetLinkerPath(); | ||||
|
|
||||
| bool WantCRTs = | ||||
|
|
@@ -229,4 +232,5 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA, | |||
| JA, *this, ResponseFileSupport::AtFileCurCP(), Args.MakeArgString(Linker), | ||||
| CmdArgs, Inputs, Output)); | ||||
| } | ||||
|
|
||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| // RISCV tools end. | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one confuses me. Why do you need it when non-MIPS doesn't?