Replace DebugLocTuple with DILocation.
[oota-llvm.git] / include / llvm / CodeGen / AsmPrinter.h
index 55fc3b0da86b658f5801e6e7bd00ecc5a0605aa1..ca8a1630630f0fef7e7f328d461517048e5e26a5 100644 (file)
 #define LLVM_CODEGEN_ASMPRINTER_H
 
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/Analysis/DebugInfo.h"
 #include "llvm/Support/DebugLoc.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/ADT/DenseMap.h"
 
 namespace llvm {
+  class BlockAddress;
   class GCStrategy;
   class Constant;
   class ConstantArray;
@@ -46,6 +48,7 @@ namespace llvm {
   class MCContext;
   class MCSection;
   class MCStreamer;
+  class MCSymbol;
   class DwarfWriter;
   class Mangler;
   class MCAsmInfo;
@@ -75,14 +78,23 @@ namespace llvm {
     ///
     MachineLoopInfo *LI;
 
-  protected:
+  public:
     /// MMI - If available, this is a pointer to the current MachineModuleInfo.
     MachineModuleInfo *MMI;
     
+  protected:
     /// DW - If available, this is a pointer to the current dwarf writer.
     DwarfWriter *DW;
 
   public:
+    /// Flags to specify different kinds of comments to output in
+    /// assembly code.  These flags carry semantic information not
+    /// otherwise easily derivable from the IR text.
+    ///
+    enum CommentFlag {
+      ReloadReuse = 0x1
+    };
+
     /// Output stream on which we're printing assembly code.
     ///
     formatted_raw_ostream &O;
@@ -120,10 +132,10 @@ namespace llvm {
     ///
     Mangler *Mang;
 
-    /// Cache of mangled name for current function. This is recalculated at the
+    /// The symbol for the current function. This is recalculated at the
     /// beginning of each call to runOnMachineFunction().
     ///
-    std::string CurrentFnName;
+    const MCSymbol *CurrentFnSym;
     
     /// getCurrentSection() - Return the current section we are emitting to.
     const MCSection *getCurrentSection() const;
@@ -133,19 +145,14 @@ namespace llvm {
     ///
     bool VerboseAsm;
 
-    /// ExuberantAsm - Emit many more comments in assembly output if
-    /// this is true.
-    ///
-    bool ExuberantAsm;
-
     /// Private state for PrintSpecial()
     // Assign a unique ID to this machine instruction.
     mutable const MachineInstr *LastMI;
     mutable const Function *LastFn;
     mutable unsigned Counter;
     
-    // Private state for processDebugLock()
-    mutable DebugLocTuple PrevDLT;
+    // Private state for processDebugLoc()
+    mutable DILocation PrevDLT;
 
   protected:
     explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM,
@@ -158,20 +165,10 @@ namespace llvm {
     ///
     bool isVerbose() const { return VerboseAsm; }
 
-    /// getGlobalLinkName - Returns the asm/link name of of the specified
-    /// global variable.  Should be overridden by each target asm printer to
-    /// generate the appropriate value.
-    virtual const std::string &getGlobalLinkName(const GlobalVariable *GV,
-                                                 std::string &LinkName) const;
-
-    /// EmitExternalGlobal - Emit the external reference to a global variable.
-    /// Should be overridden if an indirect reference should be used.
-    virtual void EmitExternalGlobal(const GlobalVariable *GV);
-
-    /// getCurrentFunctionEHName - Called to return the CurrentFnEHName.
-    /// 
-    std::string getCurrentFunctionEHName(const MachineFunction *MF) const;
-
+    /// getFunctionNumber - Return a unique ID for the current function.
+    ///
+    unsigned getFunctionNumber() const { return FunctionNumber; }
+    
   protected:
     /// getAnalysisUsage - Record analysis usage.
     /// 
@@ -182,6 +179,14 @@ namespace llvm {
     /// call this implementation.
     bool doInitialization(Module &M);
 
+    /// EmitStartOfAsmFile - This virtual method can be overridden by targets
+    /// that want to emit something at the start of their file.
+    virtual void EmitStartOfAsmFile(Module &) {}
+    
+    /// EmitEndOfAsmFile - This virtual method can be overridden by targets that
+    /// want to emit something at the end of their file.
+    virtual void EmitEndOfAsmFile(Module &) {}
+    
     /// doFinalization - Shut down the asmprinter.  If you override this in your
     /// pass, you must make sure to call it explicitly.
     bool doFinalization(Module &M);
@@ -217,10 +222,6 @@ namespace llvm {
     /// is being processed from runOnMachineFunction.
     void SetupMachineFunction(MachineFunction &MF);
     
-    /// getFunctionNumber - Return a unique ID for the current function.
-    ///
-    unsigned getFunctionNumber() const { return FunctionNumber; }
-    
     /// IncrementFunctionNumber - Increase Function Number.  AsmPrinters should
     /// not normally call this, as the counter is automatically bumped by
     /// SetupMachineFunction.
@@ -268,7 +269,8 @@ namespace llvm {
     void EOL() const;
     void EOL(const std::string &Comment) const;
     void EOL(const char* Comment) const;
-    
+    void EOL(const char *Comment, unsigned Encoding) const;
+
     /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
     /// unsigned leb128 value.
     void EmitULEB128Bytes(unsigned Value) const;
@@ -296,7 +298,7 @@ namespace llvm {
     /// EmitString - Emit a string with quotes and a null terminator.
     /// Special characters are emitted properly.
     /// @verbatim (Eg. '\t') @endverbatim
-    void EmitString(const std::string &String) const;
+    void EmitString(const StringRef String) const;
     void EmitString(const char *String, unsigned Size) const;
 
     /// EmitFile - Emit a .file directive.
@@ -335,17 +337,39 @@ namespace llvm {
 
     /// EmitComments - Pretty-print comments for instructions
     void EmitComments(const MachineInstr &MI) const;
-    /// EmitComments - Pretty-print comments for instructions
-    void EmitComments(const MCInst &MI) const;
     /// EmitComments - Pretty-print comments for basic blocks
     void EmitComments(const MachineBasicBlock &MBB) const;
 
-    /// printMCInst - Print an MCInst for this target.
-    ///
-    /// Note, this is only a temporary hack to allow the MCStreamer to print
-    /// instructions, do not use this function outside of llvm-mc.
-    virtual void printMCInst(const MCInst *MI);
+    /// GetGlobalValueSymbol - Return the MCSymbol for the specified global
+    /// value.
+    MCSymbol *GetGlobalValueSymbol(const GlobalValue *GV) const;
 
+    /// GetPrivateGlobalValueSymbolStub - Return the MCSymbol for a symbol with
+    /// global value name as its base, with the specified suffix, and where the
+    /// symbol is forced to have private linkage.
+    MCSymbol *GetPrivateGlobalValueSymbolStub(const GlobalValue *GV,
+                                              StringRef Suffix) const;
+    
+    /// GetExternalSymbolSymbol - Return the MCSymbol for the specified
+    /// ExternalSymbol.
+    MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const;
+    
+    /// GetMBBSymbol - Return the MCSymbol corresponding to the specified basic
+    /// block label.
+    MCSymbol *GetMBBSymbol(unsigned MBBID) const;
+    
+    /// GetBlockAddressSymbol - Return the MCSymbol used to satisfy BlockAddress
+    /// uses of the specified basic block.
+    MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA,
+                                    const char *Suffix = "") const;
+    MCSymbol *GetBlockAddressSymbol(const Function *F,
+                                    const BasicBlock *BB,
+                                    const char *Suffix = "") const;
+
+    /// EmitBasicBlockStart - This method prints the label for the specified
+    /// MachineBasicBlock, an alignment (if present) and a comment describing
+    /// it if appropriate.
+    void EmitBasicBlockStart(const MachineBasicBlock *MBB) const;
   protected:
     /// EmitZeros - Emit a block of zeros.
     ///
@@ -365,8 +389,8 @@ namespace llvm {
     virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
 
     /// processDebugLoc - Processes the debug information of each machine
-    /// instruction's DebugLoc.
-    void processDebugLoc(DebugLoc DL);
+    /// instruction's DebugLoc. 
+    void processDebugLoc(const MachineInstr *MI, bool BeforePrintingInsn);
     
     /// printInlineAsm - This method formats and prints the specified machine
     /// instruction that is an inline asm.
@@ -374,15 +398,11 @@ namespace llvm {
 
     /// printImplicitDef - This method prints the specified machine instruction
     /// that is an implicit def.
-    virtual void printImplicitDef(const MachineInstr *MI) const;
-    
-    /// printBasicBlockLabel - This method prints the label for the specified
-    /// MachineBasicBlock
-    virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,
-                                      bool printAlign = false,
-                                      bool printColon = false,
-                                      bool printComment = true) const;
-                                      
+    void printImplicitDef(const MachineInstr *MI) const;
+
+    /// printKill - This method prints the specified kill machine instruction.
+    void printKill(const MachineInstr *MI) const;
+
     /// printPICJumpTableSetLabel - This method prints a set label for the
     /// specified MachineBasicBlock for a jumptable entry.
     virtual void printPICJumpTableSetLabel(unsigned uid,
@@ -399,8 +419,8 @@ namespace llvm {
 
     /// printVisibility - This prints visibility information about symbol, if
     /// this is suported by the target.
-    void printVisibility(const std::string& Name, unsigned Visibility) const;
-
+    void printVisibility(const MCSymbol *Sym, unsigned Visibility) const;
+    
     /// printOffset - This is just convenient handler for printing offsets.
     void printOffset(int64_t Offset) const;