OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_ASSEMBLER_X64_H_ | 5 #ifndef VM_ASSEMBLER_X64_H_ |
6 #define VM_ASSEMBLER_X64_H_ | 6 #define VM_ASSEMBLER_X64_H_ |
7 | 7 |
8 #ifndef VM_ASSEMBLER_H_ | 8 #ifndef VM_ASSEMBLER_H_ |
9 #error Do not include assembler_x64.h directly; use assembler.h instead. | 9 #error Do not include assembler_x64.h directly; use assembler.h instead. |
10 #endif | 10 #endif |
11 | 11 |
(...skipping 12 matching lines...) Expand all Loading... |
24 | 24 |
25 int64_t value() const { return value_; } | 25 int64_t value() const { return value_; } |
26 | 26 |
27 bool is_int8() const { return Utils::IsInt(8, value_); } | 27 bool is_int8() const { return Utils::IsInt(8, value_); } |
28 bool is_uint8() const { return Utils::IsUint(8, value_); } | 28 bool is_uint8() const { return Utils::IsUint(8, value_); } |
29 bool is_uint16() const { return Utils::IsUint(16, value_); } | 29 bool is_uint16() const { return Utils::IsUint(16, value_); } |
30 bool is_int32() const { return Utils::IsInt(32, value_); } | 30 bool is_int32() const { return Utils::IsInt(32, value_); } |
31 | 31 |
32 private: | 32 private: |
33 const int64_t value_; | 33 const int64_t value_; |
34 | 34 DISALLOW_ALLOCATION(); |
35 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(Immediate) once the mac | |
36 // build issue is resolved. | |
37 }; | 35 }; |
38 | 36 |
39 | 37 |
40 class Operand : public ValueObject { | 38 class Operand : public ValueObject { |
41 public: | 39 public: |
42 uint8_t rex() const { | 40 uint8_t rex() const { |
43 return rex_; | 41 return rex_; |
44 } | 42 } |
45 | 43 |
46 uint8_t mod() const { | 44 uint8_t mod() const { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Returns whether or not this operand is really the given register in | 125 // Returns whether or not this operand is really the given register in |
128 // disguise. Used from the assembler to generate better encodings. | 126 // disguise. Used from the assembler to generate better encodings. |
129 bool IsRegister(Register reg) const { | 127 bool IsRegister(Register reg) const { |
130 return ((reg > 7 ? 1 : 0) == (rex_ & REX_B)) // REX.B match. | 128 return ((reg > 7 ? 1 : 0) == (rex_ & REX_B)) // REX.B match. |
131 && ((encoding_at(0) & 0xF8) == 0xC0) // Addressing mode is register. | 129 && ((encoding_at(0) & 0xF8) == 0xC0) // Addressing mode is register. |
132 && ((encoding_at(0) & 0x07) == reg); // Register codes match. | 130 && ((encoding_at(0) & 0x07) == reg); // Register codes match. |
133 } | 131 } |
134 | 132 |
135 | 133 |
136 friend class Assembler; | 134 friend class Assembler; |
137 | 135 DISALLOW_ALLOCATION(); |
138 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(Operand) once the mac | |
139 // build issue is resolved. | |
140 }; | 136 }; |
141 | 137 |
142 | 138 |
143 class Address : public Operand { | 139 class Address : public Operand { |
144 public: | 140 public: |
145 Address(Register base, int32_t disp) { | 141 Address(Register base, int32_t disp) { |
146 if ((disp == 0) && ((base & 7) != RBP)) { | 142 if ((disp == 0) && ((base & 7) != RBP)) { |
147 SetModRM(0, base); | 143 SetModRM(0, base); |
148 if ((base & 7) == RSP) { | 144 if ((base & 7) == RSP) { |
149 SetSIB(TIMES_1, RSP, base); | 145 SetSIB(TIMES_1, RSP, base); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 SetDisp8(disp); | 177 SetDisp8(disp); |
182 } else { | 178 } else { |
183 SetModRM(2, RSP); | 179 SetModRM(2, RSP); |
184 SetSIB(scale, index, base); | 180 SetSIB(scale, index, base); |
185 SetDisp32(disp); | 181 SetDisp32(disp); |
186 } | 182 } |
187 } | 183 } |
188 | 184 |
189 private: | 185 private: |
190 Address() {} | 186 Address() {} |
191 | 187 DISALLOW_ALLOCATION(); |
192 // TODO(5411081): Add DISALLOW_COPY_AND_ASSIGN(Address) once the mac | |
193 // build issue is resolved. | |
194 }; | 188 }; |
195 | 189 |
196 | 190 |
197 class FieldAddress : public Address { | 191 class FieldAddress : public Address { |
198 public: | 192 public: |
199 FieldAddress(Register base, int32_t disp) | 193 FieldAddress(Register base, int32_t disp) |
200 : Address(base, disp - kHeapObjectTag) {} | 194 : Address(base, disp - kHeapObjectTag) {} |
201 FieldAddress(Register base, Register index, ScaleFactor scale, int32_t disp) | 195 FieldAddress(Register base, Register index, ScaleFactor scale, int32_t disp) |
202 : Address(base, index, scale, disp - kHeapObjectTag) {} | 196 : Address(base, index, scale, disp - kHeapObjectTag) {} |
203 }; | 197 }; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 // Debugging and bringup support. | 643 // Debugging and bringup support. |
650 void Stop(const char* message); | 644 void Stop(const char* message); |
651 void Unimplemented(const char* message); | 645 void Unimplemented(const char* message); |
652 void Untested(const char* message); | 646 void Untested(const char* message); |
653 void Unreachable(const char* message); | 647 void Unreachable(const char* message); |
654 | 648 |
655 static void InitializeMemoryWithBreakpoints(uword data, int length); | 649 static void InitializeMemoryWithBreakpoints(uword data, int length); |
656 | 650 |
657 static const char* RegisterName(Register reg); | 651 static const char* RegisterName(Register reg); |
658 | 652 |
659 static const char* XmmRegisterName(XmmRegister reg); | 653 static const char* FpuRegisterName(FpuRegister reg); |
660 | 654 |
661 private: | 655 private: |
662 AssemblerBuffer buffer_; | 656 AssemblerBuffer buffer_; |
663 int prologue_offset_; | 657 int prologue_offset_; |
664 | 658 |
665 class CodeComment : public ZoneAllocated { | 659 class CodeComment : public ZoneAllocated { |
666 public: | 660 public: |
667 CodeComment(intptr_t pc_offset, const String& comment) | 661 CodeComment(intptr_t pc_offset, const String& comment) |
668 : pc_offset_(pc_offset), comment_(comment) { } | 662 : pc_offset_(pc_offset), comment_(comment) { } |
669 | 663 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 783 } |
790 | 784 |
791 | 785 |
792 inline void Assembler::EmitOperandSizeOverride() { | 786 inline void Assembler::EmitOperandSizeOverride() { |
793 EmitUint8(0x66); | 787 EmitUint8(0x66); |
794 } | 788 } |
795 | 789 |
796 } // namespace dart | 790 } // namespace dart |
797 | 791 |
798 #endif // VM_ASSEMBLER_X64_H_ | 792 #endif // VM_ASSEMBLER_X64_H_ |
OLD | NEW |