forked from OSchip/llvm-project
[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 llvm-svn: 348113
This commit is contained in:
parent
7502e5fc56
commit
c588110f13
|
@ -208,6 +208,8 @@ public:
|
||||||
/// string.
|
/// string.
|
||||||
void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer = nullptr,
|
void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer = nullptr,
|
||||||
StringRef Separator = " ") const;
|
StringRef Separator = " ") const;
|
||||||
|
void dump_pretty(raw_ostream &OS, StringRef Name,
|
||||||
|
StringRef Separator = " ") const;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline raw_ostream& operator<<(raw_ostream &OS, const MCOperand &MO) {
|
inline raw_ostream& operator<<(raw_ostream &OS, const MCOperand &MO) {
|
||||||
|
|
|
@ -72,11 +72,17 @@ void MCInst::print(raw_ostream &OS) const {
|
||||||
|
|
||||||
void MCInst::dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer,
|
void MCInst::dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer,
|
||||||
StringRef Separator) const {
|
StringRef Separator) const {
|
||||||
|
StringRef InstName = Printer ? Printer->getOpcodeName(getOpcode()) : "";
|
||||||
|
dump_pretty(OS, InstName, Separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCInst::dump_pretty(raw_ostream &OS, StringRef Name,
|
||||||
|
StringRef Separator) const {
|
||||||
OS << "<MCInst #" << getOpcode();
|
OS << "<MCInst #" << getOpcode();
|
||||||
|
|
||||||
// Show the instruction opcode name if we have access to a printer.
|
// Show the instruction opcode name if we have it.
|
||||||
if (Printer)
|
if (!Name.empty())
|
||||||
OS << ' ' << Printer->getOpcodeName(getOpcode());
|
OS << ' ' << Name;
|
||||||
|
|
||||||
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
||||||
OS << Separator;
|
OS << Separator;
|
||||||
|
|
|
@ -9310,6 +9310,10 @@ bool ARMAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||||
|
|
||||||
switch (MatchResult) {
|
switch (MatchResult) {
|
||||||
case Match_Success:
|
case Match_Success:
|
||||||
|
LLVM_DEBUG(dbgs() << "Parsed as: ";
|
||||||
|
Inst.dump_pretty(dbgs(), MII.getName(Inst.getOpcode()));
|
||||||
|
dbgs() << "\n");
|
||||||
|
|
||||||
// Context sensitive operand constraints aren't handled by the matcher,
|
// Context sensitive operand constraints aren't handled by the matcher,
|
||||||
// so check them here.
|
// so check them here.
|
||||||
if (validateInstruction(Inst, Operands)) {
|
if (validateInstruction(Inst, Operands)) {
|
||||||
|
@ -9327,7 +9331,9 @@ bool ARMAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
||||||
// individual transformations can chain off each other. E.g.,
|
// individual transformations can chain off each other. E.g.,
|
||||||
// tPOP(r8)->t2LDMIA_UPD(sp,r8)->t2STR_POST(sp,r8)
|
// tPOP(r8)->t2LDMIA_UPD(sp,r8)->t2STR_POST(sp,r8)
|
||||||
while (processInstruction(Inst, Operands, Out))
|
while (processInstruction(Inst, Operands, Out))
|
||||||
;
|
LLVM_DEBUG(dbgs() << "Changed to: ";
|
||||||
|
Inst.dump_pretty(dbgs(), MII.getName(Inst.getOpcode()));
|
||||||
|
dbgs() << "\n");
|
||||||
|
|
||||||
// Only after the instruction is fully processed, we can validate it
|
// Only after the instruction is fully processed, we can validate it
|
||||||
if (wasInITBlock && hasV8Ops() && isThumb() &&
|
if (wasInITBlock && hasV8Ops() && isThumb() &&
|
||||||
|
|
Loading…
Reference in New Issue