xref: /aosp_15_r20/art/compiler/utils/x86/assembler_x86.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_COMPILER_UTILS_X86_ASSEMBLER_X86_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_COMPILER_UTILS_X86_ASSEMBLER_X86_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include <vector>
21*795d594fSAndroid Build Coastguard Worker 
22*795d594fSAndroid Build Coastguard Worker #include "arch/x86/instruction_set_features_x86.h"
23*795d594fSAndroid Build Coastguard Worker #include "base/arena_containers.h"
24*795d594fSAndroid Build Coastguard Worker #include "base/array_ref.h"
25*795d594fSAndroid Build Coastguard Worker #include "base/bit_utils.h"
26*795d594fSAndroid Build Coastguard Worker #include "base/globals.h"
27*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
28*795d594fSAndroid Build Coastguard Worker #include "base/pointer_size.h"
29*795d594fSAndroid Build Coastguard Worker #include "constants_x86.h"
30*795d594fSAndroid Build Coastguard Worker #include "heap_poisoning.h"
31*795d594fSAndroid Build Coastguard Worker #include "managed_register_x86.h"
32*795d594fSAndroid Build Coastguard Worker #include "offsets.h"
33*795d594fSAndroid Build Coastguard Worker #include "utils/assembler.h"
34*795d594fSAndroid Build Coastguard Worker 
35*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
36*795d594fSAndroid Build Coastguard Worker namespace x86 {
37*795d594fSAndroid Build Coastguard Worker 
38*795d594fSAndroid Build Coastguard Worker class Immediate : public ValueObject {
39*795d594fSAndroid Build Coastguard Worker  public:
Immediate(int32_t value_in)40*795d594fSAndroid Build Coastguard Worker   explicit Immediate(int32_t value_in) : value_(value_in) {}
41*795d594fSAndroid Build Coastguard Worker 
value()42*795d594fSAndroid Build Coastguard Worker   int32_t value() const { return value_; }
43*795d594fSAndroid Build Coastguard Worker 
is_int8()44*795d594fSAndroid Build Coastguard Worker   bool is_int8() const { return IsInt<8>(value_); }
is_uint8()45*795d594fSAndroid Build Coastguard Worker   bool is_uint8() const { return IsUint<8>(value_); }
is_int16()46*795d594fSAndroid Build Coastguard Worker   bool is_int16() const { return IsInt<16>(value_); }
is_uint16()47*795d594fSAndroid Build Coastguard Worker   bool is_uint16() const { return IsUint<16>(value_); }
48*795d594fSAndroid Build Coastguard Worker 
49*795d594fSAndroid Build Coastguard Worker  private:
50*795d594fSAndroid Build Coastguard Worker   const int32_t value_;
51*795d594fSAndroid Build Coastguard Worker };
52*795d594fSAndroid Build Coastguard Worker 
53*795d594fSAndroid Build Coastguard Worker 
54*795d594fSAndroid Build Coastguard Worker class Operand : public ValueObject {
55*795d594fSAndroid Build Coastguard Worker  public:
mod()56*795d594fSAndroid Build Coastguard Worker   uint8_t mod() const {
57*795d594fSAndroid Build Coastguard Worker     return (encoding_at(0) >> 6) & 3;
58*795d594fSAndroid Build Coastguard Worker   }
59*795d594fSAndroid Build Coastguard Worker 
rm()60*795d594fSAndroid Build Coastguard Worker   Register rm() const {
61*795d594fSAndroid Build Coastguard Worker     return static_cast<Register>(encoding_at(0) & 7);
62*795d594fSAndroid Build Coastguard Worker   }
63*795d594fSAndroid Build Coastguard Worker 
scale()64*795d594fSAndroid Build Coastguard Worker   ScaleFactor scale() const {
65*795d594fSAndroid Build Coastguard Worker     return static_cast<ScaleFactor>((encoding_at(1) >> 6) & 3);
66*795d594fSAndroid Build Coastguard Worker   }
67*795d594fSAndroid Build Coastguard Worker 
index()68*795d594fSAndroid Build Coastguard Worker   Register index() const {
69*795d594fSAndroid Build Coastguard Worker     return static_cast<Register>((encoding_at(1) >> 3) & 7);
70*795d594fSAndroid Build Coastguard Worker   }
71*795d594fSAndroid Build Coastguard Worker 
base()72*795d594fSAndroid Build Coastguard Worker   Register base() const {
73*795d594fSAndroid Build Coastguard Worker     return static_cast<Register>(encoding_at(1) & 7);
74*795d594fSAndroid Build Coastguard Worker   }
75*795d594fSAndroid Build Coastguard Worker 
disp()76*795d594fSAndroid Build Coastguard Worker   int32_t disp() const {
77*795d594fSAndroid Build Coastguard Worker     return disp_;
78*795d594fSAndroid Build Coastguard Worker   }
79*795d594fSAndroid Build Coastguard Worker 
disp8()80*795d594fSAndroid Build Coastguard Worker   int8_t disp8() const {
81*795d594fSAndroid Build Coastguard Worker     CHECK_GE(length_, 2);
82*795d594fSAndroid Build Coastguard Worker     return static_cast<int8_t>(encoding_[length_ - 1]);
83*795d594fSAndroid Build Coastguard Worker   }
84*795d594fSAndroid Build Coastguard Worker 
disp32()85*795d594fSAndroid Build Coastguard Worker   int32_t disp32() const {
86*795d594fSAndroid Build Coastguard Worker     CHECK_GE(length_, 5);
87*795d594fSAndroid Build Coastguard Worker     int32_t value;
88*795d594fSAndroid Build Coastguard Worker     memcpy(&value, &encoding_[length_ - 4], sizeof(value));
89*795d594fSAndroid Build Coastguard Worker     return value;
90*795d594fSAndroid Build Coastguard Worker   }
91*795d594fSAndroid Build Coastguard Worker 
IsRegister(Register reg)92*795d594fSAndroid Build Coastguard Worker   bool IsRegister(Register reg) const {
93*795d594fSAndroid Build Coastguard Worker     return ((encoding_[0] & 0xF8) == 0xC0)  // Addressing mode is register only.
94*795d594fSAndroid Build Coastguard Worker         && ((encoding_[0] & 0x07) == reg);  // Register codes match.
95*795d594fSAndroid Build Coastguard Worker   }
96*795d594fSAndroid Build Coastguard Worker 
97*795d594fSAndroid Build Coastguard Worker   inline bool operator==(const Operand &op) const {
98*795d594fSAndroid Build Coastguard Worker     return length_ == op.length_ &&
99*795d594fSAndroid Build Coastguard Worker         memcmp(encoding_, op.encoding_, length_) == 0 &&
100*795d594fSAndroid Build Coastguard Worker         disp_ == op.disp_ &&
101*795d594fSAndroid Build Coastguard Worker         fixup_ == op.fixup_;
102*795d594fSAndroid Build Coastguard Worker   }
103*795d594fSAndroid Build Coastguard Worker 
104*795d594fSAndroid Build Coastguard Worker  protected:
105*795d594fSAndroid Build Coastguard Worker   // Operand can be sub classed (e.g: Address).
Operand()106*795d594fSAndroid Build Coastguard Worker   Operand() : length_(0), disp_(0), fixup_(nullptr) { }
107*795d594fSAndroid Build Coastguard Worker 
SetModRM(int mod_in,Register rm_in)108*795d594fSAndroid Build Coastguard Worker   void SetModRM(int mod_in, Register rm_in) {
109*795d594fSAndroid Build Coastguard Worker     CHECK_EQ(mod_in & ~3, 0);
110*795d594fSAndroid Build Coastguard Worker     encoding_[0] = (mod_in << 6) | rm_in;
111*795d594fSAndroid Build Coastguard Worker     length_ = 1;
112*795d594fSAndroid Build Coastguard Worker   }
113*795d594fSAndroid Build Coastguard Worker 
SetSIB(ScaleFactor scale_in,Register index_in,Register base_in)114*795d594fSAndroid Build Coastguard Worker   void SetSIB(ScaleFactor scale_in, Register index_in, Register base_in) {
115*795d594fSAndroid Build Coastguard Worker     CHECK_EQ(length_, 1);
116*795d594fSAndroid Build Coastguard Worker     CHECK_EQ(scale_in & ~3, 0);
117*795d594fSAndroid Build Coastguard Worker     encoding_[1] = (scale_in << 6) | (index_in << 3) | base_in;
118*795d594fSAndroid Build Coastguard Worker     length_ = 2;
119*795d594fSAndroid Build Coastguard Worker   }
120*795d594fSAndroid Build Coastguard Worker 
SetDisp8(int8_t disp)121*795d594fSAndroid Build Coastguard Worker   void SetDisp8(int8_t disp) {
122*795d594fSAndroid Build Coastguard Worker     CHECK(length_ == 1 || length_ == 2);
123*795d594fSAndroid Build Coastguard Worker     encoding_[length_++] = static_cast<uint8_t>(disp);
124*795d594fSAndroid Build Coastguard Worker     disp_ = disp;
125*795d594fSAndroid Build Coastguard Worker   }
126*795d594fSAndroid Build Coastguard Worker 
SetDisp32(int32_t disp)127*795d594fSAndroid Build Coastguard Worker   void SetDisp32(int32_t disp) {
128*795d594fSAndroid Build Coastguard Worker     CHECK(length_ == 1 || length_ == 2);
129*795d594fSAndroid Build Coastguard Worker     int disp_size = sizeof(disp);
130*795d594fSAndroid Build Coastguard Worker     memmove(&encoding_[length_], &disp, disp_size);
131*795d594fSAndroid Build Coastguard Worker     length_ += disp_size;
132*795d594fSAndroid Build Coastguard Worker     disp_ = disp;
133*795d594fSAndroid Build Coastguard Worker   }
134*795d594fSAndroid Build Coastguard Worker 
GetFixup()135*795d594fSAndroid Build Coastguard Worker   AssemblerFixup* GetFixup() const {
136*795d594fSAndroid Build Coastguard Worker     return fixup_;
137*795d594fSAndroid Build Coastguard Worker   }
138*795d594fSAndroid Build Coastguard Worker 
SetFixup(AssemblerFixup * fixup)139*795d594fSAndroid Build Coastguard Worker   void SetFixup(AssemblerFixup* fixup) {
140*795d594fSAndroid Build Coastguard Worker     fixup_ = fixup;
141*795d594fSAndroid Build Coastguard Worker   }
142*795d594fSAndroid Build Coastguard Worker 
143*795d594fSAndroid Build Coastguard Worker  private:
144*795d594fSAndroid Build Coastguard Worker   uint8_t length_;
145*795d594fSAndroid Build Coastguard Worker   uint8_t encoding_[6];
146*795d594fSAndroid Build Coastguard Worker   int32_t disp_;
147*795d594fSAndroid Build Coastguard Worker 
148*795d594fSAndroid Build Coastguard Worker   // A fixup can be associated with the operand, in order to be applied after the
149*795d594fSAndroid Build Coastguard Worker   // code has been generated. This is used for constant area fixups.
150*795d594fSAndroid Build Coastguard Worker   AssemblerFixup* fixup_;
151*795d594fSAndroid Build Coastguard Worker 
Operand(Register reg)152*795d594fSAndroid Build Coastguard Worker   explicit Operand(Register reg) : disp_(0), fixup_(nullptr) { SetModRM(3, reg); }
153*795d594fSAndroid Build Coastguard Worker 
154*795d594fSAndroid Build Coastguard Worker   // Get the operand encoding byte at the given index.
encoding_at(int index_in)155*795d594fSAndroid Build Coastguard Worker   uint8_t encoding_at(int index_in) const {
156*795d594fSAndroid Build Coastguard Worker     CHECK_GE(index_in, 0);
157*795d594fSAndroid Build Coastguard Worker     CHECK_LT(index_in, length_);
158*795d594fSAndroid Build Coastguard Worker     return encoding_[index_in];
159*795d594fSAndroid Build Coastguard Worker   }
160*795d594fSAndroid Build Coastguard Worker 
161*795d594fSAndroid Build Coastguard Worker   friend class X86Assembler;
162*795d594fSAndroid Build Coastguard Worker };
163*795d594fSAndroid Build Coastguard Worker 
164*795d594fSAndroid Build Coastguard Worker 
165*795d594fSAndroid Build Coastguard Worker class Address : public Operand {
166*795d594fSAndroid Build Coastguard Worker  public:
Address(Register base_in,int32_t disp)167*795d594fSAndroid Build Coastguard Worker   Address(Register base_in, int32_t disp) {
168*795d594fSAndroid Build Coastguard Worker     Init(base_in, disp);
169*795d594fSAndroid Build Coastguard Worker   }
170*795d594fSAndroid Build Coastguard Worker 
Address(Register base_in,int32_t disp,AssemblerFixup * fixup)171*795d594fSAndroid Build Coastguard Worker   Address(Register base_in, int32_t disp, AssemblerFixup *fixup) {
172*795d594fSAndroid Build Coastguard Worker     Init(base_in, disp);
173*795d594fSAndroid Build Coastguard Worker     SetFixup(fixup);
174*795d594fSAndroid Build Coastguard Worker   }
175*795d594fSAndroid Build Coastguard Worker 
Address(Register base_in,Offset disp)176*795d594fSAndroid Build Coastguard Worker   Address(Register base_in, Offset disp) {
177*795d594fSAndroid Build Coastguard Worker     Init(base_in, disp.Int32Value());
178*795d594fSAndroid Build Coastguard Worker   }
179*795d594fSAndroid Build Coastguard Worker 
Address(Register base_in,FrameOffset disp)180*795d594fSAndroid Build Coastguard Worker   Address(Register base_in, FrameOffset disp) {
181*795d594fSAndroid Build Coastguard Worker     CHECK_EQ(base_in, ESP);
182*795d594fSAndroid Build Coastguard Worker     Init(ESP, disp.Int32Value());
183*795d594fSAndroid Build Coastguard Worker   }
184*795d594fSAndroid Build Coastguard Worker 
Address(Register base_in,MemberOffset disp)185*795d594fSAndroid Build Coastguard Worker   Address(Register base_in, MemberOffset disp) {
186*795d594fSAndroid Build Coastguard Worker     Init(base_in, disp.Int32Value());
187*795d594fSAndroid Build Coastguard Worker   }
188*795d594fSAndroid Build Coastguard Worker 
Address(Register index_in,ScaleFactor scale_in,int32_t disp)189*795d594fSAndroid Build Coastguard Worker   Address(Register index_in, ScaleFactor scale_in, int32_t disp) {
190*795d594fSAndroid Build Coastguard Worker     CHECK_NE(index_in, ESP);  // Illegal addressing mode.
191*795d594fSAndroid Build Coastguard Worker     SetModRM(0, ESP);
192*795d594fSAndroid Build Coastguard Worker     SetSIB(scale_in, index_in, EBP);
193*795d594fSAndroid Build Coastguard Worker     SetDisp32(disp);
194*795d594fSAndroid Build Coastguard Worker   }
195*795d594fSAndroid Build Coastguard Worker 
Address(Register base_in,Register index_in,ScaleFactor scale_in,int32_t disp)196*795d594fSAndroid Build Coastguard Worker   Address(Register base_in, Register index_in, ScaleFactor scale_in, int32_t disp) {
197*795d594fSAndroid Build Coastguard Worker     Init(base_in, index_in, scale_in, disp);
198*795d594fSAndroid Build Coastguard Worker   }
199*795d594fSAndroid Build Coastguard Worker 
Address(Register base_in,Register index_in,ScaleFactor scale_in,int32_t disp,AssemblerFixup * fixup)200*795d594fSAndroid Build Coastguard Worker   Address(Register base_in,
201*795d594fSAndroid Build Coastguard Worker           Register index_in,
202*795d594fSAndroid Build Coastguard Worker           ScaleFactor scale_in,
203*795d594fSAndroid Build Coastguard Worker           int32_t disp, AssemblerFixup *fixup) {
204*795d594fSAndroid Build Coastguard Worker     Init(base_in, index_in, scale_in, disp);
205*795d594fSAndroid Build Coastguard Worker     SetFixup(fixup);
206*795d594fSAndroid Build Coastguard Worker   }
207*795d594fSAndroid Build Coastguard Worker 
208*795d594fSAndroid Build Coastguard Worker   // Break the address into pieces and reassemble it again with a new displacement.
209*795d594fSAndroid Build Coastguard Worker   // Note that it may require a new addressing mode if displacement size is changed.
displace(const Address & addr,int32_t disp)210*795d594fSAndroid Build Coastguard Worker   static Address displace(const Address &addr, int32_t disp) {
211*795d594fSAndroid Build Coastguard Worker     const int32_t new_disp = addr.disp() + disp;
212*795d594fSAndroid Build Coastguard Worker     const bool sib = addr.rm() == ESP;
213*795d594fSAndroid Build Coastguard Worker     const bool ebp = EBP == (sib ? addr.base() : addr.rm());
214*795d594fSAndroid Build Coastguard Worker     Address new_addr;
215*795d594fSAndroid Build Coastguard Worker     if (addr.mod() == 0 && ebp) {
216*795d594fSAndroid Build Coastguard Worker       // Special case: mod 00b and EBP in r/m or SIB base => 32-bit displacement.
217*795d594fSAndroid Build Coastguard Worker       new_addr.SetModRM(0, addr.rm());
218*795d594fSAndroid Build Coastguard Worker       if (sib) {
219*795d594fSAndroid Build Coastguard Worker         new_addr.SetSIB(addr.scale(), addr.index(), addr.base());
220*795d594fSAndroid Build Coastguard Worker       }
221*795d594fSAndroid Build Coastguard Worker       new_addr.SetDisp32(new_disp);
222*795d594fSAndroid Build Coastguard Worker     } else if (new_disp == 0 && !ebp) {
223*795d594fSAndroid Build Coastguard Worker       // Mod 00b (excluding a special case for EBP) => no displacement.
224*795d594fSAndroid Build Coastguard Worker       new_addr.SetModRM(0, addr.rm());
225*795d594fSAndroid Build Coastguard Worker       if (sib) {
226*795d594fSAndroid Build Coastguard Worker         new_addr.SetSIB(addr.scale(), addr.index(), addr.base());
227*795d594fSAndroid Build Coastguard Worker       }
228*795d594fSAndroid Build Coastguard Worker     } else if (new_disp >= -128 && new_disp <= 127) {
229*795d594fSAndroid Build Coastguard Worker       // Mod 01b => 8-bit displacement.
230*795d594fSAndroid Build Coastguard Worker       new_addr.SetModRM(1, addr.rm());
231*795d594fSAndroid Build Coastguard Worker       if (sib) {
232*795d594fSAndroid Build Coastguard Worker         new_addr.SetSIB(addr.scale(), addr.index(), addr.base());
233*795d594fSAndroid Build Coastguard Worker       }
234*795d594fSAndroid Build Coastguard Worker       new_addr.SetDisp8(new_disp);
235*795d594fSAndroid Build Coastguard Worker     } else {
236*795d594fSAndroid Build Coastguard Worker       // Mod 10b => 32-bit displacement.
237*795d594fSAndroid Build Coastguard Worker       new_addr.SetModRM(2, addr.rm());
238*795d594fSAndroid Build Coastguard Worker       if (sib) {
239*795d594fSAndroid Build Coastguard Worker         new_addr.SetSIB(addr.scale(), addr.index(), addr.base());
240*795d594fSAndroid Build Coastguard Worker       }
241*795d594fSAndroid Build Coastguard Worker       new_addr.SetDisp32(new_disp);
242*795d594fSAndroid Build Coastguard Worker     }
243*795d594fSAndroid Build Coastguard Worker     new_addr.SetFixup(addr.GetFixup());
244*795d594fSAndroid Build Coastguard Worker     return new_addr;
245*795d594fSAndroid Build Coastguard Worker   }
246*795d594fSAndroid Build Coastguard Worker 
GetBaseRegister()247*795d594fSAndroid Build Coastguard Worker   Register GetBaseRegister() {
248*795d594fSAndroid Build Coastguard Worker     if (rm() == ESP) {
249*795d594fSAndroid Build Coastguard Worker       return base();
250*795d594fSAndroid Build Coastguard Worker     } else {
251*795d594fSAndroid Build Coastguard Worker       return rm();
252*795d594fSAndroid Build Coastguard Worker     }
253*795d594fSAndroid Build Coastguard Worker   }
254*795d594fSAndroid Build Coastguard Worker 
Absolute(uintptr_t addr)255*795d594fSAndroid Build Coastguard Worker   static Address Absolute(uintptr_t addr) {
256*795d594fSAndroid Build Coastguard Worker     Address result;
257*795d594fSAndroid Build Coastguard Worker     result.SetModRM(0, EBP);
258*795d594fSAndroid Build Coastguard Worker     result.SetDisp32(addr);
259*795d594fSAndroid Build Coastguard Worker     return result;
260*795d594fSAndroid Build Coastguard Worker   }
261*795d594fSAndroid Build Coastguard Worker 
Absolute(ThreadOffset32 addr)262*795d594fSAndroid Build Coastguard Worker   static Address Absolute(ThreadOffset32 addr) {
263*795d594fSAndroid Build Coastguard Worker     return Absolute(addr.Int32Value());
264*795d594fSAndroid Build Coastguard Worker   }
265*795d594fSAndroid Build Coastguard Worker 
266*795d594fSAndroid Build Coastguard Worker   inline bool operator==(const Address& addr) const {
267*795d594fSAndroid Build Coastguard Worker     return static_cast<const Operand&>(*this) == static_cast<const Operand&>(addr);
268*795d594fSAndroid Build Coastguard Worker   }
269*795d594fSAndroid Build Coastguard Worker 
270*795d594fSAndroid Build Coastguard Worker  private:
Address()271*795d594fSAndroid Build Coastguard Worker   Address() {}
272*795d594fSAndroid Build Coastguard Worker 
Init(Register base_in,int32_t disp)273*795d594fSAndroid Build Coastguard Worker   void Init(Register base_in, int32_t disp) {
274*795d594fSAndroid Build Coastguard Worker     if (disp == 0 && base_in != EBP) {
275*795d594fSAndroid Build Coastguard Worker       SetModRM(0, base_in);
276*795d594fSAndroid Build Coastguard Worker       if (base_in == ESP) SetSIB(TIMES_1, ESP, base_in);
277*795d594fSAndroid Build Coastguard Worker     } else if (disp >= -128 && disp <= 127) {
278*795d594fSAndroid Build Coastguard Worker       SetModRM(1, base_in);
279*795d594fSAndroid Build Coastguard Worker       if (base_in == ESP) SetSIB(TIMES_1, ESP, base_in);
280*795d594fSAndroid Build Coastguard Worker       SetDisp8(disp);
281*795d594fSAndroid Build Coastguard Worker     } else {
282*795d594fSAndroid Build Coastguard Worker       SetModRM(2, base_in);
283*795d594fSAndroid Build Coastguard Worker       if (base_in == ESP) SetSIB(TIMES_1, ESP, base_in);
284*795d594fSAndroid Build Coastguard Worker       SetDisp32(disp);
285*795d594fSAndroid Build Coastguard Worker     }
286*795d594fSAndroid Build Coastguard Worker   }
287*795d594fSAndroid Build Coastguard Worker 
Init(Register base_in,Register index_in,ScaleFactor scale_in,int32_t disp)288*795d594fSAndroid Build Coastguard Worker   void Init(Register base_in, Register index_in, ScaleFactor scale_in, int32_t disp) {
289*795d594fSAndroid Build Coastguard Worker     CHECK_NE(index_in, ESP);  // Illegal addressing mode.
290*795d594fSAndroid Build Coastguard Worker     if (disp == 0 && base_in != EBP) {
291*795d594fSAndroid Build Coastguard Worker       SetModRM(0, ESP);
292*795d594fSAndroid Build Coastguard Worker       SetSIB(scale_in, index_in, base_in);
293*795d594fSAndroid Build Coastguard Worker     } else if (disp >= -128 && disp <= 127) {
294*795d594fSAndroid Build Coastguard Worker       SetModRM(1, ESP);
295*795d594fSAndroid Build Coastguard Worker       SetSIB(scale_in, index_in, base_in);
296*795d594fSAndroid Build Coastguard Worker       SetDisp8(disp);
297*795d594fSAndroid Build Coastguard Worker     } else {
298*795d594fSAndroid Build Coastguard Worker       SetModRM(2, ESP);
299*795d594fSAndroid Build Coastguard Worker       SetSIB(scale_in, index_in, base_in);
300*795d594fSAndroid Build Coastguard Worker       SetDisp32(disp);
301*795d594fSAndroid Build Coastguard Worker     }
302*795d594fSAndroid Build Coastguard Worker   }
303*795d594fSAndroid Build Coastguard Worker };
304*795d594fSAndroid Build Coastguard Worker 
305*795d594fSAndroid Build Coastguard Worker std::ostream& operator<<(std::ostream& os, const Address& addr);
306*795d594fSAndroid Build Coastguard Worker 
307*795d594fSAndroid Build Coastguard Worker // This is equivalent to the Label class, used in a slightly different context. We
308*795d594fSAndroid Build Coastguard Worker // inherit the functionality of the Label class, but prevent unintended
309*795d594fSAndroid Build Coastguard Worker // derived-to-base conversions by making the base class private.
310*795d594fSAndroid Build Coastguard Worker class NearLabel : private Label {
311*795d594fSAndroid Build Coastguard Worker  public:
NearLabel()312*795d594fSAndroid Build Coastguard Worker   NearLabel() : Label() {}
313*795d594fSAndroid Build Coastguard Worker 
314*795d594fSAndroid Build Coastguard Worker   // Expose the Label routines that we need.
315*795d594fSAndroid Build Coastguard Worker   using Label::Position;
316*795d594fSAndroid Build Coastguard Worker   using Label::LinkPosition;
317*795d594fSAndroid Build Coastguard Worker   using Label::IsBound;
318*795d594fSAndroid Build Coastguard Worker   using Label::IsUnused;
319*795d594fSAndroid Build Coastguard Worker   using Label::IsLinked;
320*795d594fSAndroid Build Coastguard Worker 
321*795d594fSAndroid Build Coastguard Worker  private:
322*795d594fSAndroid Build Coastguard Worker   using Label::BindTo;
323*795d594fSAndroid Build Coastguard Worker   using Label::LinkTo;
324*795d594fSAndroid Build Coastguard Worker 
325*795d594fSAndroid Build Coastguard Worker   friend class x86::X86Assembler;
326*795d594fSAndroid Build Coastguard Worker 
327*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(NearLabel);
328*795d594fSAndroid Build Coastguard Worker };
329*795d594fSAndroid Build Coastguard Worker 
330*795d594fSAndroid Build Coastguard Worker /**
331*795d594fSAndroid Build Coastguard Worker  * Class to handle constant area values.
332*795d594fSAndroid Build Coastguard Worker  */
333*795d594fSAndroid Build Coastguard Worker class ConstantArea {
334*795d594fSAndroid Build Coastguard Worker  public:
ConstantArea(ArenaAllocator * allocator)335*795d594fSAndroid Build Coastguard Worker   explicit ConstantArea(ArenaAllocator* allocator)
336*795d594fSAndroid Build Coastguard Worker       : buffer_(allocator->Adapter(kArenaAllocAssembler)) {}
337*795d594fSAndroid Build Coastguard Worker 
338*795d594fSAndroid Build Coastguard Worker   // Add a double to the constant area, returning the offset into
339*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
340*795d594fSAndroid Build Coastguard Worker   size_t AddDouble(double v);
341*795d594fSAndroid Build Coastguard Worker 
342*795d594fSAndroid Build Coastguard Worker   // Add a float to the constant area, returning the offset into
343*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
344*795d594fSAndroid Build Coastguard Worker   size_t AddFloat(float v);
345*795d594fSAndroid Build Coastguard Worker 
346*795d594fSAndroid Build Coastguard Worker   // Add an int32_t to the constant area, returning the offset into
347*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
348*795d594fSAndroid Build Coastguard Worker   size_t AddInt32(int32_t v);
349*795d594fSAndroid Build Coastguard Worker 
350*795d594fSAndroid Build Coastguard Worker   // Add an int32_t to the end of the constant area, returning the offset into
351*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
352*795d594fSAndroid Build Coastguard Worker   size_t AppendInt32(int32_t v);
353*795d594fSAndroid Build Coastguard Worker 
354*795d594fSAndroid Build Coastguard Worker   // Add an int64_t to the constant area, returning the offset into
355*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
356*795d594fSAndroid Build Coastguard Worker   size_t AddInt64(int64_t v);
357*795d594fSAndroid Build Coastguard Worker 
IsEmpty()358*795d594fSAndroid Build Coastguard Worker   bool IsEmpty() const {
359*795d594fSAndroid Build Coastguard Worker     return buffer_.size() == 0;
360*795d594fSAndroid Build Coastguard Worker   }
361*795d594fSAndroid Build Coastguard Worker 
GetSize()362*795d594fSAndroid Build Coastguard Worker   size_t GetSize() const {
363*795d594fSAndroid Build Coastguard Worker     return buffer_.size() * elem_size_;
364*795d594fSAndroid Build Coastguard Worker   }
365*795d594fSAndroid Build Coastguard Worker 
GetBuffer()366*795d594fSAndroid Build Coastguard Worker   ArrayRef<const int32_t> GetBuffer() const {
367*795d594fSAndroid Build Coastguard Worker     return ArrayRef<const int32_t>(buffer_);
368*795d594fSAndroid Build Coastguard Worker   }
369*795d594fSAndroid Build Coastguard Worker 
370*795d594fSAndroid Build Coastguard Worker  private:
371*795d594fSAndroid Build Coastguard Worker   static constexpr size_t elem_size_ = sizeof(int32_t);
372*795d594fSAndroid Build Coastguard Worker   ArenaVector<int32_t> buffer_;
373*795d594fSAndroid Build Coastguard Worker };
374*795d594fSAndroid Build Coastguard Worker 
375*795d594fSAndroid Build Coastguard Worker class X86Assembler final : public Assembler {
376*795d594fSAndroid Build Coastguard Worker  public:
377*795d594fSAndroid Build Coastguard Worker   explicit X86Assembler(ArenaAllocator* allocator,
378*795d594fSAndroid Build Coastguard Worker                         const X86InstructionSetFeatures* instruction_set_features = nullptr)
Assembler(allocator)379*795d594fSAndroid Build Coastguard Worker                 : Assembler(allocator),
380*795d594fSAndroid Build Coastguard Worker                   constant_area_(allocator),
381*795d594fSAndroid Build Coastguard Worker                   has_AVX_(instruction_set_features != nullptr ? instruction_set_features->HasAVX() : false),
382*795d594fSAndroid Build Coastguard Worker                   has_AVX2_(instruction_set_features != nullptr ? instruction_set_features->HasAVX2() :false) {}
~X86Assembler()383*795d594fSAndroid Build Coastguard Worker   virtual ~X86Assembler() {}
384*795d594fSAndroid Build Coastguard Worker 
385*795d594fSAndroid Build Coastguard Worker   /*
386*795d594fSAndroid Build Coastguard Worker    * Emit Machine Instructions.
387*795d594fSAndroid Build Coastguard Worker    */
388*795d594fSAndroid Build Coastguard Worker   void call(Register reg);
389*795d594fSAndroid Build Coastguard Worker   void call(const Address& address);
390*795d594fSAndroid Build Coastguard Worker   void call(Label* label);
391*795d594fSAndroid Build Coastguard Worker   void call(const ExternalLabel& label);
392*795d594fSAndroid Build Coastguard Worker 
393*795d594fSAndroid Build Coastguard Worker   void pushl(Register reg);
394*795d594fSAndroid Build Coastguard Worker   void pushl(const Address& address);
395*795d594fSAndroid Build Coastguard Worker   void pushl(const Immediate& imm);
396*795d594fSAndroid Build Coastguard Worker 
397*795d594fSAndroid Build Coastguard Worker   void popl(Register reg);
398*795d594fSAndroid Build Coastguard Worker   void popl(const Address& address);
399*795d594fSAndroid Build Coastguard Worker 
400*795d594fSAndroid Build Coastguard Worker   void movl(Register dst, const Immediate& src);
401*795d594fSAndroid Build Coastguard Worker   void movl(Register dst, Register src);
402*795d594fSAndroid Build Coastguard Worker 
403*795d594fSAndroid Build Coastguard Worker   void movl(Register dst, const Address& src);
404*795d594fSAndroid Build Coastguard Worker   void movl(const Address& dst, Register src);
405*795d594fSAndroid Build Coastguard Worker   void movl(const Address& dst, const Immediate& imm);
406*795d594fSAndroid Build Coastguard Worker   void movl(const Address& dst, Label* lbl);
407*795d594fSAndroid Build Coastguard Worker 
408*795d594fSAndroid Build Coastguard Worker   void movntl(const Address& dst, Register src);
409*795d594fSAndroid Build Coastguard Worker 
410*795d594fSAndroid Build Coastguard Worker   void blsi(Register dst, Register src);  // no addr variant (for now)
411*795d594fSAndroid Build Coastguard Worker   void blsmsk(Register dst, Register src);  // no addr variant (for now)
412*795d594fSAndroid Build Coastguard Worker   void blsr(Register dst, Register src);  // no addr varianr (for now)
413*795d594fSAndroid Build Coastguard Worker 
414*795d594fSAndroid Build Coastguard Worker   void bswapl(Register dst);
415*795d594fSAndroid Build Coastguard Worker 
416*795d594fSAndroid Build Coastguard Worker   void bsfl(Register dst, Register src);
417*795d594fSAndroid Build Coastguard Worker   void bsfl(Register dst, const Address& src);
418*795d594fSAndroid Build Coastguard Worker   void bsrl(Register dst, Register src);
419*795d594fSAndroid Build Coastguard Worker   void bsrl(Register dst, const Address& src);
420*795d594fSAndroid Build Coastguard Worker 
421*795d594fSAndroid Build Coastguard Worker   void popcntl(Register dst, Register src);
422*795d594fSAndroid Build Coastguard Worker   void popcntl(Register dst, const Address& src);
423*795d594fSAndroid Build Coastguard Worker 
424*795d594fSAndroid Build Coastguard Worker   void rorl(Register reg, const Immediate& imm);
425*795d594fSAndroid Build Coastguard Worker   void rorl(Register operand, Register shifter);
426*795d594fSAndroid Build Coastguard Worker   void roll(Register reg, const Immediate& imm);
427*795d594fSAndroid Build Coastguard Worker   void roll(Register operand, Register shifter);
428*795d594fSAndroid Build Coastguard Worker 
429*795d594fSAndroid Build Coastguard Worker   void movzxb(Register dst, ByteRegister src);
430*795d594fSAndroid Build Coastguard Worker   void movzxb(Register dst, const Address& src);
431*795d594fSAndroid Build Coastguard Worker   void movsxb(Register dst, ByteRegister src);
432*795d594fSAndroid Build Coastguard Worker   void movsxb(Register dst, const Address& src);
433*795d594fSAndroid Build Coastguard Worker   void movb(Register dst, const Address& src);
434*795d594fSAndroid Build Coastguard Worker   void movb(const Address& dst, ByteRegister src);
435*795d594fSAndroid Build Coastguard Worker   void movb(const Address& dst, const Immediate& imm);
436*795d594fSAndroid Build Coastguard Worker 
437*795d594fSAndroid Build Coastguard Worker   void movzxw(Register dst, Register src);
438*795d594fSAndroid Build Coastguard Worker   void movzxw(Register dst, const Address& src);
439*795d594fSAndroid Build Coastguard Worker   void movsxw(Register dst, Register src);
440*795d594fSAndroid Build Coastguard Worker   void movsxw(Register dst, const Address& src);
441*795d594fSAndroid Build Coastguard Worker   void movw(Register dst, const Address& src);
442*795d594fSAndroid Build Coastguard Worker   void movw(const Address& dst, Register src);
443*795d594fSAndroid Build Coastguard Worker   void movw(const Address& dst, const Immediate& imm);
444*795d594fSAndroid Build Coastguard Worker 
445*795d594fSAndroid Build Coastguard Worker   void leal(Register dst, const Address& src);
446*795d594fSAndroid Build Coastguard Worker 
447*795d594fSAndroid Build Coastguard Worker   void cmovl(Condition condition, Register dst, Register src);
448*795d594fSAndroid Build Coastguard Worker   void cmovl(Condition condition, Register dst, const Address& src);
449*795d594fSAndroid Build Coastguard Worker 
450*795d594fSAndroid Build Coastguard Worker   void setb(Condition condition, Register dst);
451*795d594fSAndroid Build Coastguard Worker 
452*795d594fSAndroid Build Coastguard Worker   void movaps(XmmRegister dst, XmmRegister src);     // move
453*795d594fSAndroid Build Coastguard Worker   void movaps(XmmRegister dst, const Address& src);  // load aligned
454*795d594fSAndroid Build Coastguard Worker   void movups(XmmRegister dst, const Address& src);  // load unaligned
455*795d594fSAndroid Build Coastguard Worker   void movaps(const Address& dst, XmmRegister src);  // store aligned
456*795d594fSAndroid Build Coastguard Worker   void movups(const Address& dst, XmmRegister src);  // store unaligned
457*795d594fSAndroid Build Coastguard Worker 
458*795d594fSAndroid Build Coastguard Worker   void vmovaps(XmmRegister dst, XmmRegister src);     // move
459*795d594fSAndroid Build Coastguard Worker   void vmovaps(XmmRegister dst, const Address& src);  // load aligned
460*795d594fSAndroid Build Coastguard Worker   void vmovups(XmmRegister dst, const Address& src);  // load unaligned
461*795d594fSAndroid Build Coastguard Worker   void vmovaps(const Address& dst, XmmRegister src);  // store aligned
462*795d594fSAndroid Build Coastguard Worker   void vmovups(const Address& dst, XmmRegister src);  // store unaligned
463*795d594fSAndroid Build Coastguard Worker 
464*795d594fSAndroid Build Coastguard Worker   void movss(XmmRegister dst, const Address& src);
465*795d594fSAndroid Build Coastguard Worker   void movss(const Address& dst, XmmRegister src);
466*795d594fSAndroid Build Coastguard Worker   void movss(XmmRegister dst, XmmRegister src);
467*795d594fSAndroid Build Coastguard Worker 
468*795d594fSAndroid Build Coastguard Worker   void movd(XmmRegister dst, Register src);
469*795d594fSAndroid Build Coastguard Worker   void movd(Register dst, XmmRegister src);
470*795d594fSAndroid Build Coastguard Worker 
471*795d594fSAndroid Build Coastguard Worker   void addss(XmmRegister dst, XmmRegister src);
472*795d594fSAndroid Build Coastguard Worker   void addss(XmmRegister dst, const Address& src);
473*795d594fSAndroid Build Coastguard Worker   void subss(XmmRegister dst, XmmRegister src);
474*795d594fSAndroid Build Coastguard Worker   void subss(XmmRegister dst, const Address& src);
475*795d594fSAndroid Build Coastguard Worker   void mulss(XmmRegister dst, XmmRegister src);
476*795d594fSAndroid Build Coastguard Worker   void mulss(XmmRegister dst, const Address& src);
477*795d594fSAndroid Build Coastguard Worker   void divss(XmmRegister dst, XmmRegister src);
478*795d594fSAndroid Build Coastguard Worker   void divss(XmmRegister dst, const Address& src);
479*795d594fSAndroid Build Coastguard Worker 
480*795d594fSAndroid Build Coastguard Worker   void addps(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
481*795d594fSAndroid Build Coastguard Worker   void subps(XmmRegister dst, XmmRegister src);
482*795d594fSAndroid Build Coastguard Worker   void mulps(XmmRegister dst, XmmRegister src);
483*795d594fSAndroid Build Coastguard Worker   void divps(XmmRegister dst, XmmRegister src);
484*795d594fSAndroid Build Coastguard Worker 
485*795d594fSAndroid Build Coastguard Worker   void vmulps(XmmRegister dst, XmmRegister src1, XmmRegister src2);
486*795d594fSAndroid Build Coastguard Worker   void vmulpd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
487*795d594fSAndroid Build Coastguard Worker   void vdivps(XmmRegister dst, XmmRegister src1, XmmRegister src2);
488*795d594fSAndroid Build Coastguard Worker   void vdivpd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
489*795d594fSAndroid Build Coastguard Worker 
490*795d594fSAndroid Build Coastguard Worker   void vaddps(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
491*795d594fSAndroid Build Coastguard Worker   void vsubps(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
492*795d594fSAndroid Build Coastguard Worker   void vsubpd(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
493*795d594fSAndroid Build Coastguard Worker   void vaddpd(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
494*795d594fSAndroid Build Coastguard Worker 
495*795d594fSAndroid Build Coastguard Worker   void vfmadd213ss(XmmRegister acc, XmmRegister left, XmmRegister right);
496*795d594fSAndroid Build Coastguard Worker   void vfmadd213sd(XmmRegister acc, XmmRegister left, XmmRegister right);
497*795d594fSAndroid Build Coastguard Worker 
498*795d594fSAndroid Build Coastguard Worker   void movapd(XmmRegister dst, XmmRegister src);     // move
499*795d594fSAndroid Build Coastguard Worker   void movapd(XmmRegister dst, const Address& src);  // load aligned
500*795d594fSAndroid Build Coastguard Worker   void movupd(XmmRegister dst, const Address& src);  // load unaligned
501*795d594fSAndroid Build Coastguard Worker   void movapd(const Address& dst, XmmRegister src);  // store aligned
502*795d594fSAndroid Build Coastguard Worker   void movupd(const Address& dst, XmmRegister src);  // store unaligned
503*795d594fSAndroid Build Coastguard Worker 
504*795d594fSAndroid Build Coastguard Worker   void vmovapd(XmmRegister dst, XmmRegister src);     // move
505*795d594fSAndroid Build Coastguard Worker   void vmovapd(XmmRegister dst, const Address& src);  // load aligned
506*795d594fSAndroid Build Coastguard Worker   void vmovupd(XmmRegister dst, const Address& src);  // load unaligned
507*795d594fSAndroid Build Coastguard Worker   void vmovapd(const Address& dst, XmmRegister src);  // store aligned
508*795d594fSAndroid Build Coastguard Worker   void vmovupd(const Address& dst, XmmRegister src);  // store unaligned
509*795d594fSAndroid Build Coastguard Worker 
510*795d594fSAndroid Build Coastguard Worker   void movsd(XmmRegister dst, const Address& src);
511*795d594fSAndroid Build Coastguard Worker   void movsd(const Address& dst, XmmRegister src);
512*795d594fSAndroid Build Coastguard Worker   void movsd(XmmRegister dst, XmmRegister src);
513*795d594fSAndroid Build Coastguard Worker 
514*795d594fSAndroid Build Coastguard Worker   void movhpd(XmmRegister dst, const Address& src);
515*795d594fSAndroid Build Coastguard Worker   void movhpd(const Address& dst, XmmRegister src);
516*795d594fSAndroid Build Coastguard Worker 
517*795d594fSAndroid Build Coastguard Worker   void addsd(XmmRegister dst, XmmRegister src);
518*795d594fSAndroid Build Coastguard Worker   void addsd(XmmRegister dst, const Address& src);
519*795d594fSAndroid Build Coastguard Worker   void subsd(XmmRegister dst, XmmRegister src);
520*795d594fSAndroid Build Coastguard Worker   void subsd(XmmRegister dst, const Address& src);
521*795d594fSAndroid Build Coastguard Worker   void mulsd(XmmRegister dst, XmmRegister src);
522*795d594fSAndroid Build Coastguard Worker   void mulsd(XmmRegister dst, const Address& src);
523*795d594fSAndroid Build Coastguard Worker   void divsd(XmmRegister dst, XmmRegister src);
524*795d594fSAndroid Build Coastguard Worker   void divsd(XmmRegister dst, const Address& src);
525*795d594fSAndroid Build Coastguard Worker 
526*795d594fSAndroid Build Coastguard Worker   void addpd(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
527*795d594fSAndroid Build Coastguard Worker   void subpd(XmmRegister dst, XmmRegister src);
528*795d594fSAndroid Build Coastguard Worker   void mulpd(XmmRegister dst, XmmRegister src);
529*795d594fSAndroid Build Coastguard Worker   void divpd(XmmRegister dst, XmmRegister src);
530*795d594fSAndroid Build Coastguard Worker 
531*795d594fSAndroid Build Coastguard Worker   void movdqa(XmmRegister dst, XmmRegister src);     // move
532*795d594fSAndroid Build Coastguard Worker   void movdqa(XmmRegister dst, const Address& src);  // load aligned
533*795d594fSAndroid Build Coastguard Worker   void movdqu(XmmRegister dst, const Address& src);  // load unaligned
534*795d594fSAndroid Build Coastguard Worker   void movdqa(const Address& dst, XmmRegister src);  // store aligned
535*795d594fSAndroid Build Coastguard Worker   void movdqu(const Address& dst, XmmRegister src);  // store unaligned
536*795d594fSAndroid Build Coastguard Worker 
537*795d594fSAndroid Build Coastguard Worker   void vmovdqa(XmmRegister dst, XmmRegister src);     // move
538*795d594fSAndroid Build Coastguard Worker   void vmovdqa(XmmRegister dst, const Address& src);  // load aligned
539*795d594fSAndroid Build Coastguard Worker   void vmovdqu(XmmRegister dst, const Address& src);  // load unaligned
540*795d594fSAndroid Build Coastguard Worker   void vmovdqa(const Address& dst, XmmRegister src);  // store aligned
541*795d594fSAndroid Build Coastguard Worker   void vmovdqu(const Address& dst, XmmRegister src);  // store unaligned
542*795d594fSAndroid Build Coastguard Worker 
543*795d594fSAndroid Build Coastguard Worker   void paddb(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
544*795d594fSAndroid Build Coastguard Worker   void psubb(XmmRegister dst, XmmRegister src);
545*795d594fSAndroid Build Coastguard Worker 
546*795d594fSAndroid Build Coastguard Worker   void vpaddb(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
547*795d594fSAndroid Build Coastguard Worker   void vpaddw(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
548*795d594fSAndroid Build Coastguard Worker 
549*795d594fSAndroid Build Coastguard Worker   void paddw(XmmRegister dst, XmmRegister src);
550*795d594fSAndroid Build Coastguard Worker   void psubw(XmmRegister dst, XmmRegister src);
551*795d594fSAndroid Build Coastguard Worker   void pmullw(XmmRegister dst, XmmRegister src);
552*795d594fSAndroid Build Coastguard Worker   void vpmullw(XmmRegister dst, XmmRegister src1, XmmRegister src2);
553*795d594fSAndroid Build Coastguard Worker 
554*795d594fSAndroid Build Coastguard Worker   void vpsubb(XmmRegister dst, XmmRegister src1, XmmRegister src2);
555*795d594fSAndroid Build Coastguard Worker   void vpsubw(XmmRegister dst, XmmRegister src1, XmmRegister src2);
556*795d594fSAndroid Build Coastguard Worker   void vpsubd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
557*795d594fSAndroid Build Coastguard Worker 
558*795d594fSAndroid Build Coastguard Worker   void paddd(XmmRegister dst, XmmRegister src);
559*795d594fSAndroid Build Coastguard Worker   void psubd(XmmRegister dst, XmmRegister src);
560*795d594fSAndroid Build Coastguard Worker   void pmulld(XmmRegister dst, XmmRegister src);
561*795d594fSAndroid Build Coastguard Worker 
562*795d594fSAndroid Build Coastguard Worker   void vpmulld(XmmRegister dst, XmmRegister src1, XmmRegister src2);
563*795d594fSAndroid Build Coastguard Worker 
564*795d594fSAndroid Build Coastguard Worker   void vpaddd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
565*795d594fSAndroid Build Coastguard Worker 
566*795d594fSAndroid Build Coastguard Worker   void paddq(XmmRegister dst, XmmRegister src);
567*795d594fSAndroid Build Coastguard Worker   void psubq(XmmRegister dst, XmmRegister src);
568*795d594fSAndroid Build Coastguard Worker 
569*795d594fSAndroid Build Coastguard Worker   void vpaddq(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
570*795d594fSAndroid Build Coastguard Worker   void vpsubq(XmmRegister dst, XmmRegister add_left, XmmRegister add_right);
571*795d594fSAndroid Build Coastguard Worker 
572*795d594fSAndroid Build Coastguard Worker   void paddusb(XmmRegister dst, XmmRegister src);
573*795d594fSAndroid Build Coastguard Worker   void paddsb(XmmRegister dst, XmmRegister src);
574*795d594fSAndroid Build Coastguard Worker   void paddusw(XmmRegister dst, XmmRegister src);
575*795d594fSAndroid Build Coastguard Worker   void paddsw(XmmRegister dst, XmmRegister src);
576*795d594fSAndroid Build Coastguard Worker   void psubusb(XmmRegister dst, XmmRegister src);
577*795d594fSAndroid Build Coastguard Worker   void psubsb(XmmRegister dst, XmmRegister src);
578*795d594fSAndroid Build Coastguard Worker   void psubusw(XmmRegister dst, XmmRegister src);
579*795d594fSAndroid Build Coastguard Worker   void psubsw(XmmRegister dst, XmmRegister src);
580*795d594fSAndroid Build Coastguard Worker 
581*795d594fSAndroid Build Coastguard Worker   void cvtsi2ss(XmmRegister dst, Register src);
582*795d594fSAndroid Build Coastguard Worker   void cvtsi2sd(XmmRegister dst, Register src);
583*795d594fSAndroid Build Coastguard Worker 
584*795d594fSAndroid Build Coastguard Worker   void cvtss2si(Register dst, XmmRegister src);
585*795d594fSAndroid Build Coastguard Worker   void cvtss2sd(XmmRegister dst, XmmRegister src);
586*795d594fSAndroid Build Coastguard Worker 
587*795d594fSAndroid Build Coastguard Worker   void cvtsd2si(Register dst, XmmRegister src);
588*795d594fSAndroid Build Coastguard Worker   void cvtsd2ss(XmmRegister dst, XmmRegister src);
589*795d594fSAndroid Build Coastguard Worker 
590*795d594fSAndroid Build Coastguard Worker   void cvttss2si(Register dst, XmmRegister src);
591*795d594fSAndroid Build Coastguard Worker   void cvttsd2si(Register dst, XmmRegister src);
592*795d594fSAndroid Build Coastguard Worker 
593*795d594fSAndroid Build Coastguard Worker   void cvtdq2ps(XmmRegister dst, XmmRegister src);
594*795d594fSAndroid Build Coastguard Worker   void cvtdq2pd(XmmRegister dst, XmmRegister src);
595*795d594fSAndroid Build Coastguard Worker 
596*795d594fSAndroid Build Coastguard Worker   void comiss(XmmRegister a, XmmRegister b);
597*795d594fSAndroid Build Coastguard Worker   void comiss(XmmRegister a, const Address& b);
598*795d594fSAndroid Build Coastguard Worker   void comisd(XmmRegister a, XmmRegister b);
599*795d594fSAndroid Build Coastguard Worker   void comisd(XmmRegister a, const Address& b);
600*795d594fSAndroid Build Coastguard Worker   void ucomiss(XmmRegister a, XmmRegister b);
601*795d594fSAndroid Build Coastguard Worker   void ucomiss(XmmRegister a, const Address& b);
602*795d594fSAndroid Build Coastguard Worker   void ucomisd(XmmRegister a, XmmRegister b);
603*795d594fSAndroid Build Coastguard Worker   void ucomisd(XmmRegister a, const Address& b);
604*795d594fSAndroid Build Coastguard Worker 
605*795d594fSAndroid Build Coastguard Worker   void roundsd(XmmRegister dst, XmmRegister src, const Immediate& imm);
606*795d594fSAndroid Build Coastguard Worker   void roundss(XmmRegister dst, XmmRegister src, const Immediate& imm);
607*795d594fSAndroid Build Coastguard Worker 
608*795d594fSAndroid Build Coastguard Worker   void sqrtsd(XmmRegister dst, XmmRegister src);
609*795d594fSAndroid Build Coastguard Worker   void sqrtss(XmmRegister dst, XmmRegister src);
610*795d594fSAndroid Build Coastguard Worker 
611*795d594fSAndroid Build Coastguard Worker   void xorpd(XmmRegister dst, const Address& src);
612*795d594fSAndroid Build Coastguard Worker   void xorpd(XmmRegister dst, XmmRegister src);
613*795d594fSAndroid Build Coastguard Worker   void xorps(XmmRegister dst, const Address& src);
614*795d594fSAndroid Build Coastguard Worker   void xorps(XmmRegister dst, XmmRegister src);
615*795d594fSAndroid Build Coastguard Worker   void pxor(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
616*795d594fSAndroid Build Coastguard Worker   void vpxor(XmmRegister dst, XmmRegister src1, XmmRegister src2);
617*795d594fSAndroid Build Coastguard Worker   void vxorps(XmmRegister dst, XmmRegister src1, XmmRegister src2);
618*795d594fSAndroid Build Coastguard Worker   void vxorpd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
619*795d594fSAndroid Build Coastguard Worker 
620*795d594fSAndroid Build Coastguard Worker   void andpd(XmmRegister dst, XmmRegister src);
621*795d594fSAndroid Build Coastguard Worker   void andpd(XmmRegister dst, const Address& src);
622*795d594fSAndroid Build Coastguard Worker   void andps(XmmRegister dst, XmmRegister src);
623*795d594fSAndroid Build Coastguard Worker   void andps(XmmRegister dst, const Address& src);
624*795d594fSAndroid Build Coastguard Worker   void pand(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
625*795d594fSAndroid Build Coastguard Worker   void vpand(XmmRegister dst, XmmRegister src1, XmmRegister src2);
626*795d594fSAndroid Build Coastguard Worker   void vandps(XmmRegister dst, XmmRegister src1, XmmRegister src2);
627*795d594fSAndroid Build Coastguard Worker   void vandpd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
628*795d594fSAndroid Build Coastguard Worker 
629*795d594fSAndroid Build Coastguard Worker   void andn(Register dst, Register src1, Register src2);  // no addr variant (for now)
630*795d594fSAndroid Build Coastguard Worker   void andnpd(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
631*795d594fSAndroid Build Coastguard Worker   void andnps(XmmRegister dst, XmmRegister src);
632*795d594fSAndroid Build Coastguard Worker   void pandn(XmmRegister dst, XmmRegister src);
633*795d594fSAndroid Build Coastguard Worker   void vpandn(XmmRegister dst, XmmRegister src1, XmmRegister src2);
634*795d594fSAndroid Build Coastguard Worker   void vandnps(XmmRegister dst, XmmRegister src1, XmmRegister src2);
635*795d594fSAndroid Build Coastguard Worker   void vandnpd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
636*795d594fSAndroid Build Coastguard Worker 
637*795d594fSAndroid Build Coastguard Worker   void orpd(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
638*795d594fSAndroid Build Coastguard Worker   void orps(XmmRegister dst, XmmRegister src);
639*795d594fSAndroid Build Coastguard Worker   void por(XmmRegister dst, XmmRegister src);
640*795d594fSAndroid Build Coastguard Worker   void vpor(XmmRegister dst, XmmRegister src1, XmmRegister src2);
641*795d594fSAndroid Build Coastguard Worker   void vorps(XmmRegister dst, XmmRegister src1, XmmRegister src2);
642*795d594fSAndroid Build Coastguard Worker   void vorpd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
643*795d594fSAndroid Build Coastguard Worker 
644*795d594fSAndroid Build Coastguard Worker   void pavgb(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
645*795d594fSAndroid Build Coastguard Worker   void pavgw(XmmRegister dst, XmmRegister src);
646*795d594fSAndroid Build Coastguard Worker   void psadbw(XmmRegister dst, XmmRegister src);
647*795d594fSAndroid Build Coastguard Worker   void pmaddwd(XmmRegister dst, XmmRegister src);
648*795d594fSAndroid Build Coastguard Worker   void vpmaddwd(XmmRegister dst, XmmRegister src1, XmmRegister src2);
649*795d594fSAndroid Build Coastguard Worker   void phaddw(XmmRegister dst, XmmRegister src);
650*795d594fSAndroid Build Coastguard Worker   void phaddd(XmmRegister dst, XmmRegister src);
651*795d594fSAndroid Build Coastguard Worker   void haddps(XmmRegister dst, XmmRegister src);
652*795d594fSAndroid Build Coastguard Worker   void haddpd(XmmRegister dst, XmmRegister src);
653*795d594fSAndroid Build Coastguard Worker   void phsubw(XmmRegister dst, XmmRegister src);
654*795d594fSAndroid Build Coastguard Worker   void phsubd(XmmRegister dst, XmmRegister src);
655*795d594fSAndroid Build Coastguard Worker   void hsubps(XmmRegister dst, XmmRegister src);
656*795d594fSAndroid Build Coastguard Worker   void hsubpd(XmmRegister dst, XmmRegister src);
657*795d594fSAndroid Build Coastguard Worker 
658*795d594fSAndroid Build Coastguard Worker   void pminsb(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
659*795d594fSAndroid Build Coastguard Worker   void pmaxsb(XmmRegister dst, XmmRegister src);
660*795d594fSAndroid Build Coastguard Worker   void pminsw(XmmRegister dst, XmmRegister src);
661*795d594fSAndroid Build Coastguard Worker   void pmaxsw(XmmRegister dst, XmmRegister src);
662*795d594fSAndroid Build Coastguard Worker   void pminsd(XmmRegister dst, XmmRegister src);
663*795d594fSAndroid Build Coastguard Worker   void pmaxsd(XmmRegister dst, XmmRegister src);
664*795d594fSAndroid Build Coastguard Worker 
665*795d594fSAndroid Build Coastguard Worker   void pminub(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
666*795d594fSAndroid Build Coastguard Worker   void pmaxub(XmmRegister dst, XmmRegister src);
667*795d594fSAndroid Build Coastguard Worker   void pminuw(XmmRegister dst, XmmRegister src);
668*795d594fSAndroid Build Coastguard Worker   void pmaxuw(XmmRegister dst, XmmRegister src);
669*795d594fSAndroid Build Coastguard Worker   void pminud(XmmRegister dst, XmmRegister src);
670*795d594fSAndroid Build Coastguard Worker   void pmaxud(XmmRegister dst, XmmRegister src);
671*795d594fSAndroid Build Coastguard Worker 
672*795d594fSAndroid Build Coastguard Worker   void minps(XmmRegister dst, XmmRegister src);  // no addr variant (for now)
673*795d594fSAndroid Build Coastguard Worker   void maxps(XmmRegister dst, XmmRegister src);
674*795d594fSAndroid Build Coastguard Worker   void minpd(XmmRegister dst, XmmRegister src);
675*795d594fSAndroid Build Coastguard Worker   void maxpd(XmmRegister dst, XmmRegister src);
676*795d594fSAndroid Build Coastguard Worker 
677*795d594fSAndroid Build Coastguard Worker   void pcmpeqb(XmmRegister dst, XmmRegister src);
678*795d594fSAndroid Build Coastguard Worker   void pcmpeqw(XmmRegister dst, XmmRegister src);
679*795d594fSAndroid Build Coastguard Worker   void pcmpeqd(XmmRegister dst, XmmRegister src);
680*795d594fSAndroid Build Coastguard Worker   void pcmpeqq(XmmRegister dst, XmmRegister src);
681*795d594fSAndroid Build Coastguard Worker 
682*795d594fSAndroid Build Coastguard Worker   void pcmpgtb(XmmRegister dst, XmmRegister src);
683*795d594fSAndroid Build Coastguard Worker   void pcmpgtw(XmmRegister dst, XmmRegister src);
684*795d594fSAndroid Build Coastguard Worker   void pcmpgtd(XmmRegister dst, XmmRegister src);
685*795d594fSAndroid Build Coastguard Worker   void pcmpgtq(XmmRegister dst, XmmRegister src);  // SSE4.2
686*795d594fSAndroid Build Coastguard Worker 
687*795d594fSAndroid Build Coastguard Worker   void shufpd(XmmRegister dst, XmmRegister src, const Immediate& imm);
688*795d594fSAndroid Build Coastguard Worker   void shufps(XmmRegister dst, XmmRegister src, const Immediate& imm);
689*795d594fSAndroid Build Coastguard Worker   void pshufd(XmmRegister dst, XmmRegister src, const Immediate& imm);
690*795d594fSAndroid Build Coastguard Worker 
691*795d594fSAndroid Build Coastguard Worker   void punpcklbw(XmmRegister dst, XmmRegister src);
692*795d594fSAndroid Build Coastguard Worker   void punpcklwd(XmmRegister dst, XmmRegister src);
693*795d594fSAndroid Build Coastguard Worker   void punpckldq(XmmRegister dst, XmmRegister src);
694*795d594fSAndroid Build Coastguard Worker   void punpcklqdq(XmmRegister dst, XmmRegister src);
695*795d594fSAndroid Build Coastguard Worker 
696*795d594fSAndroid Build Coastguard Worker   void punpckhbw(XmmRegister dst, XmmRegister src);
697*795d594fSAndroid Build Coastguard Worker   void punpckhwd(XmmRegister dst, XmmRegister src);
698*795d594fSAndroid Build Coastguard Worker   void punpckhdq(XmmRegister dst, XmmRegister src);
699*795d594fSAndroid Build Coastguard Worker   void punpckhqdq(XmmRegister dst, XmmRegister src);
700*795d594fSAndroid Build Coastguard Worker 
701*795d594fSAndroid Build Coastguard Worker   void psllw(XmmRegister reg, const Immediate& shift_count);
702*795d594fSAndroid Build Coastguard Worker   void pslld(XmmRegister reg, const Immediate& shift_count);
703*795d594fSAndroid Build Coastguard Worker   void psllq(XmmRegister reg, const Immediate& shift_count);
704*795d594fSAndroid Build Coastguard Worker 
705*795d594fSAndroid Build Coastguard Worker   void psraw(XmmRegister reg, const Immediate& shift_count);
706*795d594fSAndroid Build Coastguard Worker   void psrad(XmmRegister reg, const Immediate& shift_count);
707*795d594fSAndroid Build Coastguard Worker   // no psraq
708*795d594fSAndroid Build Coastguard Worker 
709*795d594fSAndroid Build Coastguard Worker   void psrlw(XmmRegister reg, const Immediate& shift_count);
710*795d594fSAndroid Build Coastguard Worker   void psrld(XmmRegister reg, const Immediate& shift_count);
711*795d594fSAndroid Build Coastguard Worker   void psrlq(XmmRegister reg, const Immediate& shift_count);
712*795d594fSAndroid Build Coastguard Worker   void psrldq(XmmRegister reg, const Immediate& shift_count);
713*795d594fSAndroid Build Coastguard Worker 
714*795d594fSAndroid Build Coastguard Worker   void flds(const Address& src);
715*795d594fSAndroid Build Coastguard Worker   void fstps(const Address& dst);
716*795d594fSAndroid Build Coastguard Worker   void fsts(const Address& dst);
717*795d594fSAndroid Build Coastguard Worker 
718*795d594fSAndroid Build Coastguard Worker   void fldl(const Address& src);
719*795d594fSAndroid Build Coastguard Worker   void fstpl(const Address& dst);
720*795d594fSAndroid Build Coastguard Worker   void fstl(const Address& dst);
721*795d594fSAndroid Build Coastguard Worker 
722*795d594fSAndroid Build Coastguard Worker   void fstsw();
723*795d594fSAndroid Build Coastguard Worker 
724*795d594fSAndroid Build Coastguard Worker   void fucompp();
725*795d594fSAndroid Build Coastguard Worker 
726*795d594fSAndroid Build Coastguard Worker   void fnstcw(const Address& dst);
727*795d594fSAndroid Build Coastguard Worker   void fldcw(const Address& src);
728*795d594fSAndroid Build Coastguard Worker 
729*795d594fSAndroid Build Coastguard Worker   void fistpl(const Address& dst);
730*795d594fSAndroid Build Coastguard Worker   void fistps(const Address& dst);
731*795d594fSAndroid Build Coastguard Worker   void fildl(const Address& src);
732*795d594fSAndroid Build Coastguard Worker   void filds(const Address& src);
733*795d594fSAndroid Build Coastguard Worker 
734*795d594fSAndroid Build Coastguard Worker   void fincstp();
735*795d594fSAndroid Build Coastguard Worker   void ffree(const Immediate& index);
736*795d594fSAndroid Build Coastguard Worker 
737*795d594fSAndroid Build Coastguard Worker   void fsin();
738*795d594fSAndroid Build Coastguard Worker   void fcos();
739*795d594fSAndroid Build Coastguard Worker   void fptan();
740*795d594fSAndroid Build Coastguard Worker   void fprem();
741*795d594fSAndroid Build Coastguard Worker 
742*795d594fSAndroid Build Coastguard Worker   void xchgb(ByteRegister dst, ByteRegister src);
743*795d594fSAndroid Build Coastguard Worker   void xchgb(ByteRegister reg, const Address& address);
744*795d594fSAndroid Build Coastguard Worker 
745*795d594fSAndroid Build Coastguard Worker   // Wrappers for `xchgb` that accept `Register` instead of `ByteRegister` (used for testing).
746*795d594fSAndroid Build Coastguard Worker   void xchgb(Register dst, Register src);
747*795d594fSAndroid Build Coastguard Worker   void xchgb(Register reg, const Address& address);
748*795d594fSAndroid Build Coastguard Worker 
749*795d594fSAndroid Build Coastguard Worker   void xchgw(Register dst, Register src);
750*795d594fSAndroid Build Coastguard Worker   void xchgw(Register reg, const Address& address);
751*795d594fSAndroid Build Coastguard Worker 
752*795d594fSAndroid Build Coastguard Worker   void xchgl(Register dst, Register src);
753*795d594fSAndroid Build Coastguard Worker   void xchgl(Register reg, const Address& address);
754*795d594fSAndroid Build Coastguard Worker 
755*795d594fSAndroid Build Coastguard Worker   void cmpb(const Address& address, const Immediate& imm);
756*795d594fSAndroid Build Coastguard Worker   void cmpw(const Address& address, const Immediate& imm);
757*795d594fSAndroid Build Coastguard Worker 
758*795d594fSAndroid Build Coastguard Worker   void cmpl(Register reg, const Immediate& imm);
759*795d594fSAndroid Build Coastguard Worker   void cmpl(Register reg0, Register reg1);
760*795d594fSAndroid Build Coastguard Worker   void cmpl(Register reg, const Address& address);
761*795d594fSAndroid Build Coastguard Worker 
762*795d594fSAndroid Build Coastguard Worker   void cmpl(const Address& address, Register reg);
763*795d594fSAndroid Build Coastguard Worker   void cmpl(const Address& address, const Immediate& imm);
764*795d594fSAndroid Build Coastguard Worker 
765*795d594fSAndroid Build Coastguard Worker   void testl(Register reg1, Register reg2);
766*795d594fSAndroid Build Coastguard Worker   void testl(Register reg, const Immediate& imm);
767*795d594fSAndroid Build Coastguard Worker   void testl(Register reg1, const Address& address);
768*795d594fSAndroid Build Coastguard Worker 
769*795d594fSAndroid Build Coastguard Worker   void testb(const Address& dst, const Immediate& imm);
770*795d594fSAndroid Build Coastguard Worker   void testl(const Address& dst, const Immediate& imm);
771*795d594fSAndroid Build Coastguard Worker 
772*795d594fSAndroid Build Coastguard Worker   void andl(Register dst, const Immediate& imm);
773*795d594fSAndroid Build Coastguard Worker   void andl(Register dst, Register src);
774*795d594fSAndroid Build Coastguard Worker   void andl(Register dst, const Address& address);
775*795d594fSAndroid Build Coastguard Worker   void andw(const Address& address, const Immediate& imm);
776*795d594fSAndroid Build Coastguard Worker 
777*795d594fSAndroid Build Coastguard Worker   void orl(Register dst, const Immediate& imm);
778*795d594fSAndroid Build Coastguard Worker   void orl(Register dst, Register src);
779*795d594fSAndroid Build Coastguard Worker   void orl(Register dst, const Address& address);
780*795d594fSAndroid Build Coastguard Worker 
781*795d594fSAndroid Build Coastguard Worker   void xorl(Register dst, Register src);
782*795d594fSAndroid Build Coastguard Worker   void xorl(Register dst, const Immediate& imm);
783*795d594fSAndroid Build Coastguard Worker   void xorl(Register dst, const Address& address);
784*795d594fSAndroid Build Coastguard Worker 
785*795d594fSAndroid Build Coastguard Worker   void addl(Register dst, Register src);
786*795d594fSAndroid Build Coastguard Worker   void addl(Register reg, const Immediate& imm);
787*795d594fSAndroid Build Coastguard Worker   void addl(Register reg, const Address& address);
788*795d594fSAndroid Build Coastguard Worker 
789*795d594fSAndroid Build Coastguard Worker   void addl(const Address& address, Register reg);
790*795d594fSAndroid Build Coastguard Worker   void addl(const Address& address, const Immediate& imm);
791*795d594fSAndroid Build Coastguard Worker   void addw(const Address& address, const Immediate& imm);
792*795d594fSAndroid Build Coastguard Worker   void addw(Register reg, const Immediate& imm);
793*795d594fSAndroid Build Coastguard Worker 
794*795d594fSAndroid Build Coastguard Worker   void adcl(Register dst, Register src);
795*795d594fSAndroid Build Coastguard Worker   void adcl(Register reg, const Immediate& imm);
796*795d594fSAndroid Build Coastguard Worker   void adcl(Register dst, const Address& address);
797*795d594fSAndroid Build Coastguard Worker 
798*795d594fSAndroid Build Coastguard Worker   void subl(Register dst, Register src);
799*795d594fSAndroid Build Coastguard Worker   void subl(Register reg, const Immediate& imm);
800*795d594fSAndroid Build Coastguard Worker   void subl(Register reg, const Address& address);
801*795d594fSAndroid Build Coastguard Worker   void subl(const Address& address, Register src);
802*795d594fSAndroid Build Coastguard Worker 
803*795d594fSAndroid Build Coastguard Worker   void cdq();
804*795d594fSAndroid Build Coastguard Worker 
805*795d594fSAndroid Build Coastguard Worker   void idivl(Register reg);
806*795d594fSAndroid Build Coastguard Worker   void divl(Register reg);
807*795d594fSAndroid Build Coastguard Worker 
808*795d594fSAndroid Build Coastguard Worker   void imull(Register dst, Register src);
809*795d594fSAndroid Build Coastguard Worker   void imull(Register reg, const Immediate& imm);
810*795d594fSAndroid Build Coastguard Worker   void imull(Register dst, Register src, const Immediate& imm);
811*795d594fSAndroid Build Coastguard Worker   void imull(Register reg, const Address& address);
812*795d594fSAndroid Build Coastguard Worker 
813*795d594fSAndroid Build Coastguard Worker   void imull(Register reg);
814*795d594fSAndroid Build Coastguard Worker   void imull(const Address& address);
815*795d594fSAndroid Build Coastguard Worker 
816*795d594fSAndroid Build Coastguard Worker   void mull(Register reg);
817*795d594fSAndroid Build Coastguard Worker   void mull(const Address& address);
818*795d594fSAndroid Build Coastguard Worker 
819*795d594fSAndroid Build Coastguard Worker   void sbbl(Register dst, Register src);
820*795d594fSAndroid Build Coastguard Worker   void sbbl(Register reg, const Immediate& imm);
821*795d594fSAndroid Build Coastguard Worker   void sbbl(Register reg, const Address& address);
822*795d594fSAndroid Build Coastguard Worker   void sbbl(const Address& address, Register src);
823*795d594fSAndroid Build Coastguard Worker 
824*795d594fSAndroid Build Coastguard Worker   void incl(Register reg);
825*795d594fSAndroid Build Coastguard Worker   void incl(const Address& address);
826*795d594fSAndroid Build Coastguard Worker 
827*795d594fSAndroid Build Coastguard Worker   void decl(Register reg);
828*795d594fSAndroid Build Coastguard Worker   void decl(const Address& address);
829*795d594fSAndroid Build Coastguard Worker 
830*795d594fSAndroid Build Coastguard Worker   void shll(Register reg, const Immediate& imm);
831*795d594fSAndroid Build Coastguard Worker   void shll(Register operand, Register shifter);
832*795d594fSAndroid Build Coastguard Worker   void shll(const Address& address, const Immediate& imm);
833*795d594fSAndroid Build Coastguard Worker   void shll(const Address& address, Register shifter);
834*795d594fSAndroid Build Coastguard Worker   void shrl(Register reg, const Immediate& imm);
835*795d594fSAndroid Build Coastguard Worker   void shrl(Register operand, Register shifter);
836*795d594fSAndroid Build Coastguard Worker   void shrl(const Address& address, const Immediate& imm);
837*795d594fSAndroid Build Coastguard Worker   void shrl(const Address& address, Register shifter);
838*795d594fSAndroid Build Coastguard Worker   void sarl(Register reg, const Immediate& imm);
839*795d594fSAndroid Build Coastguard Worker   void sarl(Register operand, Register shifter);
840*795d594fSAndroid Build Coastguard Worker   void sarl(const Address& address, const Immediate& imm);
841*795d594fSAndroid Build Coastguard Worker   void sarl(const Address& address, Register shifter);
842*795d594fSAndroid Build Coastguard Worker   void shld(Register dst, Register src, Register shifter);
843*795d594fSAndroid Build Coastguard Worker   void shld(Register dst, Register src, const Immediate& imm);
844*795d594fSAndroid Build Coastguard Worker   void shrd(Register dst, Register src, Register shifter);
845*795d594fSAndroid Build Coastguard Worker   void shrd(Register dst, Register src, const Immediate& imm);
846*795d594fSAndroid Build Coastguard Worker 
847*795d594fSAndroid Build Coastguard Worker   void negl(Register reg);
848*795d594fSAndroid Build Coastguard Worker   void notl(Register reg);
849*795d594fSAndroid Build Coastguard Worker 
850*795d594fSAndroid Build Coastguard Worker   void enter(const Immediate& imm);
851*795d594fSAndroid Build Coastguard Worker   void leave();
852*795d594fSAndroid Build Coastguard Worker 
853*795d594fSAndroid Build Coastguard Worker   void ret();
854*795d594fSAndroid Build Coastguard Worker   void ret(const Immediate& imm);
855*795d594fSAndroid Build Coastguard Worker 
856*795d594fSAndroid Build Coastguard Worker   void nop();
857*795d594fSAndroid Build Coastguard Worker   void int3();
858*795d594fSAndroid Build Coastguard Worker   void hlt();
859*795d594fSAndroid Build Coastguard Worker 
860*795d594fSAndroid Build Coastguard Worker   void j(Condition condition, Label* label);
861*795d594fSAndroid Build Coastguard Worker   void j(Condition condition, NearLabel* label);
862*795d594fSAndroid Build Coastguard Worker   void jecxz(NearLabel* label);
863*795d594fSAndroid Build Coastguard Worker 
864*795d594fSAndroid Build Coastguard Worker   void jmp(Register reg);
865*795d594fSAndroid Build Coastguard Worker   void jmp(const Address& address);
866*795d594fSAndroid Build Coastguard Worker   void jmp(Label* label);
867*795d594fSAndroid Build Coastguard Worker   void jmp(NearLabel* label);
868*795d594fSAndroid Build Coastguard Worker 
869*795d594fSAndroid Build Coastguard Worker   void repne_scasb();
870*795d594fSAndroid Build Coastguard Worker   void repne_scasw();
871*795d594fSAndroid Build Coastguard Worker   void repe_cmpsb();
872*795d594fSAndroid Build Coastguard Worker   void repe_cmpsw();
873*795d594fSAndroid Build Coastguard Worker   void repe_cmpsl();
874*795d594fSAndroid Build Coastguard Worker   void rep_movsb();
875*795d594fSAndroid Build Coastguard Worker   void rep_movsl();
876*795d594fSAndroid Build Coastguard Worker   void rep_movsw();
877*795d594fSAndroid Build Coastguard Worker 
878*795d594fSAndroid Build Coastguard Worker   X86Assembler* lock();
879*795d594fSAndroid Build Coastguard Worker   void cmpxchgb(const Address& address, ByteRegister reg);
880*795d594fSAndroid Build Coastguard Worker   void cmpxchgw(const Address& address, Register reg);
881*795d594fSAndroid Build Coastguard Worker   void cmpxchgl(const Address& address, Register reg);
882*795d594fSAndroid Build Coastguard Worker   void cmpxchg8b(const Address& address);
883*795d594fSAndroid Build Coastguard Worker 
884*795d594fSAndroid Build Coastguard Worker   void xaddb(const Address& address, ByteRegister reg);
885*795d594fSAndroid Build Coastguard Worker   void xaddw(const Address& address, Register reg);
886*795d594fSAndroid Build Coastguard Worker   void xaddl(const Address& address, Register reg);
887*795d594fSAndroid Build Coastguard Worker 
888*795d594fSAndroid Build Coastguard Worker   void mfence();
889*795d594fSAndroid Build Coastguard Worker 
890*795d594fSAndroid Build Coastguard Worker   X86Assembler* fs();
891*795d594fSAndroid Build Coastguard Worker   X86Assembler* gs();
892*795d594fSAndroid Build Coastguard Worker 
893*795d594fSAndroid Build Coastguard Worker   //
894*795d594fSAndroid Build Coastguard Worker   // Macros for High-level operations.
895*795d594fSAndroid Build Coastguard Worker   //
896*795d594fSAndroid Build Coastguard Worker 
897*795d594fSAndroid Build Coastguard Worker   void AddImmediate(Register reg, const Immediate& imm);
898*795d594fSAndroid Build Coastguard Worker 
899*795d594fSAndroid Build Coastguard Worker   void LoadLongConstant(XmmRegister dst, int64_t value);
900*795d594fSAndroid Build Coastguard Worker   void LoadDoubleConstant(XmmRegister dst, double value);
901*795d594fSAndroid Build Coastguard Worker 
902*795d594fSAndroid Build Coastguard Worker   // For testing purpose (Repeat* functions expect Register rather than ByteRegister).
cmpxchgb(const Address & address,Register reg)903*795d594fSAndroid Build Coastguard Worker   void cmpxchgb(const Address& address, Register reg) {
904*795d594fSAndroid Build Coastguard Worker     cmpxchgb(address, static_cast<ByteRegister>(reg));
905*795d594fSAndroid Build Coastguard Worker   }
906*795d594fSAndroid Build Coastguard Worker 
907*795d594fSAndroid Build Coastguard Worker   // For testing purpose (Repeat* functions expect Register rather than ByteRegister).
LockCmpxchgb(const Address & address,Register reg)908*795d594fSAndroid Build Coastguard Worker   void LockCmpxchgb(const Address& address, Register reg) {
909*795d594fSAndroid Build Coastguard Worker     LockCmpxchgb(address, static_cast<ByteRegister>(reg));
910*795d594fSAndroid Build Coastguard Worker   }
911*795d594fSAndroid Build Coastguard Worker 
LockCmpxchgb(const Address & address,ByteRegister reg)912*795d594fSAndroid Build Coastguard Worker   void LockCmpxchgb(const Address& address, ByteRegister reg) {
913*795d594fSAndroid Build Coastguard Worker     lock()->cmpxchgb(address, reg);
914*795d594fSAndroid Build Coastguard Worker   }
915*795d594fSAndroid Build Coastguard Worker 
LockCmpxchgw(const Address & address,Register reg)916*795d594fSAndroid Build Coastguard Worker   void LockCmpxchgw(const Address& address, Register reg) {
917*795d594fSAndroid Build Coastguard Worker     AssemblerBuffer::EnsureCapacity ensured(&buffer_);
918*795d594fSAndroid Build Coastguard Worker     // We make sure that the operand size override bytecode is emited before the lock bytecode.
919*795d594fSAndroid Build Coastguard Worker     // We test against clang which enforces this bytecode order.
920*795d594fSAndroid Build Coastguard Worker     EmitOperandSizeOverride();
921*795d594fSAndroid Build Coastguard Worker     EmitUint8(0xF0);
922*795d594fSAndroid Build Coastguard Worker     EmitUint8(0x0F);
923*795d594fSAndroid Build Coastguard Worker     EmitUint8(0xB1);
924*795d594fSAndroid Build Coastguard Worker     EmitOperand(reg, address);
925*795d594fSAndroid Build Coastguard Worker   }
926*795d594fSAndroid Build Coastguard Worker 
LockCmpxchgl(const Address & address,Register reg)927*795d594fSAndroid Build Coastguard Worker   void LockCmpxchgl(const Address& address, Register reg) {
928*795d594fSAndroid Build Coastguard Worker     lock()->cmpxchgl(address, reg);
929*795d594fSAndroid Build Coastguard Worker   }
930*795d594fSAndroid Build Coastguard Worker 
LockCmpxchg8b(const Address & address)931*795d594fSAndroid Build Coastguard Worker   void LockCmpxchg8b(const Address& address) {
932*795d594fSAndroid Build Coastguard Worker     lock()->cmpxchg8b(address);
933*795d594fSAndroid Build Coastguard Worker   }
934*795d594fSAndroid Build Coastguard Worker 
935*795d594fSAndroid Build Coastguard Worker   // For testing purpose (Repeat* functions expect Register rather than ByteRegister).
LockXaddb(const Address & address,Register reg)936*795d594fSAndroid Build Coastguard Worker   void LockXaddb(const Address& address, Register reg) {
937*795d594fSAndroid Build Coastguard Worker     LockXaddb(address, static_cast<ByteRegister>(reg));
938*795d594fSAndroid Build Coastguard Worker   }
939*795d594fSAndroid Build Coastguard Worker 
LockXaddb(const Address & address,ByteRegister reg)940*795d594fSAndroid Build Coastguard Worker   void LockXaddb(const Address& address, ByteRegister reg) {
941*795d594fSAndroid Build Coastguard Worker     lock()->xaddb(address, reg);
942*795d594fSAndroid Build Coastguard Worker   }
943*795d594fSAndroid Build Coastguard Worker 
LockXaddw(const Address & address,Register reg)944*795d594fSAndroid Build Coastguard Worker   void LockXaddw(const Address& address, Register reg) {
945*795d594fSAndroid Build Coastguard Worker     AssemblerBuffer::EnsureCapacity ensured(&buffer_);
946*795d594fSAndroid Build Coastguard Worker     // We make sure that the operand size override bytecode is emited before the lock bytecode.
947*795d594fSAndroid Build Coastguard Worker     // We test against clang which enforces this bytecode order.
948*795d594fSAndroid Build Coastguard Worker     EmitOperandSizeOverride();
949*795d594fSAndroid Build Coastguard Worker     EmitUint8(0xF0);
950*795d594fSAndroid Build Coastguard Worker     EmitUint8(0x0F);
951*795d594fSAndroid Build Coastguard Worker     EmitUint8(0xC1);
952*795d594fSAndroid Build Coastguard Worker     EmitOperand(reg, address);
953*795d594fSAndroid Build Coastguard Worker   }
954*795d594fSAndroid Build Coastguard Worker 
LockXaddl(const Address & address,Register reg)955*795d594fSAndroid Build Coastguard Worker   void LockXaddl(const Address& address, Register reg) {
956*795d594fSAndroid Build Coastguard Worker     lock()->xaddl(address, reg);
957*795d594fSAndroid Build Coastguard Worker   }
958*795d594fSAndroid Build Coastguard Worker 
rdtsc()959*795d594fSAndroid Build Coastguard Worker   void rdtsc() {
960*795d594fSAndroid Build Coastguard Worker     AssemblerBuffer::EnsureCapacity ensured(&buffer_);
961*795d594fSAndroid Build Coastguard Worker     EmitUint8(0x0F);
962*795d594fSAndroid Build Coastguard Worker     EmitUint8(0x31);
963*795d594fSAndroid Build Coastguard Worker   }
964*795d594fSAndroid Build Coastguard Worker 
965*795d594fSAndroid Build Coastguard Worker   //
966*795d594fSAndroid Build Coastguard Worker   // Misc. functionality
967*795d594fSAndroid Build Coastguard Worker   //
PreferredLoopAlignment()968*795d594fSAndroid Build Coastguard Worker   int PreferredLoopAlignment() { return 16; }
969*795d594fSAndroid Build Coastguard Worker   void Align(int alignment, int offset);
970*795d594fSAndroid Build Coastguard Worker   void Bind(Label* label) override;
Jump(Label * label)971*795d594fSAndroid Build Coastguard Worker   void Jump(Label* label) override {
972*795d594fSAndroid Build Coastguard Worker     jmp(label);
973*795d594fSAndroid Build Coastguard Worker   }
974*795d594fSAndroid Build Coastguard Worker   void Bind(NearLabel* label);
975*795d594fSAndroid Build Coastguard Worker 
976*795d594fSAndroid Build Coastguard Worker   //
977*795d594fSAndroid Build Coastguard Worker   // Heap poisoning.
978*795d594fSAndroid Build Coastguard Worker   //
979*795d594fSAndroid Build Coastguard Worker 
980*795d594fSAndroid Build Coastguard Worker   // Poison a heap reference contained in `reg`.
PoisonHeapReference(Register reg)981*795d594fSAndroid Build Coastguard Worker   void PoisonHeapReference(Register reg) { negl(reg); }
982*795d594fSAndroid Build Coastguard Worker   // Unpoison a heap reference contained in `reg`.
UnpoisonHeapReference(Register reg)983*795d594fSAndroid Build Coastguard Worker   void UnpoisonHeapReference(Register reg) { negl(reg); }
984*795d594fSAndroid Build Coastguard Worker   // Poison a heap reference contained in `reg` if heap poisoning is enabled.
MaybePoisonHeapReference(Register reg)985*795d594fSAndroid Build Coastguard Worker   void MaybePoisonHeapReference(Register reg) {
986*795d594fSAndroid Build Coastguard Worker     if (kPoisonHeapReferences) {
987*795d594fSAndroid Build Coastguard Worker       PoisonHeapReference(reg);
988*795d594fSAndroid Build Coastguard Worker     }
989*795d594fSAndroid Build Coastguard Worker   }
990*795d594fSAndroid Build Coastguard Worker   // Unpoison a heap reference contained in `reg` if heap poisoning is enabled.
MaybeUnpoisonHeapReference(Register reg)991*795d594fSAndroid Build Coastguard Worker   void MaybeUnpoisonHeapReference(Register reg) {
992*795d594fSAndroid Build Coastguard Worker     if (kPoisonHeapReferences) {
993*795d594fSAndroid Build Coastguard Worker       UnpoisonHeapReference(reg);
994*795d594fSAndroid Build Coastguard Worker     }
995*795d594fSAndroid Build Coastguard Worker   }
996*795d594fSAndroid Build Coastguard Worker 
997*795d594fSAndroid Build Coastguard Worker   // Add a double to the constant area, returning the offset into
998*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
AddDouble(double v)999*795d594fSAndroid Build Coastguard Worker   size_t AddDouble(double v) { return constant_area_.AddDouble(v); }
1000*795d594fSAndroid Build Coastguard Worker 
1001*795d594fSAndroid Build Coastguard Worker   // Add a float to the constant area, returning the offset into
1002*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
AddFloat(float v)1003*795d594fSAndroid Build Coastguard Worker   size_t AddFloat(float v)   { return constant_area_.AddFloat(v); }
1004*795d594fSAndroid Build Coastguard Worker 
1005*795d594fSAndroid Build Coastguard Worker   // Add an int32_t to the constant area, returning the offset into
1006*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
AddInt32(int32_t v)1007*795d594fSAndroid Build Coastguard Worker   size_t AddInt32(int32_t v) {
1008*795d594fSAndroid Build Coastguard Worker     return constant_area_.AddInt32(v);
1009*795d594fSAndroid Build Coastguard Worker   }
1010*795d594fSAndroid Build Coastguard Worker 
1011*795d594fSAndroid Build Coastguard Worker   // Add an int32_t to the end of the constant area, returning the offset into
1012*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
AppendInt32(int32_t v)1013*795d594fSAndroid Build Coastguard Worker   size_t AppendInt32(int32_t v) {
1014*795d594fSAndroid Build Coastguard Worker     return constant_area_.AppendInt32(v);
1015*795d594fSAndroid Build Coastguard Worker   }
1016*795d594fSAndroid Build Coastguard Worker 
1017*795d594fSAndroid Build Coastguard Worker   // Add an int64_t to the constant area, returning the offset into
1018*795d594fSAndroid Build Coastguard Worker   // the constant area where the literal resides.
AddInt64(int64_t v)1019*795d594fSAndroid Build Coastguard Worker   size_t AddInt64(int64_t v) { return constant_area_.AddInt64(v); }
1020*795d594fSAndroid Build Coastguard Worker 
1021*795d594fSAndroid Build Coastguard Worker   // Add the contents of the constant area to the assembler buffer.
1022*795d594fSAndroid Build Coastguard Worker   void AddConstantArea();
1023*795d594fSAndroid Build Coastguard Worker 
1024*795d594fSAndroid Build Coastguard Worker   // Is the constant area empty? Return true if there are no literals in the constant area.
IsConstantAreaEmpty()1025*795d594fSAndroid Build Coastguard Worker   bool IsConstantAreaEmpty() const { return constant_area_.IsEmpty(); }
1026*795d594fSAndroid Build Coastguard Worker 
1027*795d594fSAndroid Build Coastguard Worker   // Return the current size of the constant area.
ConstantAreaSize()1028*795d594fSAndroid Build Coastguard Worker   size_t ConstantAreaSize() const { return constant_area_.GetSize(); }
1029*795d594fSAndroid Build Coastguard Worker 
1030*795d594fSAndroid Build Coastguard Worker   bool CpuHasAVXorAVX2FeatureFlag();
1031*795d594fSAndroid Build Coastguard Worker 
1032*795d594fSAndroid Build Coastguard Worker  private:
1033*795d594fSAndroid Build Coastguard Worker   inline void EmitUint8(uint8_t value);
1034*795d594fSAndroid Build Coastguard Worker   inline void EmitInt32(int32_t value);
1035*795d594fSAndroid Build Coastguard Worker   inline void EmitRegisterOperand(int rm, int reg);
1036*795d594fSAndroid Build Coastguard Worker   inline void EmitXmmRegisterOperand(int rm, XmmRegister reg);
1037*795d594fSAndroid Build Coastguard Worker   inline void EmitFixup(AssemblerFixup* fixup);
1038*795d594fSAndroid Build Coastguard Worker   inline void EmitOperandSizeOverride();
1039*795d594fSAndroid Build Coastguard Worker 
1040*795d594fSAndroid Build Coastguard Worker   void EmitOperand(int rm, const Operand& operand);
1041*795d594fSAndroid Build Coastguard Worker   void EmitImmediate(const Immediate& imm, bool is_16_op = false);
1042*795d594fSAndroid Build Coastguard Worker   void EmitComplex(
1043*795d594fSAndroid Build Coastguard Worker       int rm, const Operand& operand, const Immediate& immediate, bool is_16_op = false);
1044*795d594fSAndroid Build Coastguard Worker   void EmitLabel(Label* label, int instruction_size);
1045*795d594fSAndroid Build Coastguard Worker   void EmitLabelLink(Label* label);
1046*795d594fSAndroid Build Coastguard Worker   void EmitLabelLink(NearLabel* label);
1047*795d594fSAndroid Build Coastguard Worker 
1048*795d594fSAndroid Build Coastguard Worker   void EmitGenericShift(int rm, const Operand& operand, const Immediate& imm);
1049*795d594fSAndroid Build Coastguard Worker   void EmitGenericShift(int rm, const Operand& operand, Register shifter);
1050*795d594fSAndroid Build Coastguard Worker 
1051*795d594fSAndroid Build Coastguard Worker   uint8_t EmitVexPrefixByteZero(bool is_twobyte_form);
1052*795d594fSAndroid Build Coastguard Worker   uint8_t EmitVexPrefixByteOne(bool R, bool X, bool B, int SET_VEX_M);
1053*795d594fSAndroid Build Coastguard Worker   uint8_t EmitVexPrefixByteOne(bool R,
1054*795d594fSAndroid Build Coastguard Worker                                X86ManagedRegister operand,
1055*795d594fSAndroid Build Coastguard Worker                                int SET_VEX_L,
1056*795d594fSAndroid Build Coastguard Worker                                int SET_VEX_PP);
1057*795d594fSAndroid Build Coastguard Worker   uint8_t EmitVexPrefixByteTwo(bool W,
1058*795d594fSAndroid Build Coastguard Worker                                X86ManagedRegister operand,
1059*795d594fSAndroid Build Coastguard Worker                                int SET_VEX_L,
1060*795d594fSAndroid Build Coastguard Worker                                int SET_VEX_PP);
1061*795d594fSAndroid Build Coastguard Worker   uint8_t EmitVexPrefixByteTwo(bool W,
1062*795d594fSAndroid Build Coastguard Worker                                int SET_VEX_L,
1063*795d594fSAndroid Build Coastguard Worker                                int SET_VEX_PP);
1064*795d594fSAndroid Build Coastguard Worker 
1065*795d594fSAndroid Build Coastguard Worker   // Helper function to emit a shorter variant of XCHG for when at least one operand is EAX/AX.
1066*795d594fSAndroid Build Coastguard Worker   bool try_xchg_eax(Register dst, Register src);
1067*795d594fSAndroid Build Coastguard Worker 
1068*795d594fSAndroid Build Coastguard Worker   ConstantArea constant_area_;
1069*795d594fSAndroid Build Coastguard Worker   bool has_AVX_;     // x86 256bit SIMD AVX.
1070*795d594fSAndroid Build Coastguard Worker   bool has_AVX2_;    // x86 256bit SIMD AVX 2.0.
1071*795d594fSAndroid Build Coastguard Worker 
1072*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(X86Assembler);
1073*795d594fSAndroid Build Coastguard Worker };
1074*795d594fSAndroid Build Coastguard Worker 
EmitUint8(uint8_t value)1075*795d594fSAndroid Build Coastguard Worker inline void X86Assembler::EmitUint8(uint8_t value) {
1076*795d594fSAndroid Build Coastguard Worker   buffer_.Emit<uint8_t>(value);
1077*795d594fSAndroid Build Coastguard Worker }
1078*795d594fSAndroid Build Coastguard Worker 
EmitInt32(int32_t value)1079*795d594fSAndroid Build Coastguard Worker inline void X86Assembler::EmitInt32(int32_t value) {
1080*795d594fSAndroid Build Coastguard Worker   buffer_.Emit<int32_t>(value);
1081*795d594fSAndroid Build Coastguard Worker }
1082*795d594fSAndroid Build Coastguard Worker 
EmitRegisterOperand(int rm,int reg)1083*795d594fSAndroid Build Coastguard Worker inline void X86Assembler::EmitRegisterOperand(int rm, int reg) {
1084*795d594fSAndroid Build Coastguard Worker   CHECK_GE(rm, 0);
1085*795d594fSAndroid Build Coastguard Worker   CHECK_LT(rm, 8);
1086*795d594fSAndroid Build Coastguard Worker   buffer_.Emit<uint8_t>(0xC0 + (rm << 3) + reg);
1087*795d594fSAndroid Build Coastguard Worker }
1088*795d594fSAndroid Build Coastguard Worker 
EmitXmmRegisterOperand(int rm,XmmRegister reg)1089*795d594fSAndroid Build Coastguard Worker inline void X86Assembler::EmitXmmRegisterOperand(int rm, XmmRegister reg) {
1090*795d594fSAndroid Build Coastguard Worker   EmitRegisterOperand(rm, static_cast<Register>(reg));
1091*795d594fSAndroid Build Coastguard Worker }
1092*795d594fSAndroid Build Coastguard Worker 
EmitFixup(AssemblerFixup * fixup)1093*795d594fSAndroid Build Coastguard Worker inline void X86Assembler::EmitFixup(AssemblerFixup* fixup) {
1094*795d594fSAndroid Build Coastguard Worker   buffer_.EmitFixup(fixup);
1095*795d594fSAndroid Build Coastguard Worker }
1096*795d594fSAndroid Build Coastguard Worker 
EmitOperandSizeOverride()1097*795d594fSAndroid Build Coastguard Worker inline void X86Assembler::EmitOperandSizeOverride() {
1098*795d594fSAndroid Build Coastguard Worker   EmitUint8(0x66);
1099*795d594fSAndroid Build Coastguard Worker }
1100*795d594fSAndroid Build Coastguard Worker 
1101*795d594fSAndroid Build Coastguard Worker }  // namespace x86
1102*795d594fSAndroid Build Coastguard Worker }  // namespace art
1103*795d594fSAndroid Build Coastguard Worker 
1104*795d594fSAndroid Build Coastguard Worker #endif  // ART_COMPILER_UTILS_X86_ASSEMBLER_X86_H_
1105