assembler-ia32.h revision 44f0eee88ff00398ff7f715fab053374d808c90d
1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright (c) 1994-2006 Sun Microsystems Inc.
2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// All Rights Reserved.
3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met:
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// - Redistributions of source code must retain the above copyright notice,
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// this list of conditions and the following disclaimer.
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// - Redistribution in binary form must reproduce the above copyright
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// notice, this list of conditions and the following disclaimer in the
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// documentation and/or other materials provided with the distribution.
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// - Neither the name of Sun Microsystems or the names of contributors may
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// be used to endorse or promote products derived from this software without
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// specific prior written permission.
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// The original source code covered by the above license above has been
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modified significantly by Google Inc.
331e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block// Copyright 2011 the V8 project authors. All rights reserved.
34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A light-weight IA32 Assembler.
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_IA32_ASSEMBLER_IA32_H_
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_IA32_ASSEMBLER_IA32_H_
39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
4044f0eee88ff00398ff7f715fab053374d808c90dSteve Block#include "isolate.h"
41d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block#include "serialize.h"
42d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 {
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal {
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// CPU Registers.
47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 1) We would prefer to use an enum, but enum values are assignment-
49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// compatible with int, which has caused code-generation bugs.
50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 2) We would prefer to use a class instead of a struct but we don't like
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// the register initialization to depend on the particular initialization
53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// order (which appears to be different on OS X, Linux, and Windows for the
54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// installed versions of C++ we tried). Using a struct permits C-style
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "initialization". Also, the Register objects cannot be const as this
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// forces initialization stubs in MSVC, making us dependent on initialization
57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// order.
58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 3) By not using an enum, we are possibly preventing the compiler from
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// doing certain constant folds, which may significantly reduce the
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// code generated for some assembly instructions (because they boil down
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// to a few constants). If this is a problem, we could change the code
63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// such that we use an enum in optimized mode, and the struct in debug
64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// mode. This way we get the compile-time error checking in debug mode
65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// and best performance in optimized code.
66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstruct Register {
681e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  static const int kNumAllocatableRegisters = 6;
69b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const int kNumRegisters = 8;
70b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
711e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  static inline const char* AllocationIndexToString(int index);
72b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
731e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  static inline int ToAllocationIndex(Register reg);
74b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
751e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  static inline Register FromAllocationIndex(int index);
76b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
77b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static Register from_code(int code) {
78b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    Register r = { code };
79b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    return r;
80b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  }
81b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; }
820d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  bool is(Register reg) const { return code_ == reg.code_; }
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // eax, ebx, ecx and edx are byte registers, the rest are not.
840d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  bool is_byte_register() const { return code_ <= 3; }
850d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  int code() const {
86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(is_valid());
87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return code_;
88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
890d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  int bit() const {
90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(is_valid());
91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return 1 << code_;
92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
943100271588b61cbc1dc472a3f2f105d2eed8497fAndrei Popescu  // Unfortunately we can't make this private in a struct.
95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int code_;
96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
981e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register eax = { 0 };
100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register ecx = { 1 };
101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register edx = { 2 };
102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register ebx = { 3 };
103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register esp = { 4 };
104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register ebp = { 5 };
105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register esi = { 6 };
106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register edi = { 7 };
107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst Register no_reg = { -1 };
108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1101e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockinline const char* Register::AllocationIndexToString(int index) {
1111e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  ASSERT(index >= 0 && index < kNumAllocatableRegisters);
1121e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  // This is the mapping of allocation indices to registers.
1131e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  const char* const kNames[] = { "eax", "ecx", "edx", "ebx", "esi", "edi" };
1141e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  return kNames[index];
1151e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block}
1161e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
1171e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
1181e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockinline int Register::ToAllocationIndex(Register reg) {
1191e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  ASSERT(reg.is_valid() && !reg.is(esp) && !reg.is(ebp));
1201e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  return (reg.code() >= 6) ? reg.code() - 2 : reg.code();
1211e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block}
1221e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
1231e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
1241e0659c275bb392c045087af4f6b0d7565cb3d77Steve Blockinline Register Register::FromAllocationIndex(int index)  {
1251e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  ASSERT(index >= 0 && index < kNumAllocatableRegisters);
1261e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  return (index >= 4) ? from_code(index + 2) : from_code(index);
1271e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block}
1281e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
1291e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block
130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstruct XMMRegister {
131b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const int kNumAllocatableRegisters = 7;
132b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const int kNumRegisters = 8;
133b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
134b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static int ToAllocationIndex(XMMRegister reg) {
135b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    ASSERT(reg.code() != 0);
136b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    return reg.code() - 1;
137b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  }
138b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
139b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static XMMRegister FromAllocationIndex(int index) {
140b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    ASSERT(index >= 0 && index < kNumAllocatableRegisters);
141b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    return from_code(index + 1);
142b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  }
143b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
144b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const char* AllocationIndexToString(int index) {
145b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    ASSERT(index >= 0 && index < kNumAllocatableRegisters);
146b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    const char* const names[] = {
147b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm1",
148b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm2",
149b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm3",
150b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm4",
151b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm5",
152b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm6",
153b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch      "xmm7"
154b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    };
155b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    return names[index];
156b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  }
157b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
158b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static XMMRegister from_code(int code) {
159b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    XMMRegister r = { code };
160b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    return r;
161b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  }
162b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
163b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; }
164b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  bool is(XMMRegister reg) const { return code_ == reg.code_; }
1650d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  int code() const {
166a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(is_valid());
167a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return code_;
168a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
169a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
170a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int code_;
171a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
172a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
173b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
174a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm0 = { 0 };
175a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm1 = { 1 };
176a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm2 = { 2 };
177a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm3 = { 3 };
178a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm4 = { 4 };
179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm5 = { 5 };
180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm6 = { 6 };
181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst XMMRegister xmm7 = { 7 };
182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
183b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
184b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdochtypedef XMMRegister DoubleRegister;
185b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
186b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum Condition {
188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // any value < 0 is considered no_condition
189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  no_condition  = -1,
190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
191a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  overflow      =  0,
192a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  no_overflow   =  1,
193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  below         =  2,
194a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  above_equal   =  3,
195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  equal         =  4,
196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  not_equal     =  5,
197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  below_equal   =  6,
198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  above         =  7,
199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  negative      =  8,
200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  positive      =  9,
201a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  parity_even   = 10,
202a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  parity_odd    = 11,
203a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  less          = 12,
204a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  greater_equal = 13,
205a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  less_equal    = 14,
206a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  greater       = 15,
207a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
208a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // aliases
209a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  carry         = below,
210a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  not_carry     = above_equal,
211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  zero          = equal,
212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  not_zero      = not_equal,
213a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  sign          = negative,
214a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  not_sign      = positive
215a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
216a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
217a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
218a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Returns the equivalent of !cc.
219a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Negation of the default no_condition (-1) results in a non-default
220a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// no_condition value (-2). As long as tests for no_condition check
221a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// for condition < 0, this will work as expected.
2229dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monseninline Condition NegateCondition(Condition cc) {
2239dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen  return static_cast<Condition>(cc ^ 1);
2249dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen}
2259dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen
226a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
227a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Corresponds to transposing the operands of a comparison.
228a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockinline Condition ReverseCondition(Condition cc) {
229a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  switch (cc) {
230a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case below:
231a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return above;
232a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case above:
233a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return below;
234a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case above_equal:
235a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return below_equal;
236a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case below_equal:
237a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return above_equal;
238a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case less:
239a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return greater;
240a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case greater:
241a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return less;
242a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case greater_equal:
243a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return less_equal;
244a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    case less_equal:
245a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return greater_equal;
246a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    default:
247a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      return cc;
248a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
249a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}
250a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
2519dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen
252a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum Hint {
253a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  no_hint = 0,
254a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  not_taken = 0x2e,
255a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  taken = 0x3e
256a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
257a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
2589dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen
259a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// The result of negating a hint is as if the corresponding condition
260a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// were negated by NegateCondition.  That is, no_hint is mapped to
261a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// itself and not_taken and taken are mapped to each other.
262a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockinline Hint NegateHint(Hint hint) {
263a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  return (hint == no_hint)
264a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      ? no_hint
265a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      : ((hint == not_taken) ? taken : not_taken);
266a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}
267a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
268a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
269a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// -----------------------------------------------------------------------------
270a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Machine instruction Immediates
271a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
272a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass Immediate BASE_EMBEDDED {
273a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
274a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline explicit Immediate(int x);
275a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline explicit Immediate(const ExternalReference& ext);
276a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline explicit Immediate(Handle<Object> handle);
277a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline explicit Immediate(Smi* value);
278b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  inline explicit Immediate(Address addr);
279a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
280a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Immediate CodeRelativeOffset(Label* label) {
281a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return Immediate(label);
282a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
283a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
284a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool is_zero() const { return x_ == 0 && rmode_ == RelocInfo::NONE; }
285a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool is_int8() const {
286a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return -128 <= x_ && x_ < 128 && rmode_ == RelocInfo::NONE;
287a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
288a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool is_int16() const {
289a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return -32768 <= x_ && x_ < 32768 && rmode_ == RelocInfo::NONE;
290a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
291a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
292a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
293a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline explicit Immediate(Label* value);
294a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
295a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int x_;
296a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  RelocInfo::Mode rmode_;
297a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
298a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class Assembler;
299a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
300a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
301a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
302a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// -----------------------------------------------------------------------------
303a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Machine instruction Operands
304a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
305a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockenum ScaleFactor {
306a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  times_1 = 0,
307a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  times_2 = 1,
308a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  times_4 = 2,
309a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  times_8 = 3,
3104515c472dc3e5ed2448a564600976759e569a0a8Leon Clarke  times_int_size = times_4,
3114515c472dc3e5ed2448a564600976759e569a0a8Leon Clarke  times_half_pointer_size = times_2,
312402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  times_pointer_size = times_4,
313402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  times_twice_pointer_size = times_8
314a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
315a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
316a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
317a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass Operand BASE_EMBEDDED {
318a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
319a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // reg
320a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  INLINE(explicit Operand(Register reg));
321a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
3226ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  // XMM reg
3236ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  INLINE(explicit Operand(XMMRegister xmm_reg));
3246ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
325a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // [disp/r]
326a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  INLINE(explicit Operand(int32_t disp, RelocInfo::Mode rmode));
327a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // disp only must always be relocated
328a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
329a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // [base + disp/r]
330a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  explicit Operand(Register base, int32_t disp,
331a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   RelocInfo::Mode rmode = RelocInfo::NONE);
332a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
333a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // [base + index*scale + disp/r]
334a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  explicit Operand(Register base,
335a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   Register index,
336a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   ScaleFactor scale,
337a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   int32_t disp,
338a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   RelocInfo::Mode rmode = RelocInfo::NONE);
339a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
340a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // [index*scale + disp/r]
341a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  explicit Operand(Register index,
342a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   ScaleFactor scale,
343a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   int32_t disp,
344a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   RelocInfo::Mode rmode = RelocInfo::NONE);
345a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
346a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Operand StaticVariable(const ExternalReference& ext) {
347a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return Operand(reinterpret_cast<int32_t>(ext.address()),
348a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   RelocInfo::EXTERNAL_REFERENCE);
349a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
350a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
351a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Operand StaticArray(Register index,
352a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                             ScaleFactor scale,
353a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                             const ExternalReference& arr) {
354a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return Operand(index, scale, reinterpret_cast<int32_t>(arr.address()),
355a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                   RelocInfo::EXTERNAL_REFERENCE);
356a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
357a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
358b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static Operand Cell(Handle<JSGlobalPropertyCell> cell) {
359b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch    return Operand(reinterpret_cast<int32_t>(cell.location()),
360b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch                   RelocInfo::GLOBAL_PROPERTY_CELL);
361b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  }
362b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
363a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Returns true if this Operand is a wrapper for the specified register.
364a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool is_reg(Register reg) const;
365a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
366a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
367a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  byte buf_[6];
368a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The number of bytes in buf_.
369a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  unsigned int len_;
370a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Only valid if len_ > 4.
371a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  RelocInfo::Mode rmode_;
372a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
373a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Set the ModRM byte without an encoded 'reg' register. The
374a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // register is encoded later as part of the emit_operand operation.
375a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void set_modrm(int mod, Register rm);
376a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
377a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void set_sib(ScaleFactor scale, Register index, Register base);
378a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void set_disp8(int8_t disp);
379a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void set_dispr(int32_t disp, RelocInfo::Mode rmode);
380a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
381a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class Assembler;
382a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
383a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
384a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
385a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// -----------------------------------------------------------------------------
386a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A Displacement describes the 32bit immediate field of an instruction which
387a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// may be used together with a Label in order to refer to a yet unknown code
388a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// position. Displacements stored in the instruction stream are used to describe
389a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// the instruction and to chain a list of instructions using the same Label.
390a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A Displacement contains 2 different fields:
391a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
392a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// next field: position of next displacement in the chain (0 = end of list)
393a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// type field: instruction type
394a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
395a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A next value of null (0) indicates the end of a chain (note that there can
396a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// be no displacement at position zero, because there is always at least one
397a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// instruction byte before the displacement).
398a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
399a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Displacement _data field layout
400a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
401a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// |31.....2|1......0|
402a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// [  next  |  type  |
403a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
404a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass Displacement BASE_EMBEDDED {
405a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
406a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  enum Type {
407a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    UNCONDITIONAL_JUMP,
408a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    CODE_RELATIVE,
409a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    OTHER
410a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
411a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
412a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int data() const { return data_; }
413a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Type type() const { return TypeField::decode(data_); }
414a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void next(Label* L) const {
415a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    int n = NextField::decode(data_);
416a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    n > 0 ? L->link_to(n) : L->Unuse();
417a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
418a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void link_to(Label* L) { init(L, type()); }
419a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
420a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  explicit Displacement(int data) { data_ = data; }
421a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
422a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Displacement(Label* L, Type type) { init(L, type); }
423a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
424a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void print() {
425a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    PrintF("%s (%x) ", (type() == UNCONDITIONAL_JUMP ? "jmp" : "[other]"),
426a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                       NextField::decode(data_));
427a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
428a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
429a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
430a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int data_;
431a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
432a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  class TypeField: public BitField<Type, 0, 2> {};
433a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  class NextField: public BitField<int,  2, 32-2> {};
434a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
435a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void init(Label* L, Type type);
436a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
437a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
438a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
439a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
440a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// CpuFeatures keeps track of which features are supported by the target CPU.
441a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Supported features must be enabled by a Scope before use.
442a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Example:
443a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   if (CpuFeatures::IsSupported(SSE2)) {
444a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     CpuFeatures::Scope fscope(SSE2);
445a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     // Generate SSE2 floating point code.
446a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   } else {
447a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     // Generate standard x87 floating point code.
448a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//   }
44944f0eee88ff00398ff7f715fab053374d808c90dSteve Blockclass CpuFeatures {
450a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
451b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // Detect features of the target CPU. If the portable flag is set,
452b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // the method sets safe defaults if the serializer is enabled
453b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // (snapshots must be portable).
45444f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void Probe(bool portable);
45544f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void Clear() { supported_ = 0; }
456b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
457a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check whether a feature is supported by the target CPU.
45844f0eee88ff00398ff7f715fab053374d808c90dSteve Block  bool IsSupported(CpuFeature f) const {
4593ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block    if (f == SSE2 && !FLAG_enable_sse2) return false;
4603ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block    if (f == SSE3 && !FLAG_enable_sse3) return false;
461f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch    if (f == SSE4_1 && !FLAG_enable_sse4_1) return false;
4623ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block    if (f == CMOV && !FLAG_enable_cmov) return false;
4633ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block    if (f == RDTSC && !FLAG_enable_rdtsc) return false;
464a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return (supported_ & (static_cast<uint64_t>(1) << f)) != 0;
465a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
466a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check whether a feature is currently enabled.
46744f0eee88ff00398ff7f715fab053374d808c90dSteve Block  bool IsEnabled(CpuFeature f) const {
468a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return (enabled_ & (static_cast<uint64_t>(1) << f)) != 0;
469a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
470a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Enable a specified feature within a scope.
471a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  class Scope BASE_EMBEDDED {
472a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef DEBUG
473a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   public:
47444f0eee88ff00398ff7f715fab053374d808c90dSteve Block    explicit Scope(CpuFeature f)
47544f0eee88ff00398ff7f715fab053374d808c90dSteve Block        : cpu_features_(Isolate::Current()->cpu_features()),
47644f0eee88ff00398ff7f715fab053374d808c90dSteve Block          isolate_(Isolate::Current()) {
477d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block      uint64_t mask = static_cast<uint64_t>(1) << f;
47844f0eee88ff00398ff7f715fab053374d808c90dSteve Block      ASSERT(cpu_features_->IsSupported(f));
47944f0eee88ff00398ff7f715fab053374d808c90dSteve Block      ASSERT(!Serializer::enabled() ||
48044f0eee88ff00398ff7f715fab053374d808c90dSteve Block          (cpu_features_->found_by_runtime_probing_ & mask) == 0);
48144f0eee88ff00398ff7f715fab053374d808c90dSteve Block      old_enabled_ = cpu_features_->enabled_;
48244f0eee88ff00398ff7f715fab053374d808c90dSteve Block      cpu_features_->enabled_ |= mask;
48344f0eee88ff00398ff7f715fab053374d808c90dSteve Block    }
48444f0eee88ff00398ff7f715fab053374d808c90dSteve Block    ~Scope() {
48544f0eee88ff00398ff7f715fab053374d808c90dSteve Block      ASSERT_EQ(Isolate::Current(), isolate_);
48644f0eee88ff00398ff7f715fab053374d808c90dSteve Block      cpu_features_->enabled_ = old_enabled_;
487a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    }
488a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   private:
489a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    uint64_t old_enabled_;
49044f0eee88ff00398ff7f715fab053374d808c90dSteve Block    CpuFeatures* cpu_features_;
49144f0eee88ff00398ff7f715fab053374d808c90dSteve Block    Isolate* isolate_;
492a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#else
493a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block   public:
494d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    explicit Scope(CpuFeature f) {}
495a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
496a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
49744f0eee88ff00398ff7f715fab053374d808c90dSteve Block
498a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
49944f0eee88ff00398ff7f715fab053374d808c90dSteve Block  CpuFeatures();
50044f0eee88ff00398ff7f715fab053374d808c90dSteve Block
50144f0eee88ff00398ff7f715fab053374d808c90dSteve Block  uint64_t supported_;
50244f0eee88ff00398ff7f715fab053374d808c90dSteve Block  uint64_t enabled_;
50344f0eee88ff00398ff7f715fab053374d808c90dSteve Block  uint64_t found_by_runtime_probing_;
50444f0eee88ff00398ff7f715fab053374d808c90dSteve Block
50544f0eee88ff00398ff7f715fab053374d808c90dSteve Block  friend class Isolate;
50644f0eee88ff00398ff7f715fab053374d808c90dSteve Block
50744f0eee88ff00398ff7f715fab053374d808c90dSteve Block  DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
508a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
509a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
510a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
51144f0eee88ff00398ff7f715fab053374d808c90dSteve Blockclass Assembler : public AssemblerBase {
512a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
513a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // We check before assembling an instruction that there is sufficient
514a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // space to write an instruction and its relocation information.
515a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The relocation writer's position must be kGap bytes above the end of
516a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the generated instructions. This leaves enough space for the
517a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // longest possible ia32 instruction, 15 bytes, and the longest possible
518a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // relocation information encoding, RelocInfoWriter::kMaxLength == 16.
519a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // (There is a 15 byte limit on ia32 instruction length that rules out some
520a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // otherwise valid instructions.)
521a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // This allows for a single, fast space check per instruction.
522a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kGap = 32;
523a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
524a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
525a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Create an assembler. Instructions and relocation information are emitted
526a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // into a buffer, with the instructions starting from the beginning and the
527a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // relocation information starting from the end of the buffer. See CodeDesc
528a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // for a detailed comment on the layout (globals.h).
529a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //
530a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // If the provided buffer is NULL, the assembler allocates and grows its own
531a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // buffer, and buffer_size determines the initial buffer size. The buffer is
532a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // owned by the assembler and deallocated upon destruction of the assembler.
533a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //
534a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // If the provided buffer is not NULL, the assembler uses the provided buffer
535a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // for code generation and assumes its size to be buffer_size. If the buffer
536a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // is too small, a fatal error occurs. No deallocation of the buffer is done
537a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // upon destruction of the assembler.
538a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Assembler(void* buffer, int buffer_size);
539a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  ~Assembler();
540a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
54144f0eee88ff00398ff7f715fab053374d808c90dSteve Block  // Overrides the default provided by FLAG_debug_code.
54244f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
54344f0eee88ff00398ff7f715fab053374d808c90dSteve Block
544a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // GetCode emits any pending (non-emitted) code and fills the descriptor
545a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // desc. GetCode() is idempotent; it returns the same result if no other
546a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Assembler functions are invoked in between GetCode() calls.
547a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void GetCode(CodeDesc* desc);
548a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
549a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Read/Modify the code target in the branch/call instruction at pc.
550a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline static Address target_address_at(Address pc);
551a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline static void set_target_address_at(Address pc, Address target);
552a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
553d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // This sets the branch destination (which is in the instruction on x86).
554d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // This is for calls and branches within generated code.
555d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  inline static void set_target_at(Address instruction_payload,
556d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block                                   Address target) {
557d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    set_target_address_at(instruction_payload, target);
558d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
559d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
560d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // This sets the branch destination (which is in the instruction on x86).
561d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  // This is for calls and branches to runtime code.
562d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  inline static void set_external_target_at(Address instruction_payload,
563d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block                                            Address target) {
564d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block    set_target_address_at(instruction_payload, target);
565d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  }
566d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
567d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static const int kCallTargetSize = kPointerSize;
568d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static const int kExternalTargetSize = kPointerSize;
569d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block
570a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Distance between the address of the code target in the call instruction
571a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // and the return address
572a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kCallTargetAddressOffset = kPointerSize;
573a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Distance between start of patched return sequence and the emitted address
574a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // to jump to.
575a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kPatchReturnSequenceAddressOffset = 1;  // JMP imm32.
576a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
5777f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // Distance between start of patched debug break slot and the emitted address
5787f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // to jump to.
5797f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  static const int kPatchDebugBreakSlotAddressOffset = 1;  // JMP imm32.
5807f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch
581d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static const int kCallInstructionLength = 5;
582d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  static const int kJSReturnSequenceLength = 6;
583a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
5847f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // The debug break slot must be able to contain a call instruction.
5857f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  static const int kDebugBreakSlotLength = kCallInstructionLength;
5867f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch
587b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // One byte opcode for test eax,0xXXXXXXXX.
588b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kTestEaxByte = 0xA9;
589b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // One byte opcode for test al, 0xXX.
590b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kTestAlByte = 0xA8;
591b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // One byte opcode for nop.
592b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kNopByte = 0x90;
593b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
594b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // One byte opcode for a short unconditional jump.
595b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kJmpShortOpcode = 0xEB;
596b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // One byte prefix for a short conditional jump.
597b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kJccShortPrefix = 0x70;
598b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kJncShortOpcode = kJccShortPrefix | not_carry;
599b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  static const byte kJcShortOpcode = kJccShortPrefix | carry;
600b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch
601a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // ---------------------------------------------------------------------------
602a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Code generation
603a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //
604a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // - function names correspond one-to-one to ia32 instruction mnemonics
605a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // - unless specified otherwise, instructions operate on 32bit operands
606a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // - instructions on 8bit (byte) operands/registers have a trailing '_b'
607a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // - instructions on 16bit (word) operands/registers have a trailing '_w'
608a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // - naming conflicts with C++ keywords are resolved via a trailing '_'
609a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
610a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // NOTE ON INTERFACE: Currently, the interface is not very consistent
611a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // in the sense that some operations (e.g. mov()) can be called in more
612a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the one way to generate the same instruction: The Register argument
613a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // can in some cases be replaced with an Operand(Register) argument.
614a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // This should be cleaned up and made more orthogonal. The questions
615a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // is: should we always use Operands instead of Registers where an
616a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Operand is possible, or should we have a Register (overloaded) form
617a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // instead? We must be careful to make sure that the selected instruction
618a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // is obvious from the parameters to avoid hard-to-find code generation
619a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // bugs.
620a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
621a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Insert the smallest number of nop instructions
622a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // possible to align the pc offset to a multiple
623a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // of m. m must be a power of 2.
624a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void Align(int m);
6259dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen  // Aligns code to something that's optimal for a jump target for the platform.
6269dcf7e2f83591d471e88bf7d230651900b8e424bKristian Monsen  void CodeTargetAlign();
627a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
628a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Stack
629a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void pushad();
630a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void popad();
631a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
632a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void pushfd();
633a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void popfd();
634a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
635a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void push(const Immediate& x);
636b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void push_imm32(int32_t imm32);
637a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void push(Register src);
638a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void push(const Operand& src);
639a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
640a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void pop(Register dst);
641a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void pop(const Operand& dst);
642a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
643a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void enter(const Immediate& size);
644a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void leave();
645a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
646a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Moves
647a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov_b(Register dst, const Operand& src);
648a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov_b(const Operand& dst, int8_t imm8);
649a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov_b(const Operand& dst, Register src);
650a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
651a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov_w(Register dst, const Operand& src);
652a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov_w(const Operand& dst, Register src);
653a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
654a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(Register dst, int32_t imm32);
655a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(Register dst, const Immediate& x);
656a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(Register dst, Handle<Object> handle);
657a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(Register dst, const Operand& src);
658a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(Register dst, Register src);
659a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(const Operand& dst, const Immediate& x);
660a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(const Operand& dst, Handle<Object> handle);
661a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mov(const Operand& dst, Register src);
662a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
663a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movsx_b(Register dst, const Operand& src);
664a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
665a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movsx_w(Register dst, const Operand& src);
666a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
667a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movzx_b(Register dst, const Operand& src);
668a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
669a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movzx_w(Register dst, const Operand& src);
670a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
671a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Conditional moves
672a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmov(Condition cc, Register dst, int32_t imm32);
673a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmov(Condition cc, Register dst, Handle<Object> handle);
674a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmov(Condition cc, Register dst, const Operand& src);
675a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
6766ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  // Flag management.
6776ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void cld();
6786ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
679e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  // Repetitive string instructions.
680e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void rep_movs();
6816ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void rep_stos();
682f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke  void stos();
683e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke
684a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Exchange two registers
685a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void xchg(Register dst, Register src);
686a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
687a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Arithmetics
688a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void adc(Register dst, int32_t imm32);
689a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void adc(Register dst, const Operand& src);
690a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
691a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void add(Register dst, const Operand& src);
692a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void add(const Operand& dst, const Immediate& x);
693a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
694a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void and_(Register dst, int32_t imm32);
69559151504615d929945dc59db37bf1166937748c6Steve Block  void and_(Register dst, const Immediate& x);
696a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void and_(Register dst, const Operand& src);
697a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void and_(const Operand& src, Register dst);
698a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void and_(const Operand& dst, const Immediate& x);
699a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
700a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmpb(const Operand& op, int8_t imm8);
701d91b9f7d46489a9ee00f9cb415630299c76a502bLeon Clarke  void cmpb(Register src, const Operand& dst);
702d91b9f7d46489a9ee00f9cb415630299c76a502bLeon Clarke  void cmpb(const Operand& dst, Register src);
703a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmpb_al(const Operand& op);
704a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmpw_ax(const Operand& op);
705a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmpw(const Operand& op, Immediate imm16);
706a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmp(Register reg, int32_t imm32);
707a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmp(Register reg, Handle<Object> handle);
708a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmp(Register reg, const Operand& op);
709a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmp(const Operand& op, const Immediate& imm);
710a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cmp(const Operand& op, Handle<Object> handle);
711a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
712a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void dec_b(Register dst);
7130d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void dec_b(const Operand& dst);
714a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
715a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void dec(Register dst);
716a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void dec(const Operand& dst);
717a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
718a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cdq();
719a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
720a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void idiv(Register src);
721a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
722a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Signed multiply instructions.
723a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void imul(Register src);                               // edx:eax = eax * src.
724a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void imul(Register dst, const Operand& src);           // dst = dst * src.
725a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void imul(Register dst, Register src, int32_t imm32);  // dst = src * imm32.
726a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
727a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void inc(Register dst);
728a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void inc(const Operand& dst);
729a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
730a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void lea(Register dst, const Operand& src);
731a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
732a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Unsigned multiply instruction.
733a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mul(Register src);                                // edx:eax = eax * reg.
734a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
735a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void neg(Register dst);
736a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
737a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void not_(Register dst);
738a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
739a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void or_(Register dst, int32_t imm32);
740a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void or_(Register dst, const Operand& src);
741a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void or_(const Operand& dst, Register src);
742a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void or_(const Operand& dst, const Immediate& x);
743a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
744a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void rcl(Register dst, uint8_t imm8);
745756813857a4c2a4d8ad2e805969d5768d3cf43a0Iain Merrick  void rcr(Register dst, uint8_t imm8);
746a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
747a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void sar(Register dst, uint8_t imm8);
748d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  void sar_cl(Register dst);
749a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
750a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void sbb(Register dst, const Operand& src);
751a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
752a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void shld(Register dst, const Operand& src);
753a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
754a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void shl(Register dst, uint8_t imm8);
755d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block  void shl_cl(Register dst);
756a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
757a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void shrd(Register dst, const Operand& src);
758a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
759a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void shr(Register dst, uint8_t imm8);
760a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void shr_cl(Register dst);
761a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
7623ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block  void subb(const Operand& dst, int8_t imm8);
763e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void subb(Register dst, const Operand& src);
764a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void sub(const Operand& dst, const Immediate& x);
765a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void sub(Register dst, const Operand& src);
766a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void sub(const Operand& dst, Register src);
767a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
768a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void test(Register reg, const Immediate& imm);
769a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void test(Register reg, const Operand& op);
770e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void test_b(Register reg, const Operand& op);
771a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void test(const Operand& op, const Immediate& imm);
7727f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  void test_b(const Operand& op, uint8_t imm8);
773a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
774a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void xor_(Register dst, int32_t imm32);
775a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void xor_(Register dst, const Operand& src);
776a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void xor_(const Operand& src, Register dst);
777a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void xor_(const Operand& dst, const Immediate& x);
778a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
779a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Bit operations.
780a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void bt(const Operand& dst, Register src);
781a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void bts(const Operand& dst, Register src);
782a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
783a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Miscellaneous
784a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void hlt();
785a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void int3();
786a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void nop();
787a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void rdtsc();
788a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void ret(int imm16);
789a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
790a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Label operations & relative jumps (PPUM Appendix D)
791a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //
792a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Takes a branch opcode (cc) and a label (L) and generates
793a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // either a backward branch or a forward branch and links it
794a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // to the label fixup chain. Usage:
795a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //
796a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Label L;    // unbound label
797a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // j(cc, &L);  // forward branch to unbound label
798a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // bind(&L);   // bind label to the current pc
799a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // j(cc, &L);  // backward branch to bound label
800a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // bind(&L);   // illegal: a label may be bound only once
801a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //
802a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Note: The same Label can be used for forward and backward branches
803a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // but it may be bound only once.
804a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
805a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void bind(Label* L);  // binds an unbound label L to the current code position
8060d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void bind(NearLabel* L);
807a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
808a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Calls
809a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void call(Label* L);
810a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void call(byte* entry, RelocInfo::Mode rmode);
811a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void call(const Operand& adr);
812a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void call(Handle<Code> code, RelocInfo::Mode rmode);
813a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
814a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Jumps
815a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void jmp(Label* L);  // unconditional jump to L
816a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void jmp(byte* entry, RelocInfo::Mode rmode);
817a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void jmp(const Operand& adr);
818a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void jmp(Handle<Code> code, RelocInfo::Mode rmode);
819a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
8200d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  // Short jump
8210d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void jmp(NearLabel* L);
8220d5e116f6aee03185f237311a943491bb079a768Kristian Monsen
823a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Conditional jumps
824a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void j(Condition cc, Label* L, Hint hint = no_hint);
825a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint = no_hint);
826a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void j(Condition cc, Handle<Code> code, Hint hint = no_hint);
827a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
8280d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  // Conditional short jump
8290d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void j(Condition cc, NearLabel* L, Hint hint = no_hint);
8300d5e116f6aee03185f237311a943491bb079a768Kristian Monsen
831a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Floating-point operations
832a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fld(int i);
833402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  void fstp(int i);
834a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
835a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fld1();
836a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fldz();
837402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  void fldpi();
838b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void fldln2();
839a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
840a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fld_s(const Operand& adr);
841a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fld_d(const Operand& adr);
842a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
843a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fstp_s(const Operand& adr);
844a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fstp_d(const Operand& adr);
845402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  void fst_d(const Operand& adr);
846a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
847a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fild_s(const Operand& adr);
848a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fild_d(const Operand& adr);
849a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
850a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fist_s(const Operand& adr);
851a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
852a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fistp_s(const Operand& adr);
853a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fistp_d(const Operand& adr);
854a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
8556ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  // The fisttp instructions require SSE3.
856a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fisttp_s(const Operand& adr);
857e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void fisttp_d(const Operand& adr);
858a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
859a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fabs();
860a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fchs();
861a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fcos();
862a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fsin();
863b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void fyl2x();
864a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
865a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fadd(int i);
866a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fsub(int i);
867a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fmul(int i);
868a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fdiv(int i);
869a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
870a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fisub_s(const Operand& adr);
871a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
872a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void faddp(int i = 1);
873a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fsubp(int i = 1);
874a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fsubrp(int i = 1);
875a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fmulp(int i = 1);
876a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fdivp(int i = 1);
877a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fprem();
878a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fprem1();
879a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
880a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fxch(int i = 1);
881a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fincstp();
882a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void ffree(int i = 0);
883a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
884a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void ftst();
885a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fucomp(int i);
886a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fucompp();
8873ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block  void fucomi(int i);
8883ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block  void fucomip();
889a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fcompp();
890a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fnstsw_ax();
891a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fwait();
892a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void fnclex();
893a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
894a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void frndint();
895a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
896a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void sahf();
897a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void setcc(Condition cc, Register reg);
898a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
899a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cpuid();
900a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
901a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // SSE2 instructions
902a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cvttss2si(Register dst, const Operand& src);
903a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cvttsd2si(Register dst, const Operand& src);
904a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
905a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void cvtsi2sd(XMMRegister dst, const Operand& src);
9066ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void cvtss2sd(XMMRegister dst, XMMRegister src);
90744f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void cvtsd2ss(XMMRegister dst, XMMRegister src);
908a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
909a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void addsd(XMMRegister dst, XMMRegister src);
910a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void subsd(XMMRegister dst, XMMRegister src);
911a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void mulsd(XMMRegister dst, XMMRegister src);
912a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void divsd(XMMRegister dst, XMMRegister src);
913e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void xorpd(XMMRegister dst, XMMRegister src);
9146ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void sqrtsd(XMMRegister dst, XMMRegister src);
915a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
9160d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void andpd(XMMRegister dst, XMMRegister src);
9170d5e116f6aee03185f237311a943491bb079a768Kristian Monsen
9186ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void ucomisd(XMMRegister dst, XMMRegister src);
9196ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void movmskpd(Register dst, XMMRegister src);
920a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
9210d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void cmpltsd(XMMRegister dst, XMMRegister src);
9220d5e116f6aee03185f237311a943491bb079a768Kristian Monsen
9230d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void movaps(XMMRegister dst, XMMRegister src);
9240d5e116f6aee03185f237311a943491bb079a768Kristian Monsen
925e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void movdqa(XMMRegister dst, const Operand& src);
926e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void movdqa(const Operand& dst, XMMRegister src);
927e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void movdqu(XMMRegister dst, const Operand& src);
928e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  void movdqu(const Operand& dst, XMMRegister src);
929e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke
930a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Use either movsd or movlpd.
931a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movdbl(XMMRegister dst, const Operand& src);
932a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movdbl(const Operand& dst, XMMRegister src);
933a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
9346ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void movd(XMMRegister dst, const Operand& src);
935b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void movd(const Operand& src, XMMRegister dst);
9366ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void movsd(XMMRegister dst, XMMRegister src);
9376ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
93844f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void movss(XMMRegister dst, const Operand& src);
93944f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void movss(const Operand& src, XMMRegister dst);
94044f0eee88ff00398ff7f715fab053374d808c90dSteve Block  void movss(XMMRegister dst, XMMRegister src);
94144f0eee88ff00398ff7f715fab053374d808c90dSteve Block
942b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void pand(XMMRegister dst, XMMRegister src);
9436ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void pxor(XMMRegister dst, XMMRegister src);
944b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch  void por(XMMRegister dst, XMMRegister src);
9456ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void ptest(XMMRegister dst, XMMRegister src);
9466ded16be15dd865a9b21ea304d5273c8be299c87Steve Block
947b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void psllq(XMMRegister reg, int8_t shift);
948b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch  void psllq(XMMRegister dst, XMMRegister src);
949b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch  void psrlq(XMMRegister reg, int8_t shift);
950b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch  void psrlq(XMMRegister dst, XMMRegister src);
951b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void pshufd(XMMRegister dst, XMMRegister src, int8_t shuffle);
952b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void pextrd(const Operand& dst, XMMRegister src, int8_t offset);
9531e0659c275bb392c045087af4f6b0d7565cb3d77Steve Block  void pinsrd(XMMRegister dst, const Operand& src, int8_t offset);
9540d5e116f6aee03185f237311a943491bb079a768Kristian Monsen
9557f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // Parallel XMM operations.
9567f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  void movntdqa(XMMRegister src, const Operand& dst);
9577f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  void movntdq(const Operand& dst, XMMRegister src);
9587f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // Prefetch src position into cache level.
9597f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // Level 1, 2 or 3 specifies CPU cache level. Level 0 specifies a
9607f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // non-temporal
9617f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  void prefetch(const Operand& src, int level);
9627f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // TODO(lrn): Need SFENCE for movnt?
9637f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch
964a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Debugging
965a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void Print();
966a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
967a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check the code size generated from label to here.
968a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int SizeOfCodeGeneratedSince(Label* l) { return pc_offset() - l->pos(); }
969a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
970a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Mark address of the ExitJSFrame code.
971a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void RecordJSReturn();
972a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
9737f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  // Mark address of a debug break slot.
9747f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  void RecordDebugBreakSlot();
9757f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch
976a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Record a comment relocation entry that can be used by a disassembler.
977e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch  // Use --code-comments to enable, or provide "force = true" flag to always
978e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch  // write a comment.
979e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch  void RecordComment(const char* msg, bool force = false);
980a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
981b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // Writes a single byte or word of data in the code stream.  Used for
982b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  // inline tables, e.g., jump-tables.
983b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void db(uint8_t data);
984b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch  void dd(uint32_t data);
985a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
9860d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  int pc_offset() const { return pc_ - buffer_; }
987a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
988a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check if there is less than kGap bytes available in the buffer.
989a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // If this is the case, we need to grow the buffer before emitting
990a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // an instruction or relocation information.
991a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; }
992a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
993a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Get the number of bytes available in the buffer.
994a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline int available_space() const { return reloc_info_writer.pos() - pc_; }
995a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
9967f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch  static bool IsNop(Address addr) { return *addr == 0x90; }
9977f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch
9983e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu  PositionsRecorder* positions_recorder() { return &positions_recorder_; }
9993e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu
1000e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch  int relocation_writer_size() {
1001e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch    return (buffer_ + buffer_size_) - reloc_info_writer.pos();
1002e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch  }
1003e0cee9b3ed82e2391fd85d118aeaa4ea361c687dBen Murdoch
1004a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Avoid overflows for displacements etc.
1005a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kMaximalBufferSize = 512*MB;
1006a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kMinimalBufferSize = 4*KB;
1007a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1008a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block protected:
100944f0eee88ff00398ff7f715fab053374d808c90dSteve Block  bool emit_debug_code() const { return emit_debug_code_; }
101044f0eee88ff00398ff7f715fab053374d808c90dSteve Block
1011a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movsd(XMMRegister dst, const Operand& src);
1012a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void movsd(const Operand& dst, XMMRegister src);
1013a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1014a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void emit_sse_operand(XMMRegister reg, const Operand& adr);
1015a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void emit_sse_operand(XMMRegister dst, XMMRegister src);
10166ded16be15dd865a9b21ea304d5273c8be299c87Steve Block  void emit_sse_operand(Register dst, XMMRegister src);
1017a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
101844f0eee88ff00398ff7f715fab053374d808c90dSteve Block  byte* addr_at(int pos) { return buffer_ + pos; }
101944f0eee88ff00398ff7f715fab053374d808c90dSteve Block
1020b0fe1620dcb4135ac3ab2d66ff93072373911299Ben Murdoch private:
1021a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  byte byte_at(int pos)  { return buffer_[pos]; }
10220d5e116f6aee03185f237311a943491bb079a768Kristian Monsen  void set_byte_at(int pos, byte value) { buffer_[pos] = value; }
1023a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  uint32_t long_at(int pos)  {
1024a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return *reinterpret_cast<uint32_t*>(addr_at(pos));
1025a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
1026a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void long_at_put(int pos, uint32_t x)  {
1027a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    *reinterpret_cast<uint32_t*>(addr_at(pos)) = x;
1028a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
1029a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1030a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // code emission
1031a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void GrowBuffer();
1032a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit(uint32_t x);
1033a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit(Handle<Object> handle);
1034a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit(uint32_t x, RelocInfo::Mode rmode);
1035a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit(const Immediate& x);
1036a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit_w(const Immediate& x);
1037a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1038a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Emit the code-object-relative offset of the label's position
1039a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit_code_relative_offset(Label* label);
1040a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1041a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // instruction generation
1042a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void emit_arith_b(int op1, int op2, Register dst, int imm8);
1043a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1044a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Emit a basic arithmetic instruction (i.e. first byte of the family is 0x81)
1045a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // with a given destination expression and an immediate operand.  It attempts
1046a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // to use the shortest encoding possible.
1047a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // sel specifies the /n in the modrm byte (see the Intel PRM).
1048a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void emit_arith(int sel, Operand dst, const Immediate& x);
1049a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1050a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void emit_operand(Register reg, const Operand& adr);
1051a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1052a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void emit_farith(int b1, int b2, int i);
1053a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1054a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // labels
1055a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void print(Label* L);
1056a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void bind_to(Label* L, int pos);
1057a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1058a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // displacements
1059a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline Displacement disp_at(Label* L);
1060a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void disp_at_put(Label* L, Displacement disp);
1061a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  inline void emit_disp(Label* L, Displacement::Type type);
1062a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1063a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // record reloc info for current pc_
1064a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
1065a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1066a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class CodePatcher;
1067a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  friend class EnsureSpace;
1068a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1069a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Code buffer:
1070a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The buffer into which code and relocation info are generated.
1071a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  byte* buffer_;
1072a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int buffer_size_;
1073a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // True if the assembler owns the buffer, false if buffer is external.
1074a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  bool own_buffer_;
1075a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1076a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // code generation
1077a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  byte* pc_;  // the program counter; moves forward
1078a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  RelocInfoWriter reloc_info_writer;
1079a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1080a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // push-pop elimination
1081a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  byte* last_pc_;
1082a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
10833e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu  PositionsRecorder positions_recorder_;
10843e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu
108544f0eee88ff00398ff7f715fab053374d808c90dSteve Block  bool emit_debug_code_;
108644f0eee88ff00398ff7f715fab053374d808c90dSteve Block
10873e5fa29ddb82551500b118e9bf37af3966277b70Teng-Hui Zhu  friend class PositionsRecorder;
1088a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
1089a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1090a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1091a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Helper class that ensures that there is enough space for generating
1092a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// instructions and relocation information.  The constructor makes
1093a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// sure that there is enough space and (in debug mode) the destructor
1094a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// checks that we did not generate too much.
1095a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass EnsureSpace BASE_EMBEDDED {
1096a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
1097a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  explicit EnsureSpace(Assembler* assembler) : assembler_(assembler) {
1098a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    if (assembler_->overflow()) assembler_->GrowBuffer();
1099a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef DEBUG
1100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    space_before_ = assembler_->available_space();
1101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
1102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
1103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef DEBUG
1105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  ~EnsureSpace() {
1106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    int bytes_generated = space_before_ - assembler_->available_space();
1107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    ASSERT(bytes_generated < assembler_->kGap);
1108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
1109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
1110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private:
1112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Assembler* assembler_;
1113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef DEBUG
1114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  int space_before_;
1115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif
1116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
1117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} }  // namespace v8::internal
1119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
1120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_IA32_ASSEMBLER_IA32_H_
1121