Source file test/codegen/atomics.go

     1  // asmcheck
     2  
     3  // Copyright 2024 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  // These tests check that atomic instructions without dynamic checks are
     8  // generated for architectures that support them
     9  
    10  package codegen
    11  
    12  import "sync/atomic"
    13  
    14  type Counter struct {
    15  	count int32
    16  }
    17  
    18  func (c *Counter) Increment() {
    19  	// Check that ARm64 v8.0 has both atomic instruction (LDADDALW) and a dynamic check
    20  	// (for arm64HasATOMICS), while ARM64 v8.1 has only atomic and no dynamic check.
    21  	// arm64/v8.0:"LDADDALW"
    22  	// arm64/v8.1:"LDADDALW"
    23  	// arm64/v8.0:".*arm64HasATOMICS"
    24  	// arm64/v8.1:-".*arm64HasATOMICS"
    25  	atomic.AddInt32(&c.count, 1)
    26  }
    27  
    28  

View as plain text