[llvm] [PowerPC] Add bctar instruction (ISA 2.07) (PR #187322)
Sophia Elya via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 18:06:12 PDT 2026
sophiaeagent-beep wrote:
Thanks for the review @lei137 — pushed both fixes:
**1. 64-bit variants (BCCTAR8 / BCCTARL8)** — 3dd27bd
Added two new blocks in `PPCInstr64Bit.td` mirroring the existing BCCTR/BCCTR8 and BCCTRL/BCCCTRL8 split:
- **BCCTAR8** (non-linking): inside `isTerminator=1, isBarrier=1` scope, `Predicates=[IsISA2_07]`, `isBranch=1, isIndirectBranch=1`, `Requires<[IsPPC64]>`. No `Defs`, same as BCCCTR8's shape.
- **BCCTARL8** (linking): inside `isCall=1, PPC970_Unit=7, Defs=[LR8]` outer scope, `Predicates=[IsISA2_07]`, `Uses=[RM]`, `Requires<[IsPPC64]>`. Matches BCCCTRL8 exactly.
The existing 32-bit BCCTAR/BCCTARL in `PPCInstrInfo.td` (with `Defs=[LR]`) is unchanged — it follows the same non-gated codegen-only pattern as BCCCTR/BCCCTRL, which works because lowering emits the matching instance for the current subtarget.
**2. Disassembly tests** — 157ed0d
Added `llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-bctar.txt` covering both `powerpc64-unknown-unknown` and `powerpc64le-unknown-unknown` with `-mcpu=pwr8`:
- Generic `bctar`/`bctarl` (2-operand and 3-operand forms)
- Simple mnemonics (`bttar`/`bftar`) decoding back as generic bctar with BO value
- Prediction hints (+/-)
- Extended mnemonics that round-trip: `blttar`/`blttarl`, `bgttar`, `beqtar`
- `bdnztar`/`bdztar` forms decoding as generic `bctar 16/18/24/25/26/27, 0, 0`
All bytes are the BE encodings already verified in the paired `.s` test, so BE decodes them directly and LE decodes the byte-reversed forms to the same mnemonics.
**Caveat worth naming**: these commits were prepared without a local LLVM rebuild (the patch was derived from comparing against BCCCTRL8 shape and the existing `.s` test's verified byte table). If either test fails in CI I'll iterate on the MC printer's actual output format for the extended mnemonics — my assumption is the disassembler prints `blttar N` for the BO=12 cases and generic `bctar BO, 0, 0` for the bdnz/bdz BO values, matching the `.s` file's CHECK lines.
Let me know if you want me to also add an LLVM 32-bit disassembly test, or restructure the 64-bit blocks any differently.
https://github.com/llvm/llvm-project/pull/187322
More information about the llvm-commits
mailing list