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

Side by Side Diff: src/IceInstX8632.cpp

Issue 1472623002: Unify alloca, outgoing arg, and prolog construction (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review fixes. Also removed StackAdjustment. Created 5 years 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/IceInstARM32.cpp ('k') | src/IceInstX8664.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/IceInstX8632.cpp - X86-32 instruction implementation ---===// 1 //===- subzero/src/IceInstX8632.cpp - X86-32 instruction implementation ---===//
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 SizeT I = 0; 92 SizeT I = 0;
93 if (Base) 93 if (Base)
94 Vars[I++] = Base; 94 Vars[I++] = Base;
95 if (Index) 95 if (Index)
96 Vars[I++] = Index; 96 Vars[I++] = Index;
97 assert(I == NumVars); 97 assert(I == NumVars);
98 } 98 }
99 } 99 }
100 100
101 namespace { 101 namespace {
102 static int32_t GetRematerializableOffset(Variable *Var, bool IgnoreStackAdjust, 102 static int32_t GetRematerializableOffset(Variable *Var,
103 const Ice::TargetX8632 *Target) { 103 const Ice::TargetX8632 *Target) {
104 int32_t Disp = 0; 104 int32_t Disp = Var->getStackOffset();
105 Disp += Var->getStackOffset();
106 SizeT RegNum = static_cast<SizeT>(Var->getRegNum()); 105 SizeT RegNum = static_cast<SizeT>(Var->getRegNum());
107 if (RegNum == Target->getStackReg()) { 106 if (RegNum == Target->getFrameReg()) {
108 if (!IgnoreStackAdjust)
109 Disp += Target->getStackAdjustment();
110 } else if (RegNum == Target->getFrameReg()) {
111 Disp += Target->getFrameFixedAllocaOffset(); 107 Disp += Target->getFrameFixedAllocaOffset();
112 } else { 108 } else if (RegNum != Target->getStackReg()) {
113 llvm::report_fatal_error("Unexpected rematerializable register type"); 109 llvm::report_fatal_error("Unexpected rematerializable register type");
114 } 110 }
115 return Disp; 111 return Disp;
116 } 112 }
117 } // end of anonymous namespace 113 } // end of anonymous namespace
118 114
119 void MachineTraits<TargetX8632>::X86OperandMem::emit(const Cfg *Func) const { 115 void MachineTraits<TargetX8632>::X86OperandMem::emit(const Cfg *Func) const {
120 if (!BuildDefs::dump()) 116 if (!BuildDefs::dump())
121 return; 117 return;
122 const auto *Target = static_cast<const Ice::TargetX8632 *>(Func->getTarget()); 118 const auto *Target = static_cast<const Ice::TargetX8632 *>(Func->getTarget());
123 // If the base is rematerializable, we need to replace it with the correct 119 // If the base is rematerializable, we need to replace it with the correct
124 // physical register (esp or ebp), and update the Offset. 120 // physical register (esp or ebp), and update the Offset.
125 int32_t Disp = 0; 121 int32_t Disp = 0;
126 if (getBase() && getBase()->isRematerializable()) { 122 if (getBase() && getBase()->isRematerializable()) {
127 Disp += 123 Disp += GetRematerializableOffset(getBase(), Target);
128 GetRematerializableOffset(getBase(), getIgnoreStackAdjust(), Target);
129 } 124 }
130 // The index should never be rematerializable. But if we ever allow it, then 125 // The index should never be rematerializable. But if we ever allow it, then
131 // we should make sure the rematerialization offset is shifted by the Shift 126 // we should make sure the rematerialization offset is shifted by the Shift
132 // value. 127 // value.
133 if (getIndex()) 128 if (getIndex())
134 assert(!getIndex()->isRematerializable()); 129 assert(!getIndex()->isRematerializable());
135 Ostream &Str = Func->getContext()->getStrEmit(); 130 Ostream &Str = Func->getContext()->getStrEmit();
136 if (SegmentReg != DefaultSegment) { 131 if (SegmentReg != DefaultSegment) {
137 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); 132 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
138 Str << "%" << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":"; 133 Str << "%" << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":";
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return; 172 return;
178 if (SegmentReg != DefaultSegment) { 173 if (SegmentReg != DefaultSegment) {
179 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); 174 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
180 Str << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":"; 175 Str << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":";
181 } 176 }
182 bool Dumped = false; 177 bool Dumped = false;
183 Str << "["; 178 Str << "[";
184 int32_t Disp = 0; 179 int32_t Disp = 0;
185 const auto *Target = static_cast<const Ice::TargetX8632 *>(Func->getTarget()); 180 const auto *Target = static_cast<const Ice::TargetX8632 *>(Func->getTarget());
186 if (getBase() && getBase()->isRematerializable()) { 181 if (getBase() && getBase()->isRematerializable()) {
187 Disp += 182 Disp += GetRematerializableOffset(getBase(), Target);
188 GetRematerializableOffset(getBase(), getIgnoreStackAdjust(), Target);
189 } 183 }
190 if (getBase()) { 184 if (getBase()) {
191 if (Func) 185 if (Func)
192 getBase()->dump(Func); 186 getBase()->dump(Func);
193 else 187 else
194 getBase()->dump(Str); 188 getBase()->dump(Str);
195 Dumped = true; 189 Dumped = true;
196 } 190 }
197 if (getIndex()) { 191 if (getIndex()) {
198 assert(!getIndex()->isRematerializable()); 192 assert(!getIndex()->isRematerializable());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 238 }
245 } 239 }
246 240
247 MachineTraits<TargetX8632>::Address 241 MachineTraits<TargetX8632>::Address
248 MachineTraits<TargetX8632>::X86OperandMem::toAsmAddress( 242 MachineTraits<TargetX8632>::X86OperandMem::toAsmAddress(
249 MachineTraits<TargetX8632>::Assembler *Asm, 243 MachineTraits<TargetX8632>::Assembler *Asm,
250 const Ice::TargetLowering *TargetLowering) const { 244 const Ice::TargetLowering *TargetLowering) const {
251 int32_t Disp = 0; 245 int32_t Disp = 0;
252 const auto *Target = static_cast<const Ice::TargetX8632 *>(TargetLowering); 246 const auto *Target = static_cast<const Ice::TargetX8632 *>(TargetLowering);
253 if (getBase() && getBase()->isRematerializable()) { 247 if (getBase() && getBase()->isRematerializable()) {
254 Disp += 248 Disp += GetRematerializableOffset(getBase(), Target);
255 GetRematerializableOffset(getBase(), getIgnoreStackAdjust(), Target);
256 } 249 }
257 // The index should never be rematerializable. But if we ever allow it, then 250 // The index should never be rematerializable. But if we ever allow it, then
258 // we should make sure the rematerialization offset is shifted by the Shift 251 // we should make sure the rematerialization offset is shifted by the Shift
259 // value. 252 // value.
260 if (getIndex()) 253 if (getIndex())
261 assert(!getIndex()->isRematerializable()); 254 assert(!getIndex()->isRematerializable());
262 AssemblerFixup *Fixup = nullptr; 255 AssemblerFixup *Fixup = nullptr;
263 // Determine the offset (is it relocatable?) 256 // Determine the offset (is it relocatable?)
264 if (getOffset()) { 257 if (getOffset()) {
265 if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) { 258 if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) {
(...skipping 22 matching lines...) Expand all
288 Fixup); 281 Fixup);
289 } else { 282 } else {
290 return X8632::Traits::Address(Disp, Fixup); 283 return X8632::Traits::Address(Disp, Fixup);
291 } 284 }
292 } 285 }
293 286
294 MachineTraits<TargetX8632>::Address 287 MachineTraits<TargetX8632>::Address
295 MachineTraits<TargetX8632>::VariableSplit::toAsmAddress(const Cfg *Func) const { 288 MachineTraits<TargetX8632>::VariableSplit::toAsmAddress(const Cfg *Func) const {
296 assert(!Var->hasReg()); 289 assert(!Var->hasReg());
297 const ::Ice::TargetLowering *Target = Func->getTarget(); 290 const ::Ice::TargetLowering *Target = Func->getTarget();
298 int32_t Offset = 291 int32_t Offset = Var->getStackOffset() + getOffset();
299 Var->getStackOffset() + Target->getStackAdjustment() + getOffset();
300 return X8632::Traits::Address(getEncodedGPR(Target->getFrameOrStackReg()), 292 return X8632::Traits::Address(getEncodedGPR(Target->getFrameOrStackReg()),
301 Offset, AssemblerFixup::NoFixup); 293 Offset, AssemblerFixup::NoFixup);
302 } 294 }
303 295
304 void MachineTraits<TargetX8632>::VariableSplit::emit(const Cfg *Func) const { 296 void MachineTraits<TargetX8632>::VariableSplit::emit(const Cfg *Func) const {
305 if (!BuildDefs::dump()) 297 if (!BuildDefs::dump())
306 return; 298 return;
307 Ostream &Str = Func->getContext()->getStrEmit(); 299 Ostream &Str = Func->getContext()->getStrEmit();
308 assert(!Var->hasReg()); 300 assert(!Var->hasReg());
309 // The following is copied/adapted from TargetX8632::emitVariable(). 301 // The following is copied/adapted from TargetX8632::emitVariable().
310 const ::Ice::TargetLowering *Target = Func->getTarget(); 302 const ::Ice::TargetLowering *Target = Func->getTarget();
311 constexpr Type Ty = IceType_i32; 303 constexpr Type Ty = IceType_i32;
312 int32_t Offset = 304 int32_t Offset = Var->getStackOffset() + getOffset();
313 Var->getStackOffset() + Target->getStackAdjustment() + getOffset();
314 if (Offset) 305 if (Offset)
315 Str << Offset; 306 Str << Offset;
316 Str << "(%" << Target->getRegName(Target->getFrameOrStackReg(), Ty) << ")"; 307 Str << "(%" << Target->getRegName(Target->getFrameOrStackReg(), Ty) << ")";
317 } 308 }
318 309
319 void MachineTraits<TargetX8632>::VariableSplit::dump(const Cfg *Func, 310 void MachineTraits<TargetX8632>::VariableSplit::dump(const Cfg *Func,
320 Ostream &Str) const { 311 Ostream &Str) const {
321 if (!BuildDefs::dump()) 312 if (!BuildDefs::dump())
322 return; 313 return;
323 switch (Part) { 314 switch (Part) {
324 case Low: 315 case Low:
325 Str << "low"; 316 Str << "low";
326 break; 317 break;
327 case High: 318 case High:
328 Str << "high"; 319 Str << "high";
329 break; 320 break;
330 } 321 }
331 Str << "("; 322 Str << "(";
332 if (Func) 323 if (Func)
333 Var->dump(Func); 324 Var->dump(Func);
334 else 325 else
335 Var->dump(Str); 326 Var->dump(Str);
336 Str << ")"; 327 Str << ")";
337 } 328 }
338 329
339 } // namespace X86Internal 330 } // namespace X86Internal
340 } // end of namespace Ice 331 } // end of namespace Ice
341 332
342 X86INSTS_DEFINE_STATIC_DATA(TargetX8632) 333 X86INSTS_DEFINE_STATIC_DATA(TargetX8632)
OLDNEW
« no previous file with comments | « src/IceInstARM32.cpp ('k') | src/IceInstX8664.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698