| 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 Traits::X86_RET_IP_SIZE_BYTES + PreservedRegsSizeBytes; | 480 Traits::X86_RET_IP_SIZE_BYTES + PreservedRegsSizeBytes; |
| 481 uint32_t StackSize = | 481 uint32_t StackSize = |
| 482 Traits::applyStackAlignment(StackOffset + SpillAreaSizeBytes); | 482 Traits::applyStackAlignment(StackOffset + SpillAreaSizeBytes); |
| 483 SpillAreaSizeBytes = StackSize - StackOffset; | 483 SpillAreaSizeBytes = StackSize - StackOffset; |
| 484 } | 484 } |
| 485 | 485 |
| 486 // Generate "sub esp, SpillAreaSizeBytes" | 486 // Generate "sub esp, SpillAreaSizeBytes" |
| 487 if (SpillAreaSizeBytes) | 487 if (SpillAreaSizeBytes) |
| 488 _sub(getPhysicalRegister(Traits::RegisterSet::Reg_esp), | 488 _sub(getPhysicalRegister(Traits::RegisterSet::Reg_esp), |
| 489 Ctx->getConstantInt32(SpillAreaSizeBytes)); | 489 Ctx->getConstantInt32(SpillAreaSizeBytes)); |
| 490 |
| 491 // Account for alloca instructions with known frame offsets. |
| 492 SpillAreaSizeBytes += FixedAllocaSizeBytes; |
| 493 |
| 490 Ctx->statsUpdateFrameBytes(SpillAreaSizeBytes); | 494 Ctx->statsUpdateFrameBytes(SpillAreaSizeBytes); |
| 491 | 495 |
| 496 // Initialize the stack adjustment so that after all the known-frame-offset |
| 497 // alloca instructions are emitted, the stack adjustment will reach zero. |
| 492 resetStackAdjustment(); | 498 resetStackAdjustment(); |
| 499 updateStackAdjustment(-FixedAllocaSizeBytes); |
| 493 | 500 |
| 494 // Fill in stack offsets for stack args, and copy args into registers for | 501 // Fill in stack offsets for stack args, and copy args into registers for |
| 495 // those that were register-allocated. Args are pushed right to left, so | 502 // those that were register-allocated. Args are pushed right to left, so |
| 496 // Arg[0] is closest to the stack/frame pointer. | 503 // Arg[0] is closest to the stack/frame pointer. |
| 497 Variable *FramePtr = getPhysicalRegister(getFrameOrStackReg()); | 504 Variable *FramePtr = getPhysicalRegister(getFrameOrStackReg()); |
| 498 size_t BasicFrameOffset = | 505 size_t BasicFrameOffset = |
| 499 PreservedRegsSizeBytes + Traits::X86_RET_IP_SIZE_BYTES; | 506 PreservedRegsSizeBytes + Traits::X86_RET_IP_SIZE_BYTES; |
| 500 if (!IsEbpBasedFrame) | 507 if (!IsEbpBasedFrame) |
| 501 BasicFrameOffset += SpillAreaSizeBytes; | 508 BasicFrameOffset += SpillAreaSizeBytes; |
| 502 | 509 |
| 503 const VarList &Args = Func->getArgs(); | 510 const VarList &Args = Func->getArgs(); |
| 504 size_t InArgsSizeBytes = 0; | 511 size_t InArgsSizeBytes = 0; |
| 505 unsigned NumXmmArgs = 0; | 512 unsigned NumXmmArgs = 0; |
| 506 for (Variable *Arg : Args) { | 513 for (Variable *Arg : Args) { |
| 507 // Skip arguments passed in registers. | 514 // Skip arguments passed in registers. |
| 508 if (isVectorType(Arg->getType()) && NumXmmArgs < Traits::X86_MAX_XMM_ARGS) { | 515 if (isVectorType(Arg->getType()) && NumXmmArgs < Traits::X86_MAX_XMM_ARGS) { |
| 509 ++NumXmmArgs; | 516 ++NumXmmArgs; |
| 510 continue; | 517 continue; |
| 511 } | 518 } |
| 512 finishArgumentLowering(Arg, FramePtr, BasicFrameOffset, InArgsSizeBytes); | 519 // For esp-based frames, the esp value may not stabilize to its home value |
| 520 // until after all the fixed-size alloca instructions have executed. In |
| 521 // this case, a stack adjustment is needed when accessing in-args in order |
| 522 // to copy them into registers. |
| 523 size_t StackAdjBytes = IsEbpBasedFrame ? 0 : -FixedAllocaSizeBytes; |
| 524 finishArgumentLowering(Arg, FramePtr, BasicFrameOffset, StackAdjBytes, |
| 525 InArgsSizeBytes); |
| 513 } | 526 } |
| 514 | 527 |
| 515 // Fill in stack offsets for locals. | 528 // Fill in stack offsets for locals. |
| 516 assignVarStackSlots(SortedSpilledVariables, SpillAreaPaddingBytes, | 529 assignVarStackSlots(SortedSpilledVariables, SpillAreaPaddingBytes, |
| 517 SpillAreaSizeBytes, GlobalsAndSubsequentPaddingSize, | 530 SpillAreaSizeBytes, GlobalsAndSubsequentPaddingSize, |
| 518 IsEbpBasedFrame); | 531 IsEbpBasedFrame); |
| 519 // Assign stack offsets to variables that have been linked to spilled | 532 // Assign stack offsets to variables that have been linked to spilled |
| 520 // variables. | 533 // variables. |
| 521 for (Variable *Var : VariablesLinkedToSpillSlots) { | 534 for (Variable *Var : VariablesLinkedToSpillSlots) { |
| 522 Variable *Linked = | 535 Variable *Linked = |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 // case the high-level table has extra entries. | 944 // case the high-level table has extra entries. |
| 932 #define X(tag, sizeLog2, align, elts, elty, str) \ | 945 #define X(tag, sizeLog2, align, elts, elty, str) \ |
| 933 static_assert(_table1_##tag == _table2_##tag, \ | 946 static_assert(_table1_##tag == _table2_##tag, \ |
| 934 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); | 947 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); |
| 935 ICETYPE_TABLE | 948 ICETYPE_TABLE |
| 936 #undef X | 949 #undef X |
| 937 } // end of namespace dummy3 | 950 } // end of namespace dummy3 |
| 938 } // end of anonymous namespace | 951 } // end of anonymous namespace |
| 939 | 952 |
| 940 } // end of namespace Ice | 953 } // end of namespace Ice |
| OLD | NEW |