From adbf71eb9869caef8eb61471c0e6a93ead7479e1 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Thu, 26 Oct 2023 15:10:23 -0500 Subject: [PATCH] cmd/internal/obj/ppc64: combine C_SBRA and C_LBRA optab classes 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 Reviewed-by: Michael Knyszek Reviewed-by: Lynn Boger Reviewed-by: David Chase --- src/cmd/internal/obj/ppc64/a.out.go | 5 ++--- src/cmd/internal/obj/ppc64/anames9.go | 5 ++--- src/cmd/internal/obj/ppc64/asm9.go | 31 +++++++++++--------------- src/cmd/internal/obj/ppc64/asm_test.go | 4 ++-- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/cmd/internal/obj/ppc64/a.out.go b/src/cmd/internal/obj/ppc64/a.out.go index 13143f5beb..44c6b09d66 100644 --- a/src/cmd/internal/obj/ppc64/a.out.go +++ b/src/cmd/internal/obj/ppc64/a.out.go @@ -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 */ diff --git a/src/cmd/internal/obj/ppc64/anames9.go b/src/cmd/internal/obj/ppc64/anames9.go index 72d1f4915d..824bc2ab68 100644 --- a/src/cmd/internal/obj/ppc64/anames9.go +++ b/src/cmd/internal/obj/ppc64/anames9.go @@ -33,9 +33,8 @@ var cnames9 = []string{ "SACON", "LACON", "DACON", - "SBRA", - "LBRA", - "LBRAPIC", + "BRA", + "BRAPIC", "ZOREG", "SOREG", "LOREG", diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 0f01dfa8db..541d9fdbbd 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -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) diff --git a/src/cmd/internal/obj/ppc64/asm_test.go b/src/cmd/internal/obj/ppc64/asm_test.go index 7167a6a947..186112b88f 100644 --- a/src/cmd/internal/obj/ppc64/asm_test.go +++ b/src/cmd/internal/obj/ppc64/asm_test.go @@ -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} -- 2.48.1