Skip to content

Commit 247fc4a

Browse files
Vladimir Stefanovicbradfitz
Vladimir Stefanovic
authored andcommitted
cmd/compile/internal/ssa: add support for GOARCH=mips{,le}
Change-Id: I632d4aef7295778ba5018d98bcb06a68bcf07ce1 Reviewed-on: https://go-review.googlesource.com/31478 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent f72a629 commit 247fc4a

File tree

10 files changed

+12892
-195
lines changed

10 files changed

+12892
-195
lines changed

Diff for: src/cmd/compile/internal/ssa/config.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Config struct {
3636
use387 bool // GO386=387
3737
OldArch bool // True for older versions of architecture, e.g. true for PPC64BE, false for PPC64LE
3838
NeedsFpScratch bool // No direct move between GP and FP register sets
39+
BigEndian bool //
3940
DebugTest bool // default true unless $GOSSAHASH != ""; as a debugging aid, make new code conditional on this and use GOSSAHASH to binary search for failing cases
4041
sparsePhiCutoff uint64 // Sparse phi location algorithm used above this #blocks*#variables score
4142
curFunc *Func
@@ -204,6 +205,7 @@ func NewConfig(arch string, fe Frontend, ctxt *obj.Link, optimize bool) *Config
204205
c.noDuffDevice = obj.GOOS == "darwin" // darwin linker cannot handle BR26 reloc with non-zero addend
205206
case "ppc64":
206207
c.OldArch = true
208+
c.BigEndian = true
207209
fallthrough
208210
case "ppc64le":
209211
c.IntSize = 8
@@ -219,7 +221,10 @@ func NewConfig(arch string, fe Frontend, ctxt *obj.Link, optimize bool) *Config
219221
c.noDuffDevice = true // TODO: Resolve PPC64 DuffDevice (has zero, but not copy)
220222
c.NeedsFpScratch = true
221223
c.hasGReg = true
222-
case "mips64", "mips64le":
224+
case "mips64":
225+
c.BigEndian = true
226+
fallthrough
227+
case "mips64le":
223228
c.IntSize = 8
224229
c.PtrSize = 8
225230
c.RegSize = 8
@@ -245,6 +250,24 @@ func NewConfig(arch string, fe Frontend, ctxt *obj.Link, optimize bool) *Config
245250
c.LinkReg = linkRegS390X
246251
c.hasGReg = true
247252
c.noDuffDevice = true
253+
c.BigEndian = true
254+
case "mips":
255+
c.BigEndian = true
256+
fallthrough
257+
case "mipsle":
258+
c.IntSize = 4
259+
c.PtrSize = 4
260+
c.RegSize = 4
261+
c.lowerBlock = rewriteBlockMIPS
262+
c.lowerValue = rewriteValueMIPS
263+
c.registers = registersMIPS[:]
264+
c.gpRegMask = gpRegMaskMIPS
265+
c.fpRegMask = fpRegMaskMIPS
266+
c.specialRegMask = specialRegMaskMIPS
267+
c.FPReg = framepointerRegMIPS
268+
c.LinkReg = linkRegMIPS
269+
c.hasGReg = true
270+
c.noDuffDevice = true
248271
default:
249272
fe.Fatalf(0, "arch %s not implemented", arch)
250273
}

Diff for: src/cmd/compile/internal/ssa/gen/MIPS.rules

+739
Large diffs are not rendered by default.

Diff for: src/cmd/compile/internal/ssa/gen/MIPSOps.go

+413
Large diffs are not rendered by default.

Diff for: src/cmd/compile/internal/ssa/gen/dec64.rules

+32-6
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,57 @@
99
(Int64Hi (Int64Make hi _)) -> hi
1010
(Int64Lo (Int64Make _ lo)) -> lo
1111

12-
// Assuming little endian (we don't support big endian 32-bit architecture yet)
13-
(Load <t> ptr mem) && is64BitInt(t) && t.IsSigned() ->
12+
13+
(Load <t> ptr mem) && is64BitInt(t) && !config.BigEndian && t.IsSigned() ->
1414
(Int64Make
1515
(Load <config.fe.TypeInt32()> (OffPtr <config.fe.TypeInt32().PtrTo()> [4] ptr) mem)
1616
(Load <config.fe.TypeUInt32()> ptr mem))
17-
(Load <t> ptr mem) && is64BitInt(t) && !t.IsSigned() ->
17+
18+
(Load <t> ptr mem) && is64BitInt(t) && !config.BigEndian && !t.IsSigned() ->
1819
(Int64Make
1920
(Load <config.fe.TypeUInt32()> (OffPtr <config.fe.TypeUInt32().PtrTo()> [4] ptr) mem)
2021
(Load <config.fe.TypeUInt32()> ptr mem))
2122

22-
(Store [8] dst (Int64Make hi lo) mem) ->
23+
(Load <t> ptr mem) && is64BitInt(t) && config.BigEndian && t.IsSigned() ->
24+
(Int64Make
25+
(Load <config.fe.TypeInt32()> ptr mem)
26+
(Load <config.fe.TypeUInt32()> (OffPtr <config.fe.TypeUInt32().PtrTo()> [4] ptr) mem))
27+
28+
(Load <t> ptr mem) && is64BitInt(t) && config.BigEndian && !t.IsSigned() ->
29+
(Int64Make
30+
(Load <config.fe.TypeUInt32()> ptr mem)
31+
(Load <config.fe.TypeUInt32()> (OffPtr <config.fe.TypeUInt32().PtrTo()> [4] ptr) mem))
32+
33+
(Store [8] dst (Int64Make hi lo) mem) && !config.BigEndian ->
2334
(Store [4]
2435
(OffPtr <hi.Type.PtrTo()> [4] dst)
2536
hi
2637
(Store [4] dst lo mem))
2738

28-
(Arg {n} [off]) && is64BitInt(v.Type) && v.Type.IsSigned() ->
39+
(Store [8] dst (Int64Make hi lo) mem) && config.BigEndian ->
40+
(Store [4]
41+
(OffPtr <lo.Type.PtrTo()> [4] dst)
42+
lo
43+
(Store [4] dst hi mem))
44+
45+
(Arg {n} [off]) && is64BitInt(v.Type) && !config.BigEndian && v.Type.IsSigned() ->
2946
(Int64Make
3047
(Arg <config.fe.TypeInt32()> {n} [off+4])
3148
(Arg <config.fe.TypeUInt32()> {n} [off]))
32-
(Arg {n} [off]) && is64BitInt(v.Type) && !v.Type.IsSigned() ->
49+
(Arg {n} [off]) && is64BitInt(v.Type) && !config.BigEndian && !v.Type.IsSigned() ->
3350
(Int64Make
3451
(Arg <config.fe.TypeUInt32()> {n} [off+4])
3552
(Arg <config.fe.TypeUInt32()> {n} [off]))
3653

54+
(Arg {n} [off]) && is64BitInt(v.Type) && config.BigEndian && v.Type.IsSigned() ->
55+
(Int64Make
56+
(Arg <config.fe.TypeInt32()> {n} [off])
57+
(Arg <config.fe.TypeUInt32()> {n} [off+4]))
58+
(Arg {n} [off]) && is64BitInt(v.Type) && config.BigEndian && !v.Type.IsSigned() ->
59+
(Int64Make
60+
(Arg <config.fe.TypeUInt32()> {n} [off])
61+
(Arg <config.fe.TypeUInt32()> {n} [off+4]))
62+
3763
(Add64 x y) ->
3864
(Int64Make
3965
(Add32withcarry <config.fe.TypeInt32()>

Diff for: src/cmd/compile/internal/ssa/gen/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ func genOp() {
195195
}
196196
if v.faultOnNilArg0 {
197197
fmt.Fprintln(w, "faultOnNilArg0: true,")
198-
if v.aux != "SymOff" && v.aux != "SymValAndOff" && v.aux != "Int64" && v.aux != "" {
198+
if v.aux != "SymOff" && v.aux != "SymValAndOff" && v.aux != "Int64" && v.aux != "Int32" && v.aux != "" {
199199
log.Fatalf("faultOnNilArg0 with aux %s not allowed", v.aux)
200200
}
201201
}
202202
if v.faultOnNilArg1 {
203203
fmt.Fprintln(w, "faultOnNilArg1: true,")
204-
if v.aux != "SymOff" && v.aux != "SymValAndOff" && v.aux != "Int64" && v.aux != "" {
204+
if v.aux != "SymOff" && v.aux != "SymValAndOff" && v.aux != "Int64" && v.aux != "Int32" && v.aux != "" {
205205
log.Fatalf("faultOnNilArg1 with aux %s not allowed", v.aux)
206206
}
207207
}

Diff for: src/cmd/compile/internal/ssa/nilcheck.go

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ func nilcheckelim2(f *Func) {
184184
if v.Aux != nil || off < 0 || off >= minZeroPage {
185185
continue
186186
}
187+
case auxInt32:
188+
// Mips uses this auxType for atomic add constant. It does not affect the effective address.
187189
case auxInt64:
188190
// ARM uses this auxType for duffcopy/duffzero/alignment info.
189191
// It does not affect the effective address.

0 commit comments

Comments
 (0)