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 <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>
This commit is contained in:
Paul E. Murphy 2023-10-26 15:10:23 -05:00 committed by Paul Murphy
parent 1ffc110469
commit adbf71eb98
4 changed files with 19 additions and 26 deletions

View File

@ -428,9 +428,8 @@ const (
C_SACON /* $n(REG) where n <= int16 */ C_SACON /* $n(REG) where n <= int16 */
C_LACON /* $n(REG) where n <= int32 */ C_LACON /* $n(REG) where n <= int32 */
C_DACON /* $n(REG) where n <= int64 */ C_DACON /* $n(REG) where n <= int64 */
C_SBRA /* A short offset argument to a branching instruction */ C_BRA /* A short offset argument to a branching instruction */
C_LBRA /* A long offset argument to a branching instruction */ C_BRAPIC /* Like C_BRA, but requires an extra NOP for potential TOC restore by the linker. */
C_LBRAPIC /* Like C_LBRA, but requires an extra NOP for potential TOC restore by the linker. */
C_ZOREG /* An $0+reg memory op */ C_ZOREG /* An $0+reg memory op */
C_SOREG /* An $n+reg memory arg where n is a 16 bit signed offset */ 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 */ C_LOREG /* An $n+reg memory arg where n is a 32 bit signed offset */

View File

@ -33,9 +33,8 @@ var cnames9 = []string{
"SACON", "SACON",
"LACON", "LACON",
"DACON", "DACON",
"SBRA", "BRA",
"LBRA", "BRAPIC",
"LBRAPIC",
"ZOREG", "ZOREG",
"SOREG", "SOREG",
"LOREG", "LOREG",

View File

@ -284,18 +284,17 @@ var optabBase = []Optab{
{as: ASYSCALL, type_: 5, size: 4}, {as: ASYSCALL, type_: 5, size: 4},
{as: ASYSCALL, a1: C_REG, type_: 77, size: 12}, {as: ASYSCALL, a1: C_REG, type_: 77, size: 12},
{as: ASYSCALL, a1: C_SCON, type_: 77, size: 12}, {as: ASYSCALL, a1: C_SCON, type_: 77, size: 12},
{as: ABEQ, a6: C_SBRA, type_: 16, size: 4}, {as: ABEQ, a6: C_BRA, type_: 16, size: 4},
{as: ABEQ, a1: C_CREG, a6: C_SBRA, type_: 16, size: 4}, {as: ABEQ, a1: C_CREG, a6: C_BRA, type_: 16, size: 4},
{as: ABR, a6: C_LBRA, type_: 11, size: 4}, // b label {as: ABR, a6: C_BRA, type_: 11, size: 4}, // b label
{as: ABR, a6: C_LBRAPIC, type_: 11, size: 8}, // b label; nop {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_LR, type_: 18, size: 4}, // blr
{as: ABR, a6: C_CTR, type_: 18, size: 4}, // bctr {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_BRA, 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_LR, type_: 18, size: 4}, // bclr bo, bi {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, 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: 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: ASYNC, type_: 46, size: 4},
{as: AWORD, a1: C_LCON, type_: 40, size: 4}, {as: AWORD, a1: C_LCON, type_: 40, size: 4},
{as: ADWORD, a1: C_64CON, type_: 31, size: 8}, {as: ADWORD, a1: C_64CON, type_: 31, size: 8},
@ -515,8 +514,8 @@ var optabBase = []Optab{
{as: obj.ANOP, a1: C_LCON, type_: 0, size: 0}, // NOP operand variations added for #40689 {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_REG, type_: 0, size: 0}, // to preserve previous behavior
{as: obj.ANOP, a1: C_FREG, type_: 0, size: 0}, {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.ADUFFZERO, a6: C_BRA, type_: 11, size: 4}, // same as ABR/ABL
{as: obj.ADUFFCOPY, a6: C_LBRA, 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 {as: obj.APCALIGN, a1: C_LCON, type_: 0, size: 0}, // align code
} }
@ -1041,9 +1040,9 @@ func (c *ctxt9) aclass(a *obj.Addr) int {
case obj.TYPE_BRANCH: case obj.TYPE_BRANCH:
if a.Sym != nil && c.ctxt.Flag_dynlink && !pfxEnabled { if a.Sym != nil && c.ctxt.Flag_dynlink && !pfxEnabled {
return C_LBRAPIC return C_BRAPIC
} }
return C_SBRA return C_BRA
} }
return C_GOK return C_GOK
@ -1160,9 +1159,6 @@ func cmp(a int, b int) bool {
case C_LACON: case C_LACON:
return cmp(C_SACON, b) return cmp(C_SACON, b)
case C_LBRA:
return cmp(C_SBRA, b)
case C_SOREG: case C_SOREG:
return cmp(C_ZOREG, b) 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)) 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) v := int32(0)
if p.To.Target() != nil { 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) c.ctxt.Diag("unexpected op in rldc case\n%v", p)
} }
case 17, /* bc bo,bi,lbra (same for now) */ case 16: /* bc bo,bi,bra */
16: /* bc bo,bi,sbra */
a := 0 a := 0
r := int(p.Reg) r := int(p.Reg)

View 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}, {obj.Addr{Type: obj.TYPE_CONST, Name: obj.NAME_NONE, Offset: -(1 << 34)}, C_64CON},
// Branch like arguments // 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, Sym: &obj.LSym{Type: objabi.SDATA}}, cmplx{C_BRA, C_BRAPIC, C_BRAPIC, C_BRA}},
{obj.Addr{Type: obj.TYPE_BRANCH}, C_SBRA}, {obj.Addr{Type: obj.TYPE_BRANCH}, C_BRA},
} }
pic_ctxt9 := ctxt9{ctxt: &obj.Link{Flag_shared: true, Arch: &Linkppc64}, autosize: 0} pic_ctxt9 := ctxt9{ctxt: &obj.Link{Flag_shared: true, Arch: &Linkppc64}, autosize: 0}