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.*\)$`
129 // use a runtime call for type switches to interface types.
130 func interfaceSwitch(x any) int {
131 // amd64:`CALL\truntime.interfaceSwitch`,`MOVL\t16\(.*\)`,`MOVQ\t8\(.*\)(.*\*8)`
132 // arm64:`CALL\truntime.interfaceSwitch`,`LDAR`,`MOVWU`,`MOVD\t\(R.*\)\(R.*\)`
143 func interfaceCast(x any) int {
144 // amd64:`CALL\truntime.typeAssert`,`MOVL\t16\(.*\)`,`MOVQ\t8\(.*\)(.*\*1)`
145 // arm64:`CALL\truntime.typeAssert`,`LDAR`,`MOVWU`,`MOVD\t\(R.*\)\(R.*\)`
146 if _, ok := x.(I); ok {