]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/ppc64: combine C_SBRA and C_LBRA optab classes
authorPaul E. Murphy <murp@ibm.com>
Thu, 26 Oct 2023 20:10:23 +0000 (15:10 -0500)
committerPaul Murphy <murp@ibm.com>
Wed, 7 Feb 2024 21:50:42 +0000 (21:50 +0000)
The assembler treats C_SBRA and C_LBRA optab classes identically,
combine them into one class to reduce the number of optab classes.

Likewise, C_LBRAPIC is renamed to C_BRAPIC for consistency with
the above change.

Change-Id: I47000e7273cb8f89a4d0621d71433ccbfb7afb70
Reviewed-on: https://go-review.googlesource.com/c/go/+/557916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/obj/ppc64/a.out.go
src/cmd/internal/obj/ppc64/anames9.go
src/cmd/internal/obj/ppc64/asm9.go
src/cmd/internal/obj/ppc64/asm_test.go

index 13143f5beb3797548517bb9719d4a2eb3bf0cfb3..44c6b09d669ac5fbf3a2e3c78d5f15054f3e3497 100644 (file)
@@ -428,9 +428,8 @@ const (
        C_SACON    /* $n(REG) where n <= int16 */
        C_LACON    /* $n(REG) where n <= int32 */
        C_DACON    /* $n(REG) where n <= int64 */
-       C_SBRA     /* A short offset argument to a branching instruction */
-       C_LBRA     /* A long offset argument to a branching instruction */
-       C_LBRAPIC  /* Like C_LBRA, but requires an extra NOP for potential TOC restore by the linker. */
+       C_BRA      /* A short offset argument to a branching instruction */
+       C_BRAPIC   /* Like C_BRA, but requires an extra NOP for potential TOC restore by the linker. */
        C_ZOREG    /* An $0+reg memory op */
        C_SOREG    /* An $n+reg memory arg where n is a 16 bit signed offset */
        C_LOREG    /* An $n+reg memory arg where n is a 32 bit signed offset */
index 72d1f4915dea82069b73f0a2fe8a824899c99d16..824bc2ab6853b82d3e4771c068937d2bbee2ad52 100644 (file)
@@ -33,9 +33,8 @@ var cnames9 = []string{
        "SACON",
        "LACON",
        "DACON",
-       "SBRA",
-       "LBRA",
-       "LBRAPIC",
+       "BRA",
+       "BRAPIC",
        "ZOREG",
        "SOREG",
        "LOREG",
index 0f01dfa8db99394f9b6d2e56eeac2de75e2d8f74..541d9fdbbdfa3ca78428cec1f482594ef8ff140b 100644 (file)
@@ -284,18 +284,17 @@ var optabBase = []Optab{
        {as: ASYSCALL, type_: 5, size: 4},
        {as: ASYSCALL, a1: C_REG, type_: 77, size: 12},
        {as: ASYSCALL, a1: C_SCON, type_: 77, size: 12},
-       {as: ABEQ, a6: C_SBRA, type_: 16, size: 4},
-       {as: ABEQ, a1: C_CREG, a6: C_SBRA, type_: 16, size: 4},
-       {as: ABR, a6: C_LBRA, type_: 11, size: 4},                                    // b label
-       {as: ABR, a6: C_LBRAPIC, type_: 11, size: 8},                                 // b label; nop
+       {as: ABEQ, a6: C_BRA, type_: 16, size: 4},
+       {as: ABEQ, a1: C_CREG, a6: C_BRA, type_: 16, size: 4},
+       {as: ABR, a6: C_BRA, type_: 11, size: 4},                                     // b label
+       {as: ABR, a6: C_BRAPIC, type_: 11, size: 8},                                  // b label; nop
        {as: ABR, a6: C_LR, type_: 18, size: 4},                                      // blr
        {as: ABR, a6: C_CTR, type_: 18, size: 4},                                     // bctr
-       {as: ABC, a1: C_SCON, a2: C_CRBIT, a6: C_SBRA, type_: 16, size: 4},           // bc bo, bi, label
-       {as: ABC, a1: C_SCON, a2: C_CRBIT, a6: C_LBRA, type_: 17, size: 4},           // bc bo, bi, label
+       {as: ABC, a1: C_SCON, a2: C_CRBIT, a6: C_BRA, type_: 16, size: 4},            // bc bo, bi, label
        {as: ABC, a1: C_SCON, a2: C_CRBIT, a6: C_LR, type_: 18, size: 4},             // bclr bo, bi
        {as: ABC, a1: C_SCON, a2: C_CRBIT, a3: C_SCON, a6: C_LR, type_: 18, size: 4}, // bclr bo, bi, bh
        {as: ABC, a1: C_SCON, a2: C_CRBIT, a6: C_CTR, type_: 18, size: 4},            // bcctr bo, bi
-       {as: ABDNZ, a6: C_SBRA, type_: 16, size: 4},
+       {as: ABDNZ, a6: C_BRA, 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},
@@ -515,9 +514,9 @@ var optabBase = []Optab{
        {as: obj.ANOP, a1: C_LCON, type_: 0, size: 0}, // NOP operand variations added for #40689
        {as: obj.ANOP, a1: C_REG, type_: 0, size: 0},  // to preserve previous behavior
        {as: obj.ANOP, a1: C_FREG, type_: 0, size: 0},
-       {as: obj.ADUFFZERO, a6: C_LBRA, type_: 11, size: 4}, // same as ABR/ABL
-       {as: obj.ADUFFCOPY, a6: C_LBRA, type_: 11, size: 4}, // same as ABR/ABL
-       {as: obj.APCALIGN, a1: C_LCON, type_: 0, size: 0},   // align code
+       {as: obj.ADUFFZERO, a6: C_BRA, type_: 11, size: 4}, // same as ABR/ABL
+       {as: obj.ADUFFCOPY, a6: C_BRA, type_: 11, size: 4}, // same as ABR/ABL
+       {as: obj.APCALIGN, a1: C_LCON, type_: 0, size: 0},  // align code
 }
 
 // These are opcodes above which may generate different sequences depending on whether prefix opcode support
@@ -1041,9 +1040,9 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
 
        case obj.TYPE_BRANCH:
                if a.Sym != nil && c.ctxt.Flag_dynlink && !pfxEnabled {
-                       return C_LBRAPIC
+                       return C_BRAPIC
                }
-               return C_SBRA
+               return C_BRA
        }
 
        return C_GOK
@@ -1160,9 +1159,6 @@ func cmp(a int, b int) bool {
        case C_LACON:
                return cmp(C_SACON, b)
 
-       case C_LBRA:
-               return cmp(C_SBRA, b)
-
        case C_SOREG:
                return cmp(C_ZOREG, b)
 
@@ -2654,7 +2650,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
                }
                o1 = AOP_RRR(c.oprrr(p.As), uint32(p.To.Reg), uint32(p.From.Reg), uint32(r))
 
-       case 11: /* br/bl lbra */
+       case 11: /* br/bl bra */
                v := int32(0)
 
                if p.To.Target() != nil {
@@ -2776,8 +2772,7 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
                        c.ctxt.Diag("unexpected op in rldc case\n%v", p)
                }
 
-       case 17, /* bc bo,bi,lbra (same for now) */
-               16: /* bc bo,bi,sbra */
+       case 16: /* bc bo,bi,bra */
                a := 0
 
                r := int(p.Reg)
index 7167a6a947e85170100b0a214462fbac0a7fa074..186112b88f4283b7af0b355e4baea72acc692d18 100644 (file)
@@ -525,8 +525,8 @@ func TestAddrClassifier(t *testing.T) {
                {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -(1 << 34)}, C_64CON},
 
                // Branch like arguments
-               {obj.Addr{Type: obj.TYPE_BRANCH, Sym: &obj.LSym{Type: objabi.SDATA}}, cmplx{C_SBRA, C_LBRAPIC, C_LBRAPIC, C_SBRA}},
-               {obj.Addr{Type: obj.TYPE_BRANCH}, C_SBRA},
+               {obj.Addr{Type: obj.TYPE_BRANCH, Sym: &obj.LSym{Type: objabi.SDATA}}, cmplx{C_BRA, C_BRAPIC, C_BRAPIC, C_BRA}},
+               {obj.Addr{Type: obj.TYPE_BRANCH}, C_BRA},
        }
 
        pic_ctxt9 := ctxt9{ctxt: &obj.Link{Flag_shared: true, Arch: &Linkppc64}, autosize: 0}