aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-09-03 11:19:43 -0400
committerCherry Mui <cherryyz@google.com>2025-09-03 11:19:43 -0400
commit7c8b9115bc578a1f6577d2239fd5e9d8db100531 (patch)
tree2acffa10f5d90ab07d62eb4cd0670a979bf1062a /src/cmd/internal/obj
parent91253515831d1d51f9a998a743309c94e1fc4e1e (diff)
parent4c4cefc19a16924f3aa7135d3fdc6d1687fe26c7 (diff)
downloadgo-7c8b9115bc578a1f6577d2239fd5e9d8db100531.tar.xz
[dev.simd] all: merge master (4c4cefc) into dev.simd
Merge List: + 2025-09-03 4c4cefc19a cmd/gofmt: simplify logic to process arguments + 2025-09-03 925a3cdcd1 unicode/utf8: make DecodeRune{,InString} inlineable + 2025-09-03 3e596d448f math: rename Modf parameter int to integer + 2025-09-02 2a7f1d47b0 runtime: use one more address bit for tagged pointers + 2025-09-02 b09068041a cmd/dist: run racebench tests only in longtest mode + 2025-09-02 355370ac52 runtime: add comment for concatstring2 + 2025-09-02 1eec830f54 go/doc: linkify interface methods + 2025-08-31 7bba745820 cmd/compile: use generated loops instead of DUFFZERO on loong64 + 2025-08-31 882335e2cb cmd/internal/obj/loong64: add LDPTR.{W/D} and STPTR.{W/D} instructions support + 2025-08-31 d4b17f5869 internal/runtime/atomic: reset wrong jump target in Cas{,64} on loong64 + 2025-08-31 6a08e80399 net/http: skip redirecting in ServeMux when URL path for CONNECT is empty + 2025-08-29 8bcda6c79d runtime/race: add race detector support for linux/riscv64 + 2025-08-29 8377adafc5 cmd/cgo: split loadDWARF into two parts + 2025-08-29 a7d9d5a80a cmd/cgo: move typedefs and typedefList out of Package + 2025-08-29 1d459c4357 all: delete more windows/arm remnants + 2025-08-29 27ce6e4e26 cmd/compile: remove sign extension before MULW on riscv64 + 2025-08-29 84b070bfb1 cmd/compile/internal/ssa: make oneBit function generic + 2025-08-29 fe42628dae internal/cpu: inline DebugOptions + 2025-08-29 94b7d519bd net: update document on limitation of iprawsock on Windows + 2025-08-29 ba9e1ddccf testing: allow specify temp dir by GOTMPDIR environment variable + 2025-08-29 9f6936b8da cmd/link: disallow linkname of runtime.addmoduledata + 2025-08-29 89d41d254a bytes, strings: speed up TrimSpace + 2025-08-29 38204e0872 testing/synctest: call out common issues with tests + 2025-08-29 252c901125 os,syscall: pass file flags to CreateFile on Windows + 2025-08-29 53515fb0a9 crypto/tls: use hash.Cloner + 2025-08-28 13bb48e6fb go/constant: fix complex != unknown comparison + 2025-08-28 ba1109feb5 net: remove redundant cgoLookupCNAME return parameter + 2025-08-28 f74ed44ed9 net/http/httputil: remove redundant pw.Close() call in DumpRequestOut + 2025-08-28 a9689d2e0b time: skip TestLongAdjustTimers in short mode on single CPU systems + 2025-08-28 ebc763f76d syscall: only get parent PID if SysProcAttr.Pdeathsig is set + 2025-08-28 7f1864b0a8 strings: remove redundant "runs" from string.Fields docstring + 2025-08-28 90c21fa5b6 net/textproto: eliminate some bounds checks + 2025-08-27 e47d88beae os: return nil slice when ReadDir is used with a file on file_windows + 2025-08-27 6b837a64db cmd/internal/obj/loong64: simplify buildop + 2025-08-27 765905e3bd debug/elf: don't panic if symtab too small + 2025-08-27 2ee4b31242 net/http: Ensure that CONNECT proxied requests respect MaxResponseHeaderBytes + 2025-08-27 b21867b1a2 net/http: require exact match for CrossSiteProtection bypass patterns + 2025-08-27 d19e377f6e cmd/cgo: make it safe to run gcc in parallel + 2025-08-27 49a2f3ed87 net: allow zero value destination address in WriteMsgUDPAddrPort + 2025-08-26 afc51ed007 internall/poll: remove bufs field from Windows' poll.operation + 2025-08-26 801b74eb95 internal/poll: remove rsa field from Windows' poll.operation + 2025-08-26 fa18c547cd syscall: sort Windows env block in StartProcess + 2025-08-26 bfd130db02 internal/poll: don't use stack-allocated WSAMsg parameters + 2025-08-26 dae9e456ae runtime: identify virtual memory layout for riscv64 + 2025-08-25 25c2d4109f math: use Trunc to implement Modf + 2025-08-25 4e05a070c4 math: implement IsInf using Abs + 2025-08-25 1eed4f32a0 math: optimize Signbit implementation slightly + 2025-08-25 bd71b94659 cmd/compile/internal: optimizing add+sll rule using ALSLV instruction on loong64 + 2025-08-25 ea55ca3600 runtime: skip doInit of plugins in runtime.main + 2025-08-25 9ae2f1fb57 internal/trace: skip async preempt off tests on low end systems + 2025-08-25 bbd5342a62 net: fix cgoResSearch + 2025-08-25 ed7f804775 os: set full name for Roots created with Root.OpenRoot + 2025-08-25 a21249436b internal/poll: use fdMutex to provide read/write locking on Windows + 2025-08-24 44c5956bf7 test/codegen: add Mul2 and DivPow2 test for loong64 + 2025-08-24 0aa8019e94 test/codegen: add Mul* test for loong64 + 2025-08-24 83420974b7 test/codegen: add sqrt* abs and copysign test for loong64 + 2025-08-23 f2db0dca0b net/http/httptest: redirect example.com requests to server + 2025-08-22 d86ec92499 internal/syscall/windows: increase internal Windows O_ flags values + 2025-08-22 9d3f7fda70 crypto/tls: fix quic comment typo + 2025-08-22 78a05c541f internal/poll: don't pass non-nil WSAMsg.Name with 0 namelen on windows + 2025-08-22 52c3f73fda runtime/metrics: improve doc + 2025-08-22 a076f49757 os: fix Root.MkdirAll to handle race of directory creation + 2025-08-22 98238fd495 all: delete remaining windows/arm code + 2025-08-21 1ad30844d9 cmd/asm: process forward jump to PCALIGN + 2025-08-21 13c082601d internal/poll: permit nil destination address in WriteMsg{Inet4,Inet6} + 2025-08-21 9b0a507735 runtime: remove remaining windows/arm files and comments + 2025-08-21 1843f1e9c0 cmd/compile: use zero register instead of specialized *zero instructions on loong64 + 2025-08-21 e0870a0a12 cmd/compile: simplify zerorange on loong64 + 2025-08-21 fb8bbe46d5 cmd/compile/internal/ssa: eliminate unnecessary extension operations + 2025-08-21 9632ba8160 cmd/compile: optimize some patterns into revb2h/revb4h instruction on loong64 + 2025-08-21 8dcab6f450 syscall: simplify execve handling on libc platforms + 2025-08-21 ba840c1bf9 cmd/compile: deduplication in the source code generated by mknode + 2025-08-21 fa706ea50f cmd/compile: optimize rule (x + x) << c to x << c+1 on loong64 + 2025-08-21 ffc85ee1f1 cmd/internal/objabi,cmd/link: add support for additional riscv64 relocations Change-Id: I3896f74b1a3cc0a52b29ca48767bb0ba84620f71
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/fips140.go10
-rw-r--r--src/cmd/internal/obj/loong64/a.out.go4
-rw-r--r--src/cmd/internal/obj/loong64/anames.go2
-rw-r--r--src/cmd/internal/obj/loong64/asm.go71
-rw-r--r--src/cmd/internal/obj/loong64/doc.go28
-rw-r--r--src/cmd/internal/obj/x86/asm6.go25
6 files changed, 97 insertions, 43 deletions
diff --git a/src/cmd/internal/obj/fips140.go b/src/cmd/internal/obj/fips140.go
index ea36849a21..da18b64178 100644
--- a/src/cmd/internal/obj/fips140.go
+++ b/src/cmd/internal/obj/fips140.go
@@ -196,14 +196,8 @@ func EnableFIPS() bool {
// Perhaps the default should be changed back to -buildmode=exe,
// after which we could remove this case, but until then,
// skip FIPS on windows-386.
- //
- // We don't know whether arm works, because it is too hard to get builder
- // time to test it. Disable since it's not important right now.
- if buildcfg.GOOS == "windows" {
- switch buildcfg.GOARCH {
- case "386", "arm":
- return false
- }
+ if buildcfg.GOOS == "windows" && buildcfg.GOARCH == "386" {
+ return false
}
// AIX doesn't just work, and it's not worth fixing.
diff --git a/src/cmd/internal/obj/loong64/a.out.go b/src/cmd/internal/obj/loong64/a.out.go
index f5d20cfabe..8e651cdfef 100644
--- a/src/cmd/internal/obj/loong64/a.out.go
+++ b/src/cmd/internal/obj/loong64/a.out.go
@@ -666,6 +666,10 @@ const (
ABSTRPICKW
ABSTRPICKV
+ // 2.2.5.3
+ AMOVWP
+ AMOVVP
+
// 2.2.5.4. Prefetch Instructions
APRELD
APRELDX
diff --git a/src/cmd/internal/obj/loong64/anames.go b/src/cmd/internal/obj/loong64/anames.go
index 67b5f2fc80..c629553d55 100644
--- a/src/cmd/internal/obj/loong64/anames.go
+++ b/src/cmd/internal/obj/loong64/anames.go
@@ -202,6 +202,8 @@ var Anames = []string{
"BSTRINSV",
"BSTRPICKW",
"BSTRPICKV",
+ "MOVWP",
+ "MOVVP",
"PRELD",
"PRELDX",
"CRCWBW",
diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go
index ffd1177350..1b982f6c86 100644
--- a/src/cmd/internal/obj/loong64/asm.go
+++ b/src/cmd/internal/obj/loong64/asm.go
@@ -212,6 +212,8 @@ var optab = []Optab{
{AMOVV, C_REG, C_NONE, C_NONE, C_TLS_LE, C_NONE, 53, 16, 0, 0},
{AMOVB, C_REG, C_NONE, C_NONE, C_TLS_LE, C_NONE, 53, 16, 0, 0},
{AMOVBU, C_REG, C_NONE, C_NONE, C_TLS_LE, C_NONE, 53, 16, 0, 0},
+ {AMOVWP, C_REG, C_NONE, C_NONE, C_SOREG, C_NONE, 73, 4, 0, 0},
+ {AMOVWP, C_REG, C_NONE, C_NONE, C_LOREG, C_NONE, 73, 4, 0, 0},
{AMOVW, C_LAUTO, C_NONE, C_NONE, C_REG, C_NONE, 36, 12, REGSP, 0},
{AMOVWU, C_LAUTO, C_NONE, C_NONE, C_REG, C_NONE, 36, 12, REGSP, 0},
@@ -233,6 +235,8 @@ var optab = []Optab{
{AMOVV, C_TLS_LE, C_NONE, C_NONE, C_REG, C_NONE, 54, 16, 0, 0},
{AMOVB, C_TLS_LE, C_NONE, C_NONE, C_REG, C_NONE, 54, 16, 0, 0},
{AMOVBU, C_TLS_LE, C_NONE, C_NONE, C_REG, C_NONE, 54, 16, 0, 0},
+ {AMOVWP, C_SOREG, C_NONE, C_NONE, C_REG, C_NONE, 74, 4, 0, 0},
+ {AMOVWP, C_LOREG, C_NONE, C_NONE, C_REG, C_NONE, 74, 4, 0, 0},
{AMOVW, C_SACON, C_NONE, C_NONE, C_REG, C_NONE, 3, 4, REGSP, 0},
{AMOVV, C_SACON, C_NONE, C_NONE, C_REG, C_NONE, 3, 4, REGSP, 0},
@@ -438,8 +442,6 @@ var optab = []Optab{
{obj.ANOP, C_FREG, C_NONE, C_NONE, C_NONE, C_NONE, 0, 0, 0, 0},
{obj.ADUFFZERO, C_NONE, C_NONE, C_NONE, C_BRAN, C_NONE, 11, 4, 0, 0}, // same as AJMP
{obj.ADUFFCOPY, C_NONE, C_NONE, C_NONE, C_BRAN, C_NONE, 11, 4, 0, 0}, // same as AJMP
-
- {obj.AXXX, C_NONE, C_NONE, C_NONE, C_NONE, C_NONE, 0, 4, 0, 0},
}
var atomicInst = map[obj.As]uint32{
@@ -1303,31 +1305,27 @@ func buildop(ctxt *obj.Link) {
return
}
- var n int
-
- for i := 0; i < C_NCLASS; i++ {
- for n = 0; n < C_NCLASS; n++ {
- if cmp(n, i) {
- xcmp[i][n] = true
+ for i := range C_NCLASS {
+ for j := range C_NCLASS {
+ if cmp(j, i) {
+ xcmp[i][j] = true
}
}
}
- for n = 0; optab[n].as != obj.AXXX; n++ {
- }
- slices.SortFunc(optab[:n], ocmp)
- for i := 0; i < n; i++ {
- r := optab[i].as
- r0 := r & obj.AMask
- start := i
- for optab[i].as == r {
- i++
- }
- oprange[r0] = optab[start:i]
- i--
- switch r {
+ slices.SortFunc(optab, ocmp)
+ for i := 0; i < len(optab); i++ {
+ as, start := optab[i].as, i
+ for ; i < len(optab)-1; i++ {
+ if optab[i+1].as != as {
+ break
+ }
+ }
+ r0 := as & obj.AMask
+ oprange[r0] = optab[start : i+1]
+ switch as {
default:
- ctxt.Diag("unknown op in build: %v", r)
+ ctxt.Diag("unknown op in build: %v", as)
ctxt.DiagFlush()
log.Fatalf("bad code")
@@ -1443,6 +1441,9 @@ func buildop(ctxt *obj.Link) {
case AMOVBU:
opset(AMOVHU, r0)
+ case AMOVWP:
+ opset(AMOVVP, r0)
+
case AMUL:
opset(AMULU, r0)
opset(AMULH, r0)
@@ -1970,6 +1971,10 @@ func OP_16IRR(op uint32, i uint32, r2 uint32, r3 uint32) uint32 {
return op | (i&0xFFFF)<<10 | (r2&0x1F)<<5 | (r3&0x1F)<<0
}
+func OP_14IRR(op uint32, i uint32, r2 uint32, r3 uint32) uint32 {
+ return op | (i&0x3FFF)<<10 | (r2&0x1F)<<5 | (r3&0x1F)<<0
+}
+
func OP_12IR_5I(op uint32, i1 uint32, r2 uint32, i2 uint32) uint32 {
return op | (i1&0xFFF)<<10 | (r2&0x1F)<<5 | (i2&0x1F)<<0
}
@@ -2899,6 +2904,20 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
o3 = OP_12IRR(c.opirr(ALU52ID), uint32(v>>52), uint32(REGTMP), uint32(REGTMP))
}
o4 = OP_RRR(c.oprrr(p.As), uint32(REGTMP), uint32(r), uint32(p.To.Reg))
+
+ case 73:
+ v := c.regoff(&p.To)
+ if v&3 != 0 {
+ c.ctxt.Diag("%v: offset must be a multiple of 4.\n", p)
+ }
+ o1 = OP_14IRR(c.opirr(p.As), uint32(v>>2), uint32(p.To.Reg), uint32(p.From.Reg))
+
+ case 74:
+ v := c.regoff(&p.From)
+ if v&3 != 0 {
+ c.ctxt.Diag("%v: offset must be a multiple of 4.\n", p)
+ }
+ o1 = OP_14IRR(c.opirr(-p.As), uint32(v>>2), uint32(p.From.Reg), uint32(p.To.Reg))
}
out[0] = o1
@@ -4032,6 +4051,10 @@ func (c *ctxt0) opirr(a obj.As) uint32 {
return 0x0ad << 22
case AMOVD:
return 0x0af << 22
+ case AMOVVP:
+ return 0x27 << 24 // stptr.d
+ case AMOVWP:
+ return 0x25 << 24 // stptr.w
case -AMOVB:
return 0x0a0 << 22
case -AMOVBU:
@@ -4050,6 +4073,10 @@ func (c *ctxt0) opirr(a obj.As) uint32 {
return 0x0ac << 22
case -AMOVD:
return 0x0ae << 22
+ case -AMOVVP:
+ return 0x26 << 24 // ldptr.d
+ case -AMOVWP:
+ return 0x24 << 24 // ldptr.w
case -AVMOVQ:
return 0x0b0 << 22 // vld
case -AXVMOVQ:
diff --git a/src/cmd/internal/obj/loong64/doc.go b/src/cmd/internal/obj/loong64/doc.go
index 64bb41ae5a..6c8f2618a2 100644
--- a/src/cmd/internal/obj/loong64/doc.go
+++ b/src/cmd/internal/obj/loong64/doc.go
@@ -289,6 +289,34 @@ Note: In the following sections 3.1 to 3.6, "ui4" (4-bit unsigned int immediate)
Go assembly | instruction Encoding
ALSLV $4, r4, r5, R6 | 002d9486
+
+5. Note of special memory access instructions
+ Instruction format:
+ MOVWP offset(Rj), Rd
+ MOVVP offset(Rj), Rd
+ MOVWP Rd, offset(Rj)
+ MOVVP Rd, offset(Rj)
+
+ Mapping between Go and platform assembly:
+ Go assembly | platform assembly
+ MOVWP offset(Rj), Rd | ldptr.w rd, rj, si14
+ MOVVP offset(Rj), Rd | ldptr.d rd, rj, si14
+ MOVWP Rd, offset(Rj) | stptr.w rd, rj, si14
+ MOVVP Rd, offset(Rj) | stptr.d rd, rj, si14
+
+ note: In Go assembly, for ease of understanding, offset is a 16-bit immediate number representing
+ the actual address offset, but in platform assembly, it need a 14-bit immediate number.
+ si14 = offset>>2
+
+ The addressing calculation for the above instruction involves logically left-shifting the 14-bit
+ immediate number si14 by 2 bits, then sign-extending it, and finally adding it to the value in the
+ general-purpose register rj to obtain the sum.
+
+ For example:
+
+ Go assembly | platform assembly
+ MOVWP 8(R4), R5 | ldptr.w r5, r4, $2
+
*/
package loong64
diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go
index b071bd530d..03718fbb31 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -2120,19 +2120,6 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
c0 := c
c = pjc.padJump(ctxt, s, p, c)
- if p.As == obj.APCALIGN || p.As == obj.APCALIGNMAX {
- v := obj.AlignmentPadding(c, p, ctxt, s)
- if v > 0 {
- s.Grow(int64(c) + int64(v))
- fillnop(s.P[c:], int(v))
- }
- p.Pc = int64(c)
- c += int32(v)
- pPrev = p
- continue
-
- }
-
if maxLoopPad > 0 && p.Back&branchLoopHead != 0 && c&(loopAlign-1) != 0 {
// pad with NOPs
v := -c & (loopAlign - 1)
@@ -2165,6 +2152,18 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
}
}
+ if p.As == obj.APCALIGN || p.As == obj.APCALIGNMAX {
+ v := obj.AlignmentPadding(c, p, ctxt, s)
+ if v > 0 {
+ s.Grow(int64(c) + int64(v))
+ fillnop(s.P[c:], int(v))
+ }
+ p.Pc = int64(c)
+ c += int32(v)
+ pPrev = p
+ continue
+ }
+
p.Rel = nil
p.Pc = int64(c)