Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceInst.h - High-level instructions ----------*- 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 the Inst class and its target-independent |
| 11 | // subclasses, which represent the high-level Vanilla ICE instructions |
| 12 | // and map roughly 1:1 to LLVM instructions. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef SUBZERO_SRC_ICEINST_H |
| 17 | #define SUBZERO_SRC_ICEINST_H |
| 18 | |
| 19 | #include "IceDefs.h" |
| 20 | #include "IceInst.def" |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 21 | #include "IceIntrinsics.h" |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 22 | #include "IceTypes.h" |
| 23 | |
| 24 | // TODO: The Cfg structure, and instructions in particular, need to be |
| 25 | // validated for things like valid operand types, valid branch |
| 26 | // targets, proper ordering of Phi and non-Phi instructions, etc. |
| 27 | // Most of the validity checking will be done in the bitcode reader. |
| 28 | // We need a list of everything that should be validated, and tests |
| 29 | // for each. |
| 30 | |
| 31 | namespace Ice { |
| 32 | |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 33 | // Base instruction class for ICE. Inst has two subclasses: |
| 34 | // InstHighLevel and InstTarget. High-level ICE instructions inherit |
| 35 | // from InstHighLevel, and low-level (target-specific) ICE |
| 36 | // instructions inherit from InstTarget. |
Jim Stichnoth | 607e9f0 | 2014-11-06 13:32:05 -0800 | [diff] [blame] | 37 | class Inst : public llvm::ilist_node<Inst> { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 38 | Inst(const Inst &) = delete; |
| 39 | Inst &operator=(const Inst &) = delete; |
| 40 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 41 | public: |
| 42 | enum InstKind { |
| 43 | // Arbitrary (alphabetical) order, except put Unreachable first. |
| 44 | Unreachable, |
| 45 | Alloca, |
| 46 | Arithmetic, |
| 47 | Assign, // not part of LLVM/PNaCl bitcode |
| 48 | Br, |
| 49 | Call, |
| 50 | Cast, |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 51 | ExtractElement, |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 52 | Fcmp, |
| 53 | Icmp, |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 54 | IntrinsicCall, |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 55 | InsertElement, |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 56 | Load, |
| 57 | Phi, |
| 58 | Ret, |
| 59 | Select, |
| 60 | Store, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 61 | Switch, |
| 62 | FakeDef, // not part of LLVM/PNaCl bitcode |
| 63 | FakeUse, // not part of LLVM/PNaCl bitcode |
| 64 | FakeKill, // not part of LLVM/PNaCl bitcode |
| 65 | Target // target-specific low-level ICE |
| 66 | // Anything >= Target is an InstTarget subclass. |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 67 | }; |
| 68 | InstKind getKind() const { return Kind; } |
| 69 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 70 | InstNumberT getNumber() const { return Number; } |
| 71 | void renumber(Cfg *Func); |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 72 | enum { NumberDeleted = -1, NumberSentinel = 0 }; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 73 | |
| 74 | bool isDeleted() const { return Deleted; } |
| 75 | void setDeleted() { Deleted = true; } |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 76 | void deleteIfDead(); |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 77 | |
| 78 | bool hasSideEffects() const { return HasSideEffects; } |
| 79 | |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 80 | bool isDestNonKillable() const { return IsDestNonKillable; } |
| 81 | void setDestNonKillable() { IsDestNonKillable = true; } |
| 82 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 83 | Variable *getDest() const { return Dest; } |
| 84 | |
| 85 | SizeT getSrcSize() const { return NumSrcs; } |
| 86 | Operand *getSrc(SizeT I) const { |
| 87 | assert(I < getSrcSize()); |
| 88 | return Srcs[I]; |
| 89 | } |
| 90 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 91 | bool isLastUse(const Operand *Src) const; |
| 92 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 93 | // Returns a list of out-edges corresponding to a terminator |
| 94 | // instruction, which is the last instruction of the block. |
| 95 | virtual NodeList getTerminatorEdges() const { |
| 96 | // All valid terminator instructions override this method. For |
| 97 | // the default implementation, we assert in case some CfgNode |
| 98 | // is constructed without a terminator instruction at the end. |
| 99 | llvm_unreachable( |
| 100 | "getTerminatorEdges() called on a non-terminator instruction"); |
| 101 | return NodeList(); |
| 102 | } |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 103 | virtual bool isUnconditionalBranch() const { return false; } |
| 104 | // If the instruction is a branch-type instruction with OldNode as a |
| 105 | // target, repoint it to NewNode and return true, otherwise return |
| 106 | // false. Only repoint one instance, even if the instruction has |
| 107 | // multiple instances of OldNode as a target. |
| 108 | virtual bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) { |
| 109 | (void)OldNode; |
| 110 | (void)NewNode; |
| 111 | return false; |
| 112 | } |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 113 | |
Jim Stichnoth | ad40353 | 2014-09-25 12:44:17 -0700 | [diff] [blame] | 114 | virtual bool isSimpleAssign() const { return false; } |
| 115 | |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 116 | void livenessLightweight(Cfg *Func, LivenessBV &Live); |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 117 | // Calculates liveness for this instruction. Returns true if this |
| 118 | // instruction is (tentatively) still live and should be retained, |
| 119 | // and false if this instruction is (tentatively) dead and should be |
| 120 | // deleted. The decision is tentative until the liveness dataflow |
| 121 | // algorithm has converged, and then a separate pass permanently |
| 122 | // deletes dead instructions. |
| 123 | bool liveness(InstNumberT InstNumber, LivenessBV &Live, Liveness *Liveness, |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 124 | LiveBeginEndMap *LiveBegin, LiveBeginEndMap *LiveEnd); |
Jim Stichnoth | 1873560 | 2014-09-16 19:59:35 -0700 | [diff] [blame] | 125 | |
| 126 | // Get the number of native instructions that this instruction |
| 127 | // ultimately emits. By default, high-level instructions don't |
| 128 | // result in any native instructions, and a target-specific |
| 129 | // instruction results in a single native instruction. |
| 130 | virtual uint32_t getEmitInstCount() const { return 0; } |
Jim Stichnoth | dddaf9c | 2014-12-04 14:09:21 -0800 | [diff] [blame^] | 131 | // TODO(stichnot): Change Inst back to abstract once the g++ build |
| 132 | // issue is fixed. llvm::ilist<Ice::Inst> doesn't work under g++ |
| 133 | // because the resize(size_t, Ice::Inst) method is incorrectly |
| 134 | // declared and thus doesn't allow the abstract class Ice::Inst. |
| 135 | // The method should be declared resize(size_t, const Ice::Inst &). |
| 136 | // virtual void emit(const Cfg *Func) const = 0; |
| 137 | // virtual void emitIAS(const Cfg *Func) const = 0; |
| 138 | virtual void emit(const Cfg *) const { |
| 139 | llvm_unreachable("emit on abstract class"); |
| 140 | } |
| 141 | virtual void emitIAS(const Cfg *Func) const { emit(Func); } |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 142 | virtual void dump(const Cfg *Func) const; |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 143 | virtual void dumpExtras(const Cfg *Func) const; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 144 | void dumpDecorated(const Cfg *Func) const; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 145 | void emitSources(const Cfg *Func) const; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 146 | void dumpSources(const Cfg *Func) const; |
| 147 | void dumpDest(const Cfg *Func) const; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 148 | virtual bool isRedundantAssign() const { return false; } |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 149 | |
| 150 | virtual ~Inst() {} |
| 151 | |
| 152 | protected: |
| 153 | Inst(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest); |
| 154 | void addSource(Operand *Src) { |
| 155 | assert(Src); |
| 156 | assert(NumSrcs < MaxSrcs); |
| 157 | Srcs[NumSrcs++] = Src; |
| 158 | } |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 159 | void setLastUse(SizeT VarIndex) { |
| 160 | if (VarIndex < CHAR_BIT * sizeof(LiveRangesEnded)) |
| 161 | LiveRangesEnded |= (((LREndedBits)1u) << VarIndex); |
| 162 | } |
| 163 | void resetLastUses() { LiveRangesEnded = 0; } |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 164 | // The destroy() method lets the instruction cleanly release any |
| 165 | // memory that was allocated via the Cfg's allocator. |
| 166 | virtual void destroy(Cfg *Func) { Func->deallocateArrayOf<Operand *>(Srcs); } |
| 167 | |
| 168 | const InstKind Kind; |
| 169 | // Number is the instruction number for describing live ranges. |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 170 | InstNumberT Number; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 171 | // Deleted means irrevocably deleted. |
| 172 | bool Deleted; |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 173 | // Dead means pending deletion after liveness analysis converges. |
| 174 | bool Dead; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 175 | // HasSideEffects means the instruction is something like a function |
| 176 | // call or a volatile load that can't be removed even if its Dest |
| 177 | // variable is not live. |
| 178 | bool HasSideEffects; |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 179 | // IsDestNonKillable means that liveness analysis shouldn't consider |
| 180 | // this instruction to kill the Dest variable. This is used when |
| 181 | // lowering produces two assignments to the same variable. |
| 182 | bool IsDestNonKillable; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 183 | |
| 184 | Variable *Dest; |
| 185 | const SizeT MaxSrcs; // only used for assert |
| 186 | SizeT NumSrcs; |
| 187 | Operand **Srcs; |
| 188 | |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 189 | // LiveRangesEnded marks which Variables' live ranges end in this |
| 190 | // instruction. An instruction can have an arbitrary number of |
| 191 | // source operands (e.g. a call instruction), and each source |
| 192 | // operand can contain 0 or 1 Variable (and target-specific operands |
| 193 | // could contain more than 1 Variable). All the variables in an |
| 194 | // instruction are conceptually flattened and each variable is |
| 195 | // mapped to one bit position of the LiveRangesEnded bit vector. |
| 196 | // Only the first CHAR_BIT * sizeof(LREndedBits) variables are |
| 197 | // tracked this way. |
| 198 | typedef uint32_t LREndedBits; // only first 32 src operands tracked, sorry |
| 199 | LREndedBits LiveRangesEnded; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 202 | class InstHighLevel : public Inst { |
Jim Stichnoth | 0795ba0 | 2014-10-01 14:23:01 -0700 | [diff] [blame] | 203 | InstHighLevel(const InstHighLevel &) = delete; |
| 204 | InstHighLevel &operator=(const InstHighLevel &) = delete; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 205 | |
| 206 | protected: |
| 207 | InstHighLevel(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 208 | : Inst(Func, Kind, MaxSrcs, Dest) {} |
| 209 | void emit(const Cfg * /*Func*/) const override { |
| 210 | llvm_unreachable("emit() called on a non-lowered instruction"); |
| 211 | } |
| 212 | void emitIAS(const Cfg * /*Func*/) const override { |
| 213 | llvm_unreachable("emitIAS() called on a non-lowered instruction"); |
| 214 | } |
| 215 | ~InstHighLevel() override {} |
| 216 | }; |
| 217 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 218 | // Alloca instruction. This captures the size in bytes as getSrc(0), |
| 219 | // and the required alignment in bytes. The alignment must be either |
| 220 | // 0 (no alignment required) or a power of 2. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 221 | class InstAlloca : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 222 | InstAlloca(const InstAlloca &) = delete; |
| 223 | InstAlloca &operator=(const InstAlloca &) = delete; |
| 224 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 225 | public: |
| 226 | static InstAlloca *create(Cfg *Func, Operand *ByteCount, |
| 227 | uint32_t AlignInBytes, Variable *Dest) { |
| 228 | return new (Func->allocateInst<InstAlloca>()) |
| 229 | InstAlloca(Func, ByteCount, AlignInBytes, Dest); |
| 230 | } |
| 231 | uint32_t getAlignInBytes() const { return AlignInBytes; } |
| 232 | Operand *getSizeInBytes() const { return getSrc(0); } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 233 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 234 | static bool classof(const Inst *Inst) { return Inst->getKind() == Alloca; } |
| 235 | |
| 236 | private: |
| 237 | InstAlloca(Cfg *Func, Operand *ByteCount, uint32_t AlignInBytes, |
| 238 | Variable *Dest); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 239 | ~InstAlloca() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 240 | const uint32_t AlignInBytes; |
| 241 | }; |
| 242 | |
| 243 | // Binary arithmetic instruction. The source operands are captured in |
| 244 | // getSrc(0) and getSrc(1). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 245 | class InstArithmetic : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 246 | InstArithmetic(const InstArithmetic &) = delete; |
| 247 | InstArithmetic &operator=(const InstArithmetic &) = delete; |
| 248 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 249 | public: |
| 250 | enum OpKind { |
| 251 | #define X(tag, str, commutative) tag, |
| 252 | ICEINSTARITHMETIC_TABLE |
| 253 | #undef X |
Jim Stichnoth | 4376d29 | 2014-05-23 13:39:02 -0700 | [diff] [blame] | 254 | _num |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 255 | }; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 256 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 257 | static InstArithmetic *create(Cfg *Func, OpKind Op, Variable *Dest, |
| 258 | Operand *Source1, Operand *Source2) { |
| 259 | return new (Func->allocateInst<InstArithmetic>()) |
| 260 | InstArithmetic(Func, Op, Dest, Source1, Source2); |
| 261 | } |
| 262 | OpKind getOp() const { return Op; } |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 263 | static const char *getOpName(OpKind Op); |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 264 | bool isCommutative() const; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 265 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 266 | static bool classof(const Inst *Inst) { |
| 267 | return Inst->getKind() == Arithmetic; |
| 268 | } |
| 269 | |
| 270 | private: |
| 271 | InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, Operand *Source1, |
| 272 | Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 273 | ~InstArithmetic() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 274 | |
| 275 | const OpKind Op; |
| 276 | }; |
| 277 | |
| 278 | // Assignment instruction. The source operand is captured in |
| 279 | // getSrc(0). This is not part of the LLVM bitcode, but is a useful |
| 280 | // abstraction for some of the lowering. E.g., if Phi instruction |
| 281 | // lowering happens before target lowering, or for representing an |
| 282 | // Inttoptr instruction, or as an intermediate step for lowering a |
| 283 | // Load instruction. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 284 | class InstAssign : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 285 | InstAssign(const InstAssign &) = delete; |
| 286 | InstAssign &operator=(const InstAssign &) = delete; |
| 287 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 288 | public: |
| 289 | static InstAssign *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 290 | return new (Func->allocateInst<InstAssign>()) |
| 291 | InstAssign(Func, Dest, Source); |
| 292 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 293 | bool isSimpleAssign() const override { return true; } |
| 294 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 295 | static bool classof(const Inst *Inst) { return Inst->getKind() == Assign; } |
| 296 | |
| 297 | private: |
| 298 | InstAssign(Cfg *Func, Variable *Dest, Operand *Source); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 299 | ~InstAssign() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | // Branch instruction. This represents both conditional and |
| 303 | // unconditional branches. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 304 | class InstBr : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 305 | InstBr(const InstBr &) = delete; |
| 306 | InstBr &operator=(const InstBr &) = delete; |
| 307 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 308 | public: |
| 309 | // Create a conditional branch. If TargetTrue==TargetFalse, it is |
| 310 | // optimized to an unconditional branch. |
| 311 | static InstBr *create(Cfg *Func, Operand *Source, CfgNode *TargetTrue, |
| 312 | CfgNode *TargetFalse) { |
| 313 | return new (Func->allocateInst<InstBr>()) |
| 314 | InstBr(Func, Source, TargetTrue, TargetFalse); |
| 315 | } |
| 316 | // Create an unconditional branch. |
| 317 | static InstBr *create(Cfg *Func, CfgNode *Target) { |
| 318 | return new (Func->allocateInst<InstBr>()) InstBr(Func, Target); |
| 319 | } |
| 320 | bool isUnconditional() const { return getTargetTrue() == NULL; } |
| 321 | Operand *getCondition() const { |
| 322 | assert(!isUnconditional()); |
| 323 | return getSrc(0); |
| 324 | } |
| 325 | CfgNode *getTargetTrue() const { return TargetTrue; } |
| 326 | CfgNode *getTargetFalse() const { return TargetFalse; } |
| 327 | CfgNode *getTargetUnconditional() const { |
| 328 | assert(isUnconditional()); |
| 329 | return getTargetFalse(); |
| 330 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 331 | NodeList getTerminatorEdges() const override; |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 332 | bool isUnconditionalBranch() const override { return isUnconditional(); } |
| 333 | bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 334 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 335 | static bool classof(const Inst *Inst) { return Inst->getKind() == Br; } |
| 336 | |
| 337 | private: |
| 338 | // Conditional branch |
| 339 | InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse); |
| 340 | // Unconditional branch |
| 341 | InstBr(Cfg *Func, CfgNode *Target); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 342 | ~InstBr() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 343 | |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 344 | CfgNode *TargetFalse; // Doubles as unconditional branch target |
| 345 | CfgNode *TargetTrue; // NULL if unconditional branch |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 346 | }; |
| 347 | |
| 348 | // Call instruction. The call target is captured as getSrc(0), and |
| 349 | // arg I is captured as getSrc(I+1). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 350 | class InstCall : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 351 | InstCall(const InstCall &) = delete; |
| 352 | InstCall &operator=(const InstCall &) = delete; |
| 353 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 354 | public: |
| 355 | static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 356 | Operand *CallTarget, bool HasTailCall) { |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 357 | // Set HasSideEffects to true so that the call instruction can't be |
| 358 | // dead-code eliminated. IntrinsicCalls can override this if the |
| 359 | // particular intrinsic is deletable and has no side-effects. |
| 360 | const bool HasSideEffects = true; |
| 361 | const InstKind Kind = Inst::Call; |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 362 | return new (Func->allocateInst<InstCall>()) InstCall( |
| 363 | Func, NumArgs, Dest, CallTarget, HasTailCall, HasSideEffects, Kind); |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 364 | } |
| 365 | void addArg(Operand *Arg) { addSource(Arg); } |
| 366 | Operand *getCallTarget() const { return getSrc(0); } |
| 367 | Operand *getArg(SizeT I) const { return getSrc(I + 1); } |
| 368 | SizeT getNumArgs() const { return getSrcSize() - 1; } |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 369 | bool isTailcall() const { return HasTailCall; } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 370 | void dump(const Cfg *Func) const; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 371 | static bool classof(const Inst *Inst) { return Inst->getKind() == Call; } |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 372 | Type getReturnType() const; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 373 | |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 374 | protected: |
| 375 | InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget, |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 376 | bool HasTailCall, bool HasSideEff, InstKind Kind) |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 377 | : InstHighLevel(Func, Kind, NumArgs + 1, Dest), HasTailCall(HasTailCall) { |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 378 | HasSideEffects = HasSideEff; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 379 | addSource(CallTarget); |
| 380 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 381 | ~InstCall() override {} |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 382 | |
| 383 | private: |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 384 | bool HasTailCall; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 385 | }; |
| 386 | |
| 387 | // Cast instruction (a.k.a. conversion operation). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 388 | class InstCast : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 389 | InstCast(const InstCast &) = delete; |
| 390 | InstCast &operator=(const InstCast &) = delete; |
| 391 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 392 | public: |
| 393 | enum OpKind { |
| 394 | #define X(tag, str) tag, |
| 395 | ICEINSTCAST_TABLE |
| 396 | #undef X |
Jim Stichnoth | 4376d29 | 2014-05-23 13:39:02 -0700 | [diff] [blame] | 397 | _num |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 398 | }; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 399 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 400 | static InstCast *create(Cfg *Func, OpKind CastKind, Variable *Dest, |
| 401 | Operand *Source) { |
| 402 | return new (Func->allocateInst<InstCast>()) |
| 403 | InstCast(Func, CastKind, Dest, Source); |
| 404 | } |
| 405 | OpKind getCastKind() const { return CastKind; } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 406 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 407 | static bool classof(const Inst *Inst) { return Inst->getKind() == Cast; } |
| 408 | |
| 409 | private: |
| 410 | InstCast(Cfg *Func, OpKind CastKind, Variable *Dest, Operand *Source); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 411 | ~InstCast() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 412 | const OpKind CastKind; |
| 413 | }; |
| 414 | |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 415 | // ExtractElement instruction. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 416 | class InstExtractElement : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 417 | InstExtractElement(const InstExtractElement &) = delete; |
| 418 | InstExtractElement &operator=(const InstExtractElement &) = delete; |
| 419 | |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 420 | public: |
| 421 | static InstExtractElement *create(Cfg *Func, Variable *Dest, Operand *Source1, |
| 422 | Operand *Source2) { |
| 423 | return new (Func->allocateInst<InstExtractElement>()) |
| 424 | InstExtractElement(Func, Dest, Source1, Source2); |
| 425 | } |
| 426 | |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 427 | void dump(const Cfg *Func) const override; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 428 | static bool classof(const Inst *Inst) { |
| 429 | return Inst->getKind() == ExtractElement; |
| 430 | } |
| 431 | |
| 432 | private: |
| 433 | InstExtractElement(Cfg *Func, Variable *Dest, Operand *Source1, |
| 434 | Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 435 | ~InstExtractElement() override {} |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 436 | }; |
| 437 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 438 | // Floating-point comparison instruction. The source operands are |
| 439 | // captured in getSrc(0) and getSrc(1). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 440 | class InstFcmp : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 441 | InstFcmp(const InstFcmp &) = delete; |
| 442 | InstFcmp &operator=(const InstFcmp &) = delete; |
| 443 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 444 | public: |
| 445 | enum FCond { |
| 446 | #define X(tag, str) tag, |
| 447 | ICEINSTFCMP_TABLE |
| 448 | #undef X |
Jim Stichnoth | 4376d29 | 2014-05-23 13:39:02 -0700 | [diff] [blame] | 449 | _num |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 450 | }; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 451 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 452 | static InstFcmp *create(Cfg *Func, FCond Condition, Variable *Dest, |
| 453 | Operand *Source1, Operand *Source2) { |
| 454 | return new (Func->allocateInst<InstFcmp>()) |
| 455 | InstFcmp(Func, Condition, Dest, Source1, Source2); |
| 456 | } |
| 457 | FCond getCondition() const { return Condition; } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 458 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 459 | static bool classof(const Inst *Inst) { return Inst->getKind() == Fcmp; } |
| 460 | |
| 461 | private: |
| 462 | InstFcmp(Cfg *Func, FCond Condition, Variable *Dest, Operand *Source1, |
| 463 | Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 464 | ~InstFcmp() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 465 | const FCond Condition; |
| 466 | }; |
| 467 | |
| 468 | // Integer comparison instruction. The source operands are captured |
| 469 | // in getSrc(0) and getSrc(1). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 470 | class InstIcmp : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 471 | InstIcmp(const InstIcmp &) = delete; |
| 472 | InstIcmp &operator=(const InstIcmp &) = delete; |
| 473 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 474 | public: |
| 475 | enum ICond { |
| 476 | #define X(tag, str) tag, |
| 477 | ICEINSTICMP_TABLE |
| 478 | #undef X |
Jim Stichnoth | 4376d29 | 2014-05-23 13:39:02 -0700 | [diff] [blame] | 479 | _num |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 480 | }; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 481 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 482 | static InstIcmp *create(Cfg *Func, ICond Condition, Variable *Dest, |
| 483 | Operand *Source1, Operand *Source2) { |
| 484 | return new (Func->allocateInst<InstIcmp>()) |
| 485 | InstIcmp(Func, Condition, Dest, Source1, Source2); |
| 486 | } |
| 487 | ICond getCondition() const { return Condition; } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 488 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 489 | static bool classof(const Inst *Inst) { return Inst->getKind() == Icmp; } |
| 490 | |
| 491 | private: |
| 492 | InstIcmp(Cfg *Func, ICond Condition, Variable *Dest, Operand *Source1, |
| 493 | Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 494 | ~InstIcmp() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 495 | const ICond Condition; |
| 496 | }; |
| 497 | |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 498 | // InsertElement instruction. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 499 | class InstInsertElement : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 500 | InstInsertElement(const InstInsertElement &) = delete; |
| 501 | InstInsertElement &operator=(const InstInsertElement &) = delete; |
| 502 | |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 503 | public: |
| 504 | static InstInsertElement *create(Cfg *Func, Variable *Dest, Operand *Source1, |
| 505 | Operand *Source2, Operand *Source3) { |
| 506 | return new (Func->allocateInst<InstInsertElement>()) |
| 507 | InstInsertElement(Func, Dest, Source1, Source2, Source3); |
| 508 | } |
| 509 | |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 510 | void dump(const Cfg *Func) const override; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 511 | static bool classof(const Inst *Inst) { |
| 512 | return Inst->getKind() == InsertElement; |
| 513 | } |
| 514 | |
| 515 | private: |
| 516 | InstInsertElement(Cfg *Func, Variable *Dest, Operand *Source1, |
| 517 | Operand *Source2, Operand *Source3); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 518 | ~InstInsertElement() override {} |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 519 | }; |
| 520 | |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 521 | // Call to an intrinsic function. The call target is captured as getSrc(0), |
| 522 | // and arg I is captured as getSrc(I+1). |
| 523 | class InstIntrinsicCall : public InstCall { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 524 | InstIntrinsicCall(const InstIntrinsicCall &) = delete; |
| 525 | InstIntrinsicCall &operator=(const InstIntrinsicCall &) = delete; |
| 526 | |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 527 | public: |
| 528 | static InstIntrinsicCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, |
| 529 | Operand *CallTarget, |
| 530 | const Intrinsics::IntrinsicInfo &Info) { |
| 531 | return new (Func->allocateInst<InstIntrinsicCall>()) |
| 532 | InstIntrinsicCall(Func, NumArgs, Dest, CallTarget, Info); |
| 533 | } |
| 534 | static bool classof(const Inst *Inst) { |
| 535 | return Inst->getKind() == IntrinsicCall; |
| 536 | } |
| 537 | |
| 538 | Intrinsics::IntrinsicInfo getIntrinsicInfo() const { return Info; } |
| 539 | |
| 540 | private: |
| 541 | InstIntrinsicCall(Cfg *Func, SizeT NumArgs, Variable *Dest, |
| 542 | Operand *CallTarget, const Intrinsics::IntrinsicInfo &Info) |
Karl Schimpf | 8df26f3 | 2014-09-19 09:33:26 -0700 | [diff] [blame] | 543 | : InstCall(Func, NumArgs, Dest, CallTarget, false, Info.HasSideEffects, |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 544 | Inst::IntrinsicCall), |
| 545 | Info(Info) {} |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 546 | ~InstIntrinsicCall() override {} |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 547 | const Intrinsics::IntrinsicInfo Info; |
| 548 | }; |
| 549 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 550 | // Load instruction. The source address is captured in getSrc(0). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 551 | class InstLoad : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 552 | InstLoad(const InstLoad &) = delete; |
| 553 | InstLoad &operator=(const InstLoad &) = delete; |
| 554 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 555 | public: |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 556 | static InstLoad *create(Cfg *Func, Variable *Dest, Operand *SourceAddr, |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 557 | uint32_t Align = 1) { |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 558 | // TODO(kschimpf) Stop ignoring alignment specification. |
Jim Stichnoth | c4554d7 | 2014-09-30 16:49:38 -0700 | [diff] [blame] | 559 | (void)Align; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 560 | return new (Func->allocateInst<InstLoad>()) |
| 561 | InstLoad(Func, Dest, SourceAddr); |
| 562 | } |
| 563 | Operand *getSourceAddress() const { return getSrc(0); } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 564 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 565 | static bool classof(const Inst *Inst) { return Inst->getKind() == Load; } |
| 566 | |
| 567 | private: |
| 568 | InstLoad(Cfg *Func, Variable *Dest, Operand *SourceAddr); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 569 | ~InstLoad() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 570 | }; |
| 571 | |
| 572 | // Phi instruction. For incoming edge I, the node is Labels[I] and |
| 573 | // the Phi source operand is getSrc(I). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 574 | class InstPhi : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 575 | InstPhi(const InstPhi &) = delete; |
| 576 | InstPhi &operator=(const InstPhi &) = delete; |
| 577 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 578 | public: |
| 579 | static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) { |
| 580 | return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest); |
| 581 | } |
| 582 | void addArgument(Operand *Source, CfgNode *Label); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 583 | Operand *getOperandForTarget(CfgNode *Target) const; |
Jim Stichnoth | 98712a3 | 2014-10-24 10:59:02 -0700 | [diff] [blame] | 584 | CfgNode *getLabel(SizeT Index) const { return Labels[Index]; } |
Jim Stichnoth | 4775255 | 2014-10-13 17:15:08 -0700 | [diff] [blame] | 585 | void livenessPhiOperand(LivenessBV &Live, CfgNode *Target, |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 586 | Liveness *Liveness); |
Jim Stichnoth | 144cdce | 2014-09-22 16:02:59 -0700 | [diff] [blame] | 587 | Inst *lower(Cfg *Func); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 588 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 589 | static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; } |
| 590 | |
| 591 | private: |
| 592 | InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 593 | void destroy(Cfg *Func) override { |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 594 | Func->deallocateArrayOf<CfgNode *>(Labels); |
| 595 | Inst::destroy(Func); |
| 596 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 597 | ~InstPhi() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 598 | |
| 599 | // Labels[] duplicates the InEdges[] information in the enclosing |
| 600 | // CfgNode, but the Phi instruction is created before InEdges[] |
| 601 | // is available, so it's more complicated to share the list. |
| 602 | CfgNode **Labels; |
| 603 | }; |
| 604 | |
| 605 | // Ret instruction. The return value is captured in getSrc(0), but if |
| 606 | // there is no return value (void-type function), then |
| 607 | // getSrcSize()==0 and hasRetValue()==false. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 608 | class InstRet : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 609 | InstRet(const InstRet &) = delete; |
| 610 | InstRet &operator=(const InstRet &) = delete; |
| 611 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 612 | public: |
| 613 | static InstRet *create(Cfg *Func, Operand *RetValue = NULL) { |
| 614 | return new (Func->allocateInst<InstRet>()) InstRet(Func, RetValue); |
| 615 | } |
| 616 | bool hasRetValue() const { return getSrcSize(); } |
| 617 | Operand *getRetValue() const { |
| 618 | assert(hasRetValue()); |
| 619 | return getSrc(0); |
| 620 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 621 | NodeList getTerminatorEdges() const override { return NodeList(); } |
| 622 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 623 | static bool classof(const Inst *Inst) { return Inst->getKind() == Ret; } |
| 624 | |
| 625 | private: |
| 626 | InstRet(Cfg *Func, Operand *RetValue); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 627 | ~InstRet() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 628 | }; |
| 629 | |
| 630 | // Select instruction. The condition, true, and false operands are captured. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 631 | class InstSelect : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 632 | InstSelect(const InstSelect &) = delete; |
| 633 | InstSelect &operator=(const InstSelect &) = delete; |
| 634 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 635 | public: |
| 636 | static InstSelect *create(Cfg *Func, Variable *Dest, Operand *Condition, |
| 637 | Operand *SourceTrue, Operand *SourceFalse) { |
| 638 | return new (Func->allocateInst<InstSelect>()) |
| 639 | InstSelect(Func, Dest, Condition, SourceTrue, SourceFalse); |
| 640 | } |
| 641 | Operand *getCondition() const { return getSrc(0); } |
| 642 | Operand *getTrueOperand() const { return getSrc(1); } |
| 643 | Operand *getFalseOperand() const { return getSrc(2); } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 644 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 645 | static bool classof(const Inst *Inst) { return Inst->getKind() == Select; } |
| 646 | |
| 647 | private: |
| 648 | InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, Operand *Source1, |
| 649 | Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 650 | ~InstSelect() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 651 | }; |
| 652 | |
| 653 | // Store instruction. The address operand is captured, along with the |
| 654 | // data operand to be stored into the address. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 655 | class InstStore : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 656 | InstStore(const InstStore &) = delete; |
| 657 | InstStore &operator=(const InstStore &) = delete; |
| 658 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 659 | public: |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 660 | static InstStore *create(Cfg *Func, Operand *Data, Operand *Addr, |
| 661 | uint32_t align = 1) { |
| 662 | // TODO(kschimpf) Stop ignoring alignment specification. |
| 663 | (void)align; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 664 | return new (Func->allocateInst<InstStore>()) InstStore(Func, Data, Addr); |
| 665 | } |
| 666 | Operand *getAddr() const { return getSrc(1); } |
| 667 | Operand *getData() const { return getSrc(0); } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 668 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 669 | static bool classof(const Inst *Inst) { return Inst->getKind() == Store; } |
| 670 | |
| 671 | private: |
| 672 | InstStore(Cfg *Func, Operand *Data, Operand *Addr); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 673 | ~InstStore() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 674 | }; |
| 675 | |
| 676 | // Switch instruction. The single source operand is captured as |
| 677 | // getSrc(0). |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 678 | class InstSwitch : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 679 | InstSwitch(const InstSwitch &) = delete; |
| 680 | InstSwitch &operator=(const InstSwitch &) = delete; |
| 681 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 682 | public: |
| 683 | static InstSwitch *create(Cfg *Func, SizeT NumCases, Operand *Source, |
| 684 | CfgNode *LabelDefault) { |
| 685 | return new (Func->allocateInst<InstSwitch>()) |
| 686 | InstSwitch(Func, NumCases, Source, LabelDefault); |
| 687 | } |
| 688 | Operand *getComparison() const { return getSrc(0); } |
| 689 | CfgNode *getLabelDefault() const { return LabelDefault; } |
| 690 | SizeT getNumCases() const { return NumCases; } |
| 691 | uint64_t getValue(SizeT I) const { |
| 692 | assert(I < NumCases); |
| 693 | return Values[I]; |
| 694 | } |
| 695 | CfgNode *getLabel(SizeT I) const { |
| 696 | assert(I < NumCases); |
| 697 | return Labels[I]; |
| 698 | } |
| 699 | void addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 700 | NodeList getTerminatorEdges() const override; |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 701 | bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 702 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 703 | static bool classof(const Inst *Inst) { return Inst->getKind() == Switch; } |
| 704 | |
| 705 | private: |
| 706 | InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, CfgNode *LabelDefault); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 707 | void destroy(Cfg *Func) override { |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 708 | Func->deallocateArrayOf<uint64_t>(Values); |
| 709 | Func->deallocateArrayOf<CfgNode *>(Labels); |
| 710 | Inst::destroy(Func); |
| 711 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 712 | ~InstSwitch() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 713 | |
| 714 | CfgNode *LabelDefault; |
| 715 | SizeT NumCases; // not including the default case |
| 716 | uint64_t *Values; // size is NumCases |
| 717 | CfgNode **Labels; // size is NumCases |
| 718 | }; |
| 719 | |
| 720 | // Unreachable instruction. This is a terminator instruction with no |
| 721 | // operands. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 722 | class InstUnreachable : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 723 | InstUnreachable(const InstUnreachable &) = delete; |
| 724 | InstUnreachable &operator=(const InstUnreachable &) = delete; |
| 725 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 726 | public: |
| 727 | static InstUnreachable *create(Cfg *Func) { |
| 728 | return new (Func->allocateInst<InstUnreachable>()) InstUnreachable(Func); |
| 729 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 730 | NodeList getTerminatorEdges() const override { return NodeList(); } |
| 731 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 732 | static bool classof(const Inst *Inst) { |
| 733 | return Inst->getKind() == Unreachable; |
| 734 | } |
| 735 | |
| 736 | private: |
| 737 | InstUnreachable(Cfg *Func); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 738 | ~InstUnreachable() override {} |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 739 | }; |
| 740 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 741 | // FakeDef instruction. This creates a fake definition of a variable, |
| 742 | // which is how we represent the case when an instruction produces |
| 743 | // multiple results. This doesn't happen with high-level ICE |
| 744 | // instructions, but might with lowered instructions. For example, |
| 745 | // this would be a way to represent condition flags being modified by |
| 746 | // an instruction. |
| 747 | // |
| 748 | // It's generally useful to set the optional source operand to be the |
| 749 | // dest variable of the instruction that actually produces the FakeDef |
| 750 | // dest. Otherwise, the original instruction could be dead-code |
| 751 | // eliminated if its dest operand is unused, and therefore the FakeDef |
| 752 | // dest wouldn't be properly initialized. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 753 | class InstFakeDef : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 754 | InstFakeDef(const InstFakeDef &) = delete; |
| 755 | InstFakeDef &operator=(const InstFakeDef &) = delete; |
| 756 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 757 | public: |
| 758 | static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) { |
| 759 | return new (Func->allocateInst<InstFakeDef>()) InstFakeDef(Func, Dest, Src); |
| 760 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 761 | void emit(const Cfg *Func) const override; |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 762 | void emitIAS(const Cfg * /* Func */) const override {} |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 763 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 764 | static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; } |
| 765 | |
| 766 | private: |
| 767 | InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 768 | ~InstFakeDef() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 769 | }; |
| 770 | |
| 771 | // FakeUse instruction. This creates a fake use of a variable, to |
| 772 | // keep the instruction that produces that variable from being |
| 773 | // dead-code eliminated. This is useful in a variety of lowering |
| 774 | // situations. The FakeUse instruction has no dest, so it can itself |
| 775 | // never be dead-code eliminated. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 776 | class InstFakeUse : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 777 | InstFakeUse(const InstFakeUse &) = delete; |
| 778 | InstFakeUse &operator=(const InstFakeUse &) = delete; |
| 779 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 780 | public: |
| 781 | static InstFakeUse *create(Cfg *Func, Variable *Src) { |
| 782 | return new (Func->allocateInst<InstFakeUse>()) InstFakeUse(Func, Src); |
| 783 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 784 | void emit(const Cfg *Func) const override; |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 785 | void emitIAS(const Cfg * /* Func */) const override {} |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 786 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 787 | static bool classof(const Inst *Inst) { return Inst->getKind() == FakeUse; } |
| 788 | |
| 789 | private: |
| 790 | InstFakeUse(Cfg *Func, Variable *Src); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 791 | ~InstFakeUse() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 792 | }; |
| 793 | |
Jim Stichnoth | 87ff3a1 | 2014-11-14 10:27:29 -0800 | [diff] [blame] | 794 | // FakeKill instruction. This "kills" a set of variables by modeling |
| 795 | // a trivial live range at this instruction for each (implicit) |
| 796 | // variable. The primary use is to indicate that scratch registers |
| 797 | // are killed after a call, so that the register allocator won't |
| 798 | // assign a scratch register to a variable whose live range spans a |
| 799 | // call. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 800 | // |
| 801 | // The FakeKill instruction also holds a pointer to the instruction |
| 802 | // that kills the set of variables, so that if that linked instruction |
| 803 | // gets dead-code eliminated, the FakeKill instruction will as well. |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 804 | class InstFakeKill : public InstHighLevel { |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 805 | InstFakeKill(const InstFakeKill &) = delete; |
| 806 | InstFakeKill &operator=(const InstFakeKill &) = delete; |
| 807 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 808 | public: |
Jim Stichnoth | 87ff3a1 | 2014-11-14 10:27:29 -0800 | [diff] [blame] | 809 | static InstFakeKill *create(Cfg *Func, const Inst *Linked) { |
| 810 | return new (Func->allocateInst<InstFakeKill>()) InstFakeKill(Func, Linked); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 811 | } |
| 812 | const Inst *getLinked() const { return Linked; } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 813 | void emit(const Cfg *Func) const override; |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 814 | void emitIAS(const Cfg * /* Func */) const override {} |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 815 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 816 | static bool classof(const Inst *Inst) { return Inst->getKind() == FakeKill; } |
| 817 | |
| 818 | private: |
Jim Stichnoth | 87ff3a1 | 2014-11-14 10:27:29 -0800 | [diff] [blame] | 819 | InstFakeKill(Cfg *Func, const Inst *Linked); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 820 | ~InstFakeKill() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 821 | |
| 822 | // This instruction is ignored if Linked->isDeleted() is true. |
| 823 | const Inst *Linked; |
| 824 | }; |
| 825 | |
| 826 | // The Target instruction is the base class for all target-specific |
| 827 | // instructions. |
| 828 | class InstTarget : public Inst { |
Jim Stichnoth | 0795ba0 | 2014-10-01 14:23:01 -0700 | [diff] [blame] | 829 | InstTarget(const InstTarget &) = delete; |
| 830 | InstTarget &operator=(const InstTarget &) = delete; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 831 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 832 | public: |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 833 | uint32_t getEmitInstCount() const override { return 1; } |
| 834 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 835 | static bool classof(const Inst *Inst) { return Inst->getKind() >= Target; } |
| 836 | |
| 837 | protected: |
| 838 | InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 839 | : Inst(Func, Kind, MaxSrcs, Dest) { |
| 840 | assert(Kind >= Target); |
| 841 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 842 | ~InstTarget() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 843 | }; |
| 844 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 845 | } // end of namespace Ice |
| 846 | |
Jim Stichnoth | dddaf9c | 2014-12-04 14:09:21 -0800 | [diff] [blame^] | 847 | namespace llvm { |
| 848 | |
Jim Stichnoth | 607e9f0 | 2014-11-06 13:32:05 -0800 | [diff] [blame] | 849 | // Override the default ilist traits so that Inst's private ctor and |
| 850 | // deleted dtor aren't invoked. |
| 851 | template <> |
Jim Stichnoth | dddaf9c | 2014-12-04 14:09:21 -0800 | [diff] [blame^] | 852 | struct ilist_traits<Ice::Inst> : public ilist_default_traits<Ice::Inst> { |
Jim Stichnoth | 607e9f0 | 2014-11-06 13:32:05 -0800 | [diff] [blame] | 853 | Ice::Inst *createSentinel() const { |
| 854 | return static_cast<Ice::Inst *>(&Sentinel); |
| 855 | } |
| 856 | static void destroySentinel(Ice::Inst *) {} |
| 857 | Ice::Inst *provideInitialHead() const { return createSentinel(); } |
| 858 | Ice::Inst *ensureHead(Ice::Inst *) const { return createSentinel(); } |
| 859 | static void noteHead(Ice::Inst *, Ice::Inst *) {} |
| 860 | void deleteNode(Ice::Inst *) {} |
| 861 | |
| 862 | private: |
| 863 | mutable ilist_half_node<Ice::Inst> Sentinel; |
| 864 | }; |
| 865 | |
Jim Stichnoth | dddaf9c | 2014-12-04 14:09:21 -0800 | [diff] [blame^] | 866 | } // end of namespace llvm |
| 867 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 868 | #endif // SUBZERO_SRC_ICEINST_H |