| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 emit(0x80); | 765 emit(0x80); |
| 766 emit_operand(subcode, dst); | 766 emit_operand(subcode, dst); |
| 767 emit(src.value_); | 767 emit(src.value_); |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 void Assembler::immediate_arithmetic_op_8(byte subcode, | 771 void Assembler::immediate_arithmetic_op_8(byte subcode, |
| 772 Register dst, | 772 Register dst, |
| 773 Immediate src) { | 773 Immediate src) { |
| 774 EnsureSpace ensure_space(this); | 774 EnsureSpace ensure_space(this); |
| 775 if (dst.code() > 3) { | 775 if (!dst.is_byte_register()) { |
| 776 // Use 64-bit mode byte registers. | 776 // Use 64-bit mode byte registers. |
| 777 emit_rex_64(dst); | 777 emit_rex_64(dst); |
| 778 } | 778 } |
| 779 ASSERT(is_int8(src.value_) || is_uint8(src.value_)); | 779 ASSERT(is_int8(src.value_) || is_uint8(src.value_)); |
| 780 emit(0x80); | 780 emit(0x80); |
| 781 emit_modrm(subcode, dst); | 781 emit_modrm(subcode, dst); |
| 782 emit(src.value_); | 782 emit(src.value_); |
| 783 } | 783 } |
| 784 | 784 |
| 785 | 785 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 void Assembler::decl(const Operand& dst) { | 1049 void Assembler::decl(const Operand& dst) { |
| 1050 EnsureSpace ensure_space(this); | 1050 EnsureSpace ensure_space(this); |
| 1051 emit_optional_rex_32(dst); | 1051 emit_optional_rex_32(dst); |
| 1052 emit(0xFF); | 1052 emit(0xFF); |
| 1053 emit_operand(1, dst); | 1053 emit_operand(1, dst); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 | 1056 |
| 1057 void Assembler::decb(Register dst) { | 1057 void Assembler::decb(Register dst) { |
| 1058 EnsureSpace ensure_space(this); | 1058 EnsureSpace ensure_space(this); |
| 1059 if (dst.code() > 3) { | 1059 if (!dst.is_byte_register()) { |
| 1060 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 1060 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
| 1061 emit_rex_32(dst); | 1061 emit_rex_32(dst); |
| 1062 } | 1062 } |
| 1063 emit(0xFE); | 1063 emit(0xFE); |
| 1064 emit_modrm(0x1, dst); | 1064 emit_modrm(0x1, dst); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 | 1067 |
| 1068 void Assembler::decb(const Operand& dst) { | 1068 void Assembler::decb(const Operand& dst) { |
| 1069 EnsureSpace ensure_space(this); | 1069 EnsureSpace ensure_space(this); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 | 1377 |
| 1378 | 1378 |
| 1379 void Assembler::leave() { | 1379 void Assembler::leave() { |
| 1380 EnsureSpace ensure_space(this); | 1380 EnsureSpace ensure_space(this); |
| 1381 emit(0xC9); | 1381 emit(0xC9); |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 | 1384 |
| 1385 void Assembler::movb(Register dst, const Operand& src) { | 1385 void Assembler::movb(Register dst, const Operand& src) { |
| 1386 EnsureSpace ensure_space(this); | 1386 EnsureSpace ensure_space(this); |
| 1387 if (dst.code() > 3) { | 1387 if (!dst.is_byte_register()) { |
| 1388 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 1388 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
| 1389 emit_rex_32(dst, src); | 1389 emit_rex_32(dst, src); |
| 1390 } else { | 1390 } else { |
| 1391 emit_optional_rex_32(dst, src); | 1391 emit_optional_rex_32(dst, src); |
| 1392 } | 1392 } |
| 1393 emit(0x8A); | 1393 emit(0x8A); |
| 1394 emit_operand(dst, src); | 1394 emit_operand(dst, src); |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 | 1397 |
| 1398 void Assembler::movb(Register dst, Immediate imm) { | 1398 void Assembler::movb(Register dst, Immediate imm) { |
| 1399 EnsureSpace ensure_space(this); | 1399 EnsureSpace ensure_space(this); |
| 1400 if (dst.code() > 3) { | 1400 if (!dst.is_byte_register()) { |
| 1401 emit_rex_32(dst); | 1401 emit_rex_32(dst); |
| 1402 } | 1402 } |
| 1403 emit(0xB0 + dst.low_bits()); | 1403 emit(0xB0 + dst.low_bits()); |
| 1404 emit(imm.value_); | 1404 emit(imm.value_); |
| 1405 } | 1405 } |
| 1406 | 1406 |
| 1407 | 1407 |
| 1408 void Assembler::movb(const Operand& dst, Register src) { | 1408 void Assembler::movb(const Operand& dst, Register src) { |
| 1409 EnsureSpace ensure_space(this); | 1409 EnsureSpace ensure_space(this); |
| 1410 if (src.code() > 3) { | 1410 if (!src.is_byte_register()) { |
| 1411 emit_rex_32(src, dst); | 1411 emit_rex_32(src, dst); |
| 1412 } else { | 1412 } else { |
| 1413 emit_optional_rex_32(src, dst); | 1413 emit_optional_rex_32(src, dst); |
| 1414 } | 1414 } |
| 1415 emit(0x88); | 1415 emit(0x88); |
| 1416 emit_operand(src, dst); | 1416 emit_operand(src, dst); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 | 1419 |
| 1420 void Assembler::movw(const Operand& dst, Register src) { | 1420 void Assembler::movw(const Operand& dst, Register src) { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 } | 1930 } |
| 1931 | 1931 |
| 1932 | 1932 |
| 1933 void Assembler::setcc(Condition cc, Register reg) { | 1933 void Assembler::setcc(Condition cc, Register reg) { |
| 1934 if (cc > last_condition) { | 1934 if (cc > last_condition) { |
| 1935 movb(reg, Immediate(cc == always ? 1 : 0)); | 1935 movb(reg, Immediate(cc == always ? 1 : 0)); |
| 1936 return; | 1936 return; |
| 1937 } | 1937 } |
| 1938 EnsureSpace ensure_space(this); | 1938 EnsureSpace ensure_space(this); |
| 1939 ASSERT(is_uint4(cc)); | 1939 ASSERT(is_uint4(cc)); |
| 1940 if (reg.code() > 3) { // Use x64 byte registers, where different. | 1940 if (!reg.is_byte_register()) { // Use x64 byte registers, where different. |
| 1941 emit_rex_32(reg); | 1941 emit_rex_32(reg); |
| 1942 } | 1942 } |
| 1943 emit(0x0F); | 1943 emit(0x0F); |
| 1944 emit(0x90 | cc); | 1944 emit(0x90 | cc); |
| 1945 emit_modrm(0x0, reg); | 1945 emit_modrm(0x0, reg); |
| 1946 } | 1946 } |
| 1947 | 1947 |
| 1948 | 1948 |
| 1949 void Assembler::shld(Register dst, Register src) { | 1949 void Assembler::shld(Register dst, Register src) { |
| 1950 EnsureSpace ensure_space(this); | 1950 EnsureSpace ensure_space(this); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 } | 1995 } |
| 1996 | 1996 |
| 1997 | 1997 |
| 1998 void Assembler::testb(Register dst, Register src) { | 1998 void Assembler::testb(Register dst, Register src) { |
| 1999 EnsureSpace ensure_space(this); | 1999 EnsureSpace ensure_space(this); |
| 2000 if (src.low_bits() == 4) { | 2000 if (src.low_bits() == 4) { |
| 2001 emit_rex_32(src, dst); | 2001 emit_rex_32(src, dst); |
| 2002 emit(0x84); | 2002 emit(0x84); |
| 2003 emit_modrm(src, dst); | 2003 emit_modrm(src, dst); |
| 2004 } else { | 2004 } else { |
| 2005 if (dst.code() > 3 || src.code() > 3) { | 2005 if (!dst.is_byte_register() || !src.is_byte_register()) { |
| 2006 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2006 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
| 2007 emit_rex_32(dst, src); | 2007 emit_rex_32(dst, src); |
| 2008 } | 2008 } |
| 2009 emit(0x84); | 2009 emit(0x84); |
| 2010 emit_modrm(dst, src); | 2010 emit_modrm(dst, src); |
| 2011 } | 2011 } |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 | 2014 |
| 2015 void Assembler::testb(Register reg, Immediate mask) { | 2015 void Assembler::testb(Register reg, Immediate mask) { |
| 2016 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); | 2016 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); |
| 2017 EnsureSpace ensure_space(this); | 2017 EnsureSpace ensure_space(this); |
| 2018 if (reg.is(rax)) { | 2018 if (reg.is(rax)) { |
| 2019 emit(0xA8); | 2019 emit(0xA8); |
| 2020 emit(mask.value_); // Low byte emitted. | 2020 emit(mask.value_); // Low byte emitted. |
| 2021 } else { | 2021 } else { |
| 2022 if (reg.code() > 3) { | 2022 if (!reg.is_byte_register()) { |
| 2023 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2023 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
| 2024 emit_rex_32(reg); | 2024 emit_rex_32(reg); |
| 2025 } | 2025 } |
| 2026 emit(0xF6); | 2026 emit(0xF6); |
| 2027 emit_modrm(0x0, reg); | 2027 emit_modrm(0x0, reg); |
| 2028 emit(mask.value_); // Low byte emitted. | 2028 emit(mask.value_); // Low byte emitted. |
| 2029 } | 2029 } |
| 2030 } | 2030 } |
| 2031 | 2031 |
| 2032 | 2032 |
| 2033 void Assembler::testb(const Operand& op, Immediate mask) { | 2033 void Assembler::testb(const Operand& op, Immediate mask) { |
| 2034 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); | 2034 ASSERT(is_int8(mask.value_) || is_uint8(mask.value_)); |
| 2035 EnsureSpace ensure_space(this); | 2035 EnsureSpace ensure_space(this); |
| 2036 emit_optional_rex_32(rax, op); | 2036 emit_optional_rex_32(rax, op); |
| 2037 emit(0xF6); | 2037 emit(0xF6); |
| 2038 emit_operand(rax, op); // Operation code 0 | 2038 emit_operand(rax, op); // Operation code 0 |
| 2039 emit(mask.value_); // Low byte emitted. | 2039 emit(mask.value_); // Low byte emitted. |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 | 2042 |
| 2043 void Assembler::testb(const Operand& op, Register reg) { | 2043 void Assembler::testb(const Operand& op, Register reg) { |
| 2044 EnsureSpace ensure_space(this); | 2044 EnsureSpace ensure_space(this); |
| 2045 if (reg.code() > 3) { | 2045 if (!reg.is_byte_register()) { |
| 2046 // Register is not one of al, bl, cl, dl. Its encoding needs REX. | 2046 // Register is not one of al, bl, cl, dl. Its encoding needs REX. |
| 2047 emit_rex_32(reg, op); | 2047 emit_rex_32(reg, op); |
| 2048 } else { | 2048 } else { |
| 2049 emit_optional_rex_32(reg, op); | 2049 emit_optional_rex_32(reg, op); |
| 2050 } | 2050 } |
| 2051 emit(0x84); | 2051 emit(0x84); |
| 2052 emit_operand(reg, op); | 2052 emit_operand(reg, op); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 | 2055 |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3025 // specially coded on x64 means that it is a relative 32 bit address, as used | 3025 // specially coded on x64 means that it is a relative 32 bit address, as used |
| 3026 // by branch instructions. | 3026 // by branch instructions. |
| 3027 return (1 << rmode_) & kApplyMask; | 3027 return (1 << rmode_) & kApplyMask; |
| 3028 } | 3028 } |
| 3029 | 3029 |
| 3030 | 3030 |
| 3031 | 3031 |
| 3032 } } // namespace v8::internal | 3032 } } // namespace v8::internal |
| 3033 | 3033 |
| 3034 #endif // V8_TARGET_ARCH_X64 | 3034 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |