diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-04-06 15:52:58 +0000 | 
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-04-06 15:52:58 +0000 | 
| commit | 9f4a1da9a0a56a0b0a7f8249f34b3cdea6179c41 (patch) | |
| tree | 0dd020f28a4846707f8d60717d9b2921ea187bd8 /include/llvm | |
| parent | b5efedaf2ab20d844d5a21cdef76b55acbf4f01c (diff) | |
Notes
Diffstat (limited to 'include/llvm')
32 files changed, 389 insertions, 400 deletions
diff --git a/include/llvm/ADT/OwningPtr.h b/include/llvm/ADT/OwningPtr.h index cc53c8c30c12..6d9c30597789 100644 --- a/include/llvm/ADT/OwningPtr.h +++ b/include/llvm/ADT/OwningPtr.h @@ -128,7 +128,6 @@ inline void swap(OwningArrayPtr<T> &a, OwningArrayPtr<T> &b) {    a.swap(b);  } -  } // end namespace llvm  #endif diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index a405932beadb..2eff50123a23 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -18,8 +18,6 @@  #include "llvm/CodeGen/MachineFunctionPass.h"  #include "llvm/Support/DebugLoc.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/ADT/DenseMap.h"  namespace llvm {    class BlockAddress; @@ -43,63 +41,33 @@ namespace llvm {    class MachineConstantPoolValue;    class MachineJumpTableInfo;    class MachineModuleInfo; +  class MachineMove; +  class MCAsmInfo;    class MCInst;    class MCContext;    class MCSection;    class MCStreamer;    class MCSymbol; -  class DwarfWriter; +  class DwarfDebug; +  class DwarfException;    class Mangler; -  class MCAsmInfo;    class TargetLoweringObjectFile; +  class TargetData;    class Twine;    class Type; -  class formatted_raw_ostream;    /// AsmPrinter - This class is intended to be used as a driving class for all    /// asm writers.    class AsmPrinter : public MachineFunctionPass { -    static char ID; - -    // GCMetadataPrinters - The garbage collection metadata printer table. -    typedef DenseMap<GCStrategy*,GCMetadataPrinter*> gcp_map_type; -    typedef gcp_map_type::iterator gcp_iterator; -    gcp_map_type GCMetadataPrinters; - -    /// If VerboseAsm is set, a pointer to the loop info for this -    /// function. -    /// -    MachineLoopInfo *LI; - -  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: - -    /// Output stream on which we're printing assembly code. -    /// -    formatted_raw_ostream &O; -      /// Target machine description.      ///      TargetMachine &TM; -    /// getObjFileLowering - Return information about object file lowering. -    TargetLoweringObjectFile &getObjFileLowering() const; -          /// Target Asm Printer information.      ///      const MCAsmInfo *MAI; -    /// Target Register Information. -    /// -    const TargetRegisterInfo *TRI; -      /// OutContext - This is the context for the output file that we are      /// streaming.  This owns all of the global MC-related objects for the      /// generated translation unit. @@ -114,6 +82,9 @@ namespace llvm {      /// The current machine function.      const MachineFunction *MF; +    /// MMI - This is a pointer to the current MachineModuleInfo. +    MachineModuleInfo *MMI; +      /// Name-mangler for global names.      ///      Mangler *Mang; @@ -123,24 +94,28 @@ namespace llvm {      ///      MCSymbol *CurrentFnSym; -    /// getCurrentSection() - Return the current section we are emitting to. -    const MCSection *getCurrentSection() const; +  private: +    // GCMetadataPrinters - The garbage collection metadata printer table. +    void *GCMetadataPrinters;  // Really a DenseMap. -      /// VerboseAsm - Emit comments in assembly output if this is true.      ///      bool VerboseAsm; +    static char ID; +     +    /// If VerboseAsm is set, a pointer to the loop info for this +    /// function. +    MachineLoopInfo *LI; -    /// Private state for PrintSpecial() -    // Assign a unique ID to this machine instruction. -    mutable const MachineInstr *LastMI; -    mutable const Function *LastFn; -    mutable unsigned Counter; -    mutable unsigned SetCounter; +    /// DD - If the target supports dwarf debug info, this pointer is non-null. +    DwarfDebug *DD; +     +    /// DE - If the target supports dwarf exception info, this pointer is +    /// non-null. +    DwarfException *DE;    protected: -    explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM, -                        MCStreamer &Streamer); +    explicit AsmPrinter(TargetMachine &TM, MCStreamer &Streamer);    public:      virtual ~AsmPrinter(); @@ -153,7 +128,20 @@ namespace llvm {      ///      unsigned getFunctionNumber() const; -  protected: +    /// getObjFileLowering - Return information about object file lowering. +    TargetLoweringObjectFile &getObjFileLowering() const; + +    /// getTargetData - Return information about data layout. +    const TargetData &getTargetData() const; + +    /// getCurrentSection() - Return the current section we are emitting to. +    const MCSection *getCurrentSection() const; +     +     +    //===------------------------------------------------------------------===// +    // MachineFunctionPass Implementation. +    //===------------------------------------------------------------------===// +          /// getAnalysisUsage - Record analysis usage.      ///       void getAnalysisUsage(AnalysisUsage &AU) const; @@ -163,41 +151,10 @@ 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); -    /// 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) const; - -    /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM -    /// instruction, using the specified assembler variant.  Targets should -    /// override this to format as appropriate.  This method can return true if -    /// the operand is erroneous. -    virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, -                                 unsigned AsmVariant, const char *ExtraCode); -     -    /// PrintAsmMemoryOperand - Print the specified operand of MI, an INLINEASM -    /// instruction, using the specified assembler variant as an address. -    /// Targets should override this to format as appropriate.  This method can -    /// return true if the operand is erroneous. -    virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, -                                       unsigned AsmVariant,  -                                       const char *ExtraCode); -          /// runOnMachineFunction - Emit the specified function out to the      /// OutStreamer.      virtual bool runOnMachineFunction(MachineFunction &MF) { @@ -207,6 +164,10 @@ namespace llvm {        return false;      }       +    //===------------------------------------------------------------------===// +    // Coarse grained IR lowering routines. +    //===------------------------------------------------------------------===// +          /// SetupMachineFunction - This should be called when a new MachineFunction      /// is being processed from runOnMachineFunction.      void SetupMachineFunction(MachineFunction &MF); @@ -219,19 +180,6 @@ namespace llvm {      /// function.      void EmitFunctionBody(); -    /// EmitInstruction - Targets should implement this to emit instructions. -    virtual void EmitInstruction(const MachineInstr *) { -      assert(0 && "EmitInstruction not implemented"); -    } -     -    /// EmitFunctionBodyStart - Targets can override this to emit stuff before -    /// the first basic block in the function. -    virtual void EmitFunctionBodyStart() {} - -    /// EmitFunctionBodyEnd - Targets can override this to emit stuff after -    /// the last basic block in the function. -    virtual void EmitFunctionBodyEnd() {} -          /// EmitConstantPool - Print to the current output stream assembly      /// representations of the constants in the constant pool MCP. This is      /// used to print out constants which have been "spilled to memory" by @@ -252,36 +200,6 @@ namespace llvm {      /// do nothing and return false.      bool EmitSpecialLLVMGlobal(const GlobalVariable *GV); -  public: -    //===------------------------------------------------------------------===// -    // Emission and print routines -    // - -    /// EmitInt8 - Emit a byte directive and value. -    /// -    void EmitInt8(int Value) const; - -    /// EmitInt16 - Emit a short directive and value. -    /// -    void EmitInt16(int Value) const; - -    /// EmitInt32 - Emit a long directive and value. -    /// -    void EmitInt32(int Value) const; - -    /// EmitInt64 - Emit a long long directive and value. -    /// -    void EmitInt64(uint64_t Value) const; -     -     -    /// EmitLabelDifference - Emit something like ".long Hi-Lo" where the size -    /// in bytes of the directive is specified by Size and Hi/Lo specify the -    /// labels.  This implicitly uses .set if it is available. -    void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, -                             unsigned Size) const; - -    //===------------------------------------------------------------------===// -      /// EmitAlignment - Emit an alignment directive to the specified power of      /// two boundary.  For example, if you pass in 3 here, you will get an 8      /// byte alignment.  If a global value is specified, and if that global has @@ -301,11 +219,69 @@ namespace llvm {      void EmitAlignment(unsigned NumBits, const GlobalValue *GV = 0,                         unsigned ForcedAlignBits = 0,                         bool UseFillExpr = true) 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; +     +     +    /// EmitGlobalConstant - Print a general LLVM constant to the .s file. +    void EmitGlobalConstant(const Constant *CV, unsigned AddrSpace = 0); +     +     +    //===------------------------------------------------------------------===// +    // Overridable Hooks +    //===------------------------------------------------------------------===// +     +    // Targets can, or in the case of EmitInstruction, must implement these to +    // customize output. +     +    /// 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 &) {} +     +    /// EmitFunctionBodyStart - Targets can override this to emit stuff before +    /// the first basic block in the function. +    virtual void EmitFunctionBodyStart() {} +     +    /// EmitFunctionBodyEnd - Targets can override this to emit stuff after +    /// the last basic block in the function. +    virtual void EmitFunctionBodyEnd() {} +     +    /// EmitInstruction - Targets should implement this to emit instructions. +    virtual void EmitInstruction(const MachineInstr *) { +      assert(0 && "EmitInstruction not implemented"); +    } +     +    virtual void EmitFunctionEntryLabel(); +     +    virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); +     +    /// isBlockOnlyReachableByFallthough - Return true if the basic block has +    /// exactly one predecessor and the control transfer mechanism between +    /// the predecessor and this block is a fall-through. +    virtual bool +    isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const; +     +    //===------------------------------------------------------------------===// +    // Symbol Lowering Routines. +    //===------------------------------------------------------------------===// +  public: -    /// printDeclare - This method prints a local variable declaration used by -    /// debug tables. -    void printDeclare(const MachineInstr *MI) const; - +    /// GetTempSymbol - Return the MCSymbol corresponding to the assembler +    /// temporary label with the specified stem and unique ID. +    MCSymbol *GetTempSymbol(StringRef Name, unsigned ID) const; +     +    /// GetTempSymbol - Return an assembler temporary label with the specified +    /// stem. +    MCSymbol *GetTempSymbol(StringRef Name) const; +     +          /// GetSymbolWithGlobalValueBase - 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 if ForcePrivate is true. @@ -332,49 +308,131 @@ namespace llvm {      MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;      MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) 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; +     //===------------------------------------------------------------------===// +    // Emission Helper Routines. +    //===------------------------------------------------------------------===// +  public: +    /// printOffset - This is just convenient handler for printing offsets. +    void printOffset(int64_t Offset, raw_ostream &OS) const; +    /// EmitInt8 - Emit a byte directive and value. +    /// +    void EmitInt8(int Value) const; -    // Data emission. +    /// EmitInt16 - Emit a short directive and value. +    /// +    void EmitInt16(int Value) const; -    /// EmitGlobalConstant - Print a general LLVM constant to the .s file. -    void EmitGlobalConstant(const Constant* CV, unsigned AddrSpace = 0); +    /// EmitInt32 - Emit a long directive and value. +    /// +    void EmitInt32(int Value) const; -  protected: -    virtual void EmitFunctionEntryLabel(); +    /// EmitLabelDifference - Emit something like ".long Hi-Lo" where the size +    /// in bytes of the directive is specified by Size and Hi/Lo specify the +    /// labels.  This implicitly uses .set if it is available. +    void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, +                             unsigned Size) const; -    virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); - -    /// printOffset - This is just convenient handler for printing offsets. -    void printOffset(int64_t Offset) const; - -    /// isBlockOnlyReachableByFallthough - Return true if the basic block has -    /// exactly one predecessor and the control transfer mechanism between -    /// the predecessor and this block is a fall-through. -    virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const; +    //===------------------------------------------------------------------===// +    // Dwarf Emission Helper Routines +    //===------------------------------------------------------------------===// +     +    /// EmitSLEB128 - emit the specified signed leb128 value. +    void EmitSLEB128(int Value, const char *Desc = 0) const; +     +    /// EmitULEB128 - emit the specified unsigned leb128 value. +    void EmitULEB128(unsigned Value, const char *Desc = 0, +                     unsigned PadTo = 0) const; +     +    /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value. +    void EmitCFAByte(unsigned Val) const; +    /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an +    /// encoding.  If verbose assembly output is enabled, we output comments +    /// describing the encoding.  Desc is a string saying what the encoding is +    /// specifying (e.g. "LSDA"). +    void EmitEncodingByte(unsigned Val, const char *Desc = 0) const; +     +    /// GetSizeOfEncodedValue - Return the size of the encoding in bytes. +    unsigned GetSizeOfEncodedValue(unsigned Encoding) const; +     +    /// EmitReference - Emit a reference to a label with a specified encoding. +    /// +    void EmitReference(const MCSymbol *Sym, unsigned Encoding) const; +    void EmitReference(const GlobalValue *GV, unsigned Encoding) const; +     +    /// EmitSectionOffset - Emit the 4-byte offset of Label from the start of +    /// its section.  This can be done with a special directive if the target +    /// supports it (e.g. cygwin) or by emitting it as an offset from a label at +    /// the start of the section. +    /// +    /// SectionLabel is a temporary label emitted at the start of the section +    /// that Label lives in. +    void EmitSectionOffset(const MCSymbol *Label, +                           const MCSymbol *SectionLabel) const; +     +    //===------------------------------------------------------------------===// +    // Dwarf Lowering Routines +    //===------------------------------------------------------------------===// +     +    /// EmitFrameMoves - Emit frame instructions to describe the layout of the +    /// frame. +    void EmitFrameMoves(const std::vector<MachineMove> &Moves,  +                        MCSymbol *BaseLabel, bool isEH) const; +     +     +    //===------------------------------------------------------------------===// +    // Inline Asm Support +    //===------------------------------------------------------------------===// +  public: +    // These are hooks that targets can override to implement inline asm +    // support.  These should probably be moved out of AsmPrinter someday. +     +    /// 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, raw_ostream &OS, +                              const char *Code) const; +     +    /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM +    /// instruction, using the specified assembler variant.  Targets should +    /// override this to format as appropriate.  This method can return true if +    /// the operand is erroneous. +    virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, +                                 unsigned AsmVariant, const char *ExtraCode, +                                 raw_ostream &OS); +     +    /// PrintAsmMemoryOperand - Print the specified operand of MI, an INLINEASM +    /// instruction, using the specified assembler variant as an address. +    /// Targets should override this to format as appropriate.  This method can +    /// return true if the operand is erroneous. +    virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, +                                       unsigned AsmVariant,  +                                       const char *ExtraCode, +                                       raw_ostream &OS); +        private: +    /// Private state for PrintSpecial() +    // Assign a unique ID to this machine instruction. +    mutable const MachineInstr *LastMI; +    mutable unsigned LastFn; +    mutable unsigned Counter; +    mutable unsigned SetCounter; -    /// processDebugLoc - Processes the debug information of each machine -    /// instruction's DebugLoc.  -    void processDebugLoc(const MachineInstr *MI, bool BeforePrintingInsn); +    /// EmitInlineAsm - Emit a blob of inline asm to the output streamer. +    void EmitInlineAsm(StringRef Str, unsigned LocCookie) const; -    void printLabelInst(const MachineInstr *MI) const; - -    /// printInlineAsm - This method formats and prints the specified machine +    /// EmitInlineAsm - This method formats and emits the specified machine      /// instruction that is an inline asm. -    void printInlineAsm(const MachineInstr *MI) const; - -    /// printImplicitDef - This method prints the specified machine instruction -    /// that is an implicit def. -    void printImplicitDef(const MachineInstr *MI) const; - -    /// printKill - This method prints the specified kill machine instruction. -    void printKill(const MachineInstr *MI) const; +    void EmitInlineAsm(const MachineInstr *MI) const; +    //===------------------------------------------------------------------===// +    // Internal Implementation Details +    //===------------------------------------------------------------------===// +          /// EmitVisibility - This emits visibility information about symbol, if      /// this is suported by the target.      void EmitVisibility(MCSymbol *Sym, unsigned Visibility) const; diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h deleted file mode 100644 index 494400ee2c98..000000000000 --- a/include/llvm/CodeGen/DwarfWriter.h +++ /dev/null @@ -1,96 +0,0 @@ -//===-- llvm/CodeGen/DwarfWriter.h - Dwarf Framework ------------*- C++ -*-===// -// -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains support for writing Dwarf debug and exception info into -// asm files.  For Details on the Dwarf 3 specfication see DWARF Debugging -// Information Format V.3 reference manual http://dwarf.freestandards.org , -// -// The role of the Dwarf Writer class is to extract information from the -// MachineModuleInfo object, organize it in Dwarf form and then emit it into asm -// the current asm file using data and high level Dwarf directives. -//  -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_DWARFWRITER_H -#define LLVM_CODEGEN_DWARFWRITER_H - -#include "llvm/Pass.h" -#include "llvm/Target/TargetMachine.h" - -namespace llvm { - -class AsmPrinter; -class DwarfDebug; -class DwarfException; -class MachineModuleInfo; -class MachineFunction; -class MachineInstr; -class Value; -class Module; -class MDNode; -class MCAsmInfo; -class MCSymbol; -class raw_ostream; -class Instruction; -class DICompileUnit; -class DISubprogram; -class DIVariable; - -//===----------------------------------------------------------------------===// -// DwarfWriter - Emits Dwarf debug and exception handling directives. -// - -class DwarfWriter : public ImmutablePass { -private: -  /// DD - Provides the DwarfWriter debug implementation. -  /// -  DwarfDebug *DD; - -  /// DE - Provides the DwarfWriter exception implementation. -  /// -  DwarfException *DE; - -public: -  static char ID; // Pass identification, replacement for typeid - -  DwarfWriter(); -  virtual ~DwarfWriter(); - -  //===--------------------------------------------------------------------===// -  // Main entry points. -  // -   -  /// BeginModule - Emit all Dwarf sections that should come prior to the -  /// content. -  void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS, -                   AsmPrinter *A, const MCAsmInfo *T); -   -  /// EndModule - Emit all Dwarf sections that should come after the content. -  /// -  void EndModule(); -   -  /// BeginFunction - Gather pre-function debug information.  Assumes being  -  /// emitted immediately after the function entry point. -  void BeginFunction(const MachineFunction *MF); -   -  /// EndFunction - Gather and emit post-function debug information. -  /// -  void EndFunction(const MachineFunction *MF); - -  /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should -  /// be emitted. -  bool ShouldEmitDwarfDebug() const; - -  void BeginScope(const MachineInstr *MI); -  void EndScope(const MachineInstr *MI); -}; - -} // end llvm namespace - -#endif diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index 9d0f0d9e57b9..8d336654411c 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -27,8 +27,6 @@ class MachineBasicBlock;  class MachineConstantPool;  class MachineFunction;  class MachineFrameInfo; -class MachineModuleInfo; -class DwarfWriter;  class MachineRegisterInfo;  class TargetData;  class TargetInstrInfo; @@ -50,8 +48,6 @@ protected:    SmallSet<Instruction*, 8> &CatchInfoLost;  #endif    MachineFunction &MF; -  MachineModuleInfo *MMI; -  DwarfWriter *DW;    MachineRegisterInfo &MRI;    MachineFrameInfo &MFI;    MachineConstantPool &MCP; @@ -116,8 +112,6 @@ public:  protected:    FastISel(MachineFunction &mf, -           MachineModuleInfo *mmi, -           DwarfWriter *dw,             DenseMap<const Value *, unsigned> &vm,             DenseMap<const BasicBlock *, MachineBasicBlock *> &bm,             DenseMap<const AllocaInst *, int> &am diff --git a/include/llvm/CodeGen/GCMetadataPrinter.h b/include/llvm/CodeGen/GCMetadataPrinter.h index 62875c398b89..3703545bb6f6 100644 --- a/include/llvm/CodeGen/GCMetadataPrinter.h +++ b/include/llvm/CodeGen/GCMetadataPrinter.h @@ -27,8 +27,6 @@  namespace llvm {    class GCMetadataPrinter; -  class raw_ostream; -  class MCAsmInfo;    /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the    /// defaults from Registry. @@ -63,11 +61,9 @@ namespace llvm {      iterator end()   { return S->end();   }      /// beginAssembly/finishAssembly - Emit module metadata as assembly code. -    virtual void beginAssembly(raw_ostream &OS, AsmPrinter &AP, -                               const MCAsmInfo &MAI); +    virtual void beginAssembly(AsmPrinter &AP); -    virtual void finishAssembly(raw_ostream &OS, AsmPrinter &AP, -                                const MCAsmInfo &MAI); +    virtual void finishAssembly(AsmPrinter &AP);      virtual ~GCMetadataPrinter();    }; diff --git a/include/llvm/CodeGen/MachineDominators.h b/include/llvm/CodeGen/MachineDominators.h index 086528aaf57c..48695d500b19 100644 --- a/include/llvm/CodeGen/MachineDominators.h +++ b/include/llvm/CodeGen/MachineDominators.h @@ -156,8 +156,13 @@ public:    inline void splitBlock(MachineBasicBlock* NewBB) {      DT->splitBlock(NewBB);    } -   -   + +  /// isReachableFromEntry - Return true if A is dominated by the entry +  /// block of the function containing it. +  bool isReachableFromEntry(MachineBasicBlock *A) { +    return DT->isReachableFromEntry(A); +  } +    virtual void releaseMemory();    virtual void print(raw_ostream &OS, const Module*) const; diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index 043e97f9a7cd..c7c53006f687 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -14,12 +14,9 @@  #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H  #define LLVM_CODEGEN_MACHINEFRAMEINFO_H -#include "llvm/ADT/BitVector.h" -#include "llvm/ADT/DenseMap.h"  #include "llvm/ADT/SmallVector.h"  #include "llvm/System/DataTypes.h"  #include <cassert> -#include <limits>  #include <vector>  namespace llvm { @@ -27,26 +24,21 @@ class raw_ostream;  class TargetData;  class TargetRegisterClass;  class Type; -class MachineModuleInfo;  class MachineFunction;  class MachineBasicBlock;  class TargetFrameInfo; +class BitVector;  /// The CalleeSavedInfo class tracks the information need to locate where a  /// callee saved register in the current frame.    class CalleeSavedInfo { - -private:    unsigned Reg;    const TargetRegisterClass *RegClass;    int FrameIdx;  public:    CalleeSavedInfo(unsigned R, const TargetRegisterClass *RC, int FI = 0) -  : Reg(R) -  , RegClass(RC) -  , FrameIdx(FI) -  {} +  : Reg(R), RegClass(RC), FrameIdx(FI) {}    // Accessors.    unsigned getReg()                        const { return Reg; } @@ -188,13 +180,6 @@ class MachineFrameInfo {    /// spill slots.    SmallVector<bool, 8> SpillObjects; -  /// MMI - This field is set (via setMachineModuleInfo) by a module info -  /// consumer (ex. DwarfWriter) to indicate that frame layout information -  /// should be acquired.  Typically, it's the responsibility of the target's -  /// TargetRegisterInfo prologue/epilogue emitting code to inform -  /// MachineModuleInfo of frame layouts. -  MachineModuleInfo *MMI; -      /// TargetFrameInfo - Target information about frame layout.    ///    const TargetFrameInfo &TFI; @@ -208,7 +193,6 @@ public:      StackProtectorIdx = -1;      MaxCallFrameSize = 0;      CSIValid = false; -    MMI = 0;    }    /// hasStackObjects - Return true if there are any stack objects in this @@ -451,14 +435,6 @@ public:    /// method always returns an empty set.    BitVector getPristineRegs(const MachineBasicBlock *MBB) const; -  /// getMachineModuleInfo - Used by a prologue/epilogue -  /// emitter (TargetRegisterInfo) to provide frame layout information.  -  MachineModuleInfo *getMachineModuleInfo() const { return MMI; } - -  /// setMachineModuleInfo - Used by a meta info consumer (DwarfWriter) to -  /// indicate that frame layout information should be gathered. -  void setMachineModuleInfo(MachineModuleInfo *mmi) { MMI = mmi; } -    /// print - Used by the MachineFunction printer to print information about    /// stack objects.  Implemented in MachineFunction.cpp    /// diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 59b171850d0d..b3609c2ea73e 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -32,6 +32,7 @@ class MachineRegisterInfo;  class MachineFrameInfo;  class MachineConstantPool;  class MachineJumpTableInfo; +class MachineModuleInfo;  class MCContext;  class Pass;  class TargetMachine; @@ -72,7 +73,8 @@ class MachineFunction {    Function *Fn;    const TargetMachine &Target;    MCContext &Ctx; - +  MachineModuleInfo &MMI; +      // RegInfo - Information about each register in use in the function.    MachineRegisterInfo *RegInfo; @@ -107,8 +109,8 @@ class MachineFunction {    typedef ilist<MachineBasicBlock> BasicBlockListType;    BasicBlockListType BasicBlocks; -  // Default debug location. Used to print out the debug label at the beginning -  // of a function. +  /// Default debug location. Used to print out the debug label at the beginning +  /// of a function.    DebugLoc DefaultDebugLoc;    /// FunctionNumber - This provides a unique ID for each function emitted in @@ -116,17 +118,17 @@ class MachineFunction {    ///    unsigned FunctionNumber; -  // The alignment of the function. +  /// The alignment of the function.    unsigned Alignment;    MachineFunction(const MachineFunction &); // DO NOT IMPLEMENT    void operator=(const MachineFunction&);   // DO NOT IMPLEMENT -  public:    MachineFunction(Function *Fn, const TargetMachine &TM, unsigned FunctionNum, -                  MCContext &Ctx); +                  MachineModuleInfo &MMI);    ~MachineFunction(); +  MachineModuleInfo &getMMI() const { return MMI; }    MCContext &getContext() const { return Ctx; }    /// getFunction - Return the LLVM function that this machine code represents diff --git a/include/llvm/CodeGen/MachineFunctionAnalysis.h b/include/llvm/CodeGen/MachineFunctionAnalysis.h index ee2c6ddc81f3..75dbaab973d8 100644 --- a/include/llvm/CodeGen/MachineFunctionAnalysis.h +++ b/include/llvm/CodeGen/MachineFunctionAnalysis.h @@ -39,7 +39,7 @@ public:    CodeGenOpt::Level getOptLevel() const { return OptLevel; }  private: -  virtual bool doInitialization(Module &) { NextFnNum = 1; return false; } +  virtual bool doInitialization(Module &M);    virtual bool runOnFunction(Function &F);    virtual void releaseMemory();    virtual void getAnalysisUsage(AnalysisUsage &AU) const; diff --git a/include/llvm/CodeGen/MachineModuleInfo.h b/include/llvm/CodeGen/MachineModuleInfo.h index d610390b6357..17da43b7d621 100644 --- a/include/llvm/CodeGen/MachineModuleInfo.h +++ b/include/llvm/CodeGen/MachineModuleInfo.h @@ -100,6 +100,9 @@ class MachineModuleInfo : public ImmutablePass {    /// Context - This is the MCContext used for the entire code generator.    MCContext Context; +  /// TheModule - This is the LLVM Module being worked on. +  Module *TheModule; +      /// ObjFileMMI - This is the object-file-format-specific implementation of    /// MachineModuleInfoImpl, which lets targets accumulate whatever info they    /// want. @@ -176,6 +179,9 @@ public:    const MCContext &getContext() const { return Context; }    MCContext &getContext() { return Context; } +  void setModule(Module *M) { TheModule = M; } +  Module *getModule() const { return TheModule; } +      /// getInfo - Keep track of various per-function pieces of information for    /// backends that would like to do so.    /// diff --git a/include/llvm/CodeGen/ScheduleDAG.h b/include/llvm/CodeGen/ScheduleDAG.h index 81e9ab31529e..9563d0811cf5 100644 --- a/include/llvm/CodeGen/ScheduleDAG.h +++ b/include/llvm/CodeGen/ScheduleDAG.h @@ -27,7 +27,6 @@ namespace llvm {    class SUnit;    class MachineConstantPool;    class MachineFunction; -  class MachineModuleInfo;    class MachineRegisterInfo;    class MachineInstr;    class TargetRegisterInfo; diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index ef5d7e2a8959..5dd0aa8705f3 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -29,11 +29,9 @@  namespace llvm {  class AliasAnalysis; -class DwarfWriter;  class FunctionLoweringInfo;  class MachineConstantPoolValue;  class MachineFunction; -class MachineModuleInfo;  class MDNode;  class SDNodeOrdering;  class SDDbgValue; @@ -122,9 +120,7 @@ class SelectionDAG {    TargetLowering &TLI;    MachineFunction *MF;    FunctionLoweringInfo &FLI; -  MachineModuleInfo *MMI; -  DwarfWriter *DW; -  LLVMContext* Context; +  LLVMContext *Context;    /// EntryNode - The starting token.    SDNode EntryNode; @@ -182,7 +178,7 @@ public:    /// init - Prepare this SelectionDAG to process code in the given    /// MachineFunction.    /// -  void init(MachineFunction &mf, MachineModuleInfo *mmi, DwarfWriter *dw); +  void init(MachineFunction &mf);    /// clear - Clear state and free memory necessary to make this    /// SelectionDAG ready to process a new block. @@ -193,8 +189,6 @@ public:    const TargetMachine &getTarget() const;    TargetLowering &getTargetLoweringInfo() const { return TLI; }    FunctionLoweringInfo &getFunctionLoweringInfo() const { return FLI; } -  MachineModuleInfo *getMachineModuleInfo() const { return MMI; } -  DwarfWriter *getDwarfWriter() const { return DW; }    LLVMContext *getContext() const {return Context; }    /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'. @@ -532,17 +526,17 @@ public:    SDValue getStackArgumentTokenFactor(SDValue Chain);    SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, -                    SDValue Size, unsigned Align, bool AlwaysInline, +                    SDValue Size, unsigned Align, bool isVol, bool AlwaysInline,                      const Value *DstSV, uint64_t DstSVOff,                      const Value *SrcSV, uint64_t SrcSVOff);    SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, -                     SDValue Size, unsigned Align, +                     SDValue Size, unsigned Align, bool isVol,                       const Value *DstSV, uint64_t DstOSVff,                       const Value *SrcSV, uint64_t SrcSVOff);    SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, -                    SDValue Size, unsigned Align, +                    SDValue Size, unsigned Align, bool isVol,                      const Value *DstSV, uint64_t DstSVOff);    /// getSetCC - Helper function to make it easier to build SetCC's if you just diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index def09c76fcbe..3c000f032c97 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -29,8 +29,6 @@ namespace llvm {    class MachineBasicBlock;    class MachineFunction;    class MachineInstr; -  class MachineModuleInfo; -  class DwarfWriter;    class TargetLowering;    class TargetInstrInfo;    class FunctionLoweringInfo; @@ -284,8 +282,6 @@ private:                      const SDValue *Ops, unsigned NumOps, unsigned EmitNodeInfo);    void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF, -                            MachineModuleInfo *MMI, -                            DwarfWriter *DW,                              const TargetInstrInfo &TII);    void FinishBasicBlock(); diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h index d86b33ef50a8..bd8a8c4e9d39 100644 --- a/include/llvm/IntrinsicInst.h +++ b/include/llvm/IntrinsicInst.h @@ -133,6 +133,13 @@ namespace llvm {        return getAlignmentCst()->getZExtValue();      } +    ConstantInt *getVolatileCst() const { +      return cast<ConstantInt>(const_cast<Value*>(getOperand(5))); +    } +    bool isVolatile() const { +      return getVolatileCst()->getZExtValue() != 0; +    } +      /// getDest - This is just like getRawDest, but it strips off any cast      /// instructions that feed it, giving the original input.  The returned      /// value is guaranteed to be a pointer. @@ -155,7 +162,11 @@ namespace llvm {      void setAlignment(Constant* A) {        setOperand(4, A);      } -     + +    void setVolatile(Constant* V) { +      setOperand(5, V); +    } +      const Type *getAlignmentType() const {        return getOperand(4)->getType();      } diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td index d66e80fb22fb..8bbfd774bdb5 100644 --- a/include/llvm/Intrinsics.td +++ b/include/llvm/Intrinsics.td @@ -224,16 +224,16 @@ def int_stackprotector : Intrinsic<[],  //  def int_memcpy  : Intrinsic<[], -                             [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, -                              llvm_i32_ty], +                             [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, +                              llvm_i32_ty, llvm_i1_ty],                              [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>;  def int_memmove : Intrinsic<[], -                            [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, -                             llvm_i32_ty], +                            [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, +                             llvm_i32_ty, llvm_i1_ty],                              [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>;  def int_memset  : Intrinsic<[], -                            [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, -                             llvm_i32_ty], +                            [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, +                             llvm_i32_ty, llvm_i1_ty],                              [IntrWriteArgMem, NoCapture<0>]>;  // These functions do not actually read memory, but they are sensitive to the diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index ea7f4a2d8e9d..43548407f681 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -50,6 +50,24 @@ public:    /// custom metadata IDs registered in this LLVMContext.   ID #0 is not used,    /// so it is filled in as an empty string.    void getMDKindNames(SmallVectorImpl<StringRef> &Result) const; +   +  /// setInlineAsmDiagnosticHandler - This method sets a handler that is invoked +  /// when problems with inline asm are detected by the backend.  The first +  /// argument is a function pointer (of type SourceMgr::DiagHandlerTy) and the +  /// second is a context pointer that gets passed into the DiagHandler. +  /// +  /// LLVMContext doesn't take ownership or interpreter either of these +  /// pointers. +  void setInlineAsmDiagnosticHandler(void *DiagHandler, void *DiagContext = 0); + +  /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by +  /// setInlineAsmDiagnosticHandler. +  void *getInlineAsmDiagnosticHandler() const; + +  /// getInlineAsmDiagnosticContext - Return the diagnostic context set by +  /// setInlineAsmDiagnosticHandler. +  void *getInlineAsmDiagnosticContext() const; +    };  /// getGlobalContext - Returns a global context.  This is for LLVM clients that diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 4dfe9f0e52eb..33def8618990 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -223,14 +223,6 @@ namespace llvm {      //===--- Dwarf Emission Directives -----------------------------------===// -    /// AbsoluteDebugSectionOffsets - True if we should emit abolute section -    /// offsets for debug information. -    bool AbsoluteDebugSectionOffsets;        // Defaults to false. - -    /// AbsoluteEHSectionOffsets - True if we should emit abolute section -    /// offsets for EH information. Defaults to false. -    bool AbsoluteEHSectionOffsets; -      /// HasLEB128 - True if target asm supports leb128 directives.      bool HasLEB128;                          // Defaults to false. @@ -389,12 +381,6 @@ namespace llvm {      MCSymbolAttr getProtectedVisibilityAttr() const {        return ProtectedVisibilityAttr;      } -    bool isAbsoluteDebugSectionOffsets() const { -      return AbsoluteDebugSectionOffsets; -    } -    bool isAbsoluteEHSectionOffsets() const { -      return AbsoluteEHSectionOffsets; -    }      bool hasLEB128() const {        return HasLEB128;      } diff --git a/include/llvm/MC/MCInstPrinter.h b/include/llvm/MC/MCInstPrinter.h index d2ddc5bb42b2..4839a83dba5c 100644 --- a/include/llvm/MC/MCInstPrinter.h +++ b/include/llvm/MC/MCInstPrinter.h @@ -20,26 +20,23 @@ class StringRef;  /// that converts an MCInst to valid target assembly syntax.  class MCInstPrinter {  protected: -  /// O - The main stream to emit instruction text to. -  raw_ostream &O; -      /// CommentStream - a stream that comments can be emitted to if desired.    /// Each comment must end with a newline.  This will be null if verbose    /// assembly emission is disable.    raw_ostream *CommentStream;    const MCAsmInfo &MAI;  public: -  MCInstPrinter(raw_ostream &o, const MCAsmInfo &mai) -    : O(o), CommentStream(0), MAI(mai) {} +  MCInstPrinter(const MCAsmInfo &mai) +    : CommentStream(0), MAI(mai) {}    virtual ~MCInstPrinter();    /// setCommentStream - Specify a stream to emit comments to.    void setCommentStream(raw_ostream &OS) { CommentStream = &OS; } -  /// printInst - Print the specified MCInst to the current raw_ostream. +  /// printInst - Print the specified MCInst to the specified raw_ostream.    /// -  virtual void printInst(const MCInst *MI) = 0; +  virtual void printInst(const MCInst *MI, raw_ostream &OS) = 0;    /// getOpcodeName - Return the name of the specified opcode enum (e.g.    /// "MOV32ri") or empty if we can't resolve it. diff --git a/include/llvm/MC/MCParser/AsmParser.h b/include/llvm/MC/MCParser/AsmParser.h index 06e0920950d4..23f4a1fb72a2 100644 --- a/include/llvm/MC/MCParser/AsmParser.h +++ b/include/llvm/MC/MCParser/AsmParser.h @@ -64,7 +64,7 @@ public:              const MCAsmInfo &MAI);    ~AsmParser(); -  bool Run(bool NoInitialTextSection); +  bool Run(bool NoInitialTextSection, bool NoFinalize = false);    void AddDirectiveHandler(StringRef Directive, diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 4a1c46ccb926..e9c19fce20aa 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -39,6 +39,14 @@ namespace llvm {      virtual void PrintSwitchToSection(const MCAsmInfo &MAI,                                        raw_ostream &OS) const = 0; + +    /// isBaseAddressKnownZero - Return true if we know that this section will +    /// get a base address of zero.  In cases where we know that this is true we +    /// can emit section offsets as direct references to avoid a subtraction +    /// from the base of the section, saving a relocation. +    virtual bool isBaseAddressKnownZero() const { +      return false; +    }    };    class MCSectionCOFF : public MCSection { diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index cdd2f73b3484..e550cd2c1111 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -172,6 +172,11 @@ public:    virtual void PrintSwitchToSection(const MCAsmInfo &MAI,                                      raw_ostream &OS) const; +  /// isBaseAddressKnownZero - We know that non-allocatable sections (like +  /// debug info) have a base of zero. +  virtual bool isBaseAddressKnownZero() const { +    return (getFlags() & SHF_ALLOC) == 0; +  }    /// PrintTargetSpecificSectionFlags - Targets that define their own    /// MCSectionELF subclasses with target specific section flags should diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index bdcfdb2debee..4667c41d6235 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -62,9 +62,13 @@ class TargetAsmBackend;      /// @name Assembly File Formatting.      /// @{ -    /// isVerboseAsm - Return true if this streamer supports verbose assembly at -    /// all. +    /// isVerboseAsm - Return true if this streamer supports verbose assembly +    /// and if it is enabled.      virtual bool isVerboseAsm() const { return false; } +     +    /// hasRawTextSupport - Return true if this asm streamer supports emitting +    /// unformatted text to the .s file with EmitRawText. +    virtual bool hasRawTextSupport() const { return false; }      /// AddComment - Add a comment that can be emitted to the generated .s      /// file if applicable as a QoI issue to make the output of the compiler @@ -278,6 +282,12 @@ class TargetAsmBackend;      /// section.      virtual void EmitInstruction(const MCInst &Inst) = 0; +    /// EmitRawText - If this file is backed by a assembly streamer, this dumps +    /// the specified string in the output .s file.  This capability is +    /// indicated by the hasRawTextSupport() predicate.  By default this aborts. +    virtual void EmitRawText(StringRef String); +    void EmitRawText(const Twine &String); +          /// Finish - Finish emission of machine code and flush any output.      virtual void Finish() = 0;    }; diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index eb6c2d1e25a7..148d47e785c7 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -202,7 +202,7 @@ public:                                                (char *)Slab + Slab->Size;        for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) {          Ptr = Allocator.AlignPtr(Ptr, alignof<T>()); -	if (Ptr + sizeof(T) <= End) +        if (Ptr + sizeof(T) <= End)            reinterpret_cast<T*>(Ptr)->~T();        }        Slab = Slab->NextPtr; diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index faa8fa3aee2b..660c9f8001b2 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -917,6 +917,11 @@ public:      Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };      return Insert(CallInst::Create(Callee, Args, Args+4), Name);    } +  CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, +                        Value *Arg4, Value *Arg5, const Twine &Name = "") { +    Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; +    return Insert(CallInst::Create(Callee, Args, Args+5), Name); +  }    template<typename InputIterator>    CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, diff --git a/include/llvm/Support/IRReader.h b/include/llvm/Support/IRReader.h index 66314e057ef6..2a43c5fa906a 100644 --- a/include/llvm/Support/IRReader.h +++ b/include/llvm/Support/IRReader.h @@ -38,7 +38,8 @@ namespace llvm {        std::string ErrMsg;        Module *M = getLazyBitcodeModule(Buffer, Context, &ErrMsg);        if (M == 0) { -        Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, ""); +        Err = SMDiagnostic(SMLoc(), Buffer->getBufferIdentifier(), -1, -1, +                           ErrMsg, "");          // ParseBitcodeFile does not take ownership of the Buffer in the          // case of an error.          delete Buffer; @@ -59,7 +60,7 @@ namespace llvm {      std::string ErrMsg;      MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);      if (F == 0) { -      Err = SMDiagnostic(Filename, -1, -1, +      Err = SMDiagnostic(SMLoc(), Filename, -1, -1,                           "Could not open input file '" + Filename + "'", "");        return 0;      } @@ -81,7 +82,8 @@ namespace llvm {        // ParseBitcodeFile does not take ownership of the Buffer.        delete Buffer;        if (M == 0) -        Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, ""); +        Err = SMDiagnostic(SMLoc(), Buffer->getBufferIdentifier(), +                           -1, -1, ErrMsg, "");        return M;      } @@ -97,7 +99,7 @@ namespace llvm {      std::string ErrMsg;      MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);      if (F == 0) { -      Err = SMDiagnostic(Filename, -1, -1, +      Err = SMDiagnostic(SMLoc(), Filename, -1, -1,                           "Could not open input file '" + Filename + "'", "");        return 0;      } diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index f56241c5790b..80d11ae062f7 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -459,14 +459,14 @@ inline int64_t abs64(int64_t x) {  /// SignExtend32 - Sign extend B-bit number x to 32-bit int.  /// Usage int32_t r = SignExtend32<5>(x); -template <unsigned B> inline int32_t SignExtend32(int32_t x) { -  return (x << (32 - B)) >> (32 - B); +template <unsigned B> inline int32_t SignExtend32(uint32_t x) { +  return int32_t(x << (32 - B)) >> (32 - B);  }  /// SignExtend64 - Sign extend B-bit number x to 64-bit int.  /// Usage int64_t r = SignExtend64<5>(x); -template <unsigned B> inline int64_t SignExtend64(int32_t x) { -  return (x << (64 - B)) >> (64 - B); +template <unsigned B> inline int64_t SignExtend64(uint64_t x) { +  return int64_t(x << (64 - B)) >> (64 - B);  }  } // End llvm namespace diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index fcea5d20de4b..ef7af6968405 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -65,13 +65,13 @@ public:    /// getMemBuffer - Open the specified memory range as a MemoryBuffer.  Note    /// that EndPtr[0] must be a null byte and be accessible! -  static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr, +  static MemoryBuffer *getMemBuffer(StringRef InputData,                                      const char *BufferName = "");    /// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,    /// copying the contents and taking ownership of it.  This has no requirements    /// on EndPtr[0]. -  static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr, +  static MemoryBuffer *getMemBufferCopy(StringRef InputData,                                          const char *BufferName = "");    /// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index fd56b16639cb..3e66762ae349 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -31,6 +31,13 @@ namespace llvm {  /// SourceMgr - This owns the files read by a parser, handles include stacks,  /// and handles diagnostic wrangling.  class SourceMgr { +public: +  /// DiagHandlerTy - Clients that want to handle their own diagnostics in a +  /// custom way can register a function pointer+context as a diagnostic +  /// handler.  It gets called each time PrintMessage is invoked. +  typedef void (*DiagHandlerTy)(const SMDiagnostic&, void *Context, +                                unsigned LocCookie); +private:    struct SrcBuffer {      /// Buffer - The memory buffer for the file.      MemoryBuffer *Buffer; @@ -51,16 +58,29 @@ class SourceMgr {    /// is really private to SourceMgr.cpp.    mutable void *LineNoCache; +  DiagHandlerTy DiagHandler; +  void *DiagContext; +  unsigned DiagLocCookie; +      SourceMgr(const SourceMgr&);    // DO NOT IMPLEMENT    void operator=(const SourceMgr&); // DO NOT IMPLEMENT  public: -  SourceMgr() : LineNoCache(0) {} +  SourceMgr() : LineNoCache(0), DiagHandler(0), DiagContext(0) {}    ~SourceMgr();    void setIncludeDirs(const std::vector<std::string> &Dirs) {      IncludeDirectories = Dirs;    } +  /// setDiagHandler - Specify a diagnostic handler to be invoked every time +  /// PrintMessage is called.  Ctx and Cookie are passed into the handler when +  /// it is invoked. +  void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0, unsigned Cookie = 0) { +    DiagHandler = DH; +    DiagContext = Ctx; +    DiagLocCookie = Cookie; +  } +    const SrcBuffer &getBufferInfo(unsigned i) const {      assert(i < Buffers.size() && "Invalid Buffer ID!");      return Buffers[i]; @@ -76,6 +96,8 @@ public:      return Buffers[i].IncludeLoc;    } +  /// AddNewSourceBuffer - Add a new source buffer to this source manager.  This +  /// takes ownership of the memory buffer.    unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) {      SrcBuffer NB;      NB.Buffer = F; @@ -126,6 +148,7 @@ private:  /// SMDiagnostic - Instances of this class encapsulate one diagnostic report,  /// allowing printing to a raw_ostream as a caret diagnostic.  class SMDiagnostic { +  SMLoc Loc;    std::string Filename;    int LineNo, ColumnNo;    std::string Message, LineContents; @@ -133,12 +156,20 @@ class SMDiagnostic {  public:    SMDiagnostic() : LineNo(0), ColumnNo(0), ShowLine(0) {} -  SMDiagnostic(const std::string &FN, int Line, int Col, +  SMDiagnostic(SMLoc L, const std::string &FN, int Line, int Col,                 const std::string &Msg, const std::string &LineStr,                 bool showline = true) -    : Filename(FN), LineNo(Line), ColumnNo(Col), Message(Msg), +    : Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Message(Msg),        LineContents(LineStr), ShowLine(showline) {} +  SMLoc getLoc() const { return Loc; } +  const std::string getFilename() { return Filename; } +  int getLineNo() const { return LineNo; } +  int getColumnNo() const { return ColumnNo; } +  const std::string &getMessage() const { return Message; } +  const std::string &getLineContents() const { return LineContents; } +  bool getShowLine() const { return ShowLine; } +      void Print(const char *ProgName, raw_ostream &S) const;  }; diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index 0a7f54937705..462c38f03d27 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -132,8 +132,8 @@ class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,  //===----------------------------------------------------------------------===//  // DwarfRegNum - This class provides a mapping of the llvm register enumeration  // to the register numbering used by gcc and gdb.  These values are used by a -// debug information writer (ex. DwarfWriter) to describe where values may be -// located during execution. +// debug information writer to describe where values may be located during +// execution.  class DwarfRegNum<list<int> Numbers> {    // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.    // These values can be determined by locating the <target>.h file in the @@ -224,10 +224,13 @@ class Instruction {    InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.    string Constraints = "";  // OperandConstraint, e.g. $src = $dst. -   +    /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not    /// be encoded into the output machineinstr.    string DisableEncoding = ""; + +  /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc. +  bits<32> TSFlags = 0;  }  /// Predicates - These are extra conditionals which are turned into instruction @@ -372,13 +375,6 @@ class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>  // which are global to the target machine.  //  class InstrInfo { -  // If the target wants to associate some target-specific information with each -  // instruction, it should provide these two lists to indicate how to assemble -  // the target specific information into the 32 bits available. -  // -  list<string> TSFlagsFields = []; -  list<int>    TSFlagsShifts = []; -    // Target can specify its instructions in either big or little-endian formats.    // For instance, while both Sparc and PowerPC are big-endian platforms, the    // Sparc manual specifies its instructions in the format [31..0] (big), while diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index f040c9db38ca..1a94b4448ae4 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -47,10 +47,8 @@ namespace llvm {    class MachineFrameInfo;    class MachineInstr;    class MachineJumpTableInfo; -  class MachineModuleInfo;    class MCContext;    class MCExpr; -  class DwarfWriter;    class SDNode;    class SDValue;    class SelectionDAG; @@ -1191,7 +1189,7 @@ public:    EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl,                            SDValue Chain,                            SDValue Op1, SDValue Op2, -                          SDValue Op3, unsigned Align, +                          SDValue Op3, unsigned Align, bool isVolatile,                            bool AlwaysInline,                            const Value *DstSV, uint64_t DstOff,                            const Value *SrcSV, uint64_t SrcOff) { @@ -1208,7 +1206,7 @@ public:    EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl,                             SDValue Chain,                             SDValue Op1, SDValue Op2, -                           SDValue Op3, unsigned Align, +                           SDValue Op3, unsigned Align, bool isVolatile,                             const Value *DstSV, uint64_t DstOff,                             const Value *SrcSV, uint64_t SrcOff) {      return SDValue(); @@ -1224,7 +1222,7 @@ public:    EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,                            SDValue Chain,                            SDValue Op1, SDValue Op2, -                          SDValue Op3, unsigned Align, +                          SDValue Op3, unsigned Align, bool isVolatile,                            const Value *DstSV, uint64_t DstOff) {      return SDValue();    } @@ -1274,7 +1272,6 @@ public:    /// or null if the target does not support "fast" ISel.    virtual FastISel *    createFastISel(MachineFunction &, -                 MachineModuleInfo *, DwarfWriter *,                   DenseMap<const Value *, unsigned> &,                   DenseMap<const BasicBlock *, MachineBasicBlock *> &,                   DenseMap<const AllocaInst *, int> & diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index 6b6dad8185b0..36bbe000025c 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -38,7 +38,6 @@ namespace llvm {    class TargetAsmLexer;    class TargetAsmParser;    class TargetMachine; -  class formatted_raw_ostream;    class raw_ostream;    /// Target - Wrapper for Target specific information. @@ -60,8 +59,7 @@ namespace llvm {      typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,                                                    const std::string &TT,                                                    const std::string &Features); -    typedef AsmPrinter *(*AsmPrinterCtorTy)(formatted_raw_ostream &OS, -                                            TargetMachine &TM, +    typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM,                                              MCStreamer &Streamer);      typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T,                                                    const std::string &TT); @@ -71,8 +69,7 @@ namespace llvm {      typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T);      typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,                                                    unsigned SyntaxVariant, -                                                  const MCAsmInfo &MAI, -                                                  raw_ostream &O); +                                                  const MCAsmInfo &MAI);      typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T,                                                  TargetMachine &TM,                                                  MCContext &Ctx); @@ -234,11 +231,10 @@ namespace llvm {      /// createAsmPrinter - Create a target specific assembly printer pass.  This      /// takes ownership of the MCStreamer object. -    AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM, -                                 MCStreamer &Streamer) const { +    AsmPrinter *createAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) const{        if (!AsmPrinterCtorFn)          return 0; -      return AsmPrinterCtorFn(OS, TM, Streamer); +      return AsmPrinterCtorFn(TM, Streamer);      }      MCDisassembler *createMCDisassembler() const { @@ -248,11 +244,10 @@ namespace llvm {      }      MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant, -                                       const MCAsmInfo &MAI, -                                       raw_ostream &O) const { +                                       const MCAsmInfo &MAI) const {        if (!MCInstPrinterCtorFn)          return 0; -      return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, O); +      return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI);      } @@ -646,9 +641,8 @@ namespace llvm {      }    private: -    static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM, -                                 MCStreamer &Streamer) { -      return new AsmPrinterImpl(OS, TM, Streamer); +    static AsmPrinter *Allocator(TargetMachine &TM, MCStreamer &Streamer) { +      return new AsmPrinterImpl(TM, Streamer);      }    }; diff --git a/include/llvm/Transforms/Utils/BuildLibCalls.h b/include/llvm/Transforms/Utils/BuildLibCalls.h index d278672a1f02..8e76f50bb21e 100644 --- a/include/llvm/Transforms/Utils/BuildLibCalls.h +++ b/include/llvm/Transforms/Utils/BuildLibCalls.h @@ -46,8 +46,8 @@ namespace llvm {    /// EmitMemCpy - Emit a call to the memcpy function to the builder.  This    /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. -  Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, -                    unsigned Align, IRBuilder<> &B, const TargetData *TD); +  Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, +                    bool isVolatile, IRBuilder<> &B, const TargetData *TD);    /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder.    /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src @@ -57,8 +57,8 @@ namespace llvm {    /// EmitMemMove - Emit a call to the memmove function to the builder.  This    /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. -  Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, -		                 unsigned Align, IRBuilder<> &B, const TargetData *TD); +  Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, +                     bool isVolatile, IRBuilder<> &B, const TargetData *TD);    /// EmitMemChr - Emit a call to the memchr function.  This assumes that Ptr is    /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. @@ -70,8 +70,8 @@ namespace llvm {                      const TargetData *TD);    /// EmitMemSet - Emit a call to the memset function -  Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, -                    const TargetData *TD); +  Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, +                    IRBuilder<> &B, const TargetData *TD);    /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name'    /// (e.g.  'floor').  This function is known to take a single of type matching  | 
