From 9b78ccadc62d94a0bc1acdddfe54d6f1f0665f7b Mon Sep 17 00:00:00 2001 From: Lei Huang Date: Mon, 28 Jul 2025 16:00:20 +0000 Subject: [PATCH 1/2] add unpack high/low nibble --- llvm/lib/Target/PowerPC/PPCInstrFuture.td | 18 ++++++++++++++++++ .../PowerPC/ppc-encoding-ISAFuture.txt | 6 ++++++ .../PowerPC/ppc64le-encoding-ISAFuture.txt | 7 +++++++ llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/llvm/lib/Target/PowerPC/PPCInstrFuture.td b/llvm/lib/Target/PowerPC/PPCInstrFuture.td index 80fac18d5737f..be62552039920 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrFuture.td +++ b/llvm/lib/Target/PowerPC/PPCInstrFuture.td @@ -45,6 +45,19 @@ multiclass XOForm_RTAB5_L1r opcode, bits<9> xo, dag OOL, dag IOL, } } +class VXForm_VRTB5 xo, bits<5> R, dag OOL, dag IOL, string asmstr, + list pattern> : I<4, OOL, IOL, asmstr, NoItinerary> { + bits<5> VRT; + bits<5> VRB; + + let Pattern = pattern; + + let Inst{6 -10} = VRT; + let Inst{11 -15} = R; + let Inst{16 -20} = VRB; + let Inst{21 -31} = xo; +} + let Predicates = [IsISAFuture] in { defm SUBFUS : XOForm_RTAB5_L1r<31, 72, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, u1imm:$L), @@ -81,4 +94,9 @@ let Predicates = [HasVSX, IsISAFuture] in { (ins vsrprc:$XTp, memr:$RA, g8rc:$RB), "stxvprll $XTp, $RA, $RB", IIC_LdStLFD, []>; } + + def VUPKHSNTOB : VXForm_VRTB5<387, 0, (outs vrrc:$VRT), (ins vrrc:$VRB), + "vupkhsntob $VRT, $VRB", []>; + def VUPKLSNTOB : VXForm_VRTB5<387, 1, (outs vrrc:$VRT), (ins vrrc:$VRB), + "vupklsntob $VRT, $VRB", []>; } diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt b/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt index 4bea42243f83b..ec2e109bd8937 100644 --- a/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt +++ b/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt @@ -195,3 +195,9 @@ #CHECK: dmxxsha224256pad 0, 1 0xf0,0x18,0x0e,0x94 + +#CHECK: vupkhsntob 2, 4 +0x10,0x40,0x21,0x83 + +#CHECK: vupklsntob 2, 4 +0x10,0x41,0x21,0x83 diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt b/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt index 233693e67292e..df670b4a15426 100644 --- a/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt +++ b/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt @@ -189,3 +189,10 @@ #CHECK: dmxxsha224256pad 0, 1 0x94,0x0e,0x18,0xf0 + +#CHECK: vupkhsntob 2, 4 +0x83,0x21,0x40,0x10 + +#CHECK: vupklsntob 2, 4 +0x83,0x21,0x41,0x10 +0x10,0x41,0x21,0x83 diff --git a/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s b/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s index cba93291e4595..02fa684b950de 100644 --- a/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s +++ b/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s @@ -282,3 +282,11 @@ dmxxsha224256pad 0, 1 #CHECK-BE: dmxxsha224256pad 0, 1 # encoding: [0xf0,0x18,0x0e,0x94] #CHECK-LE: dmxxsha224256pad 0, 1 # encoding: [0x94,0x0e,0x18,0xf0] + + vupkhsntob 2, 4 +#CHECK-BE: vupkhsntob 2, 4 # encoding: [0x10,0x40,0x21,0x83] +#CHECK-LE: vupkhsntob 2, 4 # encoding: [0x83,0x21,0x40,0x10] + + vupklsntob 2, 4 +#CHECK-BE: vupklsntob 2, 4 # encoding: [0x10,0x41,0x21,0x83] +#CHECK-LE: vupklsntob 2, 4 # encoding: [0x83,0x21,0x41,0x10] From ce4c27c8cfba0761e54cf97c2adb5dbd028e1381 Mon Sep 17 00:00:00 2001 From: Lei Huang Date: Mon, 28 Jul 2025 17:11:25 +0000 Subject: [PATCH 2/2] add remaining unpacked instruction implementation --- llvm/lib/Target/PowerPC/PPCInstrFuture.td | 60 +++++++++++++++++++ .../PowerPC/ppc-encoding-ISAFuture.txt | 12 ++++ .../PowerPC/ppc64le-encoding-ISAFuture.txt | 13 +++- llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s | 16 +++++ 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/PowerPC/PPCInstrFuture.td b/llvm/lib/Target/PowerPC/PPCInstrFuture.td index be62552039920..8b1bdad0852e5 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrFuture.td +++ b/llvm/lib/Target/PowerPC/PPCInstrFuture.td @@ -58,6 +58,54 @@ class VXForm_VRTB5 xo, bits<5> R, dag OOL, dag IOL, string asmstr, let Inst{21 -31} = xo; } +class VXForm_VRTB5_UIM2 xo, bits<3> R, dag OOL, dag IOL, string asmstr, + list pattern> + : I<4, OOL, IOL, asmstr, NoItinerary> { + bits<5> VRT; + bits<5> VRB; + bits<2> UIM; + + let Pattern = pattern; + + let Inst{6 -10} = VRT; + let Inst{11 -13} = R; + let Inst{14 -15} = UIM; + let Inst{16 -20} = VRB; + let Inst{21 -31} = xo; +} + +class VXForm_VRTB5_UIM1 xo, bits<4> R, dag OOL, dag IOL, string asmstr, + list pattern> + : I<4, OOL, IOL, asmstr, NoItinerary> { + bits<5> VRT; + bits<5> VRB; + bits<1> UIM; + + let Pattern = pattern; + + let Inst{6 -10} = VRT; + let Inst{11 -14} = R; + let Inst{15} = UIM; + let Inst{16 -20} = VRB; + let Inst{21 -31} = xo; +} + +class VXForm_VRTB5_UIM3 xo, bits<2> R, dag OOL, dag IOL, string asmstr, + list pattern> + : I<4, OOL, IOL, asmstr, NoItinerary> { + bits<5> VRT; + bits<5> VRB; + bits<3> UIM; + + let Pattern = pattern; + + let Inst{6 -10} = VRT; + let Inst{11 -12} = R; + let Inst{13 -15} = UIM; + let Inst{16 -20} = VRB; + let Inst{21 -31} = xo; +} + let Predicates = [IsISAFuture] in { defm SUBFUS : XOForm_RTAB5_L1r<31, 72, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, u1imm:$L), @@ -99,4 +147,16 @@ let Predicates = [HasVSX, IsISAFuture] in { "vupkhsntob $VRT, $VRB", []>; def VUPKLSNTOB : VXForm_VRTB5<387, 1, (outs vrrc:$VRT), (ins vrrc:$VRB), "vupklsntob $VRT, $VRB", []>; + def VUPKINT4TOBF16 + : VXForm_VRTB5_UIM2<387, 2, (outs vrrc:$VRT), (ins vrrc:$VRB, u2imm:$UIM), + "vupkint4tobf16 $VRT, $VRB, $UIM", []>; + def VUPKINT8TOBF16 + : VXForm_VRTB5_UIM1<387, 1, (outs vrrc:$VRT), (ins vrrc:$VRB, u1imm:$UIM), + "vupkint8tobf16 $VRT, $VRB, $UIM", []>; + def VUPKINT8TOFP32 + : VXForm_VRTB5_UIM2<387, 3, (outs vrrc:$VRT), (ins vrrc:$VRB, u2imm:$UIM), + "vupkint8tofp32 $VRT, $VRB, $UIM", []>; + def VUPKINT4TOFP32 + : VXForm_VRTB5_UIM3<387, 2, (outs vrrc:$VRT), (ins vrrc:$VRB, u3imm:$UIM), + "vupkint4tofp32 $VRT, $VRB, $UIM", []>; } diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt b/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt index ec2e109bd8937..6adaa5cfdaefc 100644 --- a/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt +++ b/llvm/test/MC/Disassembler/PowerPC/ppc-encoding-ISAFuture.txt @@ -201,3 +201,15 @@ #CHECK: vupklsntob 2, 4 0x10,0x41,0x21,0x83 + +#CHECK: vupkint4tobf16 2, 4, 3 +0x10,0x4b,0x21,0x83 + +#CHECK: vupkint8tobf16 1, 3, 1 +0x10,0x23,0x19,0x83 + +#CHECK: vupkint4tofp32 3, 5, 2 +0x10,0x72,0x29,0x83 + +#CHECK: vupkint8tofp32 3, 5, 2 +0x10,0x6e,0x29,0x83 diff --git a/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt b/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt index df670b4a15426..84f9bc8e67b60 100644 --- a/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt +++ b/llvm/test/MC/Disassembler/PowerPC/ppc64le-encoding-ISAFuture.txt @@ -195,4 +195,15 @@ #CHECK: vupklsntob 2, 4 0x83,0x21,0x41,0x10 -0x10,0x41,0x21,0x83 + +#CHECK: vupkint4tobf16 2, 4, 3 +0x83,0x21,0x4b,0x10 + +#CHECK: vupkint8tobf16 1, 3, 1 +0x83,0x19,0x23,0x10 + +#CHECK: vupkint4tofp32 3, 5, 2 +0x83,0x29,0x72,0x10 + +#CHECK: vupkint8tofp32 3, 5, 2 +0x83,0x29,0x6e,0x10 diff --git a/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s b/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s index 02fa684b950de..8316bbd9854ea 100644 --- a/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s +++ b/llvm/test/MC/PowerPC/ppc-encoding-ISAFuture.s @@ -290,3 +290,19 @@ vupklsntob 2, 4 #CHECK-BE: vupklsntob 2, 4 # encoding: [0x10,0x41,0x21,0x83] #CHECK-LE: vupklsntob 2, 4 # encoding: [0x83,0x21,0x41,0x10] + + vupkint4tobf16 2, 4, 3 +#CHECK-BE: vupkint4tobf16 2, 4, 3 # encoding: [0x10,0x4b,0x21,0x83] +#CHECK-LE: vupkint4tobf16 2, 4, 3 # encoding: [0x83,0x21,0x4b,0x10] + + vupkint8tobf16 1, 3, 1 +#CHECK-BE: vupkint8tobf16 1, 3, 1 # encoding: [0x10,0x23,0x19,0x83] +#CHECK-LE: vupkint8tobf16 1, 3, 1 # encoding: [0x83,0x19,0x23,0x10] + + vupkint4tofp32 3, 5, 2 +#CHECK-BE: vupkint4tofp32 3, 5, 2 # encoding: [0x10,0x72,0x29,0x83] +#CHECK-LE: vupkint4tofp32 3, 5, 2 # encoding: [0x83,0x29,0x72,0x10] + + vupkint8tofp32 3, 5, 2 +#CHECK-BE: vupkint8tofp32 3, 5, 2 # encoding: [0x10,0x6e,0x29,0x83] +#CHECK-LE: vupkint8tofp32 3, 5, 2 # encoding: [0x83,0x29,0x6e,0x10]