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"
23a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
246b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art {
252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersnamespace x86 {
26a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
27b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogersstd::ostream& operator<<(std::ostream& os, const XmmRegister& reg) {
28b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  return os << "XMM" << static_cast<int>(reg);
29b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
30b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
31b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogersstd::ostream& operator<<(std::ostream& os, const X87Register& reg) {
32b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  return os << "ST" << static_cast<int>(reg);
33b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
34a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
352c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::call(Register reg) {
36a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
37a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFF);
38a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(2, reg);
39a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
40a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
41a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
422c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::call(const Address& address) {
43a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
44a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFF);
45a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(2, address);
46a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
47a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
48a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
492c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::call(Label* label) {
50a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
51a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xE8);
52a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  static const int kSize = 5;
531cf95287364948689f6a1a320567acd7728e94a3Nicolas Geoffray  // Offset by one because we already have emitted the opcode.
541cf95287364948689f6a1a320567acd7728e94a3Nicolas Geoffray  EmitLabel(label, kSize - 1);
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
14809ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::bswapl(Register dst) {
14909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
15009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x0F);
15109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0xC8 + dst);
15209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
15309ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
1542c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxb(Register dst, ByteRegister src) {
155a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
156a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
157a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xB6);
158a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
159a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
160a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
161a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxb(Register dst, const Address& src) {
163a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
164a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
165a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xB6);
166a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
167a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
168a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
169a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1702c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxb(Register dst, ByteRegister src) {
171a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
172a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
173a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xBE);
174a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
175a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
176a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
177a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1782c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxb(Register dst, const Address& src) {
179a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
180a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
181a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xBE);
182a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
183a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
184a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
185a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1861bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::movb(Register /*dst*/, const Address& /*src*/) {
187a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  LOG(FATAL) << "Use movzxb or movsxb instead.";
188a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
189a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
190a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1912c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movb(const Address& dst, ByteRegister src) {
192a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
193a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x88);
194a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(src, dst);
195a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
196a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
197a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movb(const Address& dst, const Immediate& imm) {
199a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
200a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xC6);
201a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(EAX, dst);
202a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(imm.is_int8());
203a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(imm.value() & 0xFF);
204a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
205a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
206a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2072c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxw(Register dst, Register src) {
208a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
209a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
210a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xB7);
211a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
212a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
213a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
214a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movzxw(Register dst, const Address& src) {
216a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
217a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
218a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xB7);
219a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
220a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
221a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
222a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2232c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxw(Register dst, Register src) {
224a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
225a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
226a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xBF);
227a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
228a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
229a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
230a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2312c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsxw(Register dst, const Address& src) {
232a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
233a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
234a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xBF);
235a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
236a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
237a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
238a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2391bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::movw(Register /*dst*/, const Address& /*src*/) {
240a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  LOG(FATAL) << "Use movzxw or movsxw instead.";
241a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
242a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
243a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2442c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movw(const Address& dst, Register src) {
245a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
246a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperandSizeOverride();
247a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x89);
248a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(src, dst);
249a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
250a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
251a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
25226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffrayvoid X86Assembler::movw(const Address& dst, const Immediate& imm) {
25326a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
25426a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray  EmitOperandSizeOverride();
25526a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray  EmitUint8(0xC7);
25626a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray  EmitOperand(0, dst);
257b6e7206ad7a426adda9cfd649a4ef969607d79d6Nicolas Geoffray  CHECK(imm.is_uint16() || imm.is_int16());
25826a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray  EmitUint8(imm.value() & 0xFF);
25926a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray  EmitUint8(imm.value() >> 8);
26026a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray}
26126a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray
26226a25ef62a13f409f941aa39825a51b4d6f0f047Nicolas Geoffray
2632c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::leal(Register dst, const Address& src) {
264a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
265a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x8D);
266a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
267a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
268a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
269a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2702c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmovl(Condition condition, Register dst, Register src) {
271a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
272a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
273b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  EmitUint8(0x40 + condition);
274a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
275a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
276a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
277a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2785b4b898ed8725242ee6b7229b94467c3ea3054c8Nicolas Geoffrayvoid X86Assembler::setb(Condition condition, Register dst) {
279a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
280a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
281b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  EmitUint8(0x90 + condition);
2825b4b898ed8725242ee6b7229b94467c3ea3054c8Nicolas Geoffray  EmitOperand(0, Operand(dst));
2837fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray}
2847fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray
2857fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray
2867fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffrayvoid X86Assembler::movaps(XmmRegister dst, XmmRegister src) {
2877fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
2887fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray  EmitUint8(0x0F);
2897fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray  EmitUint8(0x28);
2907fb49da8ec62e8a10ed9419ade9f32c6b1174687Nicolas Geoffray  EmitXmmRegisterOperand(dst, src);
291a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
292a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
293a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
2942c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movss(XmmRegister dst, const Address& src) {
295a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
296a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
297a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
298a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x10);
299a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
300a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
301a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
302a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3032c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movss(const Address& dst, XmmRegister src) {
304a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
305a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
306a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
307a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x11);
308a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(src, dst);
309a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
310a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
311a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3122c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movss(XmmRegister dst, XmmRegister src) {
313a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
314a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
315a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
316a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x11);
317a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(src, dst);
318a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
319a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
320a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3212c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movd(XmmRegister dst, Register src) {
322a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
323a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x66);
324a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
325a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x6E);
326a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
327a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
328a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
329a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3302c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movd(Register dst, XmmRegister src) {
331a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
332a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x66);
333a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
334a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x7E);
335a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(src, Operand(dst));
336a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
337a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
338a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3392c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addss(XmmRegister dst, XmmRegister src) {
340a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
341a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
342a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
343a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x58);
344a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
345a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
346a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
347a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addss(XmmRegister dst, const Address& src) {
349a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
350a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
351a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
352a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x58);
353a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
354a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
355a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
356a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3572c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subss(XmmRegister dst, XmmRegister src) {
358a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
359a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
360a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
361a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5C);
362a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
363a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
364a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
365a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3662c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subss(XmmRegister dst, const Address& src) {
367a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
368a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
369a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
370a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5C);
371a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
372a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
373a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
374a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3752c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulss(XmmRegister dst, XmmRegister src) {
376a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
377a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
378a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
379a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x59);
380a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
381a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
382a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
383a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulss(XmmRegister dst, const Address& src) {
385a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
386a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
387a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
388a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x59);
389a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
390a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
391a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
392a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
3932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divss(XmmRegister dst, XmmRegister src) {
394a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
395a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
396a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
397a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5E);
398a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
399a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
400a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
401a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
4022c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divss(XmmRegister dst, const Address& src) {
403a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
404a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
405a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
406a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5E);
407a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
408a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
409a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
410a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
4112c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::flds(const Address& src) {
412a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
413a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
414a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(0, src);
415a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
416a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
417a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
41824f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendellvoid X86Assembler::fsts(const Address& dst) {
41924f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
42024f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xD9);
42124f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitOperand(2, dst);
42224f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell}
42324f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
42424f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
4252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fstps(const Address& dst) {
426a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
427a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
428a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(3, dst);
429a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
430a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
431a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
4322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsd(XmmRegister dst, const Address& src) {
433a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
434a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
435a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
436a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x10);
437a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
438a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
439a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
440a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
4412c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsd(const Address& dst, XmmRegister src) {
442a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
443a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
444a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
445a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x11);
446a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(src, dst);
447a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
448a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
449a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
4502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::movsd(XmmRegister dst, XmmRegister src) {
451a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
452a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
453a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
454a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x11);
455a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(src, dst);
456a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
457a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
458a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
459234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffrayvoid X86Assembler::movhpd(XmmRegister dst, const Address& src) {
460234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
461234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x66);
462234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x0F);
463234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x16);
464234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitOperand(dst, src);
465234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray}
466234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
467234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
468234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffrayvoid X86Assembler::movhpd(const Address& dst, XmmRegister src) {
469234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
470234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x66);
471234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x0F);
472234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x17);
473234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitOperand(src, dst);
474234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray}
475234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
476234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
477234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffrayvoid X86Assembler::psrldq(XmmRegister reg, const Immediate& shift_count) {
478234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  DCHECK(shift_count.is_uint8());
479234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
480234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
481234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x66);
482234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x0F);
483234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(0x73);
484234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitXmmRegisterOperand(3, reg);
485234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray  EmitUint8(shift_count.value());
486234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray}
487234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
488234d69d075d1608f80adb647f7935077b62b6376Nicolas Geoffray
48952c489645b6e9ae33623f1ec24143cde5444906eCalin Juravlevoid X86Assembler::psrlq(XmmRegister reg, const Immediate& shift_count) {
49052c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  DCHECK(shift_count.is_uint8());
49152c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle
49252c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
49352c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(0x66);
49452c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(0x0F);
49552c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(0x73);
49652c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitXmmRegisterOperand(2, reg);
49752c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(shift_count.value());
49852c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle}
49952c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle
50052c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle
50152c489645b6e9ae33623f1ec24143cde5444906eCalin Juravlevoid X86Assembler::punpckldq(XmmRegister dst, XmmRegister src) {
50252c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
50352c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(0x66);
50452c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(0x0F);
50552c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitUint8(0x62);
50652c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle  EmitXmmRegisterOperand(dst, src);
50752c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle}
50852c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle
50952c489645b6e9ae33623f1ec24143cde5444906eCalin Juravle
5102c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addsd(XmmRegister dst, XmmRegister src) {
511a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
512a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
513a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
514a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x58);
515a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
516a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
517a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
518a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addsd(XmmRegister dst, const Address& src) {
520a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
521a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
522a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
523a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x58);
524a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
525a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
526a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
527a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5282c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subsd(XmmRegister dst, XmmRegister src) {
529a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
530a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
531a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
532a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5C);
533a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
534a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
535a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
536a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subsd(XmmRegister dst, const Address& src) {
538a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
539a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
540a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
541a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5C);
542a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
543a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
544a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
545a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5462c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulsd(XmmRegister dst, XmmRegister src) {
547a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
548a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
549a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
550a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x59);
551a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
552a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
553a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
554a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5552c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mulsd(XmmRegister dst, const Address& src) {
556a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
557a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
558a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
559a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x59);
560a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
561a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
562a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
563a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divsd(XmmRegister dst, XmmRegister src) {
565a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
566a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
567a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
568a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5E);
569a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
570a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
571a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
572a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5732c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::divsd(XmmRegister dst, const Address& src) {
574a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
575a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
576a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
577a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5E);
578a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
579a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
580a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
581a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5822c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsi2ss(XmmRegister dst, Register src) {
583a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
584a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
585a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
586a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2A);
587a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
588a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
589a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
590a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
5912c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsi2sd(XmmRegister dst, Register src) {
592a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
593a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
594a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
595a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2A);
596a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
597a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
598a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
599a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6002c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtss2si(Register dst, XmmRegister src) {
601a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
602a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
603a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
604a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2D);
605a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
606a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
607a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
608a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6092c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtss2sd(XmmRegister dst, XmmRegister src) {
610a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
611a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
612a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
613a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5A);
614a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
615a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
616a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
617a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6182c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsd2si(Register dst, XmmRegister src) {
619a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
620a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
621a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
622a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2D);
623a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
624a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
625a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
626a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvttss2si(Register dst, XmmRegister src) {
628a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
629a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
630a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
631a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2C);
632a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
633a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
634a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
635a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvttsd2si(Register dst, XmmRegister src) {
637a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
638a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
639a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
640a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2C);
641a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
642a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
643a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
644a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6452c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtsd2ss(XmmRegister dst, XmmRegister src) {
646a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
647a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
648a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
649a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x5A);
650a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
651a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
652a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
653a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6542c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cvtdq2pd(XmmRegister dst, XmmRegister src) {
655a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
656a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
657a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
658a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xE6);
659a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
660a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
661a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
662a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6632c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::comiss(XmmRegister a, XmmRegister b) {
664a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
665a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
666a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2F);
667a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(a, b);
668a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
669a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
670a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
6712c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::comisd(XmmRegister a, XmmRegister b) {
672a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
673a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x66);
674a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
675a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2F);
676a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(a, b);
677a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
678a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
679a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
680ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravlevoid X86Assembler::ucomiss(XmmRegister a, XmmRegister b) {
681ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
682ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitUint8(0x0F);
683ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitUint8(0x2E);
684ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitXmmRegisterOperand(a, b);
685ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle}
686ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle
687ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle
688ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravlevoid X86Assembler::ucomisd(XmmRegister a, XmmRegister b) {
689ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
690ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitUint8(0x66);
691ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitUint8(0x0F);
692ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitUint8(0x2E);
693ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle  EmitXmmRegisterOperand(a, b);
694ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle}
695ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle
696ddb7df25af45d7cd19ed1138e537973735cc78a5Calin Juravle
697fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendellvoid X86Assembler::roundsd(XmmRegister dst, XmmRegister src, const Immediate& imm) {
698fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
699fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x66);
700fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x0F);
701fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x3A);
702fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x0B);
703fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitXmmRegisterOperand(dst, src);
704fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(imm.value());
705fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell}
706fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell
707fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell
708fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendellvoid X86Assembler::roundss(XmmRegister dst, XmmRegister src, const Immediate& imm) {
709fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
710fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x66);
711fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x0F);
712fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x3A);
713fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(0x0A);
714fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitXmmRegisterOperand(dst, src);
715fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell  EmitUint8(imm.value());
716fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell}
717fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell
718fb8d279bc011b31d0765dc7ca59afea324fd0d0cMark Mendell
7192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sqrtsd(XmmRegister dst, XmmRegister src) {
720a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
721a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
722a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
723a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x51);
724a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
725a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
726a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
727a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
7282c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sqrtss(XmmRegister dst, XmmRegister src) {
729a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
730a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF3);
731a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
732a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x51);
733a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
734a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
735a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
736a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
7372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorpd(XmmRegister dst, const Address& src) {
738a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
739a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x66);
740a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
741a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x57);
742a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
743a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
744a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
745a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
7462c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorpd(XmmRegister dst, XmmRegister src) {
747a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
748a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x66);
749a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
750a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x57);
751a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
752a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
753a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
754a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
75509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::andps(XmmRegister dst, XmmRegister src) {
75609ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
75709ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x0F);
75809ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x54);
75909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitXmmRegisterOperand(dst, src);
76009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
76109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
76209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
76309ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::andpd(XmmRegister dst, XmmRegister src) {
76409ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
76509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x66);
76609ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x0F);
76709ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x54);
76809ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitXmmRegisterOperand(dst, src);
76909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
77009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
77109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
77209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::orpd(XmmRegister dst, XmmRegister src) {
77309ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
77409ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x66);
77509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x0F);
77609ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x56);
77709ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitXmmRegisterOperand(dst, src);
77809ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
77909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
78009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
7812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorps(XmmRegister dst, const Address& src) {
782a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
783a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
784a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x57);
785a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
786a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
787a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
788a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
78909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::orps(XmmRegister dst, XmmRegister src) {
79009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
79109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x0F);
79209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x56);
79309ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitXmmRegisterOperand(dst, src);
79409ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
79509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
79609ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
7972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorps(XmmRegister dst, XmmRegister src) {
798a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
799a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
800a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x57);
801a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitXmmRegisterOperand(dst, src);
802a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
803a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
804a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
80509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::andps(XmmRegister dst, const Address& src) {
80609ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
80709ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x0F);
80809ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x54);
80909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitOperand(dst, src);
81009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
81109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
81209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
8132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::andpd(XmmRegister dst, const Address& src) {
814a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
815a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x66);
816a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
817a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x54);
818a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, src);
819a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
820a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
821a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
8222c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fldl(const Address& src) {
823a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
824a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xDD);
825a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(0, src);
826a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
827a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
828a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
82924f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendellvoid X86Assembler::fstl(const Address& dst) {
83024f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
83124f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xDD);
83224f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitOperand(2, dst);
83324f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell}
83424f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
83524f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
8362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fstpl(const Address& dst) {
837a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
838a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xDD);
839a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(3, dst);
840a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
841a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
842a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
84324f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendellvoid X86Assembler::fstsw() {
84424f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
84524f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0x9B);
84624f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xDF);
84724f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xE0);
84824f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell}
84924f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
85024f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
8512c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fnstcw(const Address& dst) {
852a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
853a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
854a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(7, dst);
855a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
856a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
857a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
8582c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fldcw(const Address& src) {
859a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
860a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
861a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(5, src);
862a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
863a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
864a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
8652c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fistpl(const Address& dst) {
866a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
867a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xDF);
868a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(7, dst);
869a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
870a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
871a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
8722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fistps(const Address& dst) {
873a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
874a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xDB);
875a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(3, dst);
876a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
877a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
878a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
8792c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fildl(const Address& src) {
880a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
881a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xDF);
882a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(5, src);
883a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
884a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
885a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
8860a18601f141d864a26d4b74ff5613e69ae411483Roland Levillainvoid X86Assembler::filds(const Address& src) {
8870a18601f141d864a26d4b74ff5613e69ae411483Roland Levillain  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
8880a18601f141d864a26d4b74ff5613e69ae411483Roland Levillain  EmitUint8(0xDB);
8890a18601f141d864a26d4b74ff5613e69ae411483Roland Levillain  EmitOperand(0, src);
8900a18601f141d864a26d4b74ff5613e69ae411483Roland Levillain}
8910a18601f141d864a26d4b74ff5613e69ae411483Roland Levillain
8920a18601f141d864a26d4b74ff5613e69ae411483Roland Levillain
8932c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fincstp() {
894a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
895a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
896a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
897a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
898a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
899a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9002c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::ffree(const Immediate& index) {
901a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK_LT(index.value(), 7);
902a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
903a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xDD);
904a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xC0 + index.value());
905a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
906a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
907a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9082c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fsin() {
909a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
910a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
911a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFE);
912a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
913a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
914a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fcos() {
916a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
917a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
918a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFF);
919a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
920a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
921a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9222c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::fptan() {
923a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
924a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD9);
925a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF2);
926a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
927a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
928a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
92924f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendellvoid X86Assembler::fucompp() {
93024f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
93124f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xDA);
93224f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xE9);
93324f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell}
93424f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
93524f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
93624f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendellvoid X86Assembler::fprem() {
93724f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
93824f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xD9);
93924f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell  EmitUint8(0xF8);
94024f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell}
94124f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
94224f2dfae084b2382c053f5d688fd6bb26cb8a328Mark Mendell
9432c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xchgl(Register dst, Register src) {
944a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
945a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x87);
946a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
947a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
948a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9493c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
9507caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogersvoid X86Assembler::xchgl(Register reg, const Address& address) {
9517caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
9527caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers  EmitUint8(0x87);
9537caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers  EmitOperand(reg, address);
9547caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers}
9557caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers
956a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9573c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffrayvoid X86Assembler::cmpw(const Address& address, const Immediate& imm) {
9583c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
9593c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  EmitUint8(0x66);
9603c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray  EmitComplex(7, address, imm);
9613c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray}
9623c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
9633c04974a90b0e03f4b509010bff49f0b2a3da57fNicolas Geoffray
9642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(Register reg, const Immediate& imm) {
965a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
966a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(7, Operand(reg), imm);
967a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
968a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
969a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9702c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(Register reg0, Register reg1) {
971a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
972a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x3B);
973a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg0, Operand(reg1));
974a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
975a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
976a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9772c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(Register reg, const Address& address) {
978a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
979a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x3B);
980a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
981a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
982a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
983a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(Register dst, Register src) {
985a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
986a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x03);
987a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(dst, src);
988a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
989a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
990a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9912c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(Register reg, const Address& address) {
992a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
993a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x03);
994a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
995a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
996a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
997a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
9982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(const Address& address, Register reg) {
999a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1000a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x39);
1001a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
1002a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1003a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1004a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10052c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpl(const Address& address, const Immediate& imm) {
1006a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1007a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(7, address, imm);
1008a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1009a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1010a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10112c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::testl(Register reg1, Register reg2) {
1012a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1013a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x85);
1014a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(reg1, reg2);
1015a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1016a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1017a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1018f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffrayvoid X86Assembler::testl(Register reg, const Address& address) {
1019f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1020f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray  EmitUint8(0x85);
1021f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray  EmitOperand(reg, address);
1022f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray}
1023f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray
1024f12feb8e0e857f2832545b3f28d31bad5a9d3903Nicolas Geoffray
10252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::testl(Register reg, const Immediate& immediate) {
1026a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1027a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  // For registers that have a byte variant (EAX, EBX, ECX, and EDX)
1028a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  // we only test the byte register to keep the encoding short.
1029a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (immediate.is_uint8() && reg < 4) {
1030a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    // Use zero-extended 8-bit immediate.
1031a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    if (reg == EAX) {
1032a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0xA8);
1033a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    } else {
1034a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0xF6);
1035a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0xC0 + reg);
1036a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    }
1037a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(immediate.value() & 0xFF);
1038a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else if (reg == EAX) {
1039a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    // Use short form if the destination is EAX.
1040a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0xA9);
1041a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitImmediate(immediate);
1042a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else {
1043a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0xF7);
1044a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitOperand(0, Operand(reg));
1045a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitImmediate(immediate);
1046a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1047a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1048a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1049a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10502c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::andl(Register dst, Register src) {
1051a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1052a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x23);
1053a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1054a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1055a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1056a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10579574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffrayvoid X86Assembler::andl(Register reg, const Address& address) {
10589574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
10599574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  EmitUint8(0x23);
10609574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  EmitOperand(reg, address);
10619574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray}
10629574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
10639574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
10642c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::andl(Register dst, const Immediate& imm) {
1065a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1066a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(4, Operand(dst), imm);
1067a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1068a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1069a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10702c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::orl(Register dst, Register src) {
1071a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1072a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0B);
1073a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1074a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1075a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1076a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10779574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffrayvoid X86Assembler::orl(Register reg, const Address& address) {
10789574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
10799574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  EmitUint8(0x0B);
10809574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  EmitOperand(reg, address);
10819574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray}
10829574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
10839574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
10842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::orl(Register dst, const Immediate& imm) {
1085a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1086a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(1, Operand(dst), imm);
1087a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1088a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1089a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10902c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::xorl(Register dst, Register src) {
1091a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1092a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x33);
1093a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1094a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1095a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
10969574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
10979574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffrayvoid X86Assembler::xorl(Register reg, const Address& address) {
10989574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
10999574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  EmitUint8(0x33);
11009574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray  EmitOperand(reg, address);
11019574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray}
11029574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
11039574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
1104b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffrayvoid X86Assembler::xorl(Register dst, const Immediate& imm) {
1105b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffray  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1106b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffray  EmitComplex(6, Operand(dst), imm);
1107b55f835d66a61e5da6fc1895ba5a0482868c9552Nicolas Geoffray}
1108a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11099574c4b5f5ef039d694ac12c97e25ca02eca83c0Nicolas Geoffray
11102c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(Register reg, const Immediate& imm) {
1111a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1112a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(0, Operand(reg), imm);
1113a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1114a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1115a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11162c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(const Address& address, Register reg) {
1117a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1118a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x01);
1119a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
1120a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1121a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1122a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11232c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::addl(const Address& address, const Immediate& imm) {
1124a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1125a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(0, address, imm);
1126a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1127a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1128a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11292c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::adcl(Register reg, const Immediate& imm) {
1130a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1131a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(2, Operand(reg), imm);
1132a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1133a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1134a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11352c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::adcl(Register dst, Register src) {
1136a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1137a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x13);
1138a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1139a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1140a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1141a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11422c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::adcl(Register dst, const Address& address) {
1143a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1144a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x13);
1145a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, address);
1146a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1147a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1148a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11492c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subl(Register dst, Register src) {
1150a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1151a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2B);
1152a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1153a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1154a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1155a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11562c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subl(Register reg, const Immediate& imm) {
1157a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1158a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(5, Operand(reg), imm);
1159a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1160a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1161a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::subl(Register reg, const Address& address) {
1163a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1164a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x2B);
1165a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
1166a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1167a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1168a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
116909ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::subl(const Address& address, Register reg) {
117009ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
117109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x29);
117209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitOperand(reg, address);
117309ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
117409ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
117509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
11762c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cdq() {
1177a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1178a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x99);
1179a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1180a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1181a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11822c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::idivl(Register reg) {
1183a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1184a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1185a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF8 | reg);
1186a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1187a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1188a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11892c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register dst, Register src) {
1190a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1191a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
1192a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xAF);
1193a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1194a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1195a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1196a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
11972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register reg, const Immediate& imm) {
1198a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1199a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x69);
1200a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, Operand(reg));
1201a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitImmediate(imm);
1202a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1203a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1204a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12052c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register reg, const Address& address) {
1206a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1207a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
1208a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xAF);
1209a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
1210a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1211a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1212a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(Register reg) {
1214a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1215a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1216a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(5, Operand(reg));
1217a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1218a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1219a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12202c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::imull(const Address& address) {
1221a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1222a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1223a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(5, address);
1224a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1225a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1226a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mull(Register reg) {
1228a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1229a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1230a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(4, Operand(reg));
1231a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1232a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1233a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::mull(const Address& address) {
1235a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1236a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1237a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(4, address);
1238a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1239a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1240a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12412c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sbbl(Register dst, Register src) {
1242a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1243a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x1B);
1244a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, Operand(src));
1245a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1246a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1247a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sbbl(Register reg, const Immediate& imm) {
1249a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1250a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitComplex(3, Operand(reg), imm);
1251a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1252a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1253a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12542c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sbbl(Register dst, const Address& address) {
1255a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1256a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x1B);
1257a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(dst, address);
1258a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1259a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1260a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
126109ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendellvoid X86Assembler::sbbl(const Address& address, Register src) {
126209ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
126309ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitUint8(0x19);
126409ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell  EmitOperand(src, address);
126509ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell}
126609ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
126709ed1a3125849ec6ac07cb886e3c502e1dcfada2Mark Mendell
12682c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::incl(Register reg) {
1269a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1270a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x40 + reg);
1271a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1272a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1273a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12742c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::incl(const Address& address) {
1275a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1276a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFF);
1277a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(0, address);
1278a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1279a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1280a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::decl(Register reg) {
1282a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1283a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x48 + reg);
1284a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1285a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1286a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12872c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::decl(const Address& address) {
1288a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1289a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFF);
1290a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(1, address);
1291a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1292a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1293a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12942c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shll(Register reg, const Immediate& imm) {
12957394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(4, Operand(reg), imm);
1296a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1297a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1298a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
12992c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shll(Register operand, Register shifter) {
13007394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(4, Operand(operand), shifter);
13017394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13027394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13037394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13047394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::shll(const Address& address, const Immediate& imm) {
13057394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(4, address, imm);
13067394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13077394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13087394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13097394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::shll(const Address& address, Register shifter) {
13107394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(4, address, shifter);
1311a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1312a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1313a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13142c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shrl(Register reg, const Immediate& imm) {
13157394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(5, Operand(reg), imm);
1316a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1317a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1318a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::shrl(Register operand, Register shifter) {
13207394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(5, Operand(operand), shifter);
13217394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13227394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13237394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13247394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::shrl(const Address& address, const Immediate& imm) {
13257394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(5, address, imm);
13267394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13277394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13287394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13297394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::shrl(const Address& address, Register shifter) {
13307394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(5, address, shifter);
1331a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1332a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1333a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sarl(Register reg, const Immediate& imm) {
13357394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(7, Operand(reg), imm);
1336a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1337a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1338a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13392c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::sarl(Register operand, Register shifter) {
13407394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(7, Operand(operand), shifter);
13417394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13427394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13437394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13447394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::sarl(const Address& address, const Immediate& imm) {
13457394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(7, address, imm);
13467394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13477394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13487394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13497394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::sarl(const Address& address, Register shifter) {
13507394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitGenericShift(7, address, shifter);
1351a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1352a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1353a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13549aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravlevoid X86Assembler::shld(Register dst, Register src, Register shifter) {
13559aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle  DCHECK_EQ(ECX, shifter);
1356a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1357a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
1358a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xA5);
1359a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(src, dst);
1360a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1361a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1362a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13637394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::shld(Register dst, Register src, const Immediate& imm) {
13647394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
13657394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitUint8(0x0F);
13667394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitUint8(0xA4);
13677394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitRegisterOperand(src, dst);
13687394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitUint8(imm.value() & 0xFF);
13697394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13707394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13717394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13729aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravlevoid X86Assembler::shrd(Register dst, Register src, Register shifter) {
13739aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle  DCHECK_EQ(ECX, shifter);
13749aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
13759aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle  EmitUint8(0x0F);
13769aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle  EmitUint8(0xAD);
13779aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle  EmitRegisterOperand(src, dst);
13789aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle}
13799aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle
13809aec02fc5df5518c16f1e5a9b6cb198a192db973Calin Juravle
13817394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendellvoid X86Assembler::shrd(Register dst, Register src, const Immediate& imm) {
13827394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
13837394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitUint8(0x0F);
13847394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitUint8(0xAC);
13857394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitRegisterOperand(src, dst);
13867394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitUint8(imm.value() & 0xFF);
13877394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell}
13887394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13897394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell
13902c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::negl(Register reg) {
1391a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1392a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1393a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(3, Operand(reg));
1394a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1395a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1396a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
13972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::notl(Register reg) {
1398a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1399a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF7);
1400a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD0 | reg);
1401a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1402a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1403a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14042c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::enter(const Immediate& imm) {
1405a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1406a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xC8);
1407a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(imm.is_uint16());
1408a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(imm.value() & 0xFF);
1409a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8((imm.value() >> 8) & 0xFF);
1410a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x00);
1411a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1412a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1413a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14142c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::leave() {
1415a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1416a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xC9);
1417a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1418a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1419a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14202c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::ret() {
1421a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1422a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xC3);
1423a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1424a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1425a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::ret(const Immediate& imm) {
1427a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1428a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xC2);
1429a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(imm.is_uint16());
1430a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(imm.value() & 0xFF);
1431a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8((imm.value() >> 8) & 0xFF);
1432a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1433a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1434a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1435a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::nop() {
1437a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1438a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x90);
1439a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1440a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1441a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14422c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::int3() {
1443a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1444a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xCC);
1445a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1446a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1447a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14482c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::hlt() {
1449a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1450a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF4);
1451a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1452a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1453a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14542c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::j(Condition condition, Label* label) {
1455a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1456a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (label->IsBound()) {
1457a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    static const int kShortSize = 2;
1458a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    static const int kLongSize = 6;
1459a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    int offset = label->Position() - buffer_.Size();
1460a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    CHECK_LE(offset, 0);
1461ab1eb0d1d047e3478ebb891e5259d2f1d1dd78bdAndreas Gampe    if (IsInt<8>(offset - kShortSize)) {
1462a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0x70 + condition);
1463a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8((offset - kShortSize) & 0xFF);
1464a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    } else {
1465a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0x0F);
1466a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0x80 + condition);
1467a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitInt32(offset - kLongSize);
1468a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    }
1469a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else {
1470a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0x0F);
1471a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0x80 + condition);
1472a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitLabelLink(label);
1473a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1474a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1475a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1476a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14772c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::jmp(Register reg) {
1478a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1479a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xFF);
1480a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitRegisterOperand(4, reg);
1481a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1482a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14837caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogersvoid X86Assembler::jmp(const Address& address) {
14847caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
14857caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers  EmitUint8(0xFF);
14867caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers  EmitOperand(4, address);
14877caad77632ae121c9f64c488e3f8f710e2c4813dIan Rogers}
1488a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
14892c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::jmp(Label* label) {
1490a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1491a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (label->IsBound()) {
1492a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    static const int kShortSize = 2;
1493a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    static const int kLongSize = 5;
1494a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    int offset = label->Position() - buffer_.Size();
1495a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    CHECK_LE(offset, 0);
1496ab1eb0d1d047e3478ebb891e5259d2f1d1dd78bdAndreas Gampe    if (IsInt<8>(offset - kShortSize)) {
1497a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0xEB);
1498a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8((offset - kShortSize) & 0xFF);
1499a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    } else {
1500a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitUint8(0xE9);
1501a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      EmitInt32(offset - kLongSize);
1502a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    }
1503a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else {
1504a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0xE9);
1505a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitLabelLink(label);
1506a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1507a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1508a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1509a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
151021030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampevoid X86Assembler::repne_scasw() {
151121030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
151221030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe  EmitUint8(0x66);
151321030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe  EmitUint8(0xF2);
151421030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe  EmitUint8(0xAF);
151521030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe}
151621030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe
151721030dd59b1e350f6f43de39e3c4ce0886ff539cAndreas Gampe
15182c8f653c98d658419f464b6147c10e11a664d2e6Ian RogersX86Assembler* X86Assembler::lock() {
1519a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1520a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xF0);
15210d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers  return this;
1522a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1523a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1524a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
15252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::cmpxchgl(const Address& address, Register reg) {
1526a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1527a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0x0F);
1528a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xB1);
1529a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitOperand(reg, address);
1530a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1531a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
153258d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell
153358d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendellvoid X86Assembler::cmpxchg8b(const Address& address) {
153458d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
153558d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell  EmitUint8(0x0F);
153658d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell  EmitUint8(0xC7);
153758d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell  EmitOperand(1, address);
153858d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell}
153958d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell
154058d25fd052e999a24734b0cf856a1563e3d1b2d0Mark Mendell
154179ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughesvoid X86Assembler::mfence() {
154279ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
154379ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes  EmitUint8(0x0F);
154479ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes  EmitUint8(0xAE);
154579ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes  EmitUint8(0xF0);
154679ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes}
154779ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes
15482c8f653c98d658419f464b6147c10e11a664d2e6Ian RogersX86Assembler* X86Assembler::fs() {
1549b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  // TODO: fs is a prefix and not an instruction
1550b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1551b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  EmitUint8(0x64);
15520d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers  return this;
1553b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1554a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1555befbd5731ecca08f08780ee28a913d08ffb14656Ian RogersX86Assembler* X86Assembler::gs() {
1556befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers  // TODO: fs is a prefix and not an instruction
1557befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1558befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers  EmitUint8(0x65);
1559befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers  return this;
1560befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers}
1561befbd5731ecca08f08780ee28a913d08ffb14656Ian Rogers
15622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::AddImmediate(Register reg, const Immediate& imm) {
1563a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  int value = imm.value();
1564a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (value > 0) {
1565a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    if (value == 1) {
1566a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      incl(reg);
1567a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    } else if (value != 0) {
1568a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      addl(reg, imm);
1569a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    }
1570a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else if (value < 0) {
1571a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    value = -value;
1572a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    if (value == 1) {
1573a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      decl(reg);
1574a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    } else if (value != 0) {
1575a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro      subl(reg, Immediate(value));
1576a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    }
1577a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1578a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1579a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1580a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1581647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillainvoid X86Assembler::LoadLongConstant(XmmRegister dst, int64_t value) {
1582647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain  // TODO: Need to have a code constants table.
1583647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain  pushl(Immediate(High32Bits(value)));
1584647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain  pushl(Immediate(Low32Bits(value)));
1585647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain  movsd(dst, Address(ESP, 0));
1586647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain  addl(ESP, Immediate(2 * sizeof(int32_t)));
1587647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain}
1588647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain
1589647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain
15902c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::LoadDoubleConstant(XmmRegister dst, double value) {
1591a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  // TODO: Need to have a code constants table.
1592a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  int64_t constant = bit_cast<int64_t, double>(value);
1593647b9ed41cdb7cf302fd356627a3ba372419b78cRoland Levillain  LoadLongConstant(dst, constant);
1594a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1595a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1596a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
15972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Align(int alignment, int offset) {
1598a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(IsPowerOfTwo(alignment));
1599a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  // Emit nop instruction until the real position is aligned.
1600a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  while (((offset + buffer_.GetPosition()) & (alignment-1)) != 0) {
1601a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    nop();
1602a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1603a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1604a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1605a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
16062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Bind(Label* label) {
1607a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  int bound = buffer_.Size();
1608a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(!label->IsBound());  // Labels can only be bound once.
1609a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  while (label->IsLinked()) {
1610a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    int position = label->LinkPosition();
1611a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    int next = buffer_.Load<int32_t>(position);
1612a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    buffer_.Store<int32_t>(position, bound - (position + 4));
1613a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    label->position_ = next;
1614a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1615a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  label->BindTo(bound);
1616a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1617a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1618a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
161944fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitOperand(int reg_or_opcode, const Operand& operand) {
162044fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers  CHECK_GE(reg_or_opcode, 0);
162144fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers  CHECK_LT(reg_or_opcode, 8);
1622a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  const int length = operand.length_;
1623a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK_GT(length, 0);
162444fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers  // Emit the ModRM byte updated with the given reg value.
1625a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK_EQ(operand.encoding_[0] & 0x38, 0);
162644fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers  EmitUint8(operand.encoding_[0] + (reg_or_opcode << 3));
1627a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  // Emit the rest of the encoded operand.
1628a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  for (int i = 1; i < length; i++) {
1629a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(operand.encoding_[i]);
1630a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1631a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1632a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1633a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
16342c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::EmitImmediate(const Immediate& imm) {
1635a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitInt32(imm.value());
1636a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1637a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1638a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
163944fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitComplex(int reg_or_opcode,
16402c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                               const Operand& operand,
16412c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                               const Immediate& immediate) {
164244fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers  CHECK_GE(reg_or_opcode, 0);
164344fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers  CHECK_LT(reg_or_opcode, 8);
1644a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (immediate.is_int8()) {
1645a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    // Use sign-extended 8-bit immediate.
1646a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0x83);
164744fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers    EmitOperand(reg_or_opcode, operand);
1648a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(immediate.value() & 0xFF);
1649a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else if (operand.IsRegister(EAX)) {
1650a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    // Use short form if the destination is eax.
165144fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers    EmitUint8(0x05 + (reg_or_opcode << 3));
1652a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitImmediate(immediate);
1653a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else {
1654a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0x81);
165544fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogers    EmitOperand(reg_or_opcode, operand);
1656a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitImmediate(immediate);
1657a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1658a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1659a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1660a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
16612c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::EmitLabel(Label* label, int instruction_size) {
1662a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (label->IsBound()) {
1663a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    int offset = label->Position() - buffer_.Size();
1664a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    CHECK_LE(offset, 0);
1665a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitInt32(offset - instruction_size);
1666a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else {
1667a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitLabelLink(label);
1668a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1669a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1670a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1671a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
16722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::EmitLabelLink(Label* label) {
1673a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(!label->IsBound());
1674a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  int position = buffer_.Size();
1675a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitInt32(label->position_);
1676a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  label->LinkTo(position);
1677a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1678a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1679a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
168044fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitGenericShift(int reg_or_opcode,
16817394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell                                    const Operand& operand,
16822c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                    const Immediate& imm) {
1683a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1684a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK(imm.is_int8());
1685a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  if (imm.value() == 1) {
1686a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0xD1);
16877394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell    EmitOperand(reg_or_opcode, operand);
1688a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  } else {
1689a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(0xC1);
16907394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell    EmitOperand(reg_or_opcode, operand);
1691a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro    EmitUint8(imm.value() & 0xFF);
1692a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  }
1693a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1694a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1695a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
169644fb0d0e096067e6bfe1dbfedf369e705bb10814Ian Rogersvoid X86Assembler::EmitGenericShift(int reg_or_opcode,
16977394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell                                    const Operand& operand,
16982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                    Register shifter) {
1699a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1700a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  CHECK_EQ(shifter, ECX);
1701a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro  EmitUint8(0xD3);
17027394569c9252b277710b2d7d3fc35fb0dd48fc4bMark P Mendell  EmitOperand(reg_or_opcode, operand);
1703a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro}
1704a5d5cfda6239d8876937e75eba43222f639d2447Carl Shapiro
1705dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbeckystatic dwarf::Reg DWARFReg(Register reg) {
1706dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  return dwarf::Reg::X86Core(static_cast<int>(reg));
1707dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky}
1708dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky
1709790a6b7312979513710c366b411ba6791ddf78c2Ian Rogersconstexpr size_t kFramePointerSize = 4;
1710790a6b7312979513710c366b411ba6791ddf78c2Ian Rogers
17112c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::BuildFrame(size_t frame_size, ManagedRegister method_reg,
1712b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers                              const std::vector<ManagedRegister>& spill_regs,
1713fca82208f7128fcda09b6a4743199308332558a2Dmitry Petrochenko                              const ManagedRegisterEntrySpills& entry_spills) {
17148c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky  DCHECK_EQ(buffer_.Size(), 0U);  // Nothing emitted yet.
1715dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.SetCurrentCFAOffset(4);  // Return address on stack.
171606b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes  CHECK_ALIGNED(frame_size, kStackAlignment);
1717966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell  int gpr_count = 0;
1718703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao  for (int i = spill_regs.size() - 1; i >= 0; --i) {
17198c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky    Register spill = spill_regs.at(i).AsX86().AsCpuRegister();
17208c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky    pushl(spill);
1721966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell    gpr_count++;
1722dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky    cfi_.AdjustCFAOffset(kFramePointerSize);
1723dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky    cfi_.RelOffset(DWARFReg(spill), 0);
1724703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao  }
1725547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen
17268c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky  // return address then method on stack.
17273d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier  int32_t adjust = frame_size - gpr_count * kFramePointerSize -
17283d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier      kFramePointerSize /*method*/ -
17293d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier      kFramePointerSize /*return address*/;
1730547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen  addl(ESP, Immediate(-adjust));
1731dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.AdjustCFAOffset(adjust);
17322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  pushl(method_reg.AsX86().AsCpuRegister());
1733dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.AdjustCFAOffset(kFramePointerSize);
1734dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  DCHECK_EQ(static_cast<size_t>(cfi_.GetCurrentCFAOffset()), frame_size);
1735547cdfd21ee21e4ab9ca8692d6ef47c62ee7ea52Tong Shen
1736b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers  for (size_t i = 0; i < entry_spills.size(); ++i) {
1737966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell    ManagedRegisterSpill spill = entry_spills.at(i);
1738966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell    if (spill.AsX86().IsCpuRegister()) {
17398c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky      int offset = frame_size + spill.getSpillOffset();
17408c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky      movl(Address(ESP, offset), spill.AsX86().AsCpuRegister());
1741966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell    } else {
1742966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell      DCHECK(spill.AsX86().IsXmmRegister());
1743966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell      if (spill.getSize() == 8) {
1744966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell        movsd(Address(ESP, frame_size + spill.getSpillOffset()), spill.AsX86().AsXmmRegister());
1745966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell      } else {
1746966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell        CHECK_EQ(spill.getSize(), 4);
1747966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell        movss(Address(ESP, frame_size + spill.getSpillOffset()), spill.AsX86().AsXmmRegister());
1748966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell      }
1749966c3ae95d3c699ee9fbdbccc1acdaaf02325fafMark P Mendell    }
1750b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers  }
1751b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1752b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
17533d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartiervoid X86Assembler::RemoveFrame(size_t frame_size, const std::vector<ManagedRegister>& spill_regs) {
175406b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes  CHECK_ALIGNED(frame_size, kStackAlignment);
1755dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.RememberState();
17563d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier  // -kFramePointerSize for ArtMethod*.
17573d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier  int adjust = frame_size - spill_regs.size() * kFramePointerSize - kFramePointerSize;
17588c57831b2b07185ee1986b9af68a351e1ca584c3David Srbecky  addl(ESP, Immediate(adjust));
1759dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.AdjustCFAOffset(-adjust);
1760703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao  for (size_t i = 0; i < spill_regs.size(); ++i) {
1761dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky    Register spill = spill_regs.at(i).AsX86().AsCpuRegister();
1762dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky    popl(spill);
1763dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky    cfi_.AdjustCFAOffset(-static_cast<int>(kFramePointerSize));
1764dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky    cfi_.Restore(DWARFReg(spill));
1765703f2cd1f4d1eb5ab5c9792ca2de9ffb39378203jeffhao  }
1766b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  ret();
1767dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  // The CFI should be restored for any code that follows the exit block.
1768dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.RestoreState();
1769dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.DefCFAOffset(frame_size);
1770b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1771b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
17722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::IncreaseFrameSize(size_t adjust) {
177306b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes  CHECK_ALIGNED(adjust, kStackAlignment);
1774b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  addl(ESP, Immediate(-adjust));
1775dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.AdjustCFAOffset(adjust);
1776b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1777b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
17782c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::DecreaseFrameSize(size_t adjust) {
177906b37d91bb3d543002b1aee9829691f5e8bebc7eElliott Hughes  CHECK_ALIGNED(adjust, kStackAlignment);
1780b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  addl(ESP, Immediate(adjust));
1781dd97393aca1a3ff2abec4dc4f78d7724300971bcDavid Srbecky  cfi_.AdjustCFAOffset(-adjust);
1782b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1783b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
17842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Store(FrameOffset offs, ManagedRegister msrc, size_t size) {
17852c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister src = msrc.AsX86();
178645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  if (src.IsNoRegister()) {
178745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    CHECK_EQ(0u, size);
178845a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  } else if (src.IsCpuRegister()) {
1789b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    CHECK_EQ(4u, size);
1790b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    movl(Address(ESP, offs), src.AsCpuRegister());
17919b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers  } else if (src.IsRegisterPair()) {
17929b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers    CHECK_EQ(8u, size);
17939b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers    movl(Address(ESP, offs), src.AsRegisterPairLow());
17949b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers    movl(Address(ESP, FrameOffset(offs.Int32Value()+4)),
17959b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers         src.AsRegisterPairHigh());
179645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  } else if (src.IsX87Register()) {
179745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    if (size == 4) {
179845a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers      fstps(Address(ESP, offs));
179945a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    } else {
180045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers      fstpl(Address(ESP, offs));
180145a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    }
180245a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  } else {
180345a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    CHECK(src.IsXmmRegister());
1804b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    if (size == 4) {
1805b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers      movss(Address(ESP, offs), src.AsXmmRegister());
1806b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    } else {
1807b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers      movsd(Address(ESP, offs), src.AsXmmRegister());
1808b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    }
1809b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  }
1810b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1811b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
18122c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::StoreRef(FrameOffset dest, ManagedRegister msrc) {
18132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister src = msrc.AsX86();
1814b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(src.IsCpuRegister());
1815b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  movl(Address(ESP, dest), src.AsCpuRegister());
1816b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1817b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
18182c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::StoreRawPtr(FrameOffset dest, ManagedRegister msrc) {
18192c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister src = msrc.AsX86();
1820df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers  CHECK(src.IsCpuRegister());
1821df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers  movl(Address(ESP, dest), src.AsCpuRegister());
1822df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers}
1823df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers
18242c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::StoreImmediateToFrame(FrameOffset dest, uint32_t imm,
18252c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                         ManagedRegister) {
18262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  movl(Address(ESP, dest), Immediate(imm));
18272c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers}
18282c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers
1829dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::StoreImmediateToThread32(ThreadOffset<4> dest, uint32_t imm,
18302c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                          ManagedRegister) {
18312c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  fs()->movl(Address::Absolute(dest), Immediate(imm));
18322c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers}
18332c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers
1834dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::StoreStackOffsetToThread32(ThreadOffset<4> thr_offs,
18352c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                            FrameOffset fr_offs,
18362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                            ManagedRegister mscratch) {
18372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
1838b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(scratch.IsCpuRegister());
18392c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  leal(scratch.AsCpuRegister(), Address(ESP, fr_offs));
18402c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  fs()->movl(Address::Absolute(thr_offs), scratch.AsCpuRegister());
1841b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1842b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
1843dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::StoreStackPointerToThread32(ThreadOffset<4> thr_offs) {
18442c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  fs()->movl(Address::Absolute(thr_offs), ESP);
1845b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1846b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
18471bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::StoreSpanning(FrameOffset /*dst*/, ManagedRegister /*src*/,
18481bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughes                                 FrameOffset /*in_off*/, ManagedRegister /*scratch*/) {
18492c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  UNIMPLEMENTED(FATAL);  // this case only currently exists for ARM
1850b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1851b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
18522c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Load(ManagedRegister mdest, FrameOffset src, size_t size) {
18532c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister dest = mdest.AsX86();
185445a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  if (dest.IsNoRegister()) {
185545a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    CHECK_EQ(0u, size);
185645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  } else if (dest.IsCpuRegister()) {
1857b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    CHECK_EQ(4u, size);
1858b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    movl(dest.AsCpuRegister(), Address(ESP, src));
18599b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers  } else if (dest.IsRegisterPair()) {
18609b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers    CHECK_EQ(8u, size);
18619b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers    movl(dest.AsRegisterPairLow(), Address(ESP, src));
18629b269d281d16798b0c24027c32ec6507f71b2787Ian Rogers    movl(dest.AsRegisterPairHigh(), Address(ESP, FrameOffset(src.Int32Value()+4)));
186345a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  } else if (dest.IsX87Register()) {
186445a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    if (size == 4) {
186545a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers      flds(Address(ESP, src));
186645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    } else {
186745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers      fldl(Address(ESP, src));
186845a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    }
1869b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  } else {
187045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    CHECK(dest.IsXmmRegister());
187145a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    if (size == 4) {
187245a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers      movss(dest.AsXmmRegister(), Address(ESP, src));
187345a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    } else {
187445a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers      movsd(dest.AsXmmRegister(), Address(ESP, src));
187545a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers    }
1876b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  }
1877b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1878b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
1879dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::LoadFromThread32(ManagedRegister mdest, ThreadOffset<4> src, size_t size) {
18805a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  X86ManagedRegister dest = mdest.AsX86();
18815a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  if (dest.IsNoRegister()) {
18825a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    CHECK_EQ(0u, size);
18835a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  } else if (dest.IsCpuRegister()) {
18845a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    CHECK_EQ(4u, size);
18855a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    fs()->movl(dest.AsCpuRegister(), Address::Absolute(src));
18865a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  } else if (dest.IsRegisterPair()) {
18875a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    CHECK_EQ(8u, size);
18885a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    fs()->movl(dest.AsRegisterPairLow(), Address::Absolute(src));
1889dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers    fs()->movl(dest.AsRegisterPairHigh(), Address::Absolute(ThreadOffset<4>(src.Int32Value()+4)));
18905a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  } else if (dest.IsX87Register()) {
18915a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    if (size == 4) {
18925a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers      fs()->flds(Address::Absolute(src));
18935a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    } else {
18945a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers      fs()->fldl(Address::Absolute(src));
18955a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    }
18965a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  } else {
18975a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    CHECK(dest.IsXmmRegister());
18985a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    if (size == 4) {
18995a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers      fs()->movss(dest.AsXmmRegister(), Address::Absolute(src));
19005a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    } else {
19015a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers      fs()->movsd(dest.AsXmmRegister(), Address::Absolute(src));
19025a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers    }
19035a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  }
19045a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers}
19055a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers
19063d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartiervoid X86Assembler::LoadRef(ManagedRegister mdest, FrameOffset src) {
19072c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister dest = mdest.AsX86();
1908b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(dest.IsCpuRegister());
1909b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  movl(dest.AsCpuRegister(), Address(ESP, src));
1910b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1911b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
19123d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartiervoid X86Assembler::LoadRef(ManagedRegister mdest, ManagedRegister base, MemberOffset offs,
19133d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier                           bool poison_reference) {
19142c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister dest = mdest.AsX86();
1915b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(dest.IsCpuRegister() && dest.IsCpuRegister());
19162c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  movl(dest.AsCpuRegister(), Address(base.AsX86().AsCpuRegister(), offs));
19173d21bdf8894e780d349c481e5c9e29fe1556051cMathieu Chartier  if (kPoisonHeapReferences && poison_reference) {
1918e63a745f26fec5a5b4162fc83f6e88a1f696c30cHiroshi Yamauchi    negl(dest.AsCpuRegister());
1919e63a745f26fec5a5b4162fc83f6e88a1f696c30cHiroshi Yamauchi  }
1920a04d397b990ee7d3ce120e317c19fb4409d80d57Ian Rogers}
1921a04d397b990ee7d3ce120e317c19fb4409d80d57Ian Rogers
19222c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::LoadRawPtr(ManagedRegister mdest, ManagedRegister base,
19232c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                              Offset offs) {
19242c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister dest = mdest.AsX86();
1925a04d397b990ee7d3ce120e317c19fb4409d80d57Ian Rogers  CHECK(dest.IsCpuRegister() && dest.IsCpuRegister());
19262c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  movl(dest.AsCpuRegister(), Address(base.AsX86().AsCpuRegister(), offs));
1927b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1928b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
1929dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::LoadRawPtrFromThread32(ManagedRegister mdest,
1930dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers                                        ThreadOffset<4> offs) {
19312c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister dest = mdest.AsX86();
1932b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(dest.IsCpuRegister());
19330d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers  fs()->movl(dest.AsCpuRegister(), Address::Absolute(offs));
1934b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1935b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
193658136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhaovoid X86Assembler::SignExtend(ManagedRegister mreg, size_t size) {
193758136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao  X86ManagedRegister reg = mreg.AsX86();
193858136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao  CHECK(size == 1 || size == 2) << size;
193958136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao  CHECK(reg.IsCpuRegister()) << reg;
194058136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao  if (size == 1) {
194158136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao    movsxb(reg.AsCpuRegister(), reg.AsByteRegister());
194258136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao  } else {
194358136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao    movsxw(reg.AsCpuRegister(), reg.AsCpuRegister());
194458136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao  }
194558136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao}
194658136caeec7cb677bb83c2eafd1f4bab5afd96c8jeffhao
1947cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhaovoid X86Assembler::ZeroExtend(ManagedRegister mreg, size_t size) {
1948cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao  X86ManagedRegister reg = mreg.AsX86();
1949cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao  CHECK(size == 1 || size == 2) << size;
1950cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao  CHECK(reg.IsCpuRegister()) << reg;
1951cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao  if (size == 1) {
1952cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao    movzxb(reg.AsCpuRegister(), reg.AsByteRegister());
1953cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao  } else {
1954cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao    movzxw(reg.AsCpuRegister(), reg.AsCpuRegister());
1955cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao  }
1956cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao}
1957cee4d0c1c2faacf0eae748a24cc7e455e067d977jeffhao
1958b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogersvoid X86Assembler::Move(ManagedRegister mdest, ManagedRegister msrc, size_t size) {
19592c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister dest = mdest.AsX86();
19602c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister src = msrc.AsX86();
19612c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  if (!dest.Equals(src)) {
19622c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers    if (dest.IsCpuRegister() && src.IsCpuRegister()) {
19632c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers      movl(dest.AsCpuRegister(), src.AsCpuRegister());
1964b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers    } else if (src.IsX87Register() && dest.IsXmmRegister()) {
1965b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers      // Pass via stack and pop X87 register
1966b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers      subl(ESP, Immediate(16));
1967b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers      if (size == 4) {
1968b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers        CHECK_EQ(src.AsX87Register(), ST0);
1969b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers        fstps(Address(ESP, 0));
1970b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers        movss(dest.AsXmmRegister(), Address(ESP, 0));
1971b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers      } else {
1972b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers        CHECK_EQ(src.AsX87Register(), ST0);
1973b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers        fstpl(Address(ESP, 0));
1974b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers        movsd(dest.AsXmmRegister(), Address(ESP, 0));
1975b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers      }
1976b5d09b2f87202bc132ac3991d4b6d71f4f6d9264Ian Rogers      addl(ESP, Immediate(16));
19772c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers    } else {
19782c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers      // TODO: x87, SSE
19792c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers      UNIMPLEMENTED(FATAL) << ": Move " << dest << ", " << src;
19802c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers    }
19812c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  }
1982b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1983b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
19842c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::CopyRef(FrameOffset dest, FrameOffset src,
19852c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                           ManagedRegister mscratch) {
19862c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
1987b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(scratch.IsCpuRegister());
19882c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  movl(scratch.AsCpuRegister(), Address(ESP, src));
19892c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  movl(Address(ESP, dest), scratch.AsCpuRegister());
1990b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
1991b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
1992dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::CopyRawPtrFromThread32(FrameOffset fr_offs,
1993dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers                                        ThreadOffset<4> thr_offs,
19942c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                        ManagedRegister mscratch) {
19952c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
1996b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(scratch.IsCpuRegister());
19972c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  fs()->movl(scratch.AsCpuRegister(), Address::Absolute(thr_offs));
19982c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  Store(fr_offs, scratch, 4);
199945a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers}
200045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers
2001dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::CopyRawPtrToThread32(ThreadOffset<4> thr_offs,
20022c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                      FrameOffset fr_offs,
20032c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                      ManagedRegister mscratch) {
20042c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
20052c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  CHECK(scratch.IsCpuRegister());
20062c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  Load(scratch, fr_offs, 4);
20072c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  fs()->movl(Address::Absolute(thr_offs), scratch.AsCpuRegister());
2008b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2009b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
20102c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Copy(FrameOffset dest, FrameOffset src,
20112c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                        ManagedRegister mscratch,
20122c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                        size_t size) {
20132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
2014b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  if (scratch.IsCpuRegister() && size == 8) {
2015b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Load(scratch, src, 4);
2016b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Store(dest, scratch, 4);
2017b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Load(scratch, FrameOffset(src.Int32Value() + 4), 4);
2018b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Store(FrameOffset(dest.Int32Value() + 4), scratch, 4);
2019b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  } else {
2020b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Load(scratch, src, size);
2021b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Store(dest, scratch, size);
2022b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  }
2023b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2024b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
20251bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::Copy(FrameOffset /*dst*/, ManagedRegister /*src_base*/, Offset /*src_offset*/,
20261bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughes                        ManagedRegister /*scratch*/, size_t /*size*/) {
2027dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  UNIMPLEMENTED(FATAL);
2028dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers}
2029dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers
20305a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogersvoid X86Assembler::Copy(ManagedRegister dest_base, Offset dest_offset, FrameOffset src,
20315a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers                        ManagedRegister scratch, size_t size) {
20325a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  CHECK(scratch.IsNoRegister());
20335a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  CHECK_EQ(size, 4u);
20345a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  pushl(Address(ESP, src));
20355a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  popl(Address(dest_base.AsX86().AsCpuRegister(), dest_offset));
20365a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers}
20375a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers
2038dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogersvoid X86Assembler::Copy(FrameOffset dest, FrameOffset src_base, Offset src_offset,
2039dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers                        ManagedRegister mscratch, size_t size) {
2040dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  Register scratch = mscratch.AsX86().AsCpuRegister();
2041dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  CHECK_EQ(size, 4u);
2042dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  movl(scratch, Address(ESP, src_base));
2043dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  movl(scratch, Address(scratch, src_offset));
2044dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  movl(Address(ESP, dest), scratch);
2045dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers}
2046dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers
20475a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogersvoid X86Assembler::Copy(ManagedRegister dest, Offset dest_offset,
20485a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers                        ManagedRegister src, Offset src_offset,
20495a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers                        ManagedRegister scratch, size_t size) {
20505a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  CHECK_EQ(size, 4u);
20515a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  CHECK(scratch.IsNoRegister());
20525a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  pushl(Address(src.AsX86().AsCpuRegister(), src_offset));
20535a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  popl(Address(dest.AsX86().AsCpuRegister(), dest_offset));
20545a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers}
20555a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers
20565a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogersvoid X86Assembler::Copy(FrameOffset dest, Offset dest_offset, FrameOffset src, Offset src_offset,
20575a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers                        ManagedRegister mscratch, size_t size) {
2058dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  Register scratch = mscratch.AsX86().AsCpuRegister();
2059dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  CHECK_EQ(size, 4u);
20605a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  CHECK_EQ(dest.Int32Value(), src.Int32Value());
20615a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  movl(scratch, Address(ESP, src));
20625a7a74a042e73a355f5cedffa0d2faf5340028faIan Rogers  pushl(Address(scratch, src_offset));
2063dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers  popl(Address(scratch, dest_offset));
2064dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers}
2065dc51b79e65abcdad094ccd5e5a2caf5153433d49Ian Rogers
2066e5de95b3f9609e02fefd7cda7b21f30c9412eb4cIan Rogersvoid X86Assembler::MemoryBarrier(ManagedRegister) {
206779ab9e32c6880e7b342c192a479c858c9dccf496Elliott Hughes  mfence();
2068e5de95b3f9609e02fefd7cda7b21f30c9412eb4cIan Rogers}
2069e5de95b3f9609e02fefd7cda7b21f30c9412eb4cIan Rogers
2070eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartiervoid X86Assembler::CreateHandleScopeEntry(ManagedRegister mout_reg,
2071eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier                                   FrameOffset handle_scope_offset,
20722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                   ManagedRegister min_reg, bool null_allowed) {
20732c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister out_reg = mout_reg.AsX86();
20742c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister in_reg = min_reg.AsX86();
2075b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(in_reg.IsCpuRegister());
2076b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(out_reg.IsCpuRegister());
2077408f79aeb676251ba35667a64e86c20638d7cb0bIan Rogers  VerifyObject(in_reg, null_allowed);
2078b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  if (null_allowed) {
2079b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Label null_arg;
2080b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    if (!out_reg.Equals(in_reg)) {
2081b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers      xorl(out_reg.AsCpuRegister(), out_reg.AsCpuRegister());
2082b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    }
2083b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    testl(in_reg.AsCpuRegister(), in_reg.AsCpuRegister());
208418c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes    j(kZero, &null_arg);
2085eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier    leal(out_reg.AsCpuRegister(), Address(ESP, handle_scope_offset));
2086b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Bind(&null_arg);
2087b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  } else {
2088eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier    leal(out_reg.AsCpuRegister(), Address(ESP, handle_scope_offset));
2089b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  }
2090b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2091b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
2092eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartiervoid X86Assembler::CreateHandleScopeEntry(FrameOffset out_off,
2093eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier                                   FrameOffset handle_scope_offset,
20942c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                   ManagedRegister mscratch,
20952c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                   bool null_allowed) {
20962c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
2097b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(scratch.IsCpuRegister());
2098b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  if (null_allowed) {
2099b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Label null_arg;
2100eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier    movl(scratch.AsCpuRegister(), Address(ESP, handle_scope_offset));
2101b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    testl(scratch.AsCpuRegister(), scratch.AsCpuRegister());
210218c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes    j(kZero, &null_arg);
2103eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier    leal(scratch.AsCpuRegister(), Address(ESP, handle_scope_offset));
2104b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    Bind(&null_arg);
2105b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  } else {
2106eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier    leal(scratch.AsCpuRegister(), Address(ESP, handle_scope_offset));
2107b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  }
2108b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  Store(out_off, scratch, 4);
2109b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2110b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
2111eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartier// Given a handle scope entry, load the associated reference.
2112eb8167a4f4d27fce0530f6724ab8032610cd146bMathieu Chartiervoid X86Assembler::LoadReferenceFromHandleScope(ManagedRegister mout_reg,
21132c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                         ManagedRegister min_reg) {
21142c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister out_reg = mout_reg.AsX86();
21152c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister in_reg = min_reg.AsX86();
2116b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(out_reg.IsCpuRegister());
2117b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(in_reg.IsCpuRegister());
2118b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  Label null_arg;
2119b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  if (!out_reg.Equals(in_reg)) {
2120b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers    xorl(out_reg.AsCpuRegister(), out_reg.AsCpuRegister());
2121b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  }
2122b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  testl(in_reg.AsCpuRegister(), in_reg.AsCpuRegister());
212318c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes  j(kZero, &null_arg);
2124b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  movl(out_reg.AsCpuRegister(), Address(in_reg.AsCpuRegister(), 0));
2125b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  Bind(&null_arg);
2126b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2127b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
21281bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::VerifyObject(ManagedRegister /*src*/, bool /*could_be_null*/) {
2129b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  // TODO: not validating references
2130b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2131b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
21321bac54ffa933fbe9b92b62437577f2f4583eff1aElliott Hughesvoid X86Assembler::VerifyObject(FrameOffset /*src*/, bool /*could_be_null*/) {
2133b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  // TODO: not validating references
2134b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2135b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
21362c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::Call(ManagedRegister mbase, Offset offset, ManagedRegister) {
21372c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister base = mbase.AsX86();
2138b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  CHECK(base.IsCpuRegister());
2139df20fe0c097073f75f22d16e72fd3636a31d3ca1Ian Rogers  call(Address(base.AsCpuRegister(), offset.Int32Value()));
2140b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers  // TODO: place reference map on call
2141b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}
2142b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers
214367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogersvoid X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister mscratch) {
214467375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers  Register scratch = mscratch.AsX86().AsCpuRegister();
214567375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers  movl(scratch, Address(ESP, base));
214667375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers  call(Address(scratch, offset));
2147e2d373e6e09c1df9a47e73a26254048adb31ce82Carl Shapiro}
2148e2d373e6e09c1df9a47e73a26254048adb31ce82Carl Shapiro
2149dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogersvoid X86Assembler::CallFromThread32(ThreadOffset<4> offset, ManagedRegister /*mscratch*/) {
2150bdb0391258abc54bf77c676e36847d28a783bfe5Ian Rogers  fs()->call(Address::Absolute(offset));
2151668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao}
2152668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao
21532c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::GetCurrentThread(ManagedRegister tr) {
21542c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  fs()->movl(tr.AsX86().AsCpuRegister(),
2155dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers             Address::Absolute(Thread::SelfOffset<4>()));
2156668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao}
2157668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao
21582c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86Assembler::GetCurrentThread(FrameOffset offset,
21592c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers                                    ManagedRegister mscratch) {
21602c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86ManagedRegister scratch = mscratch.AsX86();
2161dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers  fs()->movl(scratch.AsCpuRegister(), Address::Absolute(Thread::SelfOffset<4>()));
2162668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao  movl(Address(ESP, offset), scratch.AsCpuRegister());
2163668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao}
2164668512afd0d9b3772a0abc589208b729ee16bc61Shih-wei Liao
216500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogersvoid X86Assembler::ExceptionPoll(ManagedRegister /*scratch*/, size_t stack_adjust) {
216600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers  X86ExceptionSlowPath* slow = new X86ExceptionSlowPath(stack_adjust);
216745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers  buffer_.EnqueueSlowPath(slow);
2168dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers  fs()->cmpl(Address::Absolute(Thread::ExceptionOffset<4>()), Immediate(0));
216918c0753c1659629021b4becdaa3f6ea81aecce35Elliott Hughes  j(kNotEqual, slow->Entry());
217045a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers}
21710d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers
21722c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogersvoid X86ExceptionSlowPath::Emit(Assembler *sasm) {
21732c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers  X86Assembler* sp_asm = down_cast<X86Assembler*>(sasm);
21740d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers#define __ sp_asm->
21750d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers  __ Bind(&entry_);
217620cde9033d51103f31e21436e88f80e1170c78adElliott Hughes  // Note: the return value is dead
217700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers  if (stack_adjust_ != 0) {  // Fix up the frame.
217800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers    __ DecreaseFrameSize(stack_adjust_);
217900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers  }
218067375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers  // Pass exception as argument in EAX
2181dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers  __ fs()->movl(EAX, Address::Absolute(Thread::ExceptionOffset<4>()));
2182dd7624d2b9e599d57762d12031b10b89defc9807Ian Rogers  __ fs()->call(Address::Absolute(QUICK_ENTRYPOINT_OFFSET(4, pDeliverException)));
218367375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers  // this call should never return
218467375acd9fec74cc2054554fe1ed0a7d213e1e47Ian Rogers  __ int3();
21850d666d8769714dcbc2acc4dd5b06f0deffa6e0a1Ian Rogers#undef __
218645a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers}
218745a76cb99104a222d6a9bd768a084893dcb7cf30Ian Rogers
21882c8f653c98d658419f464b6147c10e11a664d2e6Ian Rogers}  // namespace x86
2189b033c75ebda80ac75f936366fe78d1edf5cec937Ian Rogers}  // namespace art
2190