Black Lives Matter. Support the Equal Justice Initiative.

Source file src/cmd/asm/internal/asm/operand_test.go

Documentation: cmd/asm/internal/asm

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package asm
     6  
     7  import (
     8  	"internal/buildcfg"
     9  	"strings"
    10  	"testing"
    11  
    12  	"cmd/asm/internal/arch"
    13  	"cmd/asm/internal/lex"
    14  	"cmd/internal/obj"
    15  )
    16  
    17  // A simple in-out test: Do we print what we parse?
    18  
    19  func setArch(goarch string) (*arch.Arch, *obj.Link) {
    20  	buildcfg.GOOS = "linux" // obj can handle this OS for all architectures.
    21  	buildcfg.GOARCH = goarch
    22  	architecture := arch.Set(goarch)
    23  	if architecture == nil {
    24  		panic("asm: unrecognized architecture " + goarch)
    25  	}
    26  	return architecture, obj.Linknew(architecture.LinkArch)
    27  }
    28  
    29  func newParser(goarch string) *Parser {
    30  	architecture, ctxt := setArch(goarch)
    31  	return NewParser(ctxt, architecture, nil, false)
    32  }
    33  
    34  // tryParse executes parse func in panicOnError=true context.
    35  // parse is expected to call any parsing methods that may panic.
    36  // Returns error gathered from recover; nil if no parse errors occurred.
    37  //
    38  // For unexpected panics, calls t.Fatal.
    39  func tryParse(t *testing.T, parse func()) (err error) {
    40  	panicOnError = true
    41  	defer func() {
    42  		panicOnError = false
    43  
    44  		e := recover()
    45  		var ok bool
    46  		if err, ok = e.(error); e != nil && !ok {
    47  			t.Fatal(e)
    48  		}
    49  	}()
    50  
    51  	parse()
    52  
    53  	return nil
    54  }
    55  
    56  func testBadOperandParser(t *testing.T, parser *Parser, tests []badOperandTest) {
    57  	for _, test := range tests {
    58  		err := tryParse(t, func() {
    59  			parser.start(lex.Tokenize(test.input))
    60  			addr := obj.Addr{}
    61  			parser.operand(&addr)
    62  		})
    63  
    64  		switch {
    65  		case err == nil:
    66  			t.Errorf("fail at %s: got no errors; expected %s\n", test.input, test.error)
    67  		case !strings.Contains(err.Error(), test.error):
    68  			t.Errorf("fail at %s: got %s; expected %s", test.input, err, test.error)
    69  		}
    70  	}
    71  }
    72  
    73  func testOperandParser(t *testing.T, parser *Parser, tests []operandTest) {
    74  	for _, test := range tests {
    75  		parser.start(lex.Tokenize(test.input))
    76  		addr := obj.Addr{}
    77  		parser.operand(&addr)
    78  		var result string
    79  		if parser.compilingRuntime {
    80  			result = obj.DconvWithABIDetail(&emptyProg, &addr)
    81  		} else {
    82  			result = obj.Dconv(&emptyProg, &addr)
    83  		}
    84  		if result != test.output {
    85  			t.Errorf("fail at %s: got %s; expected %s\n", test.input, result, test.output)
    86  		}
    87  	}
    88  }
    89  
    90  func TestAMD64OperandParser(t *testing.T) {
    91  	parser := newParser("amd64")
    92  	testOperandParser(t, parser, amd64OperandTests)
    93  	testBadOperandParser(t, parser, amd64BadOperandTests)
    94  	parser.compilingRuntime = true
    95  	testOperandParser(t, parser, amd64RuntimeOperandTests)
    96  	testBadOperandParser(t, parser, amd64BadOperandRuntimeTests)
    97  }
    98  
    99  func Test386OperandParser(t *testing.T) {
   100  	parser := newParser("386")
   101  	testOperandParser(t, parser, x86OperandTests)
   102  }
   103  
   104  func TestARMOperandParser(t *testing.T) {
   105  	parser := newParser("arm")
   106  	testOperandParser(t, parser, armOperandTests)
   107  }
   108  func TestARM64OperandParser(t *testing.T) {
   109  	parser := newParser("arm64")
   110  	testOperandParser(t, parser, arm64OperandTests)
   111  }
   112  
   113  func TestPPC64OperandParser(t *testing.T) {
   114  	parser := newParser("ppc64")
   115  	testOperandParser(t, parser, ppc64OperandTests)
   116  }
   117  
   118  func TestMIPSOperandParser(t *testing.T) {
   119  	parser := newParser("mips")
   120  	testOperandParser(t, parser, mipsOperandTests)
   121  }
   122  
   123  func TestMIPS64OperandParser(t *testing.T) {
   124  	parser := newParser("mips64")
   125  	testOperandParser(t, parser, mips64OperandTests)
   126  }
   127  
   128  func TestS390XOperandParser(t *testing.T) {
   129  	parser := newParser("s390x")
   130  	testOperandParser(t, parser, s390xOperandTests)
   131  }
   132  
   133  func TestFuncAddress(t *testing.T) {
   134  	type subtest struct {
   135  		arch  string
   136  		tests []operandTest
   137  	}
   138  	for _, sub := range []subtest{
   139  		{"amd64", amd64OperandTests},
   140  		{"386", x86OperandTests},
   141  		{"arm", armOperandTests},
   142  		{"arm64", arm64OperandTests},
   143  		{"ppc64", ppc64OperandTests},
   144  		{"mips", mipsOperandTests},
   145  		{"mips64", mips64OperandTests},
   146  		{"s390x", s390xOperandTests},
   147  	} {
   148  		t.Run(sub.arch, func(t *testing.T) {
   149  			parser := newParser(sub.arch)
   150  			for _, test := range sub.tests {
   151  				parser.start(lex.Tokenize(test.input))
   152  				name, _, ok := parser.funcAddress()
   153  
   154  				isFuncSym := strings.HasSuffix(test.input, "(SB)") &&
   155  					// Ignore static symbols.
   156  					!strings.Contains(test.input, "<>")
   157  
   158  				wantName := ""
   159  				if isFuncSym {
   160  					// Strip $|* and (SB) and +Int.
   161  					wantName = test.output[:len(test.output)-4]
   162  					if strings.HasPrefix(wantName, "$") || strings.HasPrefix(wantName, "*") {
   163  						wantName = wantName[1:]
   164  					}
   165  					if i := strings.Index(wantName, "+"); i >= 0 {
   166  						wantName = wantName[:i]
   167  					}
   168  				}
   169  				if ok != isFuncSym || name != wantName {
   170  					t.Errorf("fail at %s as function address: got %s, %v; expected %s, %v", test.input, name, ok, wantName, isFuncSym)
   171  				}
   172  			}
   173  		})
   174  	}
   175  }
   176  
   177  type operandTest struct {
   178  	input, output string
   179  }
   180  
   181  type badOperandTest struct {
   182  	input, error string
   183  }
   184  
   185  // Examples collected by scanning all the assembly in the standard repo.
   186  
   187  var amd64OperandTests = []operandTest{
   188  	{"$(-1.0)", "$(-1.0)"},
   189  	{"$(0.0)", "$(0.0)"},
   190  	{"$(0x2000000+116)", "$33554548"},
   191  	{"$(0x3F<<7)", "$8064"},
   192  	{"$(112+8)", "$120"},
   193  	{"$(1<<63)", "$-9223372036854775808"},
   194  	{"$-1", "$-1"},
   195  	{"$0", "$0"},
   196  	{"$0-0", "$0"},
   197  	{"$0-16", "$-16"},
   198  	{"$0x000FFFFFFFFFFFFF", "$4503599627370495"},
   199  	{"$0x01", "$1"},
   200  	{"$0x02", "$2"},
   201  	{"$0x04", "$4"},
   202  	{"$0x3FE", "$1022"},
   203  	{"$0x7fffffe00000", "$140737486258176"},
   204  	{"$0xfffffffffffff001", "$-4095"},
   205  	{"$1", "$1"},
   206  	{"$1.0", "$(1.0)"},
   207  	{"$10", "$10"},
   208  	{"$1000", "$1000"},
   209  	{"$1000000", "$1000000"},
   210  	{"$1000000000", "$1000000000"},
   211  	{"$__tsan_func_enter(SB)", "$__tsan_func_enter(SB)"},
   212  	{"$main(SB)", "$main(SB)"},
   213  	{"$masks<>(SB)", "$masks<>(SB)"},
   214  	{"$setg_gcc<>(SB)", "$setg_gcc<>(SB)"},
   215  	{"$shifts<>(SB)", "$shifts<>(SB)"},
   216  	{"$~(1<<63)", "$9223372036854775807"},
   217  	{"$~0x3F", "$-64"},
   218  	{"$~15", "$-16"},
   219  	{"(((8)&0xf)*4)(SP)", "32(SP)"},
   220  	{"(((8-14)&0xf)*4)(SP)", "40(SP)"},
   221  	{"(6+8)(AX)", "14(AX)"},
   222  	{"(8*4)(BP)", "32(BP)"},
   223  	{"(AX)", "(AX)"},
   224  	{"(AX)(CX*8)", "(AX)(CX*8)"},
   225  	{"(BP)(CX*4)", "(BP)(CX*4)"},
   226  	{"(BP)(DX*4)", "(BP)(DX*4)"},
   227  	{"(BP)(R8*4)", "(BP)(R8*4)"},
   228  	{"(BX)", "(BX)"},
   229  	{"(DI)", "(DI)"},
   230  	{"(DI)(BX*1)", "(DI)(BX*1)"},
   231  	{"(DX)", "(DX)"},
   232  	{"(R9)", "(R9)"},
   233  	{"(R9)(BX*8)", "(R9)(BX*8)"},
   234  	{"(SI)", "(SI)"},
   235  	{"(SI)(BX*1)", "(SI)(BX*1)"},
   236  	{"(SI)(DX*1)", "(SI)(DX*1)"},
   237  	{"(SP)", "(SP)"},
   238  	{"(SP)(AX*4)", "(SP)(AX*4)"},
   239  	{"32(SP)(BX*2)", "32(SP)(BX*2)"},
   240  	{"32323(SP)(R8*4)", "32323(SP)(R8*4)"},
   241  	{"+3(PC)", "3(PC)"},
   242  	{"-1(DI)(BX*1)", "-1(DI)(BX*1)"},
   243  	{"-3(PC)", "-3(PC)"},
   244  	{"-64(SI)(BX*1)", "-64(SI)(BX*1)"},
   245  	{"-96(SI)(BX*1)", "-96(SI)(BX*1)"},
   246  	{"AL", "AL"},
   247  	{"AX", "AX"},
   248  	{"BP", "BP"},
   249  	{"BX", "BX"},
   250  	{"CX", "CX"},
   251  	{"DI", "DI"},
   252  	{"DX", "DX"},
   253  	{"R10", "R10"},
   254  	{"R10", "R10"},
   255  	{"R11", "R11"},
   256  	{"R12", "R12"},
   257  	{"R13", "R13"},
   258  	{"R14", "R14"},
   259  	{"R15", "R15"},
   260  	{"R8", "R8"},
   261  	{"R9", "R9"},
   262  	{"g", "R14"},
   263  	{"SI", "SI"},
   264  	{"SP", "SP"},
   265  	{"X0", "X0"},
   266  	{"X1", "X1"},
   267  	{"X10", "X10"},
   268  	{"X11", "X11"},
   269  	{"X12", "X12"},
   270  	{"X13", "X13"},
   271  	{"X14", "X14"},
   272  	{"X15", "X15"},
   273  	{"X2", "X2"},
   274  	{"X3", "X3"},
   275  	{"X4", "X4"},
   276  	{"X5", "X5"},
   277  	{"X6", "X6"},
   278  	{"X7", "X7"},
   279  	{"X8", "X8"},
   280  	{"X9", "X9"},
   281  	{"_expand_key_128<>(SB)", "_expand_key_128<>(SB)"},
   282  	{"_seek<>(SB)", "_seek<>(SB)"},
   283  	{"a2+16(FP)", "a2+16(FP)"},
   284  	{"addr2+24(FP)", "addr2+24(FP)"},
   285  	{"asmcgocall<>(SB)", "asmcgocall<>(SB)"},
   286  	{"b+24(FP)", "b+24(FP)"},
   287  	{"b_len+32(FP)", "b_len+32(FP)"},
   288  	{"racecall<>(SB)", "racecall<>(SB)"},
   289  	{"rcv_name+20(FP)", "rcv_name+20(FP)"},
   290  	{"retoffset+28(FP)", "retoffset+28(FP)"},
   291  	{"runtime·_GetStdHandle(SB)", "runtime._GetStdHandle(SB)"},
   292  	{"sync\u2215atomic·AddInt64(SB)", "sync/atomic.AddInt64(SB)"},
   293  	{"timeout+20(FP)", "timeout+20(FP)"},
   294  	{"ts+16(FP)", "ts+16(FP)"},
   295  	{"x+24(FP)", "x+24(FP)"},
   296  	{"x·y(SB)", "x.y(SB)"},
   297  	{"x·y(SP)", "x.y(SP)"},
   298  	{"x·y+8(SB)", "x.y+8(SB)"},
   299  	{"x·y+8(SP)", "x.y+8(SP)"},
   300  	{"y+56(FP)", "y+56(FP)"},
   301  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   302  	{"·callReflect(SB)", "\"\".callReflect(SB)"},
   303  	{"[X0-X0]", "[X0-X0]"},
   304  	{"[ Z9 - Z12 ]", "[Z9-Z12]"},
   305  	{"[X0-AX]", "[X0-AX]"},
   306  	{"[AX-X0]", "[AX-X0]"},
   307  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   308  }
   309  
   310  var amd64RuntimeOperandTests = []operandTest{
   311  	{"$bar<ABI0>(SB)", "$bar<ABI0>(SB)"},
   312  	{"$foo<ABIInternal>(SB)", "$foo<ABIInternal>(SB)"},
   313  }
   314  
   315  var amd64BadOperandTests = []badOperandTest{
   316  	{"[", "register list: expected ']', found EOF"},
   317  	{"[4", "register list: bad low register in `[4`"},
   318  	{"[]", "register list: bad low register in `[]`"},
   319  	{"[f-x]", "register list: bad low register in `[f`"},
   320  	{"[r10-r13]", "register list: bad low register in `[r10`"},
   321  	{"[k3-k6]", "register list: bad low register in `[k3`"},
   322  	{"[X0]", "register list: expected '-' after `[X0`, found ']'"},
   323  	{"[X0-]", "register list: bad high register in `[X0-]`"},
   324  	{"[X0-x]", "register list: bad high register in `[X0-x`"},
   325  	{"[X0-X1-X2]", "register list: expected ']' after `[X0-X1`, found '-'"},
   326  	{"[X0,X3]", "register list: expected '-' after `[X0`, found ','"},
   327  	{"[X0,X1,X2,X3]", "register list: expected '-' after `[X0`, found ','"},
   328  	{"$foo<ABI0>", "ABI selector only permitted when compiling runtime, reference was to \"foo\""},
   329  }
   330  
   331  var amd64BadOperandRuntimeTests = []badOperandTest{
   332  	{"$foo<bletch>", "malformed ABI selector \"bletch\" in reference to \"foo\""},
   333  }
   334  
   335  var x86OperandTests = []operandTest{
   336  	{"$(2.928932188134524e-01)", "$(0.29289321881345243)"},
   337  	{"$-1", "$-1"},
   338  	{"$0", "$0"},
   339  	{"$0x00000000", "$0"},
   340  	{"$runtime·badmcall(SB)", "$runtime.badmcall(SB)"},
   341  	{"$setg_gcc<>(SB)", "$setg_gcc<>(SB)"},
   342  	{"$~15", "$-16"},
   343  	{"(-64*1024+104)(SP)", "-65432(SP)"},
   344  	{"(0*4)(BP)", "(BP)"},
   345  	{"(1*4)(DI)", "4(DI)"},
   346  	{"(4*4)(BP)", "16(BP)"},
   347  	{"(AX)", "(AX)"},
   348  	{"(BP)(CX*4)", "(BP)(CX*4)"},
   349  	{"(BP*8)", "0(BP*8)"},
   350  	{"(BX)", "(BX)"},
   351  	{"(SP)", "(SP)"},
   352  	{"*AX", "AX"}, // TODO: Should make * illegal here; a simple alias for JMP AX.
   353  	{"*runtime·_GetStdHandle(SB)", "*runtime._GetStdHandle(SB)"},
   354  	{"-(4+12)(DI)", "-16(DI)"},
   355  	{"-1(DI)(BX*1)", "-1(DI)(BX*1)"},
   356  	{"-96(DI)(BX*1)", "-96(DI)(BX*1)"},
   357  	{"0(AX)", "(AX)"},
   358  	{"0(BP)", "(BP)"},
   359  	{"0(BX)", "(BX)"},
   360  	{"4(AX)", "4(AX)"},
   361  	{"AL", "AL"},
   362  	{"AX", "AX"},
   363  	{"BP", "BP"},
   364  	{"BX", "BX"},
   365  	{"CX", "CX"},
   366  	{"DI", "DI"},
   367  	{"DX", "DX"},
   368  	{"F0", "F0"},
   369  	{"GS", "GS"},
   370  	{"SI", "SI"},
   371  	{"SP", "SP"},
   372  	{"X0", "X0"},
   373  	{"X1", "X1"},
   374  	{"X2", "X2"},
   375  	{"X3", "X3"},
   376  	{"X4", "X4"},
   377  	{"X5", "X5"},
   378  	{"X6", "X6"},
   379  	{"X7", "X7"},
   380  	{"asmcgocall<>(SB)", "asmcgocall<>(SB)"},
   381  	{"ax+4(FP)", "ax+4(FP)"},
   382  	{"ptime-12(SP)", "ptime-12(SP)"},
   383  	{"runtime·_NtWaitForSingleObject(SB)", "runtime._NtWaitForSingleObject(SB)"},
   384  	{"s(FP)", "s(FP)"},
   385  	{"sec+4(FP)", "sec+4(FP)"},
   386  	{"shifts<>(SB)(CX*8)", "shifts<>(SB)(CX*8)"},
   387  	{"x+4(FP)", "x+4(FP)"},
   388  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   389  	{"·reflectcall(SB)", "\"\".reflectcall(SB)"},
   390  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   391  }
   392  
   393  var armOperandTests = []operandTest{
   394  	{"$0", "$0"},
   395  	{"$256", "$256"},
   396  	{"(R0)", "(R0)"},
   397  	{"(R11)", "(R11)"},
   398  	{"(g)", "(g)"},
   399  	{"-12(R4)", "-12(R4)"},
   400  	{"0(PC)", "0(PC)"},
   401  	{"1024", "1024"},
   402  	{"12(R(1))", "12(R1)"},
   403  	{"12(R13)", "12(R13)"},
   404  	{"R0", "R0"},
   405  	{"R0->(32-1)", "R0->31"},
   406  	{"R0<<R1", "R0<<R1"},
   407  	{"R0>>R(1)", "R0>>R1"},
   408  	{"R0@>(32-1)", "R0@>31"},
   409  	{"R1", "R1"},
   410  	{"R11", "R11"},
   411  	{"R12", "R12"},
   412  	{"R13", "R13"},
   413  	{"R14", "R14"},
   414  	{"R15", "R15"},
   415  	{"R1<<2(R3)", "R1<<2(R3)"},
   416  	{"R(1)<<2(R(3))", "R1<<2(R3)"},
   417  	{"R2", "R2"},
   418  	{"R3", "R3"},
   419  	{"R4", "R4"},
   420  	{"R(4)", "R4"},
   421  	{"R5", "R5"},
   422  	{"R6", "R6"},
   423  	{"R7", "R7"},
   424  	{"R8", "R8"},
   425  	{"[R0,R1,g,R15]", "[R0,R1,g,R15]"},
   426  	{"[R0-R7]", "[R0,R1,R2,R3,R4,R5,R6,R7]"},
   427  	{"[R(0)-R(7)]", "[R0,R1,R2,R3,R4,R5,R6,R7]"},
   428  	{"[R0]", "[R0]"},
   429  	{"[R1-R12]", "[R1,R2,R3,R4,R5,R6,R7,R8,R9,g,R11,R12]"},
   430  	{"armCAS64(SB)", "armCAS64(SB)"},
   431  	{"asmcgocall<>(SB)", "asmcgocall<>(SB)"},
   432  	{"c+28(FP)", "c+28(FP)"},
   433  	{"g", "g"},
   434  	{"gosave<>(SB)", "gosave<>(SB)"},
   435  	{"retlo+12(FP)", "retlo+12(FP)"},
   436  	{"runtime·gogo(SB)", "runtime.gogo(SB)"},
   437  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   438  	{"(R1, R3)", "(R1, R3)"},
   439  	{"[R0,R1,g,R15", ""}, // Issue 11764 - asm hung parsing ']' missing register lists.
   440  	{"[):[o-FP", ""},     // Issue 12469 - there was no infinite loop for ARM; these are just sanity checks.
   441  	{"[):[R0-FP", ""},
   442  	{"(", ""}, // Issue 12466 - backed up before beginning of line.
   443  }
   444  
   445  var ppc64OperandTests = []operandTest{
   446  	{"$((1<<63)-1)", "$9223372036854775807"},
   447  	{"$(-64*1024)", "$-65536"},
   448  	{"$(1024 * 8)", "$8192"},
   449  	{"$-1", "$-1"},
   450  	{"$-24(R4)", "$-24(R4)"},
   451  	{"$0", "$0"},
   452  	{"$0(R1)", "$(R1)"},
   453  	{"$0.5", "$(0.5)"},
   454  	{"$0x7000", "$28672"},
   455  	{"$0x88888eef", "$2290650863"},
   456  	{"$1", "$1"},
   457  	{"$_main<>(SB)", "$_main<>(SB)"},
   458  	{"$argframe(FP)", "$argframe(FP)"},
   459  	{"$runtime·tlsg(SB)", "$runtime.tlsg(SB)"},
   460  	{"$~3", "$-4"},
   461  	{"(-288-3*8)(R1)", "-312(R1)"},
   462  	{"(16)(R7)", "16(R7)"},
   463  	{"(8)(g)", "8(g)"},
   464  	{"(CTR)", "(CTR)"},
   465  	{"(R0)", "(R0)"},
   466  	{"(R3)", "(R3)"},
   467  	{"(R4)", "(R4)"},
   468  	{"(R5)", "(R5)"},
   469  	{"(R5)(R6*1)", "(R5)(R6*1)"},
   470  	{"(R5+R6)", "(R5)(R6*1)"}, // Old syntax.
   471  	{"-1(R4)", "-1(R4)"},
   472  	{"-1(R5)", "-1(R5)"},
   473  	{"6(PC)", "6(PC)"},
   474  	{"CR7", "CR7"},
   475  	{"CTR", "CTR"},
   476  	{"VS0", "VS0"},
   477  	{"VS1", "VS1"},
   478  	{"VS2", "VS2"},
   479  	{"VS3", "VS3"},
   480  	{"VS4", "VS4"},
   481  	{"VS5", "VS5"},
   482  	{"VS6", "VS6"},
   483  	{"VS7", "VS7"},
   484  	{"VS8", "VS8"},
   485  	{"VS9", "VS9"},
   486  	{"VS10", "VS10"},
   487  	{"VS11", "VS11"},
   488  	{"VS12", "VS12"},
   489  	{"VS13", "VS13"},
   490  	{"VS14", "VS14"},
   491  	{"VS15", "VS15"},
   492  	{"VS16", "VS16"},
   493  	{"VS17", "VS17"},
   494  	{"VS18", "VS18"},
   495  	{"VS19", "VS19"},
   496  	{"VS20", "VS20"},
   497  	{"VS21", "VS21"},
   498  	{"VS22", "VS22"},
   499  	{"VS23", "VS23"},
   500  	{"VS24", "VS24"},
   501  	{"VS25", "VS25"},
   502  	{"VS26", "VS26"},
   503  	{"VS27", "VS27"},
   504  	{"VS28", "VS28"},
   505  	{"VS29", "VS29"},
   506  	{"VS30", "VS30"},
   507  	{"VS31", "VS31"},
   508  	{"VS32", "VS32"},
   509  	{"VS33", "VS33"},
   510  	{"VS34", "VS34"},
   511  	{"VS35", "VS35"},
   512  	{"VS36", "VS36"},
   513  	{"VS37", "VS37"},
   514  	{"VS38", "VS38"},
   515  	{"VS39", "VS39"},
   516  	{"VS40", "VS40"},
   517  	{"VS41", "VS41"},
   518  	{"VS42", "VS42"},
   519  	{"VS43", "VS43"},
   520  	{"VS44", "VS44"},
   521  	{"VS45", "VS45"},
   522  	{"VS46", "VS46"},
   523  	{"VS47", "VS47"},
   524  	{"VS48", "VS48"},
   525  	{"VS49", "VS49"},
   526  	{"VS50", "VS50"},
   527  	{"VS51", "VS51"},
   528  	{"VS52", "VS52"},
   529  	{"VS53", "VS53"},
   530  	{"VS54", "VS54"},
   531  	{"VS55", "VS55"},
   532  	{"VS56", "VS56"},
   533  	{"VS57", "VS57"},
   534  	{"VS58", "VS58"},
   535  	{"VS59", "VS59"},
   536  	{"VS60", "VS60"},
   537  	{"VS61", "VS61"},
   538  	{"VS62", "VS62"},
   539  	{"VS63", "VS63"},
   540  	{"V0", "V0"},
   541  	{"V1", "V1"},
   542  	{"V2", "V2"},
   543  	{"V3", "V3"},
   544  	{"V4", "V4"},
   545  	{"V5", "V5"},
   546  	{"V6", "V6"},
   547  	{"V7", "V7"},
   548  	{"V8", "V8"},
   549  	{"V9", "V9"},
   550  	{"V10", "V10"},
   551  	{"V11", "V11"},
   552  	{"V12", "V12"},
   553  	{"V13", "V13"},
   554  	{"V14", "V14"},
   555  	{"V15", "V15"},
   556  	{"V16", "V16"},
   557  	{"V17", "V17"},
   558  	{"V18", "V18"},
   559  	{"V19", "V19"},
   560  	{"V20", "V20"},
   561  	{"V21", "V21"},
   562  	{"V22", "V22"},
   563  	{"V23", "V23"},
   564  	{"V24", "V24"},
   565  	{"V25", "V25"},
   566  	{"V26", "V26"},
   567  	{"V27", "V27"},
   568  	{"V28", "V28"},
   569  	{"V29", "V29"},
   570  	{"V30", "V30"},
   571  	{"V31", "V31"},
   572  	{"F14", "F14"},
   573  	{"F15", "F15"},
   574  	{"F16", "F16"},
   575  	{"F17", "F17"},
   576  	{"F18", "F18"},
   577  	{"F19", "F19"},
   578  	{"F20", "F20"},
   579  	{"F21", "F21"},
   580  	{"F22", "F22"},
   581  	{"F23", "F23"},
   582  	{"F24", "F24"},
   583  	{"F25", "F25"},
   584  	{"F26", "F26"},
   585  	{"F27", "F27"},
   586  	{"F28", "F28"},
   587  	{"F29", "F29"},
   588  	{"F30", "F30"},
   589  	{"F31", "F31"},
   590  	{"LR", "LR"},
   591  	{"R0", "R0"},
   592  	{"R1", "R1"},
   593  	{"R11", "R11"},
   594  	{"R12", "R12"},
   595  	{"R13", "R13"},
   596  	{"R14", "R14"},
   597  	{"R15", "R15"},
   598  	{"R16", "R16"},
   599  	{"R17", "R17"},
   600  	{"R18", "R18"},
   601  	{"R19", "R19"},
   602  	{"R2", "R2"},
   603  	{"R20", "R20"},
   604  	{"R21", "R21"},
   605  	{"R22", "R22"},
   606  	{"R23", "R23"},
   607  	{"R24", "R24"},
   608  	{"R25", "R25"},
   609  	{"R26", "R26"},
   610  	{"R27", "R27"},
   611  	{"R28", "R28"},
   612  	{"R29", "R29"},
   613  	{"R3", "R3"},
   614  	{"R31", "R31"},
   615  	{"R4", "R4"},
   616  	{"R5", "R5"},
   617  	{"R6", "R6"},
   618  	{"R7", "R7"},
   619  	{"R8", "R8"},
   620  	{"R9", "R9"},
   621  	{"SPR(269)", "SPR(269)"},
   622  	{"a(FP)", "a(FP)"},
   623  	{"g", "g"},
   624  	{"ret+8(FP)", "ret+8(FP)"},
   625  	{"runtime·abort(SB)", "runtime.abort(SB)"},
   626  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   627  	{"·trunc(SB)", "\"\".trunc(SB)"},
   628  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   629  }
   630  
   631  var arm64OperandTests = []operandTest{
   632  	{"$0", "$0"},
   633  	{"$0.5", "$(0.5)"},
   634  	{"0(R26)", "(R26)"},
   635  	{"0(RSP)", "(RSP)"},
   636  	{"$1", "$1"},
   637  	{"$-1", "$-1"},
   638  	{"$1000", "$1000"},
   639  	{"$1000000000", "$1000000000"},
   640  	{"$0x7fff3c000", "$34358935552"},
   641  	{"$1234", "$1234"},
   642  	{"$~15", "$-16"},
   643  	{"$16", "$16"},
   644  	{"-16(RSP)", "-16(RSP)"},
   645  	{"16(RSP)", "16(RSP)"},
   646  	{"1(R1)", "1(R1)"},
   647  	{"-1(R4)", "-1(R4)"},
   648  	{"18740(R5)", "18740(R5)"},
   649  	{"$2", "$2"},
   650  	{"$-24(R4)", "$-24(R4)"},
   651  	{"-24(RSP)", "-24(RSP)"},
   652  	{"$24(RSP)", "$24(RSP)"},
   653  	{"-32(RSP)", "-32(RSP)"},
   654  	{"$48", "$48"},
   655  	{"$(-64*1024)(R7)", "$-65536(R7)"},
   656  	{"$(8-1)", "$7"},
   657  	{"a+0(FP)", "a(FP)"},
   658  	{"a1+8(FP)", "a1+8(FP)"},
   659  	{"·AddInt32(SB)", `"".AddInt32(SB)`},
   660  	{"runtime·divWVW(SB)", "runtime.divWVW(SB)"},
   661  	{"$argframe+0(FP)", "$argframe(FP)"},
   662  	{"$asmcgocall<>(SB)", "$asmcgocall<>(SB)"},
   663  	{"EQ", "EQ"},
   664  	{"F29", "F29"},
   665  	{"F3", "F3"},
   666  	{"F30", "F30"},
   667  	{"g", "g"},
   668  	{"LR", "R30"},
   669  	{"(LR)", "(R30)"},
   670  	{"R0", "R0"},
   671  	{"R10", "R10"},
   672  	{"R11", "R11"},
   673  	{"R18_PLATFORM", "R18"},
   674  	{"$4503601774854144.0", "$(4503601774854144.0)"},
   675  	{"$runtime·badsystemstack(SB)", "$runtime.badsystemstack(SB)"},
   676  	{"ZR", "ZR"},
   677  	{"(ZR)", "(ZR)"},
   678  	{"(R29, RSP)", "(R29, RSP)"},
   679  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   680  }
   681  
   682  var mips64OperandTests = []operandTest{
   683  	{"$((1<<63)-1)", "$9223372036854775807"},
   684  	{"$(-64*1024)", "$-65536"},
   685  	{"$(1024 * 8)", "$8192"},
   686  	{"$-1", "$-1"},
   687  	{"$-24(R4)", "$-24(R4)"},
   688  	{"$0", "$0"},
   689  	{"$0(R1)", "$(R1)"},
   690  	{"$0.5", "$(0.5)"},
   691  	{"$0x7000", "$28672"},
   692  	{"$0x88888eef", "$2290650863"},
   693  	{"$1", "$1"},
   694  	{"$_main<>(SB)", "$_main<>(SB)"},
   695  	{"$argframe(FP)", "$argframe(FP)"},
   696  	{"$~3", "$-4"},
   697  	{"(-288-3*8)(R1)", "-312(R1)"},
   698  	{"(16)(R7)", "16(R7)"},
   699  	{"(8)(g)", "8(g)"},
   700  	{"(R0)", "(R0)"},
   701  	{"(R3)", "(R3)"},
   702  	{"(R4)", "(R4)"},
   703  	{"(R5)", "(R5)"},
   704  	{"-1(R4)", "-1(R4)"},
   705  	{"-1(R5)", "-1(R5)"},
   706  	{"6(PC)", "6(PC)"},
   707  	{"F14", "F14"},
   708  	{"F15", "F15"},
   709  	{"F16", "F16"},
   710  	{"F17", "F17"},
   711  	{"F18", "F18"},
   712  	{"F19", "F19"},
   713  	{"F20", "F20"},
   714  	{"F21", "F21"},
   715  	{"F22", "F22"},
   716  	{"F23", "F23"},
   717  	{"F24", "F24"},
   718  	{"F25", "F25"},
   719  	{"F26", "F26"},
   720  	{"F27", "F27"},
   721  	{"F28", "F28"},
   722  	{"F29", "F29"},
   723  	{"F30", "F30"},
   724  	{"F31", "F31"},
   725  	{"R0", "R0"},
   726  	{"R1", "R1"},
   727  	{"R11", "R11"},
   728  	{"R12", "R12"},
   729  	{"R13", "R13"},
   730  	{"R14", "R14"},
   731  	{"R15", "R15"},
   732  	{"R16", "R16"},
   733  	{"R17", "R17"},
   734  	{"R18", "R18"},
   735  	{"R19", "R19"},
   736  	{"R2", "R2"},
   737  	{"R20", "R20"},
   738  	{"R21", "R21"},
   739  	{"R22", "R22"},
   740  	{"R23", "R23"},
   741  	{"R24", "R24"},
   742  	{"R25", "R25"},
   743  	{"R26", "R26"},
   744  	{"R27", "R27"},
   745  	{"R29", "R29"},
   746  	{"R3", "R3"},
   747  	{"R31", "R31"},
   748  	{"R4", "R4"},
   749  	{"R5", "R5"},
   750  	{"R6", "R6"},
   751  	{"R7", "R7"},
   752  	{"R8", "R8"},
   753  	{"R9", "R9"},
   754  	{"LO", "LO"},
   755  	{"a(FP)", "a(FP)"},
   756  	{"g", "g"},
   757  	{"RSB", "R28"},
   758  	{"ret+8(FP)", "ret+8(FP)"},
   759  	{"runtime·abort(SB)", "runtime.abort(SB)"},
   760  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   761  	{"·trunc(SB)", "\"\".trunc(SB)"},
   762  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   763  }
   764  
   765  var mipsOperandTests = []operandTest{
   766  	{"$((1<<63)-1)", "$9223372036854775807"},
   767  	{"$(-64*1024)", "$-65536"},
   768  	{"$(1024 * 8)", "$8192"},
   769  	{"$-1", "$-1"},
   770  	{"$-24(R4)", "$-24(R4)"},
   771  	{"$0", "$0"},
   772  	{"$0(R1)", "$(R1)"},
   773  	{"$0.5", "$(0.5)"},
   774  	{"$0x7000", "$28672"},
   775  	{"$0x88888eef", "$2290650863"},
   776  	{"$1", "$1"},
   777  	{"$_main<>(SB)", "$_main<>(SB)"},
   778  	{"$argframe(FP)", "$argframe(FP)"},
   779  	{"$~3", "$-4"},
   780  	{"(-288-3*8)(R1)", "-312(R1)"},
   781  	{"(16)(R7)", "16(R7)"},
   782  	{"(8)(g)", "8(g)"},
   783  	{"(R0)", "(R0)"},
   784  	{"(R3)", "(R3)"},
   785  	{"(R4)", "(R4)"},
   786  	{"(R5)", "(R5)"},
   787  	{"-1(R4)", "-1(R4)"},
   788  	{"-1(R5)", "-1(R5)"},
   789  	{"6(PC)", "6(PC)"},
   790  	{"F14", "F14"},
   791  	{"F15", "F15"},
   792  	{"F16", "F16"},
   793  	{"F17", "F17"},
   794  	{"F18", "F18"},
   795  	{"F19", "F19"},
   796  	{"F20", "F20"},
   797  	{"F21", "F21"},
   798  	{"F22", "F22"},
   799  	{"F23", "F23"},
   800  	{"F24", "F24"},
   801  	{"F25", "F25"},
   802  	{"F26", "F26"},
   803  	{"F27", "F27"},
   804  	{"F28", "F28"},
   805  	{"F29", "F29"},
   806  	{"F30", "F30"},
   807  	{"F31", "F31"},
   808  	{"R0", "R0"},
   809  	{"R1", "R1"},
   810  	{"R11", "R11"},
   811  	{"R12", "R12"},
   812  	{"R13", "R13"},
   813  	{"R14", "R14"},
   814  	{"R15", "R15"},
   815  	{"R16", "R16"},
   816  	{"R17", "R17"},
   817  	{"R18", "R18"},
   818  	{"R19", "R19"},
   819  	{"R2", "R2"},
   820  	{"R20", "R20"},
   821  	{"R21", "R21"},
   822  	{"R22", "R22"},
   823  	{"R23", "R23"},
   824  	{"R24", "R24"},
   825  	{"R25", "R25"},
   826  	{"R26", "R26"},
   827  	{"R27", "R27"},
   828  	{"R28", "R28"},
   829  	{"R29", "R29"},
   830  	{"R3", "R3"},
   831  	{"R31", "R31"},
   832  	{"R4", "R4"},
   833  	{"R5", "R5"},
   834  	{"R6", "R6"},
   835  	{"R7", "R7"},
   836  	{"R8", "R8"},
   837  	{"R9", "R9"},
   838  	{"LO", "LO"},
   839  	{"a(FP)", "a(FP)"},
   840  	{"g", "g"},
   841  	{"ret+8(FP)", "ret+8(FP)"},
   842  	{"runtime·abort(SB)", "runtime.abort(SB)"},
   843  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   844  	{"·trunc(SB)", "\"\".trunc(SB)"},
   845  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   846  }
   847  
   848  var s390xOperandTests = []operandTest{
   849  	{"$((1<<63)-1)", "$9223372036854775807"},
   850  	{"$(-64*1024)", "$-65536"},
   851  	{"$(1024 * 8)", "$8192"},
   852  	{"$-1", "$-1"},
   853  	{"$-24(R4)", "$-24(R4)"},
   854  	{"$0", "$0"},
   855  	{"$0(R1)", "$(R1)"},
   856  	{"$0.5", "$(0.5)"},
   857  	{"$0x7000", "$28672"},
   858  	{"$0x88888eef", "$2290650863"},
   859  	{"$1", "$1"},
   860  	{"$_main<>(SB)", "$_main<>(SB)"},
   861  	{"$argframe(FP)", "$argframe(FP)"},
   862  	{"$~3", "$-4"},
   863  	{"(-288-3*8)(R1)", "-312(R1)"},
   864  	{"(16)(R7)", "16(R7)"},
   865  	{"(8)(g)", "8(g)"},
   866  	{"(R0)", "(R0)"},
   867  	{"(R3)", "(R3)"},
   868  	{"(R4)", "(R4)"},
   869  	{"(R5)", "(R5)"},
   870  	{"-1(R4)", "-1(R4)"},
   871  	{"-1(R5)", "-1(R5)"},
   872  	{"6(PC)", "6(PC)"},
   873  	{"R0", "R0"},
   874  	{"R1", "R1"},
   875  	{"R2", "R2"},
   876  	{"R3", "R3"},
   877  	{"R4", "R4"},
   878  	{"R5", "R5"},
   879  	{"R6", "R6"},
   880  	{"R7", "R7"},
   881  	{"R8", "R8"},
   882  	{"R9", "R9"},
   883  	{"R10", "R10"},
   884  	{"R11", "R11"},
   885  	{"R12", "R12"},
   886  	// {"R13", "R13"}, R13 is g
   887  	{"R14", "R14"},
   888  	{"R15", "R15"},
   889  	{"F0", "F0"},
   890  	{"F1", "F1"},
   891  	{"F2", "F2"},
   892  	{"F3", "F3"},
   893  	{"F4", "F4"},
   894  	{"F5", "F5"},
   895  	{"F6", "F6"},
   896  	{"F7", "F7"},
   897  	{"F8", "F8"},
   898  	{"F9", "F9"},
   899  	{"F10", "F10"},
   900  	{"F11", "F11"},
   901  	{"F12", "F12"},
   902  	{"F13", "F13"},
   903  	{"F14", "F14"},
   904  	{"F15", "F15"},
   905  	{"V0", "V0"},
   906  	{"V1", "V1"},
   907  	{"V2", "V2"},
   908  	{"V3", "V3"},
   909  	{"V4", "V4"},
   910  	{"V5", "V5"},
   911  	{"V6", "V6"},
   912  	{"V7", "V7"},
   913  	{"V8", "V8"},
   914  	{"V9", "V9"},
   915  	{"V10", "V10"},
   916  	{"V11", "V11"},
   917  	{"V12", "V12"},
   918  	{"V13", "V13"},
   919  	{"V14", "V14"},
   920  	{"V15", "V15"},
   921  	{"V16", "V16"},
   922  	{"V17", "V17"},
   923  	{"V18", "V18"},
   924  	{"V19", "V19"},
   925  	{"V20", "V20"},
   926  	{"V21", "V21"},
   927  	{"V22", "V22"},
   928  	{"V23", "V23"},
   929  	{"V24", "V24"},
   930  	{"V25", "V25"},
   931  	{"V26", "V26"},
   932  	{"V27", "V27"},
   933  	{"V28", "V28"},
   934  	{"V29", "V29"},
   935  	{"V30", "V30"},
   936  	{"V31", "V31"},
   937  	{"a(FP)", "a(FP)"},
   938  	{"g", "g"},
   939  	{"ret+8(FP)", "ret+8(FP)"},
   940  	{"runtime·abort(SB)", "runtime.abort(SB)"},
   941  	{"·AddUint32(SB)", "\"\".AddUint32(SB)"},
   942  	{"·trunc(SB)", "\"\".trunc(SB)"},
   943  	{"[):[o-FP", ""}, // Issue 12469 - asm hung parsing the o-FP range on non ARM platforms.
   944  }
   945  

View as plain text