#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONVLIWPACKETIZER_H
#include "llvm/CodeGen/DFAPacketizer.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include <vector>
namespace llvm {
class HexagonInstrInfo;
class HexagonRegisterInfo;
class MachineBranchProbabilityInfo;
class MachineFunction;
class MachineInstr;
class MachineLoopInfo;
class TargetRegisterClass;
class HexagonPacketizerList : public VLIWPacketizerList {
std::vector<MachineInstr *> OldPacketMIs;
bool PromotedToDotNew;
bool GlueAllocframeStore;
bool GlueToNewValueJump;
int64_t ChangedOffset;
bool Dependence;
bool FoundSequentialDependence;
bool MemShufDisabled = false;
std::vector<MachineInstr*> IgnoreDepMIs;
bool PacketStalls = false;
unsigned int PacketStallCycles = 0;
bool PacketHasDuplex = false;
bool PacketHasSLOT0OnlyInsn = false;
protected:
const MachineBranchProbabilityInfo *MBPI;
const MachineLoopInfo *MLI;
private:
const HexagonInstrInfo *HII;
const HexagonRegisterInfo *HRI;
const bool Minimal;
public:
HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI,
AAResults *AA, const MachineBranchProbabilityInfo *MBPI,
bool Minimal);
void initPacketizerState() override;
bool ignorePseudoInstruction(const MachineInstr &MI,
const MachineBasicBlock *MBB) override;
bool isSoloInstruction(const MachineInstr &MI) override;
bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override;
bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override;
bool foundLSInPacket();
MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override;
void endPacket(MachineBasicBlock *MBB,
MachineBasicBlock::iterator MI) override;
bool shouldAddToPacket(const MachineInstr &MI) override;
void unpacketizeSoloInstrs(MachineFunction &MF);
protected:
bool getmemShufDisabled() {
return MemShufDisabled;
};
void setmemShufDisabled(bool val) {
MemShufDisabled = val;
};
bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType,
unsigned DepReg);
bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType,
MachineBasicBlock::iterator &MII,
const TargetRegisterClass *RC);
bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU,
unsigned DepReg, MachineBasicBlock::iterator &MII,
const TargetRegisterClass *RC);
void cleanUpDotCur();
bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType,
MachineBasicBlock::iterator &MII,
const TargetRegisterClass *RC);
bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU,
unsigned DepReg, MachineBasicBlock::iterator &MII,
const TargetRegisterClass *RC);
bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU,
unsigned DepReg, MachineBasicBlock::iterator &MII);
bool canPromoteToNewValueStore(const MachineInstr &MI,
const MachineInstr &PacketMI, unsigned DepReg);
bool demoteToDotOld(MachineInstr &MI);
bool useCallersSP(MachineInstr &MI);
void useCalleesSP(MachineInstr &MI);
bool updateOffset(SUnit *SUI, SUnit *SUJ);
void undoChangedOffset(MachineInstr &MI);
bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2);
bool restrictingDepExistInPacket(MachineInstr&, unsigned);
bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC);
bool isCurifiable(MachineInstr &MI);
bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ);
bool isPromotedToDotNew() const {
return PromotedToDotNew;
}
bool tryAllocateResourcesForConstExt(bool Reserve);
bool canReserveResourcesForConstExt();
void reserveResourcesForConstExt();
bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J);
bool hasControlDependence(const MachineInstr &I, const MachineInstr &J);
bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J);
bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J);
bool producesStall(const MachineInstr &MI);
unsigned int calcStall(const MachineInstr &MI);
};
}
#endif