1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

CodeGen: Refactor regallocator command line and target selection

Make the sequence of passes to select and rewrite instructions to
physical registers be a target callback. This is to prepare to allow
targets to split register allocation into multiple phases.
This commit is contained in:
Matt Arsenault 2019-02-22 13:15:39 -05:00
parent 92098b28a7
commit a466bf7dc3
4 changed files with 17 additions and 17 deletions

View File

@ -460,10 +460,10 @@ protected:
/// regalloc pass.
virtual FunctionPass *createRegAllocPass(bool Optimized);
/// Add core register alloator passes which do the actual register assignment
/// Add core register allocator passes which do the actual register assignment
/// and rewriting. \returns true if any passes were added.
virtual bool addRegAssignmentFast();
virtual bool addRegAssignmentOptimized();
virtual bool addRegAssignAndRewriteFast();
virtual bool addRegAssignAndRewriteOptimized();
};
void registerCodeGenCallback(PassInstrumentationCallbacks &PIC,

View File

@ -1308,7 +1308,7 @@ FunctionPass *TargetPassConfig::createRegAllocPass(bool Optimized) {
return createTargetRegisterAllocator(Optimized);
}
bool TargetPassConfig::addRegAssignmentFast() {
bool TargetPassConfig::addRegAssignAndRewriteFast() {
if (RegAlloc != &useDefaultRegisterAllocator &&
RegAlloc != &createFastRegisterAllocator)
report_fatal_error("Must use fast (default) register allocator for unoptimized regalloc.");
@ -1317,7 +1317,7 @@ bool TargetPassConfig::addRegAssignmentFast() {
return true;
}
bool TargetPassConfig::addRegAssignmentOptimized() {
bool TargetPassConfig::addRegAssignAndRewriteOptimized() {
// Add the selected register allocation pass.
addPass(createRegAllocPass(true));
@ -1327,12 +1327,6 @@ bool TargetPassConfig::addRegAssignmentOptimized() {
// Finally rewrite virtual registers.
addPass(&VirtRegRewriterID);
// Perform stack slot coloring and post-ra machine LICM.
//
// FIXME: Re-enable coloring with register when it's capable of adding
// kill markers.
addPass(&StackSlotColoringID);
return true;
}
@ -1348,7 +1342,7 @@ void TargetPassConfig::addFastRegAlloc() {
addPass(&PHIEliminationID, false);
addPass(&TwoAddressInstructionPassID, false);
addRegAssignmentFast();
addRegAssignAndRewriteFast();
}
/// Add standard target-independent passes that are tightly coupled with
@ -1391,7 +1385,13 @@ void TargetPassConfig::addOptimizedRegAlloc() {
// PreRA instruction scheduling.
addPass(&MachineSchedulerID);
if (addRegAssignmentOptimized()) {
if (addRegAssignAndRewriteOptimized()) {
// Perform stack slot coloring and post-ra machine LICM.
//
// FIXME: Re-enable coloring with register when it's capable of adding
// kill markers.
addPass(&StackSlotColoringID);
// Allow targets to expand pseudo instructions depending on the choice of
// registers before MachineCopyPropagation.
addPostRewrite();

View File

@ -170,11 +170,11 @@ public:
void addFastRegAlloc() override;
void addOptimizedRegAlloc() override;
bool addRegAssignmentFast() override {
bool addRegAssignAndRewriteFast() override {
llvm_unreachable("should not be used");
}
bool addRegAssignmentOptimized() override {
bool addRegAssignAndRewriteOptimized() override {
llvm_unreachable("should not be used");
}

View File

@ -326,10 +326,10 @@ public:
void addPreEmitPass() override;
// No reg alloc
bool addRegAssignmentFast() override { return false; }
bool addRegAssignAndRewriteFast() override { return false; }
// No reg alloc
bool addRegAssignmentOptimized() override { return false; }
bool addRegAssignAndRewriteOptimized() override { return false; }
};
} // end anonymous namespace