summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-07-13 20:25:48 +0000
committerDavid Greene <greened@obbligato.org>2009-07-13 20:25:48 +0000
commit014700c1a8cba203fd21ff129426ba8a426ab244 (patch)
tree0459af1b54ae0b03b14896eb77b53801d40d4997 /include
parentb8ac841c9a275cc8d4e1a92dd06cc99323e35fa2 (diff)
downloadllvm-014700c1a8cba203fd21ff129426ba8a426ab244.tar.gz
llvm-014700c1a8cba203fd21ff129426ba8a426ab244.tar.bz2
llvm-014700c1a8cba203fd21ff129426ba8a426ab244.tar.xz
Add infrastructure to allow post instruction printing action triggers.
We'll eventually use this to print comments in asm files and do other fun things. This adds interfaces to the AsmPrinter and changes TableGen to invoke the postInstructionAction when appropriate. It also add parameters to TargetAsmInfo to control comment layout. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h24
-rw-r--r--include/llvm/Target/TargetAsmInfo.h7
2 files changed, 29 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index ef609e4efe..0129711346 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -34,6 +34,7 @@ namespace llvm {
class MachineConstantPoolEntry;
class MachineConstantPoolValue;
class MachineModuleInfo;
+ class MCInst;
class DwarfWriter;
class Mangler;
class Section;
@@ -64,7 +65,7 @@ namespace llvm {
/// DW - If available, this is a pointer to the current dwarf writer.
DwarfWriter *DW;
-
+
public:
/// Output stream on which we're printing assembly code.
///
@@ -332,6 +333,17 @@ namespace llvm {
/// debug tables.
void printDeclare(const MachineInstr *MI) const;
+ /// postInstructionAction - Handling printing of items after the
+ /// instruction iteself has been printed (e.g. comments)
+ void postInstructionAction(const MachineInstr &MI) const {
+ postInstructionActionImpl(MI);
+ EmitComments(MI);
+ }
+ void postInstructionAction(const MCInst &MI) const {
+ postInstructionActionImpl(MI);
+ EmitComments(MI);
+ }
+
protected:
/// EmitZeros - Emit a block of zeros.
///
@@ -396,7 +408,7 @@ namespace llvm {
/// printOffset - This is just convenient handler for printing offsets.
void printOffset(int64_t Offset) const;
-
+
private:
const GlobalValue *findGlobalValue(const Constant* CV);
void EmitLLVMUsedList(Constant *List);
@@ -408,6 +420,14 @@ namespace llvm {
void EmitGlobalConstantFP(const ConstantFP* CFP, unsigned AddrSpace);
void EmitGlobalConstantLargeInt(const ConstantInt* CI, unsigned AddrSpace);
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
+
+ /// EmitComments - Pretty-print comments for instructions
+ void EmitComments(const MachineInstr &MI) const;
+ /// EmitComments - Pretty-print comments for instructions
+ void EmitComments(const MCInst &MI) const;
+
+ virtual void postInstructionActionImpl(const MachineInstr &MI) const {}
+ virtual void postInstructionActionImpl(const MCInst &MI) const {}
};
}
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index 670b0996cc..d031d74657 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -214,6 +214,10 @@ namespace llvm {
/// measure inline asm instructions.
char SeparatorChar; // Defaults to ';'
+ /// CommentColumn - This indicates the comment num (zero-based) at
+ /// which asm comments should be printed.
+ unsigned CommentColumn; // Defaults to 60
+
/// CommentString - This indicates the comment character used by the
/// assembler.
const char *CommentString; // Defaults to "#"
@@ -693,6 +697,9 @@ namespace llvm {
char getSeparatorChar() const {
return SeparatorChar;
}
+ const unsigned getCommentColumn() const {
+ return CommentColumn;
+ }
const char *getCommentString() const {
return CommentString;
}