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

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 385133006: Various improvements related to legalization code. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 5 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
« src/IceTargetLoweringX8632.h ('K') | « src/IceTargetLoweringX8632.h ('k') | no next file » | 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 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 Variable *Dest = NULL; 2569 Variable *Dest = NULL;
2570 InstCall *Call = makeHelperCall("ice_unreachable", Dest, MaxSrcs); 2570 InstCall *Call = makeHelperCall("ice_unreachable", Dest, MaxSrcs);
2571 lowerCall(Call); 2571 lowerCall(Call);
2572 } 2572 }
2573 2573
2574 // Helper for legalize() to emit the right code to lower an operand to a 2574 // Helper for legalize() to emit the right code to lower an operand to a
2575 // register of the appropriate type. 2575 // register of the appropriate type.
2576 Variable *TargetX8632::copyToReg(Operand *Src, int32_t RegNum) { 2576 Variable *TargetX8632::copyToReg(Operand *Src, int32_t RegNum) {
2577 Type Ty = Src->getType(); 2577 Type Ty = Src->getType();
2578 Variable *Reg = makeReg(Ty, RegNum); 2578 Variable *Reg = makeReg(Ty, RegNum);
2579 if (isVectorType(Src->getType())) { 2579 if (isVectorType(Ty)) {
2580 _movp(Reg, Src); 2580 _movp(Reg, Src);
2581 } else { 2581 } else {
2582 _mov(Reg, Src); 2582 _mov(Reg, Src);
2583 } 2583 }
2584 return Reg; 2584 return Reg;
2585 } 2585 }
2586 2586
2587 Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed, 2587 Operand *TargetX8632::legalize(Operand *From, LegalMask Allowed,
2588 bool AllowOverlap, int32_t RegNum) { 2588 bool AllowOverlap, int32_t RegNum) {
2589 // Assert that a physical register is allowed. To date, all calls 2589 // Assert that a physical register is allowed. To date, all calls
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 Variable *Reg = makeReg(From->getType(), RegNum); 2640 Variable *Reg = makeReg(From->getType(), RegNum);
2641 // Insert a FakeDef, since otherwise the live range of Reg might 2641 // Insert a FakeDef, since otherwise the live range of Reg might
2642 // be overestimated. 2642 // be overestimated.
2643 Context.insert(InstFakeDef::create(Func, Reg)); 2643 Context.insert(InstFakeDef::create(Func, Reg));
2644 _pxor(Reg, Reg); 2644 _pxor(Reg, Reg);
2645 return Reg; 2645 return Reg;
2646 } else { 2646 } else {
2647 From = Ctx->getConstantZero(From->getType()); 2647 From = Ctx->getConstantZero(From->getType());
2648 } 2648 }
2649 } 2649 }
2650 // There should be no constants of vector type (other than undef).
2651 assert(!isVectorType(From->getType()));
2650 bool NeedsReg = false; 2652 bool NeedsReg = false;
2651 if (!(Allowed & Legal_Imm)) 2653 if (!(Allowed & Legal_Imm))
2652 // Immediate specifically not allowed 2654 // Immediate specifically not allowed
2653 NeedsReg = true; 2655 NeedsReg = true;
2654 // TODO(stichnot): LEAHACK: remove Legal_Reloc once a proper 2656 // TODO(stichnot): LEAHACK: remove Legal_Reloc once a proper
2655 // emitter is used. 2657 // emitter is used.
2656 if (!(Allowed & Legal_Reloc) && llvm::isa<ConstantRelocatable>(From)) 2658 if (!(Allowed & Legal_Reloc) && llvm::isa<ConstantRelocatable>(From))
2657 // Relocatable specifically not allowed 2659 // Relocatable specifically not allowed
2658 NeedsReg = true; 2660 NeedsReg = true;
2659 if (!(Allowed & Legal_Mem) && 2661 if (!(Allowed & Legal_Mem) &&
2660 (From->getType() == IceType_f32 || From->getType() == IceType_f64)) 2662 (From->getType() == IceType_f32 || From->getType() == IceType_f64))
2661 // On x86, FP constants are lowered to mem operands. 2663 // On x86, FP constants are lowered to mem operands.
2662 NeedsReg = true; 2664 NeedsReg = true;
2663 if (NeedsReg) { 2665 if (NeedsReg) {
2664 From = copyToReg(From, RegNum); 2666 From = copyToReg(From, RegNum);
2665 } 2667 }
2666 return From; 2668 return From;
2667 } 2669 }
2668 if (Variable *Var = llvm::dyn_cast<Variable>(From)) { 2670 if (Variable *Var = llvm::dyn_cast<Variable>(From)) {
2669 // We need a new physical register for the operand if: 2671 // We need a new physical register for the operand if:
2670 // Mem is not allowed and Var isn't guaranteed a physical 2672 // Mem is not allowed and Var isn't guaranteed a physical
2671 // register, or 2673 // register, or
2672 // RegNum is required and Var->getRegNum() doesn't match. 2674 // RegNum is required and Var->getRegNum() doesn't match.
2673 bool WillHaveRegister = 2675 bool AlreadyInRegister =
Jim Stichnoth 2014/07/14 19:44:17 To me, WillHaveRegister captures the situation whe
wala 2014/07/14 20:40:03 How about MustHaveRegister? For me, WillHaveRegis
2674 (Var->hasReg() || Var->getWeight() == RegWeight::Inf); 2676 (Var->hasReg() || Var->getWeight() == RegWeight::Inf);
2675 if ((!(Allowed & Legal_Mem) && !WillHaveRegister) || 2677 if ((!(Allowed & Legal_Mem) && !AlreadyInRegister) ||
2676 (RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) { 2678 (RegNum != Variable::NoRegister && RegNum != Var->getRegNum())) {
2677 Variable *Reg = copyToReg(From, RegNum); 2679 Variable *Reg = copyToReg(From, RegNum);
2678 if (RegNum == Variable::NoRegister) { 2680 if (RegNum == Variable::NoRegister) {
2679 Reg->setPreferredRegister(Var, AllowOverlap); 2681 Reg->setPreferredRegister(Var, AllowOverlap);
2680 } 2682 }
2681 From = Reg; 2683 From = Reg;
2682 } 2684 }
2683 return From; 2685 return From;
2684 } 2686 }
2685 llvm_unreachable("Unhandled operand kind in legalize()"); 2687 llvm_unreachable("Unhandled operand kind in legalize()");
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 for (SizeT i = 0; i < Size; ++i) { 2892 for (SizeT i = 0; i < Size; ++i) {
2891 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; 2893 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n";
2892 } 2894 }
2893 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 2895 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
2894 } 2896 }
2895 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName 2897 Str << "\t" << (IsInternal ? ".local" : ".global") << "\t" << MangledName
2896 << "\n"; 2898 << "\n";
2897 } 2899 }
2898 2900
2899 } // end of namespace Ice 2901 } // end of namespace Ice
OLDNEW
« src/IceTargetLoweringX8632.h ('K') | « src/IceTargetLoweringX8632.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698