aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-09-23 10:32:03 -0400
committerCherry Mui <cherryyz@google.com>2025-09-23 10:32:03 -0400
commit2d8cb80d7c4af3dbcb507783938ceb0e071f64e3 (patch)
tree719d86801da431f6ba11a84a3b66c60b4e5c1f38 /src/cmd/internal/obj
parent63a09d6d3d68acedfc9e5fd2daf6febc35aca1d6 (diff)
parent9b2d39b75bcc8ced3eaab1c841d7d62e27867931 (diff)
downloadgo-2d8cb80d7c4af3dbcb507783938ceb0e071f64e3.tar.xz
[dev.simd] all: merge master (9b2d39b) into dev.simd
Conflicts: - src/internal/buildcfg/exp.go Merge List: + 2025-09-22 9b2d39b75b cmd/compile/internal/ssa: match style and formatting + 2025-09-22 e23edf5e55 runtime: don't re-read metrics before check in TestReadMetricsSched + 2025-09-22 177cd8d763 log/slog: use a pooled json encoder + 2025-09-22 2353c15785 cmd/cgo/internal/test: skip TestMultipleAssign when using UCRT on Windows + 2025-09-22 32dfd69282 cmd/dist: disable FIPS 140-3 mode when testing maphash with purego + 2025-09-19 7f6ff5ec3e cmd/compile: fix doc word + 2025-09-19 9693b94be0 runtime: include stderr when objdump fails + 2025-09-19 8616981ce6 log/slog: optimize slog Level.String() to avoid fmt.Sprintf + 2025-09-19 b8af744360 testing: fix example for unexported identifier + 2025-09-19 51dc5bfe6c Revert "cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist" + 2025-09-19 ee7bf06cb3 time: improve ParseDuration performance for invalid input + 2025-09-19 f9e61a9a32 cmd/compile: duplicate nil check to two branches of write barrier + 2025-09-18 3cf1aaf8b9 runtime: use futexes with 64-bit time on Linux + 2025-09-18 0ab038af62 cmd/compile/internal/abi: use clear built-in + 2025-09-18 00bf24fdca bytes: use clear in test + 2025-09-18 f9701d21d2 crypto: use clear built-in + 2025-09-18 a58afe44fa net: fix testHookCanceledDial race + 2025-09-18 3203a5da29 net/http: avoid connCount underflow race + 2025-09-18 8ca209ec39 context: don't return a non-nil from Err before Done is closed + 2025-09-18 3032894e04 runtime: make explicit nil check in heapSetTypeSmallHeader + 2025-09-17 ef05b66d61 cmd/internal/obj/riscv: add support for Zicond instructions + 2025-09-17 78ef487a6f cmd/compile: fix the issue of shift amount exceeding the valid range + 2025-09-17 77aac7bb75 runtime: don't enable heap randomization if MSAN or ASAN is enabled + 2025-09-17 465b85eb76 runtime: fix CheckScavengedBitsCleared with randomized heap base + 2025-09-17 909704b85e encoding/json/v2: fix typo in comment + 2025-09-17 3db5979e8c testing: use reflect.TypeAssert and reflect.TypeFor + 2025-09-17 6a8dbbecbf path/filepath: fix EvalSymlinks to return ENOTDIR on plan9 + 2025-09-17 bffe7ad9f1 go/parser: Add TestBothLineAndLeadComment + 2025-09-17 02a888e820 go/ast: document that (*ast.File).Comments is sorted by position + 2025-09-16 594deca981 cmd/link: simplify PE relocations mapping + 2025-09-16 9df1a289ac go/parser: simplify expectSemi + 2025-09-16 72ba117bda internal/buildcfg: enable randomizedHeapBase64 by default + 2025-09-16 796ea3bc2e os/user: align test file name and build tags + 2025-09-16 a69395eab2 runtime/_mkmalloc: add a copy of cloneNode + 2025-09-16 cbdad4fc3c cmd/go: check pattern for utf8 validity before call regexp.MustCompile + 2025-09-16 c2d85eb999 cmd/go: disable cgo by default if CC unset and DefaultCC doesn't exist + 2025-09-16 ac82fe68aa bytes,strings: remove reference to non-existent SplitFunc + 2025-09-16 0b26678db2 cmd/compile: fix mips zerorange implementation + 2025-09-16 e2cfc1eb3a cmd/internal/obj/riscv: improve handling of float point moves + 2025-09-16 281c632e6e crypto/x509/internal/macos: standardize package name + 2025-09-16 61dc7fe30d iter: document that calling yield after terminated range loop causes runtime panic Change-Id: Ic06019efc855913632003f41eb10c746b3410b0a
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/riscv/anames.go2
-rw-r--r--src/cmd/internal/obj/riscv/cpu.go4
-rw-r--r--src/cmd/internal/obj/riscv/inst.go6
-rw-r--r--src/cmd/internal/obj/riscv/obj.go60
4 files changed, 64 insertions, 8 deletions
diff --git a/src/cmd/internal/obj/riscv/anames.go b/src/cmd/internal/obj/riscv/anames.go
index 88ac746573..a8807fc7a8 100644
--- a/src/cmd/internal/obj/riscv/anames.go
+++ b/src/cmd/internal/obj/riscv/anames.go
@@ -61,6 +61,8 @@ var Anames = []string{
"CSRRWI",
"CSRRSI",
"CSRRCI",
+ "CZEROEQZ",
+ "CZERONEZ",
"MUL",
"MULH",
"MULHU",
diff --git a/src/cmd/internal/obj/riscv/cpu.go b/src/cmd/internal/obj/riscv/cpu.go
index e265e04482..305ef061e3 100644
--- a/src/cmd/internal/obj/riscv/cpu.go
+++ b/src/cmd/internal/obj/riscv/cpu.go
@@ -409,6 +409,10 @@ const (
ACSRRSI
ACSRRCI
+ // 12.3: Integer Conditional Operations (Zicond)
+ ACZEROEQZ
+ ACZERONEZ
+
// 13.1: Multiplication Operations
AMUL
AMULH
diff --git a/src/cmd/internal/obj/riscv/inst.go b/src/cmd/internal/obj/riscv/inst.go
index a6a03dc565..a5b3acdb18 100644
--- a/src/cmd/internal/obj/riscv/inst.go
+++ b/src/cmd/internal/obj/riscv/inst.go
@@ -1,4 +1,4 @@
-// Code generated by ./parse.py -go rv64_a rv64_c rv64_d rv64_f rv64_i rv64_m rv64_q rv64_zba rv64_zbb rv64_zbs rv_a rv_c rv_c_d rv_d rv_f rv_i rv_m rv_q rv_s rv_system rv_v rv_zba rv_zbb rv_zbs rv_zicsr; DO NOT EDIT.
+// Code generated by ./parse.py -go rv64_a rv64_c rv64_d rv64_f rv64_i rv64_m rv64_q rv64_zba rv64_zbb rv64_zbs rv_a rv_c rv_c_d rv_d rv_f rv_i rv_m rv_q rv_s rv_system rv_v rv_zba rv_zbb rv_zbs rv_zicond rv_zicsr; DO NOT EDIT.
package riscv
import "cmd/internal/obj"
@@ -194,6 +194,10 @@ func encode(a obj.As) *inst {
return &inst{0x13, 0x1, 0x0, 0x1, 1537, 0x30}
case ACTZW:
return &inst{0x1b, 0x1, 0x0, 0x1, 1537, 0x30}
+ case ACZEROEQZ:
+ return &inst{0x33, 0x5, 0x0, 0x0, 224, 0x7}
+ case ACZERONEZ:
+ return &inst{0x33, 0x7, 0x0, 0x0, 224, 0x7}
case ADIV:
return &inst{0x33, 0x4, 0x0, 0x0, 32, 0x1}
case ADIVU:
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go
index 1538d03179..9d595f301c 100644
--- a/src/cmd/internal/obj/riscv/obj.go
+++ b/src/cmd/internal/obj/riscv/obj.go
@@ -29,6 +29,7 @@ import (
"internal/abi"
"internal/buildcfg"
"log"
+ "math"
"math/bits"
"strings"
)
@@ -145,9 +146,29 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
p.From.Offset = 0
}
+ case AMOVF:
+ if p.From.Type == obj.TYPE_FCONST && p.From.Name == obj.NAME_NONE && p.From.Reg == obj.REG_NONE {
+ f64 := p.From.Val.(float64)
+ f32 := float32(f64)
+ if math.Float32bits(f32) == 0 {
+ p.From.Type = obj.TYPE_REG
+ p.From.Reg = REG_ZERO
+ break
+ }
+ p.From.Type = obj.TYPE_MEM
+ p.From.Sym = ctxt.Float32Sym(f32)
+ p.From.Name = obj.NAME_EXTERN
+ p.From.Offset = 0
+ }
+
case AMOVD:
if p.From.Type == obj.TYPE_FCONST && p.From.Name == obj.NAME_NONE && p.From.Reg == obj.REG_NONE {
f64 := p.From.Val.(float64)
+ if math.Float64bits(f64) == 0 {
+ p.From.Type = obj.TYPE_REG
+ p.From.Reg = REG_ZERO
+ break
+ }
p.From.Type = obj.TYPE_MEM
p.From.Sym = ctxt.Float64Sym(f64)
p.From.Name = obj.NAME_EXTERN
@@ -1927,6 +1948,10 @@ var instructions = [ALAST & obj.AMask]instructionData{
ACSRRW & obj.AMask: {enc: iIIEncoding, immForm: ACSRRWI},
ACSRRWI & obj.AMask: {enc: iIIEncoding},
+ // 12.3: "Zicond" Extension for Integer Conditional Operations
+ ACZERONEZ & obj.AMask: {enc: rIIIEncoding, ternary: true},
+ ACZEROEQZ & obj.AMask: {enc: rIIIEncoding, ternary: true},
+
// 13.1: Multiplication Operations
AMUL & obj.AMask: {enc: rIIIEncoding, ternary: true},
AMULH & obj.AMask: {enc: rIIIEncoding, ternary: true},
@@ -3254,16 +3279,37 @@ func instructionsForMOV(p *obj.Prog) []*instruction {
case p.From.Type == obj.TYPE_REG && p.To.Type == obj.TYPE_REG:
// Handle register to register moves.
switch p.As {
- case AMOV: // MOV Ra, Rb -> ADDI $0, Ra, Rb
+ case AMOV:
+ // MOV Ra, Rb -> ADDI $0, Ra, Rb
ins.as, ins.rs1, ins.rs2, ins.imm = AADDI, uint32(p.From.Reg), obj.REG_NONE, 0
- case AMOVW: // MOVW Ra, Rb -> ADDIW $0, Ra, Rb
+ case AMOVW:
+ // MOVW Ra, Rb -> ADDIW $0, Ra, Rb
ins.as, ins.rs1, ins.rs2, ins.imm = AADDIW, uint32(p.From.Reg), obj.REG_NONE, 0
- case AMOVBU: // MOVBU Ra, Rb -> ANDI $255, Ra, Rb
+ case AMOVBU:
+ // MOVBU Ra, Rb -> ANDI $255, Ra, Rb
ins.as, ins.rs1, ins.rs2, ins.imm = AANDI, uint32(p.From.Reg), obj.REG_NONE, 255
- case AMOVF: // MOVF Ra, Rb -> FSGNJS Ra, Ra, Rb
- ins.as, ins.rs1 = AFSGNJS, uint32(p.From.Reg)
- case AMOVD: // MOVD Ra, Rb -> FSGNJD Ra, Ra, Rb
- ins.as, ins.rs1 = AFSGNJD, uint32(p.From.Reg)
+ case AMOVF:
+ // MOVF Ra, Rb -> FSGNJS Ra, Ra, Rb
+ // or -> FMVWX Ra, Rb
+ // or -> FMVXW Ra, Rb
+ if ins.rs2 >= REG_X0 && ins.rs2 <= REG_X31 && ins.rd >= REG_F0 && ins.rd <= REG_F31 {
+ ins.as = AFMVWX
+ } else if ins.rs2 >= REG_F0 && ins.rs2 <= REG_F31 && ins.rd >= REG_X0 && ins.rd <= REG_X31 {
+ ins.as = AFMVXW
+ } else {
+ ins.as, ins.rs1 = AFSGNJS, uint32(p.From.Reg)
+ }
+ case AMOVD:
+ // MOVD Ra, Rb -> FSGNJD Ra, Ra, Rb
+ // or -> FMVDX Ra, Rb
+ // or -> FMVXD Ra, Rb
+ if ins.rs2 >= REG_X0 && ins.rs2 <= REG_X31 && ins.rd >= REG_F0 && ins.rd <= REG_F31 {
+ ins.as = AFMVDX
+ } else if ins.rs2 >= REG_F0 && ins.rs2 <= REG_F31 && ins.rd >= REG_X0 && ins.rd <= REG_X31 {
+ ins.as = AFMVXD
+ } else {
+ ins.as, ins.rs1 = AFSGNJD, uint32(p.From.Reg)
+ }
case AMOVB, AMOVH:
if buildcfg.GORISCV64 >= 22 {
// Use SEXTB or SEXTH to extend.