[PowerPC] Add pnop (prefixed no-op) instruction (ISA v3.1) - #188373
[PowerPC] Add pnop (prefixed no-op) instruction (ISA v3.1)#188373Scottcjn wants to merge 1 commit into
Conversation
|
Ping — this adds the pnop (prefixed no-op) instruction from ISA v3.1. Straightforward addition with test coverage. Would appreciate a PowerPC reviewer. cc @nemanjai @stefanp-ibm |
|
Friendly bump on this one. It adds the |
pnop is defined in Power ISA v3.1 section 3.3.1.2. The prefix word is 0x07000000 (primary opcode 1, prefix type 3, all other prefix bits zero) and the suffix word is 0x00000000. It has no codegen use, so no pattern is attached, but it is left out of isAsmParserOnly so that the disassembler can decode it as well. That is the case the original request asked for: checking an external PowerISA decoder against llvm-mc needs round-trip coverage, not just assembly. Adds an MC assembly test and an MC disassembly test.
6a88fa4 to
7723b7a
Compare
|
Found and fixed a real encoding bug in this patch, and rebased onto current main (8225c81). The prefix primary opcode was wrong.
Last, the disassembly test had a little-endian RUN line over the same byte string. The PowerPC disassembler tests feed big-endian instruction bytes from a single run line, so that line is removed. What I verified, on an x86_64 host with a PowerPC-only Release build (no assertions) at 8225c81: The commit is also re-authored from the noreply address, which may be why premerge has never run on this branch. @lei137 you have been reviewing my other PowerPC patches, would you be willing to take a look at this one, or point me at the right person? |
|
@llvm/pr-subscribers-backend-powerpc Author: AutoJanitor (Scottcjn) ChangesSummaryAdd the
Fixes #176831. Encoding
Like all prefixed instructions, Implementation
ContextAs noted in #176831 by @nemanjai, Note: I also have a separate PR (#187322) adding the Full diff: https://github.com/llvm/llvm-project/pull/188373.diff 3 Files Affected:
diff --git a/llvm/lib/Target/PowerPC/PPCInstrP10.td b/llvm/lib/Target/PowerPC/PPCInstrP10.td
index 6799a9838ec63..c8c85eb84ad54 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrP10.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrP10.td
@@ -2988,3 +2988,19 @@ let Predicates = [IsISA3_1, PrefixInstrs], isAsmParserOnly = 1, hasNoSchedulingI
(ins s34imm64_pcrel:$SI),
"pla $RT, $SI", IIC_IntSimple, []>, isPCRel;
}
+
+// pnop - Prefixed No-Op (Power ISA v3.1, Section 3.3.1.2)
+// Prefix word 0x07000000: primary opcode 1, prefix type 3, remaining bits 0.
+// Suffix word 0x00000000. Like all prefixed instructions it must not cross a
+// 64-byte boundary.
+let Predicates = [PrefixInstrs],
+ hasNoSchedulingInfo = 1, hasSideEffects = 0,
+ mayLoad = 0, mayStore = 0 in {
+ def PNOP : PI<1, 0, (outs), (ins), "pnop", IIC_IntSimple> {
+ // Prefix: type 3, remaining prefix bits all zero.
+ let Inst{6...7} = 3;
+ let Inst{8...31} = 0;
+ // Suffix: bits 38-63 all zero (bits 32-37 already = 0 from opcode)
+ let Inst{38...63} = 0;
+ }
+}
diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc-pnop.txt b/llvm/test/MC/Disassembler/PowerPC/ppc-pnop.txt
new file mode 100644
index 0000000000000..eaaef6f0c7e89
--- /dev/null
+++ b/llvm/test/MC/Disassembler/PowerPC/ppc-pnop.txt
@@ -0,0 +1,6 @@
+# RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-linux-gnu \
+# RUN: -mcpu=pwr10 | FileCheck %s
+
+# Prefixed no-op (Power ISA v3.1). Instruction bytes are big-endian.
+# CHECK: pnop
+0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
diff --git a/llvm/test/MC/PowerPC/ppc-pnop.s b/llvm/test/MC/PowerPC/ppc-pnop.s
new file mode 100644
index 0000000000000..39452bd0e9af4
--- /dev/null
+++ b/llvm/test/MC/PowerPC/ppc-pnop.s
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple powerpc64-unknown-linux-gnu -show-encoding %s | \
+# RUN: FileCheck %s --check-prefix=CHECK-BE
+# RUN: llvm-mc -triple powerpc64le-unknown-linux-gnu -show-encoding %s | \
+# RUN: FileCheck %s --check-prefix=CHECK-LE
+
+# Prefixed no-op (Power ISA v3.1, Section 3.3.1.2)
+# Encoding: prefix 0x0700_0000 + suffix 0x0000_0000
+pnop
+# CHECK-BE: pnop # encoding: [0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
+# CHECK-LE: pnop # encoding: [0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00]
|
Summary
Add the
pnopinstruction that was missed when prefixed instructions were initially added to the PowerPC backend.pnopis defined in Power ISA v3.1, Section 3.3.1.2.Fixes #176831.
Encoding
Like all prefixed instructions,
pnopmust not cross a 64-byte boundary.Implementation
PNOPinPPCInstrP10.tdbuilt on thePIbase class, matching how the other prefixed instructions are defined (PI<1, opcode, ...>with the type in bits 6-7)PrefixInstrspredicatellvm-mc --disassemblecan decode itllvm/test/MC/PowerPC/ppc-pnop.sllvm/test/MC/Disassembler/PowerPC/ppc-pnop.txtContext
As noted in #176831 by @nemanjai,
pnopwas intentionally skipped initially since it has no codegen use. @programmerjake is writing a PowerISA decoder and testing againstllvm-mc, which needs the disassembler side as well as the assembler side, so both are covered here.Note: I also have a separate PR (#187322) adding the
bctarinstruction mentioned in the same discussion thread.