OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// |
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 /// \file | 10 /// \file |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 &SpillAreaSizeBytes, &SpillAreaAlignmentBytes, | 431 &SpillAreaSizeBytes, &SpillAreaAlignmentBytes, |
432 &LocalsSlotsAlignmentBytes, TargetVarHook); | 432 &LocalsSlotsAlignmentBytes, TargetVarHook); |
433 uint32_t LocalsSpillAreaSize = SpillAreaSizeBytes; | 433 uint32_t LocalsSpillAreaSize = SpillAreaSizeBytes; |
434 SpillAreaSizeBytes += GlobalsSize; | 434 SpillAreaSizeBytes += GlobalsSize; |
435 | 435 |
436 // Add push instructions for preserved registers. | 436 // Add push instructions for preserved registers. |
437 uint32_t NumCallee = 0; | 437 uint32_t NumCallee = 0; |
438 size_t PreservedRegsSizeBytes = 0; | 438 size_t PreservedRegsSizeBytes = 0; |
439 llvm::SmallBitVector Pushed(CalleeSaves.size()); | 439 llvm::SmallBitVector Pushed(CalleeSaves.size()); |
440 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { | 440 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { |
441 // SizeT Canonical = RegX8632::getCanonicalReg(i); // TODO(stichnot) | 441 SizeT Canonical = Traits::getBaseReg(i); |
442 SizeT Canonical = i; | |
443 if (CalleeSaves[i] && RegsUsed[i]) { | 442 if (CalleeSaves[i] && RegsUsed[i]) { |
444 Pushed[Canonical] = true; | 443 Pushed[Canonical] = true; |
445 } | 444 } |
446 } | 445 } |
447 for (SizeT i = 0; i < Pushed.size(); ++i) { | 446 for (SizeT i = 0; i < Pushed.size(); ++i) { |
448 if (Pushed[i]) { | 447 if (Pushed[i]) { |
449 ++NumCallee; | 448 ++NumCallee; |
450 PreservedRegsSizeBytes += typeWidthInBytes(IceType_i32); | 449 PreservedRegsSizeBytes += typeWidthInBytes(IceType_i32); |
451 _push(getPhysicalRegister(i)); | 450 _push(getPhysicalRegister(i)); |
452 } | 451 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // add esp, SpillAreaSizeBytes | 603 // add esp, SpillAreaSizeBytes |
605 if (SpillAreaSizeBytes) | 604 if (SpillAreaSizeBytes) |
606 _add(esp, Ctx->getConstantInt32(SpillAreaSizeBytes)); | 605 _add(esp, Ctx->getConstantInt32(SpillAreaSizeBytes)); |
607 } | 606 } |
608 | 607 |
609 // Add pop instructions for preserved registers. | 608 // Add pop instructions for preserved registers. |
610 llvm::SmallBitVector CalleeSaves = | 609 llvm::SmallBitVector CalleeSaves = |
611 getRegisterSet(RegSet_CalleeSave, RegSet_None); | 610 getRegisterSet(RegSet_CalleeSave, RegSet_None); |
612 llvm::SmallBitVector Popped(CalleeSaves.size()); | 611 llvm::SmallBitVector Popped(CalleeSaves.size()); |
613 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { | 612 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { |
614 // SizeT Canonical = RegX8632::getCanonicalReg(i); // TODO(stichnot) | 613 SizeT Canonical = Traits::getBaseReg(i); |
615 SizeT Canonical = i; | |
616 if (CalleeSaves[i] && RegsUsed[i]) { | 614 if (CalleeSaves[i] && RegsUsed[i]) { |
617 Popped[Canonical] = true; | 615 Popped[Canonical] = true; |
618 } | 616 } |
619 } | 617 } |
620 for (SizeT i = 0; i < Popped.size(); ++i) { | 618 for (SizeT i = 0; i < Popped.size(); ++i) { |
621 SizeT j = Popped.size() - i - 1; | 619 SizeT j = Popped.size() - i - 1; |
| 620 SizeT Canonical = Traits::getBaseReg(j); |
622 if (j == Traits::RegisterSet::Reg_ebp && IsEbpBasedFrame) | 621 if (j == Traits::RegisterSet::Reg_ebp && IsEbpBasedFrame) |
623 continue; | 622 continue; |
624 if (Popped[j]) { | 623 if (Popped[j]) { |
625 _pop(getPhysicalRegister(j)); | 624 _pop(getPhysicalRegister(Canonical)); |
626 } | 625 } |
627 } | 626 } |
628 | 627 |
629 if (!Ctx->getFlags().getUseSandboxing()) | 628 if (!Ctx->getFlags().getUseSandboxing()) |
630 return; | 629 return; |
631 // Change the original ret instruction into a sandboxed return sequence. | 630 // Change the original ret instruction into a sandboxed return sequence. |
632 // t:ecx = pop | 631 // t:ecx = pop |
633 // bundle_lock | 632 // bundle_lock |
634 // and t, ~31 | 633 // and t, ~31 |
635 // jmp *t | 634 // jmp *t |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 // case the high-level table has extra entries. | 959 // case the high-level table has extra entries. |
961 #define X(tag, sizeLog2, align, elts, elty, str) \ | 960 #define X(tag, sizeLog2, align, elts, elty, str) \ |
962 static_assert(_table1_##tag == _table2_##tag, \ | 961 static_assert(_table1_##tag == _table2_##tag, \ |
963 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); | 962 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); |
964 ICETYPE_TABLE | 963 ICETYPE_TABLE |
965 #undef X | 964 #undef X |
966 } // end of namespace dummy3 | 965 } // end of namespace dummy3 |
967 } // end of anonymous namespace | 966 } // end of anonymous namespace |
968 | 967 |
969 } // end of namespace Ice | 968 } // end of namespace Ice |
OLD | NEW |