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 22 matching lines...) Expand all Loading... |
33 // Copyright 2011 the V8 project authors. All rights reserved. | 33 // Copyright 2011 the V8 project authors. All rights reserved. |
34 | 34 |
35 // A light-weight IA32 Assembler. | 35 // A light-weight IA32 Assembler. |
36 | 36 |
37 #ifndef V8_IA32_ASSEMBLER_IA32_H_ | 37 #ifndef V8_IA32_ASSEMBLER_IA32_H_ |
38 #define V8_IA32_ASSEMBLER_IA32_H_ | 38 #define V8_IA32_ASSEMBLER_IA32_H_ |
39 | 39 |
40 #include <deque> | 40 #include <deque> |
41 | 41 |
42 #include "src/assembler.h" | 42 #include "src/assembler.h" |
| 43 #include "src/ia32/sse-instr.h" |
43 #include "src/isolate.h" | 44 #include "src/isolate.h" |
44 #include "src/utils.h" | 45 #include "src/utils.h" |
45 | 46 |
46 namespace v8 { | 47 namespace v8 { |
47 namespace internal { | 48 namespace internal { |
48 | 49 |
49 #define GENERAL_REGISTERS(V) \ | 50 #define GENERAL_REGISTERS(V) \ |
50 V(eax) \ | 51 V(eax) \ |
51 V(ecx) \ | 52 V(ecx) \ |
52 V(edx) \ | 53 V(edx) \ |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 void psrld(XMMRegister reg, int8_t shift); | 1072 void psrld(XMMRegister reg, int8_t shift); |
1072 void psllq(XMMRegister reg, int8_t shift); | 1073 void psllq(XMMRegister reg, int8_t shift); |
1073 void psllq(XMMRegister dst, XMMRegister src); | 1074 void psllq(XMMRegister dst, XMMRegister src); |
1074 void psrlq(XMMRegister reg, int8_t shift); | 1075 void psrlq(XMMRegister reg, int8_t shift); |
1075 void psrlq(XMMRegister dst, XMMRegister src); | 1076 void psrlq(XMMRegister dst, XMMRegister src); |
1076 void pshufd(XMMRegister dst, XMMRegister src, uint8_t shuffle); | 1077 void pshufd(XMMRegister dst, XMMRegister src, uint8_t shuffle); |
1077 void pextrd(Register dst, XMMRegister src, int8_t offset) { | 1078 void pextrd(Register dst, XMMRegister src, int8_t offset) { |
1078 pextrd(Operand(dst), src, offset); | 1079 pextrd(Operand(dst), src, offset); |
1079 } | 1080 } |
1080 void pextrd(const Operand& dst, XMMRegister src, int8_t offset); | 1081 void pextrd(const Operand& dst, XMMRegister src, int8_t offset); |
| 1082 void pinsrw(XMMRegister dst, Register src, int8_t offset) { |
| 1083 pinsrw(dst, Operand(src), offset); |
| 1084 } |
| 1085 void pinsrw(XMMRegister dst, const Operand& src, int8_t offset); |
1081 void pinsrd(XMMRegister dst, Register src, int8_t offset) { | 1086 void pinsrd(XMMRegister dst, Register src, int8_t offset) { |
1082 pinsrd(dst, Operand(src), offset); | 1087 pinsrd(dst, Operand(src), offset); |
1083 } | 1088 } |
1084 void pinsrd(XMMRegister dst, const Operand& src, int8_t offset); | 1089 void pinsrd(XMMRegister dst, const Operand& src, int8_t offset); |
1085 | 1090 |
1086 // AVX instructions | 1091 // AVX instructions |
1087 void vfmadd132sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) { | 1092 void vfmadd132sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) { |
1088 vfmadd132sd(dst, src1, Operand(src2)); | 1093 vfmadd132sd(dst, src1, Operand(src2)); |
1089 } | 1094 } |
1090 void vfmadd213sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) { | 1095 void vfmadd213sd(XMMRegister dst, XMMRegister src1, XMMRegister src2) { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 void v##name##pd(XMMRegister dst, XMMRegister src1, const Operand& src2) { \ | 1414 void v##name##pd(XMMRegister dst, XMMRegister src1, const Operand& src2) { \ |
1410 vpd(opcode, dst, src1, src2); \ | 1415 vpd(opcode, dst, src1, src2); \ |
1411 } | 1416 } |
1412 | 1417 |
1413 PACKED_OP_LIST(AVX_PACKED_OP_DECLARE); | 1418 PACKED_OP_LIST(AVX_PACKED_OP_DECLARE); |
1414 void vps(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2); | 1419 void vps(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2); |
1415 void vps(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2); | 1420 void vps(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2); |
1416 void vpd(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2); | 1421 void vpd(byte op, XMMRegister dst, XMMRegister src1, XMMRegister src2); |
1417 void vpd(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2); | 1422 void vpd(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2); |
1418 | 1423 |
| 1424 // Other SSE and AVX instructions |
| 1425 #define DECLARE_SSE2_INSTRUCTION(instruction, prefix, escape, opcode) \ |
| 1426 void instruction(XMMRegister dst, XMMRegister src) { \ |
| 1427 instruction(dst, Operand(src)); \ |
| 1428 } \ |
| 1429 void instruction(XMMRegister dst, const Operand& src) { \ |
| 1430 sse2_instr(dst, src, 0x##prefix, 0x##escape, 0x##opcode); \ |
| 1431 } |
| 1432 |
| 1433 SSE2_INSTRUCTION_LIST(DECLARE_SSE2_INSTRUCTION) |
| 1434 #undef DECLARE_SSE2_INSTRUCTION |
| 1435 |
| 1436 #define DECLARE_SSE2_AVX_INSTRUCTION(instruction, prefix, escape, opcode) \ |
| 1437 void v##instruction(XMMRegister dst, XMMRegister src1, XMMRegister src2) { \ |
| 1438 v##instruction(dst, src1, Operand(src2)); \ |
| 1439 } \ |
| 1440 void v##instruction(XMMRegister dst, XMMRegister src1, \ |
| 1441 const Operand& src2) { \ |
| 1442 vinstr(0x##opcode, dst, src1, src2, k##prefix, k##escape, kW0); \ |
| 1443 } |
| 1444 |
| 1445 SSE2_INSTRUCTION_LIST(DECLARE_SSE2_AVX_INSTRUCTION) |
| 1446 #undef DECLARE_SSE2_AVX_INSTRUCTION |
| 1447 |
1419 // Prefetch src position into cache level. | 1448 // Prefetch src position into cache level. |
1420 // Level 1, 2 or 3 specifies CPU cache level. Level 0 specifies a | 1449 // Level 1, 2 or 3 specifies CPU cache level. Level 0 specifies a |
1421 // non-temporal | 1450 // non-temporal |
1422 void prefetch(const Operand& src, int level); | 1451 void prefetch(const Operand& src, int level); |
1423 // TODO(lrn): Need SFENCE for movnt? | 1452 // TODO(lrn): Need SFENCE for movnt? |
1424 | 1453 |
1425 // Check the code size generated from label to here. | 1454 // Check the code size generated from label to here. |
1426 int SizeOfCodeGeneratedSince(Label* label) { | 1455 int SizeOfCodeGeneratedSince(Label* label) { |
1427 return pc_offset() - label->pos(); | 1456 return pc_offset() - label->pos(); |
1428 } | 1457 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 // labels | 1568 // labels |
1540 void print(Label* L); | 1569 void print(Label* L); |
1541 void bind_to(Label* L, int pos); | 1570 void bind_to(Label* L, int pos); |
1542 | 1571 |
1543 // displacements | 1572 // displacements |
1544 inline Displacement disp_at(Label* L); | 1573 inline Displacement disp_at(Label* L); |
1545 inline void disp_at_put(Label* L, Displacement disp); | 1574 inline void disp_at_put(Label* L, Displacement disp); |
1546 inline void emit_disp(Label* L, Displacement::Type type); | 1575 inline void emit_disp(Label* L, Displacement::Type type); |
1547 inline void emit_near_disp(Label* L); | 1576 inline void emit_near_disp(Label* L); |
1548 | 1577 |
| 1578 void sse2_instr(XMMRegister dst, const Operand& src, byte prefix, byte escape, |
| 1579 byte opcode); |
| 1580 void vinstr(byte op, XMMRegister dst, XMMRegister src1, const Operand& src2, |
| 1581 SIMDPrefix pp, LeadingOpcode m, VexW w); |
1549 // Most BMI instructions are similiar. | 1582 // Most BMI instructions are similiar. |
1550 void bmi1(byte op, Register reg, Register vreg, const Operand& rm); | 1583 void bmi1(byte op, Register reg, Register vreg, const Operand& rm); |
1551 void bmi2(SIMDPrefix pp, byte op, Register reg, Register vreg, | 1584 void bmi2(SIMDPrefix pp, byte op, Register reg, Register vreg, |
1552 const Operand& rm); | 1585 const Operand& rm); |
1553 | 1586 |
1554 // record reloc info for current pc_ | 1587 // record reloc info for current pc_ |
1555 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 1588 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
1556 | 1589 |
1557 friend class CodePatcher; | 1590 friend class CodePatcher; |
1558 friend class EnsureSpace; | 1591 friend class EnsureSpace; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 Assembler* assembler_; | 1624 Assembler* assembler_; |
1592 #ifdef DEBUG | 1625 #ifdef DEBUG |
1593 int space_before_; | 1626 int space_before_; |
1594 #endif | 1627 #endif |
1595 }; | 1628 }; |
1596 | 1629 |
1597 } // namespace internal | 1630 } // namespace internal |
1598 } // namespace v8 | 1631 } // namespace v8 |
1599 | 1632 |
1600 #endif // V8_IA32_ASSEMBLER_IA32_H_ | 1633 #endif // V8_IA32_ASSEMBLER_IA32_H_ |
OLD | NEW |