diff options
| author | Joel Sing <joel@sing.id.au> | 2020-01-01 01:28:22 +1100 |
|---|---|---|
| committer | Joel Sing <joel@sing.id.au> | 2020-01-04 04:10:21 +0000 |
| commit | 24902c5be6ba2eac6919879d2e5cb0a7bdadf91c (patch) | |
| tree | 0a6ad4c8ec5a1a693a77517cba878448f8457501 /src/cmd/internal/obj/riscv | |
| parent | 2ee2c6232c3cb7e2927b964701a81c1591c410db (diff) | |
| download | go-24902c5be6ba2eac6919879d2e5cb0a7bdadf91c.tar.xz | |
cmd/internal/obj/riscv: handle MOV rewrites in separate pass
Handle the rewriting of MOV pseudo-instructions in a separate pass. This allows
AMOV to be more readily used by other code, including AGETCALLERPC and ARET
implementations.
Updates #27532
Change-Id: Iea794121210048ed23ed0fb8f3c5e3cd5354a311
Reviewed-on: https://go-review.googlesource.com/c/go/+/212758
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/internal/obj/riscv')
| -rw-r--r-- | src/cmd/internal/obj/riscv/obj.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index 4117438d95..2e9ac6750b 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -594,9 +594,8 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { // Additional instruction rewriting. Any rewrites that change the number // of instructions must occur here (before jump target resolution). for p := cursym.Func.Text; p != nil; p = p.Link { - if p.As == obj.AGETCALLERPC { - // Handle AGETCALLERPC early so we can use AMOV, which is then - // rewritten below. + switch p.As { + case obj.AGETCALLERPC: if cursym.Leaf() { // MOV LR, Rd p.As = AMOV @@ -608,14 +607,6 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { p.From.Type = obj.TYPE_MEM p.From.Reg = REG_SP } - } - - switch p.As { - case AMOV, AMOVB, AMOVH, AMOVW, AMOVBU, AMOVHU, AMOVWU, AMOVF, AMOVD: - // Rewrite MOV pseudo-instructions. This cannot be done in - // progedit, as SP offsets need to be applied before we split - // up some of the Addrs. - rewriteMOV(ctxt, newprog, p) case obj.ACALL: switch p.To.Type { @@ -666,6 +657,16 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) { } } + // Rewrite MOV pseudo-instructions. This cannot be done in + // progedit, as SP offsets need to be applied before we split + // up some of the Addrs. + for p := cursym.Func.Text; p != nil; p = p.Link { + switch p.As { + case AMOV, AMOVB, AMOVH, AMOVW, AMOVBU, AMOVHU, AMOVWU, AMOVF, AMOVD: + rewriteMOV(ctxt, newprog, p) + } + } + // Split immediates larger than 12-bits. for p := cursym.Func.Text; p != nil; p = p.Link { switch p.As { |
