llvm.org GIT mirror llvm / 9b84009
[ARM][Asm] Debug trace for the processInstruction loop In the Arm assembly parser, we first match an instruction, then call processInstruction to possibly change it to a different encoding, to match rules in the architecture manual which can't be expressed by the table-generated matcher. This adds debug printing so that this process is visible when using the -debug option. To support this, I've added a new overload of MCInst::dump_pretty which takes the opcode name as a StringRef, since we don't have an InstPrinter instance in the assembly parser. Instead, we can get the same information directly from the MCInstrInfo. Differential revision: https://reviews.llvm.org/D54852 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348113 91177308-0d34-0410-b5e6-96231b3b80d8 Oliver Stannard 1 year, 8 months ago
3 changed file(s) with 18 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
207207 /// string.
208208 void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer = nullptr,
209209 StringRef Separator = " ") const;
210 void dump_pretty(raw_ostream &OS, StringRef Name,
211 StringRef Separator = " ") const;
210212 };
211213
212214 inline raw_ostream& operator<<(raw_ostream &OS, const MCOperand &MO) {
7171
7272 void MCInst::dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer,
7373 StringRef Separator) const {
74 StringRef InstName = Printer ? Printer->getOpcodeName(getOpcode()) : "";
75 dump_pretty(OS, InstName, Separator);
76 }
77
78 void MCInst::dump_pretty(raw_ostream &OS, StringRef Name,
79 StringRef Separator) const {
7480 OS << "
7581
76 // Show the instruction opcode name if we have access to a printer.
77 if (Printer)
78 OS << ' ' << Printer->getOpcodeName(getOpcode());
82 // Show the instruction opcode name if we have it.
83 if (!Name.empty())
84 OS << ' ' << Name;
7985
8086 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
8187 OS << Separator;
93099309
93109310 switch (MatchResult) {
93119311 case Match_Success:
9312 LLVM_DEBUG(dbgs() << "Parsed as: ";
9313 Inst.dump_pretty(dbgs(), MII.getName(Inst.getOpcode()));
9314 dbgs() << "\n");
9315
93129316 // Context sensitive operand constraints aren't handled by the matcher,
93139317 // so check them here.
93149318 if (validateInstruction(Inst, Operands)) {
93269330 // individual transformations can chain off each other. E.g.,
93279331 // tPOP(r8)->t2LDMIA_UPD(sp,r8)->t2STR_POST(sp,r8)
93289332 while (processInstruction(Inst, Operands, Out))
9329 ;
9333 LLVM_DEBUG(dbgs() << "Changed to: ";
9334 Inst.dump_pretty(dbgs(), MII.getName(Inst.getOpcode()));
9335 dbgs() << "\n");
93309336
93319337 // Only after the instruction is fully processed, we can validate it
93329338 if (wasInITBlock && hasV8Ops() && isThumb() &&