diff options
| author | Cherry Zhang <cherryyz@google.com> | 2016-05-25 09:49:28 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2016-06-05 03:56:42 +0000 |
| commit | e78d90beebbb6fde602ceb3999535ac4b49da295 (patch) | |
| tree | adcaf1ade6c8374cc8462764aa22ba3e78636237 /src/cmd/compile/internal/gc/testdata/string_ssa.go | |
| parent | 4636d02244e683a0d9c078a49b4c614bed401d6b (diff) | |
| download | go-e78d90beebbb6fde602ceb3999535ac4b49da295.tar.xz | |
[dev.ssa] cmd/compile: handle Div, Convert, GetClosurePtr etc. on ARM
This CL adds support of Div, Mod, Convert, GetClosurePtr and 64-bit indexing
support to SSA backend for ARM.
Add tests for 64-bit indexing to cmd/compile/internal/gc/testdata/string_ssa.go.
Tests cmd/compile/internal/gc/testdata/*_ssa.go passed, except compound_ssa.go
and fp_ssa.go.
Progress on SSA for ARM. Still not complete. Essentially the only unsupported
part is floating point.
Updates #15365.
Change-Id: I269e88b67f641c25e7a813d910c96d356d236bff
Reviewed-on: https://go-review.googlesource.com/23542
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/testdata/string_ssa.go')
| -rw-r--r-- | src/cmd/compile/internal/gc/testdata/string_ssa.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/testdata/string_ssa.go b/src/cmd/compile/internal/gc/testdata/string_ssa.go index b47c2f1d07..897e874ee5 100644 --- a/src/cmd/compile/internal/gc/testdata/string_ssa.go +++ b/src/cmd/compile/internal/gc/testdata/string_ssa.go @@ -111,6 +111,67 @@ func testSmallIndexType() { } //go:noinline +func testInt64Index_ssa(s string, i int64) byte { + return s[i] +} + +//go:noinline +func testInt64Slice_ssa(s string, i, j int64) string { + return s[i:j] +} + +func testInt64Index() { + tests := []struct { + i int64 + j int64 + b byte + s string + }{ + {0, 5, 'B', "Below"}, + {5, 10, 'E', "Exact"}, + {10, 15, 'A', "Above"}, + } + + str := "BelowExactAbove" + for i, t := range tests { + if got := testInt64Index_ssa(str, t.i); got != t.b { + println("#", i, "got ", got, ", wanted", t.b) + failed = true + } + if got := testInt64Slice_ssa(str, t.i, t.j); got != t.s { + println("#", i, "got ", got, ", wanted", t.s) + failed = true + } + } +} + +func testInt64IndexPanic() { + defer func() { + if r := recover(); r != nil { + println("paniced as expected") + } + }() + + str := "foobar" + println("got ", testInt64Index_ssa(str, 1<<32+1)) + println("expected to panic, but didn't") + failed = true +} + +func testInt64SlicePanic() { + defer func() { + if r := recover(); r != nil { + println("paniced as expected") + } + }() + + str := "foobar" + println("got ", testInt64Slice_ssa(str, 1<<32, 1<<32+1)) + println("expected to panic, but didn't") + failed = true +} + +//go:noinline func testStringElem_ssa(s string, i int) byte { return s[i] } @@ -153,6 +214,9 @@ func main() { testSmallIndexType() testStringElem() testStringElemConst() + testInt64Index() + testInt64IndexPanic() + testInt64SlicePanic() if failed { panic("failed") |
