Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 580633002: Subzero: Add rudimentary statistics on generated code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove SpillsPlusFills and calculate as Spills+Fills Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceTranslator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (Arg->hasReg()) { 599 if (Arg->hasReg()) {
600 assert(Ty != IceType_i64); 600 assert(Ty != IceType_i64);
601 OperandX8632Mem *Mem = OperandX8632Mem::create( 601 OperandX8632Mem *Mem = OperandX8632Mem::create(
602 Func, Ty, FramePtr, 602 Func, Ty, FramePtr,
603 Ctx->getConstantInt(IceType_i32, Arg->getStackOffset())); 603 Ctx->getConstantInt(IceType_i32, Arg->getStackOffset()));
604 if (isVectorType(Arg->getType())) { 604 if (isVectorType(Arg->getType())) {
605 _movp(Arg, Mem); 605 _movp(Arg, Mem);
606 } else { 606 } else {
607 _mov(Arg, Mem); 607 _mov(Arg, Mem);
608 } 608 }
609 // This argument-copying instruction uses an explicit
610 // OperandX8632Mem operand instead of a Variable, so its
611 // fill-from-stack operation has to be tracked separately for
612 // statistics.
613 Ctx->statsUpdateFills();
609 } 614 }
610 } 615 }
611 616
612 Type TargetX8632::stackSlotType() { return IceType_i32; } 617 Type TargetX8632::stackSlotType() { return IceType_i32; }
613 618
614 void TargetX8632::addProlog(CfgNode *Node) { 619 void TargetX8632::addProlog(CfgNode *Node) {
615 // Stack frame layout: 620 // Stack frame layout:
616 // 621 //
617 // +------------------------+ 622 // +------------------------+
618 // | 1. return address | 623 // | 1. return address |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 744 }
740 } else { 745 } else {
741 SpillAreaSizeBytes += Increment; 746 SpillAreaSizeBytes += Increment;
742 } 747 }
743 } 748 }
744 uint32_t LocalsSpillAreaSize = SpillAreaSizeBytes; 749 uint32_t LocalsSpillAreaSize = SpillAreaSizeBytes;
745 750
746 SpillAreaSizeBytes += GlobalsSize; 751 SpillAreaSizeBytes += GlobalsSize;
747 752
748 // Add push instructions for preserved registers. 753 // Add push instructions for preserved registers.
754 uint32_t NumCallee = 0;
749 for (SizeT i = 0; i < CalleeSaves.size(); ++i) { 755 for (SizeT i = 0; i < CalleeSaves.size(); ++i) {
750 if (CalleeSaves[i] && RegsUsed[i]) { 756 if (CalleeSaves[i] && RegsUsed[i]) {
757 ++NumCallee;
751 PreservedRegsSizeBytes += 4; 758 PreservedRegsSizeBytes += 4;
752 const bool SuppressStackAdjustment = true; 759 const bool SuppressStackAdjustment = true;
753 _push(getPhysicalRegister(i), SuppressStackAdjustment); 760 _push(getPhysicalRegister(i), SuppressStackAdjustment);
754 } 761 }
755 } 762 }
763 Ctx->statsUpdateRegistersSaved(NumCallee);
756 764
757 // Generate "push ebp; mov ebp, esp" 765 // Generate "push ebp; mov ebp, esp"
758 if (IsEbpBasedFrame) { 766 if (IsEbpBasedFrame) {
759 assert((RegsUsed & getRegisterSet(RegSet_FramePointer, RegSet_None)) 767 assert((RegsUsed & getRegisterSet(RegSet_FramePointer, RegSet_None))
760 .count() == 0); 768 .count() == 0);
761 PreservedRegsSizeBytes += 4; 769 PreservedRegsSizeBytes += 4;
762 Variable *ebp = getPhysicalRegister(Reg_ebp); 770 Variable *ebp = getPhysicalRegister(Reg_ebp);
763 Variable *esp = getPhysicalRegister(Reg_esp); 771 Variable *esp = getPhysicalRegister(Reg_esp);
764 const bool SuppressStackAdjustment = true; 772 const bool SuppressStackAdjustment = true;
765 _push(ebp, SuppressStackAdjustment); 773 _push(ebp, SuppressStackAdjustment);
(...skipping 27 matching lines...) Expand all
793 if (NeedsStackAlignment) { 801 if (NeedsStackAlignment) {
794 uint32_t StackOffset = X86_RET_IP_SIZE_BYTES + PreservedRegsSizeBytes; 802 uint32_t StackOffset = X86_RET_IP_SIZE_BYTES + PreservedRegsSizeBytes;
795 uint32_t StackSize = applyStackAlignment(StackOffset + SpillAreaSizeBytes); 803 uint32_t StackSize = applyStackAlignment(StackOffset + SpillAreaSizeBytes);
796 SpillAreaSizeBytes = StackSize - StackOffset; 804 SpillAreaSizeBytes = StackSize - StackOffset;
797 } 805 }
798 806
799 // Generate "sub esp, SpillAreaSizeBytes" 807 // Generate "sub esp, SpillAreaSizeBytes"
800 if (SpillAreaSizeBytes) 808 if (SpillAreaSizeBytes)
801 _sub(getPhysicalRegister(Reg_esp), 809 _sub(getPhysicalRegister(Reg_esp),
802 Ctx->getConstantInt(IceType_i32, SpillAreaSizeBytes)); 810 Ctx->getConstantInt(IceType_i32, SpillAreaSizeBytes));
811 Ctx->statsUpdateFrameBytes(SpillAreaSizeBytes);
803 812
804 resetStackAdjustment(); 813 resetStackAdjustment();
805 814
806 // Fill in stack offsets for stack args, and copy args into registers 815 // Fill in stack offsets for stack args, and copy args into registers
807 // for those that were register-allocated. Args are pushed right to 816 // for those that were register-allocated. Args are pushed right to
808 // left, so Arg[0] is closest to the stack/frame pointer. 817 // left, so Arg[0] is closest to the stack/frame pointer.
809 Variable *FramePtr = getPhysicalRegister(getFrameOrStackReg()); 818 Variable *FramePtr = getPhysicalRegister(getFrameOrStackReg());
810 size_t BasicFrameOffset = PreservedRegsSizeBytes + X86_RET_IP_SIZE_BYTES; 819 size_t BasicFrameOffset = PreservedRegsSizeBytes + X86_RET_IP_SIZE_BYTES;
811 if (!IsEbpBasedFrame) 820 if (!IsEbpBasedFrame)
812 BasicFrameOffset += SpillAreaSizeBytes; 821 BasicFrameOffset += SpillAreaSizeBytes;
(...skipping 3700 matching lines...) Expand 10 before | Expand all | Expand 10 after
4513 Str << "\t.align\t" << Align << "\n"; 4522 Str << "\t.align\t" << Align << "\n";
4514 Str << MangledName << ":\n"; 4523 Str << MangledName << ":\n";
4515 for (SizeT i = 0; i < Size; ++i) { 4524 for (SizeT i = 0; i < Size; ++i) {
4516 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 4525 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
4517 } 4526 }
4518 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4527 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4519 } 4528 }
4520 } 4529 }
4521 4530
4522 } // end of namespace Ice 4531 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698