1
0
mirror of https://github.com/golang/go synced 2024-11-17 18:44:44 -07:00

Revert "cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x"

This reverts CL 227775.

Reason for revert: broke aix-ppc64 builder (https://build.golang.org/log/cf3b4f9fd09ee81f422a4b58488b9d0a2692c949).

Change-Id: I2095bb2aadb5a4064eb89ad353012503faf15709
Reviewed-on: https://go-review.googlesource.com/c/go/+/228143
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Bryan C. Mills 2020-04-13 14:56:32 +00:00 committed by Lynn Boger
parent d3d21d0a42
commit bd0623b4e7
2 changed files with 15 additions and 54 deletions

View File

@ -620,7 +620,7 @@ var oprange [ALAST & obj.AMask][]Optab
var xcmp [C_NCLASS][C_NCLASS]bool
// padding bytes to add to align code as requested
func addpad(pc, a int64, ctxt *obj.Link, cursym *obj.LSym) int {
func addpad(pc, a int64, ctxt *obj.Link) int {
switch a {
case 8:
if pc&7 != 0 {
@ -633,21 +633,6 @@ func addpad(pc, a int64, ctxt *obj.Link, cursym *obj.LSym) int {
case 8:
return 8
}
case 32:
switch pc & 31 {
case 4, 20:
return 12
case 8, 24:
return 8
case 12, 28:
return 4
}
// The default function alignment is 16, but
// if 32 byte alignment is requested then the
// function needs to be aligned to 32.
if cursym.Func.Align < 32 {
cursym.Func.Align = 32
}
default:
ctxt.Diag("Unexpected alignment: %d for PCALIGN directive\n", a)
}
@ -678,7 +663,7 @@ func span9(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
if m == 0 {
if p.As == obj.APCALIGN {
a := c.vregoff(&p.From)
m = addpad(pc, a, ctxt, cursym)
m = addpad(pc, a, ctxt)
} else {
if p.As != obj.ANOP && p.As != obj.AFUNCDATA && p.As != obj.APCDATA {
ctxt.Diag("zero-width instruction\n%v", p)
@ -736,7 +721,7 @@ func span9(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
if m == 0 {
if p.As == obj.APCALIGN {
a := c.vregoff(&p.From)
m = addpad(pc, a, ctxt, cursym)
m = addpad(pc, a, ctxt)
} else {
if p.As != obj.ANOP && p.As != obj.AFUNCDATA && p.As != obj.APCDATA {
ctxt.Diag("zero-width instruction\n%v", p)
@ -751,6 +736,10 @@ func span9(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
c.cursym.Size = pc
}
if r := pc & funcAlignMask; r != 0 {
pc += funcAlign - r
}
c.cursym.Size = pc
/*
@ -772,7 +761,7 @@ func span9(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
if o.type_ == 0 && p.As == obj.APCALIGN {
pad := LOP_RRR(OP_OR, REGZERO, REGZERO, REGZERO)
aln := c.vregoff(&p.From)
v := addpad(p.Pc, aln, c.ctxt, c.cursym)
v := addpad(p.Pc, aln, c.ctxt)
if v > 0 {
// Same padding instruction for all
for i = 0; i < int32(v/4); i++ {

View File

@ -10,7 +10,6 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"testing"
)
@ -18,20 +17,21 @@ import (
var invalidPCAlignSrc = `
TEXT test(SB),0,$0-0
ADD $2, R3
PCALIGN $64
PCALIGN $32
RET
`
var validPCAlignSrc = `
TEXT test(SB),0,$0-0
ADD $2, R3
PCALIGN $16
MOVD $8, R16
MOVD $8, R4
ADD $8, R4
PCALIGN $16
ADD $8, R4
PCALIGN $32
ADD $8, R3
PCALIGN $8
ADD $4, R8
ADD $4, R6
PCALIGN $16
ADD R2, R3, R4
RET
`
@ -39,10 +39,6 @@ RET
// PCALIGN directive, to verify correct values are and
// accepted, and incorrect values are flagged in error.
func TestPCalign(t *testing.T) {
var pattern8 = `0x...8\s.*ADD\s..,\sR8`
var pattern16 = `0x...[80]\s.*MOVD\s..,\sR16`
var pattern32 = `0x...0\s.*ADD\s..,\sR3`
testenv.MustHaveGoBuild(t)
dir, err := ioutil.TempDir("", "testpcalign")
@ -67,30 +63,6 @@ func TestPCalign(t *testing.T) {
t.Errorf("Build failed: %v, output: %s", err, out)
}
matched, err := regexp.MatchString(pattern8, string(out))
if err != nil {
t.Fatal(err)
}
if !matched {
t.Errorf("The 8 byte alignment is not correct: %t, output:%s\n", matched, out)
}
matched, err = regexp.MatchString(pattern16, string(out))
if err != nil {
t.Fatal(err)
}
if !matched {
t.Errorf("The 16 byte alignment is not correct: %t, output:%s\n", matched, out)
}
matched, err = regexp.MatchString(pattern32, string(out))
if err != nil {
t.Fatal(err)
}
if !matched {
t.Errorf("The 32 byte alignment is not correct: %t, output:%s\n", matched, out)
}
// generate a test with invalid use of PCALIGN
tmpfile = filepath.Join(dir, "xi.s")