Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 //===- subzero/src/IceInstX8632.h - Low-level x86 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 InstX8632 and OperandX8632 classes and | |
| 11 // their subclasses. This represents the machine instructions and | |
| 12 // operands used for x86-32 code selection. | |
| 13 // | |
| 14 //===----------------------------------------------------------------------===// | |
| 15 | |
| 16 #ifndef SUBZERO_SRC_ICEINSTX8632_H | |
| 17 #define SUBZERO_SRC_ICEINSTX8632_H | |
| 18 | |
| 19 #include "IceDefs.h" | |
| 20 #include "IceInst.h" | |
| 21 #include "IceInstX8632.def" | |
| 22 #include "IceOperand.h" | |
| 23 | |
| 24 namespace Ice { | |
| 25 | |
| 26 class TargetX8632; | |
| 27 | |
| 28 // OperandX8632 extends the Operand hierarchy. Its subclasses are | |
| 29 // OperandX8632Mem and VariableSplit. | |
| 30 class OperandX8632 : public Operand { | |
| 31 public: | |
| 32 enum OperandTypeX8632 { | |
| 33 __Start = Operand::kTarget, | |
|
JF
2014/05/04 23:54:58
Identifiers starting with a double underscore are
Jim Stichnoth
2014/05/05 07:03:55
Done.
| |
| 34 kMem, | |
| 35 kSplit | |
| 36 }; | |
| 37 virtual void emit(const Cfg *Func) const = 0; | |
| 38 void dump(const Cfg *Func) const; | |
| 39 | |
| 40 protected: | |
| 41 OperandX8632(OperandTypeX8632 Kind, Type Ty) | |
|
jvoung (off chromium)
2014/05/03 00:13:28
nitty-nit: OperandKindX8632 to match the variable
Jim Stichnoth
2014/05/05 07:03:55
Done.
| |
| 42 : Operand(static_cast<OperandKind>(Kind), Ty) {} | |
| 43 virtual ~OperandX8632() {} | |
| 44 | |
| 45 private: | |
| 46 OperandX8632(const OperandX8632 &) LLVM_DELETED_FUNCTION; | |
| 47 OperandX8632 &operator=(const OperandX8632 &) LLVM_DELETED_FUNCTION; | |
| 48 }; | |
| 49 | |
| 50 // OperandX8632Mem represents the m32 addressing mode, with optional | |
| 51 // base and index registers, a constant offset, and a fixed shift | |
| 52 // value for the index register. | |
| 53 class OperandX8632Mem : public OperandX8632 { | |
| 54 public: | |
| 55 static OperandX8632Mem *create(Cfg *Func, Type Ty, Variable *Base, | |
| 56 Constant *Offset, Variable *Index = NULL, | |
| 57 uint32_t Shift = 0) { | |
|
jvoung (off chromium)
2014/05/03 00:13:28
Should something assert that the shift is reasonab
Jim Stichnoth
2014/05/05 07:03:55
Done - in the ctor in IceInstX8632.cpp.
| |
| 58 return new (Func->allocate<OperandX8632Mem>()) | |
| 59 OperandX8632Mem(Func, Ty, Base, Offset, Index, Shift); | |
| 60 } | |
| 61 Variable *getBase() const { return Base; } | |
| 62 Constant *getOffset() const { return Offset; } | |
| 63 Variable *getIndex() const { return Index; } | |
| 64 uint32_t getShift() const { return Shift; } | |
| 65 virtual void emit(const Cfg *Func) const; | |
| 66 virtual void dump(const Cfg *Func) const; | |
| 67 | |
| 68 static bool classof(const Operand *Operand) { | |
| 69 return Operand->getKind() == static_cast<OperandKind>(kMem); | |
| 70 } | |
| 71 | |
| 72 private: | |
| 73 OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, | |
| 74 Variable *Index, uint32_t Shift); | |
| 75 OperandX8632Mem(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; | |
| 76 OperandX8632Mem &operator=(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; | |
| 77 virtual ~OperandX8632Mem() {} | |
|
JF
2014/05/04 23:54:58
Delete the owned members.
Jim Stichnoth
2014/05/05 07:03:55
I don't think there are actually any owned members
| |
| 78 Variable *Base; | |
| 79 Constant *Offset; | |
| 80 Variable *Index; | |
| 81 uint32_t Shift; | |
| 82 }; | |
| 83 | |
| 84 // VariableSplit is a way to treat an f64 memory location as a pair | |
| 85 // of i32 locations (Low and High). This is needed for some cases | |
| 86 // of the Bitcast instruction. Since it's not possible for integer | |
| 87 // registers to access the XMM registers and vice versa, the | |
| 88 // lowering forces the f64 to be spilled to the stack and then | |
| 89 // accesses through the VariableSplit. | |
| 90 class VariableSplit : public OperandX8632 { | |
| 91 public: | |
| 92 enum Portion { | |
| 93 Low, | |
| 94 High | |
| 95 }; | |
| 96 static VariableSplit *create(Cfg *Func, Variable *Var, Portion Part) { | |
| 97 return new (Func->allocate<VariableSplit>()) VariableSplit(Func, Var, Part); | |
| 98 } | |
| 99 virtual void emit(const Cfg *Func) const; | |
| 100 virtual void dump(const Cfg *Func) const; | |
| 101 | |
| 102 static bool classof(const Operand *Operand) { | |
| 103 return Operand->getKind() == static_cast<OperandKind>(kSplit); | |
| 104 } | |
| 105 | |
| 106 private: | |
| 107 VariableSplit(Cfg *Func, Variable *Var, Portion Part) | |
| 108 : OperandX8632(kSplit, IceType_i32), Var(Var), Part(Part) { | |
| 109 assert(Var->getType() == IceType_f64); | |
| 110 Vars = Func->allocateArrayOf<Variable *>(1); | |
| 111 Vars[0] = Var; | |
| 112 NumVars = 1; | |
| 113 } | |
| 114 VariableSplit(const VariableSplit &) LLVM_DELETED_FUNCTION; | |
| 115 VariableSplit &operator=(const VariableSplit &) LLVM_DELETED_FUNCTION; | |
| 116 virtual ~VariableSplit() {} | |
|
JF
2014/05/04 23:54:58
Delete Vars.
Jim Stichnoth
2014/05/05 07:03:55
Done.
| |
| 117 Variable *Var; | |
| 118 Portion Part; | |
| 119 }; | |
| 120 | |
| 121 class InstX8632 : public InstTarget { | |
| 122 public: | |
| 123 enum InstKindX8632 { | |
| 124 __Start = Inst::Target, | |
| 125 Adc, | |
|
jvoung (off chromium)
2014/05/03 00:13:28
These are overloaded for various types of argument
JF
2014/05/04 23:54:58
I think you'll further want information on how ins
Jim Stichnoth
2014/05/05 07:03:55
My somewhat vague intention for SFI is to integrat
Jim Stichnoth
2014/05/05 07:03:55
I doubt we'll make use of those kinds of propertie
| |
| 126 Add, | |
| 127 Addss, | |
| 128 And, | |
| 129 Br, | |
| 130 Call, | |
| 131 Cdq, | |
| 132 Cvt, | |
| 133 Div, | |
| 134 Divss, | |
| 135 Fld, | |
| 136 Fstp, | |
| 137 Icmp, | |
| 138 Idiv, | |
| 139 Imul, | |
| 140 Label, | |
| 141 Load, | |
| 142 Mov, | |
| 143 Movsx, | |
| 144 Movzx, | |
| 145 Mul, | |
| 146 Mulss, | |
| 147 Or, | |
| 148 Pop, | |
| 149 Push, | |
| 150 Ret, | |
| 151 Sar, | |
| 152 Sbb, | |
| 153 Shl, | |
| 154 Shld, | |
| 155 Shr, | |
| 156 Shrd, | |
| 157 Store, | |
| 158 Sub, | |
| 159 Subss, | |
| 160 Test, | |
| 161 Ucomiss, | |
| 162 Xor | |
| 163 }; | |
| 164 static const char *getWidthString(Type Ty); | |
| 165 virtual void emit(const Cfg *Func) const = 0; | |
| 166 virtual void dump(const Cfg *Func) const; | |
| 167 | |
| 168 protected: | |
| 169 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) | |
| 170 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} | |
| 171 virtual ~InstX8632() {} | |
| 172 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { | |
| 173 return Inst->getKind() == static_cast<InstKind>(MyKind); | |
| 174 } | |
| 175 | |
| 176 private: | |
| 177 InstX8632(const InstX8632 &) LLVM_DELETED_FUNCTION; | |
| 178 InstX8632 &operator=(const InstX8632 &) LLVM_DELETED_FUNCTION; | |
| 179 }; | |
| 180 | |
| 181 // InstX8632Label represents an intra-block label that is the | |
| 182 // target of an intra-block branch. These are used for lowering i1 | |
| 183 // calculations, Select instructions, and 64-bit compares on a 32-bit | |
| 184 // architecture, without basic block splitting. Basic block splitting | |
| 185 // is not so desirable for several reasons, one of which is the impact | |
| 186 // on decisions based on whether a variable's live range spans | |
| 187 // multiple basic blocks. | |
| 188 // | |
| 189 // Intra-block control flow must be used with caution. Consider the | |
| 190 // sequence for "c = (a >= b ? x : y)". | |
| 191 // cmp a, b | |
| 192 // br lt, L1 | |
| 193 // mov c, x | |
| 194 // jmp L2 | |
| 195 // L1: | |
| 196 // mov c, y | |
| 197 // L2: | |
| 198 // | |
| 199 // Labels L1 and L2 are intra-block labels. Without knowledge of the | |
| 200 // intra-block control flow, liveness analysis will determine the "mov | |
| 201 // c, x" instruction to be dead. One way to prevent this is to insert | |
| 202 // a "FakeUse(c)" instruction anywhere between the two "mov c, ..." | |
| 203 // instructions, e.g.: | |
| 204 // | |
| 205 // cmp a, b | |
| 206 // br lt, L1 | |
| 207 // mov c, x | |
| 208 // jmp L2 | |
| 209 // FakeUse(c) | |
| 210 // L1: | |
| 211 // mov c, y | |
| 212 // L2: | |
| 213 // | |
| 214 // The down-side is that "mov c, x" can never be dead-code eliminated | |
| 215 // even if there are no uses of c. As unlikely as this situation is, | |
| 216 // it may be prevented by running dead code elimination before | |
| 217 // lowering. | |
| 218 class InstX8632Label : public InstX8632 { | |
| 219 public: | |
| 220 static InstX8632Label *create(Cfg *Func, TargetX8632 *Target) { | |
| 221 return new (Func->allocate<InstX8632Label>()) InstX8632Label(Func, Target); | |
| 222 } | |
| 223 IceString getName(const Cfg *Func) const; | |
| 224 virtual void emit(const Cfg *Func) const; | |
| 225 virtual void dump(const Cfg *Func) const; | |
| 226 | |
| 227 private: | |
| 228 InstX8632Label(Cfg *Func, TargetX8632 *Target); | |
| 229 InstX8632Label(const InstX8632Label &) LLVM_DELETED_FUNCTION; | |
| 230 InstX8632Label &operator=(const InstX8632Label &) LLVM_DELETED_FUNCTION; | |
| 231 virtual ~InstX8632Label() {} | |
| 232 SizeT Number; // used only for unique label string generation | |
| 233 }; | |
| 234 | |
| 235 // Conditional and unconditional branch instruction. | |
| 236 class InstX8632Br : public InstX8632 { | |
| 237 public: | |
| 238 enum BrCond { | |
| 239 #define X(tag, dump, emit) tag, | |
| 240 ICEINSTX8632BR_TABLE | |
| 241 #undef X | |
| 242 Br_None | |
| 243 }; | |
| 244 | |
| 245 // Create a conditional branch to a node. | |
| 246 static InstX8632Br *create(Cfg *Func, CfgNode *TargetTrue, | |
| 247 CfgNode *TargetFalse, BrCond Condition) { | |
| 248 return new (Func->allocate<InstX8632Br>()) | |
| 249 InstX8632Br(Func, TargetTrue, TargetFalse, NULL, Condition); | |
| 250 } | |
| 251 // Create an unconditional branch to a node. | |
| 252 static InstX8632Br *create(Cfg *Func, CfgNode *Target) { | |
| 253 return new (Func->allocate<InstX8632Br>()) | |
| 254 InstX8632Br(Func, NULL, Target, NULL, Br_None); | |
| 255 } | |
| 256 // Create a non-terminator conditional branch to a node, with a | |
| 257 // fallthrough to the next instruction in the current node. This is | |
| 258 // used for switch lowering. | |
| 259 static InstX8632Br *create(Cfg *Func, CfgNode *Target, BrCond Condition) { | |
| 260 return new (Func->allocate<InstX8632Br>()) | |
| 261 InstX8632Br(Func, Target, NULL, NULL, Condition); | |
| 262 } | |
| 263 // Create a conditional intra-block branch (or unconditional, if | |
| 264 // Condition==None) to a label in the current block. | |
| 265 static InstX8632Br *create(Cfg *Func, InstX8632Label *Label, | |
| 266 BrCond Condition) { | |
| 267 return new (Func->allocate<InstX8632Br>()) | |
| 268 InstX8632Br(Func, NULL, NULL, Label, Condition); | |
| 269 } | |
| 270 CfgNode *getTargetTrue() const { return TargetTrue; } | |
| 271 CfgNode *getTargetFalse() const { return TargetFalse; } | |
| 272 virtual void emit(const Cfg *Func) const; | |
| 273 virtual void dump(const Cfg *Func) const; | |
| 274 static bool classof(const Inst *Inst) { return isClassof(Inst, Br); } | |
| 275 | |
| 276 private: | |
| 277 InstX8632Br(Cfg *Func, CfgNode *TargetTrue, CfgNode *TargetFalse, | |
| 278 InstX8632Label *Label, BrCond Condition); | |
| 279 InstX8632Br(const InstX8632Br &) LLVM_DELETED_FUNCTION; | |
| 280 InstX8632Br &operator=(const InstX8632Br &) LLVM_DELETED_FUNCTION; | |
| 281 virtual ~InstX8632Br() {} | |
|
JF
2014/05/04 23:54:58
Delete owned members.
Jim Stichnoth
2014/05/05 07:03:55
None are owned by this instruction.
| |
| 282 BrCond Condition; | |
| 283 CfgNode *TargetTrue; | |
| 284 CfgNode *TargetFalse; | |
| 285 InstX8632Label *Label; // Intra-block branch target | |
| 286 }; | |
| 287 | |
| 288 // Call instruction. Arguments should have already been pushed. | |
| 289 class InstX8632Call : public InstX8632 { | |
| 290 public: | |
| 291 static InstX8632Call *create(Cfg *Func, Variable *Dest, Operand *CallTarget) { | |
| 292 return new (Func->allocate<InstX8632Call>()) | |
| 293 InstX8632Call(Func, Dest, CallTarget); | |
| 294 } | |
| 295 Operand *getCallTarget() const { return getSrc(0); } | |
| 296 virtual void emit(const Cfg *Func) const; | |
| 297 virtual void dump(const Cfg *Func) const; | |
| 298 static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } | |
| 299 | |
| 300 private: | |
| 301 InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget); | |
| 302 InstX8632Call(const InstX8632Call &) LLVM_DELETED_FUNCTION; | |
| 303 InstX8632Call &operator=(const InstX8632Call &) LLVM_DELETED_FUNCTION; | |
| 304 virtual ~InstX8632Call() {} | |
| 305 }; | |
| 306 | |
| 307 // See the definition of emitTwoAddress() for a description of | |
| 308 // ShiftHack. | |
| 309 void emitTwoAddress(const char *Opcode, const Inst *Inst, const Cfg *Func, | |
| 310 bool ShiftHack = false); | |
| 311 | |
| 312 template <InstX8632::InstKindX8632 K, bool ShiftHack = false> | |
|
JF
2014/05/04 23:54:58
Weird space before template?
Jim Stichnoth
2014/05/05 07:03:55
OK, I must have forgotten to do a "make format" (w
| |
| 313 class InstX8632Binop : public InstX8632 { | |
| 314 public: | |
| 315 // Create an ordinary binary-op instruction like add or sub. | |
| 316 static InstX8632Binop *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 317 return new (Func->allocate<InstX8632Binop>()) | |
| 318 InstX8632Binop(Func, Dest, Source); | |
| 319 } | |
| 320 virtual void emit(const Cfg *Func) const { | |
| 321 emitTwoAddress(Opcode, this, Func, ShiftHack); | |
| 322 } | |
| 323 virtual void dump(const Cfg *Func) const { | |
| 324 Ostream &Str = Func->getContext()->getStrDump(); | |
| 325 dumpDest(Func); | |
| 326 Str << " = " << Opcode << "." << getDest()->getType() << " "; | |
| 327 dumpSources(Func); | |
| 328 } | |
| 329 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | |
| 330 | |
| 331 private: | |
| 332 InstX8632Binop(Cfg *Func, Variable *Dest, Operand *Source) | |
| 333 : InstX8632(Func, K, 2, Dest) { | |
| 334 addSource(Dest); | |
| 335 addSource(Source); | |
| 336 } | |
| 337 InstX8632Binop(const InstX8632Binop &) LLVM_DELETED_FUNCTION; | |
| 338 InstX8632Binop &operator=(const InstX8632Binop &) LLVM_DELETED_FUNCTION; | |
| 339 virtual ~InstX8632Binop() {} | |
| 340 static const char *Opcode; | |
| 341 }; | |
| 342 | |
| 343 template <InstX8632::InstKindX8632 K> class InstX8632Ternop : public InstX8632 { | |
| 344 public: | |
| 345 // Create a ternary-op instruction like div or idiv. | |
| 346 static InstX8632Ternop *create(Cfg *Func, Variable *Dest, Operand *Source1, | |
| 347 Operand *Source2) { | |
| 348 return new (Func->allocate<InstX8632Ternop>()) | |
| 349 InstX8632Ternop(Func, Dest, Source1, Source2); | |
| 350 } | |
| 351 virtual void emit(const Cfg *Func) const { | |
| 352 Ostream &Str = Func->getContext()->getStrEmit(); | |
| 353 assert(getSrcSize() == 3); | |
| 354 Str << "\t" << Opcode << "\t"; | |
| 355 getSrc(1)->emit(Func); | |
| 356 Str << "\n"; | |
| 357 } | |
| 358 virtual void dump(const Cfg *Func) const { | |
| 359 Ostream &Str = Func->getContext()->getStrDump(); | |
| 360 dumpDest(Func); | |
| 361 Str << " = " << Opcode << "." << getDest()->getType() << " "; | |
| 362 dumpSources(Func); | |
| 363 } | |
| 364 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | |
| 365 | |
| 366 private: | |
| 367 InstX8632Ternop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2) | |
| 368 : InstX8632(Func, K, 3, Dest) { | |
| 369 addSource(Dest); | |
| 370 addSource(Source1); | |
| 371 addSource(Source2); | |
| 372 } | |
| 373 InstX8632Ternop(const InstX8632Ternop &) LLVM_DELETED_FUNCTION; | |
| 374 InstX8632Ternop &operator=(const InstX8632Ternop &) LLVM_DELETED_FUNCTION; | |
| 375 virtual ~InstX8632Ternop() {} | |
| 376 static const char *Opcode; | |
| 377 }; | |
| 378 | |
| 379 typedef InstX8632Binop<InstX8632::Add> InstX8632Add; | |
| 380 typedef InstX8632Binop<InstX8632::Adc> InstX8632Adc; | |
| 381 typedef InstX8632Binop<InstX8632::Addss> InstX8632Addss; | |
| 382 typedef InstX8632Binop<InstX8632::Sub> InstX8632Sub; | |
| 383 typedef InstX8632Binop<InstX8632::Subss> InstX8632Subss; | |
| 384 typedef InstX8632Binop<InstX8632::Sbb> InstX8632Sbb; | |
| 385 typedef InstX8632Binop<InstX8632::And> InstX8632And; | |
| 386 typedef InstX8632Binop<InstX8632::Or> InstX8632Or; | |
| 387 typedef InstX8632Binop<InstX8632::Xor> InstX8632Xor; | |
| 388 typedef InstX8632Binop<InstX8632::Imul> InstX8632Imul; | |
| 389 typedef InstX8632Binop<InstX8632::Mulss> InstX8632Mulss; | |
| 390 typedef InstX8632Binop<InstX8632::Divss> InstX8632Divss; | |
| 391 typedef InstX8632Binop<InstX8632::Shl, true> InstX8632Shl; | |
| 392 typedef InstX8632Binop<InstX8632::Shr, true> InstX8632Shr; | |
| 393 typedef InstX8632Binop<InstX8632::Sar, true> InstX8632Sar; | |
| 394 typedef InstX8632Ternop<InstX8632::Idiv> InstX8632Idiv; | |
| 395 typedef InstX8632Ternop<InstX8632::Div> InstX8632Div; | |
| 396 | |
| 397 // Mul instruction - unsigned multiply. | |
| 398 class InstX8632Mul : public InstX8632 { | |
| 399 public: | |
| 400 static InstX8632Mul *create(Cfg *Func, Variable *Dest, Variable *Source1, | |
| 401 Operand *Source2) { | |
| 402 return new (Func->allocate<InstX8632Mul>()) | |
| 403 InstX8632Mul(Func, Dest, Source1, Source2); | |
| 404 } | |
| 405 virtual void emit(const Cfg *Func) const; | |
| 406 virtual void dump(const Cfg *Func) const; | |
| 407 static bool classof(const Inst *Inst) { return isClassof(Inst, Mul); } | |
| 408 | |
| 409 private: | |
| 410 InstX8632Mul(Cfg *Func, Variable *Dest, Variable *Source1, Operand *Source2); | |
| 411 InstX8632Mul(const InstX8632Mul &) LLVM_DELETED_FUNCTION; | |
| 412 InstX8632Mul &operator=(const InstX8632Mul &) LLVM_DELETED_FUNCTION; | |
| 413 virtual ~InstX8632Mul() {} | |
| 414 }; | |
| 415 | |
| 416 // Shld instruction - shift across a pair of operands. | |
| 417 class InstX8632Shld : public InstX8632 { | |
|
jvoung (off chromium)
2014/05/03 00:13:28
Note, the (old) 32-bit validator did not accept sh
Jim Stichnoth
2014/05/05 07:03:55
Done, added a TODO. I assume the same is true for
| |
| 418 public: | |
| 419 static InstX8632Shld *create(Cfg *Func, Variable *Dest, Variable *Source1, | |
| 420 Variable *Source2) { | |
| 421 return new (Func->allocate<InstX8632Shld>()) | |
| 422 InstX8632Shld(Func, Dest, Source1, Source2); | |
| 423 } | |
| 424 virtual void emit(const Cfg *Func) const; | |
| 425 virtual void dump(const Cfg *Func) const; | |
| 426 static bool classof(const Inst *Inst) { return isClassof(Inst, Shld); } | |
| 427 | |
| 428 private: | |
| 429 InstX8632Shld(Cfg *Func, Variable *Dest, Variable *Source1, | |
| 430 Variable *Source2); | |
| 431 InstX8632Shld(const InstX8632Shld &) LLVM_DELETED_FUNCTION; | |
| 432 InstX8632Shld &operator=(const InstX8632Shld &) LLVM_DELETED_FUNCTION; | |
| 433 virtual ~InstX8632Shld() {} | |
| 434 }; | |
| 435 | |
| 436 // Shrd instruction - shift across a pair of operands. | |
|
jvoung (off chromium)
2014/05/03 00:13:28
Nit: indent the comments consistently?
E.g., this
Jim Stichnoth
2014/05/05 07:03:55
Another victim of my "make format" fail. :(
| |
| 437 class InstX8632Shrd : public InstX8632 { | |
| 438 public: | |
| 439 static InstX8632Shrd *create(Cfg *Func, Variable *Dest, Variable *Source1, | |
| 440 Variable *Source2) { | |
| 441 return new (Func->allocate<InstX8632Shrd>()) | |
| 442 InstX8632Shrd(Func, Dest, Source1, Source2); | |
| 443 } | |
| 444 virtual void emit(const Cfg *Func) const; | |
| 445 virtual void dump(const Cfg *Func) const; | |
| 446 static bool classof(const Inst *Inst) { return isClassof(Inst, Shrd); } | |
| 447 | |
| 448 private: | |
| 449 InstX8632Shrd(Cfg *Func, Variable *Dest, Variable *Source1, | |
| 450 Variable *Source2); | |
| 451 InstX8632Shrd(const InstX8632Shrd &) LLVM_DELETED_FUNCTION; | |
| 452 InstX8632Shrd &operator=(const InstX8632Shrd &) LLVM_DELETED_FUNCTION; | |
| 453 virtual ~InstX8632Shrd() {} | |
| 454 }; | |
| 455 | |
| 456 // Cdq instruction - sign-extend eax into edx | |
| 457 class InstX8632Cdq : public InstX8632 { | |
| 458 public: | |
| 459 static InstX8632Cdq *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 460 return new (Func->allocate<InstX8632Cdq>()) | |
| 461 InstX8632Cdq(Func, Dest, Source); | |
| 462 } | |
| 463 virtual void emit(const Cfg *Func) const; | |
| 464 virtual void dump(const Cfg *Func) const; | |
| 465 static bool classof(const Inst *Inst) { return isClassof(Inst, Cdq); } | |
| 466 | |
| 467 private: | |
| 468 InstX8632Cdq(Cfg *Func, Variable *Dest, Operand *Source); | |
| 469 InstX8632Cdq(const InstX8632Cdq &) LLVM_DELETED_FUNCTION; | |
| 470 InstX8632Cdq &operator=(const InstX8632Cdq &) LLVM_DELETED_FUNCTION; | |
| 471 virtual ~InstX8632Cdq() {} | |
| 472 }; | |
| 473 | |
| 474 // Cvt instruction - wrapper for cvtsX2sY where X and Y are in {s,d,i} | |
| 475 // as appropriate. s=float, d=double, i=int. X and Y are determined | |
| 476 // from dest/src types. Sign and zero extension on the integer | |
| 477 // operand needs to be done separately. | |
| 478 class InstX8632Cvt : public InstX8632 { | |
| 479 public: | |
| 480 static InstX8632Cvt *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 481 return new (Func->allocate<InstX8632Cvt>()) | |
| 482 InstX8632Cvt(Func, Dest, Source); | |
| 483 } | |
| 484 virtual void emit(const Cfg *Func) const; | |
| 485 virtual void dump(const Cfg *Func) const; | |
| 486 static bool classof(const Inst *Inst) { return isClassof(Inst, Cvt); } | |
| 487 | |
| 488 private: | |
| 489 InstX8632Cvt(Cfg *Func, Variable *Dest, Operand *Source); | |
| 490 InstX8632Cvt(const InstX8632Cvt &) LLVM_DELETED_FUNCTION; | |
| 491 InstX8632Cvt &operator=(const InstX8632Cvt &) LLVM_DELETED_FUNCTION; | |
| 492 virtual ~InstX8632Cvt() {} | |
| 493 }; | |
| 494 | |
| 495 // cmp - Integer compare instruction. | |
| 496 class InstX8632Icmp : public InstX8632 { | |
| 497 public: | |
| 498 static InstX8632Icmp *create(Cfg *Func, Operand *Src1, Operand *Src2) { | |
| 499 return new (Func->allocate<InstX8632Icmp>()) | |
| 500 InstX8632Icmp(Func, Src1, Src2); | |
| 501 } | |
| 502 virtual void emit(const Cfg *Func) const; | |
| 503 virtual void dump(const Cfg *Func) const; | |
| 504 static bool classof(const Inst *Inst) { return isClassof(Inst, Icmp); } | |
| 505 | |
| 506 private: | |
| 507 InstX8632Icmp(Cfg *Func, Operand *Src1, Operand *Src2); | |
| 508 InstX8632Icmp(const InstX8632Icmp &) LLVM_DELETED_FUNCTION; | |
| 509 InstX8632Icmp &operator=(const InstX8632Icmp &) LLVM_DELETED_FUNCTION; | |
| 510 virtual ~InstX8632Icmp() {} | |
| 511 }; | |
| 512 | |
| 513 // ucomiss/ucomisd - floating-point compare instruction. | |
| 514 class InstX8632Ucomiss : public InstX8632 { | |
| 515 public: | |
| 516 static InstX8632Ucomiss *create(Cfg *Func, Operand *Src1, Operand *Src2) { | |
| 517 return new (Func->allocate<InstX8632Ucomiss>()) | |
| 518 InstX8632Ucomiss(Func, Src1, Src2); | |
| 519 } | |
| 520 virtual void emit(const Cfg *Func) const; | |
| 521 virtual void dump(const Cfg *Func) const; | |
| 522 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } | |
| 523 | |
| 524 private: | |
| 525 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); | |
| 526 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; | |
| 527 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; | |
| 528 virtual ~InstX8632Ucomiss() {} | |
| 529 }; | |
| 530 | |
| 531 // Test instruction. | |
| 532 class InstX8632Test : public InstX8632 { | |
| 533 public: | |
| 534 static InstX8632Test *create(Cfg *Func, Operand *Source1, Operand *Source2) { | |
| 535 return new (Func->allocate<InstX8632Test>()) | |
| 536 InstX8632Test(Func, Source1, Source2); | |
| 537 } | |
| 538 virtual void emit(const Cfg *Func) const; | |
| 539 virtual void dump(const Cfg *Func) const; | |
| 540 static bool classof(const Inst *Inst) { return isClassof(Inst, Test); } | |
| 541 | |
| 542 private: | |
| 543 InstX8632Test(Cfg *Func, Operand *Source1, Operand *Source2); | |
| 544 InstX8632Test(const InstX8632Test &) LLVM_DELETED_FUNCTION; | |
| 545 InstX8632Test &operator=(const InstX8632Test &) LLVM_DELETED_FUNCTION; | |
| 546 virtual ~InstX8632Test() {} | |
| 547 }; | |
| 548 | |
| 549 // This is essentially a "mov" instruction with an OperandX8632Mem | |
| 550 // operand instead of Variable as the destination. It's important | |
| 551 // for liveness that there is no Dest operand. | |
| 552 class InstX8632Store : public InstX8632 { | |
| 553 public: | |
| 554 static InstX8632Store *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) { | |
| 555 return new (Func->allocate<InstX8632Store>()) | |
| 556 InstX8632Store(Func, Value, Mem); | |
| 557 } | |
| 558 virtual void emit(const Cfg *Func) const; | |
| 559 virtual void dump(const Cfg *Func) const; | |
| 560 static bool classof(const Inst *Inst) { return isClassof(Inst, Store); } | |
| 561 | |
| 562 private: | |
| 563 InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem); | |
| 564 InstX8632Store(const InstX8632Store &) LLVM_DELETED_FUNCTION; | |
| 565 InstX8632Store &operator=(const InstX8632Store &) LLVM_DELETED_FUNCTION; | |
| 566 virtual ~InstX8632Store() {} | |
| 567 }; | |
| 568 | |
| 569 // Move/assignment instruction - wrapper for mov/movss/movsd. | |
| 570 class InstX8632Mov : public InstX8632 { | |
| 571 public: | |
| 572 static InstX8632Mov *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 573 return new (Func->allocate<InstX8632Mov>()) | |
| 574 InstX8632Mov(Func, Dest, Source); | |
| 575 } | |
| 576 virtual bool isRedundantAssign() const; | |
| 577 virtual void emit(const Cfg *Func) const; | |
| 578 virtual void dump(const Cfg *Func) const; | |
| 579 static bool classof(const Inst *Inst) { return isClassof(Inst, Mov); } | |
| 580 | |
| 581 private: | |
| 582 InstX8632Mov(Cfg *Func, Variable *Dest, Operand *Source); | |
| 583 InstX8632Mov(const InstX8632Mov &) LLVM_DELETED_FUNCTION; | |
| 584 InstX8632Mov &operator=(const InstX8632Mov &) LLVM_DELETED_FUNCTION; | |
| 585 virtual ~InstX8632Mov() {} | |
| 586 }; | |
| 587 | |
| 588 // Movsx - copy from a narrower integer type to a wider integer | |
| 589 // type, with sign extension. | |
| 590 class InstX8632Movsx : public InstX8632 { | |
| 591 public: | |
| 592 static InstX8632Movsx *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 593 return new (Func->allocate<InstX8632Movsx>()) | |
| 594 InstX8632Movsx(Func, Dest, Source); | |
| 595 } | |
| 596 virtual void emit(const Cfg *Func) const; | |
| 597 virtual void dump(const Cfg *Func) const; | |
| 598 static bool classof(const Inst *Inst) { return isClassof(Inst, Movsx); } | |
| 599 | |
| 600 private: | |
| 601 InstX8632Movsx(Cfg *Func, Variable *Dest, Operand *Source); | |
| 602 InstX8632Movsx(const InstX8632Movsx &) LLVM_DELETED_FUNCTION; | |
| 603 InstX8632Movsx &operator=(const InstX8632Movsx &) LLVM_DELETED_FUNCTION; | |
| 604 virtual ~InstX8632Movsx() {} | |
| 605 }; | |
| 606 | |
| 607 // Movsx - copy from a narrower integer type to a wider integer | |
| 608 // type, with zero extension. | |
| 609 class InstX8632Movzx : public InstX8632 { | |
| 610 public: | |
| 611 static InstX8632Movzx *create(Cfg *Func, Variable *Dest, Operand *Source) { | |
| 612 return new (Func->allocate<InstX8632Movzx>()) | |
| 613 InstX8632Movzx(Func, Dest, Source); | |
| 614 } | |
| 615 virtual void emit(const Cfg *Func) const; | |
| 616 virtual void dump(const Cfg *Func) const; | |
| 617 static bool classof(const Inst *Inst) { return isClassof(Inst, Movzx); } | |
| 618 | |
| 619 private: | |
| 620 InstX8632Movzx(Cfg *Func, Variable *Dest, Operand *Source); | |
| 621 InstX8632Movzx(const InstX8632Movzx &) LLVM_DELETED_FUNCTION; | |
| 622 InstX8632Movzx &operator=(const InstX8632Movzx &) LLVM_DELETED_FUNCTION; | |
| 623 virtual ~InstX8632Movzx() {} | |
| 624 }; | |
| 625 | |
| 626 // Fld - load a value onto the x87 FP stack. | |
| 627 class InstX8632Fld : public InstX8632 { | |
| 628 public: | |
| 629 static InstX8632Fld *create(Cfg *Func, Operand *Src) { | |
| 630 return new (Func->allocate<InstX8632Fld>()) InstX8632Fld(Func, Src); | |
| 631 } | |
| 632 virtual void emit(const Cfg *Func) const; | |
| 633 virtual void dump(const Cfg *Func) const; | |
| 634 static bool classof(const Inst *Inst) { return isClassof(Inst, Fld); } | |
| 635 | |
| 636 private: | |
| 637 InstX8632Fld(Cfg *Func, Operand *Src); | |
| 638 InstX8632Fld(const InstX8632Fld &) LLVM_DELETED_FUNCTION; | |
| 639 InstX8632Fld &operator=(const InstX8632Fld &) LLVM_DELETED_FUNCTION; | |
| 640 virtual ~InstX8632Fld() {} | |
| 641 }; | |
| 642 | |
| 643 // Fstp - store x87 st(0) into memory and pop st(0). | |
| 644 class InstX8632Fstp : public InstX8632 { | |
| 645 public: | |
| 646 static InstX8632Fstp *create(Cfg *Func, Variable *Dest) { | |
| 647 return new (Func->allocate<InstX8632Fstp>()) InstX8632Fstp(Func, Dest); | |
| 648 } | |
| 649 virtual void emit(const Cfg *Func) const; | |
| 650 virtual void dump(const Cfg *Func) const; | |
| 651 static bool classof(const Inst *Inst) { return isClassof(Inst, Fstp); } | |
| 652 | |
| 653 private: | |
| 654 InstX8632Fstp(Cfg *Func, Variable *Dest); | |
| 655 InstX8632Fstp(const InstX8632Fstp &) LLVM_DELETED_FUNCTION; | |
| 656 InstX8632Fstp &operator=(const InstX8632Fstp &) LLVM_DELETED_FUNCTION; | |
| 657 virtual ~InstX8632Fstp() {} | |
| 658 }; | |
| 659 | |
| 660 class InstX8632Pop : public InstX8632 { | |
| 661 public: | |
| 662 static InstX8632Pop *create(Cfg *Func, Variable *Dest) { | |
| 663 return new (Func->allocate<InstX8632Pop>()) InstX8632Pop(Func, Dest); | |
| 664 } | |
| 665 virtual void emit(const Cfg *Func) const; | |
| 666 virtual void dump(const Cfg *Func) const; | |
| 667 static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } | |
| 668 | |
| 669 private: | |
| 670 InstX8632Pop(Cfg *Func, Variable *Dest); | |
| 671 InstX8632Pop(const InstX8632Pop &) LLVM_DELETED_FUNCTION; | |
| 672 InstX8632Pop &operator=(const InstX8632Pop &) LLVM_DELETED_FUNCTION; | |
| 673 virtual ~InstX8632Pop() {} | |
| 674 }; | |
| 675 | |
| 676 class InstX8632Push : public InstX8632 { | |
| 677 public: | |
| 678 static InstX8632Push *create(Cfg *Func, Operand *Source, | |
| 679 bool SuppressStackAdjustment) { | |
| 680 return new (Func->allocate<InstX8632Push>()) | |
| 681 InstX8632Push(Func, Source, SuppressStackAdjustment); | |
| 682 } | |
| 683 virtual void emit(const Cfg *Func) const; | |
| 684 virtual void dump(const Cfg *Func) const; | |
| 685 static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } | |
| 686 | |
| 687 private: | |
| 688 InstX8632Push(Cfg *Func, Operand *Source, bool SuppressStackAdjustment); | |
| 689 InstX8632Push(const InstX8632Push &) LLVM_DELETED_FUNCTION; | |
| 690 InstX8632Push &operator=(const InstX8632Push &) LLVM_DELETED_FUNCTION; | |
| 691 bool SuppressStackAdjustment; | |
| 692 virtual ~InstX8632Push() {} | |
| 693 }; | |
| 694 | |
| 695 // Ret instruction. Currently only supports the "ret" version that | |
| 696 // does not pop arguments. This instruction takes a Source operand | |
| 697 // (for non-void returning functions) for liveness analysis, though | |
| 698 // a FakeUse before the ret would do just as well. | |
| 699 class InstX8632Ret : public InstX8632 { | |
| 700 public: | |
| 701 static InstX8632Ret *create(Cfg *Func, Variable *Source = NULL) { | |
| 702 return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source); | |
| 703 } | |
| 704 virtual void emit(const Cfg *Func) const; | |
| 705 virtual void dump(const Cfg *Func) const; | |
| 706 static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } | |
| 707 | |
| 708 private: | |
| 709 InstX8632Ret(Cfg *Func, Variable *Source); | |
| 710 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; | |
| 711 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; | |
| 712 virtual ~InstX8632Ret() {} | |
| 713 }; | |
| 714 | |
| 715 } // end of namespace Ice | |
| 716 | |
| 717 #endif // SUBZERO_SRC_ICEINSTX8632_H | |
| OLD | NEW |