Jan Voung | b36ad9b | 2015-04-21 17:01:49 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceInstX8632.h - x86-32 machine instructions -*- C++ -*-===// |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 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 | |
John Porto | aff4ccf | 2015-06-10 16:35:06 -0700 | [diff] [blame] | 19 | #include "IceAssemblerX8632.h" |
Jan Voung | 3bfd99a | 2015-05-22 16:35:25 -0700 | [diff] [blame] | 20 | #include "IceConditionCodesX8632.h" |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 21 | #include "IceDefs.h" |
| 22 | #include "IceInst.h" |
| 23 | #include "IceInstX8632.def" |
| 24 | #include "IceOperand.h" |
| 25 | |
| 26 | namespace Ice { |
| 27 | |
| 28 | class TargetX8632; |
| 29 | |
| 30 | // OperandX8632 extends the Operand hierarchy. Its subclasses are |
| 31 | // OperandX8632Mem and VariableSplit. |
| 32 | class OperandX8632 : public Operand { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 33 | OperandX8632() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 34 | OperandX8632(const OperandX8632 &) = delete; |
| 35 | OperandX8632 &operator=(const OperandX8632 &) = delete; |
| 36 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 37 | public: |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 38 | enum OperandKindX8632 { k__Start = Operand::kTarget, kMem, kSplit }; |
Jim Stichnoth | 2e8bfbb | 2014-09-16 10:16:00 -0700 | [diff] [blame] | 39 | using Operand::dump; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 40 | void dump(const Cfg *, Ostream &Str) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 41 | if (ALLOW_DUMP) |
| 42 | Str << "<OperandX8632>"; |
Jim Stichnoth | 2e8bfbb | 2014-09-16 10:16:00 -0700 | [diff] [blame] | 43 | } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 44 | |
| 45 | protected: |
| 46 | OperandX8632(OperandKindX8632 Kind, Type Ty) |
| 47 | : Operand(static_cast<OperandKind>(Kind), Ty) {} |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 48 | ~OperandX8632() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | // OperandX8632Mem represents the m32 addressing mode, with optional |
| 52 | // base and index registers, a constant offset, and a fixed shift |
| 53 | // value for the index register. |
| 54 | class OperandX8632Mem : public OperandX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 55 | OperandX8632Mem() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 56 | OperandX8632Mem(const OperandX8632Mem &) = delete; |
| 57 | OperandX8632Mem &operator=(const OperandX8632Mem &) = delete; |
| 58 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 59 | public: |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 60 | enum SegmentRegisters { |
| 61 | DefaultSegment = -1, |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 62 | #define X(val, name, prefix) val, |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 63 | SEG_REGX8632_TABLE |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 64 | #undef X |
| 65 | SegReg_NUM |
| 66 | }; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 67 | static OperandX8632Mem *create(Cfg *Func, Type Ty, Variable *Base, |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 68 | Constant *Offset, Variable *Index = nullptr, |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 69 | uint16_t Shift = 0, |
| 70 | SegmentRegisters SegmentReg = DefaultSegment) { |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 71 | return new (Func->allocate<OperandX8632Mem>()) |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 72 | OperandX8632Mem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 73 | } |
| 74 | Variable *getBase() const { return Base; } |
| 75 | Constant *getOffset() const { return Offset; } |
| 76 | Variable *getIndex() const { return Index; } |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 77 | uint16_t getShift() const { return Shift; } |
| 78 | SegmentRegisters getSegmentRegister() const { return SegmentReg; } |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 79 | void emitSegmentOverride(X8632::AssemblerX8632 *Asm) const; |
| 80 | X8632::Address toAsmAddress(Assembler *Asm) const; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 81 | void emit(const Cfg *Func) const override; |
Jim Stichnoth | 2e8bfbb | 2014-09-16 10:16:00 -0700 | [diff] [blame] | 82 | using OperandX8632::dump; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 83 | void dump(const Cfg *Func, Ostream &Str) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 84 | |
| 85 | static bool classof(const Operand *Operand) { |
| 86 | return Operand->getKind() == static_cast<OperandKind>(kMem); |
| 87 | } |
| 88 | |
| 89 | private: |
| 90 | OperandX8632Mem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 91 | Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 92 | ~OperandX8632Mem() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 93 | Variable *Base; |
| 94 | Constant *Offset; |
| 95 | Variable *Index; |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 96 | uint16_t Shift; |
| 97 | SegmentRegisters SegmentReg : 16; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | // VariableSplit is a way to treat an f64 memory location as a pair |
| 101 | // of i32 locations (Low and High). This is needed for some cases |
| 102 | // of the Bitcast instruction. Since it's not possible for integer |
| 103 | // registers to access the XMM registers and vice versa, the |
| 104 | // lowering forces the f64 to be spilled to the stack and then |
| 105 | // accesses through the VariableSplit. |
| 106 | class VariableSplit : public OperandX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 107 | VariableSplit() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 108 | VariableSplit(const VariableSplit &) = delete; |
| 109 | VariableSplit &operator=(const VariableSplit &) = delete; |
| 110 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 111 | public: |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 112 | enum Portion { Low, High }; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 113 | static VariableSplit *create(Cfg *Func, Variable *Var, Portion Part) { |
| 114 | return new (Func->allocate<VariableSplit>()) VariableSplit(Func, Var, Part); |
| 115 | } |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 116 | int32_t getOffset() const { return Part == High ? 4 : 0; } |
| 117 | |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 118 | X8632::Address toAsmAddress(const Cfg *Func) const; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 119 | void emit(const Cfg *Func) const override; |
Jim Stichnoth | 2e8bfbb | 2014-09-16 10:16:00 -0700 | [diff] [blame] | 120 | using OperandX8632::dump; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 121 | void dump(const Cfg *Func, Ostream &Str) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 122 | |
| 123 | static bool classof(const Operand *Operand) { |
| 124 | return Operand->getKind() == static_cast<OperandKind>(kSplit); |
| 125 | } |
| 126 | |
| 127 | private: |
| 128 | VariableSplit(Cfg *Func, Variable *Var, Portion Part) |
| 129 | : OperandX8632(kSplit, IceType_i32), Func(Func), Var(Var), Part(Part) { |
| 130 | assert(Var->getType() == IceType_f64); |
| 131 | Vars = Func->allocateArrayOf<Variable *>(1); |
| 132 | Vars[0] = Var; |
| 133 | NumVars = 1; |
| 134 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 135 | ~VariableSplit() override { Func->deallocateArrayOf<Variable *>(Vars); } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 136 | Cfg *Func; // Held only for the destructor. |
| 137 | Variable *Var; |
| 138 | Portion Part; |
| 139 | }; |
| 140 | |
Jim Stichnoth | 800dab2 | 2014-09-20 12:25:02 -0700 | [diff] [blame] | 141 | // SpillVariable decorates a Variable by linking it to another |
| 142 | // Variable. When stack frame offsets are computed, the SpillVariable |
| 143 | // is given a distinct stack slot only if its linked Variable has a |
| 144 | // register. If the linked Variable has a stack slot, then the |
| 145 | // Variable and SpillVariable share that slot. |
| 146 | class SpillVariable : public Variable { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 147 | SpillVariable() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 148 | SpillVariable(const SpillVariable &) = delete; |
| 149 | SpillVariable &operator=(const SpillVariable &) = delete; |
| 150 | |
Jim Stichnoth | 800dab2 | 2014-09-20 12:25:02 -0700 | [diff] [blame] | 151 | public: |
Jim Stichnoth | 9a04c07 | 2014-12-11 15:51:42 -0800 | [diff] [blame] | 152 | static SpillVariable *create(Cfg *Func, Type Ty, SizeT Index) { |
| 153 | return new (Func->allocate<SpillVariable>()) SpillVariable(Ty, Index); |
Jim Stichnoth | 800dab2 | 2014-09-20 12:25:02 -0700 | [diff] [blame] | 154 | } |
| 155 | const static OperandKind SpillVariableKind = |
| 156 | static_cast<OperandKind>(kVariable_Target); |
| 157 | static bool classof(const Operand *Operand) { |
| 158 | return Operand->getKind() == SpillVariableKind; |
| 159 | } |
| 160 | void setLinkedTo(Variable *Var) { LinkedTo = Var; } |
| 161 | Variable *getLinkedTo() const { return LinkedTo; } |
| 162 | // Inherit dump() and emit() from Variable. |
| 163 | private: |
Jim Stichnoth | 9a04c07 | 2014-12-11 15:51:42 -0800 | [diff] [blame] | 164 | SpillVariable(Type Ty, SizeT Index) |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 165 | : Variable(SpillVariableKind, Ty, Index), LinkedTo(nullptr) {} |
Jim Stichnoth | 800dab2 | 2014-09-20 12:25:02 -0700 | [diff] [blame] | 166 | Variable *LinkedTo; |
| 167 | }; |
| 168 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 169 | class InstX8632 : public InstTarget { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 170 | InstX8632() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 171 | InstX8632(const InstX8632 &) = delete; |
| 172 | InstX8632 &operator=(const InstX8632 &) = delete; |
| 173 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 174 | public: |
| 175 | enum InstKindX8632 { |
| 176 | k__Start = Inst::Target, |
| 177 | Adc, |
| 178 | Add, |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame^] | 179 | AddRMW, |
Matt Wala | 8d1072e | 2014-07-11 15:43:51 -0700 | [diff] [blame] | 180 | Addps, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 181 | Addss, |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 182 | Adjuststack, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 183 | And, |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 184 | Blendvps, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 185 | Br, |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 186 | Bsf, |
| 187 | Bsr, |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 188 | Bswap, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 189 | Call, |
Matt Wala | afeaee4 | 2014-08-07 13:47:30 -0700 | [diff] [blame] | 190 | Cbwdq, |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 191 | Cmov, |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 192 | Cmpps, |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 193 | Cmpxchg, |
| 194 | Cmpxchg8b, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 195 | Cvt, |
| 196 | Div, |
Matt Wala | 8d1072e | 2014-07-11 15:43:51 -0700 | [diff] [blame] | 197 | Divps, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 198 | Divss, |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame^] | 199 | FakeRMW, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 200 | Fld, |
| 201 | Fstp, |
| 202 | Icmp, |
| 203 | Idiv, |
| 204 | Imul, |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 205 | Insertps, |
Jim Stichnoth | 9f42d8c | 2015-02-20 09:20:14 -0800 | [diff] [blame] | 206 | Jmp, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 207 | Label, |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 208 | Lea, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 209 | Load, |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 210 | Mfence, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 211 | Mov, |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 212 | Movd, |
Matt Wala | 928f129 | 2014-07-07 16:50:46 -0700 | [diff] [blame] | 213 | Movp, |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 214 | Movq, |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 215 | MovssRegs, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 216 | Movsx, |
| 217 | Movzx, |
| 218 | Mul, |
Matt Wala | 8d1072e | 2014-07-11 15:43:51 -0700 | [diff] [blame] | 219 | Mulps, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 220 | Mulss, |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 221 | Neg, |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 222 | Nop, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 223 | Or, |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 224 | Padd, |
Matt Wala | 83b8036 | 2014-07-16 10:21:30 -0700 | [diff] [blame] | 225 | Pand, |
Matt Wala | 9cb61e2 | 2014-07-24 09:44:42 -0700 | [diff] [blame] | 226 | Pandn, |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 227 | Pblendvb, |
Matt Wala | 83b8036 | 2014-07-16 10:21:30 -0700 | [diff] [blame] | 228 | Pcmpeq, |
| 229 | Pcmpgt, |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 230 | Pextr, |
| 231 | Pinsr, |
| 232 | Pmull, |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 233 | Pmuludq, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 234 | Pop, |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 235 | Por, |
| 236 | Pshufd, |
Matt Wala | 83b8036 | 2014-07-16 10:21:30 -0700 | [diff] [blame] | 237 | Psll, |
| 238 | Psra, |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 239 | Psrl, |
Matt Wala | 83b8036 | 2014-07-16 10:21:30 -0700 | [diff] [blame] | 240 | Psub, |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 241 | Push, |
Matt Wala | 928f129 | 2014-07-07 16:50:46 -0700 | [diff] [blame] | 242 | Pxor, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 243 | Ret, |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 244 | Rol, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 245 | Sar, |
| 246 | Sbb, |
Jim Stichnoth | f48b320 | 2015-05-04 10:22:17 -0700 | [diff] [blame] | 247 | Setcc, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 248 | Shl, |
| 249 | Shld, |
| 250 | Shr, |
| 251 | Shrd, |
Matt Wala | 7fa22d8 | 2014-07-17 12:41:31 -0700 | [diff] [blame] | 252 | Shufps, |
Jan Voung | f37fbbe | 2014-07-09 16:13:13 -0700 | [diff] [blame] | 253 | Sqrtss, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 254 | Store, |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 255 | StoreP, |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 256 | StoreQ, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 257 | Sub, |
Matt Wala | 8d1072e | 2014-07-11 15:43:51 -0700 | [diff] [blame] | 258 | Subps, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 259 | Subss, |
| 260 | Test, |
| 261 | Ucomiss, |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 262 | UD2, |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 263 | Xadd, |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 264 | Xchg, |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 265 | Xor |
| 266 | }; |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 267 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 268 | static const char *getWidthString(Type Ty); |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 269 | static const char *getFldString(Type Ty); |
Jim Stichnoth | 537b5ba | 2015-05-19 09:48:44 -0700 | [diff] [blame] | 270 | static CondX86::BrCond getOppositeCondition(CondX86::BrCond Cond); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 271 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 272 | |
Jan Voung | 3bfd99a | 2015-05-22 16:35:25 -0700 | [diff] [blame] | 273 | // Shared emit routines for common forms of instructions. |
| 274 | // See the definition of emitTwoAddress() for a description of |
| 275 | // ShiftHack. |
| 276 | static void emitTwoAddress(const char *Opcode, const Inst *Inst, |
| 277 | const Cfg *Func, bool ShiftHack = false); |
| 278 | |
| 279 | static void |
| 280 | emitIASGPRShift(const Cfg *Func, Type Ty, const Variable *Var, |
| 281 | const Operand *Src, |
| 282 | const X8632::AssemblerX8632::GPREmitterShiftOp &Emitter); |
| 283 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 284 | protected: |
| 285 | InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) |
| 286 | : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 287 | ~InstX8632() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 288 | static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { |
| 289 | return Inst->getKind() == static_cast<InstKind>(MyKind); |
| 290 | } |
Jim Stichnoth | f79d2cb | 2015-03-23 15:10:54 -0700 | [diff] [blame] | 291 | // Most instructions that operate on vector arguments require vector |
| 292 | // memory operands to be fully aligned (16-byte alignment for PNaCl |
| 293 | // vector types). The stack frame layout and call ABI ensure proper |
| 294 | // alignment for stack operands, but memory operands (originating |
| 295 | // from load/store bitcode instructions) only have element-size |
| 296 | // alignment guarantees. This function validates that none of the |
| 297 | // operands is a memory operand of vector type, calling |
| 298 | // report_fatal_error() if one is found. This function should be |
| 299 | // called during emission, and maybe also in the ctor (as long as |
| 300 | // that fits the lowering style). |
| 301 | void validateVectorAddrMode() const { |
| 302 | if (getDest()) |
| 303 | validateVectorAddrModeOpnd(getDest()); |
| 304 | for (SizeT i = 0; i < getSrcSize(); ++i) { |
| 305 | validateVectorAddrModeOpnd(getSrc(i)); |
| 306 | } |
| 307 | } |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 308 | |
Jim Stichnoth | f79d2cb | 2015-03-23 15:10:54 -0700 | [diff] [blame] | 309 | private: |
| 310 | static void validateVectorAddrModeOpnd(const Operand *Opnd) { |
| 311 | if (llvm::isa<OperandX8632Mem>(Opnd) && isVectorType(Opnd->getType())) { |
| 312 | llvm::report_fatal_error("Possible misaligned vector memory operation"); |
| 313 | } |
| 314 | } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 315 | }; |
| 316 | |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame^] | 317 | // InstX8632FakeRMW represents a non-atomic read-modify-write operation on a |
| 318 | // memory location. An InstX8632FakeRMW is a "fake" instruction in that it |
| 319 | // still needs to be lowered to some actual RMW instruction. |
| 320 | // |
| 321 | // If A is some memory address, D is some data value to apply, and OP is an |
| 322 | // arithmetic operator, the instruction operates as: (*A) = (*A) OP D |
| 323 | class InstX8632FakeRMW : public InstX8632 { |
| 324 | InstX8632FakeRMW() = delete; |
| 325 | InstX8632FakeRMW(const InstX8632FakeRMW &) = delete; |
| 326 | InstX8632FakeRMW &operator=(const InstX8632FakeRMW &) = delete; |
| 327 | |
| 328 | public: |
| 329 | static InstX8632FakeRMW *create(Cfg *Func, Operand *Data, Operand *Addr, |
| 330 | Variable *Beacon, InstArithmetic::OpKind Op, |
| 331 | uint32_t Align = 1) { |
| 332 | // TODO(stichnot): Stop ignoring alignment specification. |
| 333 | (void)Align; |
| 334 | return new (Func->allocate<InstX8632FakeRMW>()) |
| 335 | InstX8632FakeRMW(Func, Data, Addr, Op, Beacon); |
| 336 | } |
| 337 | Operand *getAddr() const { return getSrc(1); } |
| 338 | Operand *getData() const { return getSrc(0); } |
| 339 | InstArithmetic::OpKind getOp() const { return Op; } |
| 340 | Variable *getBeacon() const { return llvm::cast<Variable>(getSrc(2)); } |
| 341 | void dump(const Cfg *Func) const override; |
| 342 | static bool classof(const Inst *Inst) { return isClassof(Inst, FakeRMW); } |
| 343 | |
| 344 | private: |
| 345 | InstArithmetic::OpKind Op; |
| 346 | InstX8632FakeRMW(Cfg *Func, Operand *Data, Operand *Addr, |
| 347 | InstArithmetic::OpKind Op, Variable *Beacon); |
| 348 | ~InstX8632FakeRMW() override {} |
| 349 | }; |
| 350 | |
Jan Voung | 7e1e485 | 2014-10-24 10:29:30 -0700 | [diff] [blame] | 351 | // InstX8632Label represents an intra-block label that is the target |
| 352 | // of an intra-block branch. The offset between the label and the |
| 353 | // branch must be fit into one byte (considered "near"). These are |
| 354 | // used for lowering i1 calculations, Select instructions, and 64-bit |
| 355 | // compares on a 32-bit architecture, without basic block splitting. |
| 356 | // Basic block splitting is not so desirable for several reasons, one |
| 357 | // of which is the impact on decisions based on whether a variable's |
| 358 | // live range spans multiple basic blocks. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 359 | // |
| 360 | // Intra-block control flow must be used with caution. Consider the |
| 361 | // sequence for "c = (a >= b ? x : y)". |
| 362 | // cmp a, b |
| 363 | // br lt, L1 |
| 364 | // mov c, x |
| 365 | // jmp L2 |
| 366 | // L1: |
| 367 | // mov c, y |
| 368 | // L2: |
| 369 | // |
| 370 | // Labels L1 and L2 are intra-block labels. Without knowledge of the |
| 371 | // intra-block control flow, liveness analysis will determine the "mov |
| 372 | // c, x" instruction to be dead. One way to prevent this is to insert |
| 373 | // a "FakeUse(c)" instruction anywhere between the two "mov c, ..." |
| 374 | // instructions, e.g.: |
| 375 | // |
| 376 | // cmp a, b |
| 377 | // br lt, L1 |
| 378 | // mov c, x |
| 379 | // jmp L2 |
| 380 | // FakeUse(c) |
| 381 | // L1: |
| 382 | // mov c, y |
| 383 | // L2: |
| 384 | // |
| 385 | // The down-side is that "mov c, x" can never be dead-code eliminated |
| 386 | // even if there are no uses of c. As unlikely as this situation is, |
| 387 | // it may be prevented by running dead code elimination before |
| 388 | // lowering. |
| 389 | class InstX8632Label : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 390 | InstX8632Label() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 391 | InstX8632Label(const InstX8632Label &) = delete; |
| 392 | InstX8632Label &operator=(const InstX8632Label &) = delete; |
| 393 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 394 | public: |
| 395 | static InstX8632Label *create(Cfg *Func, TargetX8632 *Target) { |
| 396 | return new (Func->allocate<InstX8632Label>()) InstX8632Label(Func, Target); |
| 397 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 398 | uint32_t getEmitInstCount() const override { return 0; } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 399 | IceString getName(const Cfg *Func) const; |
Jan Voung | 7e1e485 | 2014-10-24 10:29:30 -0700 | [diff] [blame] | 400 | SizeT getNumber() const { return Number; } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 401 | void emit(const Cfg *Func) const override; |
Jan Voung | 7e1e485 | 2014-10-24 10:29:30 -0700 | [diff] [blame] | 402 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 403 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 404 | |
| 405 | private: |
| 406 | InstX8632Label(Cfg *Func, TargetX8632 *Target); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 407 | ~InstX8632Label() override {} |
Jan Voung | 7e1e485 | 2014-10-24 10:29:30 -0700 | [diff] [blame] | 408 | SizeT Number; // used for unique label generation. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 409 | }; |
| 410 | |
| 411 | // Conditional and unconditional branch instruction. |
| 412 | class InstX8632Br : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 413 | InstX8632Br() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 414 | InstX8632Br(const InstX8632Br &) = delete; |
| 415 | InstX8632Br &operator=(const InstX8632Br &) = delete; |
| 416 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 417 | public: |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 418 | // Create a conditional branch to a node. |
| 419 | static InstX8632Br *create(Cfg *Func, CfgNode *TargetTrue, |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 420 | CfgNode *TargetFalse, CondX86::BrCond Condition) { |
Jim Stichnoth | 98712a3 | 2014-10-24 10:59:02 -0700 | [diff] [blame] | 421 | assert(Condition != CondX86::Br_None); |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 422 | const InstX8632Label *NoLabel = nullptr; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 423 | return new (Func->allocate<InstX8632Br>()) |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 424 | InstX8632Br(Func, TargetTrue, TargetFalse, NoLabel, Condition); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 425 | } |
| 426 | // Create an unconditional branch to a node. |
| 427 | static InstX8632Br *create(Cfg *Func, CfgNode *Target) { |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 428 | const CfgNode *NoCondTarget = nullptr; |
| 429 | const InstX8632Label *NoLabel = nullptr; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 430 | return new (Func->allocate<InstX8632Br>()) |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 431 | InstX8632Br(Func, NoCondTarget, Target, NoLabel, CondX86::Br_None); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 432 | } |
| 433 | // Create a non-terminator conditional branch to a node, with a |
| 434 | // fallthrough to the next instruction in the current node. This is |
| 435 | // used for switch lowering. |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 436 | static InstX8632Br *create(Cfg *Func, CfgNode *Target, |
| 437 | CondX86::BrCond Condition) { |
Jim Stichnoth | 98712a3 | 2014-10-24 10:59:02 -0700 | [diff] [blame] | 438 | assert(Condition != CondX86::Br_None); |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 439 | const CfgNode *NoUncondTarget = nullptr; |
| 440 | const InstX8632Label *NoLabel = nullptr; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 441 | return new (Func->allocate<InstX8632Br>()) |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 442 | InstX8632Br(Func, Target, NoUncondTarget, NoLabel, Condition); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 443 | } |
| 444 | // Create a conditional intra-block branch (or unconditional, if |
Jim Stichnoth | 1873560 | 2014-09-16 19:59:35 -0700 | [diff] [blame] | 445 | // Condition==Br_None) to a label in the current block. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 446 | static InstX8632Br *create(Cfg *Func, InstX8632Label *Label, |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 447 | CondX86::BrCond Condition) { |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 448 | const CfgNode *NoCondTarget = nullptr; |
| 449 | const CfgNode *NoUncondTarget = nullptr; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 450 | return new (Func->allocate<InstX8632Br>()) |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 451 | InstX8632Br(Func, NoCondTarget, NoUncondTarget, Label, Condition); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 452 | } |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 453 | const CfgNode *getTargetTrue() const { return TargetTrue; } |
| 454 | const CfgNode *getTargetFalse() const { return TargetFalse; } |
| 455 | bool optimizeBranch(const CfgNode *NextNode); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 456 | uint32_t getEmitInstCount() const override { |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 457 | uint32_t Sum = 0; |
Jim Stichnoth | 1873560 | 2014-09-16 19:59:35 -0700 | [diff] [blame] | 458 | if (Label) |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 459 | ++Sum; |
| 460 | if (getTargetTrue()) |
| 461 | ++Sum; |
Jim Stichnoth | 1873560 | 2014-09-16 19:59:35 -0700 | [diff] [blame] | 462 | if (getTargetFalse()) |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 463 | ++Sum; |
| 464 | return Sum; |
Jim Stichnoth | 1873560 | 2014-09-16 19:59:35 -0700 | [diff] [blame] | 465 | } |
Jim Stichnoth | 336f6c4 | 2014-10-30 15:01:31 -0700 | [diff] [blame] | 466 | bool isUnconditionalBranch() const override { |
| 467 | return !Label && Condition == CondX86::Br_None; |
| 468 | } |
| 469 | bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 470 | void emit(const Cfg *Func) const override; |
Jan Voung | 7e1e485 | 2014-10-24 10:29:30 -0700 | [diff] [blame] | 471 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 472 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 473 | static bool classof(const Inst *Inst) { return isClassof(Inst, Br); } |
| 474 | |
| 475 | private: |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 476 | InstX8632Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 477 | const InstX8632Label *Label, CondX86::BrCond Condition); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 478 | ~InstX8632Br() override {} |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 479 | CondX86::BrCond Condition; |
Jim Stichnoth | ff9c706 | 2014-09-18 04:50:49 -0700 | [diff] [blame] | 480 | const CfgNode *TargetTrue; |
| 481 | const CfgNode *TargetFalse; |
| 482 | const InstX8632Label *Label; // Intra-block branch target |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 483 | }; |
| 484 | |
Jim Stichnoth | 9f42d8c | 2015-02-20 09:20:14 -0800 | [diff] [blame] | 485 | // Jump to a target outside this function, such as tailcall, nacljump, |
| 486 | // naclret, unreachable. This is different from a Branch instruction |
| 487 | // in that there is no intra-function control flow to represent. |
| 488 | class InstX8632Jmp : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 489 | InstX8632Jmp() = delete; |
Jim Stichnoth | 9f42d8c | 2015-02-20 09:20:14 -0800 | [diff] [blame] | 490 | InstX8632Jmp(const InstX8632Jmp &) = delete; |
| 491 | InstX8632Jmp &operator=(const InstX8632Jmp &) = delete; |
| 492 | |
| 493 | public: |
| 494 | static InstX8632Jmp *create(Cfg *Func, Operand *Target) { |
| 495 | return new (Func->allocate<InstX8632Jmp>()) InstX8632Jmp(Func, Target); |
| 496 | } |
| 497 | Operand *getJmpTarget() const { return getSrc(0); } |
| 498 | void emit(const Cfg *Func) const override; |
| 499 | void emitIAS(const Cfg *Func) const override; |
| 500 | void dump(const Cfg *Func) const override; |
| 501 | static bool classof(const Inst *Inst) { return isClassof(Inst, Jmp); } |
| 502 | |
| 503 | private: |
| 504 | InstX8632Jmp(Cfg *Func, Operand *Target); |
| 505 | }; |
| 506 | |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 507 | // AdjustStack instruction - subtracts esp by the given amount and |
| 508 | // updates the stack offset during code emission. |
| 509 | class InstX8632AdjustStack : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 510 | InstX8632AdjustStack() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 511 | InstX8632AdjustStack(const InstX8632AdjustStack &) = delete; |
| 512 | InstX8632AdjustStack &operator=(const InstX8632AdjustStack &) = delete; |
| 513 | |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 514 | public: |
Jim Stichnoth | 144cdce | 2014-09-22 16:02:59 -0700 | [diff] [blame] | 515 | static InstX8632AdjustStack *create(Cfg *Func, SizeT Amount, Variable *Esp) { |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 516 | return new (Func->allocate<InstX8632AdjustStack>()) |
Jim Stichnoth | 144cdce | 2014-09-22 16:02:59 -0700 | [diff] [blame] | 517 | InstX8632AdjustStack(Func, Amount, Esp); |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 518 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 519 | void emit(const Cfg *Func) const override; |
| 520 | void emitIAS(const Cfg *Func) const override; |
| 521 | void dump(const Cfg *Func) const override; |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 522 | static bool classof(const Inst *Inst) { return isClassof(Inst, Adjuststack); } |
| 523 | |
| 524 | private: |
Jim Stichnoth | 144cdce | 2014-09-22 16:02:59 -0700 | [diff] [blame] | 525 | InstX8632AdjustStack(Cfg *Func, SizeT Amount, Variable *Esp); |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 526 | SizeT Amount; |
| 527 | }; |
| 528 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 529 | // Call instruction. Arguments should have already been pushed. |
| 530 | class InstX8632Call : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 531 | InstX8632Call() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 532 | InstX8632Call(const InstX8632Call &) = delete; |
| 533 | InstX8632Call &operator=(const InstX8632Call &) = delete; |
| 534 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 535 | public: |
| 536 | static InstX8632Call *create(Cfg *Func, Variable *Dest, Operand *CallTarget) { |
| 537 | return new (Func->allocate<InstX8632Call>()) |
| 538 | InstX8632Call(Func, Dest, CallTarget); |
| 539 | } |
| 540 | Operand *getCallTarget() const { return getSrc(0); } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 541 | void emit(const Cfg *Func) const override; |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 542 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 543 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 544 | static bool classof(const Inst *Inst) { return isClassof(Inst, Call); } |
| 545 | |
| 546 | private: |
| 547 | InstX8632Call(Cfg *Func, Variable *Dest, Operand *CallTarget); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 548 | ~InstX8632Call() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 549 | }; |
| 550 | |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 551 | // Emit a one-operand (GPR) instruction. |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 552 | void emitIASOpTyGPR(const Cfg *Func, Type Ty, const Operand *Var, |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 553 | const X8632::AssemblerX8632::GPREmitterOneOp &Emitter); |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame^] | 554 | void emitIASAsAddrOpTyGPR( |
| 555 | const Cfg *Func, Type Ty, const Operand *Op0, const Operand *Op1, |
| 556 | const X8632::AssemblerX8632::GPREmitterAddrOp &Emitter); |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 557 | |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 558 | // Instructions of the form x := op(x). |
| 559 | template <InstX8632::InstKindX8632 K> |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 560 | class InstX8632InplaceopGPR : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 561 | InstX8632InplaceopGPR() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 562 | InstX8632InplaceopGPR(const InstX8632InplaceopGPR &) = delete; |
| 563 | InstX8632InplaceopGPR &operator=(const InstX8632InplaceopGPR &) = delete; |
| 564 | |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 565 | public: |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 566 | static InstX8632InplaceopGPR *create(Cfg *Func, Operand *SrcDest) { |
| 567 | return new (Func->allocate<InstX8632InplaceopGPR>()) |
| 568 | InstX8632InplaceopGPR(Func, SrcDest); |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 569 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 570 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 571 | if (!ALLOW_DUMP) |
| 572 | return; |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 573 | Ostream &Str = Func->getContext()->getStrEmit(); |
| 574 | assert(getSrcSize() == 1); |
| 575 | Str << "\t" << Opcode << "\t"; |
| 576 | getSrc(0)->emit(Func); |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 577 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 578 | void emitIAS(const Cfg *Func) const override { |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 579 | assert(getSrcSize() == 1); |
| 580 | const Variable *Var = getDest(); |
| 581 | Type Ty = Var->getType(); |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 582 | emitIASOpTyGPR(Func, Ty, Var, Emitter); |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 583 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 584 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 585 | if (!ALLOW_DUMP) |
| 586 | return; |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 587 | Ostream &Str = Func->getContext()->getStrDump(); |
| 588 | dumpDest(Func); |
| 589 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 590 | dumpSources(Func); |
| 591 | } |
| 592 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 593 | |
| 594 | private: |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 595 | InstX8632InplaceopGPR(Cfg *Func, Operand *SrcDest) |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 596 | : InstX8632(Func, K, 1, llvm::dyn_cast<Variable>(SrcDest)) { |
| 597 | addSource(SrcDest); |
| 598 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 599 | ~InstX8632InplaceopGPR() override {} |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 600 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 601 | static const X8632::AssemblerX8632::GPREmitterOneOp Emitter; |
Jan Voung | 7fa813b | 2014-07-18 13:01:08 -0700 | [diff] [blame] | 602 | }; |
| 603 | |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 604 | // Emit a two-operand (GPR) instruction, where the dest operand is a |
| 605 | // Variable that's guaranteed to be a register. |
Jan Voung | 39d4aca | 2014-10-15 15:16:54 -0700 | [diff] [blame] | 606 | template <bool VarCanBeByte = true, bool SrcCanBeByte = true> |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 607 | void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Dst, |
| 608 | const Operand *Src, |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 609 | const X8632::AssemblerX8632::GPREmitterRegOp &Emitter); |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 610 | |
Jan Voung | 39d4aca | 2014-10-15 15:16:54 -0700 | [diff] [blame] | 611 | // Instructions of the form x := op(y). |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 612 | template <InstX8632::InstKindX8632 K> |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 613 | class InstX8632UnaryopGPR : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 614 | InstX8632UnaryopGPR() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 615 | InstX8632UnaryopGPR(const InstX8632UnaryopGPR &) = delete; |
| 616 | InstX8632UnaryopGPR &operator=(const InstX8632UnaryopGPR &) = delete; |
| 617 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 618 | public: |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 619 | static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) { |
| 620 | return new (Func->allocate<InstX8632UnaryopGPR>()) |
| 621 | InstX8632UnaryopGPR(Func, Dest, Src); |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 622 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 623 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 624 | if (!ALLOW_DUMP) |
| 625 | return; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 626 | Ostream &Str = Func->getContext()->getStrEmit(); |
| 627 | assert(getSrcSize() == 1); |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 628 | Type SrcTy = getSrc(0)->getType(); |
| 629 | Type DestTy = getDest()->getType(); |
| 630 | Str << "\t" << Opcode << getWidthString(SrcTy); |
| 631 | // Movsx and movzx need both the source and dest type width letter |
| 632 | // to define the operation. The other unary operations have the |
| 633 | // same source and dest type and as a result need only one letter. |
| 634 | if (SrcTy != DestTy) |
| 635 | Str << getWidthString(DestTy); |
| 636 | Str << "\t"; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 637 | getSrc(0)->emit(Func); |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 638 | Str << ", "; |
| 639 | getDest()->emit(Func); |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 640 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 641 | void emitIAS(const Cfg *Func) const override { |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 642 | assert(getSrcSize() == 1); |
| 643 | const Variable *Var = getDest(); |
| 644 | Type Ty = Var->getType(); |
| 645 | const Operand *Src = getSrc(0); |
| 646 | emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); |
| 647 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 648 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 649 | if (!ALLOW_DUMP) |
| 650 | return; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 651 | Ostream &Str = Func->getContext()->getStrDump(); |
| 652 | dumpDest(Func); |
Jan Voung | 39d4aca | 2014-10-15 15:16:54 -0700 | [diff] [blame] | 653 | Str << " = " << Opcode << "." << getSrc(0)->getType() << " "; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 654 | dumpSources(Func); |
| 655 | } |
| 656 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 657 | |
| 658 | private: |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 659 | InstX8632UnaryopGPR(Cfg *Func, Variable *Dest, Operand *Src) |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 660 | : InstX8632(Func, K, 1, Dest) { |
| 661 | addSource(Src); |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 662 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 663 | ~InstX8632UnaryopGPR() override {} |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 664 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 665 | static const X8632::AssemblerX8632::GPREmitterRegOp Emitter; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 666 | }; |
| 667 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 668 | void emitIASRegOpTyXMM(const Cfg *Func, Type Ty, const Variable *Var, |
| 669 | const Operand *Src, |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 670 | const X8632::AssemblerX8632::XmmEmitterRegOp &Emitter); |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 671 | |
| 672 | template <InstX8632::InstKindX8632 K> |
| 673 | class InstX8632UnaryopXmm : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 674 | InstX8632UnaryopXmm() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 675 | InstX8632UnaryopXmm(const InstX8632UnaryopXmm &) = delete; |
| 676 | InstX8632UnaryopXmm &operator=(const InstX8632UnaryopXmm &) = delete; |
| 677 | |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 678 | public: |
| 679 | static InstX8632UnaryopXmm *create(Cfg *Func, Variable *Dest, Operand *Src) { |
| 680 | return new (Func->allocate<InstX8632UnaryopXmm>()) |
| 681 | InstX8632UnaryopXmm(Func, Dest, Src); |
| 682 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 683 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 684 | if (!ALLOW_DUMP) |
| 685 | return; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 686 | Ostream &Str = Func->getContext()->getStrEmit(); |
| 687 | assert(getSrcSize() == 1); |
| 688 | Str << "\t" << Opcode << "\t"; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 689 | getSrc(0)->emit(Func); |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 690 | Str << ", "; |
| 691 | getDest()->emit(Func); |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 692 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 693 | void emitIAS(const Cfg *Func) const override { |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 694 | Type Ty = getDest()->getType(); |
| 695 | assert(getSrcSize() == 1); |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 696 | emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter); |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 697 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 698 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 699 | if (!ALLOW_DUMP) |
| 700 | return; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 701 | Ostream &Str = Func->getContext()->getStrDump(); |
| 702 | dumpDest(Func); |
| 703 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 704 | dumpSources(Func); |
| 705 | } |
| 706 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 707 | |
| 708 | private: |
| 709 | InstX8632UnaryopXmm(Cfg *Func, Variable *Dest, Operand *Src) |
| 710 | : InstX8632(Func, K, 1, Dest) { |
| 711 | addSource(Src); |
| 712 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 713 | ~InstX8632UnaryopXmm() override {} |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 714 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 715 | static const X8632::AssemblerX8632::XmmEmitterRegOp Emitter; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 716 | }; |
| 717 | |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 718 | template <InstX8632::InstKindX8632 K> |
| 719 | class InstX8632BinopGPRShift : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 720 | InstX8632BinopGPRShift() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 721 | InstX8632BinopGPRShift(const InstX8632BinopGPRShift &) = delete; |
| 722 | InstX8632BinopGPRShift &operator=(const InstX8632BinopGPRShift &) = delete; |
| 723 | |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 724 | public: |
| 725 | // Create a binary-op GPR shift instruction. |
| 726 | static InstX8632BinopGPRShift *create(Cfg *Func, Variable *Dest, |
| 727 | Operand *Source) { |
| 728 | return new (Func->allocate<InstX8632BinopGPRShift>()) |
| 729 | InstX8632BinopGPRShift(Func, Dest, Source); |
| 730 | } |
| 731 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 732 | if (!ALLOW_DUMP) |
| 733 | return; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 734 | const bool ShiftHack = true; |
| 735 | emitTwoAddress(Opcode, this, Func, ShiftHack); |
| 736 | } |
| 737 | void emitIAS(const Cfg *Func) const override { |
| 738 | Type Ty = getDest()->getType(); |
| 739 | assert(getSrcSize() == 2); |
| 740 | emitIASGPRShift(Func, Ty, getDest(), getSrc(1), Emitter); |
| 741 | } |
| 742 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 743 | if (!ALLOW_DUMP) |
| 744 | return; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 745 | Ostream &Str = Func->getContext()->getStrDump(); |
| 746 | dumpDest(Func); |
| 747 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 748 | dumpSources(Func); |
| 749 | } |
| 750 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 751 | |
| 752 | private: |
| 753 | InstX8632BinopGPRShift(Cfg *Func, Variable *Dest, Operand *Source) |
| 754 | : InstX8632(Func, K, 2, Dest) { |
| 755 | addSource(Dest); |
| 756 | addSource(Source); |
| 757 | } |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 758 | ~InstX8632BinopGPRShift() override {} |
| 759 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 760 | static const X8632::AssemblerX8632::GPREmitterShiftOp Emitter; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 761 | }; |
| 762 | |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 763 | template <InstX8632::InstKindX8632 K> |
| 764 | class InstX8632BinopGPR : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 765 | InstX8632BinopGPR() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 766 | InstX8632BinopGPR(const InstX8632BinopGPR &) = delete; |
| 767 | InstX8632BinopGPR &operator=(const InstX8632BinopGPR &) = delete; |
| 768 | |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 769 | public: |
| 770 | // Create an ordinary binary-op instruction like add or sub. |
| 771 | static InstX8632BinopGPR *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 772 | return new (Func->allocate<InstX8632BinopGPR>()) |
| 773 | InstX8632BinopGPR(Func, Dest, Source); |
| 774 | } |
| 775 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 776 | if (!ALLOW_DUMP) |
| 777 | return; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 778 | const bool ShiftHack = false; |
| 779 | emitTwoAddress(Opcode, this, Func, ShiftHack); |
| 780 | } |
| 781 | void emitIAS(const Cfg *Func) const override { |
| 782 | Type Ty = getDest()->getType(); |
| 783 | assert(getSrcSize() == 2); |
| 784 | emitIASRegOpTyGPR(Func, Ty, getDest(), getSrc(1), Emitter); |
| 785 | } |
| 786 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 787 | if (!ALLOW_DUMP) |
| 788 | return; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 789 | Ostream &Str = Func->getContext()->getStrDump(); |
| 790 | dumpDest(Func); |
| 791 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 792 | dumpSources(Func); |
| 793 | } |
| 794 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 795 | |
| 796 | private: |
| 797 | InstX8632BinopGPR(Cfg *Func, Variable *Dest, Operand *Source) |
| 798 | : InstX8632(Func, K, 2, Dest) { |
| 799 | addSource(Dest); |
| 800 | addSource(Source); |
| 801 | } |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 802 | ~InstX8632BinopGPR() override {} |
| 803 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 804 | static const X8632::AssemblerX8632::GPREmitterRegOp Emitter; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 805 | }; |
| 806 | |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame^] | 807 | template <InstX8632::InstKindX8632 K> |
| 808 | class InstX8632BinopRMW : public InstX8632 { |
| 809 | InstX8632BinopRMW() = delete; |
| 810 | InstX8632BinopRMW(const InstX8632BinopRMW &) = delete; |
| 811 | InstX8632BinopRMW &operator=(const InstX8632BinopRMW &) = delete; |
| 812 | |
| 813 | public: |
| 814 | // Create an ordinary binary-op instruction like add or sub. |
| 815 | static InstX8632BinopRMW *create(Cfg *Func, OperandX8632Mem *DestSrc0, |
| 816 | Operand *Src1) { |
| 817 | return new (Func->allocate<InstX8632BinopRMW>()) |
| 818 | InstX8632BinopRMW(Func, DestSrc0, Src1); |
| 819 | } |
| 820 | void emit(const Cfg *Func) const override { |
| 821 | if (!ALLOW_DUMP) |
| 822 | return; |
| 823 | const bool ShiftHack = false; |
| 824 | emitTwoAddress(Opcode, this, Func, ShiftHack); |
| 825 | } |
| 826 | void emitIAS(const Cfg *Func) const override { |
| 827 | Type Ty = getSrc(0)->getType(); |
| 828 | assert(getSrcSize() == 2); |
| 829 | emitIASAsAddrOpTyGPR(Func, Ty, getSrc(0), getSrc(1), Emitter); |
| 830 | } |
| 831 | void dump(const Cfg *Func) const override { |
| 832 | if (!ALLOW_DUMP) |
| 833 | return; |
| 834 | Ostream &Str = Func->getContext()->getStrDump(); |
| 835 | Str << Opcode << "." << getSrc(0)->getType() << " "; |
| 836 | dumpSources(Func); |
| 837 | } |
| 838 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 839 | |
| 840 | private: |
| 841 | InstX8632BinopRMW(Cfg *Func, OperandX8632Mem *DestSrc0, Operand *Src1) |
| 842 | : InstX8632(Func, K, 2, nullptr) { |
| 843 | addSource(DestSrc0); |
| 844 | addSource(Src1); |
| 845 | } |
| 846 | ~InstX8632BinopRMW() override {} |
| 847 | static const char *Opcode; |
| 848 | static const X8632::AssemblerX8632::GPREmitterAddrOp Emitter; |
| 849 | }; |
| 850 | |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 851 | template <InstX8632::InstKindX8632 K, bool NeedsElementType> |
| 852 | class InstX8632BinopXmm : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 853 | InstX8632BinopXmm() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 854 | InstX8632BinopXmm(const InstX8632BinopXmm &) = delete; |
| 855 | InstX8632BinopXmm &operator=(const InstX8632BinopXmm &) = delete; |
| 856 | |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 857 | public: |
| 858 | // Create an XMM binary-op instruction like addss or addps. |
| 859 | static InstX8632BinopXmm *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 860 | return new (Func->allocate<InstX8632BinopXmm>()) |
| 861 | InstX8632BinopXmm(Func, Dest, Source); |
| 862 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 863 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 864 | if (!ALLOW_DUMP) |
| 865 | return; |
Jim Stichnoth | f79d2cb | 2015-03-23 15:10:54 -0700 | [diff] [blame] | 866 | validateVectorAddrMode(); |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 867 | const bool ShiftHack = false; |
| 868 | emitTwoAddress(Opcode, this, Func, ShiftHack); |
| 869 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 870 | void emitIAS(const Cfg *Func) const override { |
Jim Stichnoth | f79d2cb | 2015-03-23 15:10:54 -0700 | [diff] [blame] | 871 | validateVectorAddrMode(); |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 872 | Type Ty = getDest()->getType(); |
| 873 | if (NeedsElementType) |
| 874 | Ty = typeElementType(Ty); |
| 875 | assert(getSrcSize() == 2); |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 876 | emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(1), Emitter); |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 877 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 878 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 879 | if (!ALLOW_DUMP) |
| 880 | return; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 881 | Ostream &Str = Func->getContext()->getStrDump(); |
| 882 | dumpDest(Func); |
| 883 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 884 | dumpSources(Func); |
| 885 | } |
| 886 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 887 | |
| 888 | private: |
| 889 | InstX8632BinopXmm(Cfg *Func, Variable *Dest, Operand *Source) |
| 890 | : InstX8632(Func, K, 2, Dest) { |
| 891 | addSource(Dest); |
| 892 | addSource(Source); |
| 893 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 894 | ~InstX8632BinopXmm() override {} |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 895 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 896 | static const X8632::AssemblerX8632::XmmEmitterRegOp Emitter; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 897 | }; |
| 898 | |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 899 | void emitIASXmmShift(const Cfg *Func, Type Ty, const Variable *Var, |
| 900 | const Operand *Src, |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 901 | const X8632::AssemblerX8632::XmmEmitterShiftOp &Emitter); |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 902 | |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 903 | template <InstX8632::InstKindX8632 K, bool AllowAllTypes = false> |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 904 | class InstX8632BinopXmmShift : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 905 | InstX8632BinopXmmShift() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 906 | InstX8632BinopXmmShift(const InstX8632BinopXmmShift &) = delete; |
| 907 | InstX8632BinopXmmShift &operator=(const InstX8632BinopXmmShift &) = delete; |
| 908 | |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 909 | public: |
| 910 | // Create an XMM binary-op shift operation. |
| 911 | static InstX8632BinopXmmShift *create(Cfg *Func, Variable *Dest, |
| 912 | Operand *Source) { |
| 913 | return new (Func->allocate<InstX8632BinopXmmShift>()) |
| 914 | InstX8632BinopXmmShift(Func, Dest, Source); |
| 915 | } |
| 916 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 917 | if (!ALLOW_DUMP) |
| 918 | return; |
Jim Stichnoth | f79d2cb | 2015-03-23 15:10:54 -0700 | [diff] [blame] | 919 | validateVectorAddrMode(); |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 920 | const bool ShiftHack = false; |
| 921 | emitTwoAddress(Opcode, this, Func, ShiftHack); |
| 922 | } |
| 923 | void emitIAS(const Cfg *Func) const override { |
Jim Stichnoth | f79d2cb | 2015-03-23 15:10:54 -0700 | [diff] [blame] | 924 | validateVectorAddrMode(); |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 925 | Type Ty = getDest()->getType(); |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 926 | assert(AllowAllTypes || isVectorType(Ty)); |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 927 | Type ElementTy = typeElementType(Ty); |
| 928 | assert(getSrcSize() == 2); |
| 929 | emitIASXmmShift(Func, ElementTy, getDest(), getSrc(1), Emitter); |
| 930 | } |
| 931 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 932 | if (!ALLOW_DUMP) |
| 933 | return; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 934 | Ostream &Str = Func->getContext()->getStrDump(); |
| 935 | dumpDest(Func); |
| 936 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 937 | dumpSources(Func); |
| 938 | } |
| 939 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 940 | |
| 941 | private: |
| 942 | InstX8632BinopXmmShift(Cfg *Func, Variable *Dest, Operand *Source) |
| 943 | : InstX8632(Func, K, 2, Dest) { |
| 944 | addSource(Dest); |
| 945 | addSource(Source); |
| 946 | } |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 947 | ~InstX8632BinopXmmShift() override {} |
| 948 | static const char *Opcode; |
Jan Voung | 90ccc3f | 2015-04-30 14:15:10 -0700 | [diff] [blame] | 949 | static const X8632::AssemblerX8632::XmmEmitterShiftOp Emitter; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 950 | }; |
| 951 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 952 | template <InstX8632::InstKindX8632 K> class InstX8632Ternop : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 953 | InstX8632Ternop() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 954 | InstX8632Ternop(const InstX8632Ternop &) = delete; |
| 955 | InstX8632Ternop &operator=(const InstX8632Ternop &) = delete; |
| 956 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 957 | public: |
| 958 | // Create a ternary-op instruction like div or idiv. |
| 959 | static InstX8632Ternop *create(Cfg *Func, Variable *Dest, Operand *Source1, |
| 960 | Operand *Source2) { |
| 961 | return new (Func->allocate<InstX8632Ternop>()) |
| 962 | InstX8632Ternop(Func, Dest, Source1, Source2); |
| 963 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 964 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 965 | if (!ALLOW_DUMP) |
| 966 | return; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 967 | Ostream &Str = Func->getContext()->getStrEmit(); |
| 968 | assert(getSrcSize() == 3); |
| 969 | Str << "\t" << Opcode << "\t"; |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 970 | getSrc(2)->emit(Func); |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 971 | Str << ", "; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 972 | getSrc(1)->emit(Func); |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 973 | Str << ", "; |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 974 | getDest()->emit(Func); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 975 | } |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 976 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 977 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 978 | if (!ALLOW_DUMP) |
| 979 | return; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 980 | Ostream &Str = Func->getContext()->getStrDump(); |
| 981 | dumpDest(Func); |
| 982 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 983 | dumpSources(Func); |
| 984 | } |
| 985 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 986 | |
| 987 | private: |
| 988 | InstX8632Ternop(Cfg *Func, Variable *Dest, Operand *Source1, Operand *Source2) |
| 989 | : InstX8632(Func, K, 3, Dest) { |
| 990 | addSource(Dest); |
| 991 | addSource(Source1); |
| 992 | addSource(Source2); |
| 993 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 994 | ~InstX8632Ternop() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 995 | static const char *Opcode; |
| 996 | }; |
| 997 | |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 998 | // Instructions of the form x := y op z |
| 999 | template <InstX8632::InstKindX8632 K> |
| 1000 | class InstX8632ThreeAddressop : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1001 | InstX8632ThreeAddressop() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1002 | InstX8632ThreeAddressop(const InstX8632ThreeAddressop &) = delete; |
| 1003 | InstX8632ThreeAddressop &operator=(const InstX8632ThreeAddressop &) = delete; |
| 1004 | |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1005 | public: |
| 1006 | static InstX8632ThreeAddressop *create(Cfg *Func, Variable *Dest, |
| 1007 | Operand *Source0, Operand *Source1) { |
| 1008 | return new (Func->allocate<InstX8632ThreeAddressop>()) |
| 1009 | InstX8632ThreeAddressop(Func, Dest, Source0, Source1); |
| 1010 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1011 | void emit(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 1012 | if (!ALLOW_DUMP) |
| 1013 | return; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1014 | Ostream &Str = Func->getContext()->getStrEmit(); |
| 1015 | assert(getSrcSize() == 2); |
| 1016 | Str << "\t" << Opcode << "\t"; |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 1017 | getSrc(1)->emit(Func); |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1018 | Str << ", "; |
| 1019 | getSrc(0)->emit(Func); |
| 1020 | Str << ", "; |
Jim Stichnoth | bca2f65 | 2014-11-01 10:13:54 -0700 | [diff] [blame] | 1021 | getDest()->emit(Func); |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1022 | } |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1023 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1024 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 1025 | if (!ALLOW_DUMP) |
| 1026 | return; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1027 | Ostream &Str = Func->getContext()->getStrDump(); |
| 1028 | dumpDest(Func); |
| 1029 | Str << " = " << Opcode << "." << getDest()->getType() << " "; |
| 1030 | dumpSources(Func); |
| 1031 | } |
| 1032 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 1033 | |
| 1034 | private: |
| 1035 | InstX8632ThreeAddressop(Cfg *Func, Variable *Dest, Operand *Source0, |
| 1036 | Operand *Source1) |
| 1037 | : InstX8632(Func, K, 2, Dest) { |
| 1038 | addSource(Source0); |
| 1039 | addSource(Source1); |
| 1040 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1041 | ~InstX8632ThreeAddressop() override {} |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1042 | static const char *Opcode; |
| 1043 | }; |
| 1044 | |
Matt Wala | e58178a | 2014-08-12 13:15:04 -0700 | [diff] [blame] | 1045 | // Base class for assignment instructions |
| 1046 | template <InstX8632::InstKindX8632 K> |
| 1047 | class InstX8632Movlike : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1048 | InstX8632Movlike() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1049 | InstX8632Movlike(const InstX8632Movlike &) = delete; |
| 1050 | InstX8632Movlike &operator=(const InstX8632Movlike &) = delete; |
| 1051 | |
Matt Wala | e58178a | 2014-08-12 13:15:04 -0700 | [diff] [blame] | 1052 | public: |
| 1053 | static InstX8632Movlike *create(Cfg *Func, Variable *Dest, Operand *Source) { |
| 1054 | return new (Func->allocate<InstX8632Movlike>()) |
| 1055 | InstX8632Movlike(Func, Dest, Source); |
| 1056 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1057 | bool isRedundantAssign() const override { |
Matt Wala | e58178a | 2014-08-12 13:15:04 -0700 | [diff] [blame] | 1058 | return checkForRedundantAssign(getDest(), getSrc(0)); |
| 1059 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1060 | bool isSimpleAssign() const override { return true; } |
| 1061 | void emit(const Cfg *Func) const override; |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 1062 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1063 | void dump(const Cfg *Func) const override { |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 1064 | if (!ALLOW_DUMP) |
| 1065 | return; |
Matt Wala | e58178a | 2014-08-12 13:15:04 -0700 | [diff] [blame] | 1066 | Ostream &Str = Func->getContext()->getStrDump(); |
| 1067 | Str << Opcode << "." << getDest()->getType() << " "; |
| 1068 | dumpDest(Func); |
| 1069 | Str << ", "; |
| 1070 | dumpSources(Func); |
| 1071 | } |
| 1072 | static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
| 1073 | |
| 1074 | private: |
| 1075 | InstX8632Movlike(Cfg *Func, Variable *Dest, Operand *Source) |
| 1076 | : InstX8632(Func, K, 1, Dest) { |
| 1077 | addSource(Source); |
| 1078 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1079 | ~InstX8632Movlike() override {} |
Matt Wala | e58178a | 2014-08-12 13:15:04 -0700 | [diff] [blame] | 1080 | |
| 1081 | static const char *Opcode; |
| 1082 | }; |
| 1083 | |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 1084 | typedef InstX8632InplaceopGPR<InstX8632::Bswap> InstX8632Bswap; |
| 1085 | typedef InstX8632InplaceopGPR<InstX8632::Neg> InstX8632Neg; |
| 1086 | typedef InstX8632UnaryopGPR<InstX8632::Bsf> InstX8632Bsf; |
| 1087 | typedef InstX8632UnaryopGPR<InstX8632::Bsr> InstX8632Bsr; |
| 1088 | typedef InstX8632UnaryopGPR<InstX8632::Lea> InstX8632Lea; |
Matt Wala | 51e8cfb | 2014-08-08 08:39:40 -0700 | [diff] [blame] | 1089 | // Cbwdq instruction - wrapper for cbw, cwd, and cdq |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 1090 | typedef InstX8632UnaryopGPR<InstX8632::Cbwdq> InstX8632Cbwdq; |
Jan Voung | 39d4aca | 2014-10-15 15:16:54 -0700 | [diff] [blame] | 1091 | typedef InstX8632UnaryopGPR<InstX8632::Movsx> InstX8632Movsx; |
| 1092 | typedef InstX8632UnaryopGPR<InstX8632::Movzx> InstX8632Movzx; |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 1093 | typedef InstX8632UnaryopXmm<InstX8632::Movd> InstX8632Movd; |
| 1094 | typedef InstX8632UnaryopXmm<InstX8632::Sqrtss> InstX8632Sqrtss; |
Matt Wala | e58178a | 2014-08-12 13:15:04 -0700 | [diff] [blame] | 1095 | // Move/assignment instruction - wrapper for mov/movss/movsd. |
| 1096 | typedef InstX8632Movlike<InstX8632::Mov> InstX8632Mov; |
| 1097 | // Move packed - copy 128 bit values between XMM registers, or mem128 |
| 1098 | // and XMM registers. |
| 1099 | typedef InstX8632Movlike<InstX8632::Movp> InstX8632Movp; |
| 1100 | // Movq - copy between XMM registers, or mem64 and XMM registers. |
| 1101 | typedef InstX8632Movlike<InstX8632::Movq> InstX8632Movq; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1102 | typedef InstX8632BinopGPR<InstX8632::Add> InstX8632Add; |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame^] | 1103 | typedef InstX8632BinopRMW<InstX8632::AddRMW> InstX8632AddRMW; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1104 | typedef InstX8632BinopXmm<InstX8632::Addps, true> InstX8632Addps; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1105 | typedef InstX8632BinopGPR<InstX8632::Adc> InstX8632Adc; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1106 | typedef InstX8632BinopXmm<InstX8632::Addss, false> InstX8632Addss; |
| 1107 | typedef InstX8632BinopXmm<InstX8632::Padd, true> InstX8632Padd; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1108 | typedef InstX8632BinopGPR<InstX8632::Sub> InstX8632Sub; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1109 | typedef InstX8632BinopXmm<InstX8632::Subps, true> InstX8632Subps; |
| 1110 | typedef InstX8632BinopXmm<InstX8632::Subss, false> InstX8632Subss; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1111 | typedef InstX8632BinopGPR<InstX8632::Sbb> InstX8632Sbb; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1112 | typedef InstX8632BinopXmm<InstX8632::Psub, true> InstX8632Psub; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1113 | typedef InstX8632BinopGPR<InstX8632::And> InstX8632And; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1114 | typedef InstX8632BinopXmm<InstX8632::Pand, false> InstX8632Pand; |
| 1115 | typedef InstX8632BinopXmm<InstX8632::Pandn, false> InstX8632Pandn; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1116 | typedef InstX8632BinopGPR<InstX8632::Or> InstX8632Or; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1117 | typedef InstX8632BinopXmm<InstX8632::Por, false> InstX8632Por; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1118 | typedef InstX8632BinopGPR<InstX8632::Xor> InstX8632Xor; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1119 | typedef InstX8632BinopXmm<InstX8632::Pxor, false> InstX8632Pxor; |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 1120 | typedef InstX8632BinopGPR<InstX8632::Imul> InstX8632Imul; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1121 | typedef InstX8632BinopXmm<InstX8632::Mulps, true> InstX8632Mulps; |
| 1122 | typedef InstX8632BinopXmm<InstX8632::Mulss, false> InstX8632Mulss; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 1123 | typedef InstX8632BinopXmm<InstX8632::Pmull, true> InstX8632Pmull; |
Jan Voung | 8acded0 | 2014-09-22 18:02:25 -0700 | [diff] [blame] | 1124 | typedef InstX8632BinopXmm<InstX8632::Pmuludq, false> InstX8632Pmuludq; |
| 1125 | typedef InstX8632BinopXmm<InstX8632::Divps, true> InstX8632Divps; |
| 1126 | typedef InstX8632BinopXmm<InstX8632::Divss, false> InstX8632Divss; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 1127 | typedef InstX8632BinopGPRShift<InstX8632::Rol> InstX8632Rol; |
| 1128 | typedef InstX8632BinopGPRShift<InstX8632::Shl> InstX8632Shl; |
| 1129 | typedef InstX8632BinopXmmShift<InstX8632::Psll> InstX8632Psll; |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 1130 | typedef InstX8632BinopXmmShift<InstX8632::Psrl, true> InstX8632Psrl; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 1131 | typedef InstX8632BinopGPRShift<InstX8632::Shr> InstX8632Shr; |
| 1132 | typedef InstX8632BinopGPRShift<InstX8632::Sar> InstX8632Sar; |
| 1133 | typedef InstX8632BinopXmmShift<InstX8632::Psra> InstX8632Psra; |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 1134 | typedef InstX8632BinopXmm<InstX8632::Pcmpeq, true> InstX8632Pcmpeq; |
| 1135 | typedef InstX8632BinopXmm<InstX8632::Pcmpgt, true> InstX8632Pcmpgt; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1136 | // movss is only a binary operation when the source and dest |
| 1137 | // operands are both registers (the high bits of dest are left untouched). |
| 1138 | // In other cases, it behaves like a copy (mov-like) operation (and the |
| 1139 | // high bits of dest are cleared). |
| 1140 | // InstX8632Movss will assert that both its source and dest operands are |
| 1141 | // registers, so the lowering code should use _mov instead of _movss |
| 1142 | // in cases where a copy operation is intended. |
| 1143 | typedef InstX8632BinopXmm<InstX8632::MovssRegs, false> InstX8632MovssRegs; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1144 | typedef InstX8632Ternop<InstX8632::Idiv> InstX8632Idiv; |
| 1145 | typedef InstX8632Ternop<InstX8632::Div> InstX8632Div; |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 1146 | typedef InstX8632Ternop<InstX8632::Insertps> InstX8632Insertps; |
| 1147 | typedef InstX8632Ternop<InstX8632::Pinsr> InstX8632Pinsr; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1148 | typedef InstX8632Ternop<InstX8632::Shufps> InstX8632Shufps; |
Matt Wala | 0a45051 | 2014-07-30 12:44:39 -0700 | [diff] [blame] | 1149 | typedef InstX8632Ternop<InstX8632::Blendvps> InstX8632Blendvps; |
| 1150 | typedef InstX8632Ternop<InstX8632::Pblendvb> InstX8632Pblendvb; |
| 1151 | typedef InstX8632ThreeAddressop<InstX8632::Pextr> InstX8632Pextr; |
Matt Wala | 4988923 | 2014-07-18 12:45:09 -0700 | [diff] [blame] | 1152 | typedef InstX8632ThreeAddressop<InstX8632::Pshufd> InstX8632Pshufd; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1153 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1154 | // Base class for a lockable x86-32 instruction (emits a locked prefix). |
| 1155 | class InstX8632Lockable : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1156 | InstX8632Lockable() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1157 | InstX8632Lockable(const InstX8632Lockable &) = delete; |
| 1158 | InstX8632Lockable &operator=(const InstX8632Lockable &) = delete; |
| 1159 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1160 | protected: |
| 1161 | bool Locked; |
| 1162 | |
| 1163 | InstX8632Lockable(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, |
| 1164 | Variable *Dest, bool Locked) |
| 1165 | : InstX8632(Func, Kind, Maxsrcs, Dest), Locked(Locked) { |
| 1166 | // Assume that such instructions are used for Atomics and be careful |
| 1167 | // with optimizations. |
| 1168 | HasSideEffects = Locked; |
| 1169 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1170 | ~InstX8632Lockable() override {} |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1171 | }; |
| 1172 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1173 | // Mul instruction - unsigned multiply. |
| 1174 | class InstX8632Mul : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1175 | InstX8632Mul() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1176 | InstX8632Mul(const InstX8632Mul &) = delete; |
| 1177 | InstX8632Mul &operator=(const InstX8632Mul &) = delete; |
| 1178 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1179 | public: |
| 1180 | static InstX8632Mul *create(Cfg *Func, Variable *Dest, Variable *Source1, |
| 1181 | Operand *Source2) { |
| 1182 | return new (Func->allocate<InstX8632Mul>()) |
| 1183 | InstX8632Mul(Func, Dest, Source1, Source2); |
| 1184 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1185 | void emit(const Cfg *Func) const override; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1186 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1187 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1188 | static bool classof(const Inst *Inst) { return isClassof(Inst, Mul); } |
| 1189 | |
| 1190 | private: |
| 1191 | InstX8632Mul(Cfg *Func, Variable *Dest, Variable *Source1, Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1192 | ~InstX8632Mul() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1193 | }; |
| 1194 | |
Jan Voung | 8835576 | 2014-11-01 09:40:20 -0700 | [diff] [blame] | 1195 | // Shld instruction - shift across a pair of operands. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1196 | class InstX8632Shld : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1197 | InstX8632Shld() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1198 | InstX8632Shld(const InstX8632Shld &) = delete; |
| 1199 | InstX8632Shld &operator=(const InstX8632Shld &) = delete; |
| 1200 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1201 | public: |
| 1202 | static InstX8632Shld *create(Cfg *Func, Variable *Dest, Variable *Source1, |
| 1203 | Variable *Source2) { |
| 1204 | return new (Func->allocate<InstX8632Shld>()) |
| 1205 | InstX8632Shld(Func, Dest, Source1, Source2); |
| 1206 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1207 | void emit(const Cfg *Func) const override; |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1208 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1209 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1210 | static bool classof(const Inst *Inst) { return isClassof(Inst, Shld); } |
| 1211 | |
| 1212 | private: |
| 1213 | InstX8632Shld(Cfg *Func, Variable *Dest, Variable *Source1, |
| 1214 | Variable *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1215 | ~InstX8632Shld() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1216 | }; |
| 1217 | |
Jan Voung | 8835576 | 2014-11-01 09:40:20 -0700 | [diff] [blame] | 1218 | // Shrd instruction - shift across a pair of operands. |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1219 | class InstX8632Shrd : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1220 | InstX8632Shrd() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1221 | InstX8632Shrd(const InstX8632Shrd &) = delete; |
| 1222 | InstX8632Shrd &operator=(const InstX8632Shrd &) = delete; |
| 1223 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1224 | public: |
| 1225 | static InstX8632Shrd *create(Cfg *Func, Variable *Dest, Variable *Source1, |
| 1226 | Variable *Source2) { |
| 1227 | return new (Func->allocate<InstX8632Shrd>()) |
| 1228 | InstX8632Shrd(Func, Dest, Source1, Source2); |
| 1229 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1230 | void emit(const Cfg *Func) const override; |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1231 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1232 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1233 | static bool classof(const Inst *Inst) { return isClassof(Inst, Shrd); } |
| 1234 | |
| 1235 | private: |
| 1236 | InstX8632Shrd(Cfg *Func, Variable *Dest, Variable *Source1, |
| 1237 | Variable *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1238 | ~InstX8632Shrd() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1239 | }; |
| 1240 | |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 1241 | // Conditional move instruction. |
| 1242 | class InstX8632Cmov : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1243 | InstX8632Cmov() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1244 | InstX8632Cmov(const InstX8632Cmov &) = delete; |
| 1245 | InstX8632Cmov &operator=(const InstX8632Cmov &) = delete; |
| 1246 | |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 1247 | public: |
| 1248 | static InstX8632Cmov *create(Cfg *Func, Variable *Dest, Operand *Source, |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 1249 | CondX86::BrCond Cond) { |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 1250 | return new (Func->allocate<InstX8632Cmov>()) |
| 1251 | InstX8632Cmov(Func, Dest, Source, Cond); |
| 1252 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1253 | void emit(const Cfg *Func) const override; |
| 1254 | void emitIAS(const Cfg *Func) const override; |
| 1255 | void dump(const Cfg *Func) const override; |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 1256 | static bool classof(const Inst *Inst) { return isClassof(Inst, Cmov); } |
| 1257 | |
| 1258 | private: |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 1259 | InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, |
| 1260 | CondX86::BrCond Cond); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1261 | ~InstX8632Cmov() override {} |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 1262 | |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 1263 | CondX86::BrCond Condition; |
Jan Voung | e4da26f | 2014-07-15 17:52:39 -0700 | [diff] [blame] | 1264 | }; |
| 1265 | |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1266 | // Cmpps instruction - compare packed singled-precision floating point |
| 1267 | // values |
| 1268 | class InstX8632Cmpps : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1269 | InstX8632Cmpps() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1270 | InstX8632Cmpps(const InstX8632Cmpps &) = delete; |
| 1271 | InstX8632Cmpps &operator=(const InstX8632Cmpps &) = delete; |
| 1272 | |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1273 | public: |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1274 | static InstX8632Cmpps *create(Cfg *Func, Variable *Dest, Operand *Source, |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 1275 | CondX86::CmppsCond Condition) { |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1276 | return new (Func->allocate<InstX8632Cmpps>()) |
| 1277 | InstX8632Cmpps(Func, Dest, Source, Condition); |
| 1278 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1279 | void emit(const Cfg *Func) const override; |
| 1280 | void emitIAS(const Cfg *Func) const override; |
| 1281 | void dump(const Cfg *Func) const override; |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1282 | static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpps); } |
| 1283 | |
| 1284 | private: |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 1285 | InstX8632Cmpps(Cfg *Func, Variable *Dest, Operand *Source, |
| 1286 | CondX86::CmppsCond Cond); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1287 | ~InstX8632Cmpps() override {} |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1288 | |
Jan Voung | bd385e4 | 2014-09-18 18:18:10 -0700 | [diff] [blame] | 1289 | CondX86::CmppsCond Condition; |
Matt Wala | ce0ca8f | 2014-07-24 12:34:20 -0700 | [diff] [blame] | 1290 | }; |
| 1291 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1292 | // Cmpxchg instruction - cmpxchg <dest>, <desired> will compare if <dest> |
| 1293 | // equals eax. If so, the ZF is set and <desired> is stored in <dest>. |
| 1294 | // If not, ZF is cleared and <dest> is copied to eax (or subregister). |
| 1295 | // <dest> can be a register or memory, while <desired> must be a register. |
| 1296 | // It is the user's responsiblity to mark eax with a FakeDef. |
| 1297 | class InstX8632Cmpxchg : public InstX8632Lockable { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1298 | InstX8632Cmpxchg() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1299 | InstX8632Cmpxchg(const InstX8632Cmpxchg &) = delete; |
| 1300 | InstX8632Cmpxchg &operator=(const InstX8632Cmpxchg &) = delete; |
| 1301 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1302 | public: |
| 1303 | static InstX8632Cmpxchg *create(Cfg *Func, Operand *DestOrAddr, Variable *Eax, |
| 1304 | Variable *Desired, bool Locked) { |
| 1305 | return new (Func->allocate<InstX8632Cmpxchg>()) |
| 1306 | InstX8632Cmpxchg(Func, DestOrAddr, Eax, Desired, Locked); |
| 1307 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1308 | void emit(const Cfg *Func) const override; |
| 1309 | void emitIAS(const Cfg *Func) const override; |
| 1310 | void dump(const Cfg *Func) const override; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1311 | static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpxchg); } |
| 1312 | |
| 1313 | private: |
| 1314 | InstX8632Cmpxchg(Cfg *Func, Operand *DestOrAddr, Variable *Eax, |
| 1315 | Variable *Desired, bool Locked); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1316 | ~InstX8632Cmpxchg() override {} |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1317 | }; |
| 1318 | |
| 1319 | // Cmpxchg8b instruction - cmpxchg8b <m64> will compare if <m64> |
| 1320 | // equals edx:eax. If so, the ZF is set and ecx:ebx is stored in <m64>. |
| 1321 | // If not, ZF is cleared and <m64> is copied to edx:eax. |
| 1322 | // The caller is responsible for inserting FakeDefs to mark edx |
| 1323 | // and eax as modified. |
| 1324 | // <m64> must be a memory operand. |
| 1325 | class InstX8632Cmpxchg8b : public InstX8632Lockable { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1326 | InstX8632Cmpxchg8b() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1327 | InstX8632Cmpxchg8b(const InstX8632Cmpxchg8b &) = delete; |
| 1328 | InstX8632Cmpxchg8b &operator=(const InstX8632Cmpxchg8b &) = delete; |
| 1329 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1330 | public: |
Jan Voung | 03532e5 | 2014-09-23 13:32:18 -0700 | [diff] [blame] | 1331 | static InstX8632Cmpxchg8b *create(Cfg *Func, OperandX8632Mem *Dest, |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1332 | Variable *Edx, Variable *Eax, Variable *Ecx, |
| 1333 | Variable *Ebx, bool Locked) { |
| 1334 | return new (Func->allocate<InstX8632Cmpxchg8b>()) |
| 1335 | InstX8632Cmpxchg8b(Func, Dest, Edx, Eax, Ecx, Ebx, Locked); |
| 1336 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1337 | void emit(const Cfg *Func) const override; |
| 1338 | void emitIAS(const Cfg *Func) const override; |
| 1339 | void dump(const Cfg *Func) const override; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1340 | static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpxchg8b); } |
| 1341 | |
| 1342 | private: |
Jan Voung | 03532e5 | 2014-09-23 13:32:18 -0700 | [diff] [blame] | 1343 | InstX8632Cmpxchg8b(Cfg *Func, OperandX8632Mem *Dest, Variable *Edx, |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1344 | Variable *Eax, Variable *Ecx, Variable *Ebx, bool Locked); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1345 | ~InstX8632Cmpxchg8b() override {} |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1346 | }; |
| 1347 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1348 | // Cvt instruction - wrapper for cvtsX2sY where X and Y are in {s,d,i} |
| 1349 | // as appropriate. s=float, d=double, i=int. X and Y are determined |
| 1350 | // from dest/src types. Sign and zero extension on the integer |
| 1351 | // operand needs to be done separately. |
| 1352 | class InstX8632Cvt : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1353 | InstX8632Cvt() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1354 | InstX8632Cvt(const InstX8632Cvt &) = delete; |
| 1355 | InstX8632Cvt &operator=(const InstX8632Cvt &) = delete; |
| 1356 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1357 | public: |
Jan Voung | 699bf02 | 2014-10-08 13:52:10 -0700 | [diff] [blame] | 1358 | enum CvtVariant { Si2ss, Tss2si, Float2float, Dq2ps, Tps2dq }; |
Jim Stichnoth | b63cd88 | 2014-09-08 10:47:23 -0700 | [diff] [blame] | 1359 | static InstX8632Cvt *create(Cfg *Func, Variable *Dest, Operand *Source, |
Jan Voung | 699bf02 | 2014-10-08 13:52:10 -0700 | [diff] [blame] | 1360 | CvtVariant Variant) { |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1361 | return new (Func->allocate<InstX8632Cvt>()) |
Jan Voung | 699bf02 | 2014-10-08 13:52:10 -0700 | [diff] [blame] | 1362 | InstX8632Cvt(Func, Dest, Source, Variant); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1363 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1364 | void emit(const Cfg *Func) const override; |
Jan Voung | 699bf02 | 2014-10-08 13:52:10 -0700 | [diff] [blame] | 1365 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1366 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1367 | static bool classof(const Inst *Inst) { return isClassof(Inst, Cvt); } |
Jan Voung | 699bf02 | 2014-10-08 13:52:10 -0700 | [diff] [blame] | 1368 | bool isTruncating() const { return Variant == Tss2si || Variant == Tps2dq; } |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1369 | |
| 1370 | private: |
Jan Voung | 699bf02 | 2014-10-08 13:52:10 -0700 | [diff] [blame] | 1371 | CvtVariant Variant; |
| 1372 | InstX8632Cvt(Cfg *Func, Variable *Dest, Operand *Source, CvtVariant Variant); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1373 | ~InstX8632Cvt() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1374 | }; |
| 1375 | |
| 1376 | // cmp - Integer compare instruction. |
| 1377 | class InstX8632Icmp : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1378 | InstX8632Icmp() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1379 | InstX8632Icmp(const InstX8632Icmp &) = delete; |
| 1380 | InstX8632Icmp &operator=(const InstX8632Icmp &) = delete; |
| 1381 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1382 | public: |
| 1383 | static InstX8632Icmp *create(Cfg *Func, Operand *Src1, Operand *Src2) { |
| 1384 | return new (Func->allocate<InstX8632Icmp>()) |
| 1385 | InstX8632Icmp(Func, Src1, Src2); |
| 1386 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1387 | void emit(const Cfg *Func) const override; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1388 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1389 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1390 | static bool classof(const Inst *Inst) { return isClassof(Inst, Icmp); } |
| 1391 | |
| 1392 | private: |
| 1393 | InstX8632Icmp(Cfg *Func, Operand *Src1, Operand *Src2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1394 | ~InstX8632Icmp() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1395 | }; |
| 1396 | |
| 1397 | // ucomiss/ucomisd - floating-point compare instruction. |
| 1398 | class InstX8632Ucomiss : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1399 | InstX8632Ucomiss() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1400 | InstX8632Ucomiss(const InstX8632Ucomiss &) = delete; |
| 1401 | InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) = delete; |
| 1402 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1403 | public: |
| 1404 | static InstX8632Ucomiss *create(Cfg *Func, Operand *Src1, Operand *Src2) { |
| 1405 | return new (Func->allocate<InstX8632Ucomiss>()) |
| 1406 | InstX8632Ucomiss(Func, Src1, Src2); |
| 1407 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1408 | void emit(const Cfg *Func) const override; |
| 1409 | void emitIAS(const Cfg *Func) const override; |
| 1410 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1411 | static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } |
| 1412 | |
| 1413 | private: |
| 1414 | InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1415 | ~InstX8632Ucomiss() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1416 | }; |
| 1417 | |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 1418 | // UD2 instruction. |
| 1419 | class InstX8632UD2 : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1420 | InstX8632UD2() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1421 | InstX8632UD2(const InstX8632UD2 &) = delete; |
| 1422 | InstX8632UD2 &operator=(const InstX8632UD2 &) = delete; |
| 1423 | |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 1424 | public: |
| 1425 | static InstX8632UD2 *create(Cfg *Func) { |
| 1426 | return new (Func->allocate<InstX8632UD2>()) InstX8632UD2(Func); |
| 1427 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1428 | void emit(const Cfg *Func) const override; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1429 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1430 | void dump(const Cfg *Func) const override; |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 1431 | static bool classof(const Inst *Inst) { return isClassof(Inst, UD2); } |
| 1432 | |
| 1433 | private: |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1434 | explicit InstX8632UD2(Cfg *Func); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1435 | ~InstX8632UD2() override {} |
Jan Voung | 3bd9f1a | 2014-06-18 10:50:57 -0700 | [diff] [blame] | 1436 | }; |
| 1437 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1438 | // Test instruction. |
| 1439 | class InstX8632Test : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1440 | InstX8632Test() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1441 | InstX8632Test(const InstX8632Test &) = delete; |
| 1442 | InstX8632Test &operator=(const InstX8632Test &) = delete; |
| 1443 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1444 | public: |
| 1445 | static InstX8632Test *create(Cfg *Func, Operand *Source1, Operand *Source2) { |
| 1446 | return new (Func->allocate<InstX8632Test>()) |
| 1447 | InstX8632Test(Func, Source1, Source2); |
| 1448 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1449 | void emit(const Cfg *Func) const override; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1450 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1451 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1452 | static bool classof(const Inst *Inst) { return isClassof(Inst, Test); } |
| 1453 | |
| 1454 | private: |
| 1455 | InstX8632Test(Cfg *Func, Operand *Source1, Operand *Source2); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1456 | ~InstX8632Test() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1457 | }; |
| 1458 | |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1459 | // Mfence instruction. |
| 1460 | class InstX8632Mfence : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1461 | InstX8632Mfence() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1462 | InstX8632Mfence(const InstX8632Mfence &) = delete; |
| 1463 | InstX8632Mfence &operator=(const InstX8632Mfence &) = delete; |
| 1464 | |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1465 | public: |
| 1466 | static InstX8632Mfence *create(Cfg *Func) { |
| 1467 | return new (Func->allocate<InstX8632Mfence>()) InstX8632Mfence(Func); |
| 1468 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1469 | void emit(const Cfg *Func) const override; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1470 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1471 | void dump(const Cfg *Func) const override; |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1472 | static bool classof(const Inst *Inst) { return isClassof(Inst, Mfence); } |
| 1473 | |
| 1474 | private: |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1475 | explicit InstX8632Mfence(Cfg *Func); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1476 | ~InstX8632Mfence() override {} |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1477 | }; |
| 1478 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1479 | // This is essentially a "mov" instruction with an OperandX8632Mem |
| 1480 | // operand instead of Variable as the destination. It's important |
| 1481 | // for liveness that there is no Dest operand. |
| 1482 | class InstX8632Store : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1483 | InstX8632Store() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1484 | InstX8632Store(const InstX8632Store &) = delete; |
| 1485 | InstX8632Store &operator=(const InstX8632Store &) = delete; |
| 1486 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1487 | public: |
| 1488 | static InstX8632Store *create(Cfg *Func, Operand *Value, OperandX8632 *Mem) { |
| 1489 | return new (Func->allocate<InstX8632Store>()) |
| 1490 | InstX8632Store(Func, Value, Mem); |
| 1491 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1492 | void emit(const Cfg *Func) const override; |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 1493 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1494 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1495 | static bool classof(const Inst *Inst) { return isClassof(Inst, Store); } |
| 1496 | |
| 1497 | private: |
| 1498 | InstX8632Store(Cfg *Func, Operand *Value, OperandX8632 *Mem); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1499 | ~InstX8632Store() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1500 | }; |
| 1501 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1502 | // This is essentially a vector "mov" instruction with an OperandX8632Mem |
| 1503 | // operand instead of Variable as the destination. It's important |
| 1504 | // for liveness that there is no Dest operand. The source must be an |
| 1505 | // Xmm register, since Dest is mem. |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 1506 | class InstX8632StoreP : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1507 | InstX8632StoreP() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1508 | InstX8632StoreP(const InstX8632StoreP &) = delete; |
| 1509 | InstX8632StoreP &operator=(const InstX8632StoreP &) = delete; |
| 1510 | |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 1511 | public: |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1512 | static InstX8632StoreP *create(Cfg *Func, Variable *Value, |
| 1513 | OperandX8632Mem *Mem) { |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 1514 | return new (Func->allocate<InstX8632StoreP>()) |
| 1515 | InstX8632StoreP(Func, Value, Mem); |
| 1516 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1517 | void emit(const Cfg *Func) const override; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1518 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1519 | void dump(const Cfg *Func) const override; |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 1520 | static bool classof(const Inst *Inst) { return isClassof(Inst, StoreP); } |
| 1521 | |
| 1522 | private: |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1523 | InstX8632StoreP(Cfg *Func, Variable *Value, OperandX8632Mem *Mem); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1524 | ~InstX8632StoreP() override {} |
Matt Wala | 105b704 | 2014-08-11 19:56:19 -0700 | [diff] [blame] | 1525 | }; |
| 1526 | |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1527 | class InstX8632StoreQ : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1528 | InstX8632StoreQ() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1529 | InstX8632StoreQ(const InstX8632StoreQ &) = delete; |
| 1530 | InstX8632StoreQ &operator=(const InstX8632StoreQ &) = delete; |
| 1531 | |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1532 | public: |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1533 | static InstX8632StoreQ *create(Cfg *Func, Variable *Value, |
| 1534 | OperandX8632Mem *Mem) { |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1535 | return new (Func->allocate<InstX8632StoreQ>()) |
| 1536 | InstX8632StoreQ(Func, Value, Mem); |
| 1537 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1538 | void emit(const Cfg *Func) const override; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1539 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1540 | void dump(const Cfg *Func) const override; |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1541 | static bool classof(const Inst *Inst) { return isClassof(Inst, StoreQ); } |
| 1542 | |
| 1543 | private: |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1544 | InstX8632StoreQ(Cfg *Func, Variable *Value, OperandX8632Mem *Mem); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1545 | ~InstX8632StoreQ() override {} |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1546 | }; |
| 1547 | |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 1548 | // Nop instructions of varying length |
| 1549 | class InstX8632Nop : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1550 | InstX8632Nop() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1551 | InstX8632Nop(const InstX8632Nop &) = delete; |
| 1552 | InstX8632Nop &operator=(const InstX8632Nop &) = delete; |
| 1553 | |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 1554 | public: |
| 1555 | // TODO: Replace with enum. |
| 1556 | typedef unsigned NopVariant; |
| 1557 | |
| 1558 | static InstX8632Nop *create(Cfg *Func, NopVariant Variant) { |
| 1559 | return new (Func->allocate<InstX8632Nop>()) InstX8632Nop(Func, Variant); |
| 1560 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1561 | void emit(const Cfg *Func) const override; |
| 1562 | void emitIAS(const Cfg *Func) const override; |
| 1563 | void dump(const Cfg *Func) const override; |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 1564 | static bool classof(const Inst *Inst) { return isClassof(Inst, Nop); } |
| 1565 | |
| 1566 | private: |
| 1567 | InstX8632Nop(Cfg *Func, SizeT Length); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1568 | ~InstX8632Nop() override {} |
Matt Wala | c330274 | 2014-08-15 16:21:56 -0700 | [diff] [blame] | 1569 | |
| 1570 | NopVariant Variant; |
| 1571 | }; |
| 1572 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1573 | // Fld - load a value onto the x87 FP stack. |
| 1574 | class InstX8632Fld : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1575 | InstX8632Fld() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1576 | InstX8632Fld(const InstX8632Fld &) = delete; |
| 1577 | InstX8632Fld &operator=(const InstX8632Fld &) = delete; |
| 1578 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1579 | public: |
| 1580 | static InstX8632Fld *create(Cfg *Func, Operand *Src) { |
| 1581 | return new (Func->allocate<InstX8632Fld>()) InstX8632Fld(Func, Src); |
| 1582 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1583 | void emit(const Cfg *Func) const override; |
Jan Voung | 479e563 | 2014-10-08 21:05:27 -0700 | [diff] [blame] | 1584 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1585 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1586 | static bool classof(const Inst *Inst) { return isClassof(Inst, Fld); } |
| 1587 | |
| 1588 | private: |
| 1589 | InstX8632Fld(Cfg *Func, Operand *Src); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1590 | ~InstX8632Fld() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1591 | }; |
| 1592 | |
| 1593 | // Fstp - store x87 st(0) into memory and pop st(0). |
| 1594 | class InstX8632Fstp : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1595 | InstX8632Fstp() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1596 | InstX8632Fstp(const InstX8632Fstp &) = delete; |
| 1597 | InstX8632Fstp &operator=(const InstX8632Fstp &) = delete; |
| 1598 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1599 | public: |
| 1600 | static InstX8632Fstp *create(Cfg *Func, Variable *Dest) { |
| 1601 | return new (Func->allocate<InstX8632Fstp>()) InstX8632Fstp(Func, Dest); |
| 1602 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1603 | void emit(const Cfg *Func) const override; |
Jan Voung | 479e563 | 2014-10-08 21:05:27 -0700 | [diff] [blame] | 1604 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1605 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1606 | static bool classof(const Inst *Inst) { return isClassof(Inst, Fstp); } |
| 1607 | |
| 1608 | private: |
| 1609 | InstX8632Fstp(Cfg *Func, Variable *Dest); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1610 | ~InstX8632Fstp() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1611 | }; |
| 1612 | |
| 1613 | class InstX8632Pop : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1614 | InstX8632Pop() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1615 | InstX8632Pop(const InstX8632Pop &) = delete; |
| 1616 | InstX8632Pop &operator=(const InstX8632Pop &) = delete; |
| 1617 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1618 | public: |
| 1619 | static InstX8632Pop *create(Cfg *Func, Variable *Dest) { |
| 1620 | return new (Func->allocate<InstX8632Pop>()) InstX8632Pop(Func, Dest); |
| 1621 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1622 | void emit(const Cfg *Func) const override; |
| 1623 | void emitIAS(const Cfg *Func) const override; |
| 1624 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1625 | static bool classof(const Inst *Inst) { return isClassof(Inst, Pop); } |
| 1626 | |
| 1627 | private: |
| 1628 | InstX8632Pop(Cfg *Func, Variable *Dest); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1629 | ~InstX8632Pop() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1630 | }; |
| 1631 | |
| 1632 | class InstX8632Push : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1633 | InstX8632Push() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1634 | InstX8632Push(const InstX8632Push &) = delete; |
| 1635 | InstX8632Push &operator=(const InstX8632Push &) = delete; |
| 1636 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1637 | public: |
Jan Voung | 0b9eee5 | 2014-10-07 11:20:10 -0700 | [diff] [blame] | 1638 | static InstX8632Push *create(Cfg *Func, Variable *Source) { |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 1639 | return new (Func->allocate<InstX8632Push>()) InstX8632Push(Func, Source); |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1640 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1641 | void emit(const Cfg *Func) const override; |
Jan Voung | 0b9eee5 | 2014-10-07 11:20:10 -0700 | [diff] [blame] | 1642 | void emitIAS(const Cfg *Func) const override; |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1643 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1644 | static bool classof(const Inst *Inst) { return isClassof(Inst, Push); } |
| 1645 | |
| 1646 | private: |
Jan Voung | 0b9eee5 | 2014-10-07 11:20:10 -0700 | [diff] [blame] | 1647 | InstX8632Push(Cfg *Func, Variable *Source); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1648 | ~InstX8632Push() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1649 | }; |
| 1650 | |
| 1651 | // Ret instruction. Currently only supports the "ret" version that |
| 1652 | // does not pop arguments. This instruction takes a Source operand |
| 1653 | // (for non-void returning functions) for liveness analysis, though |
| 1654 | // a FakeUse before the ret would do just as well. |
| 1655 | class InstX8632Ret : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1656 | InstX8632Ret() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1657 | InstX8632Ret(const InstX8632Ret &) = delete; |
| 1658 | InstX8632Ret &operator=(const InstX8632Ret &) = delete; |
| 1659 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1660 | public: |
Jim Stichnoth | ae95320 | 2014-12-20 06:17:49 -0800 | [diff] [blame] | 1661 | static InstX8632Ret *create(Cfg *Func, Variable *Source = nullptr) { |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1662 | return new (Func->allocate<InstX8632Ret>()) InstX8632Ret(Func, Source); |
| 1663 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1664 | void emit(const Cfg *Func) const override; |
| 1665 | void emitIAS(const Cfg *Func) const override; |
| 1666 | void dump(const Cfg *Func) const override; |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1667 | static bool classof(const Inst *Inst) { return isClassof(Inst, Ret); } |
| 1668 | |
| 1669 | private: |
| 1670 | InstX8632Ret(Cfg *Func, Variable *Source); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1671 | ~InstX8632Ret() override {} |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1672 | }; |
| 1673 | |
Jim Stichnoth | f48b320 | 2015-05-04 10:22:17 -0700 | [diff] [blame] | 1674 | // Conditional set-byte instruction. |
| 1675 | class InstX8632Setcc : public InstX8632 { |
| 1676 | InstX8632Setcc() = delete; |
| 1677 | InstX8632Setcc(const InstX8632Cmov &) = delete; |
| 1678 | InstX8632Setcc &operator=(const InstX8632Setcc &) = delete; |
| 1679 | |
| 1680 | public: |
| 1681 | static InstX8632Setcc *create(Cfg *Func, Variable *Dest, |
| 1682 | CondX86::BrCond Cond) { |
| 1683 | return new (Func->allocate<InstX8632Setcc>()) |
| 1684 | InstX8632Setcc(Func, Dest, Cond); |
| 1685 | } |
| 1686 | void emit(const Cfg *Func) const override; |
| 1687 | void emitIAS(const Cfg *Func) const override; |
| 1688 | void dump(const Cfg *Func) const override; |
| 1689 | static bool classof(const Inst *Inst) { return isClassof(Inst, Setcc); } |
| 1690 | |
| 1691 | private: |
| 1692 | InstX8632Setcc(Cfg *Func, Variable *Dest, CondX86::BrCond Cond); |
| 1693 | ~InstX8632Setcc() override {} |
| 1694 | |
| 1695 | const CondX86::BrCond Condition; |
| 1696 | }; |
| 1697 | |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1698 | // Exchanging Add instruction. Exchanges the first operand (destination |
| 1699 | // operand) with the second operand (source operand), then loads the sum |
| 1700 | // of the two values into the destination operand. The destination may be |
| 1701 | // a register or memory, while the source must be a register. |
| 1702 | // |
| 1703 | // Both the dest and source are updated. The caller should then insert a |
| 1704 | // FakeDef to reflect the second udpate. |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1705 | class InstX8632Xadd : public InstX8632Lockable { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1706 | InstX8632Xadd() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1707 | InstX8632Xadd(const InstX8632Xadd &) = delete; |
| 1708 | InstX8632Xadd &operator=(const InstX8632Xadd &) = delete; |
| 1709 | |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1710 | public: |
| 1711 | static InstX8632Xadd *create(Cfg *Func, Operand *Dest, Variable *Source, |
| 1712 | bool Locked) { |
| 1713 | return new (Func->allocate<InstX8632Xadd>()) |
| 1714 | InstX8632Xadd(Func, Dest, Source, Locked); |
| 1715 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1716 | void emit(const Cfg *Func) const override; |
| 1717 | void emitIAS(const Cfg *Func) const override; |
| 1718 | void dump(const Cfg *Func) const override; |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1719 | static bool classof(const Inst *Inst) { return isClassof(Inst, Xadd); } |
| 1720 | |
| 1721 | private: |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1722 | InstX8632Xadd(Cfg *Func, Operand *Dest, Variable *Source, bool Locked); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1723 | ~InstX8632Xadd() override {} |
Jan Voung | 5cd240d | 2014-06-25 10:36:46 -0700 | [diff] [blame] | 1724 | }; |
| 1725 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1726 | // Exchange instruction. Exchanges the first operand (destination |
| 1727 | // operand) with the second operand (source operand). At least one of |
| 1728 | // the operands must be a register (and the other can be reg or mem). |
| 1729 | // Both the Dest and Source are updated. If there is a memory operand, |
| 1730 | // then the instruction is automatically "locked" without the need for |
| 1731 | // a lock prefix. |
| 1732 | class InstX8632Xchg : public InstX8632 { |
Jim Stichnoth | c6ead20 | 2015-02-24 09:30:30 -0800 | [diff] [blame] | 1733 | InstX8632Xchg() = delete; |
Jim Stichnoth | 7b451a9 | 2014-10-15 14:39:23 -0700 | [diff] [blame] | 1734 | InstX8632Xchg(const InstX8632Xchg &) = delete; |
| 1735 | InstX8632Xchg &operator=(const InstX8632Xchg &) = delete; |
| 1736 | |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1737 | public: |
| 1738 | static InstX8632Xchg *create(Cfg *Func, Operand *Dest, Variable *Source) { |
| 1739 | return new (Func->allocate<InstX8632Xchg>()) |
| 1740 | InstX8632Xchg(Func, Dest, Source); |
| 1741 | } |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1742 | void emit(const Cfg *Func) const override; |
| 1743 | void emitIAS(const Cfg *Func) const override; |
| 1744 | void dump(const Cfg *Func) const override; |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1745 | static bool classof(const Inst *Inst) { return isClassof(Inst, Xchg); } |
| 1746 | |
| 1747 | private: |
| 1748 | InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source); |
Jim Stichnoth | b56c8f4 | 2014-09-26 09:28:46 -0700 | [diff] [blame] | 1749 | ~InstX8632Xchg() override {} |
Jan Voung | a3a01a2 | 2014-07-14 10:32:41 -0700 | [diff] [blame] | 1750 | }; |
| 1751 | |
Jim Stichnoth | 6e99214 | 2014-07-30 14:45:20 -0700 | [diff] [blame] | 1752 | // Declare partial template specializations of emit() methods that |
| 1753 | // already have default implementations. Without this, there is the |
| 1754 | // possibility of ODR violations and link errors. |
| 1755 | template <> void InstX8632Addss::emit(const Cfg *Func) const; |
| 1756 | template <> void InstX8632Blendvps::emit(const Cfg *Func) const; |
Matt Wala | 51e8cfb | 2014-08-08 08:39:40 -0700 | [diff] [blame] | 1757 | template <> void InstX8632Cbwdq::emit(const Cfg *Func) const; |
Jim Stichnoth | 6e99214 | 2014-07-30 14:45:20 -0700 | [diff] [blame] | 1758 | template <> void InstX8632Div::emit(const Cfg *Func) const; |
| 1759 | template <> void InstX8632Divss::emit(const Cfg *Func) const; |
| 1760 | template <> void InstX8632Idiv::emit(const Cfg *Func) const; |
| 1761 | template <> void InstX8632Imul::emit(const Cfg *Func) const; |
| 1762 | template <> void InstX8632Lea::emit(const Cfg *Func) const; |
| 1763 | template <> void InstX8632Mulss::emit(const Cfg *Func) const; |
| 1764 | template <> void InstX8632Padd::emit(const Cfg *Func) const; |
| 1765 | template <> void InstX8632Pblendvb::emit(const Cfg *Func) const; |
| 1766 | template <> void InstX8632Pcmpeq::emit(const Cfg *Func) const; |
| 1767 | template <> void InstX8632Pcmpgt::emit(const Cfg *Func) const; |
| 1768 | template <> void InstX8632Pextr::emit(const Cfg *Func) const; |
| 1769 | template <> void InstX8632Pinsr::emit(const Cfg *Func) const; |
| 1770 | template <> void InstX8632Pmull::emit(const Cfg *Func) const; |
| 1771 | template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; |
| 1772 | template <> void InstX8632Psll::emit(const Cfg *Func) const; |
| 1773 | template <> void InstX8632Psra::emit(const Cfg *Func) const; |
Jim Stichnoth | 8c980d0 | 2015-03-19 13:01:50 -0700 | [diff] [blame] | 1774 | template <> void InstX8632Psrl::emit(const Cfg *Func) const; |
Jim Stichnoth | 6e99214 | 2014-07-30 14:45:20 -0700 | [diff] [blame] | 1775 | template <> void InstX8632Psub::emit(const Cfg *Func) const; |
| 1776 | template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; |
| 1777 | template <> void InstX8632Subss::emit(const Cfg *Func) const; |
| 1778 | |
Jan Voung | d026c44 | 2014-10-13 14:06:50 -0700 | [diff] [blame] | 1779 | template <> void InstX8632Blendvps::emitIAS(const Cfg *Func) const; |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1780 | template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const; |
Jan Voung | af2780c | 2014-09-26 11:14:30 -0700 | [diff] [blame] | 1781 | template <> void InstX8632Div::emitIAS(const Cfg *Func) const; |
| 1782 | template <> void InstX8632Idiv::emitIAS(const Cfg *Func) const; |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 1783 | template <> void InstX8632Imul::emitIAS(const Cfg *Func) const; |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1784 | template <> void InstX8632Insertps::emitIAS(const Cfg *Func) const; |
Jan Voung | 3b43b89 | 2014-09-24 13:32:39 -0700 | [diff] [blame] | 1785 | template <> void InstX8632Movd::emitIAS(const Cfg *Func) const; |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 1786 | template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const; |
Jan Voung | d026c44 | 2014-10-13 14:06:50 -0700 | [diff] [blame] | 1787 | template <> void InstX8632Pblendvb::emitIAS(const Cfg *Func) const; |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1788 | template <> void InstX8632Pextr::emitIAS(const Cfg *Func) const; |
| 1789 | template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const; |
Jan Voung | 39d4aca | 2014-10-15 15:16:54 -0700 | [diff] [blame] | 1790 | template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const; |
| 1791 | template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const; |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 1792 | template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const; |
Jan Voung | 962befa | 2014-10-15 09:32:58 -0700 | [diff] [blame] | 1793 | template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const; |
| 1794 | template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const; |
Jan Voung | 03532e5 | 2014-09-23 13:32:18 -0700 | [diff] [blame] | 1795 | |
Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1796 | } // end of namespace Ice |
| 1797 | |
| 1798 | #endif // SUBZERO_SRC_ICEINSTX8632_H |