Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 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 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 19 | #include <cassert> |
Jim Stichnoth | a18cc9c | 2014-09-30 19:10:22 -0700 | [diff] [blame] | 20 | #include <cstdint> |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 21 | #include <cstdio> // snprintf |
| 22 | #include <functional> // std::less |
Jan Voung | bc00463 | 2014-09-16 15:09:10 -0700 | [diff] [blame] | 23 | #include <limits> |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 24 | #include <list> |
| 25 | #include <map> |
| 26 | #include <set> |
| 27 | #include <string> |
| 28 | #include <vector> |
Jan Voung | b17f61d | 2014-08-28 16:00:53 -0700 | [diff] [blame] | 29 | #include "llvm/ADT/ArrayRef.h" |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 30 | #include "llvm/ADT/BitVector.h" |
| 31 | #include "llvm/ADT/SmallBitVector.h" |
| 32 | #include "llvm/ADT/STLExtras.h" |
| 33 | #include "llvm/Support/Casting.h" |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 34 | #include "llvm/Support/raw_ostream.h" |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 35 | |
| 36 | namespace Ice { |
| 37 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 38 | class Cfg; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 39 | class CfgNode; |
| 40 | class Constant; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 41 | class FunctionDeclaration; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 42 | class GlobalContext; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 43 | class GlobalDeclaration; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 44 | class Inst; |
| 45 | class InstPhi; |
| 46 | class InstTarget; |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 47 | class LiveRange; |
| 48 | class Liveness; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 49 | class Operand; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 50 | class TargetLowering; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 51 | class Variable; |
Karl Schimpf | 9d98d79 | 2014-10-13 15:01:08 -0700 | [diff] [blame] | 52 | class VariableDeclaration; |
Jim Stichnoth | 144cdce | 2014-09-22 16:02:59 -0700 | [diff] [blame] | 53 | class VariablesMetadata; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 54 | |
| 55 | // TODO: Switch over to LLVM's ADT container classes. |
| 56 | // http://llvm.org/docs/ProgrammersManual.html#picking-the-right-data-structure-for-a-task |
| 57 | typedef std::string IceString; |
| 58 | typedef std::list<Inst *> InstList; |
| 59 | typedef std::list<InstPhi *> PhiList; |
| 60 | typedef std::vector<Variable *> VarList; |
Matt Wala | 45a0623 | 2014-07-09 16:33:22 -0700 | [diff] [blame] | 61 | typedef std::vector<Operand *> OperandList; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 62 | typedef std::vector<CfgNode *> NodeList; |
Jim Stichnoth | f61d5b2 | 2014-05-23 13:31:24 -0700 | [diff] [blame] | 63 | typedef std::vector<Constant *> ConstantList; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 64 | |
| 65 | // SizeT is for holding small-ish limits like number of source |
| 66 | // operands in an instruction. It is used instead of size_t (which |
| 67 | // may be 64-bits wide) when we want to save space. |
| 68 | typedef uint32_t SizeT; |
| 69 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 70 | // InstNumberT is for holding an instruction number. Instruction |
| 71 | // numbers are used for representing Variable live ranges. |
| 72 | typedef int32_t InstNumberT; |
| 73 | |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 74 | // A LiveBeginEndMapEntry maps a Variable::Number value to an |
| 75 | // Inst::Number value, giving the instruction number that begins or |
| 76 | // ends a variable's live range. |
| 77 | typedef std::pair<SizeT, InstNumberT> LiveBeginEndMapEntry; |
| 78 | typedef std::vector<LiveBeginEndMapEntry> LiveBeginEndMap; |
| 79 | typedef llvm::BitVector LivenessBV; |
| 80 | |
Jim Stichnoth | 8363a06 | 2014-10-07 10:02:38 -0700 | [diff] [blame] | 81 | typedef uint32_t TimerStackIdT; |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 82 | typedef uint32_t TimerIdT; |
| 83 | |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 84 | // PNaCl is ILP32, so theoretically we should only need 32-bit offsets. |
| 85 | typedef int32_t RelocOffsetT; |
| 86 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 87 | enum LivenessMode { |
| 88 | // Basic version of live-range-end calculation. Marks the last uses |
| 89 | // of variables based on dataflow analysis. Records the set of |
| 90 | // live-in and live-out variables for each block. Identifies and |
| 91 | // deletes dead instructions (primarily stores). |
| 92 | Liveness_Basic, |
| 93 | |
| 94 | // In addition to Liveness_Basic, also calculate the complete |
| 95 | // live range for each variable in a form suitable for interference |
| 96 | // calculation and register allocation. |
| 97 | Liveness_Intervals |
| 98 | }; |
| 99 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 100 | enum VerboseItem { |
| 101 | IceV_None = 0, |
| 102 | IceV_Instructions = 1 << 0, |
| 103 | IceV_Deleted = 1 << 1, |
| 104 | IceV_InstNumbers = 1 << 2, |
| 105 | IceV_Preds = 1 << 3, |
| 106 | IceV_Succs = 1 << 4, |
| 107 | IceV_Liveness = 1 << 5, |
| 108 | IceV_RegManager = 1 << 6, |
| 109 | IceV_RegOrigins = 1 << 7, |
| 110 | IceV_LinearScan = 1 << 8, |
| 111 | IceV_Frame = 1 << 9, |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 112 | IceV_AddrOpt = 1 << 10, |
Jim Stichnoth | ad40353 | 2014-09-25 12:44:17 -0700 | [diff] [blame] | 113 | IceV_All = ~IceV_None, |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 114 | IceV_Most = IceV_All & ~IceV_LinearScan |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 115 | }; |
| 116 | typedef uint32_t VerboseMask; |
| 117 | |
Jim Stichnoth | 78282f6 | 2014-07-27 23:14:00 -0700 | [diff] [blame] | 118 | typedef llvm::raw_ostream Ostream; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 119 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 120 | } // end of namespace Ice |
| 121 | |
| 122 | #endif // SUBZERO_SRC_ICEDEFS_H |