diff mbox series

[risu,v2,4/6] loongarch: Add clean_lsx_result()

Message ID 20231213081839.4176614-5-gaosong@loongson.cn (mailing list archive)
State New, archived
Headers show
Series Add LoongArch LSX/LASX instructions | expand

Commit Message

gaosong Dec. 13, 2023, 8:18 a.m. UTC
The result of the LSX instruction is in the low 128 bits
of the vreg register. We use clean_lsx_result() to clean up
the high 128 bits of the vreg register.

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 risugen_loongarch64.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/risugen_loongarch64.pm b/risugen_loongarch64.pm
index f8b1612..98fbd48 100644
--- a/risugen_loongarch64.pm
+++ b/risugen_loongarch64.pm
@@ -81,6 +81,18 @@  sub nanbox_s($)
     return $fpreg;
 }
 
+sub clean_lsx_result($)
+{
+    my ($vreg) = @_;
+
+    # xvinsgr2vr.d vd, r0, 2;
+    insn32(0x76ebe000 | 2 << 10 | $vreg);
+    # xvinsgr2vr.d vd, r0, 3;
+    insn32(0x76ebe000 | 3 << 10 | $vreg);
+
+    return $vreg;
+}
+
 sub align($)
 {
     my ($a) = @_;