summaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
Commit message (Collapse)AuthorAgeFilesLines
* cmd/asm: remove unsupported opcodes MOVNP and STLP for arm64HEADmastererifan012023-05-183-468/+442
| | | | | | | | | | | | | ARM64 doesn't have MOVNP/MOVNPW and STLP/STLPW instructions, which are currently useless instructions as well. This CL deletes them. At the same time this CL sorts the opcodes by name, which looks cleaner. Change-Id: I25cfb636b23356ba0a50cba527a8c85b3f7e2ee4 Reviewed-on: https://go-review.googlesource.com/c/go/+/495695 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Eric Fang <eric.fang@arm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/riscv: regenerate instruction encoding tableMeng Zhuo2023-05-103-393/+355
| | | | | | | | | | | | | | | | | | | | | | | | | | | This CL updates riscv instructions by https://github.com/riscv/riscv-opcodes which adds instruction: APAUSE And removes the following unused instructions: AFENCEI AFMVQX AFMVXQ AHFENCEGVMA AHFENCEVVMA ASLLIRV32 ASRAIRV32 ASRLIRV32 AURET Change-Id: I314570c643af3e6bbc9d2cd471b6b39985bcbdff Reviewed-on: https://go-review.googlesource.com/c/go/+/409415 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: M Zhuo <mzh@golangcn.org>
* cmd/compile: standardize on outer-to-inner for pos listsRuss Cox2023-05-092-16/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The call sites that cared all reversed inner-to-outer to outer-to-inner already. The ones that didn't care left it alone. No one explicitly wanted inner-to-outer. Also change to a callback-based interface, so that call sites aren't required to accumulate the results in a slice (the main reason for that before was to reverse the slice!). There were three places where these lists were printed: 1. -d=ssa/genssa/dump, explicitly reversing to outer-to-inner 2. node dumps like -W, leaving the default inner-to-outer 3. file positions for HashDebugs, explicitly reversing to outer-to-inner It makes no sense that (1) and (2) would differ. The reason they do is that the code for (2) was too lazy to bother to fix it to be the right way. Consider this program: package p func f() { g() } func g() { println() } Both before and after this change, the ssa dump for f looks like: # x.go:3 00000 (3) TEXT <unlinkable>.f(SB), ABIInternal 00001 (3) FUNCDATA $0, gclocals·g2BeySu+wFnoycgXfElmcg==(SB) 00002 (3) FUNCDATA $1, gclocals·g2BeySu+wFnoycgXfElmcg==(SB) v4 00003 (-4) XCHGL AX, AX # x.go:4 # x.go:8 v5 00004 (+8) PCDATA $1, $0 v5 00005 (+8) CALL runtime.printlock(SB) v7 00006 (-8) CALL runtime.printnl(SB) v9 00007 (-8) CALL runtime.printunlock(SB) # x.go:5 b2 00008 (5) RET 00009 (?) END Note # x.go:4 (f) then # x.go:8 (g, called from f) between v4 and v5. The -W node dumps used the opposite order: before walk f . AS2 Def tc(1) # x.go:4:3 . INLMARK # +x.go:4:3 . PRINTN tc(1) # x.go:8:9,x.go:4:3 . LABEL p..i0 # x.go:4:3 Now they match the ssa dump order, and they use spaces as separators, to avoid potential problems with commas in some editors. before walk f . AS2 Def tc(1) # x.go:4:3 . INLMARK # +x.go:4:3 . PRINTN tc(1) # x.go:4:3 x.go:8:9 . LABEL p..i0 # x.go:4:3 I'm unaware of any argument for the old order other than it was easier to compute without allocation. The new code uses recursion to reverse the order without allocation. Now that the callers get the results outer-to-inner, most don't need any slices at all. This change is particularly important for HashDebug, which had been using a locked temporary slice to walk the inline stack without allocation. Now the temporary slice is gone. Change-Id: I5cb6d76b2f950db67b248acc928e47a0460569f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/493735 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Russ Cox <rsc@golang.org>
* cmd/link, cmd/internal/obj: use aux symbol for global variable DWARF infoCherry Mui2023-05-024-15/+52
| | | | | | | | | | | | | Currently, for a global variable, its debug info symbol is a named symbol with the variable's name with a special prefix. And the linker looks it up by name. This CL makes the debug info symbol an aux symbol of the variable symbol. Change-Id: I55614d0ef2af9c53eb40144ad80e09339bf3cbee Reviewed-on: https://go-review.googlesource.com/c/go/+/490816 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
* cmd/internal/obj/arm64: pass obj.As to oaddi rather than an instructionJoel Sing2023-04-281-33/+29
| | | | | | | | | | | | | This simplifies callers, as they do not need to call opirr before calling oaddi. Additionally, use appropriate types (int16) for registers, which avoids the need to continually cast. Change-Id: I8ca3807a97867ac49d63792f6922a18f35824448 Reviewed-on: https://go-review.googlesource.com/c/go/+/471520 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/arm64: use appropriate return type for regoffJoel Sing2023-04-281-16/+16
| | | | | | | | | | | | All of the callers of regoff cast the return value from uint32 to int32. Instead, simply return int32 in the first place. Change-Id: I43a672bb3143a71f4a37779ed8ae9adcda623ba4 Reviewed-on: https://go-review.googlesource.com/c/go/+/490355 Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* Revert "cmd/compile: constant-fold loads from constant dictionaries and types"Chressie Himpel2023-04-281-17/+1
| | | | | | | | | | | | | | This reverts CL 486895. Reason for revert: This breaks internal tests at Google, see b/280035614. Change-Id: I48772a44f5f6070a7f06b5704e9f9aa272b5f978 Reviewed-on: https://go-review.googlesource.com/c/go/+/490156 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Stapelberg <stapelberg@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Michael Stapelberg <stapelberg@google.com> Reviewed-by: David Chase <drchase@google.com>
* cmd/compile: constant-fold loads from constant dictionaries and typesKeith Randall2023-04-271-1/+17
| | | | | | | | | | | | | Update #59591 Change-Id: Id250a7779c5b53776fff73f3e678fec54d92a8e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/486895 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/abi, runtime, cmd: merge StackSmall, StackBig consts into internal/abiAustin Clements2023-04-219-36/+35
| | | | | | | | | | | For #59670. Change-Id: I91448363be2fc678964ce119d85cd5fae34a14da Reviewed-on: https://go-review.googlesource.com/c/go/+/486975 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com>
* internal/abi, runtime, cmd: merge PCDATA_* and FUNCDATA_* consts into ↵Austin Clements2023-04-212-19/+19
| | | | | | | | | | | | | | | | | | internal/abi We also rename the constants related to unsafe-points: currently, they follow the same naming scheme as the PCDATA table indexes, but are not PCDATA table indexes. For #59670. Change-Id: I06529fecfae535be5fe7d9ac56c886b9106c74fd Reviewed-on: https://go-review.googlesource.com/c/go/+/485497 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* internal/abi, runtime, cmd: merge funcFlag_* consts into internal/abiAustin Clements2023-04-2111-24/+34
| | | | | | | | | | | For #59670. Change-Id: Ie784ba4dd2701e4f455e1abde4a6bfebee4b1387 Reviewed-on: https://go-review.googlesource.com/c/go/+/485496 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com> Auto-Submit: Austin Clements <austin@google.com>
* internal/abi, runtime, cmd: merge funcID_* consts into internal/abiAustin Clements2023-04-211-1/+2
| | | | | | | | | | | For #59670. Change-Id: I517e97ea74cf232e5cfbb77b127fa8804f74d84b Reviewed-on: https://go-review.googlesource.com/c/go/+/485495 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com>
* cmd/internal/obj/ppc64: modify PCALIGN to ensure alignmentLynn Boger2023-04-213-36/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The initial purpose of PCALIGN was to identify code where it would be beneficial to align code for performance, but avoid cases where too many NOPs were added. On p10, it is now necessary to enforce a certain alignment in some cases, so the behavior of PCALIGN needs to be slightly different. Code will now be aligned to the value specified on the PCALIGN instruction regardless of number of NOPs added, which is more intuitive and consistent with power assembler alignment directives. This also adds 64 as a possible alignment value. The existing values used in PCALIGN were modified according to the new behavior. A testcase was updated and performance testing was done to verify that this does not adversely affect performance. Change-Id: Iad1cf5ff112e5bfc0514f0805be90e24095e932b Reviewed-on: https://go-review.googlesource.com/c/go/+/485056 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Archana Ravindar <aravind5@in.ibm.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Paul Murphy <murp@ibm.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* cmd/link,cmd/internal/obj/ppc64: enable PCrel on power10/ppc64/linuxPaul E. Murphy2023-04-211-3/+2
| | | | | | | | | | | | | | | | | | | | A CI machine has been set up to verify GOPPC64=power10 on ppc64/linux. This should be sufficient to verify the PCrel relocation support works for BE. Note, power10/ppc64/linux is an oddball case. Today, it can only link internally. Furthermore, all PCrel relocs are resolved at link time, so it works despite ELFv1 having no official support for PCrel relocs today. Change-Id: Ibf79df69406ec6f9352c9d7d941ad946dba74e73 Reviewed-on: https://go-review.googlesource.com/c/go/+/485075 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* Revert "internal/abi, runtime, cmd: merge StackSmall, StackBig consts into ↵Austin Clements2023-04-209-35/+36
| | | | | | | | | | | | | internal/abi" This reverts commit CL 486379. Submitted out of order and breaks bootstrap. Change-Id: Ie20a61cc56efc79a365841293ca4e7352b02d86b Reviewed-on: https://go-review.googlesource.com/c/go/+/486917 TryBot-Bypass: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com>
* internal/abi, runtime, cmd: merge StackSmall, StackBig consts into internal/abiAustin Clements2023-04-209-36/+35
| | | | | | | | | | For #59670. Change-Id: I04a17079b351b9b4999ca252825373c17afb8a88 Reviewed-on: https://go-review.googlesource.com/c/go/+/486379 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* all: re-run stringerIan Lance Taylor2023-04-111-0/+9
| | | | | | | | | | | | | | | Re-run all go:generate stringer commands. This mostly adds checks that the constant values did not change, but does add new strings for the debug/dwarf and internal/pkgbits packages. Change-Id: I5fc41f20da47338152c183d45d5ae65074e2fccf Reviewed-on: https://go-review.googlesource.com/c/go/+/483717 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* cmd/asm,cmd/internal/obj/x86: add RDPID instruction to x86 assemblerJoel Sing2023-04-114-1/+5
| | | | | | | | | | | | | | | | Add support for the Read Processor ID (RDPID) instruction to the x86 assembler. This returns the current logical processor's ID in the specified register, as a faster alternative to RDTSCP. Fixes #56525 Change-Id: I43482e42431dfc385ce2e7f6d44b9746b0cc4548 Reviewed-on: https://go-review.googlesource.com/c/go/+/482955 Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
* cmd/internal/obj/loong64, cmd/internal/objabi, cmd/link: add support for ↵limeidan2023-04-113-13/+67
| | | | | | | | | | | | | | | | | --buildmode=c-shared on loong64 Updates #53301 Updates #58784 Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742 Reviewed-on: https://go-review.googlesource.com/c/go/+/425476 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: WANG Xuerui <git@xen0n.name> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: WANG Xuerui <git@xen0n.name>
* runtime,cmd/internal/obj/ppc64: cleanup ppc64le runtime.racecallbackthunkPaul E. Murphy2023-04-111-6/+3
| | | | | | | | | | | | | | | Update to use the common macros to ensure all ELFv2 callee-save registers are saved properly when transitioning from ELFv2 to Go calling/stack conventions. Simplify the inlined Go function call, and remove the asm hacks which inhibited implicit stack frame management. Change-Id: Iee118a4069962a791436c6fe19370e1929404a8d Reviewed-on: https://go-review.googlesource.com/c/go/+/479795 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/loong64: auto-align loop heads to 16-byte boundariesWANG Xuerui2023-04-111-8/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CL 479816 took care of loops in hand-written assembly, but did not account for those written in Go, that may become performance-sensitive as well. In this patch, all loop heads are automatically identified and aligned to 16-byte boundaries, by inserting a synthetic `PCALIGN $16` before them. "Loop heads" are defined as targets of backward branches. While at it, tweak some of the local comments so the flow is hopefully clearer. Because LoongArch instructions are all 32 bits long, at most 3 NOOPs can be inserted for each target Prog. This may sound excessive, but benchmark results indicate the current approach is overall profitable anyway. Benchmark results on Loongson 3A5000 (LA464): goos: linux goarch: loong64 pkg: test/bench/go1 │ CL 479816 │ this CL │ │ sec/op │ sec/op vs base │ BinaryTree17 14.10 ± 1% 14.06 ± 1% ~ (p=0.280 n=10) Fannkuch11 3.579 ± 0% 3.419 ± 0% -4.45% (p=0.000 n=10) FmtFprintfEmpty 94.73n ± 0% 94.44n ± 0% -0.31% (p=0.000 n=10) FmtFprintfString 151.9n ± 0% 149.1n ± 0% -1.84% (p=0.000 n=10) FmtFprintfInt 158.3n ± 0% 155.2n ± 0% -1.96% (p=0.000 n=10) FmtFprintfIntInt 241.4n ± 0% 235.4n ± 0% -2.49% (p=0.000 n=10) FmtFprintfPrefixedInt 320.2n ± 0% 314.7n ± 0% -1.73% (p=0.000 n=10) FmtFprintfFloat 414.3n ± 0% 398.7n ± 0% -3.77% (p=0.000 n=10) FmtManyArgs 949.9n ± 0% 929.8n ± 0% -2.12% (p=0.000 n=10) GobDecode 15.24m ± 0% 15.30m ± 0% +0.38% (p=0.035 n=10) GobEncode 18.10m ± 2% 17.59m ± 1% -2.81% (p=0.002 n=10) Gzip 429.9m ± 0% 421.5m ± 0% -1.97% (p=0.000 n=10) Gunzip 88.31m ± 0% 87.39m ± 0% -1.04% (p=0.000 n=10) HTTPClientServer 85.71µ ± 0% 87.24µ ± 0% +1.79% (p=0.000 n=10) JSONEncode 19.74m ± 0% 18.55m ± 0% -6.00% (p=0.000 n=10) JSONDecode 78.60m ± 1% 77.93m ± 0% -0.84% (p=0.000 n=10) Mandelbrot200 7.208m ± 0% 7.217m ± 0% ~ (p=0.481 n=10) GoParse 7.616m ± 1% 7.630m ± 2% ~ (p=0.796 n=10) RegexpMatchEasy0_32 133.0n ± 0% 134.1n ± 0% +0.83% (p=0.000 n=10) RegexpMatchEasy0_1K 1.362µ ± 0% 1.364µ ± 0% +0.15% (p=0.000 n=10) RegexpMatchEasy1_32 161.8n ± 0% 163.7n ± 0% +1.17% (p=0.000 n=10) RegexpMatchEasy1_1K 1.497µ ± 0% 1.497µ ± 0% ~ (p=1.000 n=10) RegexpMatchMedium_32 1.420µ ± 0% 1.446µ ± 0% +1.83% (p=0.000 n=10) RegexpMatchMedium_1K 42.25µ ± 0% 42.53µ ± 0% +0.65% (p=0.000 n=10) RegexpMatchHard_32 2.108µ ± 0% 2.116µ ± 0% +0.38% (p=0.000 n=10) RegexpMatchHard_1K 62.65µ ± 0% 63.23µ ± 0% +0.93% (p=0.000 n=10) Revcomp 1.192 ± 0% 1.198 ± 0% +0.55% (p=0.000 n=10) Template 115.6m ± 2% 116.9m ± 1% ~ (p=0.075 n=10) TimeParse 418.1n ± 1% 414.7n ± 0% -0.81% (p=0.000 n=10) TimeFormat 517.9n ± 0% 513.7n ± 0% -0.81% (p=0.000 n=10) geomean 103.5µ 102.6µ -0.79% │ CL 479816 │ this CL │ │ B/s │ B/s vs base │ GobDecode 48.04Mi ± 0% 47.86Mi ± 0% -0.38% (p=0.035 n=10) GobEncode 40.44Mi ± 2% 41.61Mi ± 1% +2.89% (p=0.001 n=10) Gzip 43.04Mi ± 0% 43.91Mi ± 0% +2.02% (p=0.000 n=10) Gunzip 209.6Mi ± 0% 211.8Mi ± 0% +1.05% (p=0.000 n=10) JSONEncode 93.76Mi ± 0% 99.75Mi ± 0% +6.39% (p=0.000 n=10) JSONDecode 23.55Mi ± 1% 23.75Mi ± 0% +0.85% (p=0.000 n=10) GoParse 7.253Mi ± 1% 7.238Mi ± 2% ~ (p=0.698 n=10) RegexpMatchEasy0_32 229.4Mi ± 0% 227.6Mi ± 0% -0.82% (p=0.000 n=10) RegexpMatchEasy0_1K 717.3Mi ± 0% 716.2Mi ± 0% -0.15% (p=0.000 n=10) RegexpMatchEasy1_32 188.6Mi ± 0% 186.4Mi ± 0% -1.13% (p=0.000 n=10) RegexpMatchEasy1_1K 652.2Mi ± 0% 652.3Mi ± 0% +0.01% (p=0.005 n=10) RegexpMatchMedium_32 21.49Mi ± 0% 21.11Mi ± 0% -1.73% (p=0.000 n=10) RegexpMatchMedium_1K 23.11Mi ± 0% 22.96Mi ± 0% -0.62% (p=0.000 n=10) RegexpMatchHard_32 14.48Mi ± 0% 14.42Mi ± 0% -0.40% (p=0.000 n=10) RegexpMatchHard_1K 15.59Mi ± 0% 15.44Mi ± 0% -0.98% (p=0.000 n=10) Revcomp 203.4Mi ± 0% 202.3Mi ± 0% -0.55% (p=0.000 n=10) Template 16.00Mi ± 2% 15.83Mi ± 1% ~ (p=0.078 n=10) geomean 60.72Mi 60.89Mi +0.29% The slight regression on the Regexp cases is likely because the previous numbers are just coincidental: indeed, large regressions or improvements (of roughly ±10%) happen with definitely irrelevant changes during development. This CL should (hopefully) bring such random performance fluctuations down a bit. Change-Id: I8bdda6e65336da00d4ad79650937b3eeb9db0e7c Reviewed-on: https://go-review.googlesource.com/c/go/+/479817 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: WANG Xuerui <git@xen0n.name>
* cmd/internal/obj/arm64: improve comment and signature of pcAlignPadLengthWANG Xuerui2023-04-111-5/+6
| | | | | | | | | | | | | | | | | | | | | The function just calculates the number of needed padding bytes, instead of actually carrying out the alignment operation. And it has the context argument at the end of the argument list, while contexts idiomatically come first. Indeed, this is the only case in cmd/internal/obj where ctxt is not the only argument and does not come first. Fix those two nits; no functional change intended. Suggested by Ian during review of CL 479815 (that introduces a copy of this helper into the loong64 port). Change-Id: Ieb221ead23282abe6e04804d537e1234c7ab21d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/483155 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* cmd/internal/obj/loong64, cmd/link/internal: switch to LoongArch ELF psABI ↵WANG Xuerui2023-04-101-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v2 relocs The LoongArch ELF psABI v2 [1] relocs are vastly simplified from the v1 which involved a stack machine for computing the reloc values, but the details of PC-relative addressing are changed as well. Specifically, the `pcaddu12i` instruction is substituted with the `pcalau12i`, which is like arm64's `adrp` -- meaning the lower bits of a symbol's address now have to be absolute and not PC-relative. However, apart from the little bit of added complexity, the obvious advantage is that only 1 reloc needs to be emitted for every kind of external reloc we care about. This can mean substantial space savings (each RELA reloc occupies 24 bytes), and no open-coded stack ops has to remain any more. While at it, update the preset value for the output ELF's flags to indicate the psABI update. Fixes #58784 [1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html Change-Id: I5c13bc710eaf58293a32e930dd33feff2ef14c28 Reviewed-on: https://go-review.googlesource.com/c/go/+/455017 Run-TryBot: Ben Shi <powerman1st@163.com> Reviewed-by: xiaodong liu <teaofmoli@gmail.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* cmd/link, cmd/internal/obj/loong64: support the PCALIGN directiveWANG Xuerui2023-04-071-4/+41
| | | | | | | | | | | | | | | | | | | | | Allow writing `PCALIGN $imm` where imm is a power-of-2 between 8 and 2048 (inclusive), for ensuring that the following instruction is placed at an imm-byte boundary relative to the beginning of the function. If the PC is not sufficiently aligned, NOOPs will be inserted to make it so, otherwise the directive will do nothing. This could be useful for both asm performance hand-tuning, and future scenarios where a certain bigger alignment might be required. Change-Id: Iad6244669a3d5adea88eceb0dc7be1af4f0d4fc9 Reviewed-on: https://go-review.googlesource.com/c/go/+/479815 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: WANG Xuerui <git@xen0n.name> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/internal/obj: generate SEH aux symbols for windows/amd64qmuntal2023-04-056-2/+157
| | | | | | | | | | | | | | | | | | | | This CL updates the Go compiler so it generate SEH unwind info [1] as a function auxiliary symbol when building for windows/amd64. A follow up CL will teach the Go linker how to assemble these codes into the PE .xdata section. Updates #57302 [1] https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-unwind_info Change-Id: I40ae0437bfee326c1a67c2b5e1496f0bf3ecea17 Reviewed-on: https://go-review.googlesource.com/c/go/+/461749 Reviewed-by: Davis Goodin <dagood@microsoft.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
* cmd/internal/obj/arm64: use more appropriate types for olsr9s/olsr12uJoel Sing2023-04-051-19/+18
| | | | | | | | | | | | This allows for a large number of casts to be removed at call sites. While here, use consistent register naming. Change-Id: I78a2a928b78c9f09f91fb6ed6ad440aa4e63923d Reviewed-on: https://go-review.googlesource.com/c/go/+/471517 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* cmd/internal/obj/arm64: use more appropriate types for opldpstpJoel Sing2023-04-051-35/+37
| | | | | | | | | | | | This allows for a large number of casts to be removed at call sites. While here, use consistent register naming. Change-Id: I68cee985f6500ed9523f7fb3efbc11bb849681dc Reviewed-on: https://go-review.googlesource.com/c/go/+/471516 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* cmd/internal/obj/arm64: use more appropriate types for opbfm and opextrJoel Sing2023-04-051-21/+15
| | | | | | | | | | | This allows for a large number of casts to be removed at call sites. Change-Id: I44a162040cc5b4de02e106d3a6de10f8e0870cb9 Reviewed-on: https://go-review.googlesource.com/c/go/+/471515 Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* all: add wasip1 asm and link logicJohan Brandhorst-Satzkorn2023-04-051-2/+3
| | | | | | | | | | | | | | | | | | | | Add wasip1 asm and symbols to cmd/internal/obj, cmd/link and runtime. For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: Ie088d9b65ea13e231694af6341465f95be33093f Reviewed-on: https://go-review.googlesource.com/c/go/+/479617 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* all: fix misuses of "a" vs "an"cui fliter2023-04-043-3/+3
| | | | | | | | | | | | | | Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/ Change-Id: I53ac724070e3ff3d33c304483fe72c023c7cda47 Reviewed-on: https://go-review.googlesource.com/c/go/+/480536 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* cmd/internal/obj: remove redundant cnames on loong64Guoqi Chen2023-03-311-1/+1
| | | | | | | | | | | | | Change-Id: I5aa6328a12e74b2801ab60b5a5bb8571d382d5ef Reviewed-on: https://go-review.googlesource.com/c/go/+/425301 Reviewed-by: xiaodong liu <teaofmoli@gmail.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: WANG Xuerui <git@xen0n.name> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* cmd/internal/obj/loong64: remove Optab.family and reorganize operand class ↵WANG Xuerui2023-03-311-336/+346
| | | | | | | | | | | | | | | | | | | | | | | | fields There is currently no support for GOARCH=loong32, so the Optab.family field is unused so far. Remove it to simplify the optab; the loong assembler backend would likely already be overhauled into a sufficiently different shape by the time we start to care for loong32, that the data we have today would be useless anyway. While at it, add a operand class slot for the 3rd source operand (support for which will arrive in later commits), and rename the other operand class fields to be self-documenting. The changes are being merged into this patch for sake of reducing code churn. Change-Id: Icf0988e34ff1c0f762c8e0708cfcef2e7954760c Reviewed-on: https://go-review.googlesource.com/c/go/+/477715 Reviewed-by: abner chenc <chenguoqi@loongson.cn> Run-TryBot: Ben Shi <powerman1st@163.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org>
* cmd/internal/obj/loong64: assemble BEQ/BNEs comparing with 0 as beqz/bnezWANG Xuerui2023-03-311-10/+29
| | | | | | | | | | | | | | | | | | | | LoongArch (except for the extremely reduced LA32 Primary subset) has dedicated beqz/bnez instructions as alternative encodings for beq/bne with one of the source registers being R0, that allow the offset field to occupy 5 more bits, giving 21 bits in total (equal to the FP branches). Make use of them instead of beq/bne if one source operand is omitted in asm, or if one of the registers being compared is R0. Multiple go1 benchmark runs indicate the change is not perf-sensitive. Change-Id: If6267623c82092e81d75578091fb4e013658b9f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/478377 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Run-TryBot: Ben Shi <powerman1st@163.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org>
* cmd/internal/obj/loong64: save LR after decrementing SPGuoqi Chen2023-03-281-0/+14
| | | | | | | | | | | | | | | | | | | | Refer to CL 413428 and 412474, for loong64, like mips, s390x and riscv, there is no single instruction that saves the LR and decrements the SP, so we also need to insert an instruction to save the LR after decrementing the SP. Fixes #56623. Updates #53374. Change-Id: I3de040792f0a041d3d2a98ea89c23a2dd2f4ad10 Reviewed-on: https://go-review.googlesource.com/c/go/+/416154 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: WANG Xuerui <git@xen0n.name> Reviewed-by: xiaodong liu <teaofmoli@gmail.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn>
* cmd/internal/obj/loong64: clean up code for short conditional branchesWANG Xuerui2023-03-271-15/+15
| | | | | | | | | | | | | | | Untangle the logic so the preparation of operands and actual assembling (branch range checking included) are properly separated, making future changes easier to review and maintain. No functional change intended. Change-Id: I1f73282f9d92ff23d84846453d3597ba66d207d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/478376 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/ppc64: fix incorrect base reg causing segvLynn Boger2023-03-241-4/+11
| | | | | | | | | | | | | | | | | | This fixes a segv that was reported due to building minio. The problem occurred because of an incorrect selection of the base register, which was introduced by CL 306369. Fixes #59196 Change-Id: Ieb77b2afa8fb4e6f3943df5ce138679f6750d376 Reviewed-on: https://go-review.googlesource.com/c/go/+/478920 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Archana Ravindar <aravind5@in.ibm.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/loong64: realize all unconditional jumps with B/BLWANG Xuerui2023-03-221-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current practice of using the "PC-relative" `BEQ ZERO, ZERO` for short jumps is inherited from the MIPS port, where the pre-R6 long jumps are PC-regional instead of PC-relative. This quirk is not present in LoongArch from the very beginning so there is no reason to keep the behavior any more. While at it, simplify the code to not place anything in the jump offset field if a relocation is to take place. (It may be relic of a previous REL-era treatment where the addend is to be stored in the instruction word, but again, loong64 is exclusively RELA from day 1 so no point in doing so either.) Benchmark shows very slight improvement on a 3A5000 box, indicating the LA464 micro-architecture presumably *not* seeing the always-true BEQs as equivalent to B: goos: linux goarch: loong64 pkg: test/bench/go1 │ 2ef70d9d0f │ this CL │ │ sec/op │ sec/op vs base │ BinaryTree17 14.57 ± 4% 14.54 ± 1% ~ (p=0.353 n=10) Fannkuch11 3.570 ± 0% 3.570 ± 0% ~ (p=0.529 n=10) FmtFprintfEmpty 92.84n ± 0% 92.84n ± 0% ~ (p=0.970 n=10) FmtFprintfString 150.0n ± 0% 149.9n ± 0% ~ (p=0.350 n=10) FmtFprintfInt 153.3n ± 0% 153.3n ± 0% ~ (p=1.000 n=10) ¹ FmtFprintfIntInt 235.8n ± 0% 235.8n ± 0% ~ (p=0.963 n=10) FmtFprintfPrefixedInt 318.5n ± 0% 318.5n ± 0% ~ (p=0.474 n=10) FmtFprintfFloat 410.4n ± 0% 410.4n ± 0% ~ (p=0.628 n=10) FmtManyArgs 944.9n ± 0% 945.0n ± 0% ~ (p=0.240 n=10) GobDecode 13.97m ± 12% 12.83m ± 21% ~ (p=0.165 n=10) GobEncode 17.84m ± 5% 18.60m ± 4% ~ (p=0.123 n=10) Gzip 421.0m ± 0% 421.0m ± 0% ~ (p=0.579 n=10) Gunzip 89.80m ± 0% 89.77m ± 0% ~ (p=0.529 n=10) HTTPClientServer 86.54µ ± 1% 86.25µ ± 0% -0.33% (p=0.003 n=10) JSONEncode 18.57m ± 0% 18.57m ± 0% ~ (p=0.353 n=10) JSONDecode 77.48m ± 0% 77.30m ± 0% -0.23% (p=0.035 n=10) Mandelbrot200 7.217m ± 0% 7.217m ± 0% ~ (p=0.436 n=10) GoParse 7.599m ± 2% 7.632m ± 1% ~ (p=0.353 n=10) RegexpMatchEasy0_32 140.1n ± 0% 140.1n ± 0% ~ (p=0.582 n=10) RegexpMatchEasy0_1K 1.538µ ± 0% 1.538µ ± 0% ~ (p=1.000 n=10) ¹ RegexpMatchEasy1_32 161.7n ± 0% 161.7n ± 0% ~ (p=1.000 n=10) ¹ RegexpMatchEasy1_1K 1.632µ ± 0% 1.632µ ± 0% ~ (p=1.000 n=10) ¹ RegexpMatchMedium_32 1.369µ ± 0% 1.369µ ± 0% ~ (p=1.000 n=10) RegexpMatchMedium_1K 39.96µ ± 0% 39.96µ ± 0% +0.01% (p=0.010 n=10) RegexpMatchHard_32 2.099µ ± 0% 2.099µ ± 0% ~ (p=1.000 n=10) ¹ RegexpMatchHard_1K 62.50µ ± 0% 62.50µ ± 0% ~ (p=0.099 n=10) Revcomp 1.349 ± 0% 1.347 ± 0% -0.14% (p=0.001 n=10) Template 118.4m ± 0% 118.0m ± 0% -0.36% (p=0.023 n=10) TimeParse 407.8n ± 0% 407.9n ± 0% +0.02% (p=0.000 n=10) TimeFormat 508.0n ± 0% 507.9n ± 0% ~ (p=0.421 n=10) geomean 103.5µ 103.3µ -0.17% ¹ all samples are equal │ 2ef70d9d0f │ this CL │ │ B/s │ B/s vs base │ GobDecode 52.67Mi ± 11% 57.04Mi ± 17% ~ (p=0.149 n=10) GobEncode 41.03Mi ± 4% 39.35Mi ± 4% ~ (p=0.118 n=10) Gzip 43.95Mi ± 0% 43.95Mi ± 0% ~ (p=0.428 n=10) Gunzip 206.1Mi ± 0% 206.1Mi ± 0% ~ (p=0.399 n=10) JSONEncode 99.64Mi ± 0% 99.66Mi ± 0% ~ (p=0.304 n=10) JSONDecode 23.88Mi ± 0% 23.94Mi ± 0% +0.22% (p=0.030 n=10) GoParse 7.267Mi ± 2% 7.238Mi ± 1% ~ (p=0.360 n=10) RegexpMatchEasy0_32 217.8Mi ± 0% 217.8Mi ± 0% -0.00% (p=0.006 n=10) RegexpMatchEasy0_1K 635.0Mi ± 0% 635.0Mi ± 0% ~ (p=0.194 n=10) RegexpMatchEasy1_32 188.7Mi ± 0% 188.7Mi ± 0% ~ (p=0.338 n=10) RegexpMatchEasy1_1K 598.5Mi ± 0% 598.5Mi ± 0% -0.00% (p=0.000 n=10) RegexpMatchMedium_32 22.30Mi ± 0% 22.30Mi ± 0% ~ (p=0.211 n=10) RegexpMatchMedium_1K 24.43Mi ± 0% 24.43Mi ± 0% ~ (p=1.000 n=10) RegexpMatchHard_32 14.54Mi ± 0% 14.54Mi ± 0% ~ (p=0.474 n=10) RegexpMatchHard_1K 15.62Mi ± 0% 15.62Mi ± 0% ~ (p=1.000 n=10) ¹ Revcomp 179.7Mi ± 0% 180.0Mi ± 0% +0.14% (p=0.001 n=10) Template 15.63Mi ± 0% 15.68Mi ± 0% +0.34% (p=0.022 n=10) geomean 60.29Mi 60.44Mi +0.24% ¹ all samples are equal Change-Id: I112dd663c49567386ea75dd4966a9f8127ffb90e Reviewed-on: https://go-review.googlesource.com/c/go/+/478075 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/internal/obj/ppc64: add VC[LT]ZLSBB instructionsPaul E. Murphy2023-03-223-0/+13
| | | | | | | | | | | | | | | | These are ISA 3.0 power9 instructions which are helpful when reducing a vector compare result into a GPR. They are used in a future patch to improve the bytes.IndexByte asm routine. Change-Id: I424e2628e577167b9b7c0fcbd82099daf568ea35 Reviewed-on: https://go-review.googlesource.com/c/go/+/478115 Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* cmd/internal/obj/loong64: add support for movgr2cf and movcf2gr instructionsHuang Qiqi2023-03-211-0/+11
| | | | | | | | | | | | Change-Id: I7ff3c8df24ed7990fe104bc2530354c0bd5fe018 Reviewed-on: https://go-review.googlesource.com/c/go/+/475576 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: xiaodong liu <teaofmoli@gmail.com> Reviewed-by: WANG Xuerui <git@xen0n.name>
* cmd/internal/obj/loong64: add the PCALAU12I instruction for reloc useWANG Xuerui2023-03-163-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | The LoongArch ELF psABI v2.00 revamped the relocation design, largely moving to using the `pcalau12i + addi/ld/st` pair for PC-relative addressing within +/- 32 bits. The "pcala" in `pcalau12i` stands for "PC-aligned add"; the instruction's semantics happen to coincide with arm64's `adrp`. Add support for emitting this instruction as part of the relevant addressing ops, for use with new reloc types later. Updates #58784 Change-Id: Ic1747cd9745aad0d1abb9bd78400cd5ff5978bc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/455016 Reviewed-by: abner chenc <chenguoqi@loongson.cn> Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: xiaodong liu <teaofmoli@gmail.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/asm: improve detector for incorrect R15 usage when dynamic linkingKeith Randall2023-03-151-32/+117
| | | | | | | | | | | Fixes #58632 Change-Id: Idb19af2ac693ea5920da57c1808f1bc02702929d Reviewed-on: https://go-review.googlesource.com/c/go/+/476295 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
* cmd/internal/obj/loong64: remove invalid branch delay slotsGuoqi Chen2023-03-131-3/+0
| | | | | | | | | | | | Change-Id: I222717771019f7aefa547971b2d94ef4677a42c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/420979 Reviewed-by: WANG Xuerui <git@xen0n.name> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Run-TryBot: hopehook <hopehook@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
* cmd/internal/obj/ppc64: add SETB instructionPaul E. Murphy2023-03-083-0/+12
| | | | | | | | | | | | | | This ISA 3.0 (power9) instruction is helpful for some string functions in a future change. Change-Id: I1a659488ffb5099f8c89f480c39af4ef9c4b556a Reviewed-on: https://go-review.googlesource.com/c/go/+/472635 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Archana Ravindar <aravind5@in.ibm.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* cmd/asm: don't panic on bad GATHER x86 instructionsKeith Randall2023-03-021-0/+5
| | | | | | | | | | | | | Fixes #58822 Change-Id: I9c44c57dac72884ec3209d87ddb25e7e1675a737 Reviewed-on: https://go-review.googlesource.com/c/go/+/472795 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com>
* all: implement wasmimport directiveEvan Phoenix2023-03-026-23/+221
| | | | | | | | | | | | | | | | | | | | | | | | | | Go programs can now use the //go:wasmimport module_name function_name directive to import functions from the WebAssembly runtime. For now, the directive is restricted to the runtime and syscall/js packages. * Derived from CL 350737 * Original work modified to work with changes to the IR conversion code. * Modification of CL 350737 changes to fully exist in Unified IR path (emp) * Original work modified to work with changes to the ABI configuration code. * Fixes #38248 Co-authored-by: Vedant Roy <vroy101@gmail.com> Co-authored-by: Richard Musiol <mail@richard-musiol.de> Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Change-Id: I740719735d91c306ac718a435a78e1ee9686bc16 Reviewed-on: https://go-review.googlesource.com/c/go/+/463018 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
* runtime: remove implicit NOFRAME heuristic supportqmuntal2023-03-011-14/+2
| | | | | | | | | | | | | | | All amd64 OSes already make use of the NOFRAME flag wherever is required, so we can remove the frameless nosplit functions heuristic code path. Updates #58378 Change-Id: I966970693ba07f8c66da0aca83c23caad7cbbfe5 Reviewed-on: https://go-review.googlesource.com/c/go/+/466458 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
* runtime: use explicit NOFRAME on plan9/amd64qmuntal2023-03-011-1/+1
| | | | | | | | | | | | | | This CL marks some plan9 assembly functions as NOFRAME to avoid relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions without stack were also marked as NOFRAME. Updates #58378 Change-Id: Ic8c9ab5c1a0897bebc6c1419ddc903a7492a1b0a Reviewed-on: https://go-review.googlesource.com/c/go/+/466457 TryBot-Bypass: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* cmd/internal/obj: use prefix insn in MOV* opcodes for GOPPC64=power10Paul E. Murphy2023-02-282-56/+269
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As background, Power10 adds prefixed load, store, and add immediate instructions which encode 34b signed displacements. Likewise, they also give the option to compute addresses against the PC. This enables using simpler PC relative (PC-rel) relocations instead of maintaining a dedicated pointer (the TOC) to the code/data blob on PPC64/linux. Similary, there are several Go opcodes where it can be advantageous to use prefixed instructions instead of composite sequences like oris/ori/add to implement "MOVD <big const>, Rx" or "ADD <big const>, Rx, Ry", or large offset load/stores like "MOVD <big constant>(Rx), Ry" using the same framework which dynamically configures optab. When selecting prefixed instruction forms, the assembler must also use new relocations. These new relocations are always PC-rel by design, thus code assembled as such has no implicit requirement to maintain a TOC pointer when assembling shared objects. Thus, we can safely avoid situations where some Go objects use a TOC pointer, and some do not. This greatly simplifies linking Go objects. For more details about the challenges of linking TOC and PC-rel compiled code, see the PPC64 ELFv2 ABI. The TOC pointer in R2 is still maintained in those build configurations which previously required it (e.x buildmode=pie). However, Go code built with PC-rel relocations does not require the TOC pointer. A future change could remove the overhead of maintaining a TOC pointer in those build configurations. This is enabled only for power10/ppc64le/linux. A final noteworthy difference between the prefixed and regular load/store instruction forms is the removal of the DS/DQ form restrictions. That is, the immediate operand does not need to be aligned. Updates #44549 Change-Id: If59c216d203c3eed963bfa08855e21771e6ed669 Reviewed-on: https://go-review.googlesource.com/c/go/+/355150 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Run-TryBot: Paul Murphy <murp@ibm.com>
* cmd/asm: remove the incorrect check of LDADDx-like instructionsfanzha022023-02-281-11/+2
| | | | | | | | | | | | | | | | | | | | | | | According to the ARM Architecture Reference Manual, LDADDx-like instructions can take rt as zr when the encode A bit is 0. They are used by the alias STADDx-like instructions. The current assembler adds incorrect constraints for them, which is rt can't be zr when field.enc A is 0. This patch removes it. Add test cases. Reported by Matt Horsnell <matt.horsnell@arm.com> The reference: https://developer.arm.com/documentation/ddi0602/2022-12/Base-Instructions Change-Id: Ia2487a5e3900e32994fc14edaf03deeb245e70c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/462295 Reviewed-by: Matt Horsnell <matthew.horsnell@gmail.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: fix typospgxiaolianzi2023-02-281-1/+1
| | | | | | | | | | | | Change-Id: Ica8d5e5799a4de532764ae86cdb623508d3a8e18 GitHub-Last-Rev: 3e97cca9de3885f2fe0d7deb776e59cc1c73146d GitHub-Pull-Request: golang/go#58689 Reviewed-on: https://go-review.googlesource.com/c/go/+/471021 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>