-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISC-V] Add support for MIPS P8700 CPU #117865
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a3ed355
[RISCV] Add MIPS p8700 scheduler and target cpu
djtodoro 9b0b29c
[RISCV] Add MIPS extensions
djtodoro 4aa168a
[clang][RISCV] Set default CPU for `mti` vendor
djtodoro c503eca
[clang] Add driver support for riscv64-mti toolchains
djtodoro d35403f
[RISCV] Enable SeparateConstOffsetFromGEPPass for RISC-V
djtodoro 4f39531
[RISCV] Add RemoveBackToBackBranches Pass
djtodoro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,9 +252,17 @@ static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) { | |
case llvm::Triple::ppc64le: | ||
return "elf64lppc"; | ||
case llvm::Triple::riscv32: | ||
return "elf32lriscv"; | ||
case llvm::Triple::riscv64: | ||
return "elf64lriscv"; | ||
case llvm::Triple::riscv64: { | ||
bool IsBigEndian = false; | ||
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, | ||
options::OPT_mbig_endian)) | ||
IsBigEndian = A->getOption().matches(options::OPT_mbig_endian); | ||
|
||
if (T.getArch() == llvm::Triple::riscv32) | ||
return IsBigEndian ? "elf32briscv" : "elf32lriscv"; | ||
else | ||
return IsBigEndian ? "elf64briscv" : "elf64lriscv"; | ||
} | ||
case llvm::Triple::sparc: | ||
case llvm::Triple::sparcel: | ||
return "elf32_sparc"; | ||
|
@@ -402,6 +410,14 @@ 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) { | ||
bool IsBigEndian = false; | ||
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, | ||
options::OPT_mbig_endian)) | ||
IsBigEndian = A->getOption().matches(options::OPT_mbig_endian); | ||
CmdArgs.push_back(IsBigEndian ? "-EB" : "-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 +781,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 +791,14 @@ 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) { | ||
bool IsBigEndian = false; | ||
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, | ||
options::OPT_mbig_endian)) | ||
IsBigEndian = A->getOption().matches(options::OPT_mbig_endian); | ||
CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL"); | ||
} | ||
break; | ||
} | ||
case llvm::Triple::sparc: | ||
|
@@ -1873,9 +1898,18 @@ static void findRISCVBareMetalMultilibs(const Driver &D, | |
.flag(Twine("-march=", Element.march).str()) | ||
.flag(Twine("-mabi=", Element.mabi).str())); | ||
} | ||
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)); | ||
} | ||
MultilibSet RISCVMultilibs = | ||
MultilibSetBuilder() | ||
.Either(Ms) | ||
.Either(Endian) | ||
.Either(ArrayRef<MultilibBuilder>(Ms)) | ||
.makeMultilibSet() | ||
.FilterOut(NonExistent) | ||
.setFilePathsCallback([](const Multilib &M) { | ||
|
@@ -1899,6 +1933,19 @@ static void findRISCVBareMetalMultilibs(const Driver &D, | |
} | ||
} | ||
|
||
bool IsBigEndian = false; | ||
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, | ||
options::OPT_mbig_endian)) | ||
IsBigEndian = A->getOption().matches(options::OPT_mbig_endian); | ||
|
||
if (IsBigEndian) { | ||
D.Diag(diag::err_drv_unsupported_opt_for_target) | ||
<< "-EB" << TargetTriple.str(); | ||
} | ||
|
||
addMultilibFlag(IsBigEndian, "-EB", Flags); | ||
addMultilibFlag(!IsBigEndian, "-EL", Flags); | ||
|
||
if (selectRISCVMultilib(D, RISCVMultilibs, MArch, Flags, | ||
Result.SelectedMultilibs)) | ||
Result.Multilibs = RISCVMultilibs; | ||
|
@@ -1923,15 +1970,34 @@ 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)); | ||
} | ||
|
||
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 IsBigEndian = false; | ||
if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, | ||
options::OPT_mbig_endian)) | ||
IsBigEndian = A->getOption().matches(options::OPT_mbig_endian); | ||
|
||
if (IsBigEndian) { | ||
D.Diag(diag::err_drv_unsupported_opt_for_target) | ||
<< "-EB" << TargetTriple.str(); | ||
} | ||
|
||
addMultilibFlag(!IsRV64, "-m32", Flags); | ||
addMultilibFlag(IsRV64, "-m64", Flags); | ||
|
@@ -1941,6 +2007,8 @@ 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(IsBigEndian, "-EB", Flags); | ||
addMultilibFlag(!IsBigEndian, "-EL", Flags); | ||
|
||
if (RISCVMultilibs.select(D, Flags, Result.SelectedMultilibs)) | ||
Result.Multilibs = RISCVMultilibs; | ||
|
@@ -2565,8 +2633,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", | ||
|
@@ -3137,6 +3205,45 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const { | |
case llvm::Triple::nvptx64: | ||
case llvm::Triple::xcore: | ||
return false; | ||
case llvm::Triple::aarch64: | ||
case llvm::Triple::aarch64_be: | ||
case llvm::Triple::amdgcn: | ||
case llvm::Triple::arm: | ||
case llvm::Triple::armeb: | ||
case llvm::Triple::avr: | ||
case llvm::Triple::bpfel: | ||
case llvm::Triple::bpfeb: | ||
case llvm::Triple::csky: | ||
case llvm::Triple::hexagon: | ||
case llvm::Triple::lanai: | ||
case llvm::Triple::loongarch32: | ||
case llvm::Triple::loongarch64: | ||
case llvm::Triple::m68k: | ||
case llvm::Triple::mips: | ||
case llvm::Triple::mipsel: | ||
case llvm::Triple::mips64: | ||
case llvm::Triple::mips64el: | ||
case llvm::Triple::msp430: | ||
case llvm::Triple::ppc: | ||
case llvm::Triple::ppcle: | ||
case llvm::Triple::ppc64: | ||
case llvm::Triple::ppc64le: | ||
case llvm::Triple::r600: | ||
case llvm::Triple::sparc: | ||
case llvm::Triple::sparcel: | ||
case llvm::Triple::sparcv9: | ||
case llvm::Triple::systemz: | ||
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. Remove this whole chunk. |
||
case llvm::Triple::thumb: | ||
case llvm::Triple::thumbeb: | ||
case llvm::Triple::ve: | ||
case llvm::Triple::x86: | ||
case llvm::Triple::x86_64: | ||
return true; | ||
case llvm::Triple::riscv32: | ||
case llvm::Triple::riscv64: | ||
if (getTriple().getVendor() != llvm::Triple::MipsTechnologies) | ||
return true; | ||
return false; | ||
default: | ||
return true; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Best as I can tell, this would make RISC-V the only architecture for which there aren't any
llvm::Triple::ArchType
members distinguishing little-endian vs big-endian? That seems like a strange precedent to set.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.
There had been a patch a long time ago to add riscv32be and riscv64be. Not sure if it was in github or if it got left behind in phabricator.
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.
I will drop this part for now, since it is dummy/unsed for now. I am planning to create/add support for
BE
, once we are done with thesep8700
patches.This was a patch on Phabricator: https://reviews.llvm.org/D128612