Added first bit of support for the dwarf .file directive. This patch collects
[oota-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 <string>
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     std::string Name;
33
34     // DirIndex - the index into the list of directory names for this file name.
35     unsigned DirIndex;
36
37   private:  // MCContext creates and uniques these.
38     friend class MCContext;
39     MCDwarfFile(std::string name, unsigned dirIndex)
40       : Name(name), DirIndex(dirIndex) {}
41
42     MCDwarfFile(const MCDwarfFile&);       // DO NOT IMPLEMENT
43     void operator=(const MCDwarfFile&); // DO NOT IMPLEMENT
44   public:
45     /// getName - Get the base name of this MCDwarfFile.
46     std::string getName() const { return Name; }
47
48     /// print - Print the value to the stream \arg OS.
49     void print(raw_ostream &OS) const;
50
51     /// dump - Print the value to stderr.
52     void dump() const;
53   };
54
55   inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){
56     DwarfFile.print(OS);
57     return OS;
58   }
59 } // end namespace llvm
60
61 #endif