16 #define DEBUG_TYPE "hexagon-vector-print"
41 cl::desc(
"Enables tracing of vector stores"));
65 StringRef getPassName()
const override {
return "Hexagon VectorPrint pass"; }
75 return (Reg >= Hexagon::V0 && Reg <= Hexagon::V31)
76 || (Reg >= Hexagon::W0 && Reg <= Hexagon::W15)
77 || (Reg >= Hexagon::Q0 && Reg <= Hexagon::Q3);
81 if (R >= Hexagon::V0 && R <= Hexagon::V31) {
82 static const char* S[] = {
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
83 "28",
"29",
"2a",
"2b",
"2c",
"2d",
"2e",
"2f",
84 "30",
"31",
"32",
"33",
"34",
"35",
"36",
"37",
85 "38",
"39",
"3a",
"3b",
"3c",
"3d",
"3e",
"3f"};
86 return S[R-Hexagon::V0];
88 if (R >= Hexagon::Q0 && R <= Hexagon::Q3) {
89 static const char* S[] = {
"00",
"01",
"02",
"03"};
90 return S[R-Hexagon::Q0];
101 std::string VDescStr =
".long 0x1dffe0" +
getStringReg(Reg);
105 .addExternalSymbol(cstr)
133 bool Changed =
false;
136 QII = QST->getInstrInfo();
137 std::vector<MachineInstr *> VecPrintList;
139 for (
auto &
MI :
MBB) {
142 for (++MII; MII != MBB.instr_end() && MII->isInsideBundle(); ++MII) {
143 if (MII->getNumOperands() < 1)
147 VecPrintList.push_back((&*MII));
148 DEBUG(
dbgs() <<
"Found vector reg inside bundle \n"; MII->dump());
154 VecPrintList.push_back(&
MI);
160 Changed = !VecPrintList.empty();
164 for (
auto *
I : VecPrintList) {
167 DEBUG(
dbgs() <<
"Evaluating V MI\n";
I->dump());
172 if (
I->isInsideBundle()) {
173 DEBUG(
dbgs() <<
"add to end of bundle\n";
I->dump());
174 while (MBB->
instr_end() != MII && MII->isInsideBundle())
177 DEBUG(
dbgs() <<
"add after instruction\n";
I->dump());
183 if (Reg >= Hexagon::V0 && Reg <= Hexagon::V31) {
184 DEBUG(
dbgs() <<
"adding dump for V" << Reg-Hexagon::V0 <<
'\n');
186 }
else if (Reg >= Hexagon::W0 && Reg <= Hexagon::W15) {
187 DEBUG(
dbgs() <<
"adding dump for W" << Reg-Hexagon::W0 <<
'\n');
188 addAsmInstr(MBB, Hexagon::V0 + (Reg - Hexagon::W0) * 2 + 1,
190 addAsmInstr(MBB, Hexagon::V0 + (Reg - Hexagon::W0) * 2,
192 }
else if (Reg >= Hexagon::Q0 && Reg <= Hexagon::Q3) {
193 DEBUG(
dbgs() <<
"adding dump for Q" << Reg-Hexagon::Q0 <<
'\n');
205 "Hexagon VectorPrint pass",
false,
false)
208 return new HexagonVectorPrint();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
instr_iterator instr_end()
FunctionPass * createHexagonVectorPrint()
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonRegisterInfo * getRegisterInfo() const override
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Reg
All possible values of the reg field in the ModR/M byte.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
INLINEASM - Represents an inline asm block.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
INITIALIZE_PASS(HexagonVectorPrint,"hexagon-vector-print","Hexagon VectorPrint pass", false, false) FunctionPass *llvm
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
static bool getInstrVecReg(const MachineInstr &MI, unsigned &Reg)
const MachineOperand & getOperand(unsigned i) const
FunctionPass class - This class is used to implement most global optimizations.
static bool isVecReg(unsigned Reg)
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Iterator for intrusive lists based on ilist_node.
static void addAsmInstr(MachineBasicBlock *MBB, unsigned Reg, MachineBasicBlock::instr_iterator I, const DebugLoc &DL, const HexagonInstrInfo *QII, MachineFunction &Fn)
static cl::opt< bool > TraceHexVectorStoresOnly("trace-hex-vector-stores-only", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Enables tracing of vector stores"))
void initializeHexagonVectorPrintPass(PassRegistry &)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Representation of each machine instruction.
unsigned getReg() const
getReg - Returns the register number.
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static std::string getStringReg(unsigned R)