blob: 8974bae83860f08458e9993b71e3b5bea8f8223a [file] [log] [blame]
Jim Stichnothf7c9a142014-04-29 10:52:43 -07001//===- 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 Stichnothf7c9a142014-04-29 10:52:43 -070019#include <cassert>
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070020#include <cstdint>
Jim Stichnothf7c9a142014-04-29 10:52:43 -070021#include <cstdio> // snprintf
22#include <functional> // std::less
Jan Voungbc004632014-09-16 15:09:10 -070023#include <limits>
Jim Stichnothf7c9a142014-04-29 10:52:43 -070024#include <list>
25#include <map>
26#include <set>
27#include <string>
28#include <vector>
Jan Voungb17f61d2014-08-28 16:00:53 -070029#include "llvm/ADT/ArrayRef.h"
Jim Stichnothf7c9a142014-04-29 10:52:43 -070030#include "llvm/ADT/BitVector.h"
31#include "llvm/ADT/SmallBitVector.h"
32#include "llvm/ADT/STLExtras.h"
33#include "llvm/Support/Casting.h"
Jim Stichnothf7c9a142014-04-29 10:52:43 -070034#include "llvm/Support/raw_ostream.h"
Jim Stichnothf7c9a142014-04-29 10:52:43 -070035
36namespace Ice {
37
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070038class Cfg;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070039class CfgNode;
40class Constant;
Karl Schimpf9d98d792014-10-13 15:01:08 -070041class FunctionDeclaration;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070042class GlobalContext;
Karl Schimpf9d98d792014-10-13 15:01:08 -070043class GlobalDeclaration;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070044class Inst;
45class InstPhi;
46class InstTarget;
Jim Stichnothd97c7df2014-06-04 11:57:08 -070047class LiveRange;
48class Liveness;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070049class Operand;
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070050class TargetLowering;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070051class Variable;
Karl Schimpf9d98d792014-10-13 15:01:08 -070052class VariableDeclaration;
Jim Stichnoth144cdce2014-09-22 16:02:59 -070053class VariablesMetadata;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070054
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
57typedef std::string IceString;
58typedef std::list<Inst *> InstList;
59typedef std::list<InstPhi *> PhiList;
60typedef std::vector<Variable *> VarList;
Matt Wala45a06232014-07-09 16:33:22 -070061typedef std::vector<Operand *> OperandList;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070062typedef std::vector<CfgNode *> NodeList;
Jim Stichnothf61d5b22014-05-23 13:31:24 -070063typedef std::vector<Constant *> ConstantList;
Jim Stichnothf7c9a142014-04-29 10:52:43 -070064
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.
68typedef uint32_t SizeT;
69
Jim Stichnothd97c7df2014-06-04 11:57:08 -070070// InstNumberT is for holding an instruction number. Instruction
71// numbers are used for representing Variable live ranges.
72typedef int32_t InstNumberT;
73
Jim Stichnoth47752552014-10-13 17:15:08 -070074// 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.
77typedef std::pair<SizeT, InstNumberT> LiveBeginEndMapEntry;
78typedef std::vector<LiveBeginEndMapEntry> LiveBeginEndMap;
79typedef llvm::BitVector LivenessBV;
80
Jim Stichnoth8363a062014-10-07 10:02:38 -070081typedef uint32_t TimerStackIdT;
Jim Stichnothc4554d72014-09-30 16:49:38 -070082typedef uint32_t TimerIdT;
83
Jan Voungfe14fb82014-10-13 15:56:32 -070084// PNaCl is ILP32, so theoretically we should only need 32-bit offsets.
85typedef int32_t RelocOffsetT;
86
Jim Stichnothd97c7df2014-06-04 11:57:08 -070087enum 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 Stichnothf7c9a142014-04-29 10:52:43 -0700100enum 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 Stichnothc4554d72014-09-30 16:49:38 -0700112 IceV_AddrOpt = 1 << 10,
Jim Stichnothad403532014-09-25 12:44:17 -0700113 IceV_All = ~IceV_None,
Jim Stichnothc4554d72014-09-30 16:49:38 -0700114 IceV_Most = IceV_All & ~IceV_LinearScan
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700115};
116typedef uint32_t VerboseMask;
117
Jim Stichnoth78282f62014-07-27 23:14:00 -0700118typedef llvm::raw_ostream Ostream;
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700119
Jim Stichnothf7c9a142014-04-29 10:52:43 -0700120} // end of namespace Ice
121
122#endif // SUBZERO_SRC_ICEDEFS_H