mirror of
https://github.com/golang/go
synced 2024-11-18 20:44:45 -07:00
cmd/internal/obj/riscv: simplify instructionsForMOV
Rather than handling shift based scaling in two locations, rework logic so there is a single exit path. Change-Id: I832b4932d53183736050059a11019ced08281b3b Reviewed-on: https://go-review.googlesource.com/c/go/+/523455 Reviewed-by: M Zhuo <mzh@golangcn.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
834a6f9a33
commit
13d5ca42fd
@ -1992,20 +1992,15 @@ func instructionsForMOV(p *obj.Prog) []*instruction {
|
|||||||
ins.as, ins.rs1, ins.rs2, ins.imm = AADDI, REG_ZERO, obj.REG_NONE, low
|
ins.as, ins.rs1, ins.rs2, ins.imm = AADDI, REG_ZERO, obj.REG_NONE, low
|
||||||
|
|
||||||
// LUI is only necessary if the constant does not fit in 12 bits.
|
// LUI is only necessary if the constant does not fit in 12 bits.
|
||||||
if high == 0 {
|
if high != 0 {
|
||||||
if insSLLI != nil {
|
// LUI top20bits(c), R
|
||||||
inss = append(inss, insSLLI)
|
// ADD bottom12bits(c), R, R
|
||||||
|
insLUI := &instruction{as: ALUI, rd: ins.rd, imm: high}
|
||||||
|
inss = []*instruction{insLUI}
|
||||||
|
if low != 0 {
|
||||||
|
ins.as, ins.rs1 = AADDIW, ins.rd
|
||||||
|
inss = append(inss, ins)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// LUI top20bits(c), R
|
|
||||||
// ADD bottom12bits(c), R, R
|
|
||||||
insLUI := &instruction{as: ALUI, rd: ins.rd, imm: high}
|
|
||||||
inss = []*instruction{insLUI}
|
|
||||||
if low != 0 {
|
|
||||||
ins.as, ins.rs1 = AADDIW, ins.rd
|
|
||||||
inss = append(inss, ins)
|
|
||||||
}
|
}
|
||||||
if insSLLI != nil {
|
if insSLLI != nil {
|
||||||
inss = append(inss, insSLLI)
|
inss = append(inss, insSLLI)
|
||||||
|
Loading…
Reference in New Issue
Block a user