mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Separate patterns in asmcheck by spaces instead of commas. Many patterns end in comma (like "MOV [$]123,") so separating patterns by comma is not great; they're already quoted, so spaces are fine. Also replace all tabs in the assembly lines with spaces before matching. Finally, replace \$ or \\$ with [$] as the matching idiom. The effect of all these is to make the patterns look like: // amd64:"BSFQ" "ORQ [$]256" instead of the old: // amd64:"BSFQ","ORQ\t\\$256" Update all tests as well. Change-Id: Ia39febe5d7f67ba115846422789e11b185d5c807 Reviewed-on: https://go-review.googlesource.com/c/go/+/716060 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
95 lines
2.5 KiB
Go
95 lines
2.5 KiB
Go
// asmcheck
|
|
|
|
// Copyright 2024 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// These tests check that atomic instructions without dynamic checks are
|
|
// generated for architectures that support them
|
|
|
|
package codegen
|
|
|
|
import "sync/atomic"
|
|
|
|
type Counter struct {
|
|
count int32
|
|
}
|
|
|
|
func (c *Counter) Increment() {
|
|
// Check that ARm64 v8.0 has both atomic instruction (LDADDALW) and a dynamic check
|
|
// (for arm64HasATOMICS), while ARM64 v8.1 has only atomic and no dynamic check.
|
|
// arm64/v8.0:"LDADDALW"
|
|
// arm64/v8.1:"LDADDALW"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// amd64:"LOCK" -"CMPXCHG"
|
|
atomic.AddInt32(&c.count, 1)
|
|
}
|
|
|
|
func atomicLogical64(x *atomic.Uint64) uint64 {
|
|
var r uint64
|
|
|
|
// arm64/v8.0:"LDCLRALD"
|
|
// arm64/v8.1:"LDCLRALD"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// On amd64, make sure we use LOCK+AND instead of CMPXCHG when we don't use the result.
|
|
// amd64:"LOCK" -"CMPXCHGQ"
|
|
x.And(11)
|
|
// arm64/v8.0:"LDCLRALD"
|
|
// arm64/v8.1:"LDCLRALD"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// amd64:"LOCK" "CMPXCHGQ"
|
|
r += x.And(22)
|
|
|
|
// arm64/v8.0:"LDORALD"
|
|
// arm64/v8.1:"LDORALD"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// On amd64, make sure we use LOCK+OR instead of CMPXCHG when we don't use the result.
|
|
// amd64:"LOCK" -"CMPXCHGQ"
|
|
x.Or(33)
|
|
// arm64/v8.0:"LDORALD"
|
|
// arm64/v8.1:"LDORALD"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// amd64:"LOCK" "CMPXCHGQ"
|
|
r += x.Or(44)
|
|
|
|
return r
|
|
}
|
|
|
|
func atomicLogical32(x *atomic.Uint32) uint32 {
|
|
var r uint32
|
|
|
|
// arm64/v8.0:"LDCLRALW"
|
|
// arm64/v8.1:"LDCLRALW"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// On amd64, make sure we use LOCK+AND instead of CMPXCHG when we don't use the result.
|
|
// amd64:"LOCK" -"CMPXCHGL"
|
|
x.And(11)
|
|
// arm64/v8.0:"LDCLRALW"
|
|
// arm64/v8.1:"LDCLRALW"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// amd64:"LOCK" "CMPXCHGL"
|
|
r += x.And(22)
|
|
|
|
// arm64/v8.0:"LDORALW"
|
|
// arm64/v8.1:"LDORALW"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// On amd64, make sure we use LOCK+OR instead of CMPXCHG when we don't use the result.
|
|
// amd64:"LOCK" -"CMPXCHGL"
|
|
x.Or(33)
|
|
// arm64/v8.0:"LDORALW"
|
|
// arm64/v8.1:"LDORALW"
|
|
// arm64/v8.0:".*arm64HasATOMICS"
|
|
// arm64/v8.1:-".*arm64HasATOMICS"
|
|
// amd64:"LOCK" "CMPXCHGL"
|
|
r += x.Or(44)
|
|
|
|
return r
|
|
}
|