mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-03 10:54:42 +00:00
CodeGen/Passes: Pass MachineFunction as functor arg; NFC
Passing a MachineFunction as argument is more natural and avoids an unnecessary round-trip through the logic determining the correct Subtarget because MachineFunction already has a reference anyway. llvm-svn: 285039
This commit is contained in:
parent
f7b399052c
commit
9688a1523c
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class Function;
|
|
||||||
class FunctionPass;
|
class FunctionPass;
|
||||||
|
class MachineFunction;
|
||||||
class MachineFunctionPass;
|
class MachineFunctionPass;
|
||||||
class ModulePass;
|
class ModulePass;
|
||||||
class Pass;
|
class Pass;
|
||||||
@ -215,7 +215,8 @@ namespace llvm {
|
|||||||
/// IfConverter - This pass performs machine code if conversion.
|
/// IfConverter - This pass performs machine code if conversion.
|
||||||
extern char &IfConverterID;
|
extern char &IfConverterID;
|
||||||
|
|
||||||
FunctionPass *createIfConverter(std::function<bool(const Function &)> Ftor);
|
FunctionPass *createIfConverter(
|
||||||
|
std::function<bool(const MachineFunction &)> Ftor);
|
||||||
|
|
||||||
/// MachineBlockPlacement - This pass places basic blocks based on branch
|
/// MachineBlockPlacement - This pass places basic blocks based on branch
|
||||||
/// probabilities.
|
/// probabilities.
|
||||||
@ -326,7 +327,7 @@ namespace llvm {
|
|||||||
extern char &UnpackMachineBundlesID;
|
extern char &UnpackMachineBundlesID;
|
||||||
|
|
||||||
FunctionPass *
|
FunctionPass *
|
||||||
createUnpackMachineBundles(std::function<bool(const Function &)> Ftor);
|
createUnpackMachineBundles(std::function<bool(const MachineFunction &)> Ftor);
|
||||||
|
|
||||||
/// FinalizeMachineBundles - This pass finalize machine instruction
|
/// FinalizeMachineBundles - This pass finalize machine instruction
|
||||||
/// bundles (created earlier, e.g. during pre-RA scheduling).
|
/// bundles (created earlier, e.g. during pre-RA scheduling).
|
||||||
|
@ -184,11 +184,11 @@ namespace {
|
|||||||
bool PreRegAlloc;
|
bool PreRegAlloc;
|
||||||
bool MadeChange;
|
bool MadeChange;
|
||||||
int FnNum;
|
int FnNum;
|
||||||
std::function<bool(const Function &)> PredicateFtor;
|
std::function<bool(const MachineFunction &)> PredicateFtor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
IfConverter(std::function<bool(const Function &)> Ftor = nullptr)
|
IfConverter(std::function<bool(const MachineFunction &)> Ftor = nullptr)
|
||||||
: MachineFunctionPass(ID), FnNum(-1), PredicateFtor(std::move(Ftor)) {
|
: MachineFunctionPass(ID), FnNum(-1), PredicateFtor(std::move(Ftor)) {
|
||||||
initializeIfConverterPass(*PassRegistry::getPassRegistry());
|
initializeIfConverterPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
@ -321,8 +321,7 @@ INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo)
|
|||||||
INITIALIZE_PASS_END(IfConverter, "if-converter", "If Converter", false, false)
|
INITIALIZE_PASS_END(IfConverter, "if-converter", "If Converter", false, false)
|
||||||
|
|
||||||
bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
if (skipFunction(*MF.getFunction()) ||
|
if (skipFunction(*MF.getFunction()) || (PredicateFtor && !PredicateFtor(MF)))
|
||||||
(PredicateFtor && !PredicateFtor(*MF.getFunction())))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const TargetSubtargetInfo &ST = MF.getSubtarget();
|
const TargetSubtargetInfo &ST = MF.getSubtarget();
|
||||||
@ -2295,6 +2294,6 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *
|
FunctionPass *
|
||||||
llvm::createIfConverter(std::function<bool(const Function &)> Ftor) {
|
llvm::createIfConverter(std::function<bool(const MachineFunction &)> Ftor) {
|
||||||
return new IfConverter(std::move(Ftor));
|
return new IfConverter(std::move(Ftor));
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ namespace {
|
|||||||
class UnpackMachineBundles : public MachineFunctionPass {
|
class UnpackMachineBundles : public MachineFunctionPass {
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification
|
static char ID; // Pass identification
|
||||||
UnpackMachineBundles(std::function<bool(const Function &)> Ftor = nullptr)
|
UnpackMachineBundles(
|
||||||
|
std::function<bool(const MachineFunction &)> Ftor = nullptr)
|
||||||
: MachineFunctionPass(ID), PredicateFtor(std::move(Ftor)) {
|
: MachineFunctionPass(ID), PredicateFtor(std::move(Ftor)) {
|
||||||
initializeUnpackMachineBundlesPass(*PassRegistry::getPassRegistry());
|
initializeUnpackMachineBundlesPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
@ -32,7 +33,7 @@ namespace {
|
|||||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::function<bool(const Function &)> PredicateFtor;
|
std::function<bool(const MachineFunction &)> PredicateFtor;
|
||||||
};
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundles",
|
|||||||
"Unpack machine instruction bundles", false, false)
|
"Unpack machine instruction bundles", false, false)
|
||||||
|
|
||||||
bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) {
|
bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) {
|
||||||
if (PredicateFtor && !PredicateFtor(*MF.getFunction()))
|
if (PredicateFtor && !PredicateFtor(MF))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
@ -78,7 +79,8 @@ bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FunctionPass *
|
FunctionPass *
|
||||||
llvm::createUnpackMachineBundles(std::function<bool(const Function &)> Ftor) {
|
llvm::createUnpackMachineBundles(
|
||||||
|
std::function<bool(const MachineFunction &)> Ftor) {
|
||||||
return new UnpackMachineBundles(std::move(Ftor));
|
return new UnpackMachineBundles(std::move(Ftor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,8 +443,8 @@ void ARMPassConfig::addPreSched2() {
|
|||||||
return this->TM->getSubtarget<ARMSubtarget>(F).restrictIT();
|
return this->TM->getSubtarget<ARMSubtarget>(F).restrictIT();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
addPass(createIfConverter([this](const Function &F) {
|
addPass(createIfConverter([](const MachineFunction &MF) {
|
||||||
return !this->TM->getSubtarget<ARMSubtarget>(F).isThumb1Only();
|
return !MF.getSubtarget<ARMSubtarget>().isThumb1Only();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
addPass(createThumb2ITBlockPass());
|
addPass(createThumb2ITBlockPass());
|
||||||
@ -454,8 +454,8 @@ void ARMPassConfig::addPreEmitPass() {
|
|||||||
addPass(createThumb2SizeReductionPass());
|
addPass(createThumb2SizeReductionPass());
|
||||||
|
|
||||||
// Constant island pass work on unbundled instructions.
|
// Constant island pass work on unbundled instructions.
|
||||||
addPass(createUnpackMachineBundles([this](const Function &F) {
|
addPass(createUnpackMachineBundles([](const MachineFunction &MF) {
|
||||||
return this->TM->getSubtarget<ARMSubtarget>(F).isThumb2();
|
return MF.getSubtarget<ARMSubtarget>().isThumb2();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Don't optimize barriers at -O0.
|
// Don't optimize barriers at -O0.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user