OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/x64/assembler-x64.h" | 5 #include "src/x64/assembler-x64.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #if V8_TARGET_ARCH_X64 | 9 #if V8_TARGET_ARCH_X64 |
10 | 10 |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 emit(0x66); | 516 emit(0x66); |
517 emit_optional_rex_32(reg, rm_reg); | 517 emit_optional_rex_32(reg, rm_reg); |
518 emit(opcode); | 518 emit(opcode); |
519 emit_operand(reg, rm_reg); | 519 emit_operand(reg, rm_reg); |
520 } | 520 } |
521 | 521 |
522 | 522 |
523 void Assembler::arithmetic_op_8(byte opcode, Register reg, const Operand& op) { | 523 void Assembler::arithmetic_op_8(byte opcode, Register reg, const Operand& op) { |
524 EnsureSpace ensure_space(this); | 524 EnsureSpace ensure_space(this); |
525 if (!reg.is_byte_register()) { | 525 if (!reg.is_byte_register()) { |
526 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 526 emit_rex_32(reg, op); |
527 emit_rex_32(reg); | 527 } else { |
| 528 emit_optional_rex_32(reg, op); |
528 } | 529 } |
529 emit(opcode); | 530 emit(opcode); |
530 emit_operand(reg, op); | 531 emit_operand(reg, op); |
531 } | 532 } |
532 | 533 |
533 | 534 |
534 void Assembler::arithmetic_op_8(byte opcode, Register reg, Register rm_reg) { | 535 void Assembler::arithmetic_op_8(byte opcode, Register reg, Register rm_reg) { |
535 EnsureSpace ensure_space(this); | 536 EnsureSpace ensure_space(this); |
536 DCHECK((opcode & 0xC6) == 2); | 537 DCHECK((opcode & 0xC6) == 2); |
537 if (rm_reg.low_bits() == 4) { // Forces SIB byte. | 538 if (rm_reg.low_bits() == 4) { // Forces SIB byte. |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 if (!reg.is_byte_register()) { | 2009 if (!reg.is_byte_register()) { |
2009 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2010 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
2010 emit_rex_32(reg, op); | 2011 emit_rex_32(reg, op); |
2011 } else { | 2012 } else { |
2012 emit_optional_rex_32(reg, op); | 2013 emit_optional_rex_32(reg, op); |
2013 } | 2014 } |
2014 emit(0x84); | 2015 emit(0x84); |
2015 emit_operand(reg, op); | 2016 emit_operand(reg, op); |
2016 } | 2017 } |
2017 | 2018 |
| 2019 void Assembler::testw(Register dst, Register src) { |
| 2020 EnsureSpace ensure_space(this); |
| 2021 emit(0x66); |
| 2022 if (src.low_bits() == 4) { |
| 2023 emit_rex_32(src, dst); |
| 2024 } |
| 2025 emit(0x85); |
| 2026 emit_modrm(src, dst); |
| 2027 } |
| 2028 |
| 2029 void Assembler::testw(Register reg, Immediate mask) { |
| 2030 DCHECK(is_int16(mask.value_) || is_uint16(mask.value_)); |
| 2031 EnsureSpace ensure_space(this); |
| 2032 emit(0x66); |
| 2033 if (reg.is(rax)) { |
| 2034 emit(0xA9); |
| 2035 emit(mask.value_); |
| 2036 } else { |
| 2037 if (reg.low_bits() == 4) { |
| 2038 emit_rex_32(reg); |
| 2039 } |
| 2040 emit(0xF7); |
| 2041 emit_modrm(0x0, reg); |
| 2042 emit(mask.value_); |
| 2043 } |
| 2044 } |
| 2045 |
| 2046 void Assembler::testw(const Operand& op, Immediate mask) { |
| 2047 DCHECK(is_int16(mask.value_) || is_uint16(mask.value_)); |
| 2048 EnsureSpace ensure_space(this); |
| 2049 emit(0x66); |
| 2050 emit_optional_rex_32(rax, op); |
| 2051 emit(0xF7); |
| 2052 emit_operand(rax, op); |
| 2053 emit(mask.value_); |
| 2054 } |
| 2055 |
| 2056 void Assembler::testw(const Operand& op, Register reg) { |
| 2057 EnsureSpace ensure_space(this); |
| 2058 emit(0x66); |
| 2059 emit_optional_rex_32(reg, op); |
| 2060 emit(0x85); |
| 2061 emit_operand(rax, op); |
| 2062 } |
2018 | 2063 |
2019 void Assembler::emit_test(Register dst, Register src, int size) { | 2064 void Assembler::emit_test(Register dst, Register src, int size) { |
2020 EnsureSpace ensure_space(this); | 2065 EnsureSpace ensure_space(this); |
2021 if (src.low_bits() == 4) { | 2066 if (src.low_bits() == 4) { |
2022 emit_rex(src, dst, size); | 2067 emit_rex(src, dst, size); |
2023 emit(0x85); | 2068 emit(0x85); |
2024 emit_modrm(src, dst); | 2069 emit_modrm(src, dst); |
2025 } else { | 2070 } else { |
2026 emit_rex(dst, src, size); | 2071 emit_rex(dst, src, size); |
2027 emit(0x85); | 2072 emit(0x85); |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4150 | 4195 |
4151 bool RelocInfo::IsInConstantPool() { | 4196 bool RelocInfo::IsInConstantPool() { |
4152 return false; | 4197 return false; |
4153 } | 4198 } |
4154 | 4199 |
4155 | 4200 |
4156 } // namespace internal | 4201 } // namespace internal |
4157 } // namespace v8 | 4202 } // namespace v8 |
4158 | 4203 |
4159 #endif // V8_TARGET_ARCH_X64 | 4204 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |