Add support for ${:comment}, which expands to the current target's comment
character, and ${:uid} which expands to a unique ID for the MachineInstr.
More can be added if/when they are needed.
llvm-svn: 30619
This commit is contained in:
parent
8d21485660
commit
a32814b033
|
|
@ -108,6 +108,14 @@ namespace llvm {
|
||||||
/// doFinalization - Shut down the asmprinter. If you override this in your
|
/// doFinalization - Shut down the asmprinter. If you override this in your
|
||||||
/// pass, you must make sure to call it explicitly.
|
/// pass, you must make sure to call it explicitly.
|
||||||
bool doFinalization(Module &M);
|
bool doFinalization(Module &M);
|
||||||
|
|
||||||
|
/// PrintSpecial - Print information related to the specified machine instr
|
||||||
|
/// that is independent of the operand, and may be independent of the instr
|
||||||
|
/// itself. This can be useful for portably encoding the comment character
|
||||||
|
/// or other bits of target-specific knowledge into the asmstrings. The
|
||||||
|
/// syntax used is ${:comment}. Targets can override this to add support
|
||||||
|
/// for their own strange codes.
|
||||||
|
virtual void PrintSpecial(const MachineInstr *MI, const char *Code);
|
||||||
|
|
||||||
/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
|
/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
|
||||||
/// instruction, using the specified assembler variant. Targets should
|
/// instruction, using the specified assembler variant. Targets should
|
||||||
|
|
|
||||||
|
|
@ -619,6 +619,30 @@ AsmPrinter::EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// PrintSpecial - Print information related to the specified machine instr
|
||||||
|
/// that is independent of the operand, and may be independent of the instr
|
||||||
|
/// itself. This can be useful for portably encoding the comment character
|
||||||
|
/// or other bits of target-specific knowledge into the asmstrings. The
|
||||||
|
/// syntax used is ${:comment}. Targets can override this to add support
|
||||||
|
/// for their own strange codes.
|
||||||
|
void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
|
||||||
|
if (!strcmp(Code, "comment")) {
|
||||||
|
O << TAI->getCommentString();
|
||||||
|
} else if (!strcmp(Code, "uid")) {
|
||||||
|
// Assign a unique ID to this machine instruction.
|
||||||
|
static const MachineInstr *LastMI = 0;
|
||||||
|
static unsigned Counter = 0U-1;
|
||||||
|
// If this is a new machine instruction, bump the counter.
|
||||||
|
if (LastMI != MI) { ++Counter; LastMI = MI; }
|
||||||
|
O << Counter;
|
||||||
|
} else {
|
||||||
|
std::cerr << "Unknown special formatter '" << Code
|
||||||
|
<< "' for machine instr: " << *MI;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// printInlineAsm - This method formats and prints the specified machine
|
/// printInlineAsm - This method formats and prints the specified machine
|
||||||
/// instruction that is an inline asm.
|
/// instruction that is an inline asm.
|
||||||
void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
|
void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue