Commit 48ed1e61 authored by Joel Sing's avatar Joel Sing

cmd/internal/obj/riscv: handle AGETCALLERPC

Updates #27532

Change-Id: Ib3e44ec524ed20bbfbbaf40df22cec335460f3ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/204629
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 24f08103
......@@ -594,6 +594,22 @@ 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.
if cursym.Leaf() {
// MOV LR, Rd
p.As = AMOV
p.From.Type = obj.TYPE_REG
p.From.Reg = REG_LR
} else {
// MOV (RSP), Rd
p.As = AMOV
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment