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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 void makeRandomRegisterPermutation( | 257 void makeRandomRegisterPermutation( |
258 llvm::SmallVectorImpl<int32_t> &Permutation, | 258 llvm::SmallVectorImpl<int32_t> &Permutation, |
259 const llvm::SmallBitVector &ExcludeRegisters) const override; | 259 const llvm::SmallBitVector &ExcludeRegisters) const override; |
260 | 260 |
261 // The following are helpers that insert lowered x86 instructions | 261 // The following are helpers that insert lowered x86 instructions |
262 // with minimal syntactic overhead, so that the lowering code can | 262 // with minimal syntactic overhead, so that the lowering code can |
263 // look as close to assembly as practical. | 263 // look as close to assembly as practical. |
264 void _adc(Variable *Dest, Operand *Src0) { | 264 void _adc(Variable *Dest, Operand *Src0) { |
265 Context.insert(InstX8632Adc::create(Func, Dest, Src0)); | 265 Context.insert(InstX8632Adc::create(Func, Dest, Src0)); |
266 } | 266 } |
| 267 void _adc_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
| 268 Context.insert(InstX8632AdcRMW::create(Func, DestSrc0, Src1)); |
| 269 } |
267 void _add(Variable *Dest, Operand *Src0) { | 270 void _add(Variable *Dest, Operand *Src0) { |
268 Context.insert(InstX8632Add::create(Func, Dest, Src0)); | 271 Context.insert(InstX8632Add::create(Func, Dest, Src0)); |
269 } | 272 } |
270 void _add_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { | 273 void _add_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
271 Context.insert(InstX8632AddRMW::create(Func, DestSrc0, Src1)); | 274 Context.insert(InstX8632AddRMW::create(Func, DestSrc0, Src1)); |
272 } | 275 } |
273 void _adjust_stack(int32_t Amount) { | 276 void _adjust_stack(int32_t Amount) { |
274 Context.insert(InstX8632AdjustStack::create( | 277 Context.insert(InstX8632AdjustStack::create( |
275 Func, Amount, getPhysicalRegister(RegX8632::Reg_esp))); | 278 Func, Amount, getPhysicalRegister(RegX8632::Reg_esp))); |
276 } | 279 } |
277 void _addps(Variable *Dest, Operand *Src0) { | 280 void _addps(Variable *Dest, Operand *Src0) { |
278 Context.insert(InstX8632Addps::create(Func, Dest, Src0)); | 281 Context.insert(InstX8632Addps::create(Func, Dest, Src0)); |
279 } | 282 } |
280 void _addss(Variable *Dest, Operand *Src0) { | 283 void _addss(Variable *Dest, Operand *Src0) { |
281 Context.insert(InstX8632Addss::create(Func, Dest, Src0)); | 284 Context.insert(InstX8632Addss::create(Func, Dest, Src0)); |
282 } | 285 } |
283 void _and(Variable *Dest, Operand *Src0) { | 286 void _and(Variable *Dest, Operand *Src0) { |
284 Context.insert(InstX8632And::create(Func, Dest, Src0)); | 287 Context.insert(InstX8632And::create(Func, Dest, Src0)); |
285 } | 288 } |
| 289 void _and_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
| 290 Context.insert(InstX8632AndRMW::create(Func, DestSrc0, Src1)); |
| 291 } |
286 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) { | 292 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) { |
287 Context.insert(InstX8632Blendvps::create(Func, Dest, Src0, Src1)); | 293 Context.insert(InstX8632Blendvps::create(Func, Dest, Src0, Src1)); |
288 } | 294 } |
289 void _br(CondX86::BrCond Condition, CfgNode *TargetTrue, | 295 void _br(CondX86::BrCond Condition, CfgNode *TargetTrue, |
290 CfgNode *TargetFalse) { | 296 CfgNode *TargetFalse) { |
291 Context.insert( | 297 Context.insert( |
292 InstX8632Br::create(Func, TargetTrue, TargetFalse, Condition)); | 298 InstX8632Br::create(Func, TargetTrue, TargetFalse, Condition)); |
293 } | 299 } |
294 void _br(CfgNode *Target) { | 300 void _br(CfgNode *Target) { |
295 Context.insert(InstX8632Br::create(Func, Target)); | 301 Context.insert(InstX8632Br::create(Func, Target)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 424 } |
419 void _neg(Variable *SrcDest) { | 425 void _neg(Variable *SrcDest) { |
420 Context.insert(InstX8632Neg::create(Func, SrcDest)); | 426 Context.insert(InstX8632Neg::create(Func, SrcDest)); |
421 } | 427 } |
422 void _nop(SizeT Variant) { | 428 void _nop(SizeT Variant) { |
423 Context.insert(InstX8632Nop::create(Func, Variant)); | 429 Context.insert(InstX8632Nop::create(Func, Variant)); |
424 } | 430 } |
425 void _or(Variable *Dest, Operand *Src0) { | 431 void _or(Variable *Dest, Operand *Src0) { |
426 Context.insert(InstX8632Or::create(Func, Dest, Src0)); | 432 Context.insert(InstX8632Or::create(Func, Dest, Src0)); |
427 } | 433 } |
| 434 void _or_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
| 435 Context.insert(InstX8632OrRMW::create(Func, DestSrc0, Src1)); |
| 436 } |
428 void _padd(Variable *Dest, Operand *Src0) { | 437 void _padd(Variable *Dest, Operand *Src0) { |
429 Context.insert(InstX8632Padd::create(Func, Dest, Src0)); | 438 Context.insert(InstX8632Padd::create(Func, Dest, Src0)); |
430 } | 439 } |
431 void _pand(Variable *Dest, Operand *Src0) { | 440 void _pand(Variable *Dest, Operand *Src0) { |
432 Context.insert(InstX8632Pand::create(Func, Dest, Src0)); | 441 Context.insert(InstX8632Pand::create(Func, Dest, Src0)); |
433 } | 442 } |
434 void _pandn(Variable *Dest, Operand *Src0) { | 443 void _pandn(Variable *Dest, Operand *Src0) { |
435 Context.insert(InstX8632Pandn::create(Func, Dest, Src0)); | 444 Context.insert(InstX8632Pandn::create(Func, Dest, Src0)); |
436 } | 445 } |
437 void _pblendvb(Variable *Dest, Operand *Src0, Operand *Src1) { | 446 void _pblendvb(Variable *Dest, Operand *Src0, Operand *Src1) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 } | 496 } |
488 void _rol(Variable *Dest, Operand *Src0) { | 497 void _rol(Variable *Dest, Operand *Src0) { |
489 Context.insert(InstX8632Rol::create(Func, Dest, Src0)); | 498 Context.insert(InstX8632Rol::create(Func, Dest, Src0)); |
490 } | 499 } |
491 void _sar(Variable *Dest, Operand *Src0) { | 500 void _sar(Variable *Dest, Operand *Src0) { |
492 Context.insert(InstX8632Sar::create(Func, Dest, Src0)); | 501 Context.insert(InstX8632Sar::create(Func, Dest, Src0)); |
493 } | 502 } |
494 void _sbb(Variable *Dest, Operand *Src0) { | 503 void _sbb(Variable *Dest, Operand *Src0) { |
495 Context.insert(InstX8632Sbb::create(Func, Dest, Src0)); | 504 Context.insert(InstX8632Sbb::create(Func, Dest, Src0)); |
496 } | 505 } |
| 506 void _sbb_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
| 507 Context.insert(InstX8632SbbRMW::create(Func, DestSrc0, Src1)); |
| 508 } |
497 void _setcc(Variable *Dest, CondX86::BrCond Condition) { | 509 void _setcc(Variable *Dest, CondX86::BrCond Condition) { |
498 Context.insert(InstX8632Setcc::create(Func, Dest, Condition)); | 510 Context.insert(InstX8632Setcc::create(Func, Dest, Condition)); |
499 } | 511 } |
500 void _shl(Variable *Dest, Operand *Src0) { | 512 void _shl(Variable *Dest, Operand *Src0) { |
501 Context.insert(InstX8632Shl::create(Func, Dest, Src0)); | 513 Context.insert(InstX8632Shl::create(Func, Dest, Src0)); |
502 } | 514 } |
503 void _shld(Variable *Dest, Variable *Src0, Variable *Src1) { | 515 void _shld(Variable *Dest, Variable *Src0, Variable *Src1) { |
504 Context.insert(InstX8632Shld::create(Func, Dest, Src0, Src1)); | 516 Context.insert(InstX8632Shld::create(Func, Dest, Src0, Src1)); |
505 } | 517 } |
506 void _shr(Variable *Dest, Operand *Src0) { | 518 void _shr(Variable *Dest, Operand *Src0) { |
(...skipping 13 matching lines...) Expand all Loading... |
520 } | 532 } |
521 void _storep(Variable *Value, OperandX8632Mem *Mem) { | 533 void _storep(Variable *Value, OperandX8632Mem *Mem) { |
522 Context.insert(InstX8632StoreP::create(Func, Value, Mem)); | 534 Context.insert(InstX8632StoreP::create(Func, Value, Mem)); |
523 } | 535 } |
524 void _storeq(Variable *Value, OperandX8632Mem *Mem) { | 536 void _storeq(Variable *Value, OperandX8632Mem *Mem) { |
525 Context.insert(InstX8632StoreQ::create(Func, Value, Mem)); | 537 Context.insert(InstX8632StoreQ::create(Func, Value, Mem)); |
526 } | 538 } |
527 void _sub(Variable *Dest, Operand *Src0) { | 539 void _sub(Variable *Dest, Operand *Src0) { |
528 Context.insert(InstX8632Sub::create(Func, Dest, Src0)); | 540 Context.insert(InstX8632Sub::create(Func, Dest, Src0)); |
529 } | 541 } |
| 542 void _sub_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
| 543 Context.insert(InstX8632SubRMW::create(Func, DestSrc0, Src1)); |
| 544 } |
530 void _subps(Variable *Dest, Operand *Src0) { | 545 void _subps(Variable *Dest, Operand *Src0) { |
531 Context.insert(InstX8632Subps::create(Func, Dest, Src0)); | 546 Context.insert(InstX8632Subps::create(Func, Dest, Src0)); |
532 } | 547 } |
533 void _subss(Variable *Dest, Operand *Src0) { | 548 void _subss(Variable *Dest, Operand *Src0) { |
534 Context.insert(InstX8632Subss::create(Func, Dest, Src0)); | 549 Context.insert(InstX8632Subss::create(Func, Dest, Src0)); |
535 } | 550 } |
536 void _test(Operand *Src0, Operand *Src1) { | 551 void _test(Operand *Src0, Operand *Src1) { |
537 Context.insert(InstX8632Test::create(Func, Src0, Src1)); | 552 Context.insert(InstX8632Test::create(Func, Src0, Src1)); |
538 } | 553 } |
539 void _ucomiss(Operand *Src0, Operand *Src1) { | 554 void _ucomiss(Operand *Src0, Operand *Src1) { |
(...skipping 14 matching lines...) Expand all Loading... |
554 // The xchg modifies Dest and Src -- model that update with a | 569 // The xchg modifies Dest and Src -- model that update with a |
555 // FakeDef/FakeUse. | 570 // FakeDef/FakeUse. |
556 Context.insert( | 571 Context.insert( |
557 InstFakeDef::create(Func, Src, llvm::dyn_cast<Variable>(Dest))); | 572 InstFakeDef::create(Func, Src, llvm::dyn_cast<Variable>(Dest))); |
558 _set_dest_nonkillable(); | 573 _set_dest_nonkillable(); |
559 Context.insert(InstFakeUse::create(Func, Src)); | 574 Context.insert(InstFakeUse::create(Func, Src)); |
560 } | 575 } |
561 void _xor(Variable *Dest, Operand *Src0) { | 576 void _xor(Variable *Dest, Operand *Src0) { |
562 Context.insert(InstX8632Xor::create(Func, Dest, Src0)); | 577 Context.insert(InstX8632Xor::create(Func, Dest, Src0)); |
563 } | 578 } |
| 579 void _xor_rmw(OperandX8632Mem *DestSrc0, Operand *Src1) { |
| 580 Context.insert(InstX8632XorRMW::create(Func, DestSrc0, Src1)); |
| 581 } |
564 void _set_dest_nonkillable() { | 582 void _set_dest_nonkillable() { |
565 Context.getLastInserted()->setDestNonKillable(); | 583 Context.getLastInserted()->setDestNonKillable(); |
566 } | 584 } |
567 | 585 |
568 bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1); | 586 bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1); |
569 void findRMW(); | 587 void findRMW(); |
570 | 588 |
571 X86InstructionSet InstructionSet; | 589 X86InstructionSet InstructionSet; |
572 bool IsEbpBasedFrame; | 590 bool IsEbpBasedFrame; |
573 bool NeedsStackAlignment; | 591 bool NeedsStackAlignment; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 protected: | 636 protected: |
619 explicit TargetHeaderX8632(GlobalContext *Ctx); | 637 explicit TargetHeaderX8632(GlobalContext *Ctx); |
620 | 638 |
621 private: | 639 private: |
622 ~TargetHeaderX8632() = default; | 640 ~TargetHeaderX8632() = default; |
623 }; | 641 }; |
624 | 642 |
625 } // end of namespace Ice | 643 } // end of namespace Ice |
626 | 644 |
627 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H | 645 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H |
OLD | NEW |