]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/asm: add support for bdnz/bdz extended mnemonics on PPC64
authorPaul E. Murphy <murp@ibm.com>
Mon, 25 Oct 2021 21:51:55 +0000 (16:51 -0500)
committerPaul Murphy <murp@ibm.com>
Fri, 11 Mar 2022 14:06:56 +0000 (14:06 +0000)
Support BDNZ and BDZ mnemonics, they are commonly used
POWER instructions. The raw BC mnemonic is not easy
to read.

Likewise, cleanup code surrounding these changes.

Change-Id: I72f1dad5013f7856bd0dd320bfb17b5a9f3c69ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/390696
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/asm/internal/arch/ppc64.go
src/cmd/asm/internal/asm/testdata/ppc64.s
src/cmd/internal/obj/ppc64/a.out.go
src/cmd/internal/obj/ppc64/anames.go
src/cmd/internal/obj/ppc64/asm9.go

index 3139665ba55c581f00f71b89db303673e4b7a5eb..616e189b1a8ac09f2a50828acdb69e564c91e957 100644 (file)
@@ -15,7 +15,7 @@ import (
 
 func jumpPPC64(word string) bool {
        switch word {
-       case "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLT", "BNE", "BR", "BVC", "BVS", "CALL", "JMP":
+       case "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLT", "BNE", "BR", "BVC", "BVS", "BDNZ", "BDZ", "CALL", "JMP":
                return true
        }
        return false
index c140fd025a64e8117754db20842bffe3e714b3ff..5452668791d205522e35d9e45def10612331bbf9 100644 (file)
@@ -751,17 +751,23 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
        MOVD XER, R3                    // 7c6102a6
        MOVFL CR3, CR1                  // 4c8c0000
 
-       MOVW CR0, R1                    // 7c380026
-       MOVW CR7, R1                    // 7c301026
-       MOVW CR, R1                     // 7c200026
-
-       MOVW R1, CR                     // 7c2ff120
-       MOVFL R1, CR                    // 7c2ff120
-       MOVW R1, CR2                    // 7c320120
-       MOVFL R1, CR2                   // 7c320120
-       MOVFL R1, $255                  // 7c2ff120
-       MOVFL R1, $1                    // 7c301120
-       MOVFL R1, $128                  // 7c380120
-       MOVFL R1, $3                    // 7c203120
+       MOVW CR0, R1                    // 7c380026
+       MOVW CR7, R1                    // 7c301026
+       MOVW CR, R1                     // 7c200026
+
+       MOVW R1, CR                     // 7c2ff120
+       MOVFL R1, CR                    // 7c2ff120
+       MOVW R1, CR2                    // 7c320120
+       MOVFL R1, CR2                   // 7c320120
+       MOVFL R1, $255                  // 7c2ff120
+       MOVFL R1, $1                    // 7c301120
+       MOVFL R1, $128                  // 7c380120
+       MOVFL R1, $3                    // 7c203120
+
+       // Verify supported bdnz/bdz encodings.
+       BC 16,0,0(PC)                   // BC $16,R0,0(PC) // 42000000
+       BDNZ 0(PC)                      // 42000000
+       BDZ 0(PC)                       // 42400000
+       BC 18,0,0(PC)                   // BC $18,R0,0(PC) // 42400000
 
        RET
index 1e74e64a29fb5ff0089632923935cfe76dd21c0b..25081efcee8b3156479ae62a2e26991bef5e1c5d 100644 (file)
@@ -362,13 +362,14 @@ const (
        BI_LT  = 0
        BI_GT  = 1
        BI_EQ  = 2
-       BI_OVF = 3
+       BI_FU  = 3
 )
 
 // Common values for the BO field.
 
 const (
        BO_BCTR    = 16 // decrement ctr, branch on ctr != 0
+       BO_NOTBCTR = 18 // decrement ctr, branch on ctr == 0
        BO_BCR     = 12 // branch on cr value
        BO_BCRBCTR = 8  // decrement ctr, branch on ctr != 0 and cr value
        BO_NOTBCR  = 4  // branch on not cr value
@@ -480,9 +481,11 @@ const (
        ABGT
        ABLE // not GT = L/E/U
        ABLT
-       ABNE // not EQ = L/G/U
-       ABVC // Unordered-clear
-       ABVS // Unordered-set
+       ABNE  // not EQ = L/G/U
+       ABVC  // Branch if float not unordered (also branch on not summary overflow)
+       ABVS  // Branch if float unordered (also branch on summary overflow)
+       ABDNZ // Decrement CTR, and branch if CTR != 0
+       ABDZ  // Decrement CTR, and branch if CTR == 0
        ACMP
        ACMPU
        ACMPEQB
index 0da73ca91ed6c9f8d1036e94c481c918ddc39f12..7521a92ab4d35c1b47389e9a3cfac07b8e894d9a 100644 (file)
@@ -42,6 +42,8 @@ var Anames = []string{
        "BNE",
        "BVC",
        "BVS",
+       "BDNZ",
+       "BDZ",
        "CMP",
        "CMPU",
        "CMPEQB",
index 70ce9050b698fdeefd49a8112f656fa662795c46..50c9b37f02fa262669a8c901c99ca57dd0c7659a 100644 (file)
@@ -305,6 +305,7 @@ var optab = []Optab{
        {as: ABC, a1: C_SCON, a2: C_REG, a6: C_LR, type_: 18, size: 4},
        {as: ABC, a1: C_SCON, a2: C_REG, a6: C_CTR, type_: 18, size: 4},
        {as: ABC, a6: C_ZOREG, type_: 15, size: 8},
+       {as: ABDNZ, a6: C_SBRA, type_: 16, size: 4},
        {as: ASYNC, type_: 46, size: 4},
        {as: AWORD, a1: C_LCON, type_: 40, size: 4},
        {as: ADWORD, a1: C_64CON, type_: 31, size: 8},
@@ -1778,6 +1779,9 @@ func buildop(ctxt *obj.Link) {
                case ABC:
                        opset(ABCL, r0)
 
+               case ABDNZ:
+                       opset(ABDZ, r0)
+
                case AEXTSB: /* op Rs, Ra */
                        opset(AEXTSBCC, r0)
 
@@ -4875,21 +4879,25 @@ func (c *ctxt9) opirr(a obj.As) uint32 {
                return OPVCC(16, 0, 0, 0) | 1
 
        case ABEQ:
-               return AOP_RRR(16<<26, 12, 2, 0)
+               return AOP_RRR(16<<26, BO_BCR, BI_EQ, 0)
        case ABGE:
-               return AOP_RRR(16<<26, 4, 0, 0)
+               return AOP_RRR(16<<26, BO_NOTBCR, BI_LT, 0)
        case ABGT:
-               return AOP_RRR(16<<26, 12, 1, 0)
+               return AOP_RRR(16<<26, BO_BCR, BI_GT, 0)
        case ABLE:
-               return AOP_RRR(16<<26, 4, 1, 0)
+               return AOP_RRR(16<<26, BO_NOTBCR, BI_GT, 0)
        case ABLT:
-               return AOP_RRR(16<<26, 12, 0, 0)
+               return AOP_RRR(16<<26, BO_BCR, BI_LT, 0)
        case ABNE:
-               return AOP_RRR(16<<26, 4, 2, 0)
+               return AOP_RRR(16<<26, BO_NOTBCR, BI_EQ, 0)
        case ABVC:
-               return AOP_RRR(16<<26, 4, 3, 0) // apparently unordered-clear
+               return AOP_RRR(16<<26, BO_NOTBCR, BI_FU, 0)
        case ABVS:
-               return AOP_RRR(16<<26, 12, 3, 0) // apparently unordered-set
+               return AOP_RRR(16<<26, BO_BCR, BI_FU, 0)
+       case ABDZ:
+               return AOP_RRR(16<<26, BO_NOTBCTR, 0, 0)
+       case ABDNZ:
+               return AOP_RRR(16<<26, BO_BCTR, 0, 0)
 
        case ACMP:
                return OPVCC(11, 0, 0, 0) | 1<<21 /* L=1 */