Commit 613ba6cd authored by Michael Munday's avatar Michael Munday Committed by Matthew Dempsky

cmd/compile/internal/gc: add s390x support

Allows instructions with a From3 field to be used in regopt so
long as From3 represents a constant. This is needed because the
storage-to-storage instructions on s390x place the length of the
data into From3.

Change-Id: I12cd32d4f997baf2fe97937bb7d45bbf716dfcb5
Reviewed-on: https://go-review.googlesource.com/20875Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
parent 811ebb6a
...@@ -247,7 +247,7 @@ func cgen_wb(n, res *Node, wb bool) { ...@@ -247,7 +247,7 @@ func cgen_wb(n, res *Node, wb bool) {
return return
} }
if Ctxt.Arch.InFamily(sys.AMD64, sys.I386) && n.Addable { if Ctxt.Arch.InFamily(sys.AMD64, sys.I386, sys.S390X) && n.Addable {
Thearch.Gmove(n, res) Thearch.Gmove(n, res)
return return
} }
...@@ -1829,7 +1829,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) { ...@@ -1829,7 +1829,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
// Some architectures might need a temporary or other help here, // Some architectures might need a temporary or other help here,
// but they don't support direct generation of a bool value yet. // but they don't support direct generation of a bool value yet.
// We can fix that as we go. // We can fix that as we go.
mayNeedTemp := Ctxt.Arch.InFamily(sys.ARM, sys.ARM64, sys.MIPS64, sys.PPC64) mayNeedTemp := Ctxt.Arch.InFamily(sys.ARM, sys.ARM64, sys.MIPS64, sys.PPC64, sys.S390X)
if genval { if genval {
if mayNeedTemp { if mayNeedTemp {
......
...@@ -58,7 +58,9 @@ func Ismem(n *Node) bool { ...@@ -58,7 +58,9 @@ func Ismem(n *Node) bool {
return true return true
case OADDR: case OADDR:
return Thearch.LinkArch.InFamily(sys.AMD64, sys.PPC64) // because 6g uses PC-relative addressing; TODO(rsc): not sure why 9g too // amd64 and s390x use PC relative addressing.
// TODO(rsc): not sure why ppc64 needs this too.
return Thearch.LinkArch.InFamily(sys.AMD64, sys.PPC64, sys.S390X)
} }
return false return false
...@@ -84,7 +86,7 @@ func Gbranch(as obj.As, t *Type, likely int) *obj.Prog { ...@@ -84,7 +86,7 @@ func Gbranch(as obj.As, t *Type, likely int) *obj.Prog {
p := Prog(as) p := Prog(as)
p.To.Type = obj.TYPE_BRANCH p.To.Type = obj.TYPE_BRANCH
p.To.Val = nil p.To.Val = nil
if as != obj.AJMP && likely != 0 && Thearch.LinkArch.Family != sys.PPC64 && Thearch.LinkArch.Family != sys.ARM64 && Thearch.LinkArch.Family != sys.MIPS64 { if as != obj.AJMP && likely != 0 && !Thearch.LinkArch.InFamily(sys.PPC64, sys.ARM64, sys.MIPS64, sys.S390X) {
p.From.Type = obj.TYPE_CONST p.From.Type = obj.TYPE_CONST
if likely > 0 { if likely > 0 {
p.From.Offset = 1 p.From.Offset = 1
...@@ -458,7 +460,7 @@ func Naddr(a *obj.Addr, n *Node) { ...@@ -458,7 +460,7 @@ func Naddr(a *obj.Addr, n *Node) {
case OADDR: case OADDR:
Naddr(a, n.Left) Naddr(a, n.Left)
a.Etype = uint8(Tptr) a.Etype = uint8(Tptr)
if !Thearch.LinkArch.InFamily(sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64) { // TODO(rsc): Do this even for arm, ppc64. if !Thearch.LinkArch.InFamily(sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) { // TODO(rsc): Do this even for these architectures.
a.Width = int64(Widthptr) a.Width = int64(Widthptr)
} }
if a.Type != obj.TYPE_MEM { if a.Type != obj.TYPE_MEM {
......
...@@ -287,7 +287,7 @@ func allocauto(ptxt *obj.Prog) { ...@@ -287,7 +287,7 @@ func allocauto(ptxt *obj.Prog) {
if haspointers(n.Type) { if haspointers(n.Type) {
stkptrsize = Stksize stkptrsize = Stksize
} }
if Thearch.LinkArch.InFamily(sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64) { if Thearch.LinkArch.InFamily(sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) {
Stksize = Rnd(Stksize, int64(Widthptr)) Stksize = Rnd(Stksize, int64(Widthptr))
} }
if Stksize >= 1<<31 { if Stksize >= 1<<31 {
......
...@@ -1115,7 +1115,7 @@ func regopt(firstp *obj.Prog) { ...@@ -1115,7 +1115,7 @@ func regopt(firstp *obj.Prog) {
// Currently we never generate three register forms. // Currently we never generate three register forms.
// If we do, this will need to change. // If we do, this will need to change.
if p.From3Type() != obj.TYPE_NONE { if p.From3Type() != obj.TYPE_NONE && p.From3Type() != obj.TYPE_CONST {
Fatalf("regopt not implemented for from3") Fatalf("regopt not implemented for from3")
} }
......
...@@ -673,7 +673,7 @@ opswitch: ...@@ -673,7 +673,7 @@ opswitch:
walkexprlist(n.List.Slice(), init) walkexprlist(n.List.Slice(), init)
if n.Left.Op == ONAME && n.Left.Sym.Name == "Sqrt" && n.Left.Sym.Pkg.Path == "math" { if n.Left.Op == ONAME && n.Left.Sym.Name == "Sqrt" && n.Left.Sym.Pkg.Path == "math" {
if Thearch.LinkArch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.PPC64) { if Thearch.LinkArch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) {
n.Op = OSQRT n.Op = OSQRT
n.Left = n.List.First() n.Left = n.List.First()
n.List.Set(nil) n.List.Set(nil)
...@@ -3294,6 +3294,11 @@ func walkrotate(n *Node) *Node { ...@@ -3294,6 +3294,11 @@ func walkrotate(n *Node) *Node {
// Constants adding to width? // Constants adding to width?
w := int(l.Type.Width * 8) w := int(l.Type.Width * 8)
if Thearch.LinkArch.Family == sys.S390X && w != 32 && w != 64 {
// only supports 32-bit and 64-bit rotates
return n
}
if Smallintconst(l.Right) && Smallintconst(r.Right) { if Smallintconst(l.Right) && Smallintconst(r.Right) {
sl := int(l.Right.Int64()) sl := int(l.Right.Int64())
if sl >= 0 { if sl >= 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment