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

Side by Side Diff: src/IceInstX8664.cpp

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 11 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.cpp ('k') | src/IceInstX86Base.h » ('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/IceInstX8664.cpp - X86-64 instruction implementation ---===// 1 //===- subzero/src/IceInstX8664.cpp - X86-64 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 }; 59 };
60 60
61 void TargetX8664Traits::X86Operand::dump(const Cfg *, Ostream &Str) const { 61 void TargetX8664Traits::X86Operand::dump(const Cfg *, Ostream &Str) const {
62 if (BuildDefs::dump()) 62 if (BuildDefs::dump())
63 Str << "<OperandX8664>"; 63 Str << "<OperandX8664>";
64 } 64 }
65 65
66 TargetX8664Traits::X86OperandMem::X86OperandMem(Cfg *Func, Type Ty, 66 TargetX8664Traits::X86OperandMem::X86OperandMem(Cfg *Func, Type Ty,
67 Variable *Base, 67 Variable *Base,
68 Constant *Offset, 68 Constant *Offset,
69 Variable *Index, uint16_t Shift) 69 Variable *Index, uint16_t Shift,
70 bool IsPIC)
70 : X86Operand(kMem, Ty), Base(Base), Offset(Offset), Index(Index), 71 : X86Operand(kMem, Ty), Base(Base), Offset(Offset), Index(Index),
71 Shift(Shift) { 72 Shift(Shift), IsPIC(IsPIC) {
72 assert(Shift <= 3); 73 assert(Shift <= 3);
73 Vars = nullptr; 74 Vars = nullptr;
74 NumVars = 0; 75 NumVars = 0;
75 if (Base) 76 if (Base)
76 ++NumVars; 77 ++NumVars;
77 if (Index) 78 if (Index)
78 ++NumVars; 79 ++NumVars;
79 if (NumVars) { 80 if (NumVars) {
80 Vars = Func->allocateArrayOf<Variable *>(NumVars); 81 Vars = Func->allocateArrayOf<Variable *>(NumVars);
81 SizeT I = 0; 82 SizeT I = 0;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } else if (getOffset() == nullptr && Disp != 0) { 127 } else if (getOffset() == nullptr && Disp != 0) {
127 Str << Disp; 128 Str << Disp;
128 } else if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(Offset)) { 129 } else if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(Offset)) {
129 if (Base == nullptr || CI->getValue() || Disp != 0) 130 if (Base == nullptr || CI->getValue() || Disp != 0)
130 // Emit a non-zero offset without a leading '$'. 131 // Emit a non-zero offset without a leading '$'.
131 Str << CI->getValue() + Disp; 132 Str << CI->getValue() + Disp;
132 } else if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(Offset)) { 133 } else if (const auto *CR = llvm::dyn_cast<ConstantRelocatable>(Offset)) {
133 // TODO(sehr): ConstantRelocatable still needs updating for 134 // TODO(sehr): ConstantRelocatable still needs updating for
134 // rematerializable base/index and Disp. 135 // rematerializable base/index and Disp.
135 assert(Disp == 0); 136 assert(Disp == 0);
136 CR->emitWithoutPrefix(Func->getTarget()); 137 const bool UseNonsfi = Func->getContext()->getFlags().getUseNonsfi();
138 CR->emitWithoutPrefix(Func->getTarget(), UseNonsfi ? "@GOTOFF" : "");
137 } else { 139 } else {
138 llvm_unreachable("Invalid offset type for x86 mem operand"); 140 llvm_unreachable("Invalid offset type for x86 mem operand");
139 } 141 }
140 142
141 if (Base || Index) { 143 if (Base || Index) {
142 Str << "("; 144 Str << "(";
143 if (Base) { 145 if (Base) {
144 const Variable *Base32 = Base; 146 const Variable *Base32 = Base;
145 if (Base->getType() != IceType_i32) { 147 if (Base->getType() != IceType_i32) {
146 // X86-64 is ILP32, but %rsp and %rbp are accessed as 64-bit registers. 148 // X86-64 is ILP32, but %rsp and %rbp are accessed as 64-bit registers.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 237 }
236 if (getIndex()) 238 if (getIndex())
237 assert(!getIndex()->isRematerializable()); 239 assert(!getIndex()->isRematerializable());
238 AssemblerFixup *Fixup = nullptr; 240 AssemblerFixup *Fixup = nullptr;
239 // Determine the offset (is it relocatable?) 241 // Determine the offset (is it relocatable?)
240 if (getOffset() != nullptr) { 242 if (getOffset() != nullptr) {
241 if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) { 243 if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) {
242 Disp += static_cast<int32_t>(CI->getValue()); 244 Disp += static_cast<int32_t>(CI->getValue());
243 } else if (const auto CR = 245 } else if (const auto CR =
244 llvm::dyn_cast<ConstantRelocatable>(getOffset())) { 246 llvm::dyn_cast<ConstantRelocatable>(getOffset())) {
245 Disp += CR->getOffset(); 247 Disp = CR->getOffset();
246 Fixup = Asm->createFixup(RelFixup, CR); 248 Fixup = Asm->createFixup(FK_Abs, CR);
247 } else { 249 } else {
248 llvm_unreachable("Unexpected offset type"); 250 llvm_unreachable("Unexpected offset type");
249 } 251 }
250 } 252 }
251 253
252 // Now convert to the various possible forms. 254 // Now convert to the various possible forms.
253 if (getBase() && getIndex()) { 255 if (getBase() && getIndex()) {
254 return X8664::Traits::Address(getEncodedGPR(getBase()->getRegNum()), 256 return X8664::Traits::Address(getEncodedGPR(getBase()->getRegNum()),
255 getEncodedGPR(getIndex()->getRegNum()), 257 getEncodedGPR(getIndex()->getRegNum()),
256 X8664::Traits::ScaleFactor(getShift()), Disp, 258 X8664::Traits::ScaleFactor(getShift()), Disp,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 Var->dump(Func); 309 Var->dump(Func);
308 else 310 else
309 Var->dump(Str); 311 Var->dump(Str);
310 Str << ")"; 312 Str << ")";
311 } 313 }
312 314
313 } // namespace X8664 315 } // namespace X8664
314 } // end of namespace Ice 316 } // end of namespace Ice
315 317
316 X86INSTS_DEFINE_STATIC_DATA(X8664, X8664::Traits) 318 X86INSTS_DEFINE_STATIC_DATA(X8664, X8664::Traits)
OLDNEW
« no previous file with comments | « src/IceInstX8632.cpp ('k') | src/IceInstX86Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698