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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 // Compute the list of spilled variables and bounds for GlobalsSize, etc. | 429 // Compute the list of spilled variables and bounds for GlobalsSize, etc. |
430 getVarStackSlotParams(SortedSpilledVariables, RegsUsed, &GlobalsSize, | 430 getVarStackSlotParams(SortedSpilledVariables, RegsUsed, &GlobalsSize, |
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 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) | |
442 SizeT Canonical = i; | |
440 if (CalleeSaves[i] && RegsUsed[i]) { | 443 if (CalleeSaves[i] && RegsUsed[i]) { |
444 Pushed[Canonical] = true; | |
445 } | |
446 } | |
447 for (SizeT i = 0; i < Pushed.size(); ++i) { | |
448 if (Pushed[i]) { | |
441 ++NumCallee; | 449 ++NumCallee; |
442 PreservedRegsSizeBytes += typeWidthInBytes(IceType_i32); | 450 PreservedRegsSizeBytes += typeWidthInBytes(IceType_i32); |
443 _push(getPhysicalRegister(i)); | 451 _push(getPhysicalRegister(i)); |
444 } | 452 } |
445 } | 453 } |
446 Ctx->statsUpdateRegistersSaved(NumCallee); | 454 Ctx->statsUpdateRegistersSaved(NumCallee); |
447 | 455 |
448 // Generate "push ebp; mov ebp, esp" | 456 // Generate "push ebp; mov ebp, esp" |
449 if (IsEbpBasedFrame) { | 457 if (IsEbpBasedFrame) { |
450 assert((RegsUsed & getRegisterSet(RegSet_FramePointer, RegSet_None)) | 458 assert((RegsUsed & getRegisterSet(RegSet_FramePointer, RegSet_None)) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 _pop(ebp); | 602 _pop(ebp); |
595 } else { | 603 } else { |
596 // add esp, SpillAreaSizeBytes | 604 // add esp, SpillAreaSizeBytes |
597 if (SpillAreaSizeBytes) | 605 if (SpillAreaSizeBytes) |
598 _add(esp, Ctx->getConstantInt32(SpillAreaSizeBytes)); | 606 _add(esp, Ctx->getConstantInt32(SpillAreaSizeBytes)); |
599 } | 607 } |
600 | 608 |
601 // Add pop instructions for preserved registers. | 609 // Add pop instructions for preserved registers. |
602 llvm::SmallBitVector CalleeSaves = | 610 llvm::SmallBitVector CalleeSaves = |
603 getRegisterSet(RegSet_CalleeSave, RegSet_None); | 611 getRegisterSet(RegSet_CalleeSave, RegSet_None); |
612 llvm::SmallBitVector Popped(CalleeSaves.size()); | |
604 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { | 613 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { |
605 SizeT j = CalleeSaves.size() - i - 1; | 614 // SizeT Canonical = RegX8632::getCanonicalReg(i); // TODO(stichnot) |
Karl
2015/10/15 17:05:27
I believe that John ran into this problem (not usi
| |
615 SizeT Canonical = i; | |
616 if (CalleeSaves[i] && RegsUsed[i]) { | |
617 Popped[Canonical] = true; | |
618 } | |
619 } | |
620 for (SizeT i = 0; i < Popped.size(); ++i) { | |
621 SizeT j = Popped.size() - i - 1; | |
606 if (j == Traits::RegisterSet::Reg_ebp && IsEbpBasedFrame) | 622 if (j == Traits::RegisterSet::Reg_ebp && IsEbpBasedFrame) |
607 continue; | 623 continue; |
608 if (CalleeSaves[j] && RegsUsed[j]) { | 624 if (Popped[j]) { |
609 _pop(getPhysicalRegister(j)); | 625 _pop(getPhysicalRegister(j)); |
610 } | 626 } |
611 } | 627 } |
612 | 628 |
613 if (!Ctx->getFlags().getUseSandboxing()) | 629 if (!Ctx->getFlags().getUseSandboxing()) |
614 return; | 630 return; |
615 // Change the original ret instruction into a sandboxed return sequence. | 631 // Change the original ret instruction into a sandboxed return sequence. |
616 // t:ecx = pop | 632 // t:ecx = pop |
617 // bundle_lock | 633 // bundle_lock |
618 // and t, ~31 | 634 // and t, ~31 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 // case the high-level table has extra entries. | 960 // case the high-level table has extra entries. |
945 #define X(tag, sizeLog2, align, elts, elty, str) \ | 961 #define X(tag, sizeLog2, align, elts, elty, str) \ |
946 static_assert(_table1_##tag == _table2_##tag, \ | 962 static_assert(_table1_##tag == _table2_##tag, \ |
947 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); | 963 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); |
948 ICETYPE_TABLE | 964 ICETYPE_TABLE |
949 #undef X | 965 #undef X |
950 } // end of namespace dummy3 | 966 } // end of namespace dummy3 |
951 } // end of anonymous namespace | 967 } // end of anonymous namespace |
952 | 968 |
953 } // end of namespace Ice | 969 } // end of namespace Ice |
OLD | NEW |