OLD | NEW |
---|---|
(Empty) | |
1 //===- subzero/src/IceDefs.h - Common Subzero declaraions -------*- C++ -*-===// | |
2 // | |
3 // The Subzero Code Generator | |
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 declares various useful types and classes that have | |
11 // widespread use across Subzero. Every Subzero source file is | |
12 // expected to include IceDefs.h. | |
13 // | |
14 //===----------------------------------------------------------------------===// | |
15 | |
16 #ifndef SUBZERO_SRC_ICEDEFS_H | |
17 #define SUBZERO_SRC_ICEDEFS_H | |
18 | |
19 #include <stdint.h> | |
JF
2014/04/26 20:20:56
TODO C++11 ctsdint
Jim Stichnoth
2014/04/27 15:04:57
Done.
| |
20 | |
21 #include <cassert> | |
22 #include <cstdio> // snprintf | |
23 #include <functional> // std::less | |
24 #include <list> | |
25 #include <map> | |
26 #include <set> | |
27 #include <string> | |
28 #include <vector> | |
29 | |
30 #include "llvm/ADT/BitVector.h" | |
31 #include "llvm/ADT/SmallBitVector.h" | |
32 #include "llvm/ADT/STLExtras.h" | |
33 #include "llvm/Support/Casting.h" | |
34 #include "llvm/Support/Compiler.h" // LLVM_STATIC_ASSERT | |
35 #include "llvm/Support/raw_ostream.h" | |
36 #include "llvm/Support/Timer.h" | |
37 | |
38 namespace Ice { | |
39 | |
40 class CfgNode; | |
41 class Constant; | |
42 class GlobalContext; | |
43 class Cfg; | |
44 class Inst; | |
45 class InstPhi; | |
46 class InstTarget; | |
47 class Operand; | |
48 class Variable; | |
49 | |
50 // TODO: Switch over to LLVM's ADT container classes. | |
51 // http://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure- for-a-task | |
52 typedef std::string IceString; | |
53 typedef std::list<Inst *> InstList; | |
54 typedef std::list<InstPhi *> PhiList; | |
55 typedef std::vector<Variable *> VarList; | |
56 typedef std::vector<CfgNode *> NodeList; | |
57 | |
58 // SizeT is for holding small-ish limits like number of source | |
59 // operands in an instruction. It is used instead of size_t (which | |
60 // may be 64-bits wide) when we want to save space. | |
61 typedef uint32_t SizeT; | |
62 | |
63 enum VerboseItem { | |
64 IceV_None = 0, | |
65 IceV_Instructions = 1 << 0, | |
66 IceV_Deleted = 1 << 1, | |
67 IceV_InstNumbers = 1 << 2, | |
68 IceV_Preds = 1 << 3, | |
69 IceV_Succs = 1 << 4, | |
70 IceV_Liveness = 1 << 5, | |
71 IceV_RegManager = 1 << 6, | |
72 IceV_RegOrigins = 1 << 7, | |
73 IceV_LinearScan = 1 << 8, | |
74 IceV_Frame = 1 << 9, | |
75 IceV_Timing = 1 << 10, | |
76 IceV_All = ~IceV_None | |
77 }; | |
78 typedef uint32_t VerboseMask; | |
79 | |
80 // The Ostream class wraps an output stream and a Cfg pointer, so | |
81 // that dump routines have access to the Cfg object and can print | |
82 // labels and variable names. | |
83 | |
84 class Ostream { | |
85 public: | |
86 Ostream(llvm::raw_ostream *Stream) : Stream(Stream) {} | |
87 | |
88 llvm::raw_ostream *Stream; | |
89 | |
90 private: | |
91 Ostream(const Ostream &) LLVM_DELETED_FUNCTION; | |
92 Ostream &operator=(const Ostream &) LLVM_DELETED_FUNCTION; | |
93 }; | |
94 | |
95 template <typename T> inline Ostream &operator<<(Ostream &Str, const T &Val) { | |
96 if (Str.Stream) | |
97 (*Str.Stream) << Val; | |
98 return Str; | |
99 } | |
100 | |
101 // TODO: Implement in terms of std::chrono after switching to C++11. | |
102 class Timer { | |
103 public: | |
104 Timer() : Start(llvm::TimeRecord::getCurrentTime(false)) {} | |
105 uint64_t getElapsedNs() const { return getElapsedSec() * 1000 * 1000 * 1000; } | |
106 uint64_t getElapsedUs() const { return getElapsedSec() * 1000 * 1000; } | |
107 uint64_t getElapsedMs() const { return getElapsedSec() * 1000; } | |
108 double getElapsedSec() const { | |
109 llvm::TimeRecord End = llvm::TimeRecord::getCurrentTime(false); | |
110 return End.getWallTime() - Start.getWallTime(); | |
111 } | |
112 void printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const; | |
113 | |
114 private: | |
115 const llvm::TimeRecord Start; | |
116 Timer(const Timer &) LLVM_DELETED_FUNCTION; | |
117 Timer &operator=(const Timer &) LLVM_DELETED_FUNCTION; | |
118 }; | |
119 | |
120 } // end of namespace Ice | |
121 | |
122 #endif // SUBZERO_SRC_ICEDEFS_H | |
OLD | NEW |