2013-07-22 00:52:55 +00:00
|
|
|
//===-- PrologEpilogInserter.h - Prolog/Epilog code insertion -*- C++ -*---===//
|
2009-05-12 20:33:29 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This pass is responsible for finalizing the functions frame layout, saving
|
|
|
|
// callee saved registers, and for emitting prolog & epilog code for the
|
|
|
|
// function.
|
|
|
|
//
|
|
|
|
// This pass must be run after register allocation. After this pass is
|
|
|
|
// executed, it is illegal to construct MO_FrameIndex operands.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_PROLOGEPILOGINSERTER_H
|
|
|
|
#define LLVM_LIB_CODEGEN_PROLOGEPILOGINSERTER_H
|
2009-05-12 20:33:29 +00:00
|
|
|
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/SparseBitVector.h"
|
2009-05-12 20:33:29 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineLoopInfo.h"
|
2012-12-04 07:12:27 +00:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2009-10-07 17:12:56 +00:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2009-05-12 20:33:29 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class RegScavenger;
|
|
|
|
class MachineBasicBlock;
|
|
|
|
|
2013-09-11 18:05:11 +00:00
|
|
|
class PEI : public MachineFunctionPass {
|
2009-05-12 20:33:29 +00:00
|
|
|
public:
|
|
|
|
static char ID;
|
2010-10-19 17:21:58 +00:00
|
|
|
PEI() : MachineFunctionPass(ID) {
|
|
|
|
initializePEIPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2009-05-12 20:33:29 +00:00
|
|
|
|
2014-03-07 09:26:03 +00:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
2009-05-12 20:33:29 +00:00
|
|
|
|
|
|
|
/// runOnMachineFunction - Insert prolog/epilog code and replace abstract
|
|
|
|
/// frame indexes with appropriate references.
|
|
|
|
///
|
2014-03-07 09:26:03 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &Fn) override;
|
2009-05-12 20:33:29 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
RegScavenger *RS;
|
|
|
|
|
|
|
|
// MinCSFrameIndex, MaxCSFrameIndex - Keeps the range of callee saved
|
|
|
|
// stack frame indexes.
|
|
|
|
unsigned MinCSFrameIndex, MaxCSFrameIndex;
|
|
|
|
|
|
|
|
// Entry and return blocks of the current function.
|
|
|
|
MachineBasicBlock* EntryBlock;
|
|
|
|
SmallVector<MachineBasicBlock*, 4> ReturnBlocks;
|
|
|
|
|
2009-10-08 01:46:59 +00:00
|
|
|
// Flag to control whether to use the register scavenger to resolve
|
|
|
|
// frame index materialization registers. Set according to
|
|
|
|
// TRI->requiresFrameIndexScavenging() for the curren function.
|
|
|
|
bool FrameIndexVirtualScavenging;
|
|
|
|
|
2013-10-31 14:07:59 +00:00
|
|
|
void calculateSets(MachineFunction &Fn);
|
2009-07-16 13:50:40 +00:00
|
|
|
void calculateCallsInformation(MachineFunction &Fn);
|
2009-05-12 20:33:29 +00:00
|
|
|
void calculateCalleeSavedRegisters(MachineFunction &Fn);
|
|
|
|
void insertCSRSpillsAndRestores(MachineFunction &Fn);
|
|
|
|
void calculateFrameObjectOffsets(MachineFunction &Fn);
|
|
|
|
void replaceFrameIndices(MachineFunction &Fn);
|
2013-07-12 00:37:01 +00:00
|
|
|
void replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &Fn,
|
|
|
|
int &SPAdj);
|
Start of revamping the register scavenging in PEI. ARM Thumb1 is the driving
interest for this, as it currently reserves a register rather than using
the scavenger for matierializing constants as needed.
Instead of scavenging registers on the fly while eliminating frame indices,
new virtual registers are created, and then a scavenged collectively in a
post-pass over the function. This isolates the bits that need to interact
with the scavenger, and sets the stage for more intelligent use, and reuse,
of scavenged registers.
For the time being, this is disabled by default. Once the bugs are worked out,
the current scavenging calls in replaceFrameIndices() will be removed and
the post-pass scavenging will be the default. Until then,
-enable-frame-index-scavenging enables the new code. Currently, only the
Thumb1 back end is set up to use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82734 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-24 23:52:18 +00:00
|
|
|
void scavengeFrameVirtualRegs(MachineFunction &Fn);
|
2009-05-12 20:33:29 +00:00
|
|
|
void insertPrologEpilogCode(MachineFunction &Fn);
|
|
|
|
|
|
|
|
// Convenience for recognizing return blocks.
|
|
|
|
bool isReturnBlock(MachineBasicBlock* MBB);
|
|
|
|
};
|
|
|
|
} // End llvm namespace
|
|
|
|
#endif
|