OLD | NEW |
---|---|
1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===// | 1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file declares the TargetLoweringX8632 class, which | 10 // This file declares the TargetLoweringX8632 class, which |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 virtual void lowerLoad(const InstLoad *Inst); | 87 virtual void lowerLoad(const InstLoad *Inst); |
88 virtual void lowerPhi(const InstPhi *Inst); | 88 virtual void lowerPhi(const InstPhi *Inst); |
89 virtual void lowerRet(const InstRet *Inst); | 89 virtual void lowerRet(const InstRet *Inst); |
90 virtual void lowerSelect(const InstSelect *Inst); | 90 virtual void lowerSelect(const InstSelect *Inst); |
91 virtual void lowerStore(const InstStore *Inst); | 91 virtual void lowerStore(const InstStore *Inst); |
92 virtual void lowerSwitch(const InstSwitch *Inst); | 92 virtual void lowerSwitch(const InstSwitch *Inst); |
93 virtual void lowerUnreachable(const InstUnreachable *Inst); | 93 virtual void lowerUnreachable(const InstUnreachable *Inst); |
94 virtual void doAddressOptLoad(); | 94 virtual void doAddressOptLoad(); |
95 virtual void doAddressOptStore(); | 95 virtual void doAddressOptStore(); |
96 | 96 |
97 void lowerAtomicCmpxchg(Variable *DestPrev, Operand *Ptr, Operand *Expected, | |
98 Operand *Desired); | |
97 void lowerAtomicRMW(Variable *Dest, uint32_t Operation, Operand *Ptr, | 99 void lowerAtomicRMW(Variable *Dest, uint32_t Operation, Operand *Ptr, |
98 Operand *Val); | 100 Operand *Val); |
99 | 101 |
102 typedef void (TargetX8632::*LowerBinOp)(Variable *, Operand *); | |
103 void expandAtomicRMWAsCmpxchg(LowerBinOp op_lo, LowerBinOp op_hi, | |
104 Variable *Dest, Operand *Ptr, Operand *Val); | |
105 | |
100 // Operand legalization helpers. To deal with address mode | 106 // Operand legalization helpers. To deal with address mode |
101 // constraints, the helpers will create a new Operand and emit | 107 // constraints, the helpers will create a new Operand and emit |
102 // instructions that guarantee that the Operand kind is one of those | 108 // instructions that guarantee that the Operand kind is one of those |
103 // indicated by the LegalMask (a bitmask of allowed kinds). If the | 109 // indicated by the LegalMask (a bitmask of allowed kinds). If the |
104 // input Operand is known to already meet the constraints, it may be | 110 // input Operand is known to already meet the constraints, it may be |
105 // simply returned as the result, without creating any new | 111 // simply returned as the result, without creating any new |
106 // instructions or operands. | 112 // instructions or operands. |
107 enum OperandLegalization { | 113 enum OperandLegalization { |
108 Legal_None = 0, | 114 Legal_None = 0, |
109 Legal_Reg = 1 << 0, // physical register, not stack location | 115 Legal_Reg = 1 << 0, // physical register, not stack location |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 } | 170 } |
165 void _br(InstX8632Br::BrCond Condition, InstX8632Label *Label) { | 171 void _br(InstX8632Br::BrCond Condition, InstX8632Label *Label) { |
166 Context.insert(InstX8632Br::create(Func, Label, Condition)); | 172 Context.insert(InstX8632Br::create(Func, Label, Condition)); |
167 } | 173 } |
168 void _cdq(Variable *Dest, Operand *Src0) { | 174 void _cdq(Variable *Dest, Operand *Src0) { |
169 Context.insert(InstX8632Cdq::create(Func, Dest, Src0)); | 175 Context.insert(InstX8632Cdq::create(Func, Dest, Src0)); |
170 } | 176 } |
171 void _cmp(Operand *Src0, Operand *Src1) { | 177 void _cmp(Operand *Src0, Operand *Src1) { |
172 Context.insert(InstX8632Icmp::create(Func, Src0, Src1)); | 178 Context.insert(InstX8632Icmp::create(Func, Src0, Src1)); |
173 } | 179 } |
180 void _cmpxchg(Operand *DestOrAddr, Variable *Eax, Variable *Desired, | |
Jim Stichnoth
2014/07/08 04:50:19
This is probably not worth doing now, but in the f
jvoung (off chromium)
2014/07/08 18:14:07
Yes that would be pretty sweet syntax.
The issue
jvoung (off chromium)
2014/07/09 17:07:56
As we discussed, I'll leave this alone for now. Th
Jim Stichnoth
2014/07/09 18:14:28
Yeah, I wouldn't like a separate lock instruction
| |
181 bool Locked) { | |
182 Context.insert( | |
183 InstX8632Cmpxchg::create(Func, DestOrAddr, Eax, Desired, Locked)); | |
184 // Mark eax as possibly modified by cmpxchg. | |
185 Context.insert(InstFakeDef::create(Func, Eax)); | |
186 } | |
187 void _cmpxchg8b(OperandX8632 *Addr, Variable *Edx, Variable *Eax, | |
188 Variable *Ecx, Variable *Ebx, bool Locked) { | |
189 Context.insert( | |
190 InstX8632Cmpxchg8b::create(Func, Addr, Edx, Eax, Ecx, Ebx, Locked)); | |
191 // Mark edx, and eax as possibly modified by cmpxchg8b. | |
192 Context.insert(InstFakeDef::create(Func, Edx)); | |
193 Context.insert(InstFakeDef::create(Func, Eax)); | |
194 } | |
174 void _cvt(Variable *Dest, Operand *Src0) { | 195 void _cvt(Variable *Dest, Operand *Src0) { |
175 Context.insert(InstX8632Cvt::create(Func, Dest, Src0)); | 196 Context.insert(InstX8632Cvt::create(Func, Dest, Src0)); |
176 } | 197 } |
177 void _div(Variable *Dest, Operand *Src0, Operand *Src1) { | 198 void _div(Variable *Dest, Operand *Src0, Operand *Src1) { |
178 Context.insert(InstX8632Div::create(Func, Dest, Src0, Src1)); | 199 Context.insert(InstX8632Div::create(Func, Dest, Src0, Src1)); |
179 } | 200 } |
180 void _divss(Variable *Dest, Operand *Src0) { | 201 void _divss(Variable *Dest, Operand *Src0) { |
181 Context.insert(InstX8632Divss::create(Func, Dest, Src0)); | 202 Context.insert(InstX8632Divss::create(Func, Dest, Src0)); |
182 } | 203 } |
183 void _fld(Operand *Src0) { Context.insert(InstX8632Fld::create(Func, Src0)); } | 204 void _fld(Operand *Src0) { Context.insert(InstX8632Fld::create(Func, Src0)); } |
(...skipping 26 matching lines...) Expand all Loading... | |
210 } | 231 } |
211 void _movzx(Variable *Dest, Operand *Src0) { | 232 void _movzx(Variable *Dest, Operand *Src0) { |
212 Context.insert(InstX8632Movzx::create(Func, Dest, Src0)); | 233 Context.insert(InstX8632Movzx::create(Func, Dest, Src0)); |
213 } | 234 } |
214 void _mul(Variable *Dest, Variable *Src0, Operand *Src1) { | 235 void _mul(Variable *Dest, Variable *Src0, Operand *Src1) { |
215 Context.insert(InstX8632Mul::create(Func, Dest, Src0, Src1)); | 236 Context.insert(InstX8632Mul::create(Func, Dest, Src0, Src1)); |
216 } | 237 } |
217 void _mulss(Variable *Dest, Operand *Src0) { | 238 void _mulss(Variable *Dest, Operand *Src0) { |
218 Context.insert(InstX8632Mulss::create(Func, Dest, Src0)); | 239 Context.insert(InstX8632Mulss::create(Func, Dest, Src0)); |
219 } | 240 } |
241 void _neg(Variable *SrcDest) { | |
242 Context.insert(InstX8632Neg::create(Func, SrcDest)); | |
243 } | |
220 void _or(Variable *Dest, Operand *Src0) { | 244 void _or(Variable *Dest, Operand *Src0) { |
221 Context.insert(InstX8632Or::create(Func, Dest, Src0)); | 245 Context.insert(InstX8632Or::create(Func, Dest, Src0)); |
222 } | 246 } |
223 void _pop(Variable *Dest) { | 247 void _pop(Variable *Dest) { |
224 Context.insert(InstX8632Pop::create(Func, Dest)); | 248 Context.insert(InstX8632Pop::create(Func, Dest)); |
225 } | 249 } |
226 void _push(Operand *Src0, bool SuppressStackAdjustment = false) { | 250 void _push(Operand *Src0, bool SuppressStackAdjustment = false) { |
227 Context.insert(InstX8632Push::create(Func, Src0, SuppressStackAdjustment)); | 251 Context.insert(InstX8632Push::create(Func, Src0, SuppressStackAdjustment)); |
228 } | 252 } |
229 void _ret(Variable *Src0 = NULL) { | 253 void _ret(Variable *Src0 = NULL) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 void _ucomiss(Operand *Src0, Operand *Src1) { | 289 void _ucomiss(Operand *Src0, Operand *Src1) { |
266 Context.insert(InstX8632Ucomiss::create(Func, Src0, Src1)); | 290 Context.insert(InstX8632Ucomiss::create(Func, Src0, Src1)); |
267 } | 291 } |
268 void _ud2() { Context.insert(InstX8632UD2::create(Func)); } | 292 void _ud2() { Context.insert(InstX8632UD2::create(Func)); } |
269 void _xadd(Operand *Dest, Variable *Src, bool Locked) { | 293 void _xadd(Operand *Dest, Variable *Src, bool Locked) { |
270 Context.insert(InstX8632Xadd::create(Func, Dest, Src, Locked)); | 294 Context.insert(InstX8632Xadd::create(Func, Dest, Src, Locked)); |
271 // The xadd exchanges Dest and Src (modifying Src). | 295 // The xadd exchanges Dest and Src (modifying Src). |
272 // Model that update with a FakeDef. | 296 // Model that update with a FakeDef. |
273 Context.insert(InstFakeDef::create(Func, Src)); | 297 Context.insert(InstFakeDef::create(Func, Src)); |
274 } | 298 } |
299 void _xchg(Operand *Dest, Variable *Src) { | |
300 Context.insert(InstX8632Xchg::create(Func, Dest, Src)); | |
301 // The xchg modifies Dest and Src -- model that update with a FakeDef. | |
302 Context.insert(InstFakeDef::create(Func, Src)); | |
Jim Stichnoth
2014/07/08 04:50:19
If (as suggested earlier) Dest becomes a Variable
| |
303 } | |
275 void _xor(Variable *Dest, Operand *Src0) { | 304 void _xor(Variable *Dest, Operand *Src0) { |
276 Context.insert(InstX8632Xor::create(Func, Dest, Src0)); | 305 Context.insert(InstX8632Xor::create(Func, Dest, Src0)); |
277 } | 306 } |
278 | 307 |
279 bool IsEbpBasedFrame; | 308 bool IsEbpBasedFrame; |
280 size_t FrameSizeLocals; | 309 size_t FrameSizeLocals; |
281 size_t LocalsSizeBytes; | 310 size_t LocalsSizeBytes; |
282 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; | 311 llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; |
283 llvm::SmallBitVector ScratchRegs; | 312 llvm::SmallBitVector ScratchRegs; |
284 llvm::SmallBitVector RegsUsed; | 313 llvm::SmallBitVector RegsUsed; |
(...skipping 27 matching lines...) Expand all Loading... | |
312 operator=(const TargetGlobalInitX8632 &) LLVM_DELETED_FUNCTION; | 341 operator=(const TargetGlobalInitX8632 &) LLVM_DELETED_FUNCTION; |
313 virtual ~TargetGlobalInitX8632() {} | 342 virtual ~TargetGlobalInitX8632() {} |
314 }; | 343 }; |
315 | 344 |
316 template <> void ConstantFloat::emit(GlobalContext *Ctx) const; | 345 template <> void ConstantFloat::emit(GlobalContext *Ctx) const; |
317 template <> void ConstantDouble::emit(GlobalContext *Ctx) const; | 346 template <> void ConstantDouble::emit(GlobalContext *Ctx) const; |
318 | 347 |
319 } // end of namespace Ice | 348 } // end of namespace Ice |
320 | 349 |
321 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H | 350 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
OLD | NEW |