diff options
author | Koakuma <koachan@protonmail.com> | 2023-03-11 17:39:25 -0500 |
---|---|---|
committer | Brad Smith <brad@comstyle.com> | 2023-03-11 17:42:09 -0500 |
commit | 24e300190a57c97ce88b42bfd6afc84a79fd15e5 (patch) | |
tree | 287f62cfe98c3d29622f4fb32ff6e5d32ae4e71b /llvm/lib/Target/Sparc/SparcTargetMachine.cpp | |
parent | ef6f23535d4e2b437913b48bdbdef00f000594c2 (diff) | |
download | llvm-24e300190a57c97ce88b42bfd6afc84a79fd15e5.zip llvm-24e300190a57c97ce88b42bfd6afc84a79fd15e5.tar.gz llvm-24e300190a57c97ce88b42bfd6afc84a79fd15e5.tar.bz2 |
[SPARC] Implement hooks for conditional branch relaxation
Integrate the BranchRelaxation pass to help with relaxing out-of-range
conditional branches.
This is mostly of concern for SPARCv9, which uses conditional branches with
much smaller range than its v8 counterparts.
(Some large autogenerated code, such as the ones generated by TableGen, already
hits this limitation when building in Release)
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D142458
Diffstat (limited to 'llvm/lib/Target/Sparc/SparcTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/Sparc/SparcTargetMachine.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp index 082bb44..577dc13 100644 --- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp @@ -31,6 +31,10 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTarget() { initializeSparcDAGToDAGISelPass(PR); } +static cl::opt<bool> + BranchRelaxation("sparc-enable-branch-relax", cl::Hidden, cl::init(true), + cl::desc("Relax out of range conditional branches")); + static std::string computeDataLayout(const Triple &T, bool is64Bit) { // Sparc is typically big endian, but some are little. std::string Ret = T.getArch() == Triple::sparcel ? "e" : "E"; @@ -181,6 +185,9 @@ bool SparcPassConfig::addInstSelector() { } void SparcPassConfig::addPreEmitPass(){ + if (BranchRelaxation) + addPass(&BranchRelaxationPassID); + addPass(createSparcDelaySlotFillerPass()); if (this->getSparcTargetMachine().getSubtargetImpl()->insertNOPLoad()) |