OLD | NEW |
1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// | 1 //===- subzero/src/IceAssemblerARM32.cpp - Assembler for ARM32 --*- C++ -*-===// |
2 // | 2 // |
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
6 // | 6 // |
7 // Modified by the Subzero authors. | 7 // Modified by the Subzero authors. |
8 // | 8 // |
9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
10 // | 10 // |
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 IValueT Rm = encodeRegister(OpSrc1, "Rm", MulName); | 1470 IValueT Rm = encodeRegister(OpSrc1, "Rm", MulName); |
1471 verifyRegNotPc(Rd, "Rd", MulName); | 1471 verifyRegNotPc(Rd, "Rd", MulName); |
1472 verifyRegNotPc(Rn, "Rn", MulName); | 1472 verifyRegNotPc(Rn, "Rn", MulName); |
1473 verifyRegNotPc(Rm, "Rm", MulName); | 1473 verifyRegNotPc(Rm, "Rm", MulName); |
1474 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. | 1474 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. |
1475 constexpr IValueT MulOpcode = 0; | 1475 constexpr IValueT MulOpcode = 0; |
1476 emitMulOp(Cond, MulOpcode, RegARM32::Encoded_Reg_r0, Rd, Rn, Rm, SetFlags, | 1476 emitMulOp(Cond, MulOpcode, RegARM32::Encoded_Reg_r0, Rd, Rn, Rm, SetFlags, |
1477 MulName); | 1477 MulName); |
1478 } | 1478 } |
1479 | 1479 |
1480 void AssemblerARM32::udiv(const Operand *OpRd, const Operand *OpRn, | 1480 void AssemblerARM32::rsb(const Operand *OpRd, const Operand *OpRn, |
1481 const Operand *OpSrc1, CondARM32::Cond Cond) { | 1481 const Operand *OpSrc1, bool SetFlags, |
1482 // UDIV - ARM section A8.8.248, encoding A1. | 1482 CondARM32::Cond Cond) { |
1483 // udiv<c> <Rd>, <Rn>, <Rm> | 1483 // RSB (immediate) - ARM section A8.8.152, encoding A1. |
| 1484 // rsb{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
1484 // | 1485 // |
1485 // cccc01110011dddd1111mmmm0001nnnn where cccc=Cond, dddd=Rd, nnnn=Rn, and | 1486 // cccc0010011snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
1486 // mmmm=Rm. | 1487 // s=setFlags and iiiiiiiiiiii defines the RotatedImm8 value. |
1487 constexpr const char *UdivName = "udiv"; | 1488 // |
1488 IValueT Rd = encodeRegister(OpRd, "Rd", UdivName); | 1489 // RSB (register) - ARM section A8.8.163, encoding A1. |
1489 IValueT Rn = encodeRegister(OpRn, "Rn", UdivName); | 1490 // rsb{s}<c> <Rd>, <Rn>, <Rm>{, <Shift>} |
1490 IValueT Rm = encodeRegister(OpSrc1, "Rm", UdivName); | 1491 // |
1491 verifyRegNotPc(Rd, "Rd", UdivName); | 1492 // cccc0000011snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, |
1492 verifyRegNotPc(Rn, "Rn", UdivName); | 1493 // mmmm=Rm, iiiii=shift, tt==ShiftKind, and s=SetFlags. |
1493 verifyRegNotPc(Rm, "Rm", UdivName); | 1494 constexpr const char *RsbName = "rsb"; |
1494 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. | 1495 constexpr IValueT RsbOpcode = B1 | B0; // 0011 |
1495 constexpr IValueT UdivOpcode = B21; | 1496 emitType01(Cond, RsbOpcode, OpRd, OpRn, OpSrc1, SetFlags, RdIsPcAndSetFlags, |
1496 emitDivOp(Cond, UdivOpcode, Rd, Rn, Rm, UdivName); | 1497 RsbName); |
1497 } | 1498 } |
1498 | 1499 |
1499 void AssemblerARM32::sub(const Operand *OpRd, const Operand *OpRn, | 1500 void AssemblerARM32::sub(const Operand *OpRd, const Operand *OpRn, |
1500 const Operand *OpSrc1, bool SetFlags, | 1501 const Operand *OpSrc1, bool SetFlags, |
1501 CondARM32::Cond Cond) { | 1502 CondARM32::Cond Cond) { |
1502 // SUB (register) - ARM section A8.8.223, encoding A1: | 1503 // SUB (register) - ARM section A8.8.223, encoding A1: |
1503 // sub{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} | 1504 // sub{s}<c> <Rd>, <Rn>, <Rm>{, <shift>} |
1504 // SUB (SP minus register): See ARM section 8.8.226, encoding A1: | 1505 // SUB (SP minus register): See ARM section 8.8.226, encoding A1: |
1505 // sub{s}<c> <Rd>, sp, <Rm>{, <Shift>} | 1506 // sub{s}<c> <Rd>, sp, <Rm>{, <Shift>} |
1506 // | 1507 // |
1507 // cccc0000010snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, | 1508 // cccc0000010snnnnddddiiiiitt0mmmm where cccc=Cond, dddd=Rd, nnnn=Rn, |
1508 // mmmm=Rm, iiiiii=shift, tt=ShiftKind, and s=SetFlags. | 1509 // mmmm=Rm, iiiii=shift, tt=ShiftKind, and s=SetFlags. |
1509 // | 1510 // |
1510 // Sub (Immediate) - ARM section A8.8.222, encoding A1: | 1511 // Sub (Immediate) - ARM section A8.8.222, encoding A1: |
1511 // sub{s}<c> <Rd>, <Rn>, #<RotatedImm8> | 1512 // sub{s}<c> <Rd>, <Rn>, #<RotatedImm8> |
1512 // Sub (Sp minus immediate) - ARM section A8.*.225, encoding A1: | 1513 // Sub (Sp minus immediate) - ARM section A8.*.225, encoding A1: |
1513 // sub{s}<c> sp, <Rn>, #<RotatedImm8> | 1514 // sub{s}<c> sp, <Rn>, #<RotatedImm8> |
1514 // | 1515 // |
1515 // cccc0010010snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, | 1516 // cccc0010010snnnnddddiiiiiiiiiiii where cccc=Cond, dddd=Rd, nnnn=Rn, |
1516 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8 | 1517 // s=SetFlags and iiiiiiiiiiii=Src1Value defining RotatedImm8 |
1517 constexpr const char *SubName = "sub"; | 1518 constexpr const char *SubName = "sub"; |
1518 constexpr IValueT SubOpcode = B1; // 0010 | 1519 constexpr IValueT SubOpcode = B1; // 0010 |
(...skipping 12 matching lines...) Expand all Loading... |
1531 // TST (immediate) - ARM section A8.8.240, encoding A1: | 1532 // TST (immediate) - ARM section A8.8.240, encoding A1: |
1532 // tst<c> <Rn>, #<RotatedImm8> | 1533 // tst<c> <Rn>, #<RotatedImm8> |
1533 // | 1534 // |
1534 // cccc00110001nnnn0000iiiiiiiiiiii where cccc=Cond, nnnn=Rn, and | 1535 // cccc00110001nnnn0000iiiiiiiiiiii where cccc=Cond, nnnn=Rn, and |
1535 // iiiiiiiiiiii defines RotatedImm8. | 1536 // iiiiiiiiiiii defines RotatedImm8. |
1536 constexpr const char *TstName = "tst"; | 1537 constexpr const char *TstName = "tst"; |
1537 constexpr IValueT TstOpcode = B3; // ie. 1000 | 1538 constexpr IValueT TstOpcode = B3; // ie. 1000 |
1538 emitCompareOp(Cond, TstOpcode, OpRn, OpSrc1, TstName); | 1539 emitCompareOp(Cond, TstOpcode, OpRn, OpSrc1, TstName); |
1539 } | 1540 } |
1540 | 1541 |
| 1542 void AssemblerARM32::udiv(const Operand *OpRd, const Operand *OpRn, |
| 1543 const Operand *OpSrc1, CondARM32::Cond Cond) { |
| 1544 // UDIV - ARM section A8.8.248, encoding A1. |
| 1545 // udiv<c> <Rd>, <Rn>, <Rm> |
| 1546 // |
| 1547 // cccc01110011dddd1111mmmm0001nnnn where cccc=Cond, dddd=Rd, nnnn=Rn, and |
| 1548 // mmmm=Rm. |
| 1549 constexpr const char *UdivName = "udiv"; |
| 1550 IValueT Rd = encodeRegister(OpRd, "Rd", UdivName); |
| 1551 IValueT Rn = encodeRegister(OpRn, "Rn", UdivName); |
| 1552 IValueT Rm = encodeRegister(OpSrc1, "Rm", UdivName); |
| 1553 verifyRegNotPc(Rd, "Rd", UdivName); |
| 1554 verifyRegNotPc(Rn, "Rn", UdivName); |
| 1555 verifyRegNotPc(Rm, "Rm", UdivName); |
| 1556 // Assembler registers rd, rn, rm are encoded as rn, rm, rs. |
| 1557 constexpr IValueT UdivOpcode = B21; |
| 1558 emitDivOp(Cond, UdivOpcode, Rd, Rn, Rm, UdivName); |
| 1559 } |
| 1560 |
1541 void AssemblerARM32::umull(const Operand *OpRdLo, const Operand *OpRdHi, | 1561 void AssemblerARM32::umull(const Operand *OpRdLo, const Operand *OpRdHi, |
1542 const Operand *OpRn, const Operand *OpRm, | 1562 const Operand *OpRn, const Operand *OpRm, |
1543 CondARM32::Cond Cond) { | 1563 CondARM32::Cond Cond) { |
1544 // UMULL - ARM section A8.8.257, encoding A1: | 1564 // UMULL - ARM section A8.8.257, encoding A1: |
1545 // umull<c> <RdLo>, <RdHi>, <Rn>, <Rm> | 1565 // umull<c> <RdLo>, <RdHi>, <Rn>, <Rm> |
1546 // | 1566 // |
1547 // cccc0000100shhhhllllmmmm1001nnnn where hhhh=RdHi, llll=RdLo, nnnn=Rn, | 1567 // cccc0000100shhhhllllmmmm1001nnnn where hhhh=RdHi, llll=RdLo, nnnn=Rn, |
1548 // mmmm=Rm, and s=SetFlags | 1568 // mmmm=Rm, and s=SetFlags |
1549 constexpr const char *UmullName = "umull"; | 1569 constexpr const char *UmullName = "umull"; |
1550 IValueT RdLo = encodeRegister(OpRdLo, "RdLo", UmullName); | 1570 IValueT RdLo = encodeRegister(OpRdLo, "RdLo", UmullName); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1590 // rr defined (RotationValue) rotate. | 1610 // rr defined (RotationValue) rotate. |
1591 constexpr IValueT UxtOpcode = B26 | B25 | B23 | B22 | B21 | B20; | 1611 constexpr IValueT UxtOpcode = B26 | B25 | B23 | B22 | B21 | B20; |
1592 emitUxt(Cond, UxtOpcode, Rd, Rn, Rm, Rotation, UxtName); | 1612 emitUxt(Cond, UxtOpcode, Rd, Rn, Rm, Rotation, UxtName); |
1593 return; | 1613 return; |
1594 } | 1614 } |
1595 } | 1615 } |
1596 } | 1616 } |
1597 | 1617 |
1598 } // end of namespace ARM32 | 1618 } // end of namespace ARM32 |
1599 } // end of namespace Ice | 1619 } // end of namespace Ice |
OLD | NEW |