3 // Copyright 2019 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // These tests check code generation of switch statements.
12 func f(x string) int {
24 // use jump tables for 8+ int cases
25 func square(x int) int {
26 // amd64:`JMP\s\(.*\)\(.*\)$`
27 // arm64:`MOVD\s\(R.*\)\(R.*<<3\)`,`JMP\s\(R.*\)$`
50 // use jump tables for 8+ string lengths
51 func length(x string) int {
52 // amd64:`JMP\s\(.*\)\(.*\)$`
53 // arm64:`MOVD\s\(R.*\)\(R.*<<3\)`,`JMP\s\(R.*\)$`
76 // Use single-byte ordered comparisons for binary searching strings.
78 func mimetype(ext string) string {
79 // amd64: `CMPB\s1\(.*\), \$104$`,-`cmpstring`
80 // arm64: `MOVB\s1\(R.*\), R.*$`, `CMPW\s\$104, R.*$`, -`cmpstring`
82 // amd64: `CMPL\s\(.*\), \$1836345390$`
83 // arm64: `MOVD\s\$1836345390`, `CMPW\sR.*, R.*$`
86 // amd64: `CMPL\s\(.*\), \$1953457454$`
87 // arm64: `MOVD\s\$1953457454`, `CMPW\sR.*, R.*$`
90 // amd64: `CMPL\s\(.*\), \$1735815982$`
91 // arm64: `MOVD\s\$1735815982`, `CMPW\sR.*, R.*$`
94 // amd64: `CMPL\s\(.*\), \$1718907950$`
95 // arm64: `MOVD\s\$1718907950`, `CMPW\sR.*, R.*$`
103 // use jump tables for type switches to concrete types.
104 func typeSwitch(x any) int {
105 // amd64:`JMP\s\(.*\)\(.*\)$`
106 // arm64:`MOVD\s\(R.*\)\(R.*<<3\)`,`JMP\s\(R.*\)$`
136 // use a runtime call for type switches to interface types.
137 func interfaceSwitch(x any) int {
138 // amd64:`CALL\truntime.interfaceSwitch`,`MOVL\t16\(AX\)`,`MOVQ\t8\(.*\)(.*\*8)`
139 // arm64:`CALL\truntime.interfaceSwitch`,`LDAR`,`MOVWU\t16\(R0\)`,`MOVD\t\(R.*\)\(R.*\)`
150 func interfaceSwitch2(x K) int {
151 // amd64:`CALL\truntime.interfaceSwitch`,`MOVL\t16\(AX\)`,`MOVQ\t8\(.*\)(.*\*8)`
152 // arm64:`CALL\truntime.interfaceSwitch`,`LDAR`,`MOVWU\t16\(R0\)`,`MOVD\t\(R.*\)\(R.*\)`
163 func interfaceCast(x any) int {
164 // amd64:`CALL\truntime.typeAssert`,`MOVL\t16\(AX\)`,`MOVQ\t8\(.*\)(.*\*1)`
165 // arm64:`CALL\truntime.typeAssert`,`LDAR`,`MOVWU\t16\(R0\)`,`MOVD\t\(R.*\)\(R.*\)`
166 if _, ok := x.(I); ok {
172 func interfaceCast2(x K) int {
173 // amd64:`CALL\truntime.typeAssert`,`MOVL\t16\(AX\)`,`MOVQ\t8\(.*\)(.*\*1)`
174 // arm64:`CALL\truntime.typeAssert`,`LDAR`,`MOVWU\t16\(R0\)`,`MOVD\t\(R.*\)\(R.*\)`
175 if _, ok := x.(I); ok {
181 func interfaceConv(x IJ) I {
182 // amd64:`CALL\truntime.typeAssert`,`MOVL\t16\(AX\)`,`MOVQ\t8\(.*\)(.*\*1)`
183 // arm64:`CALL\truntime.typeAssert`,`LDAR`,`MOVWU\t16\(R0\)`,`MOVD\t\(R.*\)\(R.*\)`