assembler_x86.cc revision 52c489645b6e9ae33623f1ec24143cde5444906e
12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 16a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 172c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers#include "assembler_x86.h" 182c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 191aa246dec5abe212f699de1413a0c4a191ca364aElliott Hughes#include "base/casts.h" 20166db04e259ca51838c311891598664deeed85adIan Rogers#include "entrypoints/quick/quick_entrypoints.h" 21578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom#include "memory_region.h" 22578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom#include "thread.h" 23547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen#include "utils/dwarf_cfi.h" 24a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 256b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art { 262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersnamespace x86 { 27a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 28b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogersstd::ostream& operator<<(std::ostream& os, const XmmRegister& reg) { 29b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers return os << "XMM" << static_cast<int>(reg); 30b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 31b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 32b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogersstd::ostream& operator<<(std::ostream& os, const X87Register& reg) { 33b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers return os << "ST" << static_cast<int>(reg); 34b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 35a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::call(Register reg) { 37a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 38a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 39a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(2, reg); 40a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 41a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 42a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 432c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::call(const Address& address) { 44a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 45a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 46a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(2, address); 47a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 48a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 49a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::call(Label* label) { 51a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 52a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xE8); 53a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const int kSize = 5; 54a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitLabel(label, kSize); 55a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 56a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 57a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 588ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffrayvoid X86Assembler::call(const ExternalLabel& label) { 598ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 608ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray intptr_t call_start = buffer_.GetPosition(); 618ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray EmitUint8(0xE8); 628ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray EmitInt32(label.address()); 638ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray static const intptr_t kCallExternalLabelSize = 5; 648ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray DCHECK_EQ((buffer_.GetPosition() - call_start), kCallExternalLabelSize); 658ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray} 668ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray 678ccc3f5d06fd217cdaabd37e743adab2031d3720Nicolas Geoffray 682c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::pushl(Register reg) { 69a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 70a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x50 + reg); 71a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 72a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 73a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 742c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::pushl(const Address& address) { 75a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 76a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 77a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(6, address); 78a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 79a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 80a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::pushl(const Immediate& imm) { 82a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 8344fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers if (imm.is_int8()) { 8444fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitUint8(0x6A); 8544fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitUint8(imm.value() & 0xFF); 8644fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers } else { 8744fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitUint8(0x68); 8844fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitImmediate(imm); 8944fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers } 90a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 91a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 92a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::popl(Register reg) { 94a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 95a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x58 + reg); 96a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 97a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 98a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 992c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::popl(const Address& address) { 100a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 101a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x8F); 102a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(0, address); 103a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 104a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 105a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movl(Register dst, const Immediate& imm) { 107a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 108a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xB8 + dst); 109a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(imm); 110a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 111a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 112a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movl(Register dst, Register src) { 114a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 115a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x89); 116a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(src, dst); 117a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 118a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 119a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1202c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movl(Register dst, const Address& src) { 121a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 122a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x8B); 123a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 124a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 125a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 126a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movl(const Address& dst, Register src) { 128a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 129a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x89); 130a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(src, dst); 131a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 132a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 133a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movl(const Address& dst, const Immediate& imm) { 135a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 136a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC7); 137a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(0, dst); 138a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(imm); 139a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 140a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 141bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogersvoid X86Assembler::movl(const Address& dst, Label* lbl) { 142bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers AssemblerBuffer::EnsureCapacity ensured(&buffer_); 143bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers EmitUint8(0xC7); 144bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers EmitOperand(0, dst); 145bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers EmitLabel(lbl, dst.length_ + 5); 146bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers} 147a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxb(Register dst, ByteRegister src) { 149a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 150a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 151a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xB6); 152a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 153a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 154a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 155a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1562c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxb(Register dst, const Address& src) { 157a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 158a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 159a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xB6); 160a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 161a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 162a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 163a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxb(Register dst, ByteRegister src) { 165a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 166a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 167a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xBE); 168a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 169a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 170a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 171a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxb(Register dst, const Address& src) { 173a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 174a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 175a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xBE); 176a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 177a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 178a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 179a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1801bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::movb(Register /*dst*/, const Address& /*src*/) { 181a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro LOG(FATAL) << "Use movzxb or movsxb instead."; 182a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 183a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 184a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1852c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movb(const Address& dst, ByteRegister src) { 186a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 187a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x88); 188a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(src, dst); 189a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 190a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 191a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movb(const Address& dst, const Immediate& imm) { 193a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 194a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC6); 195a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(EAX, dst); 196a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(imm.is_int8()); 197a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(imm.value() & 0xFF); 198a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 199a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 200a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2012c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxw(Register dst, Register src) { 202a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 203a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 204a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xB7); 205a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 206a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 207a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 208a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2092c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxw(Register dst, const Address& src) { 210a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 211a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 212a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xB7); 213a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 214a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 215a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 216a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2172c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxw(Register dst, Register src) { 218a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 219a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 220a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xBF); 221a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 222a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 223a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 224a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxw(Register dst, const Address& src) { 226a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 227a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 228a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xBF); 229a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 230a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 231a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 232a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2331bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::movw(Register /*dst*/, const Address& /*src*/) { 234a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro LOG(FATAL) << "Use movzxw or movsxw instead."; 235a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 236a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 237a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2382c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movw(const Address& dst, Register src) { 239a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 240a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperandSizeOverride(); 241a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x89); 242a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(src, dst); 243a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 244a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 245a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 24626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffrayvoid X86Assembler::movw(const Address& dst, const Immediate& imm) { 24726a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 24826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray EmitOperandSizeOverride(); 24926a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray EmitUint8(0xC7); 25026a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray EmitOperand(0, dst); 251b6e7206ad7a426adda9cfd649a4ef969607d79d6Nicolas Geoffray CHECK(imm.is_uint16() || imm.is_int16()); 25226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray EmitUint8(imm.value() & 0xFF); 25326a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray EmitUint8(imm.value() >> 8); 25426a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray} 25526a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 25626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray 2572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::leal(Register dst, const Address& src) { 258a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 259a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x8D); 260a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 261a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 262a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 263a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmovl(Condition condition, Register dst, Register src) { 265a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 266a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 267b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers EmitUint8(0x40 + condition); 268a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 269a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 270a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 271a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2725b4b898ed8725242ee6b7229b94467c3ea3054c8Nicolas Geoffrayvoid X86Assembler::setb(Condition condition, Register dst) { 273a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 274a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 275b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers EmitUint8(0x90 + condition); 2765b4b898ed8725242ee6b7229b94467c3ea3054c8Nicolas Geoffray EmitOperand(0, Operand(dst)); 2777fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray} 2787fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray 2797fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray 2807fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffrayvoid X86Assembler::movaps(XmmRegister dst, XmmRegister src) { 2817fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 2827fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray EmitUint8(0x0F); 2837fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray EmitUint8(0x28); 2847fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray EmitXmmRegisterOperand(dst, src); 285a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 286a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 287a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2882c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movss(XmmRegister dst, const Address& src) { 289a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 290a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 291a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 292a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x10); 293a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 294a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 295a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 296a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 2972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movss(const Address& dst, XmmRegister src) { 298a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 299a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 300a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 301a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x11); 302a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(src, dst); 303a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 304a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 305a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movss(XmmRegister dst, XmmRegister src) { 307a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 308a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 309a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 310a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x11); 311a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(src, dst); 312a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 313a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 314a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movd(XmmRegister dst, Register src) { 316a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 317a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x66); 318a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 319a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x6E); 320a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 321a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 322a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 323a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3242c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movd(Register dst, XmmRegister src) { 325a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 326a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x66); 327a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 328a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x7E); 329a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(src, Operand(dst)); 330a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 331a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 332a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3332c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addss(XmmRegister dst, XmmRegister src) { 334a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 335a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 336a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 337a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x58); 338a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 339a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 340a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 341a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3422c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addss(XmmRegister dst, const Address& src) { 343a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 344a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 345a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 346a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x58); 347a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 348a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 349a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 350a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3512c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subss(XmmRegister dst, XmmRegister src) { 352a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 353a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 354a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 355a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5C); 356a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 357a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 358a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 359a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3602c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subss(XmmRegister dst, const Address& src) { 361a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 362a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 363a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 364a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5C); 365a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 366a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 367a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 368a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3692c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulss(XmmRegister dst, XmmRegister src) { 370a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 371a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 372a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 373a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x59); 374a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 375a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 376a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 377a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3782c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulss(XmmRegister dst, const Address& src) { 379a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 380a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 381a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 382a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x59); 383a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 384a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 385a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 386a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3872c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divss(XmmRegister dst, XmmRegister src) { 388a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 389a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 390a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 391a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5E); 392a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 393a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 394a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 395a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 3962c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divss(XmmRegister dst, const Address& src) { 397a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 398a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 399a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 400a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5E); 401a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 402a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 403a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 404a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4052c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::flds(const Address& src) { 406a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 407a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 408a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(0, src); 409a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 410a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 411a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4122c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fstps(const Address& dst) { 413a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 414a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 415a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(3, dst); 416a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 417a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 418a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsd(XmmRegister dst, const Address& src) { 420a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 421a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 422a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 423a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x10); 424a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 425a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 426a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 427a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4282c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsd(const Address& dst, XmmRegister src) { 429a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 430a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 431a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 432a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x11); 433a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(src, dst); 434a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 435a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 436a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsd(XmmRegister dst, XmmRegister src) { 438a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 439a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 440a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 441a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x11); 442a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(src, dst); 443a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 444a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 445a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 44652c489645b6e9ae33623f1ec24143cde5444906eCalin Juravlevoid X86Assembler::psrlq(XmmRegister reg, const Immediate& shift_count) { 44752c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle DCHECK(shift_count.is_uint8()); 44852c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle 44952c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle AssemblerBuffer::EnsureCapacity ensured(&buffer_); 45052c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(0x66); 45152c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(0x0F); 45252c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(0x73); 45352c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitXmmRegisterOperand(2, reg); 45452c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(shift_count.value()); 45552c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle} 45652c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle 45752c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle 45852c489645b6e9ae33623f1ec24143cde5444906eCalin Juravlevoid X86Assembler::punpckldq(XmmRegister dst, XmmRegister src) { 45952c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle AssemblerBuffer::EnsureCapacity ensured(&buffer_); 46052c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(0x66); 46152c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(0x0F); 46252c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitUint8(0x62); 46352c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle EmitXmmRegisterOperand(dst, src); 46452c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle} 46552c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle 46652c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle 4672c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addsd(XmmRegister dst, XmmRegister src) { 468a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 469a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 470a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 471a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x58); 472a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 473a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 474a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 475a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4762c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addsd(XmmRegister dst, const Address& src) { 477a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 478a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 479a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 480a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x58); 481a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 482a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 483a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 484a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4852c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subsd(XmmRegister dst, XmmRegister src) { 486a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 487a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 488a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 489a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5C); 490a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 491a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 492a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 493a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 4942c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subsd(XmmRegister dst, const Address& src) { 495a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 496a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 497a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 498a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5C); 499a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 500a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 501a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 502a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5032c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulsd(XmmRegister dst, XmmRegister src) { 504a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 505a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 506a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 507a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x59); 508a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 509a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 510a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 511a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5122c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulsd(XmmRegister dst, const Address& src) { 513a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 514a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 515a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 516a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x59); 517a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 518a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 519a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 520a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5212c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divsd(XmmRegister dst, XmmRegister src) { 522a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 523a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 524a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 525a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5E); 526a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 527a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 528a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 529a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5302c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divsd(XmmRegister dst, const Address& src) { 531a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 532a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 533a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 534a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5E); 535a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 536a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 537a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 538a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5392c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsi2ss(XmmRegister dst, Register src) { 540a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 541a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 542a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 543a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2A); 544a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 545a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 546a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 547a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsi2sd(XmmRegister dst, Register src) { 549a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 550a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 551a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 552a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2A); 553a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 554a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 555a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 556a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtss2si(Register dst, XmmRegister src) { 558a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 559a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 560a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 561a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2D); 562a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 563a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 564a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 565a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5662c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtss2sd(XmmRegister dst, XmmRegister src) { 567a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 568a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 569a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 570a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5A); 571a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 572a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 573a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 574a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5752c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsd2si(Register dst, XmmRegister src) { 576a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 577a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 578a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 579a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2D); 580a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 581a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 582a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 583a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvttss2si(Register dst, XmmRegister src) { 585a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 586a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 587a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 588a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2C); 589a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 590a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 591a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 592a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 5932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvttsd2si(Register dst, XmmRegister src) { 594a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 595a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 596a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 597a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2C); 598a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 599a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 600a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 601a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6022c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsd2ss(XmmRegister dst, XmmRegister src) { 603a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 604a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 605a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 606a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x5A); 607a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 608a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 609a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 610a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6112c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtdq2pd(XmmRegister dst, XmmRegister src) { 612a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 613a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 614a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 615a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xE6); 616a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 617a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 618a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 619a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6202c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::comiss(XmmRegister a, XmmRegister b) { 621a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 622a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 623a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2F); 624a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(a, b); 625a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 626a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 627a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6282c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::comisd(XmmRegister a, XmmRegister b) { 629a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 630a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x66); 631a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 632a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2F); 633a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(a, b); 634a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 635a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 636a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 637ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravlevoid X86Assembler::ucomiss(XmmRegister a, XmmRegister b) { 638ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle AssemblerBuffer::EnsureCapacity ensured(&buffer_); 639ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitUint8(0x0F); 640ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitUint8(0x2E); 641ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitXmmRegisterOperand(a, b); 642ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle} 643ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle 644ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle 645ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravlevoid X86Assembler::ucomisd(XmmRegister a, XmmRegister b) { 646ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle AssemblerBuffer::EnsureCapacity ensured(&buffer_); 647ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitUint8(0x66); 648ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitUint8(0x0F); 649ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitUint8(0x2E); 650ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle EmitXmmRegisterOperand(a, b); 651ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle} 652ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle 653ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle 6542c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sqrtsd(XmmRegister dst, XmmRegister src) { 655a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 656a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 657a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 658a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x51); 659a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 660a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 661a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 662a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6632c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sqrtss(XmmRegister dst, XmmRegister src) { 664a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 665a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF3); 666a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 667a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x51); 668a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 669a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 670a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 671a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorpd(XmmRegister dst, const Address& src) { 673a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 674a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x66); 675a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 676a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x57); 677a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 678a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 679a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 680a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorpd(XmmRegister dst, XmmRegister src) { 682a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 683a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x66); 684a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 685a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x57); 686a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 687a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 688a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 689a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6902c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorps(XmmRegister dst, const Address& src) { 691a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 692a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 693a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x57); 694a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 695a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 696a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 697a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 6982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorps(XmmRegister dst, XmmRegister src) { 699a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 700a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 701a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x57); 702a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitXmmRegisterOperand(dst, src); 703a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 704a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 705a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::andpd(XmmRegister dst, const Address& src) { 707a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 708a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x66); 709a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 710a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x54); 711a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, src); 712a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 713a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 714a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fldl(const Address& src) { 716a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 717a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xDD); 718a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(0, src); 719a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 720a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 721a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7222c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fstpl(const Address& dst) { 723a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 724a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xDD); 725a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(3, dst); 726a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 727a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 728a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7292c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fnstcw(const Address& dst) { 730a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 731a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 732a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(7, dst); 733a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 734a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 735a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fldcw(const Address& src) { 737a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 738a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 739a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(5, src); 740a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 741a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 742a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7432c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fistpl(const Address& dst) { 744a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 745a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xDF); 746a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(7, dst); 747a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 748a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 749a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fistps(const Address& dst) { 751a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 752a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xDB); 753a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(3, dst); 754a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 755a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 756a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fildl(const Address& src) { 758a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 759a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xDF); 760a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(5, src); 761a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 762a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 763a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fincstp() { 765a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 766a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 767a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 768a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 769a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 770a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7712c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::ffree(const Immediate& index) { 772a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_LT(index.value(), 7); 773a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 774a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xDD); 775a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC0 + index.value()); 776a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 777a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 778a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7792c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fsin() { 780a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 781a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 782a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFE); 783a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 784a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 785a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7862c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fcos() { 787a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 788a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 789a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 790a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 791a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 792a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 7932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fptan() { 794a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 795a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD9); 796a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF2); 797a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 798a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 799a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8002c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xchgl(Register dst, Register src) { 801a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 802a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x87); 803a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 804a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 805a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8063c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray 8077caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogersvoid X86Assembler::xchgl(Register reg, const Address& address) { 8087caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers AssemblerBuffer::EnsureCapacity ensured(&buffer_); 8097caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers EmitUint8(0x87); 8107caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers EmitOperand(reg, address); 8117caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers} 8127caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers 813a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8143c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffrayvoid X86Assembler::cmpw(const Address& address, const Immediate& imm) { 8153c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 8163c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray EmitUint8(0x66); 8173c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray EmitComplex(7, address, imm); 8183c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray} 8193c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray 8203c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray 8212c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(Register reg, const Immediate& imm) { 822a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 823a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(7, Operand(reg), imm); 824a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 825a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 826a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(Register reg0, Register reg1) { 828a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 829a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x3B); 830a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg0, Operand(reg1)); 831a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 832a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 833a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(Register reg, const Address& address) { 835a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 836a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x3B); 837a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 838a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 839a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 840a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8412c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(Register dst, Register src) { 842a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 843a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x03); 844a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(dst, src); 845a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 846a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 847a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(Register reg, const Address& address) { 849a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 850a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x03); 851a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 852a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 853a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 854a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8552c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(const Address& address, Register reg) { 856a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 857a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x39); 858a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 859a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 860a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 861a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(const Address& address, const Immediate& imm) { 863a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 864a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(7, address, imm); 865a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 866a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 867a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 8682c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::testl(Register reg1, Register reg2) { 869a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 870a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x85); 871a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(reg1, reg2); 872a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 873a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 874a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 875f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffrayvoid X86Assembler::testl(Register reg, const Address& address) { 876f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 877f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray EmitUint8(0x85); 878f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray EmitOperand(reg, address); 879f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray} 880f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray 881f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray 8822c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::testl(Register reg, const Immediate& immediate) { 883a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 884a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // For registers that have a byte variant (EAX, EBX, ECX, and EDX) 885a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // we only test the byte register to keep the encoding short. 886a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (immediate.is_uint8() && reg < 4) { 887a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // Use zero-extended 8-bit immediate. 888a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (reg == EAX) { 889a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xA8); 890a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 891a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF6); 892a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC0 + reg); 893a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 894a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(immediate.value() & 0xFF); 895a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else if (reg == EAX) { 896a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // Use short form if the destination is EAX. 897a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xA9); 898a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(immediate); 899a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 900a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 901a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(0, Operand(reg)); 902a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(immediate); 903a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 904a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 905a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 906a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9072c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::andl(Register dst, Register src) { 908a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 909a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x23); 910a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 911a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 912a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 913a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9149574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffrayvoid X86Assembler::andl(Register reg, const Address& address) { 9159574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 9169574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray EmitUint8(0x23); 9179574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray EmitOperand(reg, address); 9189574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray} 9199574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9209574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9212c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::andl(Register dst, const Immediate& imm) { 922a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 923a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(4, Operand(dst), imm); 924a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 925a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 926a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::orl(Register dst, Register src) { 928a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 929a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0B); 930a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 931a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 932a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 933a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9349574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffrayvoid X86Assembler::orl(Register reg, const Address& address) { 9359574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 9369574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray EmitUint8(0x0B); 9379574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray EmitOperand(reg, address); 9389574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray} 9399574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9409574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9412c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::orl(Register dst, const Immediate& imm) { 942a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 943a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(1, Operand(dst), imm); 944a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 945a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 946a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9472c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorl(Register dst, Register src) { 948a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 949a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x33); 950a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 951a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 952a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9539574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9549574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffrayvoid X86Assembler::xorl(Register reg, const Address& address) { 9559574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 9569574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray EmitUint8(0x33); 9579574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray EmitOperand(reg, address); 9589574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray} 9599574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9609574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 961b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffrayvoid X86Assembler::xorl(Register dst, const Immediate& imm) { 962b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffray AssemblerBuffer::EnsureCapacity ensured(&buffer_); 963b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffray EmitComplex(6, Operand(dst), imm); 964b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffray} 965a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9669574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray 9672c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(Register reg, const Immediate& imm) { 968a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 969a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(0, Operand(reg), imm); 970a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 971a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 972a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9732c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(const Address& address, Register reg) { 974a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 975a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x01); 976a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 977a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 978a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 979a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9802c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(const Address& address, const Immediate& imm) { 981a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 982a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(0, address, imm); 983a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 984a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 985a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9862c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::adcl(Register reg, const Immediate& imm) { 987a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 988a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(2, Operand(reg), imm); 989a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 990a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 991a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::adcl(Register dst, Register src) { 993a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 994a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x13); 995a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 996a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 997a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 998a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 9992c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::adcl(Register dst, const Address& address) { 1000a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1001a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x13); 1002a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, address); 1003a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1004a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1005a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subl(Register dst, Register src) { 1007a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1008a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2B); 1009a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 1010a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1011a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1012a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subl(Register reg, const Immediate& imm) { 1014a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1015a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(5, Operand(reg), imm); 1016a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1017a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1018a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subl(Register reg, const Address& address) { 1020a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1021a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x2B); 1022a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 1023a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1024a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1025a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cdq() { 1027a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1028a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x99); 1029a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1030a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1031a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::idivl(Register reg) { 1033a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1034a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1035a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF8 | reg); 1036a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1037a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1038a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10392c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register dst, Register src) { 1040a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1041a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 1042a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xAF); 1043a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 1044a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1045a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1046a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10472c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register reg, const Immediate& imm) { 1048a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1049a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x69); 1050a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, Operand(reg)); 1051a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(imm); 1052a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1053a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1054a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10552c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register reg, const Address& address) { 1056a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1057a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 1058a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xAF); 1059a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 1060a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1061a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1062a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10632c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register reg) { 1064a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1065a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1066a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(5, Operand(reg)); 1067a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1068a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1069a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10702c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(const Address& address) { 1071a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1072a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1073a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(5, address); 1074a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1075a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1076a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10772c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mull(Register reg) { 1078a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1079a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1080a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(4, Operand(reg)); 1081a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1082a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1083a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mull(const Address& address) { 1085a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1086a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1087a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(4, address); 1088a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1089a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1090a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10912c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sbbl(Register dst, Register src) { 1092a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1093a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x1B); 1094a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, Operand(src)); 1095a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1096a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1097a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 10982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sbbl(Register reg, const Immediate& imm) { 1099a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1100a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitComplex(3, Operand(reg), imm); 1101a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1102a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1103a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11042c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sbbl(Register dst, const Address& address) { 1105a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1106a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x1B); 1107a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(dst, address); 1108a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1109a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1110a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11112c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::incl(Register reg) { 1112a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1113a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x40 + reg); 1114a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1115a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1116a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11172c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::incl(const Address& address) { 1118a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1119a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 1120a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(0, address); 1121a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1122a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1123a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11242c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::decl(Register reg) { 1125a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1126a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x48 + reg); 1127a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1128a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1129a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11302c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::decl(const Address& address) { 1131a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1132a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 1133a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(1, address); 1134a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1135a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1136a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shll(Register reg, const Immediate& imm) { 1138a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitGenericShift(4, reg, imm); 1139a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1140a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1141a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11422c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shll(Register operand, Register shifter) { 1143a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitGenericShift(4, operand, shifter); 1144a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1145a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1146a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11472c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shrl(Register reg, const Immediate& imm) { 1148a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitGenericShift(5, reg, imm); 1149a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1150a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1151a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11522c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shrl(Register operand, Register shifter) { 1153a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitGenericShift(5, operand, shifter); 1154a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1155a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1156a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sarl(Register reg, const Immediate& imm) { 1158a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitGenericShift(7, reg, imm); 1159a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1160a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1161a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sarl(Register operand, Register shifter) { 1163a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitGenericShift(7, operand, shifter); 1164a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1165a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1166a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11679aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravlevoid X86Assembler::shld(Register dst, Register src, Register shifter) { 11689aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle DCHECK_EQ(ECX, shifter); 1169a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1170a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 1171a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xA5); 1172a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(src, dst); 1173a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1174a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1175a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11769aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravlevoid X86Assembler::shrd(Register dst, Register src, Register shifter) { 11779aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle DCHECK_EQ(ECX, shifter); 11789aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle AssemblerBuffer::EnsureCapacity ensured(&buffer_); 11799aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle EmitUint8(0x0F); 11809aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle EmitUint8(0xAD); 11819aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle EmitRegisterOperand(src, dst); 11829aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle} 11839aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle 11849aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle 11852c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::negl(Register reg) { 1186a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1187a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1188a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(3, Operand(reg)); 1189a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1190a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1191a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::notl(Register reg) { 1193a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1194a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF7); 1195a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD0 | reg); 1196a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1197a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1198a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 11992c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::enter(const Immediate& imm) { 1200a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1201a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC8); 1202a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(imm.is_uint16()); 1203a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(imm.value() & 0xFF); 1204a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8((imm.value() >> 8) & 0xFF); 1205a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x00); 1206a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1207a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1208a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12092c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::leave() { 1210a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1211a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC9); 1212a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1213a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1214a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::ret() { 1216a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1217a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC3); 1218a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1219a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1220a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12212c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::ret(const Immediate& imm) { 1222a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1223a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC2); 1224a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(imm.is_uint16()); 1225a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(imm.value() & 0xFF); 1226a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8((imm.value() >> 8) & 0xFF); 1227a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1228a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1229a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1230a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12312c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::nop() { 1232a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1233a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x90); 1234a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1235a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1236a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::int3() { 1238a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1239a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xCC); 1240a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1241a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1242a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12432c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::hlt() { 1244a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1245a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF4); 1246a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1247a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1248a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12492c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::j(Condition condition, Label* label) { 1250a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1251a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (label->IsBound()) { 1252a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const int kShortSize = 2; 1253a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const int kLongSize = 6; 1254a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int offset = label->Position() - buffer_.Size(); 1255a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_LE(offset, 0); 1256a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (IsInt(8, offset - kShortSize)) { 1257a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x70 + condition); 1258a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8((offset - kShortSize) & 0xFF); 1259a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1260a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 1261a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x80 + condition); 1262a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitInt32(offset - kLongSize); 1263a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1264a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1265a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 1266a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x80 + condition); 1267a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitLabelLink(label); 1268a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1269a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1270a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1271a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::jmp(Register reg) { 1273a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1274a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xFF); 1275a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitRegisterOperand(4, reg); 1276a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1277a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12787caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogersvoid X86Assembler::jmp(const Address& address) { 12797caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers AssemblerBuffer::EnsureCapacity ensured(&buffer_); 12807caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers EmitUint8(0xFF); 12817caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers EmitOperand(4, address); 12827caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers} 1283a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 12842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::jmp(Label* label) { 1285a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1286a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (label->IsBound()) { 1287a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const int kShortSize = 2; 1288a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const int kLongSize = 5; 1289a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int offset = label->Position() - buffer_.Size(); 1290a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_LE(offset, 0); 1291a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (IsInt(8, offset - kShortSize)) { 1292a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xEB); 1293a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8((offset - kShortSize) & 0xFF); 1294a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1295a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xE9); 1296a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitInt32(offset - kLongSize); 1297a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1298a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1299a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xE9); 1300a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitLabelLink(label); 1301a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1302a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1303a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1304a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 13052c8f653c98d658419f464b6147c10e11a664d2e6Ian RogersX86Assembler* X86Assembler::lock() { 1306a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1307a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xF0); 13080d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers return this; 1309a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1310a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1311a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 13122c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpxchgl(const Address& address, Register reg) { 1313a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1314a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x0F); 1315a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xB1); 1316a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitOperand(reg, address); 1317a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1318a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 131979ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughesvoid X86Assembler::mfence() { 132079ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes AssemblerBuffer::EnsureCapacity ensured(&buffer_); 132179ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes EmitUint8(0x0F); 132279ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes EmitUint8(0xAE); 132379ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes EmitUint8(0xF0); 132479ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes} 132579ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes 13262c8f653c98d658419f464b6147c10e11a664d2e6Ian RogersX86Assembler* X86Assembler::fs() { 1327b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers // TODO: fs is a prefix and not an instruction 1328b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1329b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers EmitUint8(0x64); 13300d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers return this; 1331b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1332a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1333befbd5731ecca08f08780ee28a913d08ffb14656Ian RogersX86Assembler* X86Assembler::gs() { 1334befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers // TODO: fs is a prefix and not an instruction 1335befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1336befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers EmitUint8(0x65); 1337befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers return this; 1338befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers} 1339befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers 13402c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::AddImmediate(Register reg, const Immediate& imm) { 1341a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int value = imm.value(); 1342a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (value > 0) { 1343a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (value == 1) { 1344a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro incl(reg); 1345a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else if (value != 0) { 1346a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro addl(reg, imm); 1347a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1348a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else if (value < 0) { 1349a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro value = -value; 1350a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (value == 1) { 1351a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro decl(reg); 1352a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else if (value != 0) { 1353a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro subl(reg, Immediate(value)); 1354a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1355a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1356a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1357a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1358a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1359647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillainvoid X86Assembler::LoadLongConstant(XmmRegister dst, int64_t value) { 1360647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain // TODO: Need to have a code constants table. 1361647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain pushl(Immediate(High32Bits(value))); 1362647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain pushl(Immediate(Low32Bits(value))); 1363647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain movsd(dst, Address(ESP, 0)); 1364647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain addl(ESP, Immediate(2 * sizeof(int32_t))); 1365647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain} 1366647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain 1367647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain 13682c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::LoadDoubleConstant(XmmRegister dst, double value) { 1369a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // TODO: Need to have a code constants table. 1370a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int64_t constant = bit_cast<int64_t, double>(value); 1371647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain LoadLongConstant(dst, constant); 1372a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1373a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1374a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 13752c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::FloatNegate(XmmRegister f) { 1376a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const struct { 1377a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint32_t a; 1378a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint32_t b; 1379a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint32_t c; 1380a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint32_t d; 1381a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } float_negate_constant __attribute__((aligned(16))) = 1382a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro { 0x80000000, 0x00000000, 0x80000000, 0x00000000 }; 138313735955f39b3b304c37d2b2840663c131262c18Ian Rogers xorps(f, Address::Absolute(reinterpret_cast<uintptr_t>(&float_negate_constant))); 1384a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1385a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1386a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 13872c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::DoubleNegate(XmmRegister d) { 1388a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const struct { 1389a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint64_t a; 1390a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint64_t b; 1391a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } double_negate_constant __attribute__((aligned(16))) = 1392a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro {0x8000000000000000LL, 0x8000000000000000LL}; 139313735955f39b3b304c37d2b2840663c131262c18Ian Rogers xorpd(d, Address::Absolute(reinterpret_cast<uintptr_t>(&double_negate_constant))); 1394a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1395a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1396a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 13972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::DoubleAbs(XmmRegister reg) { 1398a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro static const struct { 1399a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint64_t a; 1400a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro uint64_t b; 1401a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } double_abs_constant __attribute__((aligned(16))) = 1402a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro {0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL}; 140313735955f39b3b304c37d2b2840663c131262c18Ian Rogers andpd(reg, Address::Absolute(reinterpret_cast<uintptr_t>(&double_abs_constant))); 1404a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1405a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1406a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 14072c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Align(int alignment, int offset) { 1408a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(IsPowerOfTwo(alignment)); 1409a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // Emit nop instruction until the real position is aligned. 1410a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro while (((offset + buffer_.GetPosition()) & (alignment-1)) != 0) { 1411a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro nop(); 1412a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1413a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1414a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1415a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 14162c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Bind(Label* label) { 1417a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int bound = buffer_.Size(); 1418a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(!label->IsBound()); // Labels can only be bound once. 1419a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro while (label->IsLinked()) { 1420a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int position = label->LinkPosition(); 1421a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int next = buffer_.Load<int32_t>(position); 1422a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro buffer_.Store<int32_t>(position, bound - (position + 4)); 1423a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro label->position_ = next; 1424a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1425a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro label->BindTo(bound); 1426a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1427a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1428a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 142944fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitOperand(int reg_or_opcode, const Operand& operand) { 143044fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers CHECK_GE(reg_or_opcode, 0); 143144fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers CHECK_LT(reg_or_opcode, 8); 1432a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro const int length = operand.length_; 1433a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_GT(length, 0); 143444fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers // Emit the ModRM byte updated with the given reg value. 1435a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_EQ(operand.encoding_[0] & 0x38, 0); 143644fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitUint8(operand.encoding_[0] + (reg_or_opcode << 3)); 1437a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // Emit the rest of the encoded operand. 1438a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro for (int i = 1; i < length; i++) { 1439a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(operand.encoding_[i]); 1440a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1441a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1442a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1443a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 14442c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::EmitImmediate(const Immediate& imm) { 1445a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitInt32(imm.value()); 1446a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1447a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1448a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 144944fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitComplex(int reg_or_opcode, 14502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers const Operand& operand, 14512c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers const Immediate& immediate) { 145244fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers CHECK_GE(reg_or_opcode, 0); 145344fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers CHECK_LT(reg_or_opcode, 8); 1454a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (immediate.is_int8()) { 1455a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // Use sign-extended 8-bit immediate. 1456a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x83); 145744fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitOperand(reg_or_opcode, operand); 1458a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(immediate.value() & 0xFF); 1459a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else if (operand.IsRegister(EAX)) { 1460a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro // Use short form if the destination is eax. 146144fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitUint8(0x05 + (reg_or_opcode << 3)); 1462a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(immediate); 1463a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1464a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0x81); 146544fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitOperand(reg_or_opcode, operand); 1466a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitImmediate(immediate); 1467a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1468a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1469a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1470a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 14712c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::EmitLabel(Label* label, int instruction_size) { 1472a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (label->IsBound()) { 1473a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int offset = label->Position() - buffer_.Size(); 1474a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_LE(offset, 0); 1475a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitInt32(offset - instruction_size); 1476a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1477a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitLabelLink(label); 1478a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1479a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1480a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1481a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 14822c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::EmitLabelLink(Label* label) { 1483a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(!label->IsBound()); 1484a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro int position = buffer_.Size(); 1485a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitInt32(label->position_); 1486a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro label->LinkTo(position); 1487a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1488a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1489a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 149044fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitGenericShift(int reg_or_opcode, 14912c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers Register reg, 14922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers const Immediate& imm) { 1493a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1494a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK(imm.is_int8()); 1495a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro if (imm.value() == 1) { 1496a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD1); 149744fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitOperand(reg_or_opcode, Operand(reg)); 1498a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } else { 1499a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xC1); 150044fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitOperand(reg_or_opcode, Operand(reg)); 1501a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(imm.value() & 0xFF); 1502a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro } 1503a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1504a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1505a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 150644fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitGenericShift(int reg_or_opcode, 15072c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers Register operand, 15082c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers Register shifter) { 1509a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro AssemblerBuffer::EnsureCapacity ensured(&buffer_); 1510a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro CHECK_EQ(shifter, ECX); 1511a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro EmitUint8(0xD3); 151244fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers EmitOperand(reg_or_opcode, Operand(operand)); 1513a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro} 1514a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro 1515547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shenvoid X86Assembler::InitializeFrameDescriptionEntry() { 1516e3ea83811d47152c00abea24a9b420651a33b496Yevgeny Rouban WriteFDEHeader(&cfi_info_, false /* is_64bit */); 1517547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen} 1518547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 1519547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shenvoid X86Assembler::FinalizeFrameDescriptionEntry() { 1520e3ea83811d47152c00abea24a9b420651a33b496Yevgeny Rouban WriteFDEAddressRange(&cfi_info_, buffer_.Size(), false /* is_64bit */); 1521547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen PadCFI(&cfi_info_); 1522e3ea83811d47152c00abea24a9b420651a33b496Yevgeny Rouban WriteCFILength(&cfi_info_, false /* is_64bit */); 1523547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen} 1524547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 1525790a6b7312979513710c366b411ba6791ddf78c2Ian Rogersconstexpr size_t kFramePointerSize = 4; 1526790a6b7312979513710c366b411ba6791ddf78c2Ian Rogers 15272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::BuildFrame(size_t frame_size, ManagedRegister method_reg, 1528b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers const std::vector<ManagedRegister>& spill_regs, 1529fca82208f7128fcda09b6a4743199308332558a2Dmitry Petrochenko const ManagedRegisterEntrySpills& entry_spills) { 1530547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_cfa_offset_ = kFramePointerSize; // Only return address on stack 1531547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_pc_ = buffer_.Size(); // Nothing emitted yet 1532547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DCHECK_EQ(cfi_pc_, 0U); 1533547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 1534547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen uint32_t reg_offset = 1; 153506b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes CHECK_ALIGNED(frame_size, kStackAlignment); 1536703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao for (int i = spill_regs.size() - 1; i >= 0; --i) { 1537703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao pushl(spill_regs.at(i).AsX86().AsCpuRegister()); 1538547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 1539547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_advance_loc 1540547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_advance_loc(&cfi_info_, buffer_.Size() - cfi_pc_); 1541547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_pc_ = buffer_.Size(); 1542547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_def_cfa_offset 1543547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_cfa_offset_ += kFramePointerSize; 1544547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_def_cfa_offset(&cfi_info_, cfi_cfa_offset_); 1545547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_offset reg offset 1546547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen reg_offset++; 1547547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_offset(&cfi_info_, spill_regs.at(i).AsX86().DWARFRegId(), reg_offset); 1548703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao } 1549547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 1550b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers // return address then method on stack 1551547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen int32_t adjust = frame_size - (spill_regs.size() * kFramePointerSize) - 1552547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen sizeof(StackReference<mirror::ArtMethod>) /*method*/ - 1553547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen kFramePointerSize /*return address*/; 1554547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen addl(ESP, Immediate(-adjust)); 1555547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_advance_loc 1556547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_advance_loc(&cfi_info_, buffer_.Size() - cfi_pc_); 1557547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_pc_ = buffer_.Size(); 1558547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_def_cfa_offset 1559547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_cfa_offset_ += adjust; 1560547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_def_cfa_offset(&cfi_info_, cfi_cfa_offset_); 1561547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 15622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers pushl(method_reg.AsX86().AsCpuRegister()); 1563547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_advance_loc 1564547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_advance_loc(&cfi_info_, buffer_.Size() - cfi_pc_); 1565547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_pc_ = buffer_.Size(); 1566547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_def_cfa_offset 1567547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_cfa_offset_ += kFramePointerSize; 1568547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_def_cfa_offset(&cfi_info_, cfi_cfa_offset_); 1569547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen 1570b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers for (size_t i = 0; i < entry_spills.size(); ++i) { 1571cf4035a4c41ccfcc3e89a0cee25f5218a11b0705Andreas Gampe movl(Address(ESP, frame_size + sizeof(StackReference<mirror::ArtMethod>) + 1572cf4035a4c41ccfcc3e89a0cee25f5218a11b0705Andreas Gampe (i * kFramePointerSize)), 1573b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers entry_spills.at(i).AsX86().AsCpuRegister()); 1574b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers } 1575b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1576b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 15772c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::RemoveFrame(size_t frame_size, 15780d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers const std::vector<ManagedRegister>& spill_regs) { 157906b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes CHECK_ALIGNED(frame_size, kStackAlignment); 1580cf4035a4c41ccfcc3e89a0cee25f5218a11b0705Andreas Gampe addl(ESP, Immediate(frame_size - (spill_regs.size() * kFramePointerSize) - 1581cf4035a4c41ccfcc3e89a0cee25f5218a11b0705Andreas Gampe sizeof(StackReference<mirror::ArtMethod>))); 1582703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao for (size_t i = 0; i < spill_regs.size(); ++i) { 1583703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao popl(spill_regs.at(i).AsX86().AsCpuRegister()); 1584703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao } 1585b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers ret(); 1586b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1587b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 15882c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::IncreaseFrameSize(size_t adjust) { 158906b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes CHECK_ALIGNED(adjust, kStackAlignment); 1590b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers addl(ESP, Immediate(-adjust)); 1591547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_advance_loc 1592547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_advance_loc(&cfi_info_, buffer_.Size() - cfi_pc_); 1593547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_pc_ = buffer_.Size(); 1594547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen // DW_CFA_def_cfa_offset 1595547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen cfi_cfa_offset_ += adjust; 1596547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen DW_CFA_def_cfa_offset(&cfi_info_, cfi_cfa_offset_); 1597b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1598b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 15992c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::DecreaseFrameSize(size_t adjust) { 160006b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes CHECK_ALIGNED(adjust, kStackAlignment); 1601b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers addl(ESP, Immediate(adjust)); 1602b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1603b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 16042c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Store(FrameOffset offs, ManagedRegister msrc, size_t size) { 16052c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister src = msrc.AsX86(); 160645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers if (src.IsNoRegister()) { 160745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers CHECK_EQ(0u, size); 160845a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else if (src.IsCpuRegister()) { 1609b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK_EQ(4u, size); 1610b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movl(Address(ESP, offs), src.AsCpuRegister()); 16119b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers } else if (src.IsRegisterPair()) { 16129b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers CHECK_EQ(8u, size); 16139b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers movl(Address(ESP, offs), src.AsRegisterPairLow()); 16149b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers movl(Address(ESP, FrameOffset(offs.Int32Value()+4)), 16159b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers src.AsRegisterPairHigh()); 161645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else if (src.IsX87Register()) { 161745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers if (size == 4) { 161845a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers fstps(Address(ESP, offs)); 161945a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else { 162045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers fstpl(Address(ESP, offs)); 162145a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } 162245a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else { 162345a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers CHECK(src.IsXmmRegister()); 1624b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers if (size == 4) { 1625b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movss(Address(ESP, offs), src.AsXmmRegister()); 1626b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } else { 1627b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movsd(Address(ESP, offs), src.AsXmmRegister()); 1628b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1629b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1630b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1631b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 16322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::StoreRef(FrameOffset dest, ManagedRegister msrc) { 16332c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister src = msrc.AsX86(); 1634b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(src.IsCpuRegister()); 1635b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movl(Address(ESP, dest), src.AsCpuRegister()); 1636b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1637b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 16382c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::StoreRawPtr(FrameOffset dest, ManagedRegister msrc) { 16392c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister src = msrc.AsX86(); 1640df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers CHECK(src.IsCpuRegister()); 1641df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers movl(Address(ESP, dest), src.AsCpuRegister()); 1642df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers} 1643df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers 16442c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::StoreImmediateToFrame(FrameOffset dest, uint32_t imm, 16452c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister) { 16462c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers movl(Address(ESP, dest), Immediate(imm)); 16472c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers} 16482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 1649dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::StoreImmediateToThread32(ThreadOffset<4> dest, uint32_t imm, 16502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister) { 16512c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers fs()->movl(Address::Absolute(dest), Immediate(imm)); 16522c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers} 16532c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers 1654dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::StoreStackOffsetToThread32(ThreadOffset<4> thr_offs, 16552c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers FrameOffset fr_offs, 16562c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch) { 16572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 1658b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(scratch.IsCpuRegister()); 16592c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers leal(scratch.AsCpuRegister(), Address(ESP, fr_offs)); 16602c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers fs()->movl(Address::Absolute(thr_offs), scratch.AsCpuRegister()); 1661b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1662b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 1663dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::StoreStackPointerToThread32(ThreadOffset<4> thr_offs) { 16642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers fs()->movl(Address::Absolute(thr_offs), ESP); 1665b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1666b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 16671bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::StoreSpanning(FrameOffset /*dst*/, ManagedRegister /*src*/, 16681bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughes FrameOffset /*in_off*/, ManagedRegister /*scratch*/) { 16692c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers UNIMPLEMENTED(FATAL); // this case only currently exists for ARM 1670b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1671b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 16722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Load(ManagedRegister mdest, FrameOffset src, size_t size) { 16732c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister dest = mdest.AsX86(); 167445a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers if (dest.IsNoRegister()) { 167545a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers CHECK_EQ(0u, size); 167645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else if (dest.IsCpuRegister()) { 1677b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK_EQ(4u, size); 1678b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movl(dest.AsCpuRegister(), Address(ESP, src)); 16799b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers } else if (dest.IsRegisterPair()) { 16809b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers CHECK_EQ(8u, size); 16819b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers movl(dest.AsRegisterPairLow(), Address(ESP, src)); 16829b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers movl(dest.AsRegisterPairHigh(), Address(ESP, FrameOffset(src.Int32Value()+4))); 168345a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else if (dest.IsX87Register()) { 168445a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers if (size == 4) { 168545a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers flds(Address(ESP, src)); 168645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else { 168745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers fldl(Address(ESP, src)); 168845a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } 1689b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } else { 169045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers CHECK(dest.IsXmmRegister()); 169145a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers if (size == 4) { 169245a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers movss(dest.AsXmmRegister(), Address(ESP, src)); 169345a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } else { 169445a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers movsd(dest.AsXmmRegister(), Address(ESP, src)); 169545a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers } 1696b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1697b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1698b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 1699dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::LoadFromThread32(ManagedRegister mdest, ThreadOffset<4> src, size_t size) { 17005a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers X86ManagedRegister dest = mdest.AsX86(); 17015a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers if (dest.IsNoRegister()) { 17025a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK_EQ(0u, size); 17035a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } else if (dest.IsCpuRegister()) { 17045a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK_EQ(4u, size); 17055a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers fs()->movl(dest.AsCpuRegister(), Address::Absolute(src)); 17065a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } else if (dest.IsRegisterPair()) { 17075a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK_EQ(8u, size); 17085a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers fs()->movl(dest.AsRegisterPairLow(), Address::Absolute(src)); 1709dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers fs()->movl(dest.AsRegisterPairHigh(), Address::Absolute(ThreadOffset<4>(src.Int32Value()+4))); 17105a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } else if (dest.IsX87Register()) { 17115a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers if (size == 4) { 17125a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers fs()->flds(Address::Absolute(src)); 17135a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } else { 17145a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers fs()->fldl(Address::Absolute(src)); 17155a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } 17165a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } else { 17175a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK(dest.IsXmmRegister()); 17185a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers if (size == 4) { 17195a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers fs()->movss(dest.AsXmmRegister(), Address::Absolute(src)); 17205a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } else { 17215a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers fs()->movsd(dest.AsXmmRegister(), Address::Absolute(src)); 17225a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } 17235a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers } 17245a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers} 17255a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers 17262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::LoadRef(ManagedRegister mdest, FrameOffset src) { 17272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister dest = mdest.AsX86(); 1728b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(dest.IsCpuRegister()); 1729b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movl(dest.AsCpuRegister(), Address(ESP, src)); 1730b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1731b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 17322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::LoadRef(ManagedRegister mdest, ManagedRegister base, 17332c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers MemberOffset offs) { 17342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister dest = mdest.AsX86(); 1735b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(dest.IsCpuRegister() && dest.IsCpuRegister()); 17362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers movl(dest.AsCpuRegister(), Address(base.AsX86().AsCpuRegister(), offs)); 1737e63a745f26fec5a5b4162fc83f6e88a1f696c30cHiroshi Yamauchi if (kPoisonHeapReferences) { 1738e63a745f26fec5a5b4162fc83f6e88a1f696c30cHiroshi Yamauchi negl(dest.AsCpuRegister()); 1739e63a745f26fec5a5b4162fc83f6e88a1f696c30cHiroshi Yamauchi } 1740a04d397b990ee7d3ce120e317c19fb4409d80d57Ian Rogers} 1741a04d397b990ee7d3ce120e317c19fb4409d80d57Ian Rogers 17422c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::LoadRawPtr(ManagedRegister mdest, ManagedRegister base, 17432c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers Offset offs) { 17442c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister dest = mdest.AsX86(); 1745a04d397b990ee7d3ce120e317c19fb4409d80d57Ian Rogers CHECK(dest.IsCpuRegister() && dest.IsCpuRegister()); 17462c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers movl(dest.AsCpuRegister(), Address(base.AsX86().AsCpuRegister(), offs)); 1747b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1748b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 1749dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::LoadRawPtrFromThread32(ManagedRegister mdest, 1750dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers ThreadOffset<4> offs) { 17512c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister dest = mdest.AsX86(); 1752b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(dest.IsCpuRegister()); 17530d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers fs()->movl(dest.AsCpuRegister(), Address::Absolute(offs)); 1754b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1755b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 175658136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhaovoid X86Assembler::SignExtend(ManagedRegister mreg, size_t size) { 175758136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao X86ManagedRegister reg = mreg.AsX86(); 175858136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao CHECK(size == 1 || size == 2) << size; 175958136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao CHECK(reg.IsCpuRegister()) << reg; 176058136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao if (size == 1) { 176158136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao movsxb(reg.AsCpuRegister(), reg.AsByteRegister()); 176258136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao } else { 176358136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao movsxw(reg.AsCpuRegister(), reg.AsCpuRegister()); 176458136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao } 176558136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao} 176658136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao 1767cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhaovoid X86Assembler::ZeroExtend(ManagedRegister mreg, size_t size) { 1768cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao X86ManagedRegister reg = mreg.AsX86(); 1769cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao CHECK(size == 1 || size == 2) << size; 1770cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao CHECK(reg.IsCpuRegister()) << reg; 1771cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao if (size == 1) { 1772cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao movzxb(reg.AsCpuRegister(), reg.AsByteRegister()); 1773cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao } else { 1774cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao movzxw(reg.AsCpuRegister(), reg.AsCpuRegister()); 1775cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao } 1776cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao} 1777cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao 1778b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogersvoid X86Assembler::Move(ManagedRegister mdest, ManagedRegister msrc, size_t size) { 17792c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister dest = mdest.AsX86(); 17802c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister src = msrc.AsX86(); 17812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers if (!dest.Equals(src)) { 17822c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers if (dest.IsCpuRegister() && src.IsCpuRegister()) { 17832c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers movl(dest.AsCpuRegister(), src.AsCpuRegister()); 1784b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers } else if (src.IsX87Register() && dest.IsXmmRegister()) { 1785b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers // Pass via stack and pop X87 register 1786b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers subl(ESP, Immediate(16)); 1787b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers if (size == 4) { 1788b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers CHECK_EQ(src.AsX87Register(), ST0); 1789b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers fstps(Address(ESP, 0)); 1790b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers movss(dest.AsXmmRegister(), Address(ESP, 0)); 1791b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers } else { 1792b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers CHECK_EQ(src.AsX87Register(), ST0); 1793b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers fstpl(Address(ESP, 0)); 1794b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers movsd(dest.AsXmmRegister(), Address(ESP, 0)); 1795b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers } 1796b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers addl(ESP, Immediate(16)); 17972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers } else { 17982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers // TODO: x87, SSE 17992c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers UNIMPLEMENTED(FATAL) << ": Move " << dest << ", " << src; 18002c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers } 18012c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers } 1802b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1803b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 18042c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::CopyRef(FrameOffset dest, FrameOffset src, 18052c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch) { 18062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 1807b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(scratch.IsCpuRegister()); 18082c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers movl(scratch.AsCpuRegister(), Address(ESP, src)); 18092c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers movl(Address(ESP, dest), scratch.AsCpuRegister()); 1810b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1811b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 1812dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::CopyRawPtrFromThread32(FrameOffset fr_offs, 1813dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers ThreadOffset<4> thr_offs, 18142c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch) { 18152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 1816b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(scratch.IsCpuRegister()); 18172c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers fs()->movl(scratch.AsCpuRegister(), Address::Absolute(thr_offs)); 18182c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers Store(fr_offs, scratch, 4); 181945a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers} 182045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers 1821dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::CopyRawPtrToThread32(ThreadOffset<4> thr_offs, 18222c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers FrameOffset fr_offs, 18232c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch) { 18242c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 18252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers CHECK(scratch.IsCpuRegister()); 18262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers Load(scratch, fr_offs, 4); 18272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers fs()->movl(Address::Absolute(thr_offs), scratch.AsCpuRegister()); 1828b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1829b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 18302c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Copy(FrameOffset dest, FrameOffset src, 18312c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch, 18322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers size_t size) { 18332c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 1834b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers if (scratch.IsCpuRegister() && size == 8) { 1835b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Load(scratch, src, 4); 1836b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Store(dest, scratch, 4); 1837b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Load(scratch, FrameOffset(src.Int32Value() + 4), 4); 1838b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Store(FrameOffset(dest.Int32Value() + 4), scratch, 4); 1839b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } else { 1840b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Load(scratch, src, size); 1841b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Store(dest, scratch, size); 1842b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1843b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1844b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 18451bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::Copy(FrameOffset /*dst*/, ManagedRegister /*src_base*/, Offset /*src_offset*/, 18461bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughes ManagedRegister /*scratch*/, size_t /*size*/) { 1847dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers UNIMPLEMENTED(FATAL); 1848dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers} 1849dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers 18505a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogersvoid X86Assembler::Copy(ManagedRegister dest_base, Offset dest_offset, FrameOffset src, 18515a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers ManagedRegister scratch, size_t size) { 18525a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK(scratch.IsNoRegister()); 18535a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK_EQ(size, 4u); 18545a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers pushl(Address(ESP, src)); 18555a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers popl(Address(dest_base.AsX86().AsCpuRegister(), dest_offset)); 18565a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers} 18575a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers 1858dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogersvoid X86Assembler::Copy(FrameOffset dest, FrameOffset src_base, Offset src_offset, 1859dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers ManagedRegister mscratch, size_t size) { 1860dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers Register scratch = mscratch.AsX86().AsCpuRegister(); 1861dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers CHECK_EQ(size, 4u); 1862dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers movl(scratch, Address(ESP, src_base)); 1863dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers movl(scratch, Address(scratch, src_offset)); 1864dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers movl(Address(ESP, dest), scratch); 1865dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers} 1866dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers 18675a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogersvoid X86Assembler::Copy(ManagedRegister dest, Offset dest_offset, 18685a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers ManagedRegister src, Offset src_offset, 18695a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers ManagedRegister scratch, size_t size) { 18705a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK_EQ(size, 4u); 18715a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK(scratch.IsNoRegister()); 18725a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers pushl(Address(src.AsX86().AsCpuRegister(), src_offset)); 18735a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers popl(Address(dest.AsX86().AsCpuRegister(), dest_offset)); 18745a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers} 18755a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers 18765a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogersvoid X86Assembler::Copy(FrameOffset dest, Offset dest_offset, FrameOffset src, Offset src_offset, 18775a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers ManagedRegister mscratch, size_t size) { 1878dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers Register scratch = mscratch.AsX86().AsCpuRegister(); 1879dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers CHECK_EQ(size, 4u); 18805a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers CHECK_EQ(dest.Int32Value(), src.Int32Value()); 18815a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers movl(scratch, Address(ESP, src)); 18825a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers pushl(Address(scratch, src_offset)); 1883dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers popl(Address(scratch, dest_offset)); 1884dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers} 1885dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers 1886e5de95b3f9609e02fefd7cda7b21f30c9412eb4cIan Rogersvoid X86Assembler::MemoryBarrier(ManagedRegister) { 188779ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes mfence(); 1888e5de95b3f9609e02fefd7cda7b21f30c9412eb4cIan Rogers} 1889e5de95b3f9609e02fefd7cda7b21f30c9412eb4cIan Rogers 1890eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartiervoid X86Assembler::CreateHandleScopeEntry(ManagedRegister mout_reg, 1891eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier FrameOffset handle_scope_offset, 18922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister min_reg, bool null_allowed) { 18932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister out_reg = mout_reg.AsX86(); 18942c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister in_reg = min_reg.AsX86(); 1895b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(in_reg.IsCpuRegister()); 1896b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(out_reg.IsCpuRegister()); 1897408f79aeb676251ba35667a64e86c20638d7cb0bIan Rogers VerifyObject(in_reg, null_allowed); 1898b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers if (null_allowed) { 1899b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Label null_arg; 1900b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers if (!out_reg.Equals(in_reg)) { 1901b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers xorl(out_reg.AsCpuRegister(), out_reg.AsCpuRegister()); 1902b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1903b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers testl(in_reg.AsCpuRegister(), in_reg.AsCpuRegister()); 190418c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes j(kZero, &null_arg); 1905eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier leal(out_reg.AsCpuRegister(), Address(ESP, handle_scope_offset)); 1906b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Bind(&null_arg); 1907b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } else { 1908eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier leal(out_reg.AsCpuRegister(), Address(ESP, handle_scope_offset)); 1909b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1910b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1911b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 1912eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartiervoid X86Assembler::CreateHandleScopeEntry(FrameOffset out_off, 1913eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier FrameOffset handle_scope_offset, 19142c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch, 19152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers bool null_allowed) { 19162c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 1917b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(scratch.IsCpuRegister()); 1918b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers if (null_allowed) { 1919b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Label null_arg; 1920eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier movl(scratch.AsCpuRegister(), Address(ESP, handle_scope_offset)); 1921b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers testl(scratch.AsCpuRegister(), scratch.AsCpuRegister()); 192218c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes j(kZero, &null_arg); 1923eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier leal(scratch.AsCpuRegister(), Address(ESP, handle_scope_offset)); 1924b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Bind(&null_arg); 1925b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } else { 1926eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier leal(scratch.AsCpuRegister(), Address(ESP, handle_scope_offset)); 1927b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1928b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Store(out_off, scratch, 4); 1929b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1930b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 1931eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier// Given a handle scope entry, load the associated reference. 1932eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartiervoid X86Assembler::LoadReferenceFromHandleScope(ManagedRegister mout_reg, 19332c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister min_reg) { 19342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister out_reg = mout_reg.AsX86(); 19352c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister in_reg = min_reg.AsX86(); 1936b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(out_reg.IsCpuRegister()); 1937b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(in_reg.IsCpuRegister()); 1938b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Label null_arg; 1939b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers if (!out_reg.Equals(in_reg)) { 1940b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers xorl(out_reg.AsCpuRegister(), out_reg.AsCpuRegister()); 1941b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers } 1942b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers testl(in_reg.AsCpuRegister(), in_reg.AsCpuRegister()); 194318c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes j(kZero, &null_arg); 1944b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers movl(out_reg.AsCpuRegister(), Address(in_reg.AsCpuRegister(), 0)); 1945b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers Bind(&null_arg); 1946b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1947b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 19481bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::VerifyObject(ManagedRegister /*src*/, bool /*could_be_null*/) { 1949b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers // TODO: not validating references 1950b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1951b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 19521bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::VerifyObject(FrameOffset /*src*/, bool /*could_be_null*/) { 1953b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers // TODO: not validating references 1954b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1955b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 19562c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Call(ManagedRegister mbase, Offset offset, ManagedRegister) { 19572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister base = mbase.AsX86(); 1958b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers CHECK(base.IsCpuRegister()); 1959df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers call(Address(base.AsCpuRegister(), offset.Int32Value())); 1960b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers // TODO: place reference map on call 1961b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} 1962b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers 196367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogersvoid X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister mscratch) { 196467375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers Register scratch = mscratch.AsX86().AsCpuRegister(); 196567375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers movl(scratch, Address(ESP, base)); 196667375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers call(Address(scratch, offset)); 1967e2d373e6e09c1df9a47e73a26254048adb31ce82Carl Shapiro} 1968e2d373e6e09c1df9a47e73a26254048adb31ce82Carl Shapiro 1969dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::CallFromThread32(ThreadOffset<4> offset, ManagedRegister /*mscratch*/) { 1970bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers fs()->call(Address::Absolute(offset)); 1971668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao} 1972668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao 19732c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::GetCurrentThread(ManagedRegister tr) { 19742c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers fs()->movl(tr.AsX86().AsCpuRegister(), 1975dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers Address::Absolute(Thread::SelfOffset<4>())); 1976668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao} 1977668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao 19782c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::GetCurrentThread(FrameOffset offset, 19792c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers ManagedRegister mscratch) { 19802c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86ManagedRegister scratch = mscratch.AsX86(); 1981dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers fs()->movl(scratch.AsCpuRegister(), Address::Absolute(Thread::SelfOffset<4>())); 1982668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao movl(Address(ESP, offset), scratch.AsCpuRegister()); 1983668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao} 1984668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao 198500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogersvoid X86Assembler::ExceptionPoll(ManagedRegister /*scratch*/, size_t stack_adjust) { 198600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers X86ExceptionSlowPath* slow = new X86ExceptionSlowPath(stack_adjust); 198745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers buffer_.EnqueueSlowPath(slow); 1988dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers fs()->cmpl(Address::Absolute(Thread::ExceptionOffset<4>()), Immediate(0)); 198918c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes j(kNotEqual, slow->Entry()); 199045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers} 19910d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers 19922c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86ExceptionSlowPath::Emit(Assembler *sasm) { 19932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers X86Assembler* sp_asm = down_cast<X86Assembler*>(sasm); 19940d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers#define __ sp_asm-> 19950d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers __ Bind(&entry_); 199620cde9033d51103f31e21436e88f80e1170c78adElliott Hughes // Note: the return value is dead 199700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers if (stack_adjust_ != 0) { // Fix up the frame. 199800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers __ DecreaseFrameSize(stack_adjust_); 199900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers } 200067375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers // Pass exception as argument in EAX 2001dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers __ fs()->movl(EAX, Address::Absolute(Thread::ExceptionOffset<4>())); 2002dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers __ fs()->call(Address::Absolute(QUICK_ENTRYPOINT_OFFSET(4, pDeliverException))); 200367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers // this call should never return 200467375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers __ int3(); 20050d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers#undef __ 200645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers} 200745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers 20082c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers} // namespace x86 2009b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers} // namespace art 2010