Skip to content

Conversation

s-barannikov
Copy link
Contributor

@s-barannikov s-barannikov commented Aug 15, 2025

The operand is not encoded, decoded or printed and would break MCInst verification if we had one.
Extracted from #156358, where the extra operand causes DecoderEmitter to emit an error about an operand with a missing encoding.

@llvmbot
Copy link
Member

llvmbot commented Aug 15, 2025

@llvm/pr-subscribers-backend-powerpc

Author: Sergei Barannikov (s-barannikov)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/153867.diff

1 Files Affected:

  • (modified) llvm/lib/Target/PowerPC/PPCInstr64Bit.td (+1-1)
diff --git a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
index fd2084398c857..d0d77c2e28320 100644
--- a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -2000,7 +2000,7 @@ def : Pat<(int_ppc_darnraw), (DARN 2)>;
 
 class X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
                    InstrItinClass itin, list<dag> pattern>
-  : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
+  : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB),
                  !strconcat(opc, " $RA, $RB"), itin, pattern>{
    let L = 1;
 }

@s-barannikov
Copy link
Contributor Author

ping?

@s-barannikov
Copy link
Contributor Author

ping

@@ -2000,7 +2000,7 @@ def : Pat<(int_ppc_darnraw), (DARN 2)>;

class X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
InstrItinClass itin, list<dag> pattern>
: X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
: X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB),
!strconcat(opc, " $RA, $RB"), itin, pattern>{
let L = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it was meant to be used to generate the instr copy RA,RB,1.

In the class we have:

let Inst{10}    = L;

Even thought we set this explicitly to 1 on line 2005, I am not sure how that works.

I would think the generated instr needs to be fixed up here instead?

                 !strconcat(opc, " $RA, $RB, $L"), itin, pattern>{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I could google, copy has only two operands. The L bit is bit 10, which has fixed value of 1 in the encoding.

Image

This is unlike paste instruction, which indeed has three operands:

Image

I guess you could call it a copy&paste bug 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to Power ISA™ Version 3.1 (2020). In version 3.0 B (2017) paste is two operand as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! I was looking at an older ISA.

Copy link
Contributor

@lei137 lei137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the fix. This LGTM

@@ -2000,7 +2000,7 @@ def : Pat<(int_ppc_darnraw), (DARN 2)>;

class X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
InstrItinClass itin, list<dag> pattern>
: X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
: X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB),
!strconcat(opc, " $RA, $RB"), itin, pattern>{
let L = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! I was looking at an older ISA.

@s-barannikov
Copy link
Contributor Author

Thank you for the review

@s-barannikov s-barannikov merged commit 9bb860e into llvm:main Sep 4, 2025
11 checks passed
@s-barannikov s-barannikov deleted the ppc-extra-copy-operand branch September 4, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants