Source file test/codegen/compare_and_branch.go

     1  // asmcheck
     2  
     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.
     6  
     7  package codegen
     8  
     9  //go:noinline
    10  func dummy() {}
    11  
    12  // Signed 64-bit compare-and-branch.
    13  func si64(x, y chan int64) {
    14  	// s390x:"CGRJ\t[$](2|4), R[0-9]+, R[0-9]+, "
    15  	for <-x < <-y {
    16  		dummy()
    17  	}
    18  
    19  	// s390x:"CL?GRJ\t[$]8, R[0-9]+, R[0-9]+, "
    20  	for <-x == <-y {
    21  		dummy()
    22  	}
    23  }
    24  
    25  // Signed 64-bit compare-and-branch with 8-bit immediate.
    26  func si64x8() {
    27  	// s390x:"CGIJ\t[$]12, R[0-9]+, [$]127, "
    28  	for i := int64(0); i < 128; i++ {
    29  		dummy()
    30  	}
    31  
    32  	// s390x:"CGIJ\t[$]10, R[0-9]+, [$]-128, "
    33  	for i := int64(0); i > -129; i-- {
    34  		dummy()
    35  	}
    36  
    37  	// s390x:"CGIJ\t[$]2, R[0-9]+, [$]127, "
    38  	for i := int64(0); i >= 128; i++ {
    39  		dummy()
    40  	}
    41  
    42  	// s390x:"CGIJ\t[$]4, R[0-9]+, [$]-128, "
    43  	for i := int64(0); i <= -129; i-- {
    44  		dummy()
    45  	}
    46  }
    47  
    48  // Unsigned 64-bit compare-and-branch.
    49  func ui64(x, y chan uint64) {
    50  	// s390x:"CLGRJ\t[$](2|4), R[0-9]+, R[0-9]+, "
    51  	for <-x > <-y {
    52  		dummy()
    53  	}
    54  
    55  	// s390x:"CL?GRJ\t[$]6, R[0-9]+, R[0-9]+, "
    56  	for <-x != <-y {
    57  		dummy()
    58  	}
    59  }
    60  
    61  // Unsigned 64-bit comparison with 8-bit immediate.
    62  func ui64x8() {
    63  	// s390x:"CLGIJ\t[$]4, R[0-9]+, [$]128, "
    64  	for i := uint64(0); i < 128; i++ {
    65  		dummy()
    66  	}
    67  
    68  	// s390x:"CLGIJ\t[$]12, R[0-9]+, [$]255, "
    69  	for i := uint64(0); i < 256; i++ {
    70  		dummy()
    71  	}
    72  
    73  	// s390x:"CLGIJ\t[$]2, R[0-9]+, [$]255, "
    74  	for i := uint64(0); i >= 256; i-- {
    75  		dummy()
    76  	}
    77  
    78  	// s390x:"CLGIJ\t[$]2, R[0-9]+, [$]0, "
    79  	for i := uint64(1024); i > 0; i-- {
    80  		dummy()
    81  	}
    82  }
    83  
    84  // Signed 32-bit compare-and-branch.
    85  func si32(x, y chan int32) {
    86  	// s390x:"CRJ\t[$](2|4), R[0-9]+, R[0-9]+, "
    87  	for <-x < <-y {
    88  		dummy()
    89  	}
    90  
    91  	// s390x:"CL?RJ\t[$]8, R[0-9]+, R[0-9]+, "
    92  	for <-x == <-y {
    93  		dummy()
    94  	}
    95  }
    96  
    97  // Signed 32-bit compare-and-branch with 8-bit immediate.
    98  func si32x8() {
    99  	// s390x:"CIJ\t[$]12, R[0-9]+, [$]127, "
   100  	for i := int32(0); i < 128; i++ {
   101  		dummy()
   102  	}
   103  
   104  	// s390x:"CIJ\t[$]10, R[0-9]+, [$]-128, "
   105  	for i := int32(0); i > -129; i-- {
   106  		dummy()
   107  	}
   108  
   109  	// s390x:"CIJ\t[$]2, R[0-9]+, [$]127, "
   110  	for i := int32(0); i >= 128; i++ {
   111  		dummy()
   112  	}
   113  
   114  	// s390x:"CIJ\t[$]4, R[0-9]+, [$]-128, "
   115  	for i := int32(0); i <= -129; i-- {
   116  		dummy()
   117  	}
   118  }
   119  
   120  // Unsigned 32-bit compare-and-branch.
   121  func ui32(x, y chan uint32) {
   122  	// s390x:"CLRJ\t[$](2|4), R[0-9]+, R[0-9]+, "
   123  	for <-x > <-y {
   124  		dummy()
   125  	}
   126  
   127  	// s390x:"CL?RJ\t[$]6, R[0-9]+, R[0-9]+, "
   128  	for <-x != <-y {
   129  		dummy()
   130  	}
   131  }
   132  
   133  // Unsigned 32-bit comparison with 8-bit immediate.
   134  func ui32x8() {
   135  	// s390x:"CLIJ\t[$]4, R[0-9]+, [$]128, "
   136  	for i := uint32(0); i < 128; i++ {
   137  		dummy()
   138  	}
   139  
   140  	// s390x:"CLIJ\t[$]12, R[0-9]+, [$]255, "
   141  	for i := uint32(0); i < 256; i++ {
   142  		dummy()
   143  	}
   144  
   145  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]255, "
   146  	for i := uint32(0); i >= 256; i-- {
   147  		dummy()
   148  	}
   149  
   150  	// s390x:"CLIJ\t[$]2, R[0-9]+, [$]0, "
   151  	for i := uint32(1024); i > 0; i-- {
   152  		dummy()
   153  	}
   154  }
   155  
   156  // Signed 64-bit comparison with unsigned 8-bit immediate.
   157  func si64xu8(x chan int64) {
   158  	// s390x:"CLGIJ\t[$]8, R[0-9]+, [$]128, "
   159  	for <-x == 128 {
   160  		dummy()
   161  	}
   162  
   163  	// s390x:"CLGIJ\t[$]6, R[0-9]+, [$]255, "
   164  	for <-x != 255 {
   165  		dummy()
   166  	}
   167  }
   168  
   169  // Signed 32-bit comparison with unsigned 8-bit immediate.
   170  func si32xu8(x chan int32) {
   171  	// s390x:"CLIJ\t[$]8, R[0-9]+, [$]255, "
   172  	for <-x == 255 {
   173  		dummy()
   174  	}
   175  
   176  	// s390x:"CLIJ\t[$]6, R[0-9]+, [$]128, "
   177  	for <-x != 128 {
   178  		dummy()
   179  	}
   180  }
   181  
   182  // Unsigned 64-bit comparison with signed 8-bit immediate.
   183  func ui64xu8(x chan uint64) {
   184  	// s390x:"CGIJ\t[$]8, R[0-9]+, [$]-1, "
   185  	for <-x == ^uint64(0) {
   186  		dummy()
   187  	}
   188  
   189  	// s390x:"CGIJ\t[$]6, R[0-9]+, [$]-128, "
   190  	for <-x != ^uint64(127) {
   191  		dummy()
   192  	}
   193  }
   194  
   195  // Unsigned 32-bit comparison with signed 8-bit immediate.
   196  func ui32xu8(x chan uint32) {
   197  	// s390x:"CIJ\t[$]8, R[0-9]+, [$]-128, "
   198  	for <-x == ^uint32(127) {
   199  		dummy()
   200  	}
   201  
   202  	// s390x:"CIJ\t[$]6, R[0-9]+, [$]-1, "
   203  	for <-x != ^uint32(0) {
   204  		dummy()
   205  	}
   206  }
   207  

View as plain text