[dev.simd] all: merge master (ca0e035) into dev.simd

Conflicts:

- src/internal/goexperiment/flags.go

Merge List:

+ 2025-09-15 ca0e03560d cmd/link: remove support for windows/arm relocations
+ 2025-09-15 17a0fabc43 cmd/link: remove support for darwin/386 relocations
+ 2025-09-15 eb7c67fdc9 cmd/internal/obj/loong64: use the MOVVP instruction to optimize prologue
+ 2025-09-15 6b8d507508 cmd/internal/obj/riscv: implement vector segment load/store instructions
+ 2025-09-15 7ddbf4d820 cmd/asm: add double precision comparision testcases for riscv64
+ 2025-09-15 c39abe0658 runtime: fix TestSehUnwind
+ 2025-09-15 e3ed0fbe6a all: replace strings.Split with strings.SplitSeq
+ 2025-09-15 10bfddc91d all: remove redundant words in comment
+ 2025-09-15 2469e92d8c cmd/compile: combine doubling with shift on riscv64
+ 2025-09-15 aa83aee7de net/http: clarify panic conditions in Handle, HandleFunc, AddInsecureBypassPattern
+ 2025-09-15 b9e2977f1d crypto/internal/cryptotest: use linux-amd64_avx512 builder for SHA-NI
+ 2025-09-15 8105d0ccc2 cmd/go,crypto/internal/fips140: prevent using FIPS 140-3 mode with purego tag
+ 2025-09-15 7f70ca8726 crypto/internal/cryptotest: add MustSupportFIPS140
+ 2025-09-15 9e71d8a9f7 cmd/internal/testdir: re-enable default all codegen flag on linux-amd64
+ 2025-09-15 004858ccdd all: replace os.Getenv("GO_BUILDER_NAME") with testenv.Builder in tests
+ 2025-09-15 dbde15800c cmd: vendor x/tools@9fccddc
+ 2025-09-15 8ace10dad2 os: add (*Process).WithHandle
+ 2025-09-15 3573227fe3 os: add and use errProcessReleased
+ 2025-09-15 68c6a73380 internal/syscall/unix: add KernelVersionGE
+ 2025-09-15 e603e9834e cmd/link: support race mode with MSVC clang
+ 2025-09-15 e5ee1f2600 test/codegen: check zerobase for newobject on 0-sized types
+ 2025-09-15 77b93d41d5 net/http: add comments for transport gzip reader
+ 2025-09-15 30d510ca2d cmd/compile,cmd/gofmt: use reflect.TypeFor
+ 2025-09-15 8320fe8f0e runtime: deduplicate syscall assembly for darwin
+ 2025-09-14 080882a928 net: use context.AfterFunc in connect
+ 2025-09-12 ac803b5949 cmd/go/internal/work: copy vet tool's stdout to our stdout
+ 2025-09-12 889e71c2ac runtime: move Windows types and consts to internal/runtime/syscall/windows
+ 2025-09-12 cc8a6780ac vendor: update x/tools to 3adf0e9, and other repos
+ 2025-09-12 911455fe18 cmd/link: don't count tbss section in TestFlagD
+ 2025-09-12 f1fd13016a cmd/compile: optimize abi.Type.GCData loads
+ 2025-09-12 dc960d0bfe cmd/compile, reflect: further allow inlining of TypeFor
+ 2025-09-12 7acb0d0446 runtime: fix syscall9 on darwin/arm64
+ 2025-09-12 60c1ee9183 internal/goexperiment: add a sizespecializedmalloc goexperiment setting
+ 2025-09-12 c70713da82 cmd/link: support MSVC clang
+ 2025-09-12 9271bbbb80 internal/testenv: update Builder docs with LUCI builder names
+ 2025-09-12 a4e25c3d65 net,internal/poll: skip TestAllocs when race is enabled on Windows
+ 2025-09-12 dd8276657f cmd/asm, cmd/internal/obj: add riscv64 generic CSR ops
+ 2025-09-11 f37d75472d runtime: move mksizeclasses.go to runtime/_mkmalloc
+ 2025-09-11 73676e3223 cmd/go: run cgo and cgo compiles in their own actions
+ 2025-09-11 0e1b98993e testing: exit B.Loop early upon saturation
+ 2025-09-11 84e9ab3984 cmd/go/internal/work: remove deps[1]="fmt" vet hack

Change-Id: I1424228bcd9291c9ff29f6ae843d5b90652f237e
This commit is contained in:
Cherry Mui
2025-09-16 10:22:34 -04:00
188 changed files with 5869 additions and 2737 deletions

2
api/next/70352.txt Normal file
View File

@@ -0,0 +1,2 @@
pkg os, method (*Process) WithHandle(func(uintptr)) error #70352
pkg os, var ErrNoHandle error #70352

View File

@@ -0,0 +1,4 @@
The new [Process.WithHandle] method provides access to an internal process
handle on supported platforms (Linux 5.4 or later and Windows). On Linux,
the process handle is a pidfd. The method returns [ErrNoHandle] on unsupported
platforms or when no process handle is available.

View File

@@ -30,7 +30,7 @@ v%.zip:
go run ../../src/cmd/go/internal/fips140/mkzip.go v$*
# normally mkzip refuses to overwrite an existing zip file.
# make v1.2.3.rm removes the zip file and and unpacked
# make v1.2.3.rm removes the zip file and unpacked
# copy from the module cache.
v%.rm:
rm -f v$*.zip

View File

@@ -212,7 +212,7 @@ func copyLocalData(dstbase string) (pkgpath string, err error) {
// Copy all immediate files and testdata directories between
// the package being tested and the source root.
pkgpath = ""
for _, element := range strings.Split(finalPkgpath, string(filepath.Separator)) {
for element := range strings.SplitSeq(finalPkgpath, string(filepath.Separator)) {
if debug {
log.Printf("copying %s", pkgpath)
}

View File

@@ -11,6 +11,7 @@ package arch
import (
"cmd/internal/obj"
"cmd/internal/obj/riscv"
"fmt"
)
// IsRISCV64AMO reports whether op is an AMO instruction that requires
@@ -32,6 +33,20 @@ func IsRISCV64VTypeI(op obj.As) bool {
return op == riscv.AVSETVLI || op == riscv.AVSETIVLI
}
// IsRISCV64CSRO reports whether the op is an instruction that uses
// CSR symbolic names and whether that instruction expects a register
// or an immediate source operand.
func IsRISCV64CSRO(op obj.As) (imm bool, ok bool) {
switch op {
case riscv.ACSRRCI, riscv.ACSRRSI, riscv.ACSRRWI:
imm = true
fallthrough
case riscv.ACSRRC, riscv.ACSRRS, riscv.ACSRRW:
ok = true
}
return
}
var riscv64SpecialOperand map[string]riscv.SpecialOperand
// RISCV64SpecialOperand returns the internal representation of a special operand.
@@ -39,9 +54,21 @@ func RISCV64SpecialOperand(name string) riscv.SpecialOperand {
if riscv64SpecialOperand == nil {
// Generate mapping when function is first called.
riscv64SpecialOperand = map[string]riscv.SpecialOperand{}
for opd := riscv.SPOP_BEGIN; opd < riscv.SPOP_END; opd++ {
for opd := riscv.SPOP_RVV_BEGIN; opd < riscv.SPOP_RVV_END; opd++ {
riscv64SpecialOperand[opd.String()] = opd
}
// Add the CSRs
for csrCode, csrName := range riscv.CSRs {
// The set of RVV special operand names and the set of CSR special operands
// names are disjoint and so can safely share a single namespace. However,
// it's possible that a future update to the CSRs in inst.go could introduce
// a conflict. This check ensures that such a conflict does not go
// unnoticed.
if _, ok := riscv64SpecialOperand[csrName]; ok {
panic(fmt.Sprintf("riscv64 special operand %q redefined", csrName))
}
riscv64SpecialOperand[csrName] = riscv.SpecialOperand(int(csrCode) + int(riscv.SPOP_CSR_BEGIN))
}
}
if opd, ok := riscv64SpecialOperand[name]; ok {
return opd

View File

@@ -782,6 +782,21 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
prog.RegTo2 = a[2].Reg
break
}
// RISCV64 instructions that reference CSRs with symbolic names.
if isImm, ok := arch.IsRISCV64CSRO(op); ok {
if a[0].Type != obj.TYPE_CONST && isImm {
p.errorf("invalid value for first operand to %s instruction, must be a 5 bit unsigned immediate", op)
return
}
if a[1].Type != obj.TYPE_SPECIAL {
p.errorf("invalid value for second operand to %s instruction, must be a CSR name", op)
return
}
prog.AddRestSourceArgs([]obj.Addr{a[1]})
prog.From = a[0]
prog.To = a[2]
break
}
prog.From = a[0]
prog.Reg = p.getRegister(prog, op, &a[1])
prog.To = a[2]

View File

@@ -172,6 +172,24 @@ start:
SD X5, (X6) // 23305300
SD X5, 4(X6) // 23325300
// 7.1: CSR Instructions
CSRRC X0, CYCLE, X5 // f33200c0
CSRRC X0, CYCLE, X0 // 733000c0
CSRRC X10, CYCLE, X5 // f33205c0
CSRRC $2, TIME, X5 // f37211c0
CSRRCI $2, TIME, X5 // f37211c0
CSRRS X0, CYCLE, X5 // f32200c0
CSRRS X0, CYCLE, X0 // 732000c0
CSRRS X10, CYCLE, X5 // f32205c0
CSRRS $2, TIME, X5 // f36211c0
CSRRS X0, VLENB, X5 // f32220c2
CSRRSI $2, TIME, X5 // f36211c0
CSRRW X0, CYCLE, X5 // f31200c0
CSRRW X0, CYCLE, X0 // 731000c0
CSRRW X10, CYCLE, X5 // f31205c0
CSRRW $2, TIME, X5 // f35211c0
CSRRWI $2, TIME, X5 // f35211c0
// 8.1: Base Counters and Timers (Zicntr)
RDCYCLE X5 // f32200c0
RDTIME X5 // f32210c0
@@ -340,6 +358,11 @@ start:
FNMSUBD F1, F2, F3, F4 // 4b82201a
FNMADDD F1, F2, F3, F4 // 4f82201a
// 21.6: Double-Precision Floating-Point Compare Instructions
FEQD F0, F1, X7 // d3a300a2
FLTD F0, F1, X7 // d39300a2
FLED F0, F1, X7 // d38300a2
// 21.7: Double-Precision Floating-Point Classify Instruction
FCLASSD F0, X5 // d31200e2
@@ -520,6 +543,578 @@ start:
VSOXEI64V V3, V2, (X10) // a771250e
VSOXEI64V V3, V2, V0, (X10) // a771250c
// 31.7.8: Vector Load/Store Segment Instructions
// 31.7.8.1: Vector Unit-Stride Segment Loads and Stores
VLSEG2E8V (X10), V8 // 07040522
VLSEG2E16V (X10), V8 // 07540522
VLSEG2E32V (X10), V8 // 07640522
VLSEG2E64V (X10), V8 // 07740522
VLSEG2E8V (X10), V0, V8 // 07040520
VLSEG2E16V (X10), V0, V8 // 07540520
VLSEG2E32V (X10), V0, V8 // 07640520
VLSEG2E64V (X10), V0, V8 // 07740520
VLSEG3E8V (X10), V8 // 07040542
VLSEG3E16V (X10), V8 // 07540542
VLSEG3E32V (X10), V8 // 07640542
VLSEG3E64V (X10), V8 // 07740542
VLSEG3E8V (X10), V0, V8 // 07040540
VLSEG3E16V (X10), V0, V8 // 07540540
VLSEG3E32V (X10), V0, V8 // 07640540
VLSEG3E64V (X10), V0, V8 // 07740540
VLSEG4E8V (X10), V8 // 07040562
VLSEG4E16V (X10), V8 // 07540562
VLSEG4E32V (X10), V8 // 07640562
VLSEG4E64V (X10), V8 // 07740562
VLSEG4E8V (X10), V0, V8 // 07040560
VLSEG4E16V (X10), V0, V8 // 07540560
VLSEG4E32V (X10), V0, V8 // 07640560
VLSEG4E64V (X10), V0, V8 // 07740560
VLSEG5E8V (X10), V8 // 07040582
VLSEG5E16V (X10), V8 // 07540582
VLSEG5E32V (X10), V8 // 07640582
VLSEG5E64V (X10), V8 // 07740582
VLSEG5E8V (X10), V0, V8 // 07040580
VLSEG5E16V (X10), V0, V8 // 07540580
VLSEG5E32V (X10), V0, V8 // 07640580
VLSEG5E64V (X10), V0, V8 // 07740580
VLSEG6E8V (X10), V8 // 070405a2
VLSEG6E16V (X10), V8 // 075405a2
VLSEG6E32V (X10), V8 // 076405a2
VLSEG6E64V (X10), V8 // 077405a2
VLSEG6E8V (X10), V0, V8 // 070405a0
VLSEG6E16V (X10), V0, V8 // 075405a0
VLSEG6E32V (X10), V0, V8 // 076405a0
VLSEG6E64V (X10), V0, V8 // 077405a0
VLSEG7E8V (X10), V8 // 070405c2
VLSEG7E16V (X10), V8 // 075405c2
VLSEG7E32V (X10), V8 // 076405c2
VLSEG7E64V (X10), V8 // 077405c2
VLSEG7E8V (X10), V0, V8 // 070405c0
VLSEG7E16V (X10), V0, V8 // 075405c0
VLSEG7E32V (X10), V0, V8 // 076405c0
VLSEG7E64V (X10), V0, V8 // 077405c0
VLSEG8E8V (X10), V8 // 070405e2
VLSEG8E16V (X10), V8 // 075405e2
VLSEG8E32V (X10), V8 // 076405e2
VLSEG8E64V (X10), V8 // 077405e2
VLSEG8E8V (X10), V0, V8 // 070405e0
VLSEG8E16V (X10), V0, V8 // 075405e0
VLSEG8E32V (X10), V0, V8 // 076405e0
VLSEG8E64V (X10), V0, V8 // 077405e0
VSSEG2E8V V24, (X10) // 270c0522
VSSEG2E16V V24, (X10) // 275c0522
VSSEG2E32V V24, (X10) // 276c0522
VSSEG2E64V V24, (X10) // 277c0522
VSSEG2E8V V24, V0, (X10) // 270c0520
VSSEG2E16V V24, V0, (X10) // 275c0520
VSSEG2E32V V24, V0, (X10) // 276c0520
VSSEG2E64V V24, V0, (X10) // 277c0520
VSSEG3E8V V24, (X10) // 270c0542
VSSEG3E16V V24, (X10) // 275c0542
VSSEG3E32V V24, (X10) // 276c0542
VSSEG3E64V V24, (X10) // 277c0542
VSSEG3E8V V24, V0, (X10) // 270c0540
VSSEG3E16V V24, V0, (X10) // 275c0540
VSSEG3E32V V24, V0, (X10) // 276c0540
VSSEG3E64V V24, V0, (X10) // 277c0540
VSSEG4E8V V24, (X10) // 270c0562
VSSEG4E16V V24, (X10) // 275c0562
VSSEG4E32V V24, (X10) // 276c0562
VSSEG4E64V V24, (X10) // 277c0562
VSSEG4E8V V24, V0, (X10) // 270c0560
VSSEG4E16V V24, V0, (X10) // 275c0560
VSSEG4E32V V24, V0, (X10) // 276c0560
VSSEG4E64V V24, V0, (X10) // 277c0560
VSSEG5E8V V24, (X10) // 270c0582
VSSEG5E16V V24, (X10) // 275c0582
VSSEG5E32V V24, (X10) // 276c0582
VSSEG5E64V V24, (X10) // 277c0582
VSSEG5E8V V24, V0, (X10) // 270c0580
VSSEG5E16V V24, V0, (X10) // 275c0580
VSSEG5E32V V24, V0, (X10) // 276c0580
VSSEG5E64V V24, V0, (X10) // 277c0580
VSSEG6E8V V24, (X10) // 270c05a2
VSSEG6E16V V24, (X10) // 275c05a2
VSSEG6E32V V24, (X10) // 276c05a2
VSSEG6E64V V24, (X10) // 277c05a2
VSSEG6E8V V24, V0, (X10) // 270c05a0
VSSEG6E16V V24, V0, (X10) // 275c05a0
VSSEG6E32V V24, V0, (X10) // 276c05a0
VSSEG6E64V V24, V0, (X10) // 277c05a0
VSSEG7E8V V24, (X10) // 270c05c2
VSSEG7E16V V24, (X10) // 275c05c2
VSSEG7E32V V24, (X10) // 276c05c2
VSSEG7E64V V24, (X10) // 277c05c2
VSSEG7E8V V24, V0, (X10) // 270c05c0
VSSEG7E16V V24, V0, (X10) // 275c05c0
VSSEG7E32V V24, V0, (X10) // 276c05c0
VSSEG7E64V V24, V0, (X10) // 277c05c0
VSSEG8E8V V24, (X10) // 270c05e2
VSSEG8E16V V24, (X10) // 275c05e2
VSSEG8E32V V24, (X10) // 276c05e2
VSSEG8E64V V24, (X10) // 277c05e2
VSSEG8E8V V24, V0, (X10) // 270c05e0
VSSEG8E16V V24, V0, (X10) // 275c05e0
VSSEG8E32V V24, V0, (X10) // 276c05e0
VSSEG8E64V V24, V0, (X10) // 277c05e0
VLSEG2E8FFV (X10), V8 // 07040523
VLSEG2E16FFV (X10), V8 // 07540523
VLSEG2E32FFV (X10), V8 // 07640523
VLSEG2E64FFV (X10), V8 // 07740523
VLSEG2E8FFV (X10), V0, V8 // 07040521
VLSEG2E16FFV (X10), V0, V8 // 07540521
VLSEG2E32FFV (X10), V0, V8 // 07640521
VLSEG2E64FFV (X10), V0, V8 // 07740521
VLSEG3E8FFV (X10), V8 // 07040543
VLSEG3E16FFV (X10), V8 // 07540543
VLSEG3E32FFV (X10), V8 // 07640543
VLSEG3E64FFV (X10), V8 // 07740543
VLSEG3E8FFV (X10), V0, V8 // 07040541
VLSEG3E16FFV (X10), V0, V8 // 07540541
VLSEG3E32FFV (X10), V0, V8 // 07640541
VLSEG3E64FFV (X10), V0, V8 // 07740541
VLSEG4E8FFV (X10), V8 // 07040563
VLSEG4E16FFV (X10), V8 // 07540563
VLSEG4E32FFV (X10), V8 // 07640563
VLSEG4E64FFV (X10), V8 // 07740563
VLSEG4E8FFV (X10), V0, V8 // 07040561
VLSEG4E16FFV (X10), V0, V8 // 07540561
VLSEG4E32FFV (X10), V0, V8 // 07640561
VLSEG4E64FFV (X10), V0, V8 // 07740561
VLSEG5E8FFV (X10), V8 // 07040583
VLSEG5E16FFV (X10), V8 // 07540583
VLSEG5E32FFV (X10), V8 // 07640583
VLSEG5E64FFV (X10), V8 // 07740583
VLSEG5E8FFV (X10), V0, V8 // 07040581
VLSEG5E16FFV (X10), V0, V8 // 07540581
VLSEG5E32FFV (X10), V0, V8 // 07640581
VLSEG5E64FFV (X10), V0, V8 // 07740581
VLSEG6E8FFV (X10), V8 // 070405a3
VLSEG6E16FFV (X10), V8 // 075405a3
VLSEG6E32FFV (X10), V8 // 076405a3
VLSEG6E64FFV (X10), V8 // 077405a3
VLSEG6E8FFV (X10), V0, V8 // 070405a1
VLSEG6E16FFV (X10), V0, V8 // 075405a1
VLSEG6E32FFV (X10), V0, V8 // 076405a1
VLSEG6E64FFV (X10), V0, V8 // 077405a1
VLSEG7E8FFV (X10), V8 // 070405c3
VLSEG7E16FFV (X10), V8 // 075405c3
VLSEG7E32FFV (X10), V8 // 076405c3
VLSEG7E64FFV (X10), V8 // 077405c3
VLSEG7E8FFV (X10), V0, V8 // 070405c1
VLSEG7E16FFV (X10), V0, V8 // 075405c1
VLSEG7E32FFV (X10), V0, V8 // 076405c1
VLSEG7E64FFV (X10), V0, V8 // 077405c1
VLSEG8E8FFV (X10), V8 // 070405e3
VLSEG8E16FFV (X10), V8 // 075405e3
VLSEG8E32FFV (X10), V8 // 076405e3
VLSEG8E64FFV (X10), V8 // 077405e3
VLSEG8E8FFV (X10), V0, V8 // 070405e1
VLSEG8E16FFV (X10), V0, V8 // 075405e1
VLSEG8E32FFV (X10), V0, V8 // 076405e1
VLSEG8E64FFV (X10), V0, V8 // 077405e1
// 31.7.8.2: Vector Strided Segment Loads and Stores
VLSSEG2E8V (X10), X11, V8 // 0704b52a
VLSSEG2E16V (X10), X11, V8 // 0754b52a
VLSSEG2E32V (X10), X11, V8 // 0764b52a
VLSSEG2E64V (X10), X11, V8 // 0774b52a
VLSSEG2E8V (X10), X11, V0, V8 // 0704b528
VLSSEG2E16V (X10), X11, V0, V8 // 0754b528
VLSSEG2E32V (X10), X11, V0, V8 // 0764b528
VLSSEG2E64V (X10), X11, V0, V8 // 0774b528
VLSSEG3E8V (X10), X11, V8 // 0704b54a
VLSSEG3E16V (X10), X11, V8 // 0754b54a
VLSSEG3E32V (X10), X11, V8 // 0764b54a
VLSSEG3E64V (X10), X11, V8 // 0774b54a
VLSSEG3E8V (X10), X11, V0, V8 // 0704b548
VLSSEG3E16V (X10), X11, V0, V8 // 0754b548
VLSSEG3E32V (X10), X11, V0, V8 // 0764b548
VLSSEG3E64V (X10), X11, V0, V8 // 0774b548
VLSSEG4E8V (X10), X11, V8 // 0704b56a
VLSSEG4E16V (X10), X11, V8 // 0754b56a
VLSSEG4E32V (X10), X11, V8 // 0764b56a
VLSSEG4E64V (X10), X11, V8 // 0774b56a
VLSSEG4E8V (X10), X11, V0, V8 // 0704b568
VLSSEG4E16V (X10), X11, V0, V8 // 0754b568
VLSSEG4E32V (X10), X11, V0, V8 // 0764b568
VLSSEG4E64V (X10), X11, V0, V8 // 0774b568
VLSSEG5E8V (X10), X11, V8 // 0704b58a
VLSSEG5E16V (X10), X11, V8 // 0754b58a
VLSSEG5E32V (X10), X11, V8 // 0764b58a
VLSSEG5E64V (X10), X11, V8 // 0774b58a
VLSSEG5E8V (X10), X11, V0, V8 // 0704b588
VLSSEG5E16V (X10), X11, V0, V8 // 0754b588
VLSSEG5E32V (X10), X11, V0, V8 // 0764b588
VLSSEG5E64V (X10), X11, V0, V8 // 0774b588
VLSSEG6E8V (X10), X11, V8 // 0704b5aa
VLSSEG6E16V (X10), X11, V8 // 0754b5aa
VLSSEG6E32V (X10), X11, V8 // 0764b5aa
VLSSEG6E64V (X10), X11, V8 // 0774b5aa
VLSSEG6E8V (X10), X11, V0, V8 // 0704b5a8
VLSSEG6E16V (X10), X11, V0, V8 // 0754b5a8
VLSSEG6E32V (X10), X11, V0, V8 // 0764b5a8
VLSSEG6E64V (X10), X11, V0, V8 // 0774b5a8
VLSSEG7E8V (X10), X11, V8 // 0704b5ca
VLSSEG7E16V (X10), X11, V8 // 0754b5ca
VLSSEG7E32V (X10), X11, V8 // 0764b5ca
VLSSEG7E64V (X10), X11, V8 // 0774b5ca
VLSSEG7E8V (X10), X11, V0, V8 // 0704b5c8
VLSSEG7E16V (X10), X11, V0, V8 // 0754b5c8
VLSSEG7E32V (X10), X11, V0, V8 // 0764b5c8
VLSSEG7E64V (X10), X11, V0, V8 // 0774b5c8
VLSSEG8E8V (X10), X11, V8 // 0704b5ea
VLSSEG8E16V (X10), X11, V8 // 0754b5ea
VLSSEG8E32V (X10), X11, V8 // 0764b5ea
VLSSEG8E64V (X10), X11, V8 // 0774b5ea
VLSSEG8E8V (X10), X11, V0, V8 // 0704b5e8
VLSSEG8E16V (X10), X11, V0, V8 // 0754b5e8
VLSSEG8E32V (X10), X11, V0, V8 // 0764b5e8
VLSSEG8E64V (X10), X11, V0, V8 // 0774b5e8
VSSSEG2E8V V24, X11, (X10) // 270cb52a
VSSSEG2E16V V24, X11, (X10) // 275cb52a
VSSSEG2E32V V24, X11, (X10) // 276cb52a
VSSSEG2E64V V24, X11, (X10) // 277cb52a
VSSSEG2E8V V24, X11, V0, (X10) // 270cb528
VSSSEG2E16V V24, X11, V0, (X10) // 275cb528
VSSSEG2E32V V24, X11, V0, (X10) // 276cb528
VSSSEG2E64V V24, X11, V0, (X10) // 277cb528
VSSSEG3E8V V24, X11, (X10) // 270cb54a
VSSSEG3E16V V24, X11, (X10) // 275cb54a
VSSSEG3E32V V24, X11, (X10) // 276cb54a
VSSSEG3E64V V24, X11, (X10) // 277cb54a
VSSSEG3E8V V24, X11, V0, (X10) // 270cb548
VSSSEG3E16V V24, X11, V0, (X10) // 275cb548
VSSSEG3E32V V24, X11, V0, (X10) // 276cb548
VSSSEG3E64V V24, X11, V0, (X10) // 277cb548
VSSSEG4E8V V24, X11, (X10) // 270cb56a
VSSSEG4E16V V24, X11, (X10) // 275cb56a
VSSSEG4E32V V24, X11, (X10) // 276cb56a
VSSSEG4E64V V24, X11, (X10) // 277cb56a
VSSSEG4E8V V24, X11, V0, (X10) // 270cb568
VSSSEG4E16V V24, X11, V0, (X10) // 275cb568
VSSSEG4E32V V24, X11, V0, (X10) // 276cb568
VSSSEG4E64V V24, X11, V0, (X10) // 277cb568
VSSSEG5E8V V24, X11, (X10) // 270cb58a
VSSSEG5E16V V24, X11, (X10) // 275cb58a
VSSSEG5E32V V24, X11, (X10) // 276cb58a
VSSSEG5E64V V24, X11, (X10) // 277cb58a
VSSSEG5E8V V24, X11, V0, (X10) // 270cb588
VSSSEG5E16V V24, X11, V0, (X10) // 275cb588
VSSSEG5E32V V24, X11, V0, (X10) // 276cb588
VSSSEG5E64V V24, X11, V0, (X10) // 277cb588
VSSSEG6E8V V24, X11, (X10) // 270cb5aa
VSSSEG6E16V V24, X11, (X10) // 275cb5aa
VSSSEG6E32V V24, X11, (X10) // 276cb5aa
VSSSEG6E64V V24, X11, (X10) // 277cb5aa
VSSSEG6E8V V24, X11, V0, (X10) // 270cb5a8
VSSSEG6E16V V24, X11, V0, (X10) // 275cb5a8
VSSSEG6E32V V24, X11, V0, (X10) // 276cb5a8
VSSSEG6E64V V24, X11, V0, (X10) // 277cb5a8
VSSSEG7E8V V24, X11, (X10) // 270cb5ca
VSSSEG7E16V V24, X11, (X10) // 275cb5ca
VSSSEG7E32V V24, X11, (X10) // 276cb5ca
VSSSEG7E64V V24, X11, (X10) // 277cb5ca
VSSSEG7E8V V24, X11, V0, (X10) // 270cb5c8
VSSSEG7E16V V24, X11, V0, (X10) // 275cb5c8
VSSSEG7E32V V24, X11, V0, (X10) // 276cb5c8
VSSSEG7E64V V24, X11, V0, (X10) // 277cb5c8
VSSSEG8E8V V24, X11, (X10) // 270cb5ea
VSSSEG8E16V V24, X11, (X10) // 275cb5ea
VSSSEG8E32V V24, X11, (X10) // 276cb5ea
VSSSEG8E64V V24, X11, (X10) // 277cb5ea
VSSSEG8E8V V24, X11, V0, (X10) // 270cb5e8
VSSSEG8E16V V24, X11, V0, (X10) // 275cb5e8
VSSSEG8E32V V24, X11, V0, (X10) // 276cb5e8
VSSSEG8E64V V24, X11, V0, (X10) // 277cb5e8
// 31.7.8.3: Vector Indexed Segment Loads and Stores
VLUXSEG2EI8V (X10), V4, V8 // 07044526
VLUXSEG2EI16V (X10), V4, V8 // 07544526
VLUXSEG2EI32V (X10), V4, V8 // 07644526
VLUXSEG2EI64V (X10), V4, V8 // 07744526
VLUXSEG2EI8V (X10), V4, V0, V8 // 07044524
VLUXSEG2EI16V (X10), V4, V0, V8 // 07544524
VLUXSEG2EI32V (X10), V4, V0, V8 // 07644524
VLUXSEG2EI64V (X10), V4, V0, V8 // 07744524
VLUXSEG3EI8V (X10), V4, V8 // 07044546
VLUXSEG3EI16V (X10), V4, V8 // 07544546
VLUXSEG3EI32V (X10), V4, V8 // 07644546
VLUXSEG3EI64V (X10), V4, V8 // 07744546
VLUXSEG3EI8V (X10), V4, V0, V8 // 07044544
VLUXSEG3EI16V (X10), V4, V0, V8 // 07544544
VLUXSEG3EI32V (X10), V4, V0, V8 // 07644544
VLUXSEG3EI64V (X10), V4, V0, V8 // 07744544
VLUXSEG4EI8V (X10), V4, V8 // 07044566
VLUXSEG4EI16V (X10), V4, V8 // 07544566
VLUXSEG4EI32V (X10), V4, V8 // 07644566
VLUXSEG4EI64V (X10), V4, V8 // 07744566
VLUXSEG4EI8V (X10), V4, V0, V8 // 07044564
VLUXSEG4EI16V (X10), V4, V0, V8 // 07544564
VLUXSEG4EI32V (X10), V4, V0, V8 // 07644564
VLUXSEG4EI64V (X10), V4, V0, V8 // 07744564
VLUXSEG5EI8V (X10), V4, V8 // 07044586
VLUXSEG5EI16V (X10), V4, V8 // 07544586
VLUXSEG5EI32V (X10), V4, V8 // 07644586
VLUXSEG5EI64V (X10), V4, V8 // 07744586
VLUXSEG5EI8V (X10), V4, V0, V8 // 07044584
VLUXSEG5EI16V (X10), V4, V0, V8 // 07544584
VLUXSEG5EI32V (X10), V4, V0, V8 // 07644584
VLUXSEG5EI64V (X10), V4, V0, V8 // 07744584
VLUXSEG6EI8V (X10), V4, V8 // 070445a6
VLUXSEG6EI16V (X10), V4, V8 // 075445a6
VLUXSEG6EI32V (X10), V4, V8 // 076445a6
VLUXSEG6EI64V (X10), V4, V8 // 077445a6
VLUXSEG6EI8V (X10), V4, V0, V8 // 070445a4
VLUXSEG6EI16V (X10), V4, V0, V8 // 075445a4
VLUXSEG6EI32V (X10), V4, V0, V8 // 076445a4
VLUXSEG6EI64V (X10), V4, V0, V8 // 077445a4
VLOXSEG6EI8V (X10), V4, V8 // 070445ae
VLOXSEG6EI16V (X10), V4, V8 // 075445ae
VLOXSEG6EI32V (X10), V4, V8 // 076445ae
VLOXSEG6EI64V (X10), V4, V8 // 077445ae
VLOXSEG6EI8V (X10), V4, V0, V8 // 070445ac
VLOXSEG6EI16V (X10), V4, V0, V8 // 075445ac
VLOXSEG6EI32V (X10), V4, V0, V8 // 076445ac
VLOXSEG6EI64V (X10), V4, V0, V8 // 077445ac
VLUXSEG7EI8V (X10), V4, V8 // 070445c6
VLUXSEG7EI16V (X10), V4, V8 // 075445c6
VLUXSEG7EI32V (X10), V4, V8 // 076445c6
VLUXSEG7EI64V (X10), V4, V8 // 077445c6
VLUXSEG7EI8V (X10), V4, V0, V8 // 070445c4
VLUXSEG7EI16V (X10), V4, V0, V8 // 075445c4
VLUXSEG7EI32V (X10), V4, V0, V8 // 076445c4
VLUXSEG7EI64V (X10), V4, V0, V8 // 077445c4
VLUXSEG8EI8V (X10), V4, V8 // 070445e6
VLUXSEG8EI16V (X10), V4, V8 // 075445e6
VLUXSEG8EI32V (X10), V4, V8 // 076445e6
VLUXSEG8EI64V (X10), V4, V8 // 077445e6
VLUXSEG8EI8V (X10), V4, V0, V8 // 070445e4
VLUXSEG8EI16V (X10), V4, V0, V8 // 075445e4
VLUXSEG8EI32V (X10), V4, V0, V8 // 076445e4
VLUXSEG8EI64V (X10), V4, V0, V8 // 077445e4
VSUXSEG2EI8V V24, V4, (X10) // 270c4526
VSUXSEG2EI16V V24, V4, (X10) // 275c4526
VSUXSEG2EI32V V24, V4, (X10) // 276c4526
VSUXSEG2EI64V V24, V4, (X10) // 277c4526
VSUXSEG2EI8V V24, V4, V0, (X10) // 270c4524
VSUXSEG2EI16V V24, V4, V0, (X10) // 275c4524
VSUXSEG2EI32V V24, V4, V0, (X10) // 276c4524
VSUXSEG2EI64V V24, V4, V0, (X10) // 277c4524
VSUXSEG3EI8V V24, V4, (X10) // 270c4546
VSUXSEG3EI16V V24, V4, (X10) // 275c4546
VSUXSEG3EI32V V24, V4, (X10) // 276c4546
VSUXSEG3EI64V V24, V4, (X10) // 277c4546
VSUXSEG3EI8V V24, V4, V0, (X10) // 270c4544
VSUXSEG3EI16V V24, V4, V0, (X10) // 275c4544
VSUXSEG3EI32V V24, V4, V0, (X10) // 276c4544
VSUXSEG3EI64V V24, V4, V0, (X10) // 277c4544
VSUXSEG4EI8V V24, V4, (X10) // 270c4566
VSUXSEG4EI16V V24, V4, (X10) // 275c4566
VSUXSEG4EI32V V24, V4, (X10) // 276c4566
VSUXSEG4EI64V V24, V4, (X10) // 277c4566
VSUXSEG4EI8V V24, V4, V0, (X10) // 270c4564
VSUXSEG4EI16V V24, V4, V0, (X10) // 275c4564
VSUXSEG4EI32V V24, V4, V0, (X10) // 276c4564
VSUXSEG4EI64V V24, V4, V0, (X10) // 277c4564
VSUXSEG5EI8V V24, V4, (X10) // 270c4586
VSUXSEG5EI16V V24, V4, (X10) // 275c4586
VSUXSEG5EI32V V24, V4, (X10) // 276c4586
VSUXSEG5EI64V V24, V4, (X10) // 277c4586
VSUXSEG5EI8V V24, V4, V0, (X10) // 270c4584
VSUXSEG5EI16V V24, V4, V0, (X10) // 275c4584
VSUXSEG5EI32V V24, V4, V0, (X10) // 276c4584
VSUXSEG5EI64V V24, V4, V0, (X10) // 277c4584
VSUXSEG6EI8V V24, V4, (X10) // 270c45a6
VSUXSEG6EI16V V24, V4, (X10) // 275c45a6
VSUXSEG6EI32V V24, V4, (X10) // 276c45a6
VSUXSEG6EI64V V24, V4, (X10) // 277c45a6
VSUXSEG6EI8V V24, V4, V0, (X10) // 270c45a4
VSUXSEG6EI16V V24, V4, V0, (X10) // 275c45a4
VSUXSEG6EI32V V24, V4, V0, (X10) // 276c45a4
VSUXSEG6EI64V V24, V4, V0, (X10) // 277c45a4
VSUXSEG7EI8V V24, V4, (X10) // 270c45c6
VSUXSEG7EI16V V24, V4, (X10) // 275c45c6
VSUXSEG7EI32V V24, V4, (X10) // 276c45c6
VSUXSEG7EI64V V24, V4, (X10) // 277c45c6
VSUXSEG7EI8V V24, V4, V0, (X10) // 270c45c4
VSUXSEG7EI16V V24, V4, V0, (X10) // 275c45c4
VSUXSEG7EI32V V24, V4, V0, (X10) // 276c45c4
VSUXSEG7EI64V V24, V4, V0, (X10) // 277c45c4
VSUXSEG8EI8V V24, V4, (X10) // 270c45e6
VSUXSEG8EI16V V24, V4, (X10) // 275c45e6
VSUXSEG8EI32V V24, V4, (X10) // 276c45e6
VSUXSEG8EI64V V24, V4, (X10) // 277c45e6
VSUXSEG8EI8V V24, V4, V0, (X10) // 270c45e4
VSUXSEG8EI16V V24, V4, V0, (X10) // 275c45e4
VSUXSEG8EI32V V24, V4, V0, (X10) // 276c45e4
VSUXSEG8EI64V V24, V4, V0, (X10) // 277c45e4
VLOXSEG2EI8V (X10), V4, V8 // 0704452e
VLOXSEG2EI16V (X10), V4, V8 // 0754452e
VLOXSEG2EI32V (X10), V4, V8 // 0764452e
VLOXSEG2EI64V (X10), V4, V8 // 0774452e
VLOXSEG2EI8V (X10), V4, V0, V8 // 0704452c
VLOXSEG2EI16V (X10), V4, V0, V8 // 0754452c
VLOXSEG2EI32V (X10), V4, V0, V8 // 0764452c
VLOXSEG2EI64V (X10), V4, V0, V8 // 0774452c
VLOXSEG3EI8V (X10), V4, V8 // 0704454e
VLOXSEG3EI16V (X10), V4, V8 // 0754454e
VLOXSEG3EI32V (X10), V4, V8 // 0764454e
VLOXSEG3EI64V (X10), V4, V8 // 0774454e
VLOXSEG3EI8V (X10), V4, V0, V8 // 0704454c
VLOXSEG3EI16V (X10), V4, V0, V8 // 0754454c
VLOXSEG3EI32V (X10), V4, V0, V8 // 0764454c
VLOXSEG3EI64V (X10), V4, V0, V8 // 0774454c
VLOXSEG4EI8V (X10), V4, V8 // 0704456e
VLOXSEG4EI16V (X10), V4, V8 // 0754456e
VLOXSEG4EI32V (X10), V4, V8 // 0764456e
VLOXSEG4EI64V (X10), V4, V8 // 0774456e
VLOXSEG4EI8V (X10), V4, V0, V8 // 0704456c
VLOXSEG4EI16V (X10), V4, V0, V8 // 0754456c
VLOXSEG4EI32V (X10), V4, V0, V8 // 0764456c
VLOXSEG4EI64V (X10), V4, V0, V8 // 0774456c
VLOXSEG5EI8V (X10), V4, V8 // 0704458e
VLOXSEG5EI16V (X10), V4, V8 // 0754458e
VLOXSEG5EI32V (X10), V4, V8 // 0764458e
VLOXSEG5EI64V (X10), V4, V8 // 0774458e
VLOXSEG5EI8V (X10), V4, V0, V8 // 0704458c
VLOXSEG5EI16V (X10), V4, V0, V8 // 0754458c
VLOXSEG5EI32V (X10), V4, V0, V8 // 0764458c
VLOXSEG5EI64V (X10), V4, V0, V8 // 0774458c
VLOXSEG7EI8V (X10), V4, V8 // 070445ce
VLOXSEG7EI16V (X10), V4, V8 // 075445ce
VLOXSEG7EI32V (X10), V4, V8 // 076445ce
VLOXSEG7EI64V (X10), V4, V8 // 077445ce
VLOXSEG7EI8V (X10), V4, V0, V8 // 070445cc
VLOXSEG7EI16V (X10), V4, V0, V8 // 075445cc
VLOXSEG7EI32V (X10), V4, V0, V8 // 076445cc
VLOXSEG7EI64V (X10), V4, V0, V8 // 077445cc
VLOXSEG8EI8V (X10), V4, V8 // 070445ee
VLOXSEG8EI16V (X10), V4, V8 // 075445ee
VLOXSEG8EI32V (X10), V4, V8 // 076445ee
VLOXSEG8EI64V (X10), V4, V8 // 077445ee
VLOXSEG8EI8V (X10), V4, V0, V8 // 070445ec
VLOXSEG8EI16V (X10), V4, V0, V8 // 075445ec
VLOXSEG8EI32V (X10), V4, V0, V8 // 076445ec
VLOXSEG8EI64V (X10), V4, V0, V8 // 077445ec
VSOXSEG2EI8V V24, V4, (X10) // 270c452e
VSOXSEG2EI16V V24, V4, (X10) // 275c452e
VSOXSEG2EI32V V24, V4, (X10) // 276c452e
VSOXSEG2EI64V V24, V4, (X10) // 277c452e
VSOXSEG2EI8V V24, V4, V0, (X10) // 270c452c
VSOXSEG2EI16V V24, V4, V0, (X10) // 275c452c
VSOXSEG2EI32V V24, V4, V0, (X10) // 276c452c
VSOXSEG2EI64V V24, V4, V0, (X10) // 277c452c
VSOXSEG3EI8V V24, V4, (X10) // 270c454e
VSOXSEG3EI16V V24, V4, (X10) // 275c454e
VSOXSEG3EI32V V24, V4, (X10) // 276c454e
VSOXSEG3EI64V V24, V4, (X10) // 277c454e
VSOXSEG3EI8V V24, V4, V0, (X10) // 270c454c
VSOXSEG3EI16V V24, V4, V0, (X10) // 275c454c
VSOXSEG3EI32V V24, V4, V0, (X10) // 276c454c
VSOXSEG3EI64V V24, V4, V0, (X10) // 277c454c
VSOXSEG4EI8V V24, V4, (X10) // 270c456e
VSOXSEG4EI16V V24, V4, (X10) // 275c456e
VSOXSEG4EI32V V24, V4, (X10) // 276c456e
VSOXSEG4EI64V V24, V4, (X10) // 277c456e
VSOXSEG4EI8V V24, V4, V0, (X10) // 270c456c
VSOXSEG4EI16V V24, V4, V0, (X10) // 275c456c
VSOXSEG4EI32V V24, V4, V0, (X10) // 276c456c
VSOXSEG4EI64V V24, V4, V0, (X10) // 277c456c
VSOXSEG5EI8V V24, V4, (X10) // 270c458e
VSOXSEG5EI16V V24, V4, (X10) // 275c458e
VSOXSEG5EI32V V24, V4, (X10) // 276c458e
VSOXSEG5EI64V V24, V4, (X10) // 277c458e
VSOXSEG5EI8V V24, V4, V0, (X10) // 270c458c
VSOXSEG5EI16V V24, V4, V0, (X10) // 275c458c
VSOXSEG5EI32V V24, V4, V0, (X10) // 276c458c
VSOXSEG5EI64V V24, V4, V0, (X10) // 277c458c
VSOXSEG6EI8V V24, V4, (X10) // 270c45ae
VSOXSEG6EI16V V24, V4, (X10) // 275c45ae
VSOXSEG6EI32V V24, V4, (X10) // 276c45ae
VSOXSEG6EI64V V24, V4, (X10) // 277c45ae
VSOXSEG6EI8V V24, V4, V0, (X10) // 270c45ac
VSOXSEG6EI16V V24, V4, V0, (X10) // 275c45ac
VSOXSEG6EI32V V24, V4, V0, (X10) // 276c45ac
VSOXSEG6EI64V V24, V4, V0, (X10) // 277c45ac
VSOXSEG7EI8V V24, V4, (X10) // 270c45ce
VSOXSEG7EI16V V24, V4, (X10) // 275c45ce
VSOXSEG7EI32V V24, V4, (X10) // 276c45ce
VSOXSEG7EI64V V24, V4, (X10) // 277c45ce
VSOXSEG7EI8V V24, V4, V0, (X10) // 270c45cc
VSOXSEG7EI16V V24, V4, V0, (X10) // 275c45cc
VSOXSEG7EI32V V24, V4, V0, (X10) // 276c45cc
VSOXSEG7EI64V V24, V4, V0, (X10) // 277c45cc
VSOXSEG8EI8V V24, V4, (X10) // 270c45ee
VSOXSEG8EI16V V24, V4, (X10) // 275c45ee
VSOXSEG8EI32V V24, V4, (X10) // 276c45ee
VSOXSEG8EI64V V24, V4, (X10) // 277c45ee
VSOXSEG8EI8V V24, V4, V0, (X10) // 270c45ec
VSOXSEG8EI16V V24, V4, V0, (X10) // 275c45ec
VSOXSEG8EI32V V24, V4, V0, (X10) // 276c45ec
VSOXSEG8EI64V V24, V4, V0, (X10) // 277c45ec
// 31.7.9: Vector Load/Store Whole Register Instructions
VL1RV (X10), V3 // 87018502
VL1RE8V (X10), V3 // 87018502

View File

@@ -3,6 +3,27 @@
// license that can be found in the LICENSE file.
TEXT errors(SB),$0
CSRRC (X10), CYCLE, X5 // ERROR "integer register or immediate expected for 1st operand"
CSRRC X0, TU, X5 // ERROR "unknown CSR"
CSRRC X0, CYCLE // ERROR "missing CSR name"
CSRRC X0, CYCLE, (X10) // ERROR "needs an integer register output"
CSRRC $-1, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRCI $32, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRCI $1, TIME, (X15) // ERROR "needs an integer register output"
CSRRS (X10), CYCLE, X5 // ERROR "integer register or immediate expected for 1st operand"
CSRRS X0, CYCLE, (X10) // ERROR "needs an integer register output"
CSRRS X0, TU, X5 // ERROR "unknown CSR"
CSRRS X0, CYCLE // ERROR "missing CSR name"
CSRRS $-1, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRSI $32, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRSI $1, TIME, (X15) // ERROR "needs an integer register output"
CSRRW (X10), CYCLE, X5 // ERROR "integer register or immediate expected for 1st operand"
CSRRW X0, TU, X5 // ERROR "unknown CSR"
CSRRW X0, CYCLE // ERROR "missing CSR name"
CSRRW X0, CYCLE, (X5) // ERROR "needs an integer register output"
CSRRW $-1, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRWI $32, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRWI $1, TIME, (X15) // ERROR "needs an integer register output"
MOV $errors(SB), (X5) // ERROR "address load must target register"
MOV $8(SP), (X5) // ERROR "address load must target register"
MOVB $8(SP), X5 // ERROR "unsupported address load"
@@ -59,6 +80,15 @@ TEXT errors(SB),$0
VSUXEI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLOXEI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSOXEI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLSEG2E8V (X10), V1, V3 // ERROR "invalid vector mask register"
VLSEG2E8FFV (X10), V1, V3 // ERROR "invalid vector mask register"
VSSEG2E8V V3, V1, (X10) // ERROR "invalid vector mask register"
VLSSEG2E8V (X10), X10, V1, V3 // ERROR "invalid vector mask register"
VSSSEG2E8V V3, X11, V1, (X10) // ERROR "invalid vector mask register"
VLUXSEG2EI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSUXSEG2EI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLOXSEG2EI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSOXSEG2EI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VL1RV (X10), V0, V3 // ERROR "too many operands for instruction"
VS1RV V3, V0, (X11) // ERROR "too many operands for instruction"
VADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"

View File

@@ -43,6 +43,33 @@ TEXT validation(SB),$0
VSOXEI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSOXEI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSOXEI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VLSEG2E8V (X10), X10 // ERROR "expected vector register in vd position"
VLSEG2E8V (V1), V3 // ERROR "expected integer register in rs1 position"
VLSEG2E8FFV (X10), X10 // ERROR "expected vector register in vd position"
VLSEG2E8FFV (V1), V3 // ERROR "expected integer register in rs1 position"
VSSEG2E8V X10, (X10) // ERROR "expected vector register in vs1 position"
VSSEG2E8V V3, (V1) // ERROR "expected integer register in rd position"
VLSSEG2E8V (X10), V3 // ERROR "expected integer register in rs2 position"
VLSSEG2E8V (X10), X10, X11 // ERROR "expected vector register in vd position"
VLSSEG2E8V (V1), X10, V3 // ERROR "expected integer register in rs1 position"
VLSSEG2E8V (X10), V1, V0, V3 // ERROR "expected integer register in rs2 position"
VSSSEG2E8V V3, (X10) // ERROR "expected integer register in rs2 position"
VSSSEG2E8V X10, X11, (X10) // ERROR "expected vector register in vd position"
VSSSEG2E8V V3, X11, (V1) // ERROR "expected integer register in rs1 position"
VSSSEG2E8V V3, V1, V0, (X10) // ERROR "expected integer register in rs2 position"
VLUXSEG2EI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXSEG2EI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXSEG2EI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLUXSEG2EI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSUXSEG2EI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSUXSEG2EI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSUXSEG2EI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VLOXSEG2EI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLOXSEG2EI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLOXSEG2EI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSOXSEG2EI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSOXSEG2EI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSOXSEG2EI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VL1RV (X10), X10 // ERROR "expected vector register in vd position"
VL1RV (V1), V3 // ERROR "expected integer register in rs1 position"
VS1RV X11, (X11) // ERROR "expected vector register in vs1 position"

View File

@@ -251,7 +251,7 @@ func (f *File) loadDefines(gccOptions []string) bool {
stdout := gccDefines(b.Bytes(), gccOptions)
var gccIsClang bool
for _, line := range strings.Split(stdout, "\n") {
for line := range strings.SplitSeq(stdout, "\n") {
if len(line) < 9 || line[0:7] != "#define" {
continue
}
@@ -428,7 +428,7 @@ func (p *Package) guessKinds(f *File) []*Name {
notDeclared
)
sawUnmatchedErrors := false
for _, line := range strings.Split(stderr, "\n") {
for line := range strings.SplitSeq(stderr, "\n") {
// Ignore warnings and random comments, with one
// exception: newer GCC versions will sometimes emit
// an error on a macro #define with a note referring

View File

@@ -447,7 +447,7 @@ func issue7978check(t *testing.T, wantFunc string, badFunc string, depth int) {
runtime.GC()
buf := make([]byte, 65536)
trace := string(buf[:runtime.Stack(buf, true)])
for _, goroutine := range strings.Split(trace, "\n\n") {
for goroutine := range strings.SplitSeq(trace, "\n\n") {
if strings.Contains(goroutine, "test.issue7978go") {
trace := strings.Split(goroutine, "\n")
// look for the expected function in the stack

View File

@@ -58,7 +58,7 @@ func TestMain(m *testing.M) {
}
func testMain(m *testing.M) int {
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
if testing.Short() && testenv.Builder() == "" {
globalSkip = func(t testing.TB) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
return m.Run()
}

View File

@@ -44,7 +44,7 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
log.SetFlags(log.Lshortfile)
flag.Parse()
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
if testing.Short() && testenv.Builder() == "" {
globalSkip = func(t *testing.T) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
return m.Run()
}

View File

@@ -46,7 +46,7 @@ func prettyPrintf(format string, args ...interface{}) {
}
func testMain(m *testing.M) int {
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
if testing.Short() && testenv.Builder() == "" {
globalSkip = func(t *testing.T) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
return m.Run()
}

View File

@@ -96,7 +96,7 @@ func goCmd(t *testing.T, args ...string) string {
// TestMain calls testMain so that the latter can use defer (TestMain exits with os.Exit).
func testMain(m *testing.M) (int, error) {
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
if testing.Short() && testenv.Builder() == "" {
globalSkip = func(t testing.TB) { t.Skip("short mode and $GO_BUILDER_NAME not set") }
return m.Run(), nil
}
@@ -554,7 +554,7 @@ func checkPIE(t *testing.T, name string) {
}
func TestTrivialPIE(t *testing.T) {
if strings.HasSuffix(os.Getenv("GO_BUILDER_NAME"), "-alpine") {
if strings.Contains(testenv.Builder(), "-alpine") {
t.Skip("skipping on alpine until issue #54354 resolved")
}
globalSkip(t)

View File

@@ -383,14 +383,14 @@ func ParseFlags() {
// See the comment on type CmdFlags for the rules.
func registerFlags() {
var (
boolType = reflect.TypeOf(bool(false))
intType = reflect.TypeOf(int(0))
stringType = reflect.TypeOf(string(""))
ptrBoolType = reflect.TypeOf(new(bool))
ptrIntType = reflect.TypeOf(new(int))
ptrStringType = reflect.TypeOf(new(string))
countType = reflect.TypeOf(CountFlag(0))
funcType = reflect.TypeOf((func(string))(nil))
boolType = reflect.TypeFor[bool]()
intType = reflect.TypeFor[int]()
stringType = reflect.TypeFor[string]()
ptrBoolType = reflect.TypeFor[*bool]()
ptrIntType = reflect.TypeFor[*int]()
ptrStringType = reflect.TypeFor[*string]()
countType = reflect.TypeFor[CountFlag]()
funcType = reflect.TypeFor[func(string)]()
)
v := reflect.ValueOf(&Flag).Elem()
@@ -570,7 +570,7 @@ func readEmbedCfg(file string) {
// parseSpectre parses the spectre configuration from the string s.
func parseSpectre(s string) {
for _, f := range strings.Split(s, ",") {
for f := range strings.SplitSeq(s, ",") {
f = strings.TrimSpace(f)
switch f {
default:

View File

@@ -1194,7 +1194,7 @@ func dumpNode(w io.Writer, n Node, depth int) {
}
}
var nodeType = reflect.TypeOf((*Node)(nil)).Elem()
var nodeType = reflect.TypeFor[Node]()
func dumpNodes(w io.Writer, list Nodes, depth int) {
if len(list) == 0 {

View File

@@ -1493,7 +1493,7 @@ func (lv *Liveness) emitStackObjects() *obj.LSym {
if sz != int64(int32(sz)) {
base.Fatalf("stack object too big: %v of type %v, size %d", v, t, sz)
}
lsym, ptrBytes := reflectdata.GCSym(t)
lsym, ptrBytes := reflectdata.GCSym(t, false)
off = objw.Uint32(x, off, uint32(sz))
off = objw.Uint32(x, off, uint32(ptrBytes))
off = objw.SymPtrOff(x, off, lsym)

View File

@@ -717,6 +717,10 @@ func writeType(t *types.Type) *obj.LSym {
}
s.SetSiggen(true)
if !tbase.HasShape() {
TypeLinksym(t) // ensure lsym.Extra is set
}
if !NeedEmit(tbase) {
if i := typecheck.BaseTypeIndex(t); i >= 0 {
lsym.Pkg = tbase.Sym().Pkg.Prefix
@@ -1225,7 +1229,7 @@ func typesStrCmp(a, b typeAndStr) int {
// GC information is always a bitmask, never a gc program.
// GCSym may be called in concurrent backend, so it does not emit the symbol
// content.
func GCSym(t *types.Type) (lsym *obj.LSym, ptrdata int64) {
func GCSym(t *types.Type, onDemandAllowed bool) (lsym *obj.LSym, ptrdata int64) {
// Record that we need to emit the GC symbol.
gcsymmu.Lock()
if _, ok := gcsymset[t]; !ok {
@@ -1233,7 +1237,7 @@ func GCSym(t *types.Type) (lsym *obj.LSym, ptrdata int64) {
}
gcsymmu.Unlock()
lsym, _, ptrdata = dgcsym(t, false, false)
lsym, _, ptrdata = dgcsym(t, false, onDemandAllowed)
return
}

View File

@@ -49,25 +49,25 @@ func Init() {
// Note: this has to be called explicitly instead of being
// an init function so it runs after the types package has
// been properly initialized.
Type = FromReflect(reflect.TypeOf(abi.Type{}))
ArrayType = FromReflect(reflect.TypeOf(abi.ArrayType{}))
ChanType = FromReflect(reflect.TypeOf(abi.ChanType{}))
FuncType = FromReflect(reflect.TypeOf(abi.FuncType{}))
InterfaceType = FromReflect(reflect.TypeOf(abi.InterfaceType{}))
MapType = FromReflect(reflect.TypeOf(abi.MapType{}))
PtrType = FromReflect(reflect.TypeOf(abi.PtrType{}))
SliceType = FromReflect(reflect.TypeOf(abi.SliceType{}))
StructType = FromReflect(reflect.TypeOf(abi.StructType{}))
Type = FromReflect(reflect.TypeFor[abi.Type]())
ArrayType = FromReflect(reflect.TypeFor[abi.ArrayType]())
ChanType = FromReflect(reflect.TypeFor[abi.ChanType]())
FuncType = FromReflect(reflect.TypeFor[abi.FuncType]())
InterfaceType = FromReflect(reflect.TypeFor[abi.InterfaceType]())
MapType = FromReflect(reflect.TypeFor[abi.MapType]())
PtrType = FromReflect(reflect.TypeFor[abi.PtrType]())
SliceType = FromReflect(reflect.TypeFor[abi.SliceType]())
StructType = FromReflect(reflect.TypeFor[abi.StructType]())
IMethod = FromReflect(reflect.TypeOf(abi.Imethod{}))
Method = FromReflect(reflect.TypeOf(abi.Method{}))
StructField = FromReflect(reflect.TypeOf(abi.StructField{}))
UncommonType = FromReflect(reflect.TypeOf(abi.UncommonType{}))
IMethod = FromReflect(reflect.TypeFor[abi.Imethod]())
Method = FromReflect(reflect.TypeFor[abi.Method]())
StructField = FromReflect(reflect.TypeFor[abi.StructField]())
UncommonType = FromReflect(reflect.TypeFor[abi.UncommonType]())
InterfaceSwitch = FromReflect(reflect.TypeOf(abi.InterfaceSwitch{}))
TypeAssert = FromReflect(reflect.TypeOf(abi.TypeAssert{}))
InterfaceSwitch = FromReflect(reflect.TypeFor[abi.InterfaceSwitch]())
TypeAssert = FromReflect(reflect.TypeFor[abi.TypeAssert]())
ITab = FromReflect(reflect.TypeOf(abi.ITab{}))
ITab = FromReflect(reflect.TypeFor[abi.ITab]())
// Make sure abi functions are correct. These functions are used
// by the linker which doesn't have the ability to do type layout,

View File

@@ -782,6 +782,10 @@
(SRLI [x] (MOVDconst [y])) => (MOVDconst [int64(uint64(y) >> uint32(x))])
(SRAI [x] (MOVDconst [y])) => (MOVDconst [int64(y) >> uint32(x)])
// Combine doubling via addition with shift.
(SLLI <t> [c] (ADD x x)) && c < t.Size() * 8 - 1 => (SLLI <t> [c+1] x)
(SLLI <t> [c] (ADD x x)) && c >= t.Size() * 8 - 1 => (MOVDconst [0])
// SLTI/SLTIU with constants.
(SLTI [x] (MOVDconst [y])) => (MOVDconst [b2i(int64(y) < int64(x))])
(SLTIU [x] (MOVDconst [y])) => (MOVDconst [b2i(uint64(y) < uint64(x))])

View File

@@ -2067,7 +2067,7 @@ func isFixedLoad(v *Value, sym Sym, off int64) bool {
for _, f := range rttype.Type.Fields() {
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
switch f.Sym.Name {
case "Size_", "PtrBytes", "Hash", "Kind_":
case "Size_", "PtrBytes", "Hash", "Kind_", "GCData":
return true
default:
// fmt.Println("unknown field", f.Sym.Name)
@@ -2147,6 +2147,12 @@ func rewriteFixedLoad(v *Value, sym Sym, sb *Value, off int64) *Value {
v.reset(OpConst8)
v.AuxInt = int64(reflectdata.ABIKindOfType(t))
return v
case "GCData":
gcdata, _ := reflectdata.GCSym(t, true)
v.reset(OpAddr)
v.Aux = symToAux(gcdata)
v.AddArg(sb)
return v
default:
base.Fatalf("unknown field %s for fixedLoad of %s at offset %d", f.Sym.Name, lsym.Name, off)
}

View File

@@ -7185,6 +7185,42 @@ func rewriteValueRISCV64_OpRISCV64SLLI(v *Value) bool {
v.AuxInt = int64ToAuxInt(y << uint32(x))
return true
}
// match: (SLLI <t> [c] (ADD x x))
// cond: c < t.Size() * 8 - 1
// result: (SLLI <t> [c+1] x)
for {
t := v.Type
c := auxIntToInt64(v.AuxInt)
if v_0.Op != OpRISCV64ADD {
break
}
x := v_0.Args[1]
if x != v_0.Args[0] || !(c < t.Size()*8-1) {
break
}
v.reset(OpRISCV64SLLI)
v.Type = t
v.AuxInt = int64ToAuxInt(c + 1)
v.AddArg(x)
return true
}
// match: (SLLI <t> [c] (ADD x x))
// cond: c >= t.Size() * 8 - 1
// result: (MOVDconst [0])
for {
t := v.Type
c := auxIntToInt64(v.AuxInt)
if v_0.Op != OpRISCV64ADD {
break
}
x := v_0.Args[1]
if x != v_0.Args[0] || !(c >= t.Size()*8-1) {
break
}
v.reset(OpRISCV64MOVDconst)
v.AuxInt = int64ToAuxInt(0)
return true
}
return false
}
func rewriteValueRISCV64_OpRISCV64SLLW(v *Value) bool {

View File

@@ -380,7 +380,7 @@ func findgoversion() string {
if i := strings.Index(b, "\n"); i >= 0 {
rest := b[i+1:]
b = chomp(b[:i])
for _, line := range strings.Split(rest, "\n") {
for line := range strings.SplitSeq(rest, "\n") {
f := strings.Fields(line)
if len(f) == 0 {
continue
@@ -1137,7 +1137,7 @@ func shouldbuild(file, pkg string) bool {
}
// Check file contents for //go:build lines.
for _, p := range strings.Split(readfile(file), "\n") {
for p := range strings.SplitSeq(readfile(file), "\n") {
p = strings.TrimSpace(p)
if p == "" {
continue
@@ -2016,7 +2016,7 @@ func cmdlist() {
}
func setNoOpt() {
for _, gcflag := range strings.Split(gogcflags, " ") {
for gcflag := range strings.SplitSeq(gogcflags, " ") {
if gcflag == "-N" || gcflag == "-l" {
noOpt = true
break

View File

@@ -1825,6 +1825,8 @@ func isEnvSet(evar string) bool {
func (t *tester) fipsSupported() bool {
// Keep this in sync with [crypto/internal/fips140.Supported].
// We don't test with the purego tag, so no need to check it.
// Use GOFIPS140 or GOEXPERIMENT=boringcrypto, but not both.
if strings.Contains(goexperiment, "boringcrypto") {
return false

View File

@@ -271,7 +271,7 @@ func readVERSION(goroot string) (version string, t time.Time) {
log.Fatal(err)
}
version, rest, _ := strings.Cut(string(data), "\n")
for _, line := range strings.Split(rest, "\n") {
for line := range strings.SplitSeq(rest, "\n") {
f := strings.Fields(line)
if len(f) == 0 {
continue

View File

@@ -84,14 +84,14 @@ func main() {
if *allowedRewrites != "" {
allowed = make(map[string]bool)
for _, f := range strings.Split(*allowedRewrites, ",") {
for f := range strings.SplitSeq(*allowedRewrites, ",") {
allowed[f] = true
}
}
if *forceRewrites != "" {
force = make(map[string]bool)
for _, f := range strings.Split(*forceRewrites, ",") {
for f := range strings.SplitSeq(*forceRewrites, ",") {
force[f] = true
}
}

View File

@@ -6,16 +6,16 @@ require (
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5
golang.org/x/arch v0.20.1-0.20250808194827-46ba08e3ae58
golang.org/x/build v0.0.0-20250806225920-b7c66c047964
golang.org/x/mod v0.27.0
golang.org/x/sync v0.16.0
golang.org/x/sys v0.35.0
golang.org/x/telemetry v0.0.0-20250807160809-1a19826ec488
golang.org/x/mod v0.28.0
golang.org/x/sync v0.17.0
golang.org/x/sys v0.36.0
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053
golang.org/x/term v0.34.0
golang.org/x/tools v0.36.1-0.20250904192731-a09a2fba1c08
golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef
)
require (
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/text v0.29.0 // indirect
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef // indirect
)

View File

@@ -10,19 +10,19 @@ golang.org/x/arch v0.20.1-0.20250808194827-46ba08e3ae58 h1:uxPa6+/WsUfzikIAPMqpT
golang.org/x/arch v0.20.1-0.20250808194827-46ba08e3ae58/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
golang.org/x/build v0.0.0-20250806225920-b7c66c047964 h1:yRs1K51GKq7hsIO+YHJ8LsslrvwFceNPIv0tYjpcBd0=
golang.org/x/build v0.0.0-20250806225920-b7c66c047964/go.mod h1:i9Vx7+aOQUpYJRxSO+OpRStVBCVL/9ccI51xblWm5WY=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20250807160809-1a19826ec488 h1:3doPGa+Gg4snce233aCWnbZVFsyFMo/dR40KK/6skyE=
golang.org/x/telemetry v0.0.0-20250807160809-1a19826ec488/go.mod h1:fGb/2+tgXXjhjHsTNdVEEMZNWA0quBnfrO+AfoDSAKw=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053 h1:dHQOQddU4YHS5gY33/6klKjq7Gp3WwMyOXGNp5nzRj8=
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053/go.mod h1:+nZKN+XVh4LCiA9DV3ywrzN4gumyCnKjau3NGb9SGoE=
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
golang.org/x/tools v0.36.1-0.20250904192731-a09a2fba1c08 h1:KS/PXsrK6W9NdlNu8iuCiNb7KM8UFwsh8g1BUjJ9rww=
golang.org/x/tools v0.36.1-0.20250904192731-a09a2fba1c08/go.mod h1:n+8pplxVZfXnmHBxWsfPnQRJ5vWroQDk+U2MFpjwtFY=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef h1:ISPkUgvOYIt0oS7oVnwAPktCKBvgWkDlWWGMgX0veZM=
golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=

View File

@@ -82,7 +82,7 @@ func runGitAuth(client *http.Client, dir, url string) (string, http.Header, erro
// Any of these values may be empty if parsing fails.
func parseGitAuth(data []byte) (parsedPrefix, username, password string) {
prefix := new(url.URL)
for _, line := range strings.Split(string(data), "\n") {
for line := range strings.SplitSeq(string(data), "\n") {
key, value, ok := strings.Cut(strings.TrimSpace(line), "=")
if !ok {
continue

View File

@@ -5,6 +5,7 @@
package auth
import (
"strings"
"testing"
)
@@ -82,3 +83,77 @@ password:secr3t
}
}
}
func BenchmarkParseGitAuth(b *testing.B) {
// Define different test scenarios to benchmark
testCases := []struct {
name string
data []byte
}{{
// Standard scenario with all basic fields present
name: "standard",
data: []byte(`
protocol=https
host=example.com
username=bob
password=secr3t
`),
}, {
// Scenario with URL field included
name: "with_url",
data: []byte(`
protocol=https
host=example.com
username=bob
password=secr3t
url=https://example.com/repo
`),
}, {
// Minimal scenario with only required fields
name: "minimal",
data: []byte(`
protocol=https
host=example.com
`),
}, {
// Complex scenario with longer values and extra fields
name: "complex",
data: func() []byte {
var builder strings.Builder
builder.WriteString("protocol=https\n")
builder.WriteString("host=example.com\n")
builder.WriteString("username=longusernamenamename\n")
builder.WriteString("password=longpasswordwithmanycharacters123456789\n")
builder.WriteString("url=https://example.com/very/long/path/to/repository\n")
builder.WriteString("extra1=value1\n")
builder.WriteString("extra2=value2\n")
return []byte(builder.String())
}(),
}, {
// Scenario with empty input
name: "empty",
data: []byte(``),
}, {
// Scenario with malformed input (using colon instead of equals)
name: "malformed",
data: []byte(`
protocol:https
host:example.com
username:bob
password:secr3t
`),
}}
for _, tc := range testCases {
b.Run(tc.name, func(b *testing.B) {
b.ResetTimer()
for b.Loop() {
prefix, username, password := parseGitAuth(tc.data)
_ = prefix
_ = username
_ = password
}
})
}
}

View File

@@ -24,7 +24,7 @@ func parseNetrc(data string) []netrcLine {
var nrc []netrcLine
var l netrcLine
inMacro := false
for _, line := range strings.Split(data, "\n") {
for line := range strings.SplitSeq(data, "\n") {
if inMacro {
if line == "" {
inMacro = false

View File

@@ -241,7 +241,7 @@ func findCodeRoots() []Dir {
cmd := exec.Command(goCmd(), "list", "-m", "-f={{.Path}}\t{{.Dir}}", "all")
cmd.Stderr = os.Stderr
out, _ := cmd.Output()
for _, line := range strings.Split(string(out), "\n") {
for line := range strings.SplitSeq(string(out), "\n") {
path, dir, _ := strings.Cut(line, "\t")
if dir != "" {
list = append(list, Dir{importPath: path, dir: dir, inModule: true})

View File

@@ -920,7 +920,7 @@ func trimUnexportedFields(fields *ast.FieldList, isInterface bool) *ast.FieldLis
start := doc.List[0].Slash
doc.List = doc.List[:0]
for _, line := range strings.Split(text, "\n") {
for line := range strings.SplitSeq(text, "\n") {
prefix := "// "
if len(line) > 0 && line[0] == '\t' {
prefix = "//"

View File

@@ -94,6 +94,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strings"
"golang.org/x/mod/module"
@@ -121,6 +122,9 @@ func Init() {
if cfg.ExperimentErr == nil && cfg.Experiment.BoringCrypto && Enabled() {
base.Fatalf("go: cannot use GOFIPS140 with GOEXPERIMENT=boringcrypto")
}
if slices.Contains(cfg.BuildContext.BuildTags, "purego") && Enabled() {
base.Fatalf("go: cannot use GOFIPS140 with the purego build tag")
}
}
var initDone bool

View File

@@ -381,7 +381,7 @@ func (v *jsonFlag) Set(s string) error {
if *v == nil {
*v = make(map[string]bool)
}
for _, f := range strings.Split(s, ",") {
for f := range strings.SplitSeq(s, ",") {
(*v)[f] = true
}
return nil

View File

@@ -173,7 +173,7 @@ func (r *gitRepo) loadLocalTags(ctx context.Context) {
return
}
for _, line := range strings.Split(string(out), "\n") {
for line := range strings.SplitSeq(string(out), "\n") {
if line != "" {
r.localTags.Store(line, true)
}
@@ -273,7 +273,7 @@ func (r *gitRepo) loadRefs(ctx context.Context) (map[string]string, error) {
}
refs := make(map[string]string)
for _, line := range strings.Split(string(out), "\n") {
for line := range strings.SplitSeq(string(out), "\n") {
f := strings.Fields(line)
if len(f) != 2 {
continue
@@ -745,7 +745,7 @@ func (r *gitRepo) RecentTag(ctx context.Context, rev, prefix string, allowed fun
// prefixed tags aren't valid semver tags so compare without prefix, but only tags with correct prefix
var highest string
for _, line := range strings.Split(string(out), "\n") {
for line := range strings.SplitSeq(string(out), "\n") {
line = strings.TrimSpace(line)
// git do support lstrip in for-each-ref format, but it was added in v2.13.0. Stripping here
// instead gives support for git v2.7.0.

View File

@@ -561,7 +561,7 @@ func bzrParseStat(rev, out string) (*RevInfo, error) {
var revno int64
var tm time.Time
var tags []string
for _, line := range strings.Split(out, "\n") {
for line := range strings.SplitSeq(out, "\n") {
if line == "" || line[0] == ' ' || line[0] == '\t' {
// End of header, start of commit message.
break
@@ -614,7 +614,7 @@ func bzrParseStat(rev, out string) (*RevInfo, error) {
}
func fossilParseStat(rev, out string) (*RevInfo, error) {
for _, line := range strings.Split(out, "\n") {
for line := range strings.SplitSeq(out, "\n") {
if strings.HasPrefix(line, "uuid:") || strings.HasPrefix(line, "hash:") {
f := strings.Fields(line)
if len(f) != 5 || len(f[1]) != 40 || f[4] != "UTC" {

View File

@@ -426,7 +426,7 @@ Lines:
// These lines set CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS and pkg-config directives
// that affect the way cgo's C code is built.
func (ctxt *Context) saveCgo(filename string, di *build.Package, text string) error {
for _, line := range strings.Split(text, "\n") {
for line := range strings.SplitSeq(text, "\n") {
orig := line
// Line is

View File

@@ -275,7 +275,7 @@ func importRaw(modroot, reldir string) *rawPackage {
// which is the comment on import "C".
func extractCgoDirectives(doc string) []string {
var out []string
for _, line := range strings.Split(doc, "\n") {
for line := range strings.SplitSeq(doc, "\n") {
// Line is
// #cgo [GOOS/GOARCH...] LDFLAGS: stuff
//

View File

@@ -329,7 +329,7 @@ func readModGraph(ctx context.Context, pruning modPruning, roots []module.Versio
// so it wouldn't be useful to log when that occurs (because it happens in
// normal operation all the time).
readModGraphDebugOnce.Do(func() {
for _, f := range strings.Split(os.Getenv("GODEBUG"), ",") {
for f := range strings.SplitSeq(os.Getenv("GODEBUG"), ",") {
switch f {
case "lazymod=log":
debug.PrintStack()

View File

@@ -1597,7 +1597,7 @@ func modulesTextIsForWorkspace(vendorDir string) (bool, error) {
}
line, _, _ := strings.Cut(string(buf[:n]), "\n")
if annotations, ok := strings.CutPrefix(line, "## "); ok {
for _, entry := range strings.Split(annotations, ";") {
for entry := range strings.SplitSeq(annotations, ";") {
entry = strings.TrimSpace(entry)
if entry == "workspace" {
return true, nil

View File

@@ -53,7 +53,7 @@ func readVendorList(vendorDir string) {
}
var mod module.Version
for _, line := range strings.Split(string(data), "\n") {
for line := range strings.SplitSeq(string(data), "\n") {
if strings.HasPrefix(line, "# ") {
f := strings.Fields(line)
@@ -103,7 +103,7 @@ func readVendorList(vendorDir string) {
if annotations, ok := strings.CutPrefix(line, "## "); ok {
// Metadata. Take the union of annotations across multiple lines, if present.
meta := vendorMeta[mod]
for _, entry := range strings.Split(annotations, ";") {
for entry := range strings.SplitSeq(annotations, ";") {
entry = strings.TrimSpace(entry)
if entry == "explicit" {
meta.Explicit = true

View File

@@ -149,7 +149,7 @@ func (f *vetFlag) Set(value string) error {
*f = vetFlag{explicit: true}
var single string
for _, arg := range strings.Split(value, ",") {
for arg := range strings.SplitSeq(value, ",") {
switch arg {
case "":
return fmt.Errorf("-vet argument contains empty list element")

View File

@@ -21,7 +21,7 @@ var pathExts = sync.OnceValue(func() []string {
}
var exts []string
for _, e := range strings.Split(strings.ToLower(x), `;`) {
for e := range strings.SplitSeq(strings.ToLower(x), `;`) {
if e == "" {
continue
}

View File

@@ -110,7 +110,7 @@ func (v *Cmd) isSecureScheme(scheme string) bool {
// colon-separated list of schemes that are allowed to be used with git
// fetch/clone. Any scheme not mentioned will be considered insecure.
if allow := os.Getenv("GIT_ALLOW_PROTOCOL"); allow != "" {
for _, s := range strings.Split(allow, ":") {
for s := range strings.SplitSeq(allow, ":") {
if s == scheme {
return true
}
@@ -440,7 +440,7 @@ func bzrStatus(vcsBzr *Cmd, rootDir string) (Status, error) {
var rev string
var commitTime time.Time
for _, line := range strings.Split(out, "\n") {
for line := range strings.SplitSeq(out, "\n") {
i := strings.IndexByte(line, ':')
if i < 0 {
continue
@@ -974,7 +974,7 @@ func parseGOVCS(s string) (govcsConfig, error) {
}
var cfg govcsConfig
have := make(map[string]string)
for _, item := range strings.Split(s, ",") {
for item := range strings.SplitSeq(s, ",") {
item = strings.TrimSpace(item)
if item == "" {
return nil, fmt.Errorf("empty entry in GOVCS")

View File

@@ -224,7 +224,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// uniqueness: if a path exists as a directory, then it cannot exist as a
// ".txt" script (because the search would ignore that file).
scriptPath := "."
for _, part := range strings.Split(clean, "/") {
for part := range strings.SplitSeq(clean, "/") {
scriptPath = filepath.Join(scriptPath, part)
dir := filepath.Join(s.scriptDir, scriptPath)
if _, err := os.Stat(dir); err != nil {

View File

@@ -19,6 +19,7 @@ import (
"internal/platform"
"os"
"path/filepath"
"slices"
"strings"
"sync"
"time"
@@ -578,6 +579,47 @@ func (ca *coverActor) Act(b *Builder, ctx context.Context, a *Action) error {
return nil
}
// runCgoActor implements the Actor interface for running the cgo command for the package.
type runCgoActor struct {
}
func (c runCgoActor) Act(b *Builder, ctx context.Context, a *Action) error {
var cacheProvider *checkCacheProvider
for _, a1 := range a.Deps {
if pr, ok := a1.Provider.(*checkCacheProvider); ok {
cacheProvider = pr
break
}
}
need := cacheProvider.need
need &^= needCovMetaFile // handled by cover action
if need == 0 {
return nil
}
return b.runCgo(ctx, a)
}
type cgoCompileActor struct {
file string
compileFunc func(*Action, string, string, []string, string) error
getFlagsFunc func(*runCgoProvider) []string
flags *[]string
}
func (c cgoCompileActor) Act(b *Builder, ctx context.Context, a *Action) error {
pr, ok := a.Deps[0].Provider.(*runCgoProvider)
if !ok {
return nil // cgo was not needed. do nothing.
}
a.nonGoOverlay = pr.nonGoOverlay
buildAction := a.triggers[0].triggers[0] // cgo compile -> cgo collect -> build
a.actionID = cache.Subkey(buildAction.actionID, "cgo compile "+c.file) // buildAction's action id was computed by the check cache action.
return c.compileFunc(a, a.Objdir, a.Target, c.getFlagsFunc(pr), c.file)
}
// CompileAction returns the action for compiling and possibly installing
// (according to mode) the given package. The resulting action is only
// for building packages (archives), never for linking executables.
@@ -677,6 +719,17 @@ func (b *Builder) CompileAction(mode, depMode BuildMode, p *load.Package) *Actio
a.Deps = append(a.Deps, coverAction)
}
// Create actions to run swig and cgo if needed. These actions always run in the
// same go build invocation as the build action and their actions are not cached
// separately, so they can use the same objdir.
if p.UsesCgo() || p.UsesSwig() {
deps := []*Action{cacheAction}
if coverAction != nil {
deps = append(deps, coverAction)
}
a.Deps = append(a.Deps, b.cgoAction(p, a.Objdir, deps, coverAction != nil))
}
return a
})
@@ -701,6 +754,114 @@ func (b *Builder) CompileAction(mode, depMode BuildMode, p *load.Package) *Actio
return a
}
func (b *Builder) cgoAction(p *load.Package, objdir string, deps []*Action, hasCover bool) *Action {
cgoCollectAction := b.cacheAction("cgo collect", p, func() *Action {
// Run cgo
runCgo := b.cacheAction("cgo run", p, func() *Action {
return &Action{
Package: p,
Mode: "cgo run",
Actor: &runCgoActor{},
Objdir: objdir,
Deps: deps,
}
})
// Determine which files swig will produce in the cgo run action. We'll need to create
// actions to compile the C and C++ files produced by swig, as well as the C file
// produced by cgo processing swig's Go file outputs.
swigGo, swigC, swigCXX := b.swigOutputs(p, objdir)
oseq := 0
nextOfile := func() string {
oseq++
return objdir + fmt.Sprintf("_x%03d.o", oseq)
}
compileAction := func(file string, getFlagsFunc func(*runCgoProvider) []string, compileFunc func(*Action, string, string, []string, string) error) *Action {
mode := "cgo compile " + file
return b.cacheAction(mode, p, func() *Action {
return &Action{
Package: p,
Mode: mode,
Actor: &cgoCompileActor{file: file, getFlagsFunc: getFlagsFunc, compileFunc: compileFunc},
Deps: []*Action{runCgo},
Objdir: objdir,
Target: nextOfile(),
}
})
}
var collectDeps []*Action
// Add compile actions for C files generated by cgo.
cgoFiles := p.CgoFiles
if hasCover {
cgoFiles = slices.Clone(cgoFiles)
for i := range cgoFiles {
cgoFiles[i] = strings.TrimSuffix(cgoFiles[i], ".go") + ".cover.go"
}
}
cfiles := []string{"_cgo_export.c"}
for _, fn := range slices.Concat(cgoFiles, swigGo) {
cfiles = append(cfiles, strings.TrimSuffix(filepath.Base(fn), ".go")+".cgo2.c")
}
for _, f := range cfiles {
collectDeps = append(collectDeps, compileAction(objdir+f, (*runCgoProvider).cflags, b.gcc))
}
// Add compile actions for S files.
var sfiles []string
// In a package using cgo, cgo compiles the C, C++ and assembly files with gcc.
// There is one exception: runtime/cgo's job is to bridge the
// cgo and non-cgo worlds, so it necessarily has files in both.
// In that case gcc only gets the gcc_* files.
if p.Standard && p.ImportPath == "runtime/cgo" {
for _, f := range p.SFiles {
if strings.HasPrefix(f, "gcc_") {
sfiles = append(sfiles, f)
}
}
} else {
sfiles = p.SFiles
}
for _, f := range sfiles {
collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).cflags, b.gas))
}
// Add compile actions for C files in the package, M files, and those generated by swig.
for _, f := range slices.Concat(p.CFiles, p.MFiles, swigC) {
collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).cflags, b.gcc))
}
// Add compile actions for C++ files in the package, and those generated by swig.
for _, f := range slices.Concat(p.CXXFiles, swigCXX) {
collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).cxxflags, b.gxx))
}
// Add compile actions for Fortran files in the package.
for _, f := range p.FFiles {
collectDeps = append(collectDeps, compileAction(f, (*runCgoProvider).fflags, b.gfortran))
}
// Add a single convenience action that does nothing to join the previous action,
// and better separate the cgo action dependencies of the build action from the
// build actions for its package dependencies.
return &Action{
Mode: "collect cgo",
Actor: ActorFunc(func(b *Builder, ctx context.Context, a *Action) error {
// Use the cgo run action's provider as our provider output,
// so it can be easily accessed by the build action.
a.Provider = a.Deps[0].Deps[0].Provider
return nil
}),
Deps: collectDeps,
Objdir: objdir,
}
})
return cgoCollectAction
}
// VetAction returns the action for running go vet on package p.
// It depends on the action for compiling p.
// If the caller may be causing p to be installed, it is up to the caller
@@ -716,25 +877,15 @@ func (b *Builder) vetAction(mode, depMode BuildMode, p *load.Package) *Action {
a := b.cacheAction("vet", p, func() *Action {
a1 := b.CompileAction(mode|ModeVetOnly, depMode, p)
// vet expects to be able to import "fmt".
var stk load.ImportStack
stk.Push(load.NewImportInfo("vet", nil))
p1, err := load.LoadImportWithFlags("fmt", p.Dir, p, &stk, nil, 0)
if err != nil {
base.Fatalf("unexpected error loading fmt package from package %s: %v", p.ImportPath, err)
}
stk.Pop()
aFmt := b.CompileAction(ModeBuild, depMode, p1)
var deps []*Action
if a1.buggyInstall {
// (*Builder).vet expects deps[0] to be the package
// and deps[1] to be "fmt". If we see buggyInstall
// (*Builder).vet expects deps[0] to be the package.
// If we see buggyInstall
// here then a1 is an install of a shared library,
// and the real package is a1.Deps[0].
deps = []*Action{a1.Deps[0], aFmt, a1}
deps = []*Action{a1.Deps[0], a1}
} else {
deps = []*Action{a1, aFmt}
deps = []*Action{a1}
}
for _, p1 := range p.Internal.Imports {
deps = append(deps, b.vetAction(mode, depMode, p1))

View File

@@ -384,7 +384,7 @@ func (v *tagsFlag) Set(s string) error {
// Split on commas, ignore empty strings.
*v = []string{}
for _, s := range strings.Split(s, ",") {
for s := range strings.SplitSeq(s, ",") {
if s != "" {
*v = append(*v, s)
}

View File

@@ -464,6 +464,38 @@ func allowedVersion(v string) bool {
return gover.Compare(gover.Local(), v) >= 0
}
func (b *Builder) computeNonGoOverlay(a *Action, p *load.Package, sh *Shell, objdir string, nonGoFileLists [][]string) error {
OverlayLoop:
for _, fs := range nonGoFileLists {
for _, f := range fs {
if fsys.Replaced(mkAbs(p.Dir, f)) {
a.nonGoOverlay = make(map[string]string)
break OverlayLoop
}
}
}
if a.nonGoOverlay != nil {
for _, fs := range nonGoFileLists {
for i := range fs {
from := mkAbs(p.Dir, fs[i])
dst := objdir + filepath.Base(fs[i])
if err := sh.CopyFile(dst, fsys.Actual(from), 0666, false); err != nil {
return err
}
a.nonGoOverlay[from] = dst
}
}
}
return nil
}
// needsBuild reports whether the Action (which must be mode "build") needs
// to produce the built output.
func (b *Builder) needsBuild(a *Action) bool {
return !b.IsCmdList && a.needBuild || b.NeedExport
}
const (
needBuild uint32 = 1 << iota
needCgoHdr
@@ -688,12 +720,15 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) {
var cacheProvider *checkCacheProvider
var coverPr *coverProvider
var runCgoPr *runCgoProvider
for _, dep := range a.Deps {
switch pr := dep.Provider.(type) {
case *coverProvider:
coverPr = pr
case *checkCacheProvider:
cacheProvider = pr
case *runCgoProvider:
runCgoPr = pr
}
}
if cacheProvider == nil {
@@ -702,6 +737,7 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) {
need := cacheProvider.need
need &^= needCovMetaFile // handled by cover action
need &^= needCgoHdr // handled by run cgo action // TODO: accumulate "negative" need bits from actions
if need == 0 {
return
@@ -736,107 +772,40 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) {
}
gofiles := str.StringList(p.GoFiles)
cgofiles := str.StringList(p.CgoFiles)
cfiles := str.StringList(p.CFiles)
sfiles := str.StringList(p.SFiles)
cxxfiles := str.StringList(p.CXXFiles)
var objects, cgoObjects, pcCFLAGS, pcLDFLAGS []string
if p.UsesCgo() || p.UsesSwig() {
if pcCFLAGS, pcLDFLAGS, err = b.getPkgConfigFlags(a); err != nil {
return
}
}
// Compute overlays for .c/.cc/.h/etc. and if there are any overlays
// put correct contents of all those files in the objdir, to ensure
// the correct headers are included. nonGoOverlay is the overlay that
// points from nongo files to the copied files in objdir.
nonGoFileLists := [][]string{p.CFiles, p.SFiles, p.CXXFiles, p.HFiles, p.FFiles}
OverlayLoop:
for _, fs := range nonGoFileLists {
for _, f := range fs {
if fsys.Replaced(mkAbs(p.Dir, f)) {
a.nonGoOverlay = make(map[string]string)
break OverlayLoop
}
}
}
if a.nonGoOverlay != nil {
for _, fs := range nonGoFileLists {
for i := range fs {
from := mkAbs(p.Dir, fs[i])
dst := objdir + filepath.Base(fs[i])
if err := sh.CopyFile(dst, fsys.Actual(from), 0666, false); err != nil {
return err
}
a.nonGoOverlay[from] = dst
}
}
}
var objects, cgoObjects []string
// If we're doing coverage, preprocess the .go files and put them in the work directory
if p.Internal.Cover.Mode != "" {
gofiles = coverPr.goSources
cgofiles = coverPr.cgoSources
}
// Run SWIG on each .swig and .swigcxx file.
// Each run will generate two files, a .go file and a .c or .cxx file.
// The .go file will use import "C" and is to be processed by cgo.
// For -cover test or build runs, this needs to happen after the cover
// tool is run; we don't want to instrument swig-generated Go files,
// see issue #64661.
if p.UsesSwig() {
outGo, outC, outCXX, err := b.swig(a, objdir, pcCFLAGS)
if err != nil {
return err
}
cgofiles = append(cgofiles, outGo...)
cfiles = append(cfiles, outC...)
cxxfiles = append(cxxfiles, outCXX...)
}
// Run cgo.
if p.UsesCgo() || p.UsesSwig() {
if runCgoPr == nil {
base.Fatalf("internal error: could not find runCgoProvider")
}
// In a package using cgo, cgo compiles the C, C++ and assembly files with gcc.
// There is one exception: runtime/cgo's job is to bridge the
// cgo and non-cgo worlds, so it necessarily has files in both.
// In that case gcc only gets the gcc_* files.
var gccfiles []string
gccfiles = append(gccfiles, cfiles...)
cfiles = nil
if p.Standard && p.ImportPath == "runtime/cgo" {
filter := func(files, nongcc, gcc []string) ([]string, []string) {
for _, f := range files {
if strings.HasPrefix(f, "gcc_") {
gcc = append(gcc, f)
} else {
nongcc = append(nongcc, f)
}
// filter to the non-gcc files.
i := 0
for _, f := range sfiles {
if !strings.HasPrefix(f, "gcc_") {
sfiles[i] = f
i++
}
return nongcc, gcc
}
sfiles, gccfiles = filter(sfiles, sfiles[:0], gccfiles)
sfiles = sfiles[:i]
} else {
for _, sfile := range sfiles {
data, err := os.ReadFile(filepath.Join(p.Dir, sfile))
if err == nil {
if bytes.HasPrefix(data, []byte("TEXT")) || bytes.Contains(data, []byte("\nTEXT")) ||
bytes.HasPrefix(data, []byte("DATA")) || bytes.Contains(data, []byte("\nDATA")) ||
bytes.HasPrefix(data, []byte("GLOBL")) || bytes.Contains(data, []byte("\nGLOBL")) {
return fmt.Errorf("package using cgo has Go assembly file %s", sfile)
}
}
}
gccfiles = append(gccfiles, sfiles...)
sfiles = nil
}
outGo, outObj, err := b.cgo(a, base.Tool("cgo"), objdir, pcCFLAGS, pcLDFLAGS, mkAbsFiles(p.Dir, cgofiles), gccfiles, cxxfiles, p.MFiles, p.FFiles)
// The files in cxxfiles have now been handled by b.cgo.
cxxfiles = nil
outGo, outObj, err := b.processCgoOutputs(a, runCgoPr, base.Tool("cgo"), objdir)
if err != nil {
return err
@@ -857,12 +826,8 @@ OverlayLoop:
srcfiles = append(srcfiles, gofiles...)
srcfiles = append(srcfiles, sfiles...)
srcfiles = append(srcfiles, cfiles...)
srcfiles = append(srcfiles, cxxfiles...)
b.cacheSrcFiles(a, srcfiles)
// Running cgo generated the cgo header.
need &^= needCgoHdr
// Sanity check only, since Package.load already checked as well.
if len(gofiles) == 0 {
return &load.NoGoError{Package: p}
@@ -991,6 +956,12 @@ OverlayLoop:
}
}
if err := b.computeNonGoOverlay(a, p, sh, objdir, [][]string{cfiles}); err != nil {
return err
}
// Compile C files in a package being built with gccgo. We disallow
// C files when compiling with gc unless swig or cgo is used.
for _, file := range cfiles {
out := file[:len(file)-len(".c")] + ".o"
if err := BuildToolchain.cc(b, a, objdir+out, file); err != nil {
@@ -1151,7 +1122,7 @@ func (b *Builder) loadCachedVet(a *Action) error {
return fmt.Errorf("reading srcfiles list: %w", err)
}
var srcfiles []string
for _, name := range strings.Split(string(list), "\n") {
for name := range strings.SplitSeq(string(list), "\n") {
if name == "" { // end of list
continue
}
@@ -1175,7 +1146,7 @@ func (b *Builder) loadCachedCompiledGoFiles(a *Action) error {
return fmt.Errorf("reading srcfiles list: %w", err)
}
var gofiles []string
for _, name := range strings.Split(string(list), "\n") {
for name := range strings.SplitSeq(string(list), "\n") {
if name == "" { // end of list
continue
} else if !strings.HasSuffix(name, ".go") {
@@ -1213,6 +1184,7 @@ type vetConfig struct {
PackageVetx map[string]string // map package path to vetx data from earlier vet run
VetxOnly bool // only compute vetx data; don't report detected problems
VetxOutput string // write vetx data to this output file
Stdout string // write stdout (JSON, unified diff) to this output file
GoVersion string // Go version for package
SucceedOnTypecheckFailure bool // awful hack; see #18395 and below
@@ -1306,7 +1278,6 @@ var VetExplicit bool
func (b *Builder) vet(ctx context.Context, a *Action) error {
// a.Deps[0] is the build of the package being vetted.
// a.Deps[1] is the build of the "fmt" package.
a.Failed = nil // vet of dependency may have failed but we can still succeed
@@ -1327,6 +1298,7 @@ func (b *Builder) vet(ctx context.Context, a *Action) error {
vcfg.VetxOnly = a.VetxOnly
vcfg.VetxOutput = a.Objdir + "vet.out"
vcfg.Stdout = a.Objdir + "vet.stdout"
vcfg.PackageVetx = make(map[string]string)
h := cache.NewHash("vet " + a.Package.ImportPath)
@@ -1422,13 +1394,25 @@ func (b *Builder) vet(ctx context.Context, a *Action) error {
// If vet wrote export data, save it for input to future vets.
if f, err := os.Open(vcfg.VetxOutput); err == nil {
a.built = vcfg.VetxOutput
cache.Default().Put(key, f)
f.Close()
cache.Default().Put(key, f) // ignore error
f.Close() // ignore error
}
// If vet wrote to stdout, copy it to go's stdout, atomically.
if f, err := os.Open(vcfg.Stdout); err == nil {
stdoutMu.Lock()
if _, err := io.Copy(os.Stdout, f); err != nil && runErr == nil {
runErr = fmt.Errorf("copying vet tool stdout: %w", err)
}
f.Close() // ignore error
stdoutMu.Unlock()
}
return runErr
}
var stdoutMu sync.Mutex // serializes concurrent writes (e.g. JSON values) to stdout
// linkActionID computes the action ID for a link action.
func (b *Builder) linkActionID(a *Action) cache.ActionID {
p := a.Package
@@ -1695,8 +1679,7 @@ func splitPkgConfigOutput(out []byte) ([]string, error) {
}
// Calls pkg-config if needed and returns the cflags/ldflags needed to build a's package.
func (b *Builder) getPkgConfigFlags(a *Action) (cflags, ldflags []string, err error) {
p := a.Package
func (b *Builder) getPkgConfigFlags(a *Action, p *load.Package) (cflags, ldflags []string, err error) {
sh := b.Shell(a)
if pcargs := p.CgoPkgConfig; len(pcargs) > 0 {
// pkg-config permits arguments to appear anywhere in
@@ -2173,6 +2156,20 @@ func (b *Builder) gcc(a *Action, workdir, out string, flags []string, cfile stri
return b.ccompile(a, out, flags, cfile, b.GccCmd(p.Dir, workdir))
}
// gas runs the gcc c compiler to create an object file from a single C assembly file.
func (b *Builder) gas(a *Action, workdir, out string, flags []string, sfile string) error {
p := a.Package
data, err := os.ReadFile(filepath.Join(p.Dir, sfile))
if err == nil {
if bytes.HasPrefix(data, []byte("TEXT")) || bytes.Contains(data, []byte("\nTEXT")) ||
bytes.HasPrefix(data, []byte("DATA")) || bytes.Contains(data, []byte("\nDATA")) ||
bytes.HasPrefix(data, []byte("GLOBL")) || bytes.Contains(data, []byte("\nGLOBL")) {
return fmt.Errorf("package using cgo has Go assembly file %s", sfile)
}
}
return b.ccompile(a, out, flags, sfile, b.GccCmd(p.Dir, workdir))
}
// gxx runs the g++ C++ compiler to create an object from a single C++ file.
func (b *Builder) gxx(a *Action, workdir, out string, flags []string, cxxfile string) error {
p := a.Package
@@ -2192,6 +2189,8 @@ func (b *Builder) ccompile(a *Action, outfile string, flags []string, file strin
file = mkAbs(p.Dir, file)
outfile = mkAbs(p.Dir, outfile)
flags = slices.Clip(flags) // If we append to flags, write to a new slice that we own.
// Elide source directory paths if -trimpath is set.
// This is needed for source files (e.g., a .c file in a package directory).
// TODO(golang.org/issue/36072): cgo also generates files with #line
@@ -2742,26 +2741,97 @@ func buildFlags(name, defaults string, fromPackage []string, check func(string,
var cgoRe = lazyregexp.New(`[/\\:]`)
func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, gxxfiles, mfiles, ffiles []string) (outGo, outObj []string, err error) {
type runCgoProvider struct {
CFLAGS, CXXFLAGS, FFLAGS, LDFLAGS []string
notCompatibleForInternalLinking bool
nonGoOverlay map[string]string
goFiles []string // processed cgo files for the compiler
}
func (pr *runCgoProvider) cflags() []string {
return pr.CFLAGS
}
func (pr *runCgoProvider) cxxflags() []string {
return pr.CXXFLAGS
}
func (pr *runCgoProvider) fflags() []string {
return pr.CXXFLAGS
}
func (pr *runCgoProvider) ldflags() []string {
return pr.LDFLAGS
}
func mustGetCoverInfo(a *Action) *coverProvider {
for _, dep := range a.Deps {
if dep.Mode == "cover" {
return dep.Provider.(*coverProvider)
}
}
base.Fatalf("internal error: cover provider not found")
panic("unreachable")
}
func (b *Builder) runCgo(ctx context.Context, a *Action) error {
p := a.Package
sh := b.Shell(a)
objdir := a.Objdir
if err := sh.Mkdir(objdir); err != nil {
return err
}
nonGoFileLists := [][]string{p.CFiles, p.SFiles, p.CXXFiles, p.HFiles, p.FFiles}
if err := b.computeNonGoOverlay(a, p, sh, objdir, nonGoFileLists); err != nil {
return err
}
cgofiles := slices.Clip(p.CgoFiles)
if a.Package.Internal.Cover.Mode != "" {
cp := mustGetCoverInfo(a)
cgofiles = cp.cgoSources
}
pcCFLAGS, pcLDFLAGS, err := b.getPkgConfigFlags(a, p)
if err != nil {
return err
}
// Run SWIG on each .swig and .swigcxx file.
// Each run will generate two files, a .go file and a .c or .cxx file.
// The .go file will use import "C" and is to be processed by cgo.
// For -cover test or build runs, this needs to happen after the cover
// tool is run; we don't want to instrument swig-generated Go files,
// see issue #64661.
if p.UsesSwig() {
if err := b.swig(a, objdir, pcCFLAGS); err != nil {
return err
}
outGo, _, _ := b.swigOutputs(p, objdir)
cgofiles = append(cgofiles, outGo...)
}
cgoExe := base.Tool("cgo")
cgofiles = mkAbsFiles(p.Dir, cgofiles)
cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS, cgoLDFLAGS, err := b.CFlags(p)
if err != nil {
return nil, nil, err
return err
}
cgoCPPFLAGS = append(cgoCPPFLAGS, pcCFLAGS...)
cgoLDFLAGS = append(cgoLDFLAGS, pcLDFLAGS...)
// If we are compiling Objective-C code, then we need to link against libobjc
if len(mfiles) > 0 {
if len(p.MFiles) > 0 {
cgoLDFLAGS = append(cgoLDFLAGS, "-lobjc")
}
// Likewise for Fortran, except there are many Fortran compilers.
// Support gfortran out of the box and let others pass the correct link options
// via CGO_LDFLAGS
if len(ffiles) > 0 {
if len(p.FFiles) > 0 {
fc := cfg.Getenv("FC")
if fc == "" {
fc = "gfortran"
@@ -2788,13 +2858,7 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
// #58620, and #58848.
flagSources := []string{"CGO_CFLAGS", "CGO_CXXFLAGS", "CGO_FFLAGS"}
flagLists := [][]string{cgoCFLAGS, cgoCXXFLAGS, cgoFFLAGS}
if flagsNotCompatibleWithInternalLinking(flagSources, flagLists) {
tokenFile := objdir + "preferlinkext"
if err := sh.writeFile(tokenFile, nil); err != nil {
return nil, nil, err
}
outObj = append(outObj, tokenFile)
}
notCompatibleWithInternalLinking := flagsNotCompatibleWithInternalLinking(flagSources, flagLists)
if cfg.BuildMSan {
cgoCFLAGS = append([]string{"-fsanitize=memory"}, cgoCFLAGS...)
@@ -2812,11 +2876,11 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
// cgo
// TODO: CGO_FLAGS?
gofiles := []string{objdir + "_cgo_gotypes.go"}
cfiles := []string{"_cgo_export.c"}
cfiles := []string{objdir + "_cgo_export.c"}
for _, fn := range cgofiles {
f := strings.TrimSuffix(filepath.Base(fn), ".go")
gofiles = append(gofiles, objdir+f+".cgo1.go")
cfiles = append(cfiles, f+".cgo2.c")
cfiles = append(cfiles, objdir+f+".cgo2.c")
}
// TODO: make cgo not depend on $GOARCH?
@@ -2890,70 +2954,61 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
}
if err := sh.run(p.Dir, p.ImportPath, cgoenv, cfg.BuildToolexec, cgoExe, "-objdir", objdir, "-importpath", p.ImportPath, cgoflags, ldflagsOption, "--", cgoCPPFLAGS, cgoCFLAGS, cgofiles); err != nil {
return nil, nil, err
}
outGo = append(outGo, gofiles...)
// Use sequential object file names to keep them distinct
// and short enough to fit in the .a header file name slots.
// We no longer collect them all into _all.o, and we'd like
// tools to see both the .o suffix and unique names, so
// we need to make them short enough not to be truncated
// in the final archive.
oseq := 0
nextOfile := func() string {
oseq++
return objdir + fmt.Sprintf("_x%03d.o", oseq)
return err
}
// gcc
cflags := str.StringList(cgoCPPFLAGS, cgoCFLAGS)
for _, cfile := range cfiles {
ofile := nextOfile()
if err := b.gcc(a, a.Objdir, ofile, cflags, objdir+cfile); err != nil {
a.Provider = &runCgoProvider{
CFLAGS: str.StringList(cgoCPPFLAGS, cgoCFLAGS),
CXXFLAGS: str.StringList(cgoCPPFLAGS, cgoCXXFLAGS),
FFLAGS: str.StringList(cgoCPPFLAGS, cgoFFLAGS),
LDFLAGS: cgoLDFLAGS,
notCompatibleForInternalLinking: notCompatibleWithInternalLinking,
nonGoOverlay: a.nonGoOverlay,
goFiles: gofiles,
}
return nil
}
func (b *Builder) processCgoOutputs(a *Action, runCgoProvider *runCgoProvider, cgoExe, objdir string) (outGo, outObj []string, err error) {
outGo = slices.Clip(runCgoProvider.goFiles)
// TODO(matloob): Pretty much the only thing this function is doing is
// producing the dynimport go files. But we should be able to compile
// those separately from the package itself: we just need to get the
// compiled output to the linker. That means that we can remove the
// dependency of this build action on the outputs of the cgo compile actions
// (though we'd still need to depend on the runCgo action of course).
sh := b.Shell(a)
// Output the preferlinkext file if the run cgo action determined this package
// was not compatible for internal linking based on CFLAGS, CXXFLAGS, or FFLAGS.
if runCgoProvider.notCompatibleForInternalLinking {
tokenFile := objdir + "preferlinkext"
if err := sh.writeFile(tokenFile, nil); err != nil {
return nil, nil, err
}
outObj = append(outObj, ofile)
outObj = append(outObj, tokenFile)
}
for _, file := range gccfiles {
ofile := nextOfile()
if err := b.gcc(a, a.Objdir, ofile, cflags, file); err != nil {
return nil, nil, err
var collectAction *Action
for _, dep := range a.Deps {
if dep.Mode == "collect cgo" {
collectAction = dep
}
outObj = append(outObj, ofile)
}
cxxflags := str.StringList(cgoCPPFLAGS, cgoCXXFLAGS)
for _, file := range gxxfiles {
ofile := nextOfile()
if err := b.gxx(a, a.Objdir, ofile, cxxflags, file); err != nil {
return nil, nil, err
}
outObj = append(outObj, ofile)
if collectAction == nil {
base.Fatalf("internal error: no cgo collect action")
}
for _, file := range mfiles {
ofile := nextOfile()
if err := b.gcc(a, a.Objdir, ofile, cflags, file); err != nil {
return nil, nil, err
}
outObj = append(outObj, ofile)
}
fflags := str.StringList(cgoCPPFLAGS, cgoFFLAGS)
for _, file := range ffiles {
ofile := nextOfile()
if err := b.gfortran(a, a.Objdir, ofile, fflags, file); err != nil {
return nil, nil, err
}
outObj = append(outObj, ofile)
for _, dep := range collectAction.Deps {
outObj = append(outObj, dep.Target)
}
switch cfg.BuildToolchainName {
case "gc":
importGo := objdir + "_cgo_import.go"
dynOutGo, dynOutObj, err := b.dynimport(a, objdir, importGo, cgoExe, cflags, cgoLDFLAGS, outObj)
dynOutGo, dynOutObj, err := b.dynimport(a, objdir, importGo, cgoExe, runCgoProvider.CFLAGS, runCgoProvider.LDFLAGS, outObj)
if err != nil {
return nil, nil, err
}
@@ -3032,16 +3087,16 @@ func (b *Builder) cgo(a *Action, cgoExe, objdir string, pcCFLAGS, pcLDFLAGS, cgo
}
}
// We expect to find the contents of cgoLDFLAGS in flags.
if len(cgoLDFLAGS) > 0 {
// We expect to find the contents of cgoLDFLAGS used when running the CGO action in flags.
if len(runCgoProvider.LDFLAGS) > 0 {
outer:
for i := range flags {
for j, f := range cgoLDFLAGS {
for j, f := range runCgoProvider.LDFLAGS {
if f != flags[i+j] {
continue outer
}
}
flags = append(flags[:i], flags[i+len(cgoLDFLAGS):]...)
flags = append(flags[:i], flags[i+len(runCgoProvider.LDFLAGS):]...)
break
}
}
@@ -3157,43 +3212,43 @@ func (b *Builder) dynimport(a *Action, objdir, importGo, cgoExe string, cflags,
// Run SWIG on all SWIG input files.
// TODO: Don't build a shared library, once SWIG emits the necessary
// pragmas for external linking.
func (b *Builder) swig(a *Action, objdir string, pcCFLAGS []string) (outGo, outC, outCXX []string, err error) {
func (b *Builder) swig(a *Action, objdir string, pcCFLAGS []string) error {
p := a.Package
if err := b.swigVersionCheck(); err != nil {
return nil, nil, nil, err
return err
}
intgosize, err := b.swigIntSize(objdir)
if err != nil {
return nil, nil, nil, err
return err
}
for _, f := range p.SwigFiles {
goFile, cFile, err := b.swigOne(a, f, objdir, pcCFLAGS, false, intgosize)
if err != nil {
return nil, nil, nil, err
}
if goFile != "" {
outGo = append(outGo, goFile)
}
if cFile != "" {
outC = append(outC, cFile)
if err := b.swigOne(a, f, objdir, pcCFLAGS, false, intgosize); err != nil {
return err
}
}
for _, f := range p.SwigCXXFiles {
goFile, cxxFile, err := b.swigOne(a, f, objdir, pcCFLAGS, true, intgosize)
if err != nil {
return nil, nil, nil, err
}
if goFile != "" {
outGo = append(outGo, goFile)
}
if cxxFile != "" {
outCXX = append(outCXX, cxxFile)
if b.swigOne(a, f, objdir, pcCFLAGS, true, intgosize); err != nil {
return err
}
}
return outGo, outC, outCXX, nil
return nil
}
func (b *Builder) swigOutputs(p *load.Package, objdir string) (outGo, outC, outCXX []string) {
for _, f := range p.SwigFiles {
goFile, cFile := swigOneOutputs(f, objdir, false)
outGo = append(outGo, goFile)
outC = append(outC, cFile)
}
for _, f := range p.SwigCXXFiles {
goFile, cxxFile := swigOneOutputs(f, objdir, true)
outGo = append(outGo, goFile)
outCXX = append(outCXX, cxxFile)
}
return outGo, outC, outCXX
}
// Make sure SWIG is new enough.
@@ -3306,13 +3361,13 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) {
}
// Run SWIG on one SWIG input file.
func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) {
func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) error {
p := a.Package
sh := b.Shell(a)
cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _, err := b.CFlags(p)
if err != nil {
return "", "", err
return err
}
var cflags []string
@@ -3322,17 +3377,8 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
cflags = str.StringList(cgoCPPFLAGS, pcCFLAGS, cgoCFLAGS)
}
n := 5 // length of ".swig"
if cxx {
n = 8 // length of ".swigcxx"
}
base := file[:len(file)-n]
goFile := base + ".go"
gccBase := base + "_wrap."
gccExt := "c"
if cxx {
gccExt = "cxx"
}
base := swigBase(file, cxx)
newGoFile, outC := swigOneOutputs(file, objdir, cxx)
gccgo := cfg.BuildToolchainName == "gccgo"
@@ -3342,7 +3388,7 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
"-cgo",
"-intgosize", intgosize,
"-module", base,
"-o", objdir + gccBase + gccExt,
"-o", outC,
"-outdir", objdir,
}
@@ -3364,31 +3410,52 @@ func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx
out, err := sh.runOut(p.Dir, nil, "swig", args, file)
if err != nil && (bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo"))) {
return "", "", errors.New("must have SWIG version >= 3.0.6")
return errors.New("must have SWIG version >= 3.0.6")
}
if err := sh.reportCmd("", "", out, err); err != nil {
return "", "", err
return err
}
// If the input was x.swig, the output is x.go in the objdir.
// But there might be an x.go in the original dir too, and if it
// uses cgo as well, cgo will be processing both and will
// translate both into x.cgo1.go in the objdir, overwriting one.
// Rename x.go to _x_swig.go to avoid this problem.
// Rename x.go to _x_swig.go (newGoFile) to avoid this problem.
// We ignore files in the original dir that begin with underscore
// so _x_swig.go cannot conflict with an original file we were
// going to compile.
goFile = objdir + goFile
newGoFile := objdir + "_" + base + "_swig.go"
goFile := objdir + base + ".go"
if cfg.BuildX || cfg.BuildN {
sh.ShowCmd("", "mv %s %s", goFile, newGoFile)
}
if !cfg.BuildN {
if err := os.Rename(goFile, newGoFile); err != nil {
return "", "", err
return err
}
}
return newGoFile, objdir + gccBase + gccExt, nil
return nil
}
func swigBase(file string, cxx bool) string {
n := 5 // length of ".swig"
if cxx {
n = 8 // length of ".swigcxx"
}
return file[:len(file)-n]
}
func swigOneOutputs(file, objdir string, cxx bool) (outGo, outC string) {
base := swigBase(file, cxx)
gccBase := base + "_wrap."
gccExt := "c"
if cxx {
gccExt = "cxx"
}
newGoFile := objdir + "_" + base + "_swig.go"
cFile := objdir + gccBase + gccExt
return newGoFile, cFile
}
// disableBuildID adjusts a linker command line to avoid creating a

View File

@@ -278,7 +278,7 @@ func (tools gccgoToolchain) link(b *Builder, root *Action, out, importcfg string
return err
}
const ldflagsPrefix = "_CGO_LDFLAGS="
for _, line := range strings.Split(string(flags), "\n") {
for line := range strings.SplitSeq(string(flags), "\n") {
if strings.HasPrefix(line, ldflagsPrefix) {
flag := line[len(ldflagsPrefix):]
// Every _cgo_flags file has -g and -O2 in _CGO_LDFLAGS

View File

@@ -14,12 +14,13 @@ stderr '2 MOVW'
stderr '3 RET'
stderr '4'
# -json causes success, even with diagnostics and errors.
# -json causes success, even with diagnostics and errors,
# and writes to stdout.
go vet -json -asmdecl a
stderr '"a": {'
stderr '"asmdecl":'
stderr '"posn": ".*asm.s:2:1",'
stderr '"message": ".*invalid MOVW.*"'
stdout '"a": {'
stdout '"asmdecl":'
stdout '"posn": ".*asm.s:2:1",'
stdout '"message": ".*invalid MOVW.*"'
-- a/a.go --
package a

View File

@@ -105,11 +105,11 @@ var (
objectPtrNil = reflect.ValueOf((*ast.Object)(nil))
scopePtrNil = reflect.ValueOf((*ast.Scope)(nil))
identType = reflect.TypeOf((*ast.Ident)(nil))
objectPtrType = reflect.TypeOf((*ast.Object)(nil))
positionType = reflect.TypeOf(token.NoPos)
callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
identType = reflect.TypeFor[*ast.Ident]()
objectPtrType = reflect.TypeFor[*ast.Object]()
positionType = reflect.TypeFor[token.Pos]()
callExprType = reflect.TypeFor[*ast.CallExpr]()
scopePtrType = reflect.TypeFor[*ast.Scope]()
)
// apply replaces each AST field x in val with f(x), returning val.

View File

@@ -99,7 +99,7 @@ import (
//
// <symbolic constant name>
// Special symbolic constants for ARM64 (such as conditional flags, tlbi_op and so on)
// and RISCV64 (such as names for vector configuration instruction arguments).
// and RISCV64 (such as names for vector configuration instruction arguments and CSRs).
// Encoding:
// type = TYPE_SPECIAL
// offset = The constant value corresponding to this symbol

View File

@@ -324,7 +324,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
q = c.ctxt.StartUnsafePoint(q, c.newprog)
q = obj.Appendp(q, newprog)
q.As = mov
q.As = AMOVVP
q.Pos = p.Pos
q.From.Type = obj.TYPE_REG
q.From.Reg = REGLINK

View File

@@ -314,6 +314,258 @@ var Anames = []string{
"VLE16FFV",
"VLE32FFV",
"VLE64FFV",
"VLSEG2E8V",
"VLSEG3E8V",
"VLSEG4E8V",
"VLSEG5E8V",
"VLSEG6E8V",
"VLSEG7E8V",
"VLSEG8E8V",
"VLSEG2E16V",
"VLSEG3E16V",
"VLSEG4E16V",
"VLSEG5E16V",
"VLSEG6E16V",
"VLSEG7E16V",
"VLSEG8E16V",
"VLSEG2E32V",
"VLSEG3E32V",
"VLSEG4E32V",
"VLSEG5E32V",
"VLSEG6E32V",
"VLSEG7E32V",
"VLSEG8E32V",
"VLSEG2E64V",
"VLSEG3E64V",
"VLSEG4E64V",
"VLSEG5E64V",
"VLSEG6E64V",
"VLSEG7E64V",
"VLSEG8E64V",
"VSSEG2E8V",
"VSSEG3E8V",
"VSSEG4E8V",
"VSSEG5E8V",
"VSSEG6E8V",
"VSSEG7E8V",
"VSSEG8E8V",
"VSSEG2E16V",
"VSSEG3E16V",
"VSSEG4E16V",
"VSSEG5E16V",
"VSSEG6E16V",
"VSSEG7E16V",
"VSSEG8E16V",
"VSSEG2E32V",
"VSSEG3E32V",
"VSSEG4E32V",
"VSSEG5E32V",
"VSSEG6E32V",
"VSSEG7E32V",
"VSSEG8E32V",
"VSSEG2E64V",
"VSSEG3E64V",
"VSSEG4E64V",
"VSSEG5E64V",
"VSSEG6E64V",
"VSSEG7E64V",
"VSSEG8E64V",
"VLSEG2E8FFV",
"VLSEG3E8FFV",
"VLSEG4E8FFV",
"VLSEG5E8FFV",
"VLSEG6E8FFV",
"VLSEG7E8FFV",
"VLSEG8E8FFV",
"VLSEG2E16FFV",
"VLSEG3E16FFV",
"VLSEG4E16FFV",
"VLSEG5E16FFV",
"VLSEG6E16FFV",
"VLSEG7E16FFV",
"VLSEG8E16FFV",
"VLSEG2E32FFV",
"VLSEG3E32FFV",
"VLSEG4E32FFV",
"VLSEG5E32FFV",
"VLSEG6E32FFV",
"VLSEG7E32FFV",
"VLSEG8E32FFV",
"VLSEG2E64FFV",
"VLSEG3E64FFV",
"VLSEG4E64FFV",
"VLSEG5E64FFV",
"VLSEG6E64FFV",
"VLSEG7E64FFV",
"VLSEG8E64FFV",
"VLSSEG2E8V",
"VLSSEG3E8V",
"VLSSEG4E8V",
"VLSSEG5E8V",
"VLSSEG6E8V",
"VLSSEG7E8V",
"VLSSEG8E8V",
"VLSSEG2E16V",
"VLSSEG3E16V",
"VLSSEG4E16V",
"VLSSEG5E16V",
"VLSSEG6E16V",
"VLSSEG7E16V",
"VLSSEG8E16V",
"VLSSEG2E32V",
"VLSSEG3E32V",
"VLSSEG4E32V",
"VLSSEG5E32V",
"VLSSEG6E32V",
"VLSSEG7E32V",
"VLSSEG8E32V",
"VLSSEG2E64V",
"VLSSEG3E64V",
"VLSSEG4E64V",
"VLSSEG5E64V",
"VLSSEG6E64V",
"VLSSEG7E64V",
"VLSSEG8E64V",
"VSSSEG2E8V",
"VSSSEG3E8V",
"VSSSEG4E8V",
"VSSSEG5E8V",
"VSSSEG6E8V",
"VSSSEG7E8V",
"VSSSEG8E8V",
"VSSSEG2E16V",
"VSSSEG3E16V",
"VSSSEG4E16V",
"VSSSEG5E16V",
"VSSSEG6E16V",
"VSSSEG7E16V",
"VSSSEG8E16V",
"VSSSEG2E32V",
"VSSSEG3E32V",
"VSSSEG4E32V",
"VSSSEG5E32V",
"VSSSEG6E32V",
"VSSSEG7E32V",
"VSSSEG8E32V",
"VSSSEG2E64V",
"VSSSEG3E64V",
"VSSSEG4E64V",
"VSSSEG5E64V",
"VSSSEG6E64V",
"VSSSEG7E64V",
"VSSSEG8E64V",
"VLOXSEG2EI8V",
"VLOXSEG3EI8V",
"VLOXSEG4EI8V",
"VLOXSEG5EI8V",
"VLOXSEG6EI8V",
"VLOXSEG7EI8V",
"VLOXSEG8EI8V",
"VLOXSEG2EI16V",
"VLOXSEG3EI16V",
"VLOXSEG4EI16V",
"VLOXSEG5EI16V",
"VLOXSEG6EI16V",
"VLOXSEG7EI16V",
"VLOXSEG8EI16V",
"VLOXSEG2EI32V",
"VLOXSEG3EI32V",
"VLOXSEG4EI32V",
"VLOXSEG5EI32V",
"VLOXSEG6EI32V",
"VLOXSEG7EI32V",
"VLOXSEG8EI32V",
"VLOXSEG2EI64V",
"VLOXSEG3EI64V",
"VLOXSEG4EI64V",
"VLOXSEG5EI64V",
"VLOXSEG6EI64V",
"VLOXSEG7EI64V",
"VLOXSEG8EI64V",
"VSOXSEG2EI8V",
"VSOXSEG3EI8V",
"VSOXSEG4EI8V",
"VSOXSEG5EI8V",
"VSOXSEG6EI8V",
"VSOXSEG7EI8V",
"VSOXSEG8EI8V",
"VSOXSEG2EI16V",
"VSOXSEG3EI16V",
"VSOXSEG4EI16V",
"VSOXSEG5EI16V",
"VSOXSEG6EI16V",
"VSOXSEG7EI16V",
"VSOXSEG8EI16V",
"VSOXSEG2EI32V",
"VSOXSEG3EI32V",
"VSOXSEG4EI32V",
"VSOXSEG5EI32V",
"VSOXSEG6EI32V",
"VSOXSEG7EI32V",
"VSOXSEG8EI32V",
"VSOXSEG2EI64V",
"VSOXSEG3EI64V",
"VSOXSEG4EI64V",
"VSOXSEG5EI64V",
"VSOXSEG6EI64V",
"VSOXSEG7EI64V",
"VSOXSEG8EI64V",
"VLUXSEG2EI8V",
"VLUXSEG3EI8V",
"VLUXSEG4EI8V",
"VLUXSEG5EI8V",
"VLUXSEG6EI8V",
"VLUXSEG7EI8V",
"VLUXSEG8EI8V",
"VLUXSEG2EI16V",
"VLUXSEG3EI16V",
"VLUXSEG4EI16V",
"VLUXSEG5EI16V",
"VLUXSEG6EI16V",
"VLUXSEG7EI16V",
"VLUXSEG8EI16V",
"VLUXSEG2EI32V",
"VLUXSEG3EI32V",
"VLUXSEG4EI32V",
"VLUXSEG5EI32V",
"VLUXSEG6EI32V",
"VLUXSEG7EI32V",
"VLUXSEG8EI32V",
"VLUXSEG2EI64V",
"VLUXSEG3EI64V",
"VLUXSEG4EI64V",
"VLUXSEG5EI64V",
"VLUXSEG6EI64V",
"VLUXSEG7EI64V",
"VLUXSEG8EI64V",
"VSUXSEG2EI8V",
"VSUXSEG3EI8V",
"VSUXSEG4EI8V",
"VSUXSEG5EI8V",
"VSUXSEG6EI8V",
"VSUXSEG7EI8V",
"VSUXSEG8EI8V",
"VSUXSEG2EI16V",
"VSUXSEG3EI16V",
"VSUXSEG4EI16V",
"VSUXSEG5EI16V",
"VSUXSEG6EI16V",
"VSUXSEG7EI16V",
"VSUXSEG8EI16V",
"VSUXSEG2EI32V",
"VSUXSEG3EI32V",
"VSUXSEG4EI32V",
"VSUXSEG5EI32V",
"VSUXSEG6EI32V",
"VSUXSEG7EI32V",
"VSUXSEG8EI32V",
"VSUXSEG2EI64V",
"VSUXSEG3EI64V",
"VSUXSEG4EI64V",
"VSUXSEG5EI64V",
"VSUXSEG6EI64V",
"VSUXSEG7EI64V",
"VSUXSEG8EI64V",
"VL1RE8V",
"VL1RE16V",
"VL1RE32V",

View File

@@ -35,6 +35,8 @@ import (
"cmd/internal/obj"
)
var CSRs map[uint16]string = csrs
//go:generate go run ../stringer.go -i $GOFILE -o anames.go -p riscv
const (
@@ -742,6 +744,272 @@ const (
AVLE32FFV
AVLE64FFV
// 31.7.8. Vector Load/Store Segment Instructions
// 31.7.8.1. Vector Unit-Stride Segment Loads and Stores
AVLSEG2E8V
AVLSEG3E8V
AVLSEG4E8V
AVLSEG5E8V
AVLSEG6E8V
AVLSEG7E8V
AVLSEG8E8V
AVLSEG2E16V
AVLSEG3E16V
AVLSEG4E16V
AVLSEG5E16V
AVLSEG6E16V
AVLSEG7E16V
AVLSEG8E16V
AVLSEG2E32V
AVLSEG3E32V
AVLSEG4E32V
AVLSEG5E32V
AVLSEG6E32V
AVLSEG7E32V
AVLSEG8E32V
AVLSEG2E64V
AVLSEG3E64V
AVLSEG4E64V
AVLSEG5E64V
AVLSEG6E64V
AVLSEG7E64V
AVLSEG8E64V
AVSSEG2E8V
AVSSEG3E8V
AVSSEG4E8V
AVSSEG5E8V
AVSSEG6E8V
AVSSEG7E8V
AVSSEG8E8V
AVSSEG2E16V
AVSSEG3E16V
AVSSEG4E16V
AVSSEG5E16V
AVSSEG6E16V
AVSSEG7E16V
AVSSEG8E16V
AVSSEG2E32V
AVSSEG3E32V
AVSSEG4E32V
AVSSEG5E32V
AVSSEG6E32V
AVSSEG7E32V
AVSSEG8E32V
AVSSEG2E64V
AVSSEG3E64V
AVSSEG4E64V
AVSSEG5E64V
AVSSEG6E64V
AVSSEG7E64V
AVSSEG8E64V
AVLSEG2E8FFV
AVLSEG3E8FFV
AVLSEG4E8FFV
AVLSEG5E8FFV
AVLSEG6E8FFV
AVLSEG7E8FFV
AVLSEG8E8FFV
AVLSEG2E16FFV
AVLSEG3E16FFV
AVLSEG4E16FFV
AVLSEG5E16FFV
AVLSEG6E16FFV
AVLSEG7E16FFV
AVLSEG8E16FFV
AVLSEG2E32FFV
AVLSEG3E32FFV
AVLSEG4E32FFV
AVLSEG5E32FFV
AVLSEG6E32FFV
AVLSEG7E32FFV
AVLSEG8E32FFV
AVLSEG2E64FFV
AVLSEG3E64FFV
AVLSEG4E64FFV
AVLSEG5E64FFV
AVLSEG6E64FFV
AVLSEG7E64FFV
AVLSEG8E64FFV
// 31.7.8.2. Vector Strided Segment Loads and Stores
AVLSSEG2E8V
AVLSSEG3E8V
AVLSSEG4E8V
AVLSSEG5E8V
AVLSSEG6E8V
AVLSSEG7E8V
AVLSSEG8E8V
AVLSSEG2E16V
AVLSSEG3E16V
AVLSSEG4E16V
AVLSSEG5E16V
AVLSSEG6E16V
AVLSSEG7E16V
AVLSSEG8E16V
AVLSSEG2E32V
AVLSSEG3E32V
AVLSSEG4E32V
AVLSSEG5E32V
AVLSSEG6E32V
AVLSSEG7E32V
AVLSSEG8E32V
AVLSSEG2E64V
AVLSSEG3E64V
AVLSSEG4E64V
AVLSSEG5E64V
AVLSSEG6E64V
AVLSSEG7E64V
AVLSSEG8E64V
AVSSSEG2E8V
AVSSSEG3E8V
AVSSSEG4E8V
AVSSSEG5E8V
AVSSSEG6E8V
AVSSSEG7E8V
AVSSSEG8E8V
AVSSSEG2E16V
AVSSSEG3E16V
AVSSSEG4E16V
AVSSSEG5E16V
AVSSSEG6E16V
AVSSSEG7E16V
AVSSSEG8E16V
AVSSSEG2E32V
AVSSSEG3E32V
AVSSSEG4E32V
AVSSSEG5E32V
AVSSSEG6E32V
AVSSSEG7E32V
AVSSSEG8E32V
AVSSSEG2E64V
AVSSSEG3E64V
AVSSSEG4E64V
AVSSSEG5E64V
AVSSSEG6E64V
AVSSSEG7E64V
AVSSSEG8E64V
// 31.7.8.3. Vector Indexed Segment Loads and Stores
AVLOXSEG2EI8V
AVLOXSEG3EI8V
AVLOXSEG4EI8V
AVLOXSEG5EI8V
AVLOXSEG6EI8V
AVLOXSEG7EI8V
AVLOXSEG8EI8V
AVLOXSEG2EI16V
AVLOXSEG3EI16V
AVLOXSEG4EI16V
AVLOXSEG5EI16V
AVLOXSEG6EI16V
AVLOXSEG7EI16V
AVLOXSEG8EI16V
AVLOXSEG2EI32V
AVLOXSEG3EI32V
AVLOXSEG4EI32V
AVLOXSEG5EI32V
AVLOXSEG6EI32V
AVLOXSEG7EI32V
AVLOXSEG8EI32V
AVLOXSEG2EI64V
AVLOXSEG3EI64V
AVLOXSEG4EI64V
AVLOXSEG5EI64V
AVLOXSEG6EI64V
AVLOXSEG7EI64V
AVLOXSEG8EI64V
AVSOXSEG2EI8V
AVSOXSEG3EI8V
AVSOXSEG4EI8V
AVSOXSEG5EI8V
AVSOXSEG6EI8V
AVSOXSEG7EI8V
AVSOXSEG8EI8V
AVSOXSEG2EI16V
AVSOXSEG3EI16V
AVSOXSEG4EI16V
AVSOXSEG5EI16V
AVSOXSEG6EI16V
AVSOXSEG7EI16V
AVSOXSEG8EI16V
AVSOXSEG2EI32V
AVSOXSEG3EI32V
AVSOXSEG4EI32V
AVSOXSEG5EI32V
AVSOXSEG6EI32V
AVSOXSEG7EI32V
AVSOXSEG8EI32V
AVSOXSEG2EI64V
AVSOXSEG3EI64V
AVSOXSEG4EI64V
AVSOXSEG5EI64V
AVSOXSEG6EI64V
AVSOXSEG7EI64V
AVSOXSEG8EI64V
AVLUXSEG2EI8V
AVLUXSEG3EI8V
AVLUXSEG4EI8V
AVLUXSEG5EI8V
AVLUXSEG6EI8V
AVLUXSEG7EI8V
AVLUXSEG8EI8V
AVLUXSEG2EI16V
AVLUXSEG3EI16V
AVLUXSEG4EI16V
AVLUXSEG5EI16V
AVLUXSEG6EI16V
AVLUXSEG7EI16V
AVLUXSEG8EI16V
AVLUXSEG2EI32V
AVLUXSEG3EI32V
AVLUXSEG4EI32V
AVLUXSEG5EI32V
AVLUXSEG6EI32V
AVLUXSEG7EI32V
AVLUXSEG8EI32V
AVLUXSEG2EI64V
AVLUXSEG3EI64V
AVLUXSEG4EI64V
AVLUXSEG5EI64V
AVLUXSEG6EI64V
AVLUXSEG7EI64V
AVLUXSEG8EI64V
AVSUXSEG2EI8V
AVSUXSEG3EI8V
AVSUXSEG4EI8V
AVSUXSEG5EI8V
AVSUXSEG6EI8V
AVSUXSEG7EI8V
AVSUXSEG8EI8V
AVSUXSEG2EI16V
AVSUXSEG3EI16V
AVSUXSEG4EI16V
AVSUXSEG5EI16V
AVSUXSEG6EI16V
AVSUXSEG7EI16V
AVSUXSEG8EI16V
AVSUXSEG2EI32V
AVSUXSEG3EI32V
AVSUXSEG4EI32V
AVSUXSEG5EI32V
AVSUXSEG6EI32V
AVSUXSEG7EI32V
AVSUXSEG8EI32V
AVSUXSEG2EI64V
AVSUXSEG3EI64V
AVSUXSEG4EI64V
AVSUXSEG5EI64V
AVSUXSEG6EI64V
AVSUXSEG7EI64V
AVSUXSEG8EI64V
// 31.7.9: Vector Load/Store Whole Register Instructions
AVL1RE8V
AVL1RE16V
@@ -1315,9 +1583,10 @@ type SpecialOperand int
const (
SPOP_BEGIN SpecialOperand = obj.SpecialOperandRISCVBase
SPOP_RVV_BEGIN
// Vector mask policy.
SPOP_MA SpecialOperand = obj.SpecialOperandRISCVBase + iota - 1
SPOP_MA SpecialOperand = obj.SpecialOperandRISCVBase + iota - 2
SPOP_MU
// Vector tail policy.
@@ -1338,8 +1607,13 @@ const (
SPOP_E16
SPOP_E32
SPOP_E64
SPOP_RVV_END
SPOP_END
// CSR names. 4096 special operands are reserved for RISC-V CSR names.
SPOP_CSR_BEGIN = SPOP_RVV_END
SPOP_CSR_END = SPOP_CSR_BEGIN + 4096
SPOP_END = SPOP_CSR_END + 1
)
var specialOperands = map[SpecialOperand]struct {
@@ -1367,17 +1641,33 @@ var specialOperands = map[SpecialOperand]struct {
}
func (so SpecialOperand) encode() uint32 {
op, ok := specialOperands[so]
if ok {
return op.encoding
switch {
case so >= SPOP_RVV_BEGIN && so < SPOP_RVV_END:
op, ok := specialOperands[so]
if ok {
return op.encoding
}
case so >= SPOP_CSR_BEGIN && so < SPOP_CSR_END:
csrNum := uint16(so - SPOP_CSR_BEGIN)
if _, ok := csrs[csrNum]; ok {
return uint32(csrNum)
}
}
return 0
}
// String returns the textual representation of a SpecialOperand.
func (so SpecialOperand) String() string {
op, ok := specialOperands[so]
if ok {
return op.name
switch {
case so >= SPOP_RVV_BEGIN && so < SPOP_RVV_END:
op, ok := specialOperands[so]
if ok {
return op.name
}
case so >= SPOP_CSR_BEGIN && so < SPOP_CSR_END:
if csrName, ok := csrs[uint16(so-SPOP_CSR_BEGIN)]; ok {
return csrName
}
}
return ""
}

View File

@@ -808,46 +808,326 @@ func encode(a obj.As) *inst {
return &inst{0x7, 0x0, 0x0, 0x8, -472, 0x71}
case AVLE16V:
return &inst{0x7, 0x5, 0x0, 0x0, 0, 0x0}
case AVLSEG2E16V:
return &inst{0x7, 0x5, 0x0, 0x0, 512, 0x10}
case AVLSEG3E16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1024, 0x20}
case AVLSEG4E16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1536, 0x30}
case AVLSEG5E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -2048, 0x40}
case AVLSEG6E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1536, 0x50}
case AVLSEG7E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1024, 0x60}
case AVLSEG8E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -512, 0x70}
case AVLE16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, 16, 0x0}
case AVLSEG2E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, 528, 0x10}
case AVLSEG3E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, 1040, 0x20}
case AVLSEG4E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, 1552, 0x30}
case AVLSEG5E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, -2032, 0x40}
case AVLSEG6E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, -1520, 0x50}
case AVLSEG7E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, -1008, 0x60}
case AVLSEG8E16FFV:
return &inst{0x7, 0x5, 0x0, 0x10, -496, 0x70}
case AVLE32V:
return &inst{0x7, 0x6, 0x0, 0x0, 0, 0x0}
case AVLSEG2E32V:
return &inst{0x7, 0x6, 0x0, 0x0, 512, 0x10}
case AVLSEG3E32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1024, 0x20}
case AVLSEG4E32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1536, 0x30}
case AVLSEG5E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -2048, 0x40}
case AVLSEG6E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1536, 0x50}
case AVLSEG7E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1024, 0x60}
case AVLSEG8E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -512, 0x70}
case AVLE32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, 16, 0x0}
case AVLSEG2E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, 528, 0x10}
case AVLSEG3E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, 1040, 0x20}
case AVLSEG4E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, 1552, 0x30}
case AVLSEG5E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, -2032, 0x40}
case AVLSEG6E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, -1520, 0x50}
case AVLSEG7E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, -1008, 0x60}
case AVLSEG8E32FFV:
return &inst{0x7, 0x6, 0x0, 0x10, -496, 0x70}
case AVLE64V:
return &inst{0x7, 0x7, 0x0, 0x0, 0, 0x0}
case AVLSEG2E64V:
return &inst{0x7, 0x7, 0x0, 0x0, 512, 0x10}
case AVLSEG3E64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1024, 0x20}
case AVLSEG4E64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1536, 0x30}
case AVLSEG5E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -2048, 0x40}
case AVLSEG6E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1536, 0x50}
case AVLSEG7E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1024, 0x60}
case AVLSEG8E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -512, 0x70}
case AVLE64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, 16, 0x0}
case AVLSEG2E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, 528, 0x10}
case AVLSEG3E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, 1040, 0x20}
case AVLSEG4E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, 1552, 0x30}
case AVLSEG5E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, -2032, 0x40}
case AVLSEG6E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, -1520, 0x50}
case AVLSEG7E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, -1008, 0x60}
case AVLSEG8E64FFV:
return &inst{0x7, 0x7, 0x0, 0x10, -496, 0x70}
case AVLE8V:
return &inst{0x7, 0x0, 0x0, 0x0, 0, 0x0}
case AVLSEG2E8V:
return &inst{0x7, 0x0, 0x0, 0x0, 512, 0x10}
case AVLSEG3E8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1024, 0x20}
case AVLSEG4E8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1536, 0x30}
case AVLSEG5E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -2048, 0x40}
case AVLSEG6E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1536, 0x50}
case AVLSEG7E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1024, 0x60}
case AVLSEG8E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -512, 0x70}
case AVLE8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, 16, 0x0}
case AVLSEG2E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, 528, 0x10}
case AVLSEG3E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, 1040, 0x20}
case AVLSEG4E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, 1552, 0x30}
case AVLSEG5E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, -2032, 0x40}
case AVLSEG6E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, -1520, 0x50}
case AVLSEG7E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, -1008, 0x60}
case AVLSEG8E8FFV:
return &inst{0x7, 0x0, 0x0, 0x10, -496, 0x70}
case AVLMV:
return &inst{0x7, 0x0, 0x0, 0xb, 43, 0x1}
case AVLOXEI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 192, 0x6}
case AVLOXSEG2EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 704, 0x16}
case AVLOXSEG3EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1216, 0x26}
case AVLOXSEG4EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1728, 0x36}
case AVLOXSEG5EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1856, 0x46}
case AVLOXSEG6EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1344, 0x56}
case AVLOXSEG7EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -832, 0x66}
case AVLOXSEG8EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -320, 0x76}
case AVLOXEI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 192, 0x6}
case AVLOXSEG2EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 704, 0x16}
case AVLOXSEG3EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1216, 0x26}
case AVLOXSEG4EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1728, 0x36}
case AVLOXSEG5EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1856, 0x46}
case AVLOXSEG6EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1344, 0x56}
case AVLOXSEG7EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -832, 0x66}
case AVLOXSEG8EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -320, 0x76}
case AVLOXEI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 192, 0x6}
case AVLOXSEG2EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 704, 0x16}
case AVLOXSEG3EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1216, 0x26}
case AVLOXSEG4EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1728, 0x36}
case AVLOXSEG5EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1856, 0x46}
case AVLOXSEG6EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1344, 0x56}
case AVLOXSEG7EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -832, 0x66}
case AVLOXSEG8EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -320, 0x76}
case AVLOXEI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 192, 0x6}
case AVLOXSEG2EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 704, 0x16}
case AVLOXSEG3EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1216, 0x26}
case AVLOXSEG4EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1728, 0x36}
case AVLOXSEG5EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1856, 0x46}
case AVLOXSEG6EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1344, 0x56}
case AVLOXSEG7EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -832, 0x66}
case AVLOXSEG8EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -320, 0x76}
case AVLSE16V:
return &inst{0x7, 0x5, 0x0, 0x0, 128, 0x4}
case AVLSSEG2E16V:
return &inst{0x7, 0x5, 0x0, 0x0, 640, 0x14}
case AVLSSEG3E16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1152, 0x24}
case AVLSSEG4E16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1664, 0x34}
case AVLSSEG5E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1920, 0x44}
case AVLSSEG6E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1408, 0x54}
case AVLSSEG7E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -896, 0x64}
case AVLSSEG8E16V:
return &inst{0x7, 0x5, 0x0, 0x0, -384, 0x74}
case AVLSE32V:
return &inst{0x7, 0x6, 0x0, 0x0, 128, 0x4}
case AVLSSEG2E32V:
return &inst{0x7, 0x6, 0x0, 0x0, 640, 0x14}
case AVLSSEG3E32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1152, 0x24}
case AVLSSEG4E32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1664, 0x34}
case AVLSSEG5E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1920, 0x44}
case AVLSSEG6E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1408, 0x54}
case AVLSSEG7E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -896, 0x64}
case AVLSSEG8E32V:
return &inst{0x7, 0x6, 0x0, 0x0, -384, 0x74}
case AVLSE64V:
return &inst{0x7, 0x7, 0x0, 0x0, 128, 0x4}
case AVLSSEG2E64V:
return &inst{0x7, 0x7, 0x0, 0x0, 640, 0x14}
case AVLSSEG3E64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1152, 0x24}
case AVLSSEG4E64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1664, 0x34}
case AVLSSEG5E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1920, 0x44}
case AVLSSEG6E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1408, 0x54}
case AVLSSEG7E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -896, 0x64}
case AVLSSEG8E64V:
return &inst{0x7, 0x7, 0x0, 0x0, -384, 0x74}
case AVLSE8V:
return &inst{0x7, 0x0, 0x0, 0x0, 128, 0x4}
case AVLSSEG2E8V:
return &inst{0x7, 0x0, 0x0, 0x0, 640, 0x14}
case AVLSSEG3E8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1152, 0x24}
case AVLSSEG4E8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1664, 0x34}
case AVLSSEG5E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1920, 0x44}
case AVLSSEG6E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1408, 0x54}
case AVLSSEG7E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -896, 0x64}
case AVLSSEG8E8V:
return &inst{0x7, 0x0, 0x0, 0x0, -384, 0x74}
case AVLUXEI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 64, 0x2}
case AVLUXSEG2EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 576, 0x12}
case AVLUXSEG3EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1088, 0x22}
case AVLUXSEG4EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, 1600, 0x32}
case AVLUXSEG5EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1984, 0x42}
case AVLUXSEG6EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -1472, 0x52}
case AVLUXSEG7EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -960, 0x62}
case AVLUXSEG8EI16V:
return &inst{0x7, 0x5, 0x0, 0x0, -448, 0x72}
case AVLUXEI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 64, 0x2}
case AVLUXSEG2EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 576, 0x12}
case AVLUXSEG3EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1088, 0x22}
case AVLUXSEG4EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, 1600, 0x32}
case AVLUXSEG5EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1984, 0x42}
case AVLUXSEG6EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -1472, 0x52}
case AVLUXSEG7EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -960, 0x62}
case AVLUXSEG8EI32V:
return &inst{0x7, 0x6, 0x0, 0x0, -448, 0x72}
case AVLUXEI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 64, 0x2}
case AVLUXSEG2EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 576, 0x12}
case AVLUXSEG3EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1088, 0x22}
case AVLUXSEG4EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, 1600, 0x32}
case AVLUXSEG5EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1984, 0x42}
case AVLUXSEG6EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -1472, 0x52}
case AVLUXSEG7EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -960, 0x62}
case AVLUXSEG8EI64V:
return &inst{0x7, 0x7, 0x0, 0x0, -448, 0x72}
case AVLUXEI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 64, 0x2}
case AVLUXSEG2EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 576, 0x12}
case AVLUXSEG3EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1088, 0x22}
case AVLUXSEG4EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, 1600, 0x32}
case AVLUXSEG5EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1984, 0x42}
case AVLUXSEG6EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -1472, 0x52}
case AVLUXSEG7EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -960, 0x62}
case AVLUXSEG8EI8V:
return &inst{0x7, 0x0, 0x0, 0x0, -448, 0x72}
case AVMACCVV:
return &inst{0x57, 0x2, 0x0, 0x0, -1216, 0x5a}
case AVMACCVX:
@@ -1114,12 +1394,68 @@ func encode(a obj.As) *inst {
return &inst{0x57, 0x4, 0x0, 0x0, 1152, 0x24}
case AVSE16V:
return &inst{0x27, 0x5, 0x0, 0x0, 0, 0x0}
case AVSSEG2E16V:
return &inst{0x27, 0x5, 0x0, 0x0, 512, 0x10}
case AVSSEG3E16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1024, 0x20}
case AVSSEG4E16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1536, 0x30}
case AVSSEG5E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -2048, 0x40}
case AVSSEG6E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1536, 0x50}
case AVSSEG7E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1024, 0x60}
case AVSSEG8E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -512, 0x70}
case AVSE32V:
return &inst{0x27, 0x6, 0x0, 0x0, 0, 0x0}
case AVSSEG2E32V:
return &inst{0x27, 0x6, 0x0, 0x0, 512, 0x10}
case AVSSEG3E32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1024, 0x20}
case AVSSEG4E32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1536, 0x30}
case AVSSEG5E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -2048, 0x40}
case AVSSEG6E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1536, 0x50}
case AVSSEG7E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1024, 0x60}
case AVSSEG8E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -512, 0x70}
case AVSE64V:
return &inst{0x27, 0x7, 0x0, 0x0, 0, 0x0}
case AVSSEG2E64V:
return &inst{0x27, 0x7, 0x0, 0x0, 512, 0x10}
case AVSSEG3E64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1024, 0x20}
case AVSSEG4E64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1536, 0x30}
case AVSSEG5E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -2048, 0x40}
case AVSSEG6E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1536, 0x50}
case AVSSEG7E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1024, 0x60}
case AVSSEG8E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -512, 0x70}
case AVSE8V:
return &inst{0x27, 0x0, 0x0, 0x0, 0, 0x0}
case AVSSEG2E8V:
return &inst{0x27, 0x0, 0x0, 0x0, 512, 0x10}
case AVSSEG3E8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1024, 0x20}
case AVSSEG4E8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1536, 0x30}
case AVSSEG5E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -2048, 0x40}
case AVSSEG6E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1536, 0x50}
case AVSSEG7E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1024, 0x60}
case AVSSEG8E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -512, 0x70}
case AVSETIVLI:
return &inst{0x57, 0x7, 0x0, 0x0, -1024, 0x60}
case AVSETVL:
@@ -1158,12 +1494,68 @@ func encode(a obj.As) *inst {
return &inst{0x57, 0x4, 0x0, 0x0, -1600, 0x4e}
case AVSOXEI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 192, 0x6}
case AVSOXSEG2EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 704, 0x16}
case AVSOXSEG3EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1216, 0x26}
case AVSOXSEG4EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1728, 0x36}
case AVSOXSEG5EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1856, 0x46}
case AVSOXSEG6EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1344, 0x56}
case AVSOXSEG7EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -832, 0x66}
case AVSOXSEG8EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -320, 0x76}
case AVSOXEI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 192, 0x6}
case AVSOXSEG2EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 704, 0x16}
case AVSOXSEG3EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1216, 0x26}
case AVSOXSEG4EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1728, 0x36}
case AVSOXSEG5EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1856, 0x46}
case AVSOXSEG6EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1344, 0x56}
case AVSOXSEG7EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -832, 0x66}
case AVSOXSEG8EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -320, 0x76}
case AVSOXEI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 192, 0x6}
case AVSOXSEG2EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 704, 0x16}
case AVSOXSEG3EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1216, 0x26}
case AVSOXSEG4EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1728, 0x36}
case AVSOXSEG5EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1856, 0x46}
case AVSOXSEG6EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1344, 0x56}
case AVSOXSEG7EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -832, 0x66}
case AVSOXSEG8EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -320, 0x76}
case AVSOXEI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 192, 0x6}
case AVSOXSEG2EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 704, 0x16}
case AVSOXSEG3EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1216, 0x26}
case AVSOXSEG4EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1728, 0x36}
case AVSOXSEG5EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1856, 0x46}
case AVSOXSEG6EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1344, 0x56}
case AVSOXSEG7EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -832, 0x66}
case AVSOXSEG8EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -320, 0x76}
case AVSRAVI:
return &inst{0x57, 0x3, 0x0, 0x0, -1472, 0x52}
case AVSRAVV:
@@ -1178,12 +1570,68 @@ func encode(a obj.As) *inst {
return &inst{0x57, 0x4, 0x0, 0x0, -1536, 0x50}
case AVSSE16V:
return &inst{0x27, 0x5, 0x0, 0x0, 128, 0x4}
case AVSSSEG2E16V:
return &inst{0x27, 0x5, 0x0, 0x0, 640, 0x14}
case AVSSSEG3E16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1152, 0x24}
case AVSSSEG4E16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1664, 0x34}
case AVSSSEG5E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1920, 0x44}
case AVSSSEG6E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1408, 0x54}
case AVSSSEG7E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -896, 0x64}
case AVSSSEG8E16V:
return &inst{0x27, 0x5, 0x0, 0x0, -384, 0x74}
case AVSSE32V:
return &inst{0x27, 0x6, 0x0, 0x0, 128, 0x4}
case AVSSSEG2E32V:
return &inst{0x27, 0x6, 0x0, 0x0, 640, 0x14}
case AVSSSEG3E32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1152, 0x24}
case AVSSSEG4E32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1664, 0x34}
case AVSSSEG5E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1920, 0x44}
case AVSSSEG6E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1408, 0x54}
case AVSSSEG7E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -896, 0x64}
case AVSSSEG8E32V:
return &inst{0x27, 0x6, 0x0, 0x0, -384, 0x74}
case AVSSE64V:
return &inst{0x27, 0x7, 0x0, 0x0, 128, 0x4}
case AVSSSEG2E64V:
return &inst{0x27, 0x7, 0x0, 0x0, 640, 0x14}
case AVSSSEG3E64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1152, 0x24}
case AVSSSEG4E64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1664, 0x34}
case AVSSSEG5E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1920, 0x44}
case AVSSSEG6E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1408, 0x54}
case AVSSSEG7E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -896, 0x64}
case AVSSSEG8E64V:
return &inst{0x27, 0x7, 0x0, 0x0, -384, 0x74}
case AVSSE8V:
return &inst{0x27, 0x0, 0x0, 0x0, 128, 0x4}
case AVSSSEG2E8V:
return &inst{0x27, 0x0, 0x0, 0x0, 640, 0x14}
case AVSSSEG3E8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1152, 0x24}
case AVSSSEG4E8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1664, 0x34}
case AVSSSEG5E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1920, 0x44}
case AVSSSEG6E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1408, 0x54}
case AVSSSEG7E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -896, 0x64}
case AVSSSEG8E8V:
return &inst{0x27, 0x0, 0x0, 0x0, -384, 0x74}
case AVSSRAVI:
return &inst{0x57, 0x3, 0x0, 0x0, -1344, 0x56}
case AVSSRAVV:
@@ -1210,12 +1658,68 @@ func encode(a obj.As) *inst {
return &inst{0x57, 0x4, 0x0, 0x0, 128, 0x4}
case AVSUXEI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 64, 0x2}
case AVSUXSEG2EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 576, 0x12}
case AVSUXSEG3EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1088, 0x22}
case AVSUXSEG4EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, 1600, 0x32}
case AVSUXSEG5EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1984, 0x42}
case AVSUXSEG6EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -1472, 0x52}
case AVSUXSEG7EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -960, 0x62}
case AVSUXSEG8EI16V:
return &inst{0x27, 0x5, 0x0, 0x0, -448, 0x72}
case AVSUXEI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 64, 0x2}
case AVSUXSEG2EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 576, 0x12}
case AVSUXSEG3EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1088, 0x22}
case AVSUXSEG4EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, 1600, 0x32}
case AVSUXSEG5EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1984, 0x42}
case AVSUXSEG6EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -1472, 0x52}
case AVSUXSEG7EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -960, 0x62}
case AVSUXSEG8EI32V:
return &inst{0x27, 0x6, 0x0, 0x0, -448, 0x72}
case AVSUXEI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 64, 0x2}
case AVSUXSEG2EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 576, 0x12}
case AVSUXSEG3EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1088, 0x22}
case AVSUXSEG4EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, 1600, 0x32}
case AVSUXSEG5EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1984, 0x42}
case AVSUXSEG6EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -1472, 0x52}
case AVSUXSEG7EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -960, 0x62}
case AVSUXSEG8EI64V:
return &inst{0x27, 0x7, 0x0, 0x0, -448, 0x72}
case AVSUXEI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 64, 0x2}
case AVSUXSEG2EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 576, 0x12}
case AVSUXSEG3EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1088, 0x22}
case AVSUXSEG4EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, 1600, 0x32}
case AVSUXSEG5EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1984, 0x42}
case AVSUXSEG6EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -1472, 0x52}
case AVSUXSEG7EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -960, 0x62}
case AVSUXSEG8EI8V:
return &inst{0x27, 0x0, 0x0, 0x0, -448, 0x72}
case AVWADDVV:
return &inst{0x57, 0x2, 0x0, 0x0, -960, 0x62}
case AVWADDVX:

View File

@@ -52,9 +52,14 @@ func opSuffixString(s uint8) string {
}
func specialOperandConv(a int64) string {
var s string
spc := SpecialOperand(a)
if spc >= SPOP_BEGIN && spc < SPOP_END {
return spc.String()
s = spc.String()
}
return "SPC_??"
if s == "" {
return "SPC_??"
}
return s
}

View File

@@ -1920,7 +1920,12 @@ var instructions = [ALAST & obj.AMask]instructionData{
ASD & obj.AMask: {enc: sIEncoding},
// 7.1: CSR Instructions
ACSRRS & obj.AMask: {enc: iIIEncoding},
ACSRRC & obj.AMask: {enc: iIIEncoding, immForm: ACSRRCI},
ACSRRCI & obj.AMask: {enc: iIIEncoding},
ACSRRS & obj.AMask: {enc: iIIEncoding, immForm: ACSRRSI},
ACSRRSI & obj.AMask: {enc: iIIEncoding},
ACSRRW & obj.AMask: {enc: iIIEncoding, immForm: ACSRRWI},
ACSRRWI & obj.AMask: {enc: iIIEncoding},
// 13.1: Multiplication Operations
AMUL & obj.AMask: {enc: rIIIEncoding, ternary: true},
@@ -2146,6 +2151,260 @@ var instructions = [ALAST & obj.AMask]instructionData{
AVSOXEI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXEI64V & obj.AMask: {enc: sVIVEncoding},
// 31.7.8: Vector Load/Store Segment Instructions
AVLSEG2E8V & obj.AMask: {enc: iVEncoding},
AVLSEG3E8V & obj.AMask: {enc: iVEncoding},
AVLSEG4E8V & obj.AMask: {enc: iVEncoding},
AVLSEG5E8V & obj.AMask: {enc: iVEncoding},
AVLSEG6E8V & obj.AMask: {enc: iVEncoding},
AVLSEG7E8V & obj.AMask: {enc: iVEncoding},
AVLSEG8E8V & obj.AMask: {enc: iVEncoding},
AVLSEG2E16V & obj.AMask: {enc: iVEncoding},
AVLSEG3E16V & obj.AMask: {enc: iVEncoding},
AVLSEG4E16V & obj.AMask: {enc: iVEncoding},
AVLSEG5E16V & obj.AMask: {enc: iVEncoding},
AVLSEG6E16V & obj.AMask: {enc: iVEncoding},
AVLSEG7E16V & obj.AMask: {enc: iVEncoding},
AVLSEG8E16V & obj.AMask: {enc: iVEncoding},
AVLSEG2E32V & obj.AMask: {enc: iVEncoding},
AVLSEG3E32V & obj.AMask: {enc: iVEncoding},
AVLSEG4E32V & obj.AMask: {enc: iVEncoding},
AVLSEG5E32V & obj.AMask: {enc: iVEncoding},
AVLSEG6E32V & obj.AMask: {enc: iVEncoding},
AVLSEG7E32V & obj.AMask: {enc: iVEncoding},
AVLSEG8E32V & obj.AMask: {enc: iVEncoding},
AVLSEG2E64V & obj.AMask: {enc: iVEncoding},
AVLSEG3E64V & obj.AMask: {enc: iVEncoding},
AVLSEG4E64V & obj.AMask: {enc: iVEncoding},
AVLSEG5E64V & obj.AMask: {enc: iVEncoding},
AVLSEG6E64V & obj.AMask: {enc: iVEncoding},
AVLSEG7E64V & obj.AMask: {enc: iVEncoding},
AVLSEG8E64V & obj.AMask: {enc: iVEncoding},
AVSSEG2E8V & obj.AMask: {enc: sVEncoding},
AVSSEG3E8V & obj.AMask: {enc: sVEncoding},
AVSSEG4E8V & obj.AMask: {enc: sVEncoding},
AVSSEG5E8V & obj.AMask: {enc: sVEncoding},
AVSSEG6E8V & obj.AMask: {enc: sVEncoding},
AVSSEG7E8V & obj.AMask: {enc: sVEncoding},
AVSSEG8E8V & obj.AMask: {enc: sVEncoding},
AVSSEG2E16V & obj.AMask: {enc: sVEncoding},
AVSSEG3E16V & obj.AMask: {enc: sVEncoding},
AVSSEG4E16V & obj.AMask: {enc: sVEncoding},
AVSSEG5E16V & obj.AMask: {enc: sVEncoding},
AVSSEG6E16V & obj.AMask: {enc: sVEncoding},
AVSSEG7E16V & obj.AMask: {enc: sVEncoding},
AVSSEG8E16V & obj.AMask: {enc: sVEncoding},
AVSSEG2E32V & obj.AMask: {enc: sVEncoding},
AVSSEG3E32V & obj.AMask: {enc: sVEncoding},
AVSSEG4E32V & obj.AMask: {enc: sVEncoding},
AVSSEG5E32V & obj.AMask: {enc: sVEncoding},
AVSSEG6E32V & obj.AMask: {enc: sVEncoding},
AVSSEG7E32V & obj.AMask: {enc: sVEncoding},
AVSSEG8E32V & obj.AMask: {enc: sVEncoding},
AVSSEG2E64V & obj.AMask: {enc: sVEncoding},
AVSSEG3E64V & obj.AMask: {enc: sVEncoding},
AVSSEG4E64V & obj.AMask: {enc: sVEncoding},
AVSSEG5E64V & obj.AMask: {enc: sVEncoding},
AVSSEG6E64V & obj.AMask: {enc: sVEncoding},
AVSSEG7E64V & obj.AMask: {enc: sVEncoding},
AVSSEG8E64V & obj.AMask: {enc: sVEncoding},
AVLSEG2E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG3E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG4E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG5E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG6E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG7E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG8E8FFV & obj.AMask: {enc: iVEncoding},
AVLSEG2E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG3E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG4E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG5E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG6E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG7E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG8E16FFV & obj.AMask: {enc: iVEncoding},
AVLSEG2E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG3E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG4E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG5E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG6E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG7E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG8E32FFV & obj.AMask: {enc: iVEncoding},
AVLSEG2E64FFV & obj.AMask: {enc: iVEncoding},
AVLSEG3E64FFV & obj.AMask: {enc: iVEncoding},
AVLSEG4E64FFV & obj.AMask: {enc: iVEncoding},
AVLSEG5E64FFV & obj.AMask: {enc: iVEncoding},
AVLSEG6E64FFV & obj.AMask: {enc: iVEncoding},
AVLSEG7E64FFV & obj.AMask: {enc: iVEncoding},
AVLSEG8E64FFV & obj.AMask: {enc: iVEncoding},
AVLSSEG2E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG3E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG4E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG5E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG6E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG7E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG8E8V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG2E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG3E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG4E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG5E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG6E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG7E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG8E16V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG2E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG3E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG4E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG5E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG6E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG7E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG8E32V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG2E64V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG3E64V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG4E64V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG5E64V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG6E64V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG7E64V & obj.AMask: {enc: iIIVEncoding},
AVLSSEG8E64V & obj.AMask: {enc: iIIVEncoding},
AVSSSEG2E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG3E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG4E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG5E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG6E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG7E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG8E8V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG2E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG3E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG4E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG5E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG6E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG7E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG8E16V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG2E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG3E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG4E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG5E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG6E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG7E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG8E32V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG2E64V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG3E64V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG4E64V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG5E64V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG6E64V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG7E64V & obj.AMask: {enc: sVIIEncoding},
AVSSSEG8E64V & obj.AMask: {enc: sVIIEncoding},
AVLOXSEG2EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG3EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG4EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG5EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG6EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG7EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG8EI8V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG2EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG3EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG4EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG5EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG6EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG7EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG8EI16V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG2EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG3EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG4EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG5EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG6EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG7EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG8EI32V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG2EI64V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG3EI64V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG4EI64V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG5EI64V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG6EI64V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG7EI64V & obj.AMask: {enc: iVIVEncoding},
AVLOXSEG8EI64V & obj.AMask: {enc: iVIVEncoding},
AVSOXSEG2EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG3EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG4EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG5EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG6EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG7EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG8EI8V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG2EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG3EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG4EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG5EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG6EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG7EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG8EI16V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG2EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG3EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG4EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG5EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG6EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG7EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG8EI32V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG2EI64V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG3EI64V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG4EI64V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG5EI64V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG6EI64V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG7EI64V & obj.AMask: {enc: sVIVEncoding},
AVSOXSEG8EI64V & obj.AMask: {enc: sVIVEncoding},
AVLUXSEG2EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG3EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG4EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG5EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG6EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG7EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG8EI8V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG2EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG3EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG4EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG5EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG6EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG7EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG8EI16V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG2EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG3EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG4EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG5EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG6EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG7EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG8EI32V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG2EI64V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG3EI64V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG4EI64V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG5EI64V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG6EI64V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG7EI64V & obj.AMask: {enc: iVIVEncoding},
AVLUXSEG8EI64V & obj.AMask: {enc: iVIVEncoding},
AVSUXSEG2EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG3EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG4EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG5EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG6EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG7EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG8EI8V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG2EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG3EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG4EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG5EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG6EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG7EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG8EI16V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG2EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG3EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG4EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG5EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG6EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG7EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG8EI32V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG2EI64V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG3EI64V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG4EI64V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG5EI64V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG6EI64V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG7EI64V & obj.AMask: {enc: sVIVEncoding},
AVSUXSEG8EI64V & obj.AMask: {enc: sVIVEncoding},
// 31.7.9: Vector Load/Store Whole Register Instructions
AVL1RE8V & obj.AMask: {enc: iVEncoding},
AVL1RE16V & obj.AMask: {enc: iVEncoding},
@@ -3327,6 +3586,43 @@ func instructionsForProg(p *obj.Prog) []*instruction {
ins.imm = -1022
}
case ACSRRC, ACSRRCI, ACSRRS, ACSRRSI, ACSRRW, ACSRRWI:
if len(p.RestArgs) == 0 || p.RestArgs[0].Type != obj.TYPE_SPECIAL {
p.Ctxt.Diag("%v: missing CSR name", p)
return nil
}
if p.From.Type == obj.TYPE_CONST {
imm := p.From.Offset
if imm < 0 || imm >= 32 {
p.Ctxt.Diag("%v: immediate out of range 0 to 31", p)
return nil
}
ins.rs1 = uint32(imm) + REG_ZERO
} else if p.From.Type == obj.TYPE_REG {
ins.rs1 = uint32(p.From.Reg)
} else {
p.Ctxt.Diag("%v: integer register or immediate expected for 1st operand", p)
return nil
}
if p.To.Type != obj.TYPE_REG {
p.Ctxt.Diag("%v: needs an integer register output", p)
return nil
}
csrNum := SpecialOperand(p.RestArgs[0].Offset).encode()
if csrNum >= 1<<12 {
p.Ctxt.Diag("%v: unknown CSR", p)
return nil
}
if _, ok := CSRs[uint16(csrNum)]; !ok {
p.Ctxt.Diag("%v: unknown CSR", p)
return nil
}
ins.imm = int64(csrNum)
if ins.imm > 2047 {
ins.imm -= 4096
}
ins.rs2 = obj.REG_NONE
case AFENCE:
ins.rd, ins.rs1, ins.rs2 = REG_ZERO, REG_ZERO, obj.REG_NONE
ins.imm = 0x0ff
@@ -3497,7 +3793,19 @@ func instructionsForProg(p *obj.Prog) []*instruction {
ins.rs1 = uint32(p.From.Offset)
}
case AVLE8V, AVLE16V, AVLE32V, AVLE64V, AVSE8V, AVSE16V, AVSE32V, AVSE64V, AVLMV, AVSMV:
case AVLE8V, AVLE16V, AVLE32V, AVLE64V, AVSE8V, AVSE16V, AVSE32V, AVSE64V, AVLMV, AVSMV,
AVLSEG2E8V, AVLSEG3E8V, AVLSEG4E8V, AVLSEG5E8V, AVLSEG6E8V, AVLSEG7E8V, AVLSEG8E8V,
AVLSEG2E16V, AVLSEG3E16V, AVLSEG4E16V, AVLSEG5E16V, AVLSEG6E16V, AVLSEG7E16V, AVLSEG8E16V,
AVLSEG2E32V, AVLSEG3E32V, AVLSEG4E32V, AVLSEG5E32V, AVLSEG6E32V, AVLSEG7E32V, AVLSEG8E32V,
AVLSEG2E64V, AVLSEG3E64V, AVLSEG4E64V, AVLSEG5E64V, AVLSEG6E64V, AVLSEG7E64V, AVLSEG8E64V,
AVSSEG2E8V, AVSSEG3E8V, AVSSEG4E8V, AVSSEG5E8V, AVSSEG6E8V, AVSSEG7E8V, AVSSEG8E8V,
AVSSEG2E16V, AVSSEG3E16V, AVSSEG4E16V, AVSSEG5E16V, AVSSEG6E16V, AVSSEG7E16V, AVSSEG8E16V,
AVSSEG2E32V, AVSSEG3E32V, AVSSEG4E32V, AVSSEG5E32V, AVSSEG6E32V, AVSSEG7E32V, AVSSEG8E32V,
AVSSEG2E64V, AVSSEG3E64V, AVSSEG4E64V, AVSSEG5E64V, AVSSEG6E64V, AVSSEG7E64V, AVSSEG8E64V,
AVLSEG2E8FFV, AVLSEG3E8FFV, AVLSEG4E8FFV, AVLSEG5E8FFV, AVLSEG6E8FFV, AVLSEG7E8FFV, AVLSEG8E8FFV,
AVLSEG2E16FFV, AVLSEG3E16FFV, AVLSEG4E16FFV, AVLSEG5E16FFV, AVLSEG6E16FFV, AVLSEG7E16FFV, AVLSEG8E16FFV,
AVLSEG2E32FFV, AVLSEG3E32FFV, AVLSEG4E32FFV, AVLSEG5E32FFV, AVLSEG6E32FFV, AVLSEG7E32FFV, AVLSEG8E32FFV,
AVLSEG2E64FFV, AVLSEG3E64FFV, AVLSEG4E64FFV, AVLSEG5E64FFV, AVLSEG6E64FFV, AVLSEG7E64FFV, AVLSEG8E64FFV:
// Set mask bit
switch {
case ins.rs1 == obj.REG_NONE:
@@ -3508,7 +3816,19 @@ func instructionsForProg(p *obj.Prog) []*instruction {
ins.rd, ins.rs1, ins.rs2 = uint32(p.To.Reg), uint32(p.From.Reg), obj.REG_NONE
case AVLSE8V, AVLSE16V, AVLSE32V, AVLSE64V,
AVLUXEI8V, AVLUXEI16V, AVLUXEI32V, AVLUXEI64V, AVLOXEI8V, AVLOXEI16V, AVLOXEI32V, AVLOXEI64V:
AVLUXEI8V, AVLUXEI16V, AVLUXEI32V, AVLUXEI64V, AVLOXEI8V, AVLOXEI16V, AVLOXEI32V, AVLOXEI64V,
AVLSSEG2E8V, AVLSSEG3E8V, AVLSSEG4E8V, AVLSSEG5E8V, AVLSSEG6E8V, AVLSSEG7E8V, AVLSSEG8E8V,
AVLSSEG2E16V, AVLSSEG3E16V, AVLSSEG4E16V, AVLSSEG5E16V, AVLSSEG6E16V, AVLSSEG7E16V, AVLSSEG8E16V,
AVLSSEG2E32V, AVLSSEG3E32V, AVLSSEG4E32V, AVLSSEG5E32V, AVLSSEG6E32V, AVLSSEG7E32V, AVLSSEG8E32V,
AVLSSEG2E64V, AVLSSEG3E64V, AVLSSEG4E64V, AVLSSEG5E64V, AVLSSEG6E64V, AVLSSEG7E64V, AVLSSEG8E64V,
AVLOXSEG2EI8V, AVLOXSEG3EI8V, AVLOXSEG4EI8V, AVLOXSEG5EI8V, AVLOXSEG6EI8V, AVLOXSEG7EI8V, AVLOXSEG8EI8V,
AVLOXSEG2EI16V, AVLOXSEG3EI16V, AVLOXSEG4EI16V, AVLOXSEG5EI16V, AVLOXSEG6EI16V, AVLOXSEG7EI16V, AVLOXSEG8EI16V,
AVLOXSEG2EI32V, AVLOXSEG3EI32V, AVLOXSEG4EI32V, AVLOXSEG5EI32V, AVLOXSEG6EI32V, AVLOXSEG7EI32V, AVLOXSEG8EI32V,
AVLOXSEG2EI64V, AVLOXSEG3EI64V, AVLOXSEG4EI64V, AVLOXSEG5EI64V, AVLOXSEG6EI64V, AVLOXSEG7EI64V, AVLOXSEG8EI64V,
AVLUXSEG2EI8V, AVLUXSEG3EI8V, AVLUXSEG4EI8V, AVLUXSEG5EI8V, AVLUXSEG6EI8V, AVLUXSEG7EI8V, AVLUXSEG8EI8V,
AVLUXSEG2EI16V, AVLUXSEG3EI16V, AVLUXSEG4EI16V, AVLUXSEG5EI16V, AVLUXSEG6EI16V, AVLUXSEG7EI16V, AVLUXSEG8EI16V,
AVLUXSEG2EI32V, AVLUXSEG3EI32V, AVLUXSEG4EI32V, AVLUXSEG5EI32V, AVLUXSEG6EI32V, AVLUXSEG7EI32V, AVLUXSEG8EI32V,
AVLUXSEG2EI64V, AVLUXSEG3EI64V, AVLUXSEG4EI64V, AVLUXSEG5EI64V, AVLUXSEG6EI64V, AVLUXSEG7EI64V, AVLUXSEG8EI64V:
// Set mask bit
switch {
case ins.rs3 == obj.REG_NONE:
@@ -3519,7 +3839,19 @@ func instructionsForProg(p *obj.Prog) []*instruction {
ins.rs1, ins.rs2, ins.rs3 = ins.rs2, ins.rs1, obj.REG_NONE
case AVSSE8V, AVSSE16V, AVSSE32V, AVSSE64V,
AVSUXEI8V, AVSUXEI16V, AVSUXEI32V, AVSUXEI64V, AVSOXEI8V, AVSOXEI16V, AVSOXEI32V, AVSOXEI64V:
AVSUXEI8V, AVSUXEI16V, AVSUXEI32V, AVSUXEI64V, AVSOXEI8V, AVSOXEI16V, AVSOXEI32V, AVSOXEI64V,
AVSSSEG2E8V, AVSSSEG3E8V, AVSSSEG4E8V, AVSSSEG5E8V, AVSSSEG6E8V, AVSSSEG7E8V, AVSSSEG8E8V,
AVSSSEG2E16V, AVSSSEG3E16V, AVSSSEG4E16V, AVSSSEG5E16V, AVSSSEG6E16V, AVSSSEG7E16V, AVSSSEG8E16V,
AVSSSEG2E32V, AVSSSEG3E32V, AVSSSEG4E32V, AVSSSEG5E32V, AVSSSEG6E32V, AVSSSEG7E32V, AVSSSEG8E32V,
AVSSSEG2E64V, AVSSSEG3E64V, AVSSSEG4E64V, AVSSSEG5E64V, AVSSSEG6E64V, AVSSSEG7E64V, AVSSSEG8E64V,
AVSOXSEG2EI8V, AVSOXSEG3EI8V, AVSOXSEG4EI8V, AVSOXSEG5EI8V, AVSOXSEG6EI8V, AVSOXSEG7EI8V, AVSOXSEG8EI8V,
AVSOXSEG2EI16V, AVSOXSEG3EI16V, AVSOXSEG4EI16V, AVSOXSEG5EI16V, AVSOXSEG6EI16V, AVSOXSEG7EI16V, AVSOXSEG8EI16V,
AVSOXSEG2EI32V, AVSOXSEG3EI32V, AVSOXSEG4EI32V, AVSOXSEG5EI32V, AVSOXSEG6EI32V, AVSOXSEG7EI32V, AVSOXSEG8EI32V,
AVSOXSEG2EI64V, AVSOXSEG3EI64V, AVSOXSEG4EI64V, AVSOXSEG5EI64V, AVSOXSEG6EI64V, AVSOXSEG7EI64V, AVSOXSEG8EI64V,
AVSUXSEG2EI8V, AVSUXSEG3EI8V, AVSUXSEG4EI8V, AVSUXSEG5EI8V, AVSUXSEG6EI8V, AVSUXSEG7EI8V, AVSUXSEG8EI8V,
AVSUXSEG2EI16V, AVSUXSEG3EI16V, AVSUXSEG4EI16V, AVSUXSEG5EI16V, AVSUXSEG6EI16V, AVSUXSEG7EI16V, AVSUXSEG8EI16V,
AVSUXSEG2EI32V, AVSUXSEG3EI32V, AVSUXSEG4EI32V, AVSUXSEG5EI32V, AVSUXSEG6EI32V, AVSUXSEG7EI32V, AVSUXSEG8EI32V,
AVSUXSEG2EI64V, AVSUXSEG3EI64V, AVSUXSEG4EI64V, AVSUXSEG5EI64V, AVSUXSEG6EI64V, AVSUXSEG7EI64V, AVSUXSEG8EI64V:
// Set mask bit
switch {
case ins.rs3 == obj.REG_NONE:

View File

@@ -277,7 +277,7 @@ func (f *DebugFlag) Set(debugstr string) error {
if debugstr == "" {
return nil
}
for _, name := range strings.Split(debugstr, ",") {
for name := range strings.SplitSeq(debugstr, ",") {
if name == "" {
continue
}

View File

@@ -513,7 +513,7 @@ func lookPath(s *State, command string) (string, error) {
}
pathEnv, _ := s.LookupEnv(pathEnvName())
for _, dir := range strings.Split(pathEnv, string(filepath.ListSeparator)) {
for dir := range strings.SplitSeq(pathEnv, string(filepath.ListSeparator)) {
if dir == "" {
continue
}

View File

@@ -88,7 +88,7 @@ func pieLinkExt(s *script.State) (bool, error) {
func hasGodebug(s *script.State, value string) (bool, error) {
godebug, _ := s.LookupEnv("GODEBUG")
for _, p := range strings.Split(godebug, ",") {
for p := range strings.SplitSeq(godebug, ",") {
if strings.TrimSpace(p) == value {
return true, nil
}

View File

@@ -52,7 +52,7 @@ var (
// the linux-amd64 builder that's already very fast, so we get more
// test coverage on trybots. See https://go.dev/issue/34297.
func defaultAllCodeGen() bool {
return os.Getenv("GO_BUILDER_NAME") == "linux-amd64"
return testenv.Builder() == "gotip-linux-amd64"
}
var (

View File

@@ -627,30 +627,30 @@ func testFlagD(t *testing.T, dataAddr string, roundQuantum string, expectedAddr
defer ef.Close()
// Find the first data-related section to verify segment placement
var firstDataSectionAddr uint64
var found bool = false
var firstDataSection *elf.Section
for _, sec := range ef.Sections {
if sec.Type == elf.SHT_PROGBITS || sec.Type == elf.SHT_NOBITS {
// These sections are writable, allocated at runtime, but not executable
// nor TLS.
isWrite := sec.Flags&elf.SHF_WRITE != 0
isExec := sec.Flags&elf.SHF_EXECINSTR != 0
isAlloc := sec.Flags&elf.SHF_ALLOC != 0
isTLS := sec.Flags&elf.SHF_TLS != 0
if isWrite && !isExec && isAlloc {
addrLower := sec.Addr < firstDataSectionAddr
if !found || addrLower {
firstDataSectionAddr = sec.Addr
found = true
if isWrite && !isExec && isAlloc && !isTLS {
if firstDataSection == nil || sec.Addr < firstDataSection.Addr {
firstDataSection = sec
}
}
}
}
if !found {
if firstDataSection == nil {
t.Fatalf("can't find any writable data sections")
}
if firstDataSectionAddr != expectedAddr {
t.Errorf("data section starts at 0x%x, expected 0x%x", firstDataSectionAddr, expectedAddr)
if firstDataSection.Addr != expectedAddr {
t.Errorf("data section starts at 0x%x for section %s, expected 0x%x",
firstDataSection.Addr, firstDataSection.Name, expectedAddr)
}
}

View File

@@ -334,36 +334,7 @@ func machoreloc1(*sys.Arch, *ld.OutBuf, *loader.Loader, loader.Sym, loader.ExtRe
}
func pereloc1(arch *sys.Arch, out *ld.OutBuf, ldr *loader.Loader, s loader.Sym, r loader.ExtReloc, sectoff int64) bool {
rs := r.Xsym
rt := r.Type
if ldr.SymDynid(rs) < 0 {
ldr.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", rt, sym.RelocName(arch, rt), ldr.SymName(rs), ldr.SymType(rs), ldr.SymType(rs))
return false
}
out.Write32(uint32(sectoff))
out.Write32(uint32(ldr.SymDynid(rs)))
var v uint32
switch rt {
default:
// unsupported relocation type
return false
case objabi.R_DWARFSECREF:
v = ld.IMAGE_REL_ARM_SECREL
case objabi.R_ADDR:
v = ld.IMAGE_REL_ARM_ADDR32
case objabi.R_PEIMAGEOFF:
v = ld.IMAGE_REL_ARM_ADDR32NB
}
out.Write16(uint16(v))
return true
return false
}
// sign extend a 24-bit integer.

View File

@@ -1457,6 +1457,9 @@ func (ctxt *Link) hostlink() {
// Only macOS supports unmapped segments such as our __DWARF segment.
combineDwarf := ctxt.IsDarwin() && !*FlagW && machoPlatform == PLATFORM_MACOS
var isMSVC bool // used on Windows
wlPrefix := "-Wl,--"
switch ctxt.HeadType {
case objabi.Hdarwin:
if combineDwarf {
@@ -1501,6 +1504,15 @@ func (ctxt *Link) hostlink() {
argv = append(argv, "-Wl,--no-execute-only")
}
case objabi.Hwindows:
isMSVC = ctxt.isMSVC()
if isMSVC {
// For various options, MSVC lld-link only accepts one dash.
// TODO: It seems mingw clang supports one or two dashes,
// maybe we can always use one dash, but I'm not sure about
// legacy compilers that currently work.
wlPrefix = "-Wl,-"
}
if windowsgui {
argv = append(argv, "-mwindows")
} else {
@@ -1508,15 +1520,18 @@ func (ctxt *Link) hostlink() {
}
// Mark as having awareness of terminal services, to avoid
// ancient compatibility hacks.
argv = append(argv, "-Wl,--tsaware")
argv = append(argv, wlPrefix+"tsaware")
// Enable DEP
argv = append(argv, "-Wl,--nxcompat")
argv = append(argv, wlPrefix+"nxcompat")
argv = append(argv, fmt.Sprintf("-Wl,--major-os-version=%d", PeMinimumTargetMajorVersion))
argv = append(argv, fmt.Sprintf("-Wl,--minor-os-version=%d", PeMinimumTargetMinorVersion))
argv = append(argv, fmt.Sprintf("-Wl,--major-subsystem-version=%d", PeMinimumTargetMajorVersion))
argv = append(argv, fmt.Sprintf("-Wl,--minor-subsystem-version=%d", PeMinimumTargetMinorVersion))
if !isMSVC {
argv = append(argv, fmt.Sprintf("-Wl,--major-os-version=%d", PeMinimumTargetMajorVersion))
argv = append(argv, fmt.Sprintf("-Wl,--minor-os-version=%d", PeMinimumTargetMinorVersion))
argv = append(argv, fmt.Sprintf("-Wl,--major-subsystem-version=%d", PeMinimumTargetMajorVersion))
argv = append(argv, fmt.Sprintf("-Wl,--minor-subsystem-version=%d", PeMinimumTargetMinorVersion))
}
case objabi.Haix:
argv = append(argv, "-pthread")
// prevent ld to reorder .text functions to keep the same
@@ -1557,16 +1572,21 @@ func (ctxt *Link) hostlink() {
// an ancient compiler with ancient defaults.
var dbopt string
var heopt string
dbon := "--dynamicbase"
heon := "--high-entropy-va"
dboff := "--disable-dynamicbase"
heoff := "--disable-high-entropy-va"
dbon := wlPrefix + "dynamicbase"
heon := wlPrefix + "high-entropy-va"
dboff := wlPrefix + "disable-dynamicbase"
heoff := wlPrefix + "disable-high-entropy-va"
if isMSVC {
heon = wlPrefix + "highentropyva"
heoff = wlPrefix + "highentropyva:no"
dboff = wlPrefix + "dynamicbase:no"
}
if val {
dbopt = dbon
heopt = heon
} else {
// Test to see whether "--disable-dynamicbase" works.
newer := linkerFlagSupported(ctxt.Arch, argv[0], "", "-Wl,"+dboff)
newer := linkerFlagSupported(ctxt.Arch, argv[0], "", dboff)
if newer {
// Newer compiler, which supports both on/off options.
dbopt = dboff
@@ -1579,11 +1599,11 @@ func (ctxt *Link) hostlink() {
}
}
if dbopt != "" {
argv = append(argv, "-Wl,"+dbopt)
argv = append(argv, dbopt)
}
// enable high-entropy ASLR on 64-bit.
if ctxt.Arch.PtrSize >= 8 && heopt != "" {
argv = append(argv, "-Wl,"+heopt)
argv = append(argv, heopt)
}
return argv
}
@@ -1923,13 +1943,19 @@ func (ctxt *Link) hostlink() {
argv = append(argv, "-Wl,-T,"+p)
}
if *flagRace {
if p := ctxt.findLibPath("libsynchronization.a"); p != "libsynchronization.a" {
// Apparently --print-file-name doesn't work with -msvc clang.
// (The library name is synchronization.lib, but even with that
// name it still doesn't print the full path.) Assume it always
// it.
if isMSVC || ctxt.findLibPath("libsynchronization.a") != "libsynchronization.a" {
argv = append(argv, "-lsynchronization")
}
}
// libmingw32 and libmingwex have some inter-dependencies,
// so must use linker groups.
argv = append(argv, "-Wl,--start-group", "-lmingwex", "-lmingw32", "-Wl,--end-group")
if !isMSVC {
// libmingw32 and libmingwex have some inter-dependencies,
// so must use linker groups.
argv = append(argv, "-Wl,--start-group", "-lmingwex", "-lmingw32", "-Wl,--end-group")
}
argv = append(argv, peimporteddlls()...)
}
@@ -2182,6 +2208,7 @@ func trimLinkerArgv(argv []string) []string {
"-isysroot",
"--sysroot",
"-target",
"--target",
}
prefixesToKeep := []string{
"-f",
@@ -2192,6 +2219,7 @@ func trimLinkerArgv(argv []string) []string {
"-isysroot",
"--sysroot",
"-target",
"--target",
}
var flags []string
@@ -3024,3 +3052,19 @@ func (ctxt *Link) findExtLinkTool(toolname string) string {
cmdpath := strings.TrimRight(string(out), "\r\n")
return cmdpath
}
// isMSVC reports whether the C toolchain is clang with a -msvc target,
// e.g. the clang bundled in MSVC.
func (ctxt *Link) isMSVC() bool {
extld := ctxt.extld()
name, args := extld[0], extld[1:]
args = append(args, trimLinkerArgv(flagExtldflags)...)
args = append(args, "--version")
cmd := exec.Command(name, args...)
if out, err := cmd.CombinedOutput(); err == nil {
if bytes.Contains(out, []byte("-msvc\n")) || bytes.Contains(out, []byte("-msvc\r")) {
return true
}
}
return false
}

View File

@@ -224,51 +224,6 @@ func adddynrel(target *ld.Target, ldr *loader.Loader, syms *ld.ArchSyms, s loade
su := ldr.MakeSymbolUpdater(s)
su.SetRelocType(rIdx, objabi.R_ADDR)
return true
case objabi.MachoRelocOffset + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 0:
su := ldr.MakeSymbolUpdater(s)
su.SetRelocType(rIdx, objabi.R_ADDR)
if targType == sym.SDYNIMPORT {
ldr.Errorf(s, "unexpected reloc for dynamic symbol %s", ldr.SymName(targ))
}
return true
case objabi.MachoRelocOffset + ld.MACHO_GENERIC_RELOC_VANILLA*2 + 1:
su := ldr.MakeSymbolUpdater(s)
if targType == sym.SDYNIMPORT {
addpltsym(target, ldr, syms, targ)
su.SetRelocSym(rIdx, syms.PLT)
su.SetRelocAdd(rIdx, int64(ldr.SymPlt(targ)))
su.SetRelocType(rIdx, objabi.R_PCREL)
return true
}
su.SetRelocType(rIdx, objabi.R_PCREL)
return true
case objabi.MachoRelocOffset + ld.MACHO_FAKE_GOTPCREL:
su := ldr.MakeSymbolUpdater(s)
if targType != sym.SDYNIMPORT {
// have symbol
// turn MOVL of GOT entry into LEAL of symbol itself
sData := ldr.Data(s)
if r.Off() < 2 || sData[r.Off()-2] != 0x8b {
ldr.Errorf(s, "unexpected GOT reloc for non-dynamic symbol %s", ldr.SymName(targ))
return false
}
su.MakeWritable()
writeableData := su.Data()
writeableData[r.Off()-2] = 0x8d
su.SetRelocType(rIdx, objabi.R_PCREL)
return true
}
ld.AddGotSym(target, ldr, syms, targ, uint32(elf.R_386_GLOB_DAT))
su.SetRelocSym(rIdx, syms.GOT)
su.SetRelocAdd(rIdx, r.Add()+int64(ldr.SymGot(targ)))
su.SetRelocType(rIdx, objabi.R_PCREL)
return true
}
// Handle references to ELF symbols from our own object files.

View File

@@ -280,7 +280,7 @@ func TestBuildForTvOS(t *testing.T) {
if runtime.GOOS != "darwin" {
t.Skip("skipping on non-darwin platform")
}
if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" {
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in -short mode with $GO_BUILDER_NAME empty")
}
if err := testenv.Command(t, "xcrun", "--help").Run(); err != nil {

View File

@@ -1,21 +0,0 @@
// Copyright 2015 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.
//go:build go1.5
package plan9
import "syscall"
func fixwd() {
syscall.Fixwd()
}
func Getwd() (wd string, err error) {
return syscall.Getwd()
}
func Chdir(path string) error {
return syscall.Chdir(path)
}

View File

@@ -2,22 +2,18 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !go1.5
package plan9
import "syscall"
func fixwd() {
syscall.Fixwd()
}
func Getwd() (wd string, err error) {
fd, err := open(".", O_RDONLY)
if err != nil {
return "", err
}
defer Close(fd)
return Fd2path(fd)
return syscall.Getwd()
}
func Chdir(path string) error {
return chdir(path)
return syscall.Chdir(path)
}

View File

@@ -38,9 +38,7 @@ func SchedSetaffinity(pid int, set *CPUSet) error {
// Zero clears the set s, so that it contains no CPUs.
func (s *CPUSet) Zero() {
for i := range s {
s[i] = 0
}
clear(s[:])
}
func cpuBitsIndex(cpu int) int {

View File

@@ -629,7 +629,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys Kill(pid int, signum syscall.Signal) (err error)
//sys Lchown(path string, uid int, gid int) (err error)
//sys Link(path string, link string) (err error)
//sys Listen(s int, backlog int) (err error) = libsocket.__xnet_llisten
//sys Listen(s int, backlog int) (err error) = libsocket.__xnet_listen
//sys Lstat(path string, stat *Stat_t) (err error)
//sys Madvise(b []byte, advice int) (err error)
//sys Mkdir(path string, mode uint32) (err error)

View File

@@ -72,7 +72,7 @@ import (
//go:cgo_import_dynamic libc_kill kill "libc.so"
//go:cgo_import_dynamic libc_lchown lchown "libc.so"
//go:cgo_import_dynamic libc_link link "libc.so"
//go:cgo_import_dynamic libc___xnet_llisten __xnet_llisten "libsocket.so"
//go:cgo_import_dynamic libc___xnet_listen __xnet_listen "libsocket.so"
//go:cgo_import_dynamic libc_lstat lstat "libc.so"
//go:cgo_import_dynamic libc_madvise madvise "libc.so"
//go:cgo_import_dynamic libc_mkdir mkdir "libc.so"
@@ -221,7 +221,7 @@ import (
//go:linkname procKill libc_kill
//go:linkname procLchown libc_lchown
//go:linkname procLink libc_link
//go:linkname proc__xnet_llisten libc___xnet_llisten
//go:linkname proc__xnet_listen libc___xnet_listen
//go:linkname procLstat libc_lstat
//go:linkname procMadvise libc_madvise
//go:linkname procMkdir libc_mkdir
@@ -371,7 +371,7 @@ var (
procKill,
procLchown,
procLink,
proc__xnet_llisten,
proc__xnet_listen,
procLstat,
procMadvise,
procMkdir,
@@ -1178,7 +1178,7 @@ func Link(path string, link string) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) {
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_llisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0)
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proc__xnet_listen)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}

View File

@@ -632,6 +632,8 @@ const (
IFA_FLAGS = 0x8
IFA_RT_PRIORITY = 0x9
IFA_TARGET_NETNSID = 0xa
IFAL_LABEL = 0x2
IFAL_ADDRESS = 0x1
RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
@@ -689,6 +691,7 @@ const (
SizeofRtAttr = 0x4
SizeofIfInfomsg = 0x10
SizeofIfAddrmsg = 0x8
SizeofIfAddrlblmsg = 0xc
SizeofIfaCacheinfo = 0x10
SizeofRtMsg = 0xc
SizeofRtNexthop = 0x8
@@ -740,6 +743,15 @@ type IfAddrmsg struct {
Index uint32
}
type IfAddrlblmsg struct {
Family uint8
_ uint8
Prefixlen uint8
Flags uint8
Index uint32
Seq uint32
}
type IfaCacheinfo struct {
Prefered uint32
Valid uint32
@@ -3052,6 +3064,23 @@ const (
)
const (
TCA_UNSPEC = 0x0
TCA_KIND = 0x1
TCA_OPTIONS = 0x2
TCA_STATS = 0x3
TCA_XSTATS = 0x4
TCA_RATE = 0x5
TCA_FCNT = 0x6
TCA_STATS2 = 0x7
TCA_STAB = 0x8
TCA_PAD = 0x9
TCA_DUMP_INVISIBLE = 0xa
TCA_CHAIN = 0xb
TCA_HW_OFFLOAD = 0xc
TCA_INGRESS_BLOCK = 0xd
TCA_EGRESS_BLOCK = 0xe
TCA_DUMP_FLAGS = 0xf
TCA_EXT_WARN_MSG = 0x10
RTNLGRP_NONE = 0x0
RTNLGRP_LINK = 0x1
RTNLGRP_NOTIFY = 0x2
@@ -3086,6 +3115,18 @@ const (
RTNLGRP_IPV6_MROUTE_R = 0x1f
RTNLGRP_NEXTHOP = 0x20
RTNLGRP_BRVLAN = 0x21
RTNLGRP_MCTP_IFADDR = 0x22
RTNLGRP_TUNNEL = 0x23
RTNLGRP_STATS = 0x24
RTNLGRP_IPV4_MCADDR = 0x25
RTNLGRP_IPV6_MCADDR = 0x26
RTNLGRP_IPV6_ACADDR = 0x27
TCA_ROOT_UNSPEC = 0x0
TCA_ROOT_TAB = 0x1
TCA_ROOT_FLAGS = 0x2
TCA_ROOT_COUNT = 0x3
TCA_ROOT_TIME_DELTA = 0x4
TCA_ROOT_EXT_WARN_MSG = 0x5
)
type CapUserHeader struct {

View File

@@ -1976,6 +1976,12 @@ const (
SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
)
// FILE_ZERO_DATA_INFORMATION from winioctl.h
type FileZeroDataInformation struct {
FileOffset int64
BeyondFinalZero int64
}
const (
ComputerNameNetBIOS = 0
ComputerNameDnsHostname = 1

File diff suppressed because it is too large Load Diff

View File

@@ -237,7 +237,7 @@ Files:
// so accumulate them all and then prefer the one that
// matches build.Default.GOARCH.
var archCandidates []*asmArch
for _, fld := range strings.Fields(m[1]) {
for fld := range strings.FieldsSeq(m[1]) {
for _, a := range arches {
if a.name == fld {
archCandidates = append(archCandidates, a)

View File

@@ -298,7 +298,7 @@ func (check *checker) plusBuildLine(pos token.Pos, line string) {
fields := strings.Fields(line[len("//"):])
// IsPlusBuildConstraint check above implies fields[0] == "+build"
for _, arg := range fields[1:] {
for _, elem := range strings.Split(arg, ",") {
for elem := range strings.SplitSeq(arg, ",") {
if strings.HasPrefix(elem, "!!") {
check.pass.Reportf(pos, "invalid double negative in build constraint: %s", arg)
check.crossCheck = false

View File

@@ -10,7 +10,9 @@ import (
"fmt"
"go/ast"
"go/constant"
"go/token"
"go/types"
"strconv"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
@@ -57,13 +59,16 @@ func run(pass *analysis.Pass) (any, error) {
}
// checkAddr reports a diagnostic (and returns true) if e
// is a call of the form fmt.Sprintf("%d:%d", ...).
// is a call of the form fmt.Sprintf("%s:%d", ...).
// The diagnostic includes a fix.
//
// dialCall is non-nil if the Dial call is non-local
// but within the same file.
checkAddr := func(e ast.Expr, dialCall *ast.CallExpr) {
if call, ok := e.(*ast.CallExpr); ok && typeutil.Callee(info, call) == fmtSprintf {
if call, ok := e.(*ast.CallExpr); ok &&
len(call.Args) == 3 &&
typeutil.Callee(info, call) == fmtSprintf {
// Examine format string.
formatArg := call.Args[0]
if tv := info.Types[formatArg]; tv.Value != nil {
@@ -99,21 +104,41 @@ func run(pass *analysis.Pass) (any, error) {
// Turn numeric port into a string.
if numericPort {
// port => fmt.Sprintf("%d", port)
// 123 => "123"
port := call.Args[2]
newPort := fmt.Sprintf(`fmt.Sprintf("%%d", %s)`, port)
if port := info.Types[port].Value; port != nil {
if i, ok := constant.Int64Val(port); ok {
newPort = fmt.Sprintf(`"%d"`, i) // numeric constant
// Is port an integer literal?
//
// (Don't allow arbitrary constants k otherwise the
// transformation k => fmt.Sprintf("%d", "123")
// loses the symbolic connection to k.)
var kPort int64 = -1
if lit, ok := port.(*ast.BasicLit); ok && lit.Kind == token.INT {
if v, err := strconv.ParseInt(lit.Value, 0, 64); err == nil {
kPort = v
}
}
edits = append(edits, analysis.TextEdit{
Pos: port.Pos(),
End: port.End(),
NewText: []byte(newPort),
})
if kPort >= 0 {
// literal: 0x7B => "123"
edits = append(edits, analysis.TextEdit{
Pos: port.Pos(),
End: port.End(),
NewText: fmt.Appendf(nil, `"%d"`, kPort), // (decimal)
})
} else {
// non-literal: port => fmt.Sprintf("%d", port)
edits = append(edits, []analysis.TextEdit{
{
Pos: port.Pos(),
End: port.Pos(),
NewText: []byte(`fmt.Sprintf("%d", `),
},
{
Pos: port.End(),
End: port.End(),
NewText: []byte(`)`),
},
}...)
}
}
// Refer to Dial call, if not adjacent.

View File

@@ -515,8 +515,7 @@ func checkPrintf(pass *analysis.Pass, fileVersion string, kind Kind, call *ast.C
// finds are sometimes unlikely or inconsequential, and may not be worth
// fixing for some users. Gating on language version allows us to avoid
// breaking existing tests and CI scripts.
if !suppressNonconstants &&
idx == len(call.Args)-1 &&
if idx == len(call.Args)-1 &&
fileVersion != "" && // fail open
versions.AtLeast(fileVersion, "go1.24") {
@@ -993,7 +992,7 @@ func (ss stringSet) String() string {
}
func (ss stringSet) Set(flag string) error {
for _, name := range strings.Split(flag, ",") {
for name := range strings.SplitSeq(flag, ",") {
if len(name) == 0 {
return fmt.Errorf("empty string")
}
@@ -1005,15 +1004,6 @@ func (ss stringSet) Set(flag string) error {
return nil
}
// suppressNonconstants suppresses reporting printf calls with
// non-constant formatting strings (proposal #60529) when true.
//
// This variable is to allow for staging the transition to newer
// versions of x/tools by vendoring.
//
// Remove this after the 1.24 release.
var suppressNonconstants bool
// isHex reports whether b is a hex digit.
func isHex(b byte) bool {
return '0' <= b && b <= '9' ||

View File

@@ -10,7 +10,6 @@ import (
"go/ast"
"go/build"
"go/types"
"regexp"
"slices"
"golang.org/x/tools/go/analysis"
@@ -114,11 +113,6 @@ func run(pass *analysis.Pass) (any, error) {
return nil, nil
}
// Matches cgo generated comment as well as the proposed standard:
//
// https://golang.org/s/generatedcode
var generatedRx = regexp.MustCompile(`// .*DO NOT EDIT\.?`)
// origin returns the original uninstantiated symbol for obj.
func origin(obj types.Object) types.Object {
switch obj := obj.(type) {

View File

@@ -17,6 +17,8 @@ import (
"strconv"
"strings"
"fmt"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
@@ -100,7 +102,11 @@ func checkCanonicalFieldTag(pass *analysis.Pass, field *types.Var, tag string, s
}
if err := validateStructTag(tag); err != nil {
pass.Reportf(field.Pos(), "struct field tag %#q not compatible with reflect.StructTag.Get: %s", tag, err)
pass.Report(analysis.Diagnostic{
Pos: field.Pos(),
End: field.Pos() + token.Pos(len(field.Name())),
Message: fmt.Sprintf("struct field tag %#q not compatible with reflect.StructTag.Get: %s", tag, err),
})
}
// Check for use of json or xml tags with unexported fields.
@@ -122,7 +128,11 @@ func checkCanonicalFieldTag(pass *analysis.Pass, field *types.Var, tag string, s
// ignored.
case "", "-":
default:
pass.Reportf(field.Pos(), "struct field %s has %s tag but is not exported", field.Name(), enc)
pass.Report(analysis.Diagnostic{
Pos: field.Pos(),
End: field.Pos() + token.Pos(len(field.Name())),
Message: fmt.Sprintf("struct field %s has %s tag but is not exported", field.Name(), enc),
})
return
}
}
@@ -190,7 +200,11 @@ func checkTagDuplicates(pass *analysis.Pass, tag, key string, nearest, field *ty
alsoPos.Filename = rel
}
pass.Reportf(nearest.Pos(), "struct field %s repeats %s tag %q also at %s", field.Name(), key, val, alsoPos)
pass.Report(analysis.Diagnostic{
Pos: nearest.Pos(),
End: nearest.Pos() + token.Pos(len(nearest.Name())),
Message: fmt.Sprintf("struct field %s repeats %s tag %q also at %s", field.Name(), key, val, alsoPos),
})
} else {
seen.Set(key, val, level, field.Pos())
}

View File

@@ -188,7 +188,7 @@ func (ss *stringSetFlag) String() string {
func (ss *stringSetFlag) Set(s string) error {
m := make(map[string]bool) // clobber previous value
if s != "" {
for _, name := range strings.Split(s, ",") {
for name := range strings.SplitSeq(s, ",") {
if name == "" {
continue // TODO: report error? proceed?
}

View File

@@ -73,7 +73,9 @@ type Config struct {
PackageVetx map[string]string // maps package path to file of fact information
VetxOnly bool // run analysis only for facts, not diagnostics
VetxOutput string // where to write file of fact information
SucceedOnTypecheckFailure bool
Stdout string // write stdout (e.g. JSON, unified diff) to this file
SucceedOnTypecheckFailure bool // obsolete awful hack; see #18395 and below
WarnDiagnostics bool // printing diagnostics should not cause a non-zero exit
}
// Main is the main function of a vet-like analysis tool that must be
@@ -142,6 +144,15 @@ func Run(configFile string, analyzers []*analysis.Analyzer) {
log.Fatal(err)
}
// Redirect stdout to a file as requested.
if cfg.Stdout != "" {
f, err := os.Create(cfg.Stdout)
if err != nil {
log.Fatal(err)
}
os.Stdout = f
}
fset := token.NewFileSet()
results, err := run(fset, cfg, analyzers)
if err != nil {
@@ -152,7 +163,7 @@ func Run(configFile string, analyzers []*analysis.Analyzer) {
// In VetxOnly mode, the analysis is run only for facts.
if !cfg.VetxOnly {
code = processResults(fset, cfg.ID, results)
code = processResults(fset, cfg.ID, results, cfg.WarnDiagnostics)
}
os.Exit(code)
@@ -176,7 +187,7 @@ func readConfig(filename string) (*Config, error) {
return cfg, nil
}
func processResults(fset *token.FileSet, id string, results []result) (exit int) {
func processResults(fset *token.FileSet, id string, results []result, warnDiagnostics bool) (exit int) {
if analysisflags.Fix {
// Don't print the diagnostics,
// but apply all fixes from the root actions.
@@ -225,7 +236,9 @@ func processResults(fset *token.FileSet, id string, results []result) (exit int)
for _, res := range results {
for _, diag := range res.diagnostics {
analysisflags.PrintPlain(os.Stderr, fset, analysisflags.Context, diag)
exit = 1
if !warnDiagnostics {
exit = 1
}
}
}
}

View File

@@ -40,7 +40,7 @@ type Cursor struct {
// Root returns a cursor for the virtual root node,
// whose children are the files provided to [New].
//
// Its [Cursor.Node] and [Cursor.Stack] methods return nil.
// Its [Cursor.Node] method return nil.
func (in *Inspector) Root() Cursor {
return Cursor{in, -1}
}

View File

@@ -53,7 +53,6 @@ import (
//
// The entry point is Blocks[0]; there may be multiple return blocks.
type CFG struct {
fset *token.FileSet
Blocks []*Block // block[0] is entry; order otherwise undefined
}
@@ -63,6 +62,10 @@ type CFG struct {
// A block may have 0-2 successors: zero for a return block or a block
// that calls a function such as panic that never returns; one for a
// normal (jump) block; and two for a conditional (if) block.
//
// In a conditional block, the last entry in Nodes is the condition and always
// an [ast.Expr], Succs[0] is the successor if the condition is true, and
// Succs[1] is the successor if the condition is false.
type Block struct {
Nodes []ast.Node // statements, expressions, and ValueSpecs
Succs []*Block // successor nodes in the graph

View File

@@ -698,7 +698,10 @@ func Object(pkg *types.Package, p Path) (types.Object, error) {
} else if false && aliases.Enabled() {
// The Enabled check is too expensive, so for now we
// simply assume that aliases are not enabled.
// TODO(adonovan): replace with "if true {" when go1.24 is assured.
//
// Now that go1.24 is assured, we should be able to
// replace this with "if true {", but it causes tests
// to fail. TODO(adonovan): investigate.
return nil, fmt.Errorf("cannot apply %q to %s (got %T, want alias)", code, t, t)
}

View File

@@ -11,7 +11,6 @@ import (
"fmt"
"go/types"
"hash/maphash"
"unsafe"
"golang.org/x/tools/internal/typeparams"
)
@@ -380,22 +379,8 @@ var theSeed = maphash.MakeSeed()
func (hasher) hashTypeName(tname *types.TypeName) uint32 {
// Since types.Identical uses == to compare TypeNames,
// the Hash function uses maphash.Comparable.
// TODO(adonovan): or will, when it becomes available in go1.24.
// In the meantime we use the pointer's numeric value.
//
// hash := maphash.Comparable(theSeed, tname)
//
// (Another approach would be to hash the name and package
// path, and whether or not it is a package-level typename. It
// is rare for a package to define multiple local types with
// the same name.)
ptr := uintptr(unsafe.Pointer(tname))
if unsafe.Sizeof(ptr) == 8 {
hash := uint64(ptr)
return uint32(hash ^ (hash >> 32))
} else {
return uint32(ptr)
}
hash := maphash.Comparable(theSeed, tname)
return uint32(hash ^ (hash >> 32))
}
// shallowHash computes a hash of t without looking at any of its

View File

@@ -22,6 +22,7 @@ import (
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/internal/moreiters"
"golang.org/x/tools/internal/typesinternal"
)
@@ -73,25 +74,6 @@ func TypeErrorEndPos(fset *token.FileSet, src []byte, start token.Pos) token.Pos
return end
}
// WalkASTWithParent walks the AST rooted at n. The semantics are
// similar to ast.Inspect except it does not call f(nil).
func WalkASTWithParent(n ast.Node, f func(n ast.Node, parent ast.Node) bool) {
var ancestors []ast.Node
ast.Inspect(n, func(n ast.Node) (recurse bool) {
if n == nil {
ancestors = ancestors[:len(ancestors)-1]
return false
}
var parent ast.Node
if len(ancestors) > 0 {
parent = ancestors[len(ancestors)-1]
}
ancestors = append(ancestors, n)
return f(n, parent)
})
}
// MatchingIdents finds the names of all identifiers in 'node' that match any of the given types.
// 'pos' represents the position at which the identifiers may be inserted. 'pos' must be within
// the scope of each of identifier we select. Otherwise, we will insert a variable at 'pos' that
@@ -276,19 +258,27 @@ func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member
before = decl0.Doc
}
}
// If the first decl is an import group, add this new import at the end.
if gd, ok := before.(*ast.GenDecl); ok && gd.Tok == token.IMPORT && gd.Rparen.IsValid() {
pos = gd.Rparen
// if it's a std lib, we should append it at the beginning of import group.
// otherwise we may see the std package is put at the last behind a 3rd module which doesn't follow our convention.
// besides, gofmt doesn't help in this case.
if IsStdPackage(pkgpath) && len(gd.Specs) != 0 {
pos = gd.Specs[0].Pos()
// Have existing grouped import ( ... ) decl.
if IsStdPackage(pkgpath) && len(gd.Specs) > 0 {
// Add spec for a std package before
// first existing spec, followed by
// a blank line if the next one is non-std.
first := gd.Specs[0].(*ast.ImportSpec)
pos = first.Pos()
if !IsStdPackage(first.Path.Value) {
newText += "\n"
}
newText += "\n\t"
} else {
// Add spec at end of group.
pos = gd.Rparen
newText = "\t" + newText + "\n"
}
} else {
// No import decl, or non-grouped import.
// Add a new import decl before first decl.
// (gofmt will merge multiple import decls.)
pos = before.Pos()
newText = "import " + newText + "\n\n"
}
@@ -519,24 +509,11 @@ func CanImport(from, to string) bool {
return true
}
// DeleteStmt returns the edits to remove stmt if it is contained
// in a BlockStmt, CaseClause, CommClause, or is the STMT in switch STMT; ... {...}
// The report function abstracts gopls' bug.Report.
func DeleteStmt(fset *token.FileSet, astFile *ast.File, stmt ast.Stmt, report func(string, ...any)) []analysis.TextEdit {
// TODO: pass in the cursor to a ast.Stmt. callers should provide the Cursor
insp := inspector.New([]*ast.File{astFile})
root := insp.Root()
cstmt, ok := root.FindNode(stmt)
if !ok {
report("%s not found in file", stmt.Pos())
return nil
}
// some paranoia
if !stmt.Pos().IsValid() || !stmt.End().IsValid() {
report("%s: stmt has invalid position", stmt.Pos())
return nil
}
// DeleteStmt returns the edits to remove the [ast.Stmt] identified by
// curStmt, if it is contained within a BlockStmt, CaseClause,
// CommClause, or is the STMT in switch STMT; ... {...}. It returns nil otherwise.
func DeleteStmt(fset *token.FileSet, curStmt inspector.Cursor) []analysis.TextEdit {
stmt := curStmt.Node().(ast.Stmt)
// if the stmt is on a line by itself delete the whole line
// otherwise just delete the statement.
@@ -562,7 +539,7 @@ func DeleteStmt(fset *token.FileSet, astFile *ast.File, stmt ast.Stmt, report fu
// (removing the blocks requires more rewriting than this routine would do)
// CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
// (removing the stmt requires more rewriting, and it's unclear what the user means)
switch parent := cstmt.Parent().Node().(type) {
switch parent := curStmt.Parent().Node().(type) {
case *ast.SwitchStmt:
limits(parent.Switch, parent.Body.Lbrace)
case *ast.TypeSwitchStmt:
@@ -573,12 +550,12 @@ func DeleteStmt(fset *token.FileSet, astFile *ast.File, stmt ast.Stmt, report fu
case *ast.BlockStmt:
limits(parent.Lbrace, parent.Rbrace)
case *ast.CommClause:
limits(parent.Colon, cstmt.Parent().Parent().Node().(*ast.BlockStmt).Rbrace)
limits(parent.Colon, curStmt.Parent().Parent().Node().(*ast.BlockStmt).Rbrace)
if parent.Comm == stmt {
return nil // maybe the user meant to remove the entire CommClause?
}
case *ast.CaseClause:
limits(parent.Colon, cstmt.Parent().Parent().Node().(*ast.BlockStmt).Rbrace)
limits(parent.Colon, curStmt.Parent().Parent().Node().(*ast.BlockStmt).Rbrace)
case *ast.ForStmt:
limits(parent.For, parent.Body.Lbrace)
@@ -586,15 +563,15 @@ func DeleteStmt(fset *token.FileSet, astFile *ast.File, stmt ast.Stmt, report fu
return nil // not one of ours
}
if prev, found := cstmt.PrevSibling(); found && lineOf(prev.Node().End()) == stmtStartLine {
if prev, found := curStmt.PrevSibling(); found && lineOf(prev.Node().End()) == stmtStartLine {
from = prev.Node().End() // preceding statement ends on same line
}
if next, found := cstmt.NextSibling(); found && lineOf(next.Node().Pos()) == stmtEndLine {
if next, found := curStmt.NextSibling(); found && lineOf(next.Node().Pos()) == stmtEndLine {
to = next.Node().Pos() // following statement begins on same line
}
// and now for the comments
Outer:
for _, cg := range astFile.Comments {
for _, cg := range enclosingFile(curStmt).Comments {
for _, co := range cg.List {
if lineOf(co.End()) < stmtStartLine {
continue
@@ -681,3 +658,9 @@ type tokenRange struct{ StartPos, EndPos token.Pos }
func (r tokenRange) Pos() token.Pos { return r.StartPos }
func (r tokenRange) End() token.Pos { return r.EndPos }
// enclosingFile returns the syntax tree for the file enclosing c.
func enclosingFile(c inspector.Cursor) *ast.File {
c, _ = moreiters.First(c.Enclosing((*ast.File)(nil)))
return c.Node().(*ast.File)
}

View File

@@ -97,7 +97,7 @@ func ExtractDoc(content, name string) (string, error) {
if f.Doc == nil {
return "", fmt.Errorf("Go source file has no package doc comment")
}
for _, section := range strings.Split(f.Doc.Text(), "\n# ") {
for section := range strings.SplitSeq(f.Doc.Text(), "\n# ") {
if body := strings.TrimPrefix(section, "Analyzer "+name); body != section &&
body != "" &&
body[0] == '\r' || body[0] == '\n' {

View File

@@ -15,7 +15,7 @@ import (
// https://go.dev/wiki/Deprecated, or "" if the documented symbol is not
// deprecated.
func Deprecation(doc *ast.CommentGroup) string {
for _, p := range strings.Split(doc.Text(), "\n\n") {
for p := range strings.SplitSeq(doc.Text(), "\n\n") {
// There is still some ambiguity for deprecation message. This function
// only returns the paragraph introduced by "Deprecated: ". More
// information related to the deprecation may follow in additional

View File

@@ -0,0 +1,99 @@
// Copyright 2023 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.
package astutil
import (
"go/ast"
"go/token"
"reflect"
)
// Equal reports whether two nodes are structurally equal,
// ignoring fields of type [token.Pos], [ast.Object],
// and [ast.Scope], and comments.
//
// The operands x and y may be nil.
// A nil slice is not equal to an empty slice.
//
// The provided function determines whether two identifiers
// should be considered identical.
func Equal(x, y ast.Node, identical func(x, y *ast.Ident) bool) bool {
if x == nil || y == nil {
return x == y
}
return equal(reflect.ValueOf(x), reflect.ValueOf(y), identical)
}
func equal(x, y reflect.Value, identical func(x, y *ast.Ident) bool) bool {
// Ensure types are the same
if x.Type() != y.Type() {
return false
}
switch x.Kind() {
case reflect.Pointer:
if x.IsNil() || y.IsNil() {
return x.IsNil() == y.IsNil()
}
switch t := x.Interface().(type) {
// Skip fields of types potentially involved in cycles.
case *ast.Object, *ast.Scope, *ast.CommentGroup:
return true
case *ast.Ident:
return identical(t, y.Interface().(*ast.Ident))
default:
return equal(x.Elem(), y.Elem(), identical)
}
case reflect.Interface:
if x.IsNil() || y.IsNil() {
return x.IsNil() == y.IsNil()
}
return equal(x.Elem(), y.Elem(), identical)
case reflect.Struct:
for i := range x.NumField() {
xf := x.Field(i)
yf := y.Field(i)
// Skip position fields.
if xpos, ok := xf.Interface().(token.Pos); ok {
ypos := yf.Interface().(token.Pos)
// Numeric value of a Pos is not significant but its "zeroness" is,
// because it is often significant, e.g. CallExpr.Variadic(Ellipsis), ChanType.Arrow.
if xpos.IsValid() != ypos.IsValid() {
return false
}
} else if !equal(xf, yf, identical) {
return false
}
}
return true
case reflect.Slice:
if x.IsNil() || y.IsNil() {
return x.IsNil() == y.IsNil()
}
if x.Len() != y.Len() {
return false
}
for i := range x.Len() {
if !equal(x.Index(i), y.Index(i), identical) {
return false
}
}
return true
case reflect.String:
return x.String() == y.String()
case reflect.Bool:
return x.Bool() == y.Bool()
case reflect.Int:
return x.Int() == y.Int()
default:
panic(x)
}
}

View File

@@ -0,0 +1,35 @@
// 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.
package astutil
import (
"go/ast"
"iter"
)
// FlatFields 'flattens' an ast.FieldList, returning an iterator over each
// (name, field) combination in the list. For unnamed fields, the identifier is
// nil.
func FlatFields(list *ast.FieldList) iter.Seq2[*ast.Ident, *ast.Field] {
return func(yield func(*ast.Ident, *ast.Field) bool) {
if list == nil {
return
}
for _, field := range list.List {
if len(field.Names) == 0 {
if !yield(nil, field) {
return
}
} else {
for _, name := range field.Names {
if !yield(name, field) {
return
}
}
}
}
}
}

View File

@@ -0,0 +1,72 @@
// Copyright 2023 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.
// Package astutil provides various AST utility functions for gopls.
package astutil
import (
"bytes"
"go/scanner"
"go/token"
)
// PurgeFuncBodies returns a copy of src in which the contents of each
// outermost {...} region except struct and interface types have been
// deleted. This reduces the amount of work required to parse the
// top-level declarations.
//
// PurgeFuncBodies does not preserve newlines or position information.
// Also, if the input is invalid, parsing the output of
// PurgeFuncBodies may result in a different tree due to its effects
// on parser error recovery.
func PurgeFuncBodies(src []byte) []byte {
// Destroy the content of any {...}-bracketed regions that are
// not immediately preceded by a "struct" or "interface"
// token. That includes function bodies, composite literals,
// switch/select bodies, and all blocks of statements.
// This will lead to non-void functions that don't have return
// statements, which of course is a type error, but that's ok.
var out bytes.Buffer
file := token.NewFileSet().AddFile("", -1, len(src))
var sc scanner.Scanner
sc.Init(file, src, nil, 0)
var prev token.Token
var cursor int // last consumed src offset
var braces []token.Pos // stack of unclosed braces or -1 for struct/interface type
for {
pos, tok, _ := sc.Scan()
if tok == token.EOF {
break
}
switch tok {
case token.COMMENT:
// TODO(adonovan): opt: skip, to save an estimated 20% of time.
case token.LBRACE:
if prev == token.STRUCT || prev == token.INTERFACE {
pos = -1
}
braces = append(braces, pos)
case token.RBRACE:
if last := len(braces) - 1; last >= 0 {
top := braces[last]
braces = braces[:last]
if top < 0 {
// struct/interface type: leave alone
} else if len(braces) == 0 { // toplevel only
// Delete {...} body.
start := file.Offset(top)
end := file.Offset(pos)
out.Write(src[cursor : start+len("{")])
cursor = end
}
}
}
prev = tok
}
out.Write(src[cursor:])
return out.Bytes()
}

View File

@@ -0,0 +1,59 @@
// Copyright 2025 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.
package astutil
import (
"fmt"
"go/ast"
"go/token"
"strconv"
"unicode/utf8"
)
// RangeInStringLiteral calculates the positional range within a string literal
// corresponding to the specified start and end byte offsets within the logical string.
func RangeInStringLiteral(lit *ast.BasicLit, start, end int) (token.Pos, token.Pos, error) {
startPos, err := PosInStringLiteral(lit, start)
if err != nil {
return 0, 0, fmt.Errorf("start: %v", err)
}
endPos, err := PosInStringLiteral(lit, end)
if err != nil {
return 0, 0, fmt.Errorf("end: %v", err)
}
return startPos, endPos, nil
}
// PosInStringLiteral returns the position within a string literal
// corresponding to the specified byte offset within the logical
// string that it denotes.
func PosInStringLiteral(lit *ast.BasicLit, offset int) (token.Pos, error) {
raw := lit.Value
value, err := strconv.Unquote(raw)
if err != nil {
return 0, err
}
if !(0 <= offset && offset <= len(value)) {
return 0, fmt.Errorf("invalid offset")
}
// remove quotes
quote := raw[0] // '"' or '`'
raw = raw[1 : len(raw)-1]
var (
i = 0 // byte index within logical value
pos = lit.ValuePos + 1 // position within literal
)
for raw != "" && i < offset {
r, _, rest, _ := strconv.UnquoteChar(raw, quote) // can't fail
sz := len(raw) - len(rest) // length of literal char in raw bytes
pos += token.Pos(sz)
raw = raw[sz:]
i += utf8.RuneLen(r)
}
return pos, nil
}

View File

@@ -0,0 +1,61 @@
// Copyright 2023 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.
package astutil
import (
"go/ast"
"golang.org/x/tools/internal/typeparams"
)
// UnpackRecv unpacks a receiver type expression, reporting whether it is a
// pointer receiver, along with the type name identifier and any receiver type
// parameter identifiers.
//
// Copied (with modifications) from go/types.
func UnpackRecv(rtyp ast.Expr) (ptr bool, rname *ast.Ident, tparams []*ast.Ident) {
L: // unpack receiver type
// This accepts invalid receivers such as ***T and does not
// work for other invalid receivers, but we don't care. The
// validity of receiver expressions is checked elsewhere.
for {
switch t := rtyp.(type) {
case *ast.ParenExpr:
rtyp = t.X
case *ast.StarExpr:
ptr = true
rtyp = t.X
default:
break L
}
}
// unpack type parameters, if any
switch rtyp.(type) {
case *ast.IndexExpr, *ast.IndexListExpr:
var indices []ast.Expr
rtyp, _, indices, _ = typeparams.UnpackIndexExpr(rtyp)
for _, arg := range indices {
var par *ast.Ident
switch arg := arg.(type) {
case *ast.Ident:
par = arg
default:
// ignore errors
}
if par == nil {
par = &ast.Ident{NamePos: arg.Pos(), Name: "_"}
}
tparams = append(tparams, par)
}
}
// unpack receiver name
if name, _ := rtyp.(*ast.Ident); name != nil {
rname = name
}
return
}

View File

@@ -5,59 +5,10 @@
package astutil
import (
"fmt"
"go/ast"
"go/token"
"strconv"
"unicode/utf8"
)
// RangeInStringLiteral calculates the positional range within a string literal
// corresponding to the specified start and end byte offsets within the logical string.
func RangeInStringLiteral(lit *ast.BasicLit, start, end int) (token.Pos, token.Pos, error) {
startPos, err := PosInStringLiteral(lit, start)
if err != nil {
return 0, 0, fmt.Errorf("start: %v", err)
}
endPos, err := PosInStringLiteral(lit, end)
if err != nil {
return 0, 0, fmt.Errorf("end: %v", err)
}
return startPos, endPos, nil
}
// PosInStringLiteral returns the position within a string literal
// corresponding to the specified byte offset within the logical
// string that it denotes.
func PosInStringLiteral(lit *ast.BasicLit, offset int) (token.Pos, error) {
raw := lit.Value
value, err := strconv.Unquote(raw)
if err != nil {
return 0, err
}
if !(0 <= offset && offset <= len(value)) {
return 0, fmt.Errorf("invalid offset")
}
// remove quotes
quote := raw[0] // '"' or '`'
raw = raw[1 : len(raw)-1]
var (
i = 0 // byte index within logical value
pos = lit.ValuePos + 1 // position within literal
)
for raw != "" && i < offset {
r, _, rest, _ := strconv.UnquoteChar(raw, quote) // can't fail
sz := len(raw) - len(rest) // length of literal char in raw bytes
pos += token.Pos(sz)
raw = raw[sz:]
i += utf8.RuneLen(r)
}
return pos, nil
}
// PreorderStack traverses the tree rooted at root,
// calling f before visiting each node.
//
@@ -91,3 +42,28 @@ func PreorderStack(root ast.Node, stack []ast.Node, f func(n ast.Node, stack []a
panic("push/pop mismatch")
}
}
// NodeContains reports whether the Pos/End range of node n encloses
// the given position pos.
//
// It is inclusive of both end points, to allow hovering (etc) when
// the cursor is immediately after a node.
//
// For unfortunate historical reasons, the Pos/End extent of an
// ast.File runs from the start of its package declaration---excluding
// copyright comments, build tags, and package documentation---to the
// end of its last declaration, excluding any trailing comments. So,
// as a special case, if n is an [ast.File], NodeContains uses
// n.FileStart <= pos && pos <= n.FileEnd to report whether the
// position lies anywhere within the file.
//
// Precondition: n must not be nil.
func NodeContains(n ast.Node, pos token.Pos) bool {
var start, end token.Pos
if file, ok := n.(*ast.File); ok {
start, end = file.FileStart, file.FileEnd // entire file
} else {
start, end = n.Pos(), n.End()
}
return start <= pos && pos <= end
}

View File

@@ -0,0 +1,47 @@
// Copyright 2025 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.
package moreiters
import "iter"
// First returns the first value of seq and true.
// If seq is empty, it returns the zero value of T and false.
func First[T any](seq iter.Seq[T]) (z T, ok bool) {
for t := range seq {
return t, true
}
return z, false
}
// Contains reports whether x is an element of the sequence seq.
func Contains[T comparable](seq iter.Seq[T], x T) bool {
for cand := range seq {
if cand == x {
return true
}
}
return false
}
// Every reports whether every pred(t) for t in seq returns true,
// stopping at the first false element.
func Every[T any](seq iter.Seq[T], pred func(T) bool) bool {
for t := range seq {
if !pred(t) {
return false
}
}
return true
}
// Any reports whether any pred(t) for t in seq returns true.
func Any[T any](seq iter.Seq[T], pred func(T) bool) bool {
for t := range seq {
if pred(t) {
return true
}
}
return false
}

View File

@@ -15,6 +15,14 @@ import (
// file.
// If the same package is imported multiple times, the last appearance is
// recorded.
//
// TODO(adonovan): this function ignores the effect of shadowing. It
// should accept a [token.Pos] and a [types.Info] and compute only the
// set of imports that are not shadowed at that point, analogous to
// [analysisinternal.AddImport]. It could also compute (as a side
// effect) the set of additional imports required to ensure that there
// is an accessible import for each necessary package, making it
// converge even more closely with AddImport.
func FileQualifier(f *ast.File, pkg *types.Package) types.Qualifier {
// Construct mapping of import paths to their defined names.
// It is only necessary to look at renaming imports.

Some files were not shown because too many files have changed in this diff Show More