Source file test/codegen/memops.go

     1  // asmcheck
     2  
     3  // Copyright 2018 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.
     6  
     7  package codegen
     8  
     9  var x [2]bool
    10  var x8 [2]uint8
    11  var x16 [2]uint16
    12  var x32 [2]uint32
    13  var x64 [2]uint64
    14  
    15  func compMem1() int {
    16  	// amd64:`CMPB\tcommand-line-arguments.x\+1\(SB\), [$]0`
    17  	if x[1] {
    18  		return 1
    19  	}
    20  	// amd64:`CMPB\tcommand-line-arguments.x8\+1\(SB\), [$]7`
    21  	if x8[1] == 7 {
    22  		return 1
    23  	}
    24  	// amd64:`CMPW\tcommand-line-arguments.x16\+2\(SB\), [$]7`
    25  	if x16[1] == 7 {
    26  		return 1
    27  	}
    28  	// amd64:`CMPL\tcommand-line-arguments.x32\+4\(SB\), [$]7`
    29  	if x32[1] == 7 {
    30  		return 1
    31  	}
    32  	// amd64:`CMPQ\tcommand-line-arguments.x64\+8\(SB\), [$]7`
    33  	if x64[1] == 7 {
    34  		return 1
    35  	}
    36  	return 0
    37  }
    38  
    39  type T struct {
    40  	x   bool
    41  	x8  uint8
    42  	x16 uint16
    43  	x32 uint32
    44  	x64 uint64
    45  	a   [2]int // force it passed in memory
    46  }
    47  
    48  func compMem2(t T) int {
    49  	// amd64:`CMPB\t.*\(SP\), [$]0`
    50  	if t.x {
    51  		return 1
    52  	}
    53  	// amd64:`CMPB\t.*\(SP\), [$]7`
    54  	if t.x8 == 7 {
    55  		return 1
    56  	}
    57  	// amd64:`CMPW\t.*\(SP\), [$]7`
    58  	if t.x16 == 7 {
    59  		return 1
    60  	}
    61  	// amd64:`CMPL\t.*\(SP\), [$]7`
    62  	if t.x32 == 7 {
    63  		return 1
    64  	}
    65  	// amd64:`CMPQ\t.*\(SP\), [$]7`
    66  	if t.x64 == 7 {
    67  		return 1
    68  	}
    69  	return 0
    70  }
    71  
    72  func compMem3(x, y *int) (int, bool) {
    73  	// We can do comparisons of a register with memory even if
    74  	// the register is used subsequently.
    75  	r := *x
    76  	// amd64:`CMPQ\t\(`
    77  	// 386:`CMPL\t\(`
    78  	return r, r < *y
    79  }
    80  
    81  // The following functions test that indexed load/store operations get generated.
    82  
    83  func idxInt8(x, y []int8, i int) {
    84  	var t int8
    85  	// amd64: `MOVBL[SZ]X\t1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\), [A-Z]+[0-9]*`
    86  	//   386: `MOVBL[SZ]X\t1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\), [A-Z]+[0-9]*`
    87  	t = x[i+1]
    88  	// amd64: `MOVB\t[A-Z]+[0-9]*, 1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\)`
    89  	//   386: `MOVB\t[A-Z]+[0-9]*, 1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\)`
    90  	y[i+1] = t
    91  	// amd64: `MOVB\t[$]77, 1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\)`
    92  	//   386: `MOVB\t[$]77, 1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\)`
    93  	x[i+1] = 77
    94  }
    95  
    96  func idxInt16(x, y []int16, i int) {
    97  	var t int16
    98  	// amd64: `MOVWL[SZ]X\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\), [A-Z]+[0-9]*`
    99  	//   386: `MOVWL[SZ]X\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\), [A-Z]+[0-9]*`
   100  	t = x[i+1]
   101  	// amd64: `MOVW\t[A-Z]+[0-9]*, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\)`
   102  	//   386: `MOVW\t[A-Z]+[0-9]*, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\)`
   103  	y[i+1] = t
   104  	// amd64: `MOVWL[SZ]X\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\), [A-Z]+[0-9]*`
   105  	//   386: `MOVWL[SZ]X\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\), [A-Z]+[0-9]*`
   106  	t = x[16*i+1]
   107  	// amd64: `MOVW\t[A-Z]+[0-9]*, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\)`
   108  	//   386: `MOVW\t[A-Z]+[0-9]*, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\)`
   109  	y[16*i+1] = t
   110  	// amd64: `MOVW\t[$]77, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\)`
   111  	//   386: `MOVW\t[$]77, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\)`
   112  	x[i+1] = 77
   113  	// amd64: `MOVW\t[$]77, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\)`
   114  	//   386: `MOVW\t[$]77, 2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\)`
   115  	x[16*i+1] = 77
   116  }
   117  
   118  func idxInt32(x, y []int32, i int) {
   119  	var t int32
   120  	// amd64: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   121  	//   386: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   122  	t = x[i+1]
   123  	// amd64: `MOVL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   124  	//   386: `MOVL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   125  	y[i+1] = t
   126  	// amd64: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   127  	t = x[2*i+1]
   128  	// amd64: `MOVL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   129  	y[2*i+1] = t
   130  	// amd64: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\), [A-Z]+[0-9]*`
   131  	//   386: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\), [A-Z]+[0-9]*`
   132  	t = x[16*i+1]
   133  	// amd64: `MOVL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\)`
   134  	//   386: `MOVL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\)`
   135  	y[16*i+1] = t
   136  	// amd64: `MOVL\t[$]77, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   137  	//   386: `MOVL\t[$]77, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   138  	x[i+1] = 77
   139  	// amd64: `MOVL\t[$]77, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\)`
   140  	//   386: `MOVL\t[$]77, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\)`
   141  	x[16*i+1] = 77
   142  }
   143  
   144  func idxInt64(x, y []int64, i int) {
   145  	var t int64
   146  	// amd64: `MOVQ\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   147  	t = x[i+1]
   148  	// amd64: `MOVQ\t[A-Z]+[0-9]*, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   149  	y[i+1] = t
   150  	// amd64: `MOVQ\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\), [A-Z]+[0-9]*`
   151  	t = x[16*i+1]
   152  	// amd64: `MOVQ\t[A-Z]+[0-9]*, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\)`
   153  	y[16*i+1] = t
   154  	// amd64: `MOVQ\t[$]77, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   155  	x[i+1] = 77
   156  	// amd64: `MOVQ\t[$]77, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\)`
   157  	x[16*i+1] = 77
   158  }
   159  
   160  func idxFloat32(x, y []float32, i int) {
   161  	var t float32
   162  	//    amd64: `MOVSS\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), X[0-9]+`
   163  	// 386/sse2: `MOVSS\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), X[0-9]+`
   164  	//    arm64: `FMOVS\t\(R[0-9]*\)\(R[0-9]*<<2\), F[0-9]+`
   165  	t = x[i+1]
   166  	//    amd64: `MOVSS\tX[0-9]+, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   167  	// 386/sse2: `MOVSS\tX[0-9]+, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   168  	//    arm64: `FMOVS\tF[0-9]+, \(R[0-9]*\)\(R[0-9]*<<2\)`
   169  	y[i+1] = t
   170  	//    amd64: `MOVSS\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\), X[0-9]+`
   171  	// 386/sse2: `MOVSS\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\), X[0-9]+`
   172  	t = x[16*i+1]
   173  	//    amd64: `MOVSS\tX[0-9]+, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\)`
   174  	// 386/sse2: `MOVSS\tX[0-9]+, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\)`
   175  	y[16*i+1] = t
   176  }
   177  
   178  func idxFloat64(x, y []float64, i int) {
   179  	var t float64
   180  	//    amd64: `MOVSD\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), X[0-9]+`
   181  	// 386/sse2: `MOVSD\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), X[0-9]+`
   182  	//    arm64: `FMOVD\t\(R[0-9]*\)\(R[0-9]*<<3\), F[0-9]+`
   183  	t = x[i+1]
   184  	//    amd64: `MOVSD\tX[0-9]+, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   185  	// 386/sse2: `MOVSD\tX[0-9]+, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   186  	//    arm64: `FMOVD\tF[0-9]+, \(R[0-9]*\)\(R[0-9]*<<3\)`
   187  	y[i+1] = t
   188  	//    amd64: `MOVSD\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\), X[0-9]+`
   189  	// 386/sse2: `MOVSD\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\), X[0-9]+`
   190  	t = x[16*i+1]
   191  	//    amd64: `MOVSD\tX[0-9]+, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\)`
   192  	// 386/sse2: `MOVSD\tX[0-9]+, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\)`
   193  	y[16*i+1] = t
   194  }
   195  
   196  func idxLoadPlusOp32(x []int32, i int) int32 {
   197  	s := x[0]
   198  	// 386: `ADDL\t4\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
   199  	// amd64: `ADDL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   200  	s += x[i+1]
   201  	// 386: `SUBL\t8\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
   202  	// amd64: `SUBL\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   203  	s -= x[i+2]
   204  	// 386: `IMULL\t12\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
   205  	s *= x[i+3]
   206  	// 386: `ANDL\t16\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
   207  	// amd64: `ANDL\t16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   208  	s &= x[i+4]
   209  	// 386: `ORL\t20\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
   210  	// amd64: `ORL\t20\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   211  	s |= x[i+5]
   212  	// 386: `XORL\t24\([A-Z]+\)\([A-Z]+\*4\), [A-Z]+`
   213  	// amd64: `XORL\t24\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   214  	s ^= x[i+6]
   215  	return s
   216  }
   217  
   218  func idxLoadPlusOp64(x []int64, i int) int64 {
   219  	s := x[0]
   220  	// amd64: `ADDQ\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   221  	s += x[i+1]
   222  	// amd64: `SUBQ\t16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   223  	s -= x[i+2]
   224  	// amd64: `ANDQ\t24\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   225  	s &= x[i+3]
   226  	// amd64: `ORQ\t32\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   227  	s |= x[i+4]
   228  	// amd64: `XORQ\t40\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   229  	s ^= x[i+5]
   230  	return s
   231  }
   232  
   233  func idxStorePlusOp32(x []int32, i int, v int32) {
   234  	// 386: `ADDL\t[A-Z]+, 4\([A-Z]+\)\([A-Z]+\*4\)`
   235  	// amd64: `ADDL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   236  	x[i+1] += v
   237  	// 386: `SUBL\t[A-Z]+, 8\([A-Z]+\)\([A-Z]+\*4\)`
   238  	// amd64: `SUBL\t[A-Z]+[0-9]*, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   239  	x[i+2] -= v
   240  	// 386: `ANDL\t[A-Z]+, 12\([A-Z]+\)\([A-Z]+\*4\)`
   241  	// amd64: `ANDL\t[A-Z]+[0-9]*, 12\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   242  	x[i+3] &= v
   243  	// 386: `ORL\t[A-Z]+, 16\([A-Z]+\)\([A-Z]+\*4\)`
   244  	// amd64: `ORL\t[A-Z]+[0-9]*, 16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   245  	x[i+4] |= v
   246  	// 386: `XORL\t[A-Z]+, 20\([A-Z]+\)\([A-Z]+\*4\)`
   247  	// amd64: `XORL\t[A-Z]+[0-9]*, 20\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   248  	x[i+5] ^= v
   249  
   250  	// 386: `ADDL\t[$]77, 24\([A-Z]+\)\([A-Z]+\*4\)`
   251  	// amd64: `ADDL\t[$]77, 24\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   252  	x[i+6] += 77
   253  	// 386: `ANDL\t[$]77, 28\([A-Z]+\)\([A-Z]+\*4\)`
   254  	// amd64: `ANDL\t[$]77, 28\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   255  	x[i+7] &= 77
   256  	// 386: `ORL\t[$]77, 32\([A-Z]+\)\([A-Z]+\*4\)`
   257  	// amd64: `ORL\t[$]77, 32\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   258  	x[i+8] |= 77
   259  	// 386: `XORL\t[$]77, 36\([A-Z]+\)\([A-Z]+\*4\)`
   260  	// amd64: `XORL\t[$]77, 36\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\)`
   261  	x[i+9] ^= 77
   262  }
   263  
   264  func idxStorePlusOp64(x []int64, i int, v int64) {
   265  	// amd64: `ADDQ\t[A-Z]+[0-9]*, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   266  	x[i+1] += v
   267  	// amd64: `SUBQ\t[A-Z]+[0-9]*, 16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   268  	x[i+2] -= v
   269  	// amd64: `ANDQ\t[A-Z]+[0-9]*, 24\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   270  	x[i+3] &= v
   271  	// amd64: `ORQ\t[A-Z]+[0-9]*, 32\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   272  	x[i+4] |= v
   273  	// amd64: `XORQ\t[A-Z]+[0-9]*, 40\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   274  	x[i+5] ^= v
   275  
   276  	// amd64: `ADDQ\t[$]77, 48\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   277  	x[i+6] += 77
   278  	// amd64: `ANDQ\t[$]77, 56\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   279  	x[i+7] &= 77
   280  	// amd64: `ORQ\t[$]77, 64\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   281  	x[i+8] |= 77
   282  	// amd64: `XORQ\t[$]77, 72\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\)`
   283  	x[i+9] ^= 77
   284  }
   285  
   286  func idxCompare(i int) int {
   287  	// amd64: `MOVBLZX\t1\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\), [A-Z]+[0-9]*`
   288  	if x8[i+1] < x8[0] {
   289  		return 0
   290  	}
   291  	// amd64: `MOVWLZX\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\), [A-Z]+[0-9]*`
   292  	if x16[i+1] < x16[0] {
   293  		return 0
   294  	}
   295  	// amd64: `MOVWLZX\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\), [A-Z]+[0-9]*`
   296  	if x16[16*i+1] < x16[0] {
   297  		return 0
   298  	}
   299  	// amd64: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   300  	if x32[i+1] < x32[0] {
   301  		return 0
   302  	}
   303  	// amd64: `MOVL\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\), [A-Z]+[0-9]*`
   304  	if x32[16*i+1] < x32[0] {
   305  		return 0
   306  	}
   307  	// amd64: `MOVQ\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   308  	if x64[i+1] < x64[0] {
   309  		return 0
   310  	}
   311  	// amd64: `MOVQ\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\), [A-Z]+[0-9]*`
   312  	if x64[16*i+1] < x64[0] {
   313  		return 0
   314  	}
   315  	// amd64: `MOVBLZX\t2\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\), [A-Z]+[0-9]*`
   316  	if x8[i+2] < 77 {
   317  		return 0
   318  	}
   319  	// amd64: `MOVWLZX\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*2\), [A-Z]+[0-9]*`
   320  	if x16[i+2] < 77 {
   321  		return 0
   322  	}
   323  	// amd64: `MOVWLZX\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[12]\), [A-Z]+[0-9]*`
   324  	if x16[16*i+2] < 77 {
   325  		return 0
   326  	}
   327  	// amd64: `MOVL\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
   328  	if x32[i+2] < 77 {
   329  		return 0
   330  	}
   331  	// amd64: `MOVL\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[14]\), [A-Z]+[0-9]*`
   332  	if x32[16*i+2] < 77 {
   333  		return 0
   334  	}
   335  	// amd64: `MOVQ\t16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
   336  	if x64[i+2] < 77 {
   337  		return 0
   338  	}
   339  	// amd64: `MOVQ\t16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*[18]\), [A-Z]+[0-9]*`
   340  	if x64[16*i+2] < 77 {
   341  		return 0
   342  	}
   343  	return 1
   344  }
   345  
   346  func idxFloatOps(a []float64, b []float32, i int) (float64, float32) {
   347  	c := float64(7)
   348  	// amd64: `ADDSD\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), X[0-9]+`
   349  	c += a[i+1]
   350  	// amd64: `SUBSD\t16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), X[0-9]+`
   351  	c -= a[i+2]
   352  	// amd64: `MULSD\t24\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), X[0-9]+`
   353  	c *= a[i+3]
   354  	// amd64: `DIVSD\t32\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), X[0-9]+`
   355  	c /= a[i+4]
   356  
   357  	d := float32(8)
   358  	// amd64: `ADDSS\t4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), X[0-9]+`
   359  	d += b[i+1]
   360  	// amd64: `SUBSS\t8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), X[0-9]+`
   361  	d -= b[i+2]
   362  	// amd64: `MULSS\t12\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), X[0-9]+`
   363  	d *= b[i+3]
   364  	// amd64: `DIVSS\t16\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), X[0-9]+`
   365  	d /= b[i+4]
   366  	return c, d
   367  }
   368  
   369  func storeTest(a []bool, v int, i int) {
   370  	// amd64: `BTL\t\$0,`,`SETCS\t4\([A-Z]+[0-9]*\)`
   371  	a[4] = v&1 != 0
   372  	// amd64: `BTL\t\$1,`,`SETCS\t3\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*1\)`
   373  	a[3+i] = v&2 != 0
   374  }
   375  
   376  func bitOps(p *[12]uint64) {
   377  	// amd64: `ORQ\t\$8, \(AX\)`
   378  	p[0] |= 8
   379  	// amd64: `ORQ\t\$1073741824, 8\(AX\)`
   380  	p[1] |= 1 << 30
   381  	// amd64: `BTSQ\t\$31, 16\(AX\)`
   382  	p[2] |= 1 << 31
   383  	// amd64: `BTSQ\t\$63, 24\(AX\)`
   384  	p[3] |= 1 << 63
   385  
   386  	// amd64: `ANDQ\t\$-9, 32\(AX\)`
   387  	p[4] &^= 8
   388  	// amd64: `ANDQ\t\$-1073741825, 40\(AX\)`
   389  	p[5] &^= 1 << 30
   390  	// amd64: `BTRQ\t\$31, 48\(AX\)`
   391  	p[6] &^= 1 << 31
   392  	// amd64: `BTRQ\t\$63, 56\(AX\)`
   393  	p[7] &^= 1 << 63
   394  
   395  	// amd64: `XORQ\t\$8, 64\(AX\)`
   396  	p[8] ^= 8
   397  	// amd64: `XORQ\t\$1073741824, 72\(AX\)`
   398  	p[9] ^= 1 << 30
   399  	// amd64: `BTCQ\t\$31, 80\(AX\)`
   400  	p[10] ^= 1 << 31
   401  	// amd64: `BTCQ\t\$63, 88\(AX\)`
   402  	p[11] ^= 1 << 63
   403  }
   404  

View as plain text