| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // to a few constants). If this is a problem, we could change the code | 84 // to a few constants). If this is a problem, we could change the code |
| 85 // such that we use an enum in optimized mode, and the struct in debug | 85 // such that we use an enum in optimized mode, and the struct in debug |
| 86 // mode. This way we get the compile-time error checking in debug mode | 86 // mode. This way we get the compile-time error checking in debug mode |
| 87 // and best performance in optimized code. | 87 // and best performance in optimized code. |
| 88 // | 88 // |
| 89 | 89 |
| 90 struct Register { | 90 struct Register { |
| 91 // The non-allocatable registers are: | 91 // The non-allocatable registers are: |
| 92 // rsp - stack pointer | 92 // rsp - stack pointer |
| 93 // rbp - frame pointer | 93 // rbp - frame pointer |
| 94 // rsi - context register | |
| 95 // r10 - fixed scratch register | 94 // r10 - fixed scratch register |
| 96 // r12 - smi constant register | 95 // r12 - smi constant register |
| 97 // r13 - root register | 96 // r13 - root register |
| 98 static const int kMaxNumAllocatableRegisters = 10; | 97 static const int kMaxNumAllocatableRegisters = 11; |
| 99 static int NumAllocatableRegisters() { | 98 static int NumAllocatableRegisters() { |
| 100 return kMaxNumAllocatableRegisters; | 99 return kMaxNumAllocatableRegisters; |
| 101 } | 100 } |
| 102 static const int kNumRegisters = 16; | 101 static const int kNumRegisters = 16; |
| 103 | 102 |
| 104 static int ToAllocationIndex(Register reg) { | 103 static int ToAllocationIndex(Register reg) { |
| 105 return kAllocationIndexByRegisterCode[reg.code()]; | 104 return kAllocationIndexByRegisterCode[reg.code()]; |
| 106 } | 105 } |
| 107 | 106 |
| 108 static Register FromAllocationIndex(int index) { | 107 static Register FromAllocationIndex(int index) { |
| 109 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 108 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
| 110 Register result = { kRegisterCodeByAllocationIndex[index] }; | 109 Register result = { kRegisterCodeByAllocationIndex[index] }; |
| 111 return result; | 110 return result; |
| 112 } | 111 } |
| 113 | 112 |
| 114 static const char* AllocationIndexToString(int index) { | 113 static const char* AllocationIndexToString(int index) { |
| 115 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 114 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
| 116 const char* const names[] = { | 115 const char* const names[] = { |
| 117 "rax", | 116 "rax", |
| 118 "rbx", | 117 "rbx", |
| 119 "rdx", | 118 "rdx", |
| 120 "rcx", | 119 "rcx", |
| 120 "rsi", |
| 121 "rdi", | 121 "rdi", |
| 122 "r8", | 122 "r8", |
| 123 "r9", | 123 "r9", |
| 124 "r11", | 124 "r11", |
| 125 "r14", | 125 "r14", |
| 126 "r15" | 126 "r15" |
| 127 }; | 127 }; |
| 128 return names[index]; | 128 return names[index]; |
| 129 } | 129 } |
| 130 | 130 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 void pop(Register dst); | 687 void pop(Register dst); |
| 688 void pop(const Operand& dst); | 688 void pop(const Operand& dst); |
| 689 | 689 |
| 690 void enter(Immediate size); | 690 void enter(Immediate size); |
| 691 void leave(); | 691 void leave(); |
| 692 | 692 |
| 693 // Moves | 693 // Moves |
| 694 void movb(Register dst, const Operand& src); | 694 void movb(Register dst, const Operand& src); |
| 695 void movb(Register dst, Immediate imm); | 695 void movb(Register dst, Immediate imm); |
| 696 void movb(const Operand& dst, Register src); | 696 void movb(const Operand& dst, Register src); |
| 697 void movb(const Operand& dst, Immediate imm); |
| 697 | 698 |
| 698 // Move the low 16 bits of a 64-bit register value to a 16-bit | 699 // Move the low 16 bits of a 64-bit register value to a 16-bit |
| 699 // memory location. | 700 // memory location. |
| 701 void movw(Register dst, const Operand& src); |
| 700 void movw(const Operand& dst, Register src); | 702 void movw(const Operand& dst, Register src); |
| 703 void movw(const Operand& dst, Immediate imm); |
| 701 | 704 |
| 702 void movl(Register dst, Register src); | 705 void movl(Register dst, Register src); |
| 703 void movl(Register dst, const Operand& src); | 706 void movl(Register dst, const Operand& src); |
| 704 void movl(const Operand& dst, Register src); | 707 void movl(const Operand& dst, Register src); |
| 705 void movl(const Operand& dst, Immediate imm); | 708 void movl(const Operand& dst, Immediate imm); |
| 706 // Load a 32-bit immediate value, zero-extended to 64 bits. | 709 // Load a 32-bit immediate value, zero-extended to 64 bits. |
| 707 void movl(Register dst, Immediate imm32); | 710 void movl(Register dst, Immediate imm32); |
| 708 | 711 |
| 709 // Move 64 bit register value to 64-bit memory location. | 712 // Move 64 bit register value to 64-bit memory location. |
| 710 void movq(const Operand& dst, Register src); | 713 void movq(const Operand& dst, Register src); |
| 711 // Move 64 bit memory location to 64-bit register value. | 714 // Move 64 bit memory location to 64-bit register value. |
| 712 void movq(Register dst, const Operand& src); | 715 void movq(Register dst, const Operand& src); |
| 713 void movq(Register dst, Register src); | 716 void movq(Register dst, Register src); |
| 714 // Sign extends immediate 32-bit value to 64 bits. | 717 // Sign extends immediate 32-bit value to 64 bits. |
| 715 void movq(Register dst, Immediate x); | 718 void movq(Register dst, Immediate x); |
| 716 // Move the offset of the label location relative to the current | 719 // Move the offset of the label location relative to the current |
| 717 // position (after the move) to the destination. | 720 // position (after the move) to the destination. |
| 718 void movl(const Operand& dst, Label* src); | 721 void movl(const Operand& dst, Label* src); |
| 719 | 722 |
| 720 // Move sign extended immediate to memory location. | 723 // Move sign extended immediate to memory location. |
| 721 void movq(const Operand& dst, Immediate value); | 724 void movq(const Operand& dst, Immediate value); |
| 722 // Instructions to load a 64-bit immediate into a register. | 725 // Loads a pointer into a register with a relocation mode. |
| 723 // All 64-bit immediates must have a relocation mode. | |
| 724 void movq(Register dst, void* ptr, RelocInfo::Mode rmode); | 726 void movq(Register dst, void* ptr, RelocInfo::Mode rmode); |
| 725 void movq(Register dst, int64_t value, RelocInfo::Mode rmode); | 727 // Loads a 64-bit immediate into a register. |
| 726 // Moves the address of the external reference into the register. | 728 void movq(Register dst, int64_t value); |
| 727 void movq(Register dst, ExternalReference ext); | |
| 728 void movq(Register dst, Handle<Object> handle, RelocInfo::Mode rmode); | 729 void movq(Register dst, Handle<Object> handle, RelocInfo::Mode rmode); |
| 729 | 730 |
| 730 void movsxbq(Register dst, const Operand& src); | 731 void movsxbq(Register dst, const Operand& src); |
| 731 void movsxwq(Register dst, const Operand& src); | 732 void movsxwq(Register dst, const Operand& src); |
| 732 void movsxlq(Register dst, Register src); | 733 void movsxlq(Register dst, Register src); |
| 733 void movsxlq(Register dst, const Operand& src); | 734 void movsxlq(Register dst, const Operand& src); |
| 734 void movzxbq(Register dst, const Operand& src); | 735 void movzxbq(Register dst, const Operand& src); |
| 735 void movzxbl(Register dst, const Operand& src); | 736 void movzxbl(Register dst, const Operand& src); |
| 736 void movzxwq(Register dst, const Operand& src); | 737 void movzxwq(Register dst, const Operand& src); |
| 737 void movzxwl(Register dst, const Operand& src); | 738 void movzxwl(Register dst, const Operand& src); |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 void fptan(); | 1340 void fptan(); |
| 1340 void fyl2x(); | 1341 void fyl2x(); |
| 1341 void f2xm1(); | 1342 void f2xm1(); |
| 1342 void fscale(); | 1343 void fscale(); |
| 1343 void fninit(); | 1344 void fninit(); |
| 1344 | 1345 |
| 1345 void frndint(); | 1346 void frndint(); |
| 1346 | 1347 |
| 1347 void sahf(); | 1348 void sahf(); |
| 1348 | 1349 |
| 1350 // SSE instructions |
| 1351 void movaps(XMMRegister dst, XMMRegister src); |
| 1352 void movss(XMMRegister dst, const Operand& src); |
| 1353 void movss(const Operand& dst, XMMRegister src); |
| 1354 |
| 1355 void cvttss2si(Register dst, const Operand& src); |
| 1356 void cvttss2si(Register dst, XMMRegister src); |
| 1357 void cvtlsi2ss(XMMRegister dst, Register src); |
| 1358 |
| 1359 void andps(XMMRegister dst, XMMRegister src); |
| 1360 void orps(XMMRegister dst, XMMRegister src); |
| 1361 void xorps(XMMRegister dst, XMMRegister src); |
| 1362 |
| 1363 void movmskps(Register dst, XMMRegister src); |
| 1364 |
| 1349 // SSE2 instructions | 1365 // SSE2 instructions |
| 1350 void movd(XMMRegister dst, Register src); | 1366 void movd(XMMRegister dst, Register src); |
| 1351 void movd(Register dst, XMMRegister src); | 1367 void movd(Register dst, XMMRegister src); |
| 1352 void movq(XMMRegister dst, Register src); | 1368 void movq(XMMRegister dst, Register src); |
| 1353 void movq(Register dst, XMMRegister src); | 1369 void movq(Register dst, XMMRegister src); |
| 1354 void movq(XMMRegister dst, XMMRegister src); | 1370 void movq(XMMRegister dst, XMMRegister src); |
| 1355 void extractps(Register dst, XMMRegister src, byte imm8); | |
| 1356 | 1371 |
| 1357 // Don't use this unless it's important to keep the | 1372 // Don't use this unless it's important to keep the |
| 1358 // top half of the destination register unchanged. | 1373 // top half of the destination register unchanged. |
| 1359 // Used movaps when moving double values and movq for integer | 1374 // Used movaps when moving double values and movq for integer |
| 1360 // values in xmm registers. | 1375 // values in xmm registers. |
| 1361 void movsd(XMMRegister dst, XMMRegister src); | 1376 void movsd(XMMRegister dst, XMMRegister src); |
| 1362 | 1377 |
| 1363 void movsd(const Operand& dst, XMMRegister src); | 1378 void movsd(const Operand& dst, XMMRegister src); |
| 1364 void movsd(XMMRegister dst, const Operand& src); | 1379 void movsd(XMMRegister dst, const Operand& src); |
| 1365 | 1380 |
| 1366 void movdqa(const Operand& dst, XMMRegister src); | 1381 void movdqa(const Operand& dst, XMMRegister src); |
| 1367 void movdqa(XMMRegister dst, const Operand& src); | 1382 void movdqa(XMMRegister dst, const Operand& src); |
| 1368 | 1383 |
| 1369 void movdqu(const Operand& dst, XMMRegister src); | 1384 void movdqu(const Operand& dst, XMMRegister src); |
| 1370 void movdqu(XMMRegister dst, const Operand& src); | 1385 void movdqu(XMMRegister dst, const Operand& src); |
| 1371 | 1386 |
| 1372 void movapd(XMMRegister dst, XMMRegister src); | 1387 void movapd(XMMRegister dst, XMMRegister src); |
| 1373 void movaps(XMMRegister dst, XMMRegister src); | |
| 1374 | 1388 |
| 1375 void movss(XMMRegister dst, const Operand& src); | |
| 1376 void movss(const Operand& dst, XMMRegister src); | |
| 1377 | |
| 1378 void cvttss2si(Register dst, const Operand& src); | |
| 1379 void cvttss2si(Register dst, XMMRegister src); | |
| 1380 void cvttsd2si(Register dst, const Operand& src); | 1389 void cvttsd2si(Register dst, const Operand& src); |
| 1381 void cvttsd2si(Register dst, XMMRegister src); | 1390 void cvttsd2si(Register dst, XMMRegister src); |
| 1382 void cvttsd2siq(Register dst, XMMRegister src); | 1391 void cvttsd2siq(Register dst, XMMRegister src); |
| 1383 | 1392 |
| 1384 void cvtlsi2sd(XMMRegister dst, const Operand& src); | 1393 void cvtlsi2sd(XMMRegister dst, const Operand& src); |
| 1385 void cvtlsi2sd(XMMRegister dst, Register src); | 1394 void cvtlsi2sd(XMMRegister dst, Register src); |
| 1386 void cvtqsi2sd(XMMRegister dst, const Operand& src); | 1395 void cvtqsi2sd(XMMRegister dst, const Operand& src); |
| 1387 void cvtqsi2sd(XMMRegister dst, Register src); | 1396 void cvtqsi2sd(XMMRegister dst, Register src); |
| 1388 | 1397 |
| 1389 void cvtlsi2ss(XMMRegister dst, Register src); | |
| 1390 | 1398 |
| 1391 void cvtss2sd(XMMRegister dst, XMMRegister src); | 1399 void cvtss2sd(XMMRegister dst, XMMRegister src); |
| 1392 void cvtss2sd(XMMRegister dst, const Operand& src); | 1400 void cvtss2sd(XMMRegister dst, const Operand& src); |
| 1393 void cvtsd2ss(XMMRegister dst, XMMRegister src); | 1401 void cvtsd2ss(XMMRegister dst, XMMRegister src); |
| 1394 | 1402 |
| 1395 void cvtsd2si(Register dst, XMMRegister src); | 1403 void cvtsd2si(Register dst, XMMRegister src); |
| 1396 void cvtsd2siq(Register dst, XMMRegister src); | 1404 void cvtsd2siq(Register dst, XMMRegister src); |
| 1397 | 1405 |
| 1398 void addsd(XMMRegister dst, XMMRegister src); | 1406 void addsd(XMMRegister dst, XMMRegister src); |
| 1399 void addsd(XMMRegister dst, const Operand& src); | 1407 void addsd(XMMRegister dst, const Operand& src); |
| 1400 void subsd(XMMRegister dst, XMMRegister src); | 1408 void subsd(XMMRegister dst, XMMRegister src); |
| 1401 void mulsd(XMMRegister dst, XMMRegister src); | 1409 void mulsd(XMMRegister dst, XMMRegister src); |
| 1402 void mulsd(XMMRegister dst, const Operand& src); | 1410 void mulsd(XMMRegister dst, const Operand& src); |
| 1403 void divsd(XMMRegister dst, XMMRegister src); | 1411 void divsd(XMMRegister dst, XMMRegister src); |
| 1404 | 1412 |
| 1405 void andpd(XMMRegister dst, XMMRegister src); | 1413 void andpd(XMMRegister dst, XMMRegister src); |
| 1406 void orpd(XMMRegister dst, XMMRegister src); | 1414 void orpd(XMMRegister dst, XMMRegister src); |
| 1407 void xorpd(XMMRegister dst, XMMRegister src); | 1415 void xorpd(XMMRegister dst, XMMRegister src); |
| 1408 void xorps(XMMRegister dst, XMMRegister src); | |
| 1409 void sqrtsd(XMMRegister dst, XMMRegister src); | 1416 void sqrtsd(XMMRegister dst, XMMRegister src); |
| 1410 | 1417 |
| 1411 void ucomisd(XMMRegister dst, XMMRegister src); | 1418 void ucomisd(XMMRegister dst, XMMRegister src); |
| 1412 void ucomisd(XMMRegister dst, const Operand& src); | 1419 void ucomisd(XMMRegister dst, const Operand& src); |
| 1420 void cmpltsd(XMMRegister dst, XMMRegister src); |
| 1421 |
| 1422 void movmskpd(Register dst, XMMRegister src); |
| 1423 |
| 1424 // SSE 4.1 instruction |
| 1425 void extractps(Register dst, XMMRegister src, byte imm8); |
| 1413 | 1426 |
| 1414 enum RoundingMode { | 1427 enum RoundingMode { |
| 1415 kRoundToNearest = 0x0, | 1428 kRoundToNearest = 0x0, |
| 1416 kRoundDown = 0x1, | 1429 kRoundDown = 0x1, |
| 1417 kRoundUp = 0x2, | 1430 kRoundUp = 0x2, |
| 1418 kRoundToZero = 0x3 | 1431 kRoundToZero = 0x3 |
| 1419 }; | 1432 }; |
| 1420 | 1433 |
| 1421 void roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode); | 1434 void roundsd(XMMRegister dst, XMMRegister src, RoundingMode mode); |
| 1422 | 1435 |
| 1423 void movmskpd(Register dst, XMMRegister src); | |
| 1424 void movmskps(Register dst, XMMRegister src); | |
| 1425 | |
| 1426 void cmpltsd(XMMRegister dst, XMMRegister src); | |
| 1427 | |
| 1428 // The first argument is the reg field, the second argument is the r/m field. | |
| 1429 void emit_sse_operand(XMMRegister dst, XMMRegister src); | |
| 1430 void emit_sse_operand(XMMRegister reg, const Operand& adr); | |
| 1431 void emit_sse_operand(XMMRegister dst, Register src); | |
| 1432 void emit_sse_operand(Register dst, XMMRegister src); | |
| 1433 | |
| 1434 // Debugging | 1436 // Debugging |
| 1435 void Print(); | 1437 void Print(); |
| 1436 | 1438 |
| 1437 // Check the code size generated from label to here. | 1439 // Check the code size generated from label to here. |
| 1438 int SizeOfCodeGeneratedSince(Label* label) { | 1440 int SizeOfCodeGeneratedSince(Label* label) { |
| 1439 return pc_offset() - label->pos(); | 1441 return pc_offset() - label->pos(); |
| 1440 } | 1442 } |
| 1441 | 1443 |
| 1442 // Mark address of the ExitJSFrame code. | 1444 // Mark address of the ExitJSFrame code. |
| 1443 void RecordJSReturn(); | 1445 void RecordJSReturn(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 // Emit a ModR/M byte with an operation subcode in the reg field and | 1606 // Emit a ModR/M byte with an operation subcode in the reg field and |
| 1605 // a register in the rm_reg field. | 1607 // a register in the rm_reg field. |
| 1606 void emit_modrm(int code, Register rm_reg) { | 1608 void emit_modrm(int code, Register rm_reg) { |
| 1607 ASSERT(is_uint3(code)); | 1609 ASSERT(is_uint3(code)); |
| 1608 emit(0xC0 | code << 3 | rm_reg.low_bits()); | 1610 emit(0xC0 | code << 3 | rm_reg.low_bits()); |
| 1609 } | 1611 } |
| 1610 | 1612 |
| 1611 // Emit the code-object-relative offset of the label's position | 1613 // Emit the code-object-relative offset of the label's position |
| 1612 inline void emit_code_relative_offset(Label* label); | 1614 inline void emit_code_relative_offset(Label* label); |
| 1613 | 1615 |
| 1616 // The first argument is the reg field, the second argument is the r/m field. |
| 1617 void emit_sse_operand(XMMRegister dst, XMMRegister src); |
| 1618 void emit_sse_operand(XMMRegister reg, const Operand& adr); |
| 1619 void emit_sse_operand(XMMRegister dst, Register src); |
| 1620 void emit_sse_operand(Register dst, XMMRegister src); |
| 1621 |
| 1614 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, | 1622 // Emit machine code for one of the operations ADD, ADC, SUB, SBC, |
| 1615 // AND, OR, XOR, or CMP. The encodings of these operations are all | 1623 // AND, OR, XOR, or CMP. The encodings of these operations are all |
| 1616 // similar, differing just in the opcode or in the reg field of the | 1624 // similar, differing just in the opcode or in the reg field of the |
| 1617 // ModR/M byte. | 1625 // ModR/M byte. |
| 1618 void arithmetic_op_16(byte opcode, Register reg, Register rm_reg); | 1626 void arithmetic_op_16(byte opcode, Register reg, Register rm_reg); |
| 1619 void arithmetic_op_16(byte opcode, Register reg, const Operand& rm_reg); | 1627 void arithmetic_op_16(byte opcode, Register reg, const Operand& rm_reg); |
| 1620 void arithmetic_op_32(byte opcode, Register reg, Register rm_reg); | 1628 void arithmetic_op_32(byte opcode, Register reg, Register rm_reg); |
| 1621 void arithmetic_op_32(byte opcode, Register reg, const Operand& rm_reg); | 1629 void arithmetic_op_32(byte opcode, Register reg, const Operand& rm_reg); |
| 1622 void arithmetic_op(byte opcode, Register reg, Register rm_reg); | 1630 void arithmetic_op(byte opcode, Register reg, Register rm_reg); |
| 1623 void arithmetic_op(byte opcode, Register reg, const Operand& rm_reg); | 1631 void arithmetic_op(byte opcode, Register reg, const Operand& rm_reg); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 private: | 1706 private: |
| 1699 Assembler* assembler_; | 1707 Assembler* assembler_; |
| 1700 #ifdef DEBUG | 1708 #ifdef DEBUG |
| 1701 int space_before_; | 1709 int space_before_; |
| 1702 #endif | 1710 #endif |
| 1703 }; | 1711 }; |
| 1704 | 1712 |
| 1705 } } // namespace v8::internal | 1713 } } // namespace v8::internal |
| 1706 | 1714 |
| 1707 #endif // V8_X64_ASSEMBLER_X64_H_ | 1715 #endif // V8_X64_ASSEMBLER_X64_H_ |
| OLD | NEW |