Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- subzero/src/IceAssemblerX86BaseImpl.h - base x86 assembler -*- C++ -*-=// | 1 //===- subzero/src/IceAssemblerX86BaseImpl.h - base x86 assembler -*- C++ -*-=// |
| 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 // | 5 // |
| 6 // Modified by the Subzero authors. | 6 // Modified by the Subzero authors. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // The Subzero Code Generator | 10 // The Subzero Code Generator |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 emitRex(RexTypeIrrelevant, address, RexRegIrrelevant); | 115 emitRex(RexTypeIrrelevant, address, RexRegIrrelevant); |
| 116 emitUint8(0xFF); | 116 emitUint8(0xFF); |
| 117 emitOperand(2, address); | 117 emitOperand(2, address); |
| 118 } | 118 } |
| 119 | 119 |
| 120 template <class Machine> | 120 template <class Machine> |
| 121 void AssemblerX86Base<Machine>::call(const ConstantRelocatable *label) { | 121 void AssemblerX86Base<Machine>::call(const ConstantRelocatable *label) { |
| 122 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 122 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 123 intptr_t call_start = Buffer.getPosition(); | 123 intptr_t call_start = Buffer.getPosition(); |
| 124 emitUint8(0xE8); | 124 emitUint8(0xE8); |
| 125 emitFixup(this->createFixup(Traits::PcRelFixup, label)); | 125 emitFixup(this->createFixup(Traits::FixupKindPcRel, label)); |
|
John
2015/12/22 15:44:38
I prefer the other name. The prefix "FixupKind" ju
Jim Stichnoth
2015/12/28 07:54:07
Good point.
For this naming, I'm trying to distin
| |
| 126 emitInt32(-4); | 126 emitInt32(-4); |
| 127 assert((Buffer.getPosition() - call_start) == kCallExternalLabelSize); | 127 assert((Buffer.getPosition() - call_start) == kCallExternalLabelSize); |
| 128 (void)call_start; | 128 (void)call_start; |
| 129 } | 129 } |
| 130 | 130 |
| 131 template <class Machine> | 131 template <class Machine> |
| 132 void AssemblerX86Base<Machine>::call(const Immediate &abs_address) { | 132 void AssemblerX86Base<Machine>::call(const Immediate &abs_address) { |
| 133 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 133 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 134 intptr_t call_start = Buffer.getPosition(); | 134 intptr_t call_start = Buffer.getPosition(); |
| 135 emitUint8(0xE8); | 135 emitUint8(0xE8); |
| 136 emitFixup(this->createFixup(Traits::PcRelFixup, AssemblerFixup::NullSymbol)); | 136 emitFixup( |
| 137 this->createFixup(Traits::FixupKindPcRel, AssemblerFixup::NullSymbol)); | |
| 137 emitInt32(abs_address.value() - 4); | 138 emitInt32(abs_address.value() - 4); |
| 138 assert((Buffer.getPosition() - call_start) == kCallExternalLabelSize); | 139 assert((Buffer.getPosition() - call_start) == kCallExternalLabelSize); |
| 139 (void)call_start; | 140 (void)call_start; |
| 140 } | 141 } |
| 141 | 142 |
| 142 template <class Machine> | 143 template <class Machine> |
| 143 void AssemblerX86Base<Machine>::pushl(typename Traits::GPRRegister reg) { | 144 void AssemblerX86Base<Machine>::pushl(typename Traits::GPRRegister reg) { |
| 144 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 145 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 145 emitRexB(RexTypeIrrelevant, reg); | 146 emitRexB(RexTypeIrrelevant, reg); |
| 146 emitUint8(0x50 + gprEncoding(reg)); | 147 emitUint8(0x50 + gprEncoding(reg)); |
| (...skipping 2978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3125 emitLabelLink(label); | 3126 emitLabelLink(label); |
| 3126 } | 3127 } |
| 3127 } | 3128 } |
| 3128 | 3129 |
| 3129 template <class Machine> | 3130 template <class Machine> |
| 3130 void AssemblerX86Base<Machine>::j(typename Traits::Cond::BrCond condition, | 3131 void AssemblerX86Base<Machine>::j(typename Traits::Cond::BrCond condition, |
| 3131 const ConstantRelocatable *label) { | 3132 const ConstantRelocatable *label) { |
| 3132 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 3133 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 3133 emitUint8(0x0F); | 3134 emitUint8(0x0F); |
| 3134 emitUint8(0x80 + condition); | 3135 emitUint8(0x80 + condition); |
| 3135 emitFixup(this->createFixup(Traits::PcRelFixup, label)); | 3136 assert(0 && "Untested - please verify and then remove this assert."); |
| 3137 emitFixup(this->createFixup(Traits::FixupKindPcRel, label)); | |
| 3136 emitInt32(-4); | 3138 emitInt32(-4); |
| 3137 } | 3139 } |
| 3138 | 3140 |
| 3139 template <class Machine> | 3141 template <class Machine> |
| 3140 void AssemblerX86Base<Machine>::jmp(typename Traits::GPRRegister reg) { | 3142 void AssemblerX86Base<Machine>::jmp(typename Traits::GPRRegister reg) { |
| 3141 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 3143 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 3142 emitRexB(RexTypeIrrelevant, reg); | 3144 emitRexB(RexTypeIrrelevant, reg); |
| 3143 emitUint8(0xFF); | 3145 emitUint8(0xFF); |
| 3144 emitRegisterOperand(4, gprEncoding(reg)); | 3146 emitRegisterOperand(4, gprEncoding(reg)); |
| 3145 } | 3147 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3165 } else { | 3167 } else { |
| 3166 emitUint8(0xE9); | 3168 emitUint8(0xE9); |
| 3167 emitLabelLink(label); | 3169 emitLabelLink(label); |
| 3168 } | 3170 } |
| 3169 } | 3171 } |
| 3170 | 3172 |
| 3171 template <class Machine> | 3173 template <class Machine> |
| 3172 void AssemblerX86Base<Machine>::jmp(const ConstantRelocatable *label) { | 3174 void AssemblerX86Base<Machine>::jmp(const ConstantRelocatable *label) { |
| 3173 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 3175 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 3174 emitUint8(0xE9); | 3176 emitUint8(0xE9); |
| 3175 emitFixup(this->createFixup(Traits::PcRelFixup, label)); | 3177 assert(0 && "Untested - please verify and then remove this assert."); |
| 3178 emitFixup(this->createFixup(Traits::FixupKindPcRel, label)); | |
| 3176 emitInt32(-4); | 3179 emitInt32(-4); |
| 3177 } | 3180 } |
| 3178 | 3181 |
| 3179 template <class Machine> void AssemblerX86Base<Machine>::mfence() { | 3182 template <class Machine> void AssemblerX86Base<Machine>::mfence() { |
| 3180 AssemblerBuffer::EnsureCapacity ensured(&Buffer); | 3183 AssemblerBuffer::EnsureCapacity ensured(&Buffer); |
| 3181 emitUint8(0x0F); | 3184 emitUint8(0x0F); |
| 3182 emitUint8(0xAE); | 3185 emitUint8(0xAE); |
| 3183 emitUint8(0xF0); | 3186 emitUint8(0xF0); |
| 3184 } | 3187 } |
| 3185 | 3188 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3493 (void)shifter; | 3496 (void)shifter; |
| 3494 if (Ty == IceType_i16) | 3497 if (Ty == IceType_i16) |
| 3495 emitOperandSizeOverride(); | 3498 emitOperandSizeOverride(); |
| 3496 emitRexB(Ty, operand.rm()); | 3499 emitRexB(Ty, operand.rm()); |
| 3497 emitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); | 3500 emitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); |
| 3498 emitOperand(rm, operand); | 3501 emitOperand(rm, operand); |
| 3499 } | 3502 } |
| 3500 | 3503 |
| 3501 } // end of namespace X86Internal | 3504 } // end of namespace X86Internal |
| 3502 } // end of namespace Ice | 3505 } // end of namespace Ice |
| OLD | NEW |