Chromium Code Reviews| 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 <assert.h> | |
| 20 #include <stdint.h> | |
| 21 #include <stdio.h> // sprintf | |
|
JF
2014/04/16 01:27:32
Since this is a new code base I'd go with the <c*>
Jim Stichnoth
2014/04/21 20:26:40
Done for <cassert> and <cstdio>. stdint.h seems r
JF
2014/04/23 03:51:28
What are the issues? I assume something newlib+lib
Jim Stichnoth
2014/04/26 15:02:11
It looks like <cstdint> is C++11, at least accordi
JF
2014/04/26 20:20:56
Hah, I did not know that.
| |
| 22 | |
| 23 #include <list> | |
| 24 #include <map> | |
| 25 #include <set> | |
| 26 #include <string> | |
| 27 #include <vector> | |
| 28 | |
| 29 #include "llvm/ADT/BitVector.h" | |
| 30 #include "llvm/ADT/SmallBitVector.h" | |
| 31 #include "llvm/Support/Casting.h" | |
| 32 #include "llvm/Support/raw_ostream.h" | |
| 33 #include "llvm/Support/Timer.h" | |
| 34 | |
|
JF
2014/04/16 01:27:32
It would be nicer to put everything in a namespace
Jim Stichnoth
2014/04/21 20:26:40
Done. Used the "Ice" namespace. In some cases, I
| |
| 35 class IceCfg; | |
| 36 class IceCfgNode; | |
| 37 class IceConstant; | |
| 38 class IceGlobalContext; | |
| 39 class IceInst; | |
| 40 class IceInstPhi; | |
| 41 class IceInstTarget; | |
| 42 class IceOperand; | |
| 43 class IceVariable; | |
| 44 | |
| 45 // TODO: Switch over to LLVM's ADT container classes. | |
| 46 // http://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure- for-a-task | |
| 47 typedef std::string IceString; | |
| 48 typedef std::list<IceInst *> IceInstList; | |
| 49 typedef std::list<IceInstPhi *> IcePhiList; | |
| 50 typedef std::vector<IceOperand *> IceOpList; | |
| 51 typedef std::vector<IceVariable *> IceVarList; | |
| 52 typedef std::vector<IceCfgNode *> IceNodeList; | |
| 53 | |
| 54 // This is a convenience templated class that provides a mapping | |
| 55 // between a parameterized type and small unsigned integers. | |
| 56 template <typename T> class IceValueTranslation { | |
| 57 public: | |
| 58 typedef typename std::map<const T, uint32_t> ContainerType; | |
| 59 IceValueTranslation() {} | |
|
JF
2014/04/16 01:27:32
dtor, copy ctor, assign?
Jim Stichnoth
2014/04/21 20:26:40
Done. No dtor for this simple wrapper class.
| |
| 60 void clear() { Entries.clear(); } | |
| 61 uint32_t translate(const T &Value) { | |
| 62 typename ContainerType::const_iterator Iter = Entries.find(Value); | |
| 63 if (Iter != Entries.end()) | |
| 64 return Iter->second; | |
| 65 uint32_t Index = Entries.size(); | |
| 66 Entries[Value] = Index; | |
| 67 return Index; | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 ContainerType Entries; | |
| 72 }; | |
| 73 | |
| 74 enum IceVerbose { | |
| 75 IceV_None = 0, | |
| 76 IceV_Instructions = 1 << 0, | |
| 77 IceV_Deleted = 1 << 1, | |
| 78 IceV_InstNumbers = 1 << 2, | |
| 79 IceV_Preds = 1 << 3, | |
| 80 IceV_Succs = 1 << 4, | |
| 81 IceV_Liveness = 1 << 5, | |
| 82 IceV_RegManager = 1 << 6, | |
| 83 IceV_RegOrigins = 1 << 7, | |
| 84 IceV_LinearScan = 1 << 8, | |
| 85 IceV_Frame = 1 << 9, | |
| 86 IceV_Timing = 1 << 10, | |
| 87 IceV_All = ~IceV_None | |
| 88 }; | |
| 89 typedef uint32_t IceVerboseMask; | |
|
JF
2014/04/16 01:27:32
Why typedef this to uint32_t instead of just using
Jim Stichnoth
2014/04/21 20:26:40
IceVerboseMask is a bitmask of IceVerbose values.
| |
| 90 | |
| 91 // The IceOstream class wraps an output stream and an IceCfg pointer, | |
| 92 // so that dump routines have access to the IceCfg object and can | |
| 93 // print labels and variable names. | |
| 94 | |
| 95 class IceOstream { | |
| 96 public: | |
| 97 IceOstream(llvm::raw_ostream *Stream) : Stream(Stream) {} | |
| 98 | |
| 99 llvm::raw_ostream *Stream; | |
|
JF
2014/04/16 01:27:32
dtor, copy ctor, assign.
Jim Stichnoth
2014/04/21 20:26:40
Done. No dtor for this simple wrapper class.
| |
| 100 }; | |
| 101 | |
| 102 template <typename T> | |
| 103 inline IceOstream &operator<<(IceOstream &Str, const T &Val) { | |
| 104 if (Str.Stream) | |
| 105 (*Str.Stream) << Val; | |
| 106 return Str; | |
| 107 } | |
| 108 | |
| 109 class IceTimer { | |
|
JF
2014/04/16 01:27:32
Can you put a TODO to use std::chrono when we sync
Jim Stichnoth
2014/04/21 20:26:40
Done.
| |
| 110 public: | |
| 111 IceTimer() : Start(llvm::TimeRecord::getCurrentTime(false)) {} | |
| 112 uint64_t getElapsedNs() const { return getElapsedSec() * 1000 * 1000 * 1000; } | |
| 113 uint64_t getElapsedUs() const { return getElapsedSec() * 1000 * 1000; } | |
| 114 uint64_t getElapsedMs() const { return getElapsedSec() * 1000; } | |
| 115 double getElapsedSec() const { | |
| 116 llvm::TimeRecord End = llvm::TimeRecord::getCurrentTime(false); | |
| 117 return End.getWallTime() - Start.getWallTime(); | |
| 118 } | |
| 119 void printElapsedUs(IceGlobalContext *Ctx, const IceString &Tag) const; | |
| 120 | |
| 121 private: | |
| 122 const llvm::TimeRecord Start; | |
| 123 }; | |
| 124 | |
| 125 #endif // SUBZERO_SRC_ICEDEFS_H | |
| OLD | NEW |