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

Side by Side Diff: src/IceInstX8632.cpp

Issue 1676123002: Subzero: Use a proper RegNumT type instead of int32_t/SizeT. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Make it possible to do "auto NewReg = RegNumT::NoRegister;" Created 4 years, 10 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/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 if (Base) 92 if (Base)
93 Vars[I++] = Base; 93 Vars[I++] = Base;
94 if (Index) 94 if (Index)
95 Vars[I++] = Index; 95 Vars[I++] = Index;
96 assert(I == NumVars); 96 assert(I == NumVars);
97 } 97 }
98 } 98 }
99 99
100 namespace { 100 namespace {
101 101
102 int32_t GetRematerializableOffset(Variable *Var, 102 int32_t getRematerializableOffset(Variable *Var,
103 const Ice::X8632::TargetX8632 *Target) { 103 const Ice::X8632::TargetX8632 *Target) {
104 int32_t Disp = Var->getStackOffset(); 104 int32_t Disp = Var->getStackOffset();
105 SizeT RegNum = static_cast<SizeT>(Var->getRegNum()); 105 const auto RegNum = Var->getRegNum();
106 if (RegNum == Target->getFrameReg()) { 106 if (RegNum == Target->getFrameReg()) {
107 Disp += Target->getFrameFixedAllocaOffset(); 107 Disp += Target->getFrameFixedAllocaOffset();
108 } else if (RegNum != Target->getStackReg()) { 108 } else if (RegNum != Target->getStackReg()) {
109 llvm::report_fatal_error("Unexpected rematerializable register type"); 109 llvm::report_fatal_error("Unexpected rematerializable register type");
110 } 110 }
111 return Disp; 111 return Disp;
112 } 112 }
113 113
114 void validateMemOperandPIC(const TargetX8632Traits::X86OperandMem *Mem, 114 void validateMemOperandPIC(const TargetX8632Traits::X86OperandMem *Mem,
115 bool UseNonsfi) { 115 bool UseNonsfi) {
(...skipping 16 matching lines...) Expand all
132 if (!BuildDefs::dump()) 132 if (!BuildDefs::dump())
133 return; 133 return;
134 const bool UseNonsfi = Func->getContext()->getFlags().getUseNonsfi(); 134 const bool UseNonsfi = Func->getContext()->getFlags().getUseNonsfi();
135 validateMemOperandPIC(this, UseNonsfi); 135 validateMemOperandPIC(this, UseNonsfi);
136 const auto *Target = 136 const auto *Target =
137 static_cast<const ::Ice::X8632::TargetX8632 *>(Func->getTarget()); 137 static_cast<const ::Ice::X8632::TargetX8632 *>(Func->getTarget());
138 // If the base is rematerializable, we need to replace it with the correct 138 // If the base is rematerializable, we need to replace it with the correct
139 // physical register (esp or ebp), and update the Offset. 139 // physical register (esp or ebp), and update the Offset.
140 int32_t Disp = 0; 140 int32_t Disp = 0;
141 if (getBase() && getBase()->isRematerializable()) { 141 if (getBase() && getBase()->isRematerializable()) {
142 Disp += GetRematerializableOffset(getBase(), Target); 142 Disp += getRematerializableOffset(getBase(), Target);
143 } 143 }
144 // The index should never be rematerializable. But if we ever allow it, then 144 // The index should never be rematerializable. But if we ever allow it, then
145 // we should make sure the rematerialization offset is shifted by the Shift 145 // we should make sure the rematerialization offset is shifted by the Shift
146 // value. 146 // value.
147 if (getIndex()) 147 if (getIndex())
148 assert(!getIndex()->isRematerializable()); 148 assert(!getIndex()->isRematerializable());
149 Ostream &Str = Func->getContext()->getStrEmit(); 149 Ostream &Str = Func->getContext()->getStrEmit();
150 if (SegmentReg != DefaultSegment) { 150 if (SegmentReg != DefaultSegment) {
151 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); 151 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
152 Str << "%" << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":"; 152 Str << "%" << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (SegmentReg != DefaultSegment) { 192 if (SegmentReg != DefaultSegment) {
193 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM); 193 assert(SegmentReg >= 0 && SegmentReg < SegReg_NUM);
194 Str << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":"; 194 Str << X8632::Traits::InstSegmentRegNames[SegmentReg] << ":";
195 } 195 }
196 bool Dumped = false; 196 bool Dumped = false;
197 Str << "["; 197 Str << "[";
198 int32_t Disp = 0; 198 int32_t Disp = 0;
199 const auto *Target = 199 const auto *Target =
200 static_cast<const ::Ice::X8632::TargetX8632 *>(Func->getTarget()); 200 static_cast<const ::Ice::X8632::TargetX8632 *>(Func->getTarget());
201 if (getBase() && getBase()->isRematerializable()) { 201 if (getBase() && getBase()->isRematerializable()) {
202 Disp += GetRematerializableOffset(getBase(), Target); 202 Disp += getRematerializableOffset(getBase(), Target);
203 } 203 }
204 if (getBase()) { 204 if (getBase()) {
205 if (Func) 205 if (Func)
206 getBase()->dump(Func); 206 getBase()->dump(Func);
207 else 207 else
208 getBase()->dump(Str); 208 getBase()->dump(Str);
209 Dumped = true; 209 Dumped = true;
210 } 210 }
211 if (getIndex()) { 211 if (getIndex()) {
212 assert(!getIndex()->isRematerializable()); 212 assert(!getIndex()->isRematerializable());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 TargetX8632Traits::Address TargetX8632Traits::X86OperandMem::toAsmAddress( 261 TargetX8632Traits::Address TargetX8632Traits::X86OperandMem::toAsmAddress(
262 TargetX8632Traits::Assembler *Asm, 262 TargetX8632Traits::Assembler *Asm,
263 const Ice::TargetLowering *TargetLowering, bool /*IsLeaAddr*/) const { 263 const Ice::TargetLowering *TargetLowering, bool /*IsLeaAddr*/) const {
264 const auto *Target = 264 const auto *Target =
265 static_cast<const ::Ice::X8632::TargetX8632 *>(TargetLowering); 265 static_cast<const ::Ice::X8632::TargetX8632 *>(TargetLowering);
266 const bool UseNonsfi = Target->getGlobalContext()->getFlags().getUseNonsfi(); 266 const bool UseNonsfi = Target->getGlobalContext()->getFlags().getUseNonsfi();
267 validateMemOperandPIC(this, UseNonsfi); 267 validateMemOperandPIC(this, UseNonsfi);
268 int32_t Disp = 0; 268 int32_t Disp = 0;
269 if (getBase() && getBase()->isRematerializable()) { 269 if (getBase() && getBase()->isRematerializable()) {
270 Disp += GetRematerializableOffset(getBase(), Target); 270 Disp += getRematerializableOffset(getBase(), Target);
271 } 271 }
272 // The index should never be rematerializable. But if we ever allow it, then 272 // The index should never be rematerializable. But if we ever allow it, then
273 // we should make sure the rematerialization offset is shifted by the Shift 273 // we should make sure the rematerialization offset is shifted by the Shift
274 // value. 274 // value.
275 if (getIndex()) 275 if (getIndex())
276 assert(!getIndex()->isRematerializable()); 276 assert(!getIndex()->isRematerializable());
277 AssemblerFixup *Fixup = nullptr; 277 AssemblerFixup *Fixup = nullptr;
278 // Determine the offset (is it relocatable?) 278 // Determine the offset (is it relocatable?)
279 if (getOffset()) { 279 if (getOffset()) {
280 if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) { 280 if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 Var->dump(Func); 346 Var->dump(Func);
347 else 347 else
348 Var->dump(Str); 348 Var->dump(Str);
349 Str << ")"; 349 Str << ")";
350 } 350 }
351 351
352 } // namespace X8632 352 } // namespace X8632
353 } // end of namespace Ice 353 } // end of namespace Ice
354 354
355 X86INSTS_DEFINE_STATIC_DATA(X8632, X8632::Traits) 355 X86INSTS_DEFINE_STATIC_DATA(X8632, X8632::Traits)
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