OSDN Git Service

Merge commit 'refs/changes/82/67782/1' of ssh://android-git.corp.google.com:29418...
[android-x86/external-llvm.git] / include / llvm / MC / MCDwarf.h
1 //===- MCDwarf.h - Machine Code Dwarf support -------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declaration of the MCDwarfFile to support the dwarf
11 // .file directive.
12 // TODO: add the support needed for the .loc directive.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_MC_MCDWARF_H
17 #define LLVM_MC_MCDWARF_H
18
19 #include "llvm/ADT/StringRef.h"
20
21 namespace llvm {
22   class MCContext;
23   class raw_ostream;
24
25   /// MCDwarfFile - Instances of this class represent the name of the dwarf
26   /// .file directive and its associated dwarf file number in the MC file,
27   /// and MCDwarfFile's are created and unique'd by the MCContext class where
28   /// the file number for each is its index into the vector of DwarfFiles (note
29   /// index 0 is not used and not a valid dwarf file number).
30   class MCDwarfFile {
31     // Name - the base name of the file without its directory path.
32     // The StringRef references memory allocated in the MCContext.
33     StringRef Name;
34
35     // DirIndex - the index into the list of directory names for this file name.
36     unsigned DirIndex;
37
38   private:  // MCContext creates and uniques these.
39     friend class MCContext;
40     MCDwarfFile(StringRef name, unsigned dirIndex)
41       : Name(name), DirIndex(dirIndex) {}
42
43     MCDwarfFile(const MCDwarfFile&);       // DO NOT IMPLEMENT
44     void operator=(const MCDwarfFile&); // DO NOT IMPLEMENT
45   public:
46     /// getName - Get the base name of this MCDwarfFile.
47     StringRef getName() const { return Name; }
48
49     /// getDirIndex - Get the dirIndex of this MCDwarfFile.
50     unsigned getDirIndex() const { return DirIndex; }
51
52
53     /// print - Print the value to the stream \arg OS.
54     void print(raw_ostream &OS) const;
55
56     /// dump - Print the value to stderr.
57     void dump() const;
58   };
59
60   /// MCDwarfLoc - Instances of this class represent the information from a
61   /// dwarf .loc directive.
62   class MCDwarfLoc {
63     // FileNum - the file number.
64     unsigned FileNum;
65     // Line - the line number.
66     unsigned Line;
67     // Column - the column position.
68     unsigned Column;
69     // Flags (see #define's below)
70     unsigned Flags;
71     // Isa
72     unsigned Isa;
73
74 #define DWARF2_FLAG_IS_STMT        (1 << 0)
75 #define DWARF2_FLAG_BASIC_BLOCK    (1 << 1)
76 #define DWARF2_FLAG_PROLOGUE_END   (1 << 2)
77 #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
78
79   private:  // MCContext manages these
80     friend class MCContext;
81     MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags,
82                unsigned isa)
83       : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa) {}
84
85     MCDwarfLoc(const MCDwarfLoc&);       // DO NOT IMPLEMENT
86     void operator=(const MCDwarfLoc&); // DO NOT IMPLEMENT
87   public:
88     /// setFileNum - Set the FileNum of this MCDwarfLoc.
89     void setFileNum(unsigned fileNum) { FileNum = fileNum; }
90
91     /// setLine - Set the Line of this MCDwarfLoc.
92     void setLine(unsigned line) { Line = line; }
93
94     /// setColumn - Set the Column of this MCDwarfLoc.
95     void setColumn(unsigned column) { Column = column; }
96
97     /// setFlags - Set the Flags of this MCDwarfLoc.
98     void setFlags(unsigned flags) { Flags = flags; }
99
100     /// setIsa - Set the Isa of this MCDwarfLoc.
101     void setIsa(unsigned isa) { Isa = isa; }
102   };
103
104   inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){
105     DwarfFile.print(OS);
106     return OS;
107   }
108 } // end namespace llvm
109
110 #endif