2016-11-02 01:27:54 +08:00
|
|
|
//===-- RISCVTargetMachine.cpp - Define TargetMachine for RISCV -----------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-11-02 01:27:54 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Implements the info about RISCV target spec.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "RISCVTargetMachine.h"
|
[RISCV] Add RISCV-specific TargetTransformInfo
Summary:
LLVM Allows Targets to provide information that guides optimisations
made to LLVM IR. This is done with callbacks on a TargetTransformInfo object.
This patch adds a TargetTransformInfo class for RISC-V. This will allow us to
implement RISC-V specific callbacks as they become necessary.
This commit also adds the getIntImmCost callbacks, and tests them with a simple
constant hoisting test. Our immediate costs are on the conservative side, for
the moment, but we prevent hoisting in most circumstances anyway.
Previous review was on D63007
Reviewers: asb, luismarques
Reviewed By: asb
Subscribers: ributzka, MaskRay, llvm-commits, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya, mgorny
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63433
llvm-svn: 364046
2019-06-21 21:36:09 +08:00
|
|
|
#include "RISCV.h"
|
[RISCV] Use init_array instead of ctors for RISCV target, by default
Summary:
LLVM defaults to the newer .init_array/.fini_array scheme for static
constructors rather than the less desirable .ctors/.dtors (the UseCtors
flag defaults to false). This wasn't being respected in the RISC-V
backend because it fails to call TargetLoweringObjectFileELF::InitializeELF with the the appropriate
flag for UseInitArray.
This patch fixes this by implementing RISCVELFTargetObjectFile and overriding its Initialize method to call
InitializeELF(TM.Options.UseInitArray).
Reviewers: asb, apazos
Reviewed By: asb
Subscribers: mgorny, rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD, kito-cheng, shiva0217, llvm-commits
Differential Revision: https://reviews.llvm.org/D44750
llvm-svn: 328433
2018-03-25 02:37:19 +08:00
|
|
|
#include "RISCVTargetObjectFile.h"
|
[RISCV] Add RISCV-specific TargetTransformInfo
Summary:
LLVM Allows Targets to provide information that guides optimisations
made to LLVM IR. This is done with callbacks on a TargetTransformInfo object.
This patch adds a TargetTransformInfo class for RISC-V. This will allow us to
implement RISC-V specific callbacks as they become necessary.
This commit also adds the getIntImmCost callbacks, and tests them with a simple
constant hoisting test. Our immediate costs are on the conservative side, for
the moment, but we prevent hoisting in most circumstances anyway.
Previous review was on D63007
Reviewers: asb, luismarques
Reviewed By: asb
Subscribers: ributzka, MaskRay, llvm-commits, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya, mgorny
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63433
llvm-svn: 364046
2019-06-21 21:36:09 +08:00
|
|
|
#include "RISCVTargetTransformInfo.h"
|
2019-05-15 08:24:15 +08:00
|
|
|
#include "TargetInfo/RISCVTargetInfo.h"
|
2020-01-15 22:41:08 +08:00
|
|
|
#include "Utils/RISCVBaseInfo.h"
|
2016-11-02 01:27:54 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
[RISCV] Add RISCV-specific TargetTransformInfo
Summary:
LLVM Allows Targets to provide information that guides optimisations
made to LLVM IR. This is done with callbacks on a TargetTransformInfo object.
This patch adds a TargetTransformInfo class for RISC-V. This will allow us to
implement RISC-V specific callbacks as they become necessary.
This commit also adds the getIntImmCost callbacks, and tests them with a simple
constant hoisting test. Our immediate costs are on the conservative side, for
the moment, but we prevent hoisting in most circumstances anyway.
Previous review was on D63007
Reviewers: asb, luismarques
Reviewed By: asb
Subscribers: ributzka, MaskRay, llvm-commits, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya, mgorny
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63433
llvm-svn: 364046
2019-06-21 21:36:09 +08:00
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
[RISCV GlobalISel] Adding initial GlobalISel infrastructure
Summary:
Add an initial GlobalISel skeleton for RISCV. It can only run ir translator for `ret void`.
Patch by Andrew Wei
Reviewers: asb, sabuasal, apazos, lenary, simoncook, lewis-revill, edward-jones, rogfer01, xiangzhai, rovka, Petar.Avramovic, mgorny, dsanders
Reviewed By: dsanders
Subscribers: pzheng, s.egerton, dsanders, hiraditya, rbar, johnrusso, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, psnobl, benna, Jim, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65219
llvm-svn: 369467
2019-08-21 06:53:24 +08:00
|
|
|
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2016-11-02 01:27:54 +08:00
|
|
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
Sink all InitializePasses.h includes
This file lists every pass in LLVM, and is included by Pass.h, which is
very popular. Every time we add, remove, or rename a pass in LLVM, it
caused lots of recompilation.
I found this fact by looking at this table, which is sorted by the
number of times a file was changed over the last 100,000 git commits
multiplied by the number of object files that depend on it in the
current checkout:
recompiles touches affected_files header
342380 95 3604 llvm/include/llvm/ADT/STLExtras.h
314730 234 1345 llvm/include/llvm/InitializePasses.h
307036 118 2602 llvm/include/llvm/ADT/APInt.h
213049 59 3611 llvm/include/llvm/Support/MathExtras.h
170422 47 3626 llvm/include/llvm/Support/Compiler.h
162225 45 3605 llvm/include/llvm/ADT/Optional.h
158319 63 2513 llvm/include/llvm/ADT/Triple.h
140322 39 3598 llvm/include/llvm/ADT/StringRef.h
137647 59 2333 llvm/include/llvm/Support/Error.h
131619 73 1803 llvm/include/llvm/Support/FileSystem.h
Before this change, touching InitializePasses.h would cause 1345 files
to recompile. After this change, touching it only causes 550 compiles in
an incremental rebuild.
Reviewers: bkramer, asbirlea, bollu, jdoerfert
Differential Revision: https://reviews.llvm.org/D70211
2019-11-14 05:15:01 +08:00
|
|
|
#include "llvm/InitializePasses.h"
|
2016-11-02 01:27:54 +08:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
CMake: Make most target symbols hidden by default
Summary:
For builds with LLVM_BUILD_LLVM_DYLIB=ON and BUILD_SHARED_LIBS=OFF
this change makes all symbols in the target specific libraries hidden
by default.
A new macro called LLVM_EXTERNAL_VISIBILITY has been added to mark symbols in these
libraries public, which is mainly needed for the definitions of the
LLVMInitialize* functions.
This patch reduces the number of public symbols in libLLVM.so by about
25%. This should improve load times for the dynamic library and also
make abi checker tools, like abidiff require less memory when analyzing
libLLVM.so
One side-effect of this change is that for builds with
LLVM_BUILD_LLVM_DYLIB=ON and LLVM_LINK_LLVM_DYLIB=ON some unittests that
access symbols that are no longer public will need to be statically linked.
Before and after public symbol counts (using gcc 8.2.1, ld.bfd 2.31.1):
nm before/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l
36221
nm after/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l
26278
Reviewers: chandlerc, beanz, mgorny, rnk, hans
Reviewed By: rnk, hans
Subscribers: merge_guards_bot, luismarques, smeenai, ldionne, lenary, s.egerton, pzheng, sameer.abuasal, MaskRay, wuzish, echristo, Jim, hiraditya, michaelplatings, chapuni, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, mgrang, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, kristina, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D54439
2020-01-15 11:15:07 +08:00
|
|
|
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() {
|
2016-11-02 01:27:54 +08:00
|
|
|
RegisterTargetMachine<RISCVTargetMachine> X(getTheRISCV32Target());
|
|
|
|
RegisterTargetMachine<RISCVTargetMachine> Y(getTheRISCV64Target());
|
2018-09-19 18:54:22 +08:00
|
|
|
auto PR = PassRegistry::getPassRegistry();
|
[RISCV GlobalISel] Adding initial GlobalISel infrastructure
Summary:
Add an initial GlobalISel skeleton for RISCV. It can only run ir translator for `ret void`.
Patch by Andrew Wei
Reviewers: asb, sabuasal, apazos, lenary, simoncook, lewis-revill, edward-jones, rogfer01, xiangzhai, rovka, Petar.Avramovic, mgorny, dsanders
Reviewed By: dsanders
Subscribers: pzheng, s.egerton, dsanders, hiraditya, rbar, johnrusso, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, psnobl, benna, Jim, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65219
llvm-svn: 369467
2019-08-21 06:53:24 +08:00
|
|
|
initializeGlobalISel(*PR);
|
2018-09-19 18:54:22 +08:00
|
|
|
initializeRISCVExpandPseudoPass(*PR);
|
2016-11-02 01:27:54 +08:00
|
|
|
}
|
|
|
|
|
2019-02-19 22:42:00 +08:00
|
|
|
static StringRef computeDataLayout(const Triple &TT) {
|
2016-11-02 01:27:54 +08:00
|
|
|
if (TT.isArch64Bit()) {
|
2017-11-17 04:30:49 +08:00
|
|
|
return "e-m:e-p:64:64-i64:64-i128:128-n64-S128";
|
2016-11-02 01:27:54 +08:00
|
|
|
} else {
|
|
|
|
assert(TT.isArch32Bit() && "only RV32 and RV64 are currently supported");
|
2017-02-14 13:20:20 +08:00
|
|
|
return "e-m:e-p:32:32-i64:64-n32-S128";
|
2016-11-02 01:27:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
|
|
|
|
Optional<Reloc::Model> RM) {
|
|
|
|
if (!RM.hasValue())
|
|
|
|
return Reloc::Static;
|
|
|
|
return *RM;
|
|
|
|
}
|
|
|
|
|
|
|
|
RISCVTargetMachine::RISCVTargetMachine(const Target &T, const Triple &TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
|
|
|
Optional<Reloc::Model> RM,
|
2017-08-03 10:16:21 +08:00
|
|
|
Optional<CodeModel::Model> CM,
|
|
|
|
CodeGenOpt::Level OL, bool JIT)
|
2017-10-13 06:57:28 +08:00
|
|
|
: LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
|
|
|
|
getEffectiveRelocModel(TT, RM),
|
2018-12-07 20:10:23 +08:00
|
|
|
getEffectiveCodeModel(CM, CodeModel::Small), OL),
|
2019-11-29 00:33:55 +08:00
|
|
|
TLOF(std::make_unique<RISCVELFTargetObjectFile>()) {
|
2017-02-14 13:20:20 +08:00
|
|
|
initAsmInfo();
|
2019-12-20 00:41:53 +08:00
|
|
|
|
|
|
|
// RISC-V supports the MachineOutliner.
|
|
|
|
setMachineOutliner(true);
|
2017-02-14 13:20:20 +08:00
|
|
|
}
|
2016-11-02 01:27:54 +08:00
|
|
|
|
2019-11-29 00:33:55 +08:00
|
|
|
const RISCVSubtarget *
|
|
|
|
RISCVTargetMachine::getSubtargetImpl(const Function &F) const {
|
|
|
|
Attribute CPUAttr = F.getFnAttribute("target-cpu");
|
|
|
|
Attribute FSAttr = F.getFnAttribute("target-features");
|
|
|
|
|
|
|
|
std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
|
|
|
|
? CPUAttr.getValueAsString().str()
|
|
|
|
: TargetCPU;
|
|
|
|
std::string FS = !FSAttr.hasAttribute(Attribute::None)
|
|
|
|
? FSAttr.getValueAsString().str()
|
|
|
|
: TargetFS;
|
|
|
|
std::string Key = CPU + FS;
|
|
|
|
auto &I = SubtargetMap[Key];
|
|
|
|
if (!I) {
|
|
|
|
// This needs to be done before we create a new subtarget since any
|
|
|
|
// creation will depend on the TM and the code generation flags on the
|
|
|
|
// function that reside in TargetOptions.
|
|
|
|
resetTargetOptions(F);
|
2020-01-15 22:41:08 +08:00
|
|
|
auto ABIName = Options.MCOptions.getABIName();
|
|
|
|
if (const MDString *ModuleTargetABI = dyn_cast_or_null<MDString>(
|
|
|
|
F.getParent()->getModuleFlag("target-abi"))) {
|
|
|
|
auto TargetABI = RISCVABI::getTargetABI(ABIName);
|
|
|
|
if (TargetABI != RISCVABI::ABI_Unknown &&
|
|
|
|
ModuleTargetABI->getString() != ABIName) {
|
|
|
|
report_fatal_error("-target-abi option != target-abi module flag");
|
|
|
|
}
|
|
|
|
ABIName = ModuleTargetABI->getString();
|
|
|
|
}
|
|
|
|
I = std::make_unique<RISCVSubtarget>(TargetTriple, CPU, FS, ABIName, *this);
|
2019-11-29 00:33:55 +08:00
|
|
|
}
|
|
|
|
return I.get();
|
|
|
|
}
|
|
|
|
|
[RISCV] Add RISCV-specific TargetTransformInfo
Summary:
LLVM Allows Targets to provide information that guides optimisations
made to LLVM IR. This is done with callbacks on a TargetTransformInfo object.
This patch adds a TargetTransformInfo class for RISC-V. This will allow us to
implement RISC-V specific callbacks as they become necessary.
This commit also adds the getIntImmCost callbacks, and tests them with a simple
constant hoisting test. Our immediate costs are on the conservative side, for
the moment, but we prevent hoisting in most circumstances anyway.
Previous review was on D63007
Reviewers: asb, luismarques
Reviewed By: asb
Subscribers: ributzka, MaskRay, llvm-commits, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya, mgorny
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63433
llvm-svn: 364046
2019-06-21 21:36:09 +08:00
|
|
|
TargetTransformInfo
|
|
|
|
RISCVTargetMachine::getTargetTransformInfo(const Function &F) {
|
|
|
|
return TargetTransformInfo(RISCVTTIImpl(this, F));
|
|
|
|
}
|
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
namespace {
|
|
|
|
class RISCVPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
|
|
|
RISCVPassConfig(RISCVTargetMachine &TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
|
|
|
|
|
|
|
RISCVTargetMachine &getRISCVTargetMachine() const {
|
|
|
|
return getTM<RISCVTargetMachine>();
|
|
|
|
}
|
|
|
|
|
2018-06-13 19:58:46 +08:00
|
|
|
void addIRPasses() override;
|
2017-10-20 05:37:38 +08:00
|
|
|
bool addInstSelector() override;
|
[RISCV GlobalISel] Adding initial GlobalISel infrastructure
Summary:
Add an initial GlobalISel skeleton for RISCV. It can only run ir translator for `ret void`.
Patch by Andrew Wei
Reviewers: asb, sabuasal, apazos, lenary, simoncook, lewis-revill, edward-jones, rogfer01, xiangzhai, rovka, Petar.Avramovic, mgorny, dsanders
Reviewed By: dsanders
Subscribers: pzheng, s.egerton, dsanders, hiraditya, rbar, johnrusso, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, psnobl, benna, Jim, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65219
llvm-svn: 369467
2019-08-21 06:53:24 +08:00
|
|
|
bool addIRTranslator() override;
|
|
|
|
bool addLegalizeMachineIR() override;
|
|
|
|
bool addRegBankSelect() override;
|
|
|
|
bool addGlobalInstructionSelect() override;
|
2018-01-11 05:05:07 +08:00
|
|
|
void addPreEmitPass() override;
|
2018-09-19 18:54:22 +08:00
|
|
|
void addPreEmitPass2() override;
|
2020-06-29 18:03:26 +08:00
|
|
|
void addPreSched2() override;
|
[RISCV] Add machine function pass to merge base + offset
Summary:
In r333455 we added a peephole to fix the corner cases that result
from separating base + offset lowering of global address.The
peephole didn't handle some of the cases because it only has a basic
block view instead of a function level view.
This patch replaces that logic with a machine function pass. In
addition to handling the original cases it handles uses of the global
address across blocks in function and folding an offset from LW\SW
instruction. This pass won't run for OptNone compilation, so there
will be a negative impact overall vs the old approach at O0.
Reviewers: asb, apazos, mgrang
Reviewed By: asb
Subscribers: MartinMosbeck, brucehoult, the_o, rogfer01, mgorny, rbar, johnrusso, simoncook, niosHD, kito-cheng, shiva0217, zzheng, llvm-commits, edward-jones
Differential Revision: https://reviews.llvm.org/D47857
llvm-svn: 335786
2018-06-28 04:51:42 +08:00
|
|
|
void addPreRegAlloc() override;
|
2017-10-20 05:37:38 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-02 01:27:54 +08:00
|
|
|
TargetPassConfig *RISCVTargetMachine::createPassConfig(PassManagerBase &PM) {
|
2017-10-20 05:37:38 +08:00
|
|
|
return new RISCVPassConfig(*this, PM);
|
|
|
|
}
|
|
|
|
|
2018-06-13 19:58:46 +08:00
|
|
|
void RISCVPassConfig::addIRPasses() {
|
|
|
|
addPass(createAtomicExpandPass());
|
|
|
|
TargetPassConfig::addIRPasses();
|
|
|
|
}
|
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
bool RISCVPassConfig::addInstSelector() {
|
|
|
|
addPass(createRISCVISelDag(getRISCVTargetMachine()));
|
|
|
|
|
|
|
|
return false;
|
2016-11-02 01:27:54 +08:00
|
|
|
}
|
2018-01-11 05:05:07 +08:00
|
|
|
|
[RISCV GlobalISel] Adding initial GlobalISel infrastructure
Summary:
Add an initial GlobalISel skeleton for RISCV. It can only run ir translator for `ret void`.
Patch by Andrew Wei
Reviewers: asb, sabuasal, apazos, lenary, simoncook, lewis-revill, edward-jones, rogfer01, xiangzhai, rovka, Petar.Avramovic, mgorny, dsanders
Reviewed By: dsanders
Subscribers: pzheng, s.egerton, dsanders, hiraditya, rbar, johnrusso, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, psnobl, benna, Jim, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65219
llvm-svn: 369467
2019-08-21 06:53:24 +08:00
|
|
|
bool RISCVPassConfig::addIRTranslator() {
|
|
|
|
addPass(new IRTranslator());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RISCVPassConfig::addLegalizeMachineIR() {
|
|
|
|
addPass(new Legalizer());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RISCVPassConfig::addRegBankSelect() {
|
|
|
|
addPass(new RegBankSelect());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RISCVPassConfig::addGlobalInstructionSelect() {
|
|
|
|
addPass(new InstructionSelect());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-01 23:24:15 +08:00
|
|
|
void RISCVPassConfig::addPreSched2() {}
|
2020-06-29 18:03:26 +08:00
|
|
|
|
2018-01-11 05:05:07 +08:00
|
|
|
void RISCVPassConfig::addPreEmitPass() { addPass(&BranchRelaxationPassID); }
|
[RISCV] Add machine function pass to merge base + offset
Summary:
In r333455 we added a peephole to fix the corner cases that result
from separating base + offset lowering of global address.The
peephole didn't handle some of the cases because it only has a basic
block view instead of a function level view.
This patch replaces that logic with a machine function pass. In
addition to handling the original cases it handles uses of the global
address across blocks in function and folding an offset from LW\SW
instruction. This pass won't run for OptNone compilation, so there
will be a negative impact overall vs the old approach at O0.
Reviewers: asb, apazos, mgrang
Reviewed By: asb
Subscribers: MartinMosbeck, brucehoult, the_o, rogfer01, mgorny, rbar, johnrusso, simoncook, niosHD, kito-cheng, shiva0217, zzheng, llvm-commits, edward-jones
Differential Revision: https://reviews.llvm.org/D47857
llvm-svn: 335786
2018-06-28 04:51:42 +08:00
|
|
|
|
2018-09-19 18:54:22 +08:00
|
|
|
void RISCVPassConfig::addPreEmitPass2() {
|
2020-07-14 18:15:01 +08:00
|
|
|
addPass(createRISCVExpandPseudoPass());
|
2018-09-19 18:54:22 +08:00
|
|
|
// Schedule the expansion of AMOs at the last possible moment, avoiding the
|
|
|
|
// possibility for other passes to break the requirements for forward
|
|
|
|
// progress in the LR/SC block.
|
2020-06-29 18:03:26 +08:00
|
|
|
addPass(createRISCVExpandAtomicPseudoPass());
|
2018-09-19 18:54:22 +08:00
|
|
|
}
|
|
|
|
|
[RISCV] Add machine function pass to merge base + offset
Summary:
In r333455 we added a peephole to fix the corner cases that result
from separating base + offset lowering of global address.The
peephole didn't handle some of the cases because it only has a basic
block view instead of a function level view.
This patch replaces that logic with a machine function pass. In
addition to handling the original cases it handles uses of the global
address across blocks in function and folding an offset from LW\SW
instruction. This pass won't run for OptNone compilation, so there
will be a negative impact overall vs the old approach at O0.
Reviewers: asb, apazos, mgrang
Reviewed By: asb
Subscribers: MartinMosbeck, brucehoult, the_o, rogfer01, mgorny, rbar, johnrusso, simoncook, niosHD, kito-cheng, shiva0217, zzheng, llvm-commits, edward-jones
Differential Revision: https://reviews.llvm.org/D47857
llvm-svn: 335786
2018-06-28 04:51:42 +08:00
|
|
|
void RISCVPassConfig::addPreRegAlloc() {
|
|
|
|
addPass(createRISCVMergeBaseOffsetOptPass());
|
|
|
|
}
|