#include "HexagonInstrInfo.h"
#include "HexagonSubtarget.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/Pass.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<bool>
IsCombinesDisabled("disable-merge-into-combines", cl::Hidden,
cl::desc("Disable merging into combines"));
static cl::opt<bool>
IsConst64Disabled("disable-const64", cl::Hidden,
cl::desc("Disable generation of const64"));
static
cl::opt<unsigned>
MaxNumOfInstsBetweenNewValueStoreAndTFR("max-num-inst-between-tfr-and-nv-store",
cl::Hidden, cl::init(4),
cl::desc("Maximum distance between a tfr feeding a store we "
"consider the store still to be newifiable"));
namespace llvm {
FunctionPass *createHexagonCopyToCombine();
void initializeHexagonCopyToCombinePass(PassRegistry&);
}
namespace {
class HexagonCopyToCombine : public MachineFunctionPass { … };
}
char HexagonCopyToCombine::ID = …;
INITIALIZE_PASS(…)
static bool isCombinableInstType(MachineInstr &MI, const HexagonInstrInfo *TII,
bool ShouldCombineAggressively) { … }
template <unsigned N> static bool isGreaterThanNBitTFRI(const MachineInstr &I) { … }
static bool areCombinableOperations(const TargetRegisterInfo *TRI,
MachineInstr &HighRegInst,
MachineInstr &LowRegInst, bool AllowC64) { … }
static bool isEvenReg(unsigned Reg) { … }
static void removeKillInfo(MachineInstr &MI, unsigned RegNotKilled) { … }
static bool isUnsafeToMoveAcross(MachineInstr &MI, unsigned UseReg,
unsigned DestReg,
const TargetRegisterInfo *TRI) { … }
static Register UseReg(const MachineOperand& MO) { … }
bool HexagonCopyToCombine::isSafeToMoveTogether(MachineInstr &I1,
MachineInstr &I2,
unsigned I1DestReg,
unsigned I2DestReg,
bool &DoInsertAtI1) { … }
void
HexagonCopyToCombine::findPotentialNewifiableTFRs(MachineBasicBlock &BB) { … }
bool HexagonCopyToCombine::runOnMachineFunction(MachineFunction &MF) { … }
MachineInstr *HexagonCopyToCombine::findPairable(MachineInstr &I1,
bool &DoInsertAtI1,
bool AllowC64) { … }
void HexagonCopyToCombine::combine(MachineInstr &I1, MachineInstr &I2,
MachineBasicBlock::iterator &MI,
bool DoInsertAtI1, bool OptForSize) { … }
void HexagonCopyToCombine::emitConst64(MachineBasicBlock::iterator &InsertPt,
unsigned DoubleDestReg,
MachineOperand &HiOperand,
MachineOperand &LoOperand) { … }
void HexagonCopyToCombine::emitCombineII(MachineBasicBlock::iterator &InsertPt,
unsigned DoubleDestReg,
MachineOperand &HiOperand,
MachineOperand &LoOperand) { … }
void HexagonCopyToCombine::emitCombineIR(MachineBasicBlock::iterator &InsertPt,
unsigned DoubleDestReg,
MachineOperand &HiOperand,
MachineOperand &LoOperand) { … }
void HexagonCopyToCombine::emitCombineRI(MachineBasicBlock::iterator &InsertPt,
unsigned DoubleDestReg,
MachineOperand &HiOperand,
MachineOperand &LoOperand) { … }
void HexagonCopyToCombine::emitCombineRR(MachineBasicBlock::iterator &InsertPt,
unsigned DoubleDestReg,
MachineOperand &HiOperand,
MachineOperand &LoOperand) { … }
FunctionPass *llvm::createHexagonCopyToCombine() { … }