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

Side by Side Diff: src/IceTargetLoweringX86BaseImpl.h

Issue 2107073002: Subzero: Merge SpillVariable functionality directly into Variable. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review comments. Created 4 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
« no previous file with comments | « src/IceTargetLoweringX86Base.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/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==//
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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 SpillAreaSizeBytes = 0; 1036 SpillAreaSizeBytes = 0;
1037 // If there is a separate locals area, this specifies the alignment for it. 1037 // If there is a separate locals area, this specifies the alignment for it.
1038 uint32_t LocalsSlotsAlignmentBytes = 0; 1038 uint32_t LocalsSlotsAlignmentBytes = 0;
1039 // The entire spill locations area gets aligned to largest natural alignment 1039 // The entire spill locations area gets aligned to largest natural alignment
1040 // of the variables that have a spill slot. 1040 // of the variables that have a spill slot.
1041 uint32_t SpillAreaAlignmentBytes = 0; 1041 uint32_t SpillAreaAlignmentBytes = 0;
1042 // A spill slot linked to a variable with a stack slot should reuse that 1042 // A spill slot linked to a variable with a stack slot should reuse that
1043 // stack slot. 1043 // stack slot.
1044 std::function<bool(Variable *)> TargetVarHook = 1044 std::function<bool(Variable *)> TargetVarHook =
1045 [&VariablesLinkedToSpillSlots](Variable *Var) { 1045 [&VariablesLinkedToSpillSlots](Variable *Var) {
1046 if (auto *SpillVar = 1046 if (Var->getLinkedTo() != nullptr) {
1047 llvm::dyn_cast<typename Traits::SpillVariable>(Var)) { 1047 // TODO(stichnot): This assert won't necessarily be true in the
1048 // future.
1048 assert(Var->mustNotHaveReg()); 1049 assert(Var->mustNotHaveReg());
1049 if (SpillVar->getLinkedTo() && !SpillVar->getLinkedTo()->hasReg()) { 1050 if (!Var->getLinkedTo()->hasReg()) {
1050 VariablesLinkedToSpillSlots.push_back(Var); 1051 VariablesLinkedToSpillSlots.push_back(Var);
1051 return true; 1052 return true;
1052 } 1053 }
1053 } 1054 }
1054 return false; 1055 return false;
1055 }; 1056 };
1056 1057
1057 // Compute the list of spilled variables and bounds for GlobalsSize, etc. 1058 // Compute the list of spilled variables and bounds for GlobalsSize, etc.
1058 getVarStackSlotParams(SortedSpilledVariables, RegsUsed, &GlobalsSize, 1059 getVarStackSlotParams(SortedSpilledVariables, RegsUsed, &GlobalsSize,
1059 &SpillAreaSizeBytes, &SpillAreaAlignmentBytes, 1060 &SpillAreaSizeBytes, &SpillAreaAlignmentBytes,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 InArgsSizeBytes); 1204 InArgsSizeBytes);
1204 } 1205 }
1205 1206
1206 // Fill in stack offsets for locals. 1207 // Fill in stack offsets for locals.
1207 assignVarStackSlots(SortedSpilledVariables, SpillAreaPaddingBytes, 1208 assignVarStackSlots(SortedSpilledVariables, SpillAreaPaddingBytes,
1208 SpillAreaSizeBytes, GlobalsAndSubsequentPaddingSize, 1209 SpillAreaSizeBytes, GlobalsAndSubsequentPaddingSize,
1209 IsEbpBasedFrame); 1210 IsEbpBasedFrame);
1210 // Assign stack offsets to variables that have been linked to spilled 1211 // Assign stack offsets to variables that have been linked to spilled
1211 // variables. 1212 // variables.
1212 for (Variable *Var : VariablesLinkedToSpillSlots) { 1213 for (Variable *Var : VariablesLinkedToSpillSlots) {
1213 Variable *Linked = 1214 const Variable *Linked = Var->getLinkedTo();
1214 (llvm::cast<typename Traits::SpillVariable>(Var))->getLinkedTo(); 1215 assert(Linked != nullptr);
1215 Var->setStackOffset(Linked->getStackOffset()); 1216 Var->setStackOffset(Linked->getStackOffset());
1216 } 1217 }
1217 this->HasComputedFrame = true; 1218 this->HasComputedFrame = true;
1218 1219
1219 if (BuildDefs::dump() && Func->isVerbose(IceV_Frame)) { 1220 if (BuildDefs::dump() && Func->isVerbose(IceV_Frame)) {
1220 OstreamLocker L(Func->getContext()); 1221 OstreamLocker L(Func->getContext());
1221 Ostream &Str = Func->getContext()->getStrDump(); 1222 Ostream &Str = Func->getContext()->getStrDump();
1222 1223
1223 Str << "Stack layout:\n"; 1224 Str << "Stack layout:\n";
1224 uint32_t EspAdjustmentPaddingSize = 1225 uint32_t EspAdjustmentPaddingSize =
(...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 } else { 3080 } else {
3080 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); 3081 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem);
3081 // a.i64 = bitcast b.f64 ==> 3082 // a.i64 = bitcast b.f64 ==>
3082 // s.f64 = spill b.f64 3083 // s.f64 = spill b.f64
3083 // t_lo.i32 = lo(s.f64) 3084 // t_lo.i32 = lo(s.f64)
3084 // a_lo.i32 = t_lo.i32 3085 // a_lo.i32 = t_lo.i32
3085 // t_hi.i32 = hi(s.f64) 3086 // t_hi.i32 = hi(s.f64)
3086 // a_hi.i32 = t_hi.i32 3087 // a_hi.i32 = t_hi.i32
3087 Operand *SpillLo, *SpillHi; 3088 Operand *SpillLo, *SpillHi;
3088 if (auto *Src0Var = llvm::dyn_cast<Variable>(Src0RM)) { 3089 if (auto *Src0Var = llvm::dyn_cast<Variable>(Src0RM)) {
3089 SpillVariable *SpillVar = 3090 Variable *Spill = Func->makeVariable(IceType_f64);
3090 Func->makeVariable<SpillVariable>(IceType_f64); 3091 Spill->setLinkedTo(Src0Var);
3091 SpillVar->setLinkedTo(Src0Var);
3092 Variable *Spill = SpillVar;
3093 Spill->setMustNotHaveReg(); 3092 Spill->setMustNotHaveReg();
3094 _movq(Spill, Src0RM); 3093 _movq(Spill, Src0RM);
3095 SpillLo = Traits::VariableSplit::create(Func, Spill, 3094 SpillLo = Traits::VariableSplit::create(Func, Spill,
3096 Traits::VariableSplit::Low); 3095 Traits::VariableSplit::Low);
3097 SpillHi = Traits::VariableSplit::create(Func, Spill, 3096 SpillHi = Traits::VariableSplit::create(Func, Spill,
3098 Traits::VariableSplit::High); 3097 Traits::VariableSplit::High);
3099 } else { 3098 } else {
3100 SpillLo = loOperand(Src0RM); 3099 SpillLo = loOperand(Src0RM);
3101 SpillHi = hiOperand(Src0RM); 3100 SpillHi = hiOperand(Src0RM);
3102 } 3101 }
(...skipping 24 matching lines...) Expand all
3127 _movq(Dest, T); 3126 _movq(Dest, T);
3128 break; 3127 break;
3129 } 3128 }
3130 // a.f64 = bitcast b.i64 ==> 3129 // a.f64 = bitcast b.i64 ==>
3131 // t_lo.i32 = b_lo.i32 3130 // t_lo.i32 = b_lo.i32
3132 // FakeDef(s.f64) 3131 // FakeDef(s.f64)
3133 // lo(s.f64) = t_lo.i32 3132 // lo(s.f64) = t_lo.i32
3134 // t_hi.i32 = b_hi.i32 3133 // t_hi.i32 = b_hi.i32
3135 // hi(s.f64) = t_hi.i32 3134 // hi(s.f64) = t_hi.i32
3136 // a.f64 = s.f64 3135 // a.f64 = s.f64
3137 SpillVariable *SpillVar = 3136 Variable *Spill = Func->makeVariable(IceType_f64);
3138 Func->makeVariable<SpillVariable>(IceType_f64); 3137 Spill->setLinkedTo(Dest);
3139 SpillVar->setLinkedTo(Dest);
3140 Variable *Spill = SpillVar;
3141 Spill->setMustNotHaveReg(); 3138 Spill->setMustNotHaveReg();
3142 3139
3143 Variable *T_Lo = nullptr, *T_Hi = nullptr; 3140 Variable *T_Lo = nullptr, *T_Hi = nullptr;
3144 auto *SpillLo = Traits::VariableSplit::create( 3141 auto *SpillLo = Traits::VariableSplit::create(
3145 Func, Spill, Traits::VariableSplit::Low); 3142 Func, Spill, Traits::VariableSplit::Low);
3146 auto *SpillHi = Traits::VariableSplit::create( 3143 auto *SpillHi = Traits::VariableSplit::create(
3147 Func, Spill, Traits::VariableSplit::High); 3144 Func, Spill, Traits::VariableSplit::High);
3148 _mov(T_Lo, loOperand(Src0)); 3145 _mov(T_Lo, loOperand(Src0));
3149 // Technically, the Spill is defined after the _store happens, but 3146 // Technically, the Spill is defined after the _store happens, but
3150 // SpillLo is considered a "use" of Spill so define Spill before it is 3147 // SpillLo is considered a "use" of Spill so define Spill before it is
(...skipping 4884 matching lines...) Expand 10 before | Expand all | Expand 10 after
8035 emitGlobal(*Var, SectionSuffix); 8032 emitGlobal(*Var, SectionSuffix);
8036 } 8033 }
8037 } 8034 }
8038 } break; 8035 } break;
8039 } 8036 }
8040 } 8037 }
8041 } // end of namespace X86NAMESPACE 8038 } // end of namespace X86NAMESPACE
8042 } // end of namespace Ice 8039 } // end of namespace Ice
8043 8040
8044 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H 8041 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX86Base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698