/
githubmirror
/
go
ОбзорДокументацияВойти
/
githubmirror
/
go
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
ДокументацияПоддержка
Политика конфиденциальностиПользовательское соглашениеПолитика использования «cookies»Согласие субъекта персональных данных
2026 ©
go/
test/codegen/
..
README

test/codegen: fix broken syntax

4 месяца назад
addrcalc.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
alloc.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
append.go

test/codegen: update runtimefreegc test for slice backing store fix

2 месяца назад
append_freegc.go

test/codegen: update runtimefreegc test for slice backing store fix

2 месяца назад
arithmetic.go

cmd/compile/internal/ssa: lower bits.Mul64 to MULXQ on GOAMD64>=v3

20 дней назад
atomics.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
bitfield.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
bits.go

cmd/compile: add boolean absorption laws to SSA rewrite rules

4 месяца назад
bmi.go

test/codegen: add XSubXandYAndn code generation tests for arm64 and riscv64

7 дней назад
bool.go

cmd/compile: fold int(invertibleBool)^1 and int(!bool)^c

месяц назад
clobberdead.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
clobberdeadreg.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
compare_and_branch.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
comparisons.go

cmd/compile/internal/ssa: strip redundant byte/halfword zero-extensions on arm64

14 дней назад
condmove.go

test/codegen: add riscv64 checks for conditional subtractions

20 дней назад
constants.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
copy.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
deadstore.go

cmd/compile: use position of nil check when merging it with subsequent store

2 месяца назад
divmod.go

cmd/compile: optimize 32-bit unsigned division by pre-shifted magic constant

24 дня назад
floats.go

cmd/compile: rewrite x-y*z to fused multiply subtract for GOAMD64=v3

24 дня назад
fuse.go

cmd/compile: optimize comparisons with single bit difference

9 месяцев назад
generics.go

cmd/compile: eliminate nil checks on .dict arg

10 месяцев назад
ifaces.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
issue22703.go

test: port a nil-check interface test from asm_test

8 лет назад
issue25378.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
issue31618.go

cmd/compile: always mark atColumn1 results as statements

7 лет назад
issue33580.go

cmd/compile: reuse dead register before reusing register holding constant

7 лет назад
issue38554.go

cmd/compile: optimize Move with all-zero ro sym src to Zero

6 лет назад
issue42610.go

test/codegen: combine trivial PPC64 tests into ppc64x

4 года назад
issue48054.go

test/codegen: fix package name for test case

5 лет назад
issue52635.go

cmd/compile: avoid range clear when target depends on index

8 дней назад
issue54467.go

cmd/compile: use stricter rule for possible partial overlap

4 года назад
issue56440.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
issue58166.go

cmd/compile: rename some test packages in codegen

год назад
issue59297.go

test/codegen: get rid of \s

4 месяца назад
issue60324.go

cmd/compile: simplify closure name

3 месяца назад
issue60673.go

test/codegen: get rid of \s

4 месяца назад
issue61356.go

cmd/compile: get rid of special case in scheduler for entry block

3 года назад
issue63332.go

cmd/compile/internal/walk: copy SSA-able variables

3 года назад
issue66585.go

cmd/compile: rename some test packages in codegen

год назад
issue68845.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
issue69635.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
issue70409.go

cmd/compile: do not treat OpLocalAddr as load in DSE

2 года назад
issue72832.go

test/codegen: get rid of \s

4 месяца назад
issue74485.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
issue74788.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
issue75203.go

test/codegen: get rid of \s

4 месяца назад
issue77375.go

cmd/compile: fix slice bounds check elimination after function inlining

6 месяцев назад
known_bits.go

cmd/compile: add known bits pass

4 месяца назад
load_type_from_itab.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
logic.go

test/codegen: get rid of \s

4 месяца назад
mapaccess.go

cmd/compile: stop using VARKILL

4 года назад
maps.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
math.go

cmd/compile/internal/amd64: use X15 for 4- and 8-byte zero stores

7 часов назад
mathbits.go

cmd/compile/internal/ssa: constant fold math/bits functions

4 дня назад
memcombine.go

cmd/compile/internal/amd64: use X15 for 4- and 8-byte zero stores

7 часов назад
memcombine_simd.go

cmd/compile: pair NEON loads/stores

13 дней назад
memcse.go

cmd/compile: recognize OpVarDef and OpZero in cse isMemDef

4 месяца назад
memops.go

cmd/compile/internal/amd64: use X15 for 4- and 8-byte zero stores

7 часов назад
memops_bigoffset.go

test/codegen: fix some unbalanced quotes

4 месяца назад
moveload.go

cmd/compile: forward small Load through Move to avoid redundant copies

5 месяцев назад
multiply.go

cmd/compile/internal/ssa: optimize multiply-by-constant on riscv64

7 дней назад
noextend.go

cmd/compile/internal/ssa: make zero-upper-bits a declared op attribute

7 дней назад
race.go

cmd/compile: remove racefuncenterfp when it is not needed

6 лет назад
reflect_type.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
regabi_regalloc.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
retpoline.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
rotate.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
schedule.go

cmd/compile: schedule increments after flags

3 месяца назад
select.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
shape_assert.go

cmd/compile: eliminate impossible type assertions in generic functions

3 месяца назад
shift.go

cmd/compile: remove multi-register shift optimization on amd64

2 месяца назад
shortcircuit.go

cmd/compile: handle some additional phis in shortcircuit

6 лет назад
simd.go

test : repair codegen/simd mask instructions test

месяц назад
simd_arm64.go

simd/archsimd: correct ARM64 IfElse semantics

2 месяца назад
slices.go

test/codegen: fix broken syntax

4 месяца назад
smallintiface.go

cmd/compile: generalize staticuint64s sharing to larger integer constant types

13 дней назад
spectre.go

test: migrate remaining files to go:build syntax

3 года назад
spills.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
stack.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
strings.go

runtime: consolidate tiny sizespecializedmalloc functions

3 месяца назад
structs.go

cmd/compile/internal/amd64: use X15 for 4- and 8-byte zero stores

7 часов назад
switch.go

cmd/compile: support optimizing switch statements with fallthroughs to lookup tables

3 месяца назад
typeswitch.go

test/codegen: simplify asmcheck pattern matching

9 месяцев назад
unique.go

cmd/compile/internal/ssa: eliminate string copies for calls to unique.Make

год назад
unsafe.go

test/codegen: get rid of \s

4 месяца назад
writebarrier.go

test/codegen: replace commas with spaces between regexps

4 месяца назад
zerosize.go

cmd/compile/internal/amd64: use X15 for 4- and 8-byte zero stores

7 часов назад
README
// Copyright 2018 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.
 
The codegen directory contains code generation tests for the gc
compiler.
 
 
- Introduction
 
The test harness compiles Go code inside files in this directory and
matches the generated assembly (the output of `go tool compile -S`)
against a set of regexps to be specified in comments that follow a
special syntax (described below). The test driver is implemented as
an action within the GOROOT/test test suite, called "asmcheck".
 
The codegen harness is part of the all.bash test suite, but for
performance reasons only the codegen tests for the host machine's
GOARCH are enabled by default, and only on GOOS=linux.
 
To perform comprehensive tests for all the supported architectures
(even on a non-Linux system), one can run the following command:
 
$ ../../bin/go test cmd/internal/testdir -run='Test/codegen' -all_codegen -v
 
This is recommended after any change that affect the compiler's code.
 
The test harness compiles the tests with the same go toolchain that is
used to run the test. After writing tests for a newly added codegen
transformation, it can be useful to first run the test harness with a
toolchain from a released Go version (and verify that the new tests
fail), and then re-running the tests using the devel toolchain.
 
 
- Regexps comments syntax
 
Instructions to match are specified inside plain comments that start
with an architecture tag, followed by a colon and a quoted Go-style
regexp to be matched. For example, the following test:
 
func Sqrt(x float64) float64 {
// amd64:"SQRTSD"
// arm64:"FSQRTD"
return math.Sqrt(x)
}
 
verifies that math.Sqrt calls are intrinsified to a SQRTSD instruction
on amd64, and to a FSQRTD instruction on arm64.
 
It is possible to put multiple architectures checks into the same
line, as:
 
// amd64:"SQRTSD" arm64:"FSQRTD"
 
although this form should be avoided when doing so would make the
regexps line excessively long and difficult to read.
 
Comments that are on their own line will be matched against the first
subsequent non-comment line. Inline comments are also supported; the
regexp will be matched against the code found on the same line:
 
func Sqrt(x float64) float64 {
return math.Sqrt(x) // arm:"SQRTD"
}
 
It's possible to specify a space-separated list of regexps to be
matched. For example, the following test:
 
func TZ8(n uint8) int {
// amd64:"BSFL" "ORL [$]256"
return bits.TrailingZeros8(n)
}
 
verifies that the code generated for a bits.TrailingZeros8 call on
amd64 contains both a "BSFL" instruction and an "ORL $256".
 
Note that spaces are special - they will match any sequence of
whitespace (including tabs) in the printed assembly.
 
Regexps can be quoted using either " or `. Special characters must be
escaped accordingly. All of these are accepted, and equivalent:
 
// amd64:"ADDQ \\$3"
// amd64:`ADDQ \$3`
// amd64:"ADDQ [$]3"
 
and they'll match this assembly line:
 
ADDQ $3
 
Negative matches can be specified using a - before the quoted regexp.
For example:
 
func MoveSmall() {
x := [...]byte{1, 2, 3, 4, 5, 6, 7}
copy(x[1:], x[:]) // arm64:-".*memmove"
}
 
verifies that NO memmove call is present in the assembly generated for
the copy() line.
 
The expected number of matches for the regexp can be specified using a
positive number:
 
func fb(a [4]int) (r [4]int) {
// amd64:2`MOVUPS[^,]+, X0$` 2`MOVUPS X0,[^\n]+$`
return a
}
 
- Architecture specifiers
 
There are three different ways to specify on which architecture a test
should be run:
 
* Specify only the architecture (eg: "amd64"). This indicates that the
check should be run on all the supported architecture variants. For
instance, arm checks will be run against all supported GOARM
variations (5,6,7).
* Specify both the architecture and a variant, separated by a slash
(eg: "arm/7"). This means that the check will be run only on that
specific variant.
* Specify the operating system, the architecture and the variant,
separated by slashes (eg: "plan9/386/sse2", "plan9/amd64/"). This is
needed in the rare case that you need to do a codegen test affected
by a specific operating system; by default, tests are compiled only
targeting linux.
 
 
- Remarks, and Caveats
 
-- Write small test functions
 
As a general guideline, test functions should be small, to avoid
possible interactions between unrelated lines of code that may be
introduced, for example, by the compiler's optimization passes.
 
Any given line of Go code could get assigned more instructions than it
may appear from reading the source. In particular, matching all MOV
instructions should be avoided; the compiler may add them for
unrelated reasons and this may render the test ineffective.
 
-- Line matching logic
 
Regexps are always matched from the start of the instructions line.
This means, for example, that the "MULQ" regexp is equivalent to
"^MULQ" (^ representing the start of the line), and it will NOT match
the following assembly line:
 
IMULQ $99, AX
 
To force a match at any point of the line, ".*MULQ" should be used.
 
For the same reason, a negative regexp like -"memmove" is not enough
to make sure that no memmove call is included in the assembly. A
memmove call looks like this:
 
CALL runtime.memmove(SB)
 
To make sure that the "memmove" symbol does not appear anywhere in the
assembly, the negative regexp to be used is -".*memmove".