Skip to content

Commit 1c9c9c8

Browse files
committed
cmd/internal/obj/ppc64: cleanup optab entries after renaming
Combine MOVW/MOVD using C_16CON as they accept any 16 bit constant. Remove MULLW/MULLD C_U16CON optab entry. These assemble to the mulli opcode which only accepts a signed 16 bit constant. Remove superfluous optab entrys for VSPLTB and VSPLTISB, as C_S16CON accepts C_U15CON arguments. Change-Id: Ie20dd07bcedda428fb1dd674474d7dfa67d76dc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/563915 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Paul Murphy <[email protected]> Reviewed-by: Lynn Boger <[email protected]> Reviewed-by: Eli Bendersky <[email protected]>
1 parent cdd0dda commit 1c9c9c8

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

src/cmd/internal/obj/ppc64/asm9.go

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ var optabBase = []Optab{
116116
/* move register */
117117
{as: AADD, a1: C_REG, a2: C_REG, a6: C_REG, type_: 2, size: 4},
118118
{as: AADD, a1: C_REG, a6: C_REG, type_: 2, size: 4},
119-
{as: AADD, a1: C_U15CON, a2: C_REG, a6: C_REG, type_: 4, size: 4},
120-
{as: AADD, a1: C_U15CON, a6: C_REG, type_: 4, size: 4},
121119
{as: AADD, a1: C_S16CON, a2: C_REG, a6: C_REG, type_: 4, size: 4},
122120
{as: AADD, a1: C_S16CON, a6: C_REG, type_: 4, size: 4},
123121
{as: AADD, a1: C_U16CON, a2: C_REG, a6: C_REG, type_: 22, size: 8},
@@ -146,8 +144,6 @@ var optabBase = []Optab{
146144
{as: AMULLW, a1: C_REG, a6: C_REG, type_: 2, size: 4},
147145
{as: AMULLW, a1: C_S16CON, a2: C_REG, a6: C_REG, type_: 4, size: 4},
148146
{as: AMULLW, a1: C_S16CON, a6: C_REG, type_: 4, size: 4},
149-
{as: AMULLW, a1: C_U16CON, a2: C_REG, a6: C_REG, type_: 4, size: 4},
150-
{as: AMULLW, a1: C_U16CON, a6: C_REG, type_: 4, size: 4},
151147
{as: AMULLW, a1: C_32CON, a2: C_REG, a6: C_REG, type_: 22, size: 12},
152148
{as: AMULLW, a1: C_32CON, a6: C_REG, type_: 22, size: 12},
153149
{as: ASUBC, a1: C_REG, a2: C_REG, a6: C_REG, type_: 10, size: 4},
@@ -232,8 +228,7 @@ var optabBase = []Optab{
232228
{as: AMOVBZ, a1: C_REG, a6: C_XOREG, type_: 108, size: 4},
233229
{as: AMOVBZ, a1: C_REG, a6: C_REG, type_: 13, size: 4},
234230

235-
{as: AMOVD, a1: C_S16CON, a6: C_REG, type_: 3, size: 4},
236-
{as: AMOVD, a1: C_U16CON, a6: C_REG, type_: 3, size: 4},
231+
{as: AMOVD, a1: C_16CON, a6: C_REG, type_: 3, size: 4},
237232
{as: AMOVD, a1: C_SACON, a6: C_REG, type_: 3, size: 4},
238233
{as: AMOVD, a1: C_SOREG, a6: C_REG, type_: 8, size: 4},
239234
{as: AMOVD, a1: C_XOREG, a6: C_REG, type_: 109, size: 4},
@@ -245,8 +240,7 @@ var optabBase = []Optab{
245240
{as: AMOVD, a1: C_REG, a6: C_SPR, type_: 66, size: 4},
246241
{as: AMOVD, a1: C_REG, a6: C_REG, type_: 13, size: 4},
247242

248-
{as: AMOVW, a1: C_S16CON, a6: C_REG, type_: 3, size: 4},
249-
{as: AMOVW, a1: C_U16CON, a6: C_REG, type_: 3, size: 4},
243+
{as: AMOVW, a1: C_16CON, a6: C_REG, type_: 3, size: 4},
250244
{as: AMOVW, a1: C_SACON, a6: C_REG, type_: 3, size: 4},
251245
{as: AMOVW, a1: C_CREG, a6: C_REG, type_: 68, size: 4},
252246
{as: AMOVW, a1: C_SOREG, a6: C_REG, type_: 8, size: 4},
@@ -391,9 +385,7 @@ var optabBase = []Optab{
391385
{as: AVSEL, a1: C_VREG, a2: C_VREG, a3: C_VREG, a6: C_VREG, type_: 83, size: 4}, /* vector select, va-form */
392386

393387
/* Vector splat */
394-
{as: AVSPLTB, a1: C_U15CON, a2: C_VREG, a6: C_VREG, type_: 82, size: 4}, /* vector splat, vx-form */
395388
{as: AVSPLTB, a1: C_S16CON, a2: C_VREG, a6: C_VREG, type_: 82, size: 4},
396-
{as: AVSPLTISB, a1: C_U15CON, a6: C_VREG, type_: 82, size: 4}, /* vector splat immediate, vx-form */
397389
{as: AVSPLTISB, a1: C_S16CON, a6: C_VREG, type_: 82, size: 4},
398390

399391
/* Vector AES */
@@ -2544,34 +2536,26 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) {
25442536
}
25452537
o1 = AOP_RRR(c.oprrr(p.As), uint32(p.To.Reg), uint32(r), uint32(p.From.Reg))
25462538

2547-
case 3: /* mov $soreg/addcon/andcon/ucon, r ==> addis/oris/addi/ori $i,reg',r */
2539+
case 3: /* mov $soreg/16con, r ==> addi/ori $i,reg',r */
25482540
d := c.vregoff(&p.From)
25492541

25502542
v := int32(d)
25512543
r := int(p.From.Reg)
2552-
// p.From may be a constant value or an offset(reg) type argument.
2553-
isZeroOrR0 := r&0x1f == 0
25542544

25552545
if r0iszero != 0 /*TypeKind(100016)*/ && p.To.Reg == 0 && (r != 0 || v != 0) {
25562546
c.ctxt.Diag("literal operation on R0\n%v", p)
25572547
}
2558-
a := OP_ADDI
2559-
if int64(int16(d)) != d {
2560-
// Operand is 16 bit value with sign bit set
2561-
if o.a1 == C_U16CON {
2562-
// Needs unsigned 16 bit so use ORI
2563-
if isZeroOrR0 {
2564-
o1 = LOP_IRR(uint32(OP_ORI), uint32(p.To.Reg), uint32(0), uint32(v))
2565-
break
2566-
}
2567-
// With S16CON, needs signed 16 bit value, fall through to use ADDI
2568-
} else if o.a1 != C_S16CON {
2569-
log.Fatalf("invalid handling of %v", p)
2548+
if int64(int16(d)) == d {
2549+
// MOVD $int16, Ry or MOVD $offset(Rx), Ry
2550+
o1 = AOP_IRR(uint32(OP_ADDI), uint32(p.To.Reg), uint32(r), uint32(v))
2551+
} else {
2552+
// MOVD $uint16, Ry
2553+
if int64(uint16(d)) != d || (r != 0 && r != REGZERO) {
2554+
c.ctxt.Diag("Rule expects a uint16 constant load. got:\n%v", p)
25702555
}
2556+
o1 = LOP_IRR(uint32(OP_ORI), uint32(p.To.Reg), uint32(0), uint32(v))
25712557
}
25722558

2573-
o1 = AOP_IRR(uint32(a), uint32(p.To.Reg), uint32(r), uint32(v))
2574-
25752559
case 4: /* add/mul $scon,[r1],r2 */
25762560
v := c.regoff(&p.From)
25772561

0 commit comments

Comments
 (0)