OLD | NEW |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // TODO(sehr): ConstantRelocatable still needs updating for | 133 // TODO(sehr): ConstantRelocatable still needs updating for |
134 // rematerializable base/index and Disp. | 134 // rematerializable base/index and Disp. |
135 assert(Disp == 0); | 135 assert(Disp == 0); |
136 CR->emitWithoutPrefix(Func->getTarget()); | 136 CR->emitWithoutPrefix(Func->getTarget()); |
137 } else { | 137 } else { |
138 llvm_unreachable("Invalid offset type for x86 mem operand"); | 138 llvm_unreachable("Invalid offset type for x86 mem operand"); |
139 } | 139 } |
140 | 140 |
141 if (Base || Index) { | 141 if (Base || Index) { |
142 Str << "("; | 142 Str << "("; |
143 if (Base) | 143 if (Base) { |
144 Base->emit(Func); | 144 const Variable *Base32 = Base; |
| 145 if (Base->getType() != IceType_i32) { |
| 146 // X86-64 is ILP32, but %rsp and %rbp are accessed as 64-bit registers. |
| 147 // For filetype=asm, they need to be emitted as their 32-bit sibilings. |
| 148 assert(Base->getType() == IceType_i64); |
| 149 assert(Base->getRegNum() == RegX8664::Encoded_Reg_rsp || |
| 150 Base->getRegNum() == RegX8664::Encoded_Reg_rbp); |
| 151 Base32 = Base->asType(IceType_i32, X8664::Traits::getGprForType( |
| 152 IceType_i32, Base->getRegNum())); |
| 153 } |
| 154 Base32->emit(Func); |
| 155 } |
145 if (Index) { | 156 if (Index) { |
| 157 assert(Index->getType() == IceType_i32); |
146 Str << ","; | 158 Str << ","; |
147 Index->emit(Func); | 159 Index->emit(Func); |
148 if (Shift) | 160 if (Shift) |
149 Str << "," << (1u << Shift); | 161 Str << "," << (1u << Shift); |
150 } | 162 } |
151 Str << ")"; | 163 Str << ")"; |
152 } | 164 } |
153 } | 165 } |
154 | 166 |
155 void MachineTraits<TargetX8664>::X86OperandMem::dump(const Cfg *Func, | 167 void MachineTraits<TargetX8664>::X86OperandMem::dump(const Cfg *Func, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 Var->dump(Func); | 306 Var->dump(Func); |
295 else | 307 else |
296 Var->dump(Str); | 308 Var->dump(Str); |
297 Str << ")"; | 309 Str << ")"; |
298 } | 310 } |
299 | 311 |
300 } // namespace X86Internal | 312 } // namespace X86Internal |
301 } // end of namespace Ice | 313 } // end of namespace Ice |
302 | 314 |
303 X86INSTS_DEFINE_STATIC_DATA(TargetX8664) | 315 X86INSTS_DEFINE_STATIC_DATA(TargetX8664) |
OLD | NEW |