diff options
| author | Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com> | 2024-09-11 09:44:16 -0500 |
|---|---|---|
| committer | Paul Murphy <murp@ibm.com> | 2024-10-29 13:14:38 +0000 |
| commit | fdfb3067a8a27a7491c3b0f6eddedbd467495329 (patch) | |
| tree | d17dd79cb49f28e0300ef5fc5480fea66c178cb8 /src/cmd/internal | |
| parent | b03b1acfb0bb6c605a70987dfaf5bb922c792e82 (diff) | |
| download | go-fdfb3067a8a27a7491c3b0f6eddedbd467495329.tar.xz | |
cmd/internal/obj/ppc64: support for extended mnemonics of BC
BGT, BLT, BLE, BGE, BNE, BVS, BVC, and BEQ support by assembler. This will simplify the usage of BC constructs like
BC 12, 30, LR <=> BEQ CR7, LR
BC 12, 2, LR <=> BEQ CR0, LR
BC 12, 0, target <=> BLT CR0, target
BC 12, 2, target <=> BEQ CR0, target
BC 12, 5, target <=> BGT CR1, target
BC 12, 30, target <=> BEQ CR7, target
BC 4, 6, target <=> BNE CR1, target
BC 4, 5, target <=> BLE CR1, target
code cleanup based on the above additions.
Change-Id: I02fdb212b6fe3f85ce447e05f4d42118c9ce63b5
Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-ppc64_power8,gotip-linux-ppc64le_power8,gotip-linux-ppc64le_power9,gotip-linux-ppc64le_power10
Reviewed-on: https://go-review.googlesource.com/c/go/+/612395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/cmd/internal')
| -rw-r--r-- | src/cmd/internal/obj/ppc64/asm9.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 1a884dea7b..7399106c74 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -282,6 +282,7 @@ var optabBase = []Optab{ {as: ASYSCALL, a1: C_U15CON, type_: 77, size: 12}, {as: ABEQ, a6: C_BRA, type_: 16, size: 4}, {as: ABEQ, a1: C_CREG, a6: C_BRA, type_: 16, size: 4}, + {as: ABEQ, a1: C_CREG, a6: C_LR, type_: 17, size: 4}, {as: ABR, a6: C_BRA, type_: 11, size: 4}, // b label {as: ABR, a6: C_BRAPIC, type_: 11, size: 8}, // b label; nop {as: ABR, a6: C_LR, type_: 18, size: 4}, // blr @@ -2819,6 +2820,50 @@ func asmout(c *ctxt9, p *obj.Prog, o *Optab, out *[5]uint32) { } o1 = OP_BC(c.opirr(p.As), uint32(a), uint32(r), uint32(v), 0) + case 17: + var bo int32 + bi := int(p.Reg) + + if p.From.Reg == REG_CR { + c.ctxt.Diag("unrecognized register: expected CR0-CR7\n") + } + bi = int(p.From.Reg&0x7) * 4 + + bo = BO_BCR + + switch p.As { + case ABLT: + bi += BI_LT + case ABGT: + bi += BI_GT + case ABEQ: + bi += BI_EQ + case ABNE: + bo = BO_NOTBCR + bi += BI_EQ + case ABLE: + bo = BO_NOTBCR + bi += BI_GT + case ABGE: + bo = BO_NOTBCR + bi += BI_LT + case ABVS: + bi += BI_FU + case ABVC: + bo = BO_NOTBCR + bi += BI_FU + default: + c.ctxt.Diag("unexpected instruction: expecting BGT, BEQ, BNE, BLE, BGE, BVS, BVC \n%v", p) + + } + if oclass(&p.To) == C_LR { + o1 = OPVCC(19, 16, 0, 0) + } else { + c.ctxt.Diag("bad optab entry (17): %d\n%v", p.To.Class, p) + } + + o1 = OP_BCR(o1, uint32(bo), uint32(bi)) + case 18: /* br/bl (lr/ctr); bc/bcl bo,bi,(lr/ctr) */ var v int32 var bh uint32 = 0 |
