| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // The byte-register distinction of ai32 has dissapeared. | 85 // The byte-register distinction of ai32 has dissapeared. |
| 86 bool is_byte_register() const { return false; } | 86 bool is_byte_register() const { return false; } |
| 87 int code() const { | 87 int code() const { |
| 88 ASSERT(is_valid()); | 88 ASSERT(is_valid()); |
| 89 return code_; | 89 return code_; |
| 90 } | 90 } |
| 91 int bit() const { | 91 int bit() const { |
| 92 return 1 << code_; | 92 return 1 << code_; |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Return the high bit of the register code as a 0 or 1. Used often |
| 96 // when constructing the REX prefix byte. |
| 97 int high_bit() const { |
| 98 return code_ >> 3; |
| 99 } |
| 100 // Return the 3 low bits of the register code. Used when encoding registers |
| 101 // in modR/M, SIB, and opcode bytes. |
| 102 int low_bits() const { |
| 103 return code_ & 0x7; |
| 104 } |
| 105 |
| 95 // (unfortunately we can't make this private in a struct when initializing | 106 // (unfortunately we can't make this private in a struct when initializing |
| 96 // by assignment.) | 107 // by assignment.) |
| 97 int code_; | 108 int code_; |
| 98 }; | 109 }; |
| 99 | 110 |
| 100 extern Register rax; | 111 extern Register rax; |
| 101 extern Register rcx; | 112 extern Register rcx; |
| 102 extern Register rdx; | 113 extern Register rdx; |
| 103 extern Register rbx; | 114 extern Register rbx; |
| 104 extern Register rsp; | 115 extern Register rsp; |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 // Optionally do as emit_rex_32(const Operand&) if the operand register | 987 // Optionally do as emit_rex_32(const Operand&) if the operand register |
| 977 // numbers have a high bit set. | 988 // numbers have a high bit set. |
| 978 inline void emit_optional_rex_32(const Operand& op); | 989 inline void emit_optional_rex_32(const Operand& op); |
| 979 | 990 |
| 980 | 991 |
| 981 // Emit the ModR/M byte, and optionally the SIB byte and | 992 // Emit the ModR/M byte, and optionally the SIB byte and |
| 982 // 1- or 4-byte offset for a memory operand. Also encodes | 993 // 1- or 4-byte offset for a memory operand. Also encodes |
| 983 // the second operand of the operation, a register or operation | 994 // the second operand of the operation, a register or operation |
| 984 // subcode, into the reg field of the ModR/M byte. | 995 // subcode, into the reg field of the ModR/M byte. |
| 985 void emit_operand(Register reg, const Operand& adr) { | 996 void emit_operand(Register reg, const Operand& adr) { |
| 986 emit_operand(reg.code() & 0x07, adr); | 997 emit_operand(reg.low_bits(), adr); |
| 987 } | 998 } |
| 988 | 999 |
| 989 // Emit the ModR/M byte, and optionally the SIB byte and | 1000 // Emit the ModR/M byte, and optionally the SIB byte and |
| 990 // 1- or 4-byte offset for a memory operand. Also used to encode | 1001 // 1- or 4-byte offset for a memory operand. Also used to encode |
| 991 // a three-bit opcode extension into the ModR/M byte. | 1002 // a three-bit opcode extension into the ModR/M byte. |
| 992 void emit_operand(int rm, const Operand& adr); | 1003 void emit_operand(int rm, const Operand& adr); |
| 993 | 1004 |
| 994 // Emit a ModR/M byte with registers coded in the reg and rm_reg fields. | 1005 // Emit a ModR/M byte with registers coded in the reg and rm_reg fields. |
| 995 void emit_modrm(Register reg, Register rm_reg) { | 1006 void emit_modrm(Register reg, Register rm_reg) { |
| 996 emit(0xC0 | (reg.code() & 0x7) << 3 | (rm_reg.code() & 0x7)); | 1007 emit(0xC0 | reg.low_bits() << 3 | rm_reg.low_bits()); |
| 997 } | 1008 } |
| 998 | 1009 |
| 999 // Emit a ModR/M byte with an operation subcode in the reg field and | 1010 // Emit a ModR/M byte with an operation subcode in the reg field and |
| 1000 // a register in the rm_reg field. | 1011 // a register in the rm_reg field. |
| 1001 void emit_modrm(int code, Register rm_reg) { | 1012 void emit_modrm(int code, Register rm_reg) { |
| 1002 ASSERT((code & ~0x7) == 0); | 1013 ASSERT(is_uint3(code)); |
| 1003 emit(0xC0 | (code & 0x7) << 3 | (rm_reg.code() & 0x7)); | 1014 emit(0xC0 | code << 3 | rm_reg.low_bits()); |
| 1004 } | 1015 } |
| 1005 | 1016 |
| 1006 // Emit the code-object-relative offset of the label's position | 1017 // Emit the code-object-relative offset of the label's position |
| 1007 inline void emit_code_relative_offset(Label* label); | 1018 inline void emit_code_relative_offset(Label* label); |
| 1008 | 1019 |
| 1009 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, | 1020 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, |
| 1010 // AND, OR, XOR, or CMP. The encodings of these operations are all | 1021 // AND, OR, XOR, or CMP. The encodings of these operations are all |
| 1011 // similar, differing just in the opcode or in the reg field of the | 1022 // similar, differing just in the opcode or in the reg field of the |
| 1012 // ModR/M byte. | 1023 // ModR/M byte. |
| 1013 void arithmetic_op(byte opcode, Register dst, Register src); | 1024 void arithmetic_op(byte opcode, Register dst, Register src); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 private: | 1103 private: |
| 1093 Assembler* assembler_; | 1104 Assembler* assembler_; |
| 1094 #ifdef DEBUG | 1105 #ifdef DEBUG |
| 1095 int space_before_; | 1106 int space_before_; |
| 1096 #endif | 1107 #endif |
| 1097 }; | 1108 }; |
| 1098 | 1109 |
| 1099 } } // namespace v8::internal | 1110 } } // namespace v8::internal |
| 1100 | 1111 |
| 1101 #endif // V8_X64_ASSEMBLER_X64_H_ | 1112 #endif // V8_X64_ASSEMBLER_X64_H_ |
| OLD | NEW |