38#define DEBUG_TYPE "hexagon-vector-print"
42 cl::desc(
"Enables tracing of vector stores"));
55 StringRef getPassName()
const override {
return "Hexagon VectorPrint pass"; }
62char HexagonVectorPrint::ID = 0;
65 return (
Reg >= Hexagon::V0 &&
Reg <= Hexagon::V31) ||
66 (
Reg >= Hexagon::W0 &&
Reg <= Hexagon::W15) ||
67 (
Reg >= Hexagon::WR0 &&
Reg <= Hexagon::WR15) ||
68 (
Reg >= Hexagon::Q0 &&
Reg <= Hexagon::Q3);
72 if (R >= Hexagon::V0 && R <= Hexagon::V31) {
73 static const char* S[] = {
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
74 "28",
"29",
"2a",
"2b",
"2c",
"2d",
"2e",
"2f",
75 "30",
"31",
"32",
"33",
"34",
"35",
"36",
"37",
76 "38",
"39",
"3a",
"3b",
"3c",
"3d",
"3e",
"3f"};
77 return S[R-Hexagon::V0];
79 if (R >= Hexagon::Q0 && R <= Hexagon::Q3) {
80 static const char* S[] = {
"00",
"01",
"02",
"03"};
81 return S[R-Hexagon::Q0];
100 if (
MI.getNumOperands() < 1)
return false;
102 if (
MI.getOperand(0).isReg() &&
MI.getOperand(0).isDef()) {
103 Reg =
MI.getOperand(0).getReg();
108 if (
MI.mayStore() &&
MI.getNumOperands() >= 3 &&
MI.getOperand(2).isReg()) {
109 Reg =
MI.getOperand(2).getReg();
114 if (
MI.mayStore() &&
MI.getNumOperands() >= 4 &&
MI.getOperand(3).isReg()) {
115 Reg =
MI.getOperand(3).getReg();
126 std::vector<MachineInstr *> VecPrintList;
128 for (
auto &
MI :
MBB) {
131 for (++MII; MII !=
MBB.
instr_end() && MII->isInsideBundle(); ++MII) {
132 if (MII->getNumOperands() < 1)
136 VecPrintList.push_back((&*MII));
144 VecPrintList.push_back(&
MI);
150 Changed = !VecPrintList.empty();
154 for (
auto *
I : VecPrintList) {
162 if (
I->isInsideBundle()) {
164 while (
MBB->
instr_end() != MII && MII->isInsideBundle())
173 if (
Reg >= Hexagon::V0 &&
Reg <= Hexagon::V31) {
176 }
else if (
Reg >= Hexagon::W0 &&
Reg <= Hexagon::W15) {
182 }
else if (
Reg >= Hexagon::Q0 &&
Reg <= Hexagon::Q3) {
195 "Hexagon VectorPrint pass",
false,
false)
198 return new HexagonVectorPrint();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< bool > TraceHexVectorStoresOnly("trace-hex-vector-stores-only", cl::Hidden, cl::desc("Enables tracing of vector stores"))
static std::string getStringReg(unsigned R)
static bool isVecReg(unsigned Reg)
static void addAsmInstr(MachineBasicBlock *MBB, unsigned Reg, MachineBasicBlock::instr_iterator I, const DebugLoc &DL, const HexagonInstrInfo *QII, MachineFunction &Fn)
static bool getInstrVecReg(const MachineInstr &MI, unsigned &Reg)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
FunctionPass class - This class is used to implement most global optimizations.
const HexagonInstrInfo * getInstrInfo() const override
Instructions::iterator instr_iterator
instr_iterator instr_end()
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createHexagonVectorPrint()
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.