Skip to content

Commit 11c2411

Browse files
Ruixin(Peter) Baomundaym
Ruixin(Peter) Bao
authored andcommitted
cmd/compile/internal/s390x: replace 4-byte NOP with a 2-byte NOP on s390x
Added a new instruction, NOPH, with the encoding [0x0700](i.e: bcr 0, 0) and replace the current 4-byte nop that was encoded using the WORD instruction. This reduces the size of .text section in go binary by around 17KB and make generated code easier to read. Change-Id: I6a756df39e93c4415ea6d038ba4af001b8ccb286 Reviewed-on: https://go-review.googlesource.com/c/go/+/194344 Reviewed-by: Michael Munday <[email protected]> Run-TryBot: Michael Munday <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent b25ec50 commit 11c2411

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

src/cmd/asm/internal/asm/testdata/s390x.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
329329
TCEB F5, $8 // ed5000080010
330330
TCDB F15, $4095 // edf00fff0011
331331

332+
UNDEF // 00000000
333+
NOPH // 0700
334+
332335
VL (R15), V1 // e710f0000006
333336
VST V1, (R15) // e710f000000e
334337
VL (R15), V31 // e7f0f0000806

src/cmd/compile/internal/s390x/ggen.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,5 @@ func zeroAuto(pp *gc.Progs, n *gc.Node) {
105105
}
106106

107107
func ginsnop(pp *gc.Progs) *obj.Prog {
108-
p := pp.Prog(s390x.AWORD)
109-
p.From.Type = obj.TYPE_CONST
110-
p.From.Offset = 0x47000000 // nop 0
111-
return p
108+
return pp.Prog(s390x.ANOPH)
112109
}

src/cmd/internal/obj/s390x/a.out.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,8 @@ const (
966966
AVMSLOG
967967
AVMSLEOG
968968

969+
ANOPH // NOP
970+
969971
// binary
970972
ABYTE
971973
AWORD

src/cmd/internal/obj/s390x/anames.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/internal/obj/s390x/asmz.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ var optab = []Optab{
314314
// undefined (deliberate illegal instruction)
315315
{i: 78, as: obj.AUNDEF},
316316

317+
// 2 byte no-operation
318+
{i: 66, as: ANOPH},
319+
317320
// vector instructions
318321

319322
// VRX store
@@ -3394,6 +3397,9 @@ func (c *ctxtz) asmout(p *obj.Prog, asm *[]byte) {
33943397
d2 := c.regoff(&p.To)
33953398
zRXE(opcode, uint32(p.From.Reg), 0, 0, uint32(d2), 0, asm)
33963399

3400+
case 66:
3401+
zRR(op_BCR, 0, 0, asm)
3402+
33973403
case 67: // fmov $0 freg
33983404
var opcode uint32
33993405
switch p.As {

0 commit comments

Comments
 (0)