add cfuged
authorJacob Lifshay <programmerjake@gmail.com>
Sat, 22 Jul 2023 00:33:38 +0000 (17:33 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:19 +0000 (19:26 +0000)
openpower/isa/fixedlogical.mdwn
openpower/isatables/RM-1P-2S1D.csv
openpower/isatables/minor_31.csv
src/openpower/decoder/isa/caller.py
src/openpower/decoder/power_enums.py
src/openpower/test/logical/logical_cases.py

index 43aafe515edaf0aa249ff711da6013d47e987598..b2bba382f66b7a962a43d4a0ee0735078ead416c 100644 (file)
@@ -512,4 +512,26 @@ Special Registers Altered:
 
     None
 
-<!-- Checked March 2021 -->
+# Centrifuge Doubleword
+
+X-Form
+
+* cfuged RA,RS,RB
+
+Pseudo-code:
+
+    ptr0 <- 0
+    ptr1 <- 0
+    result[0:63] <- 0
+    do i = 0 to 63
+        if (RB)[i] = 0 then
+            result[ptr0] <- (RS)[i]
+            ptr0 <- ptr0 + 1
+        if (RB)[63-i] = 1 then
+            result[63-ptr1] <- (RS)[63-i]
+            ptr1 <- ptr1 + 1
+    RA <- result
+
+Special Registers Altered:
+
+    None
index c96a038aec2af37e165c76bf3814613b318a1ddd..75ee3ac13b56d07ac52968c5dd4377e24ccd5f34 100644 (file)
@@ -17,6 +17,7 @@ cmpeqb,CROP,,1P,EXTRA3,NO,d:BF,s:RA,s:RB,0,RA,RB,0,0,0,BF,0
 bmask,NORMAL,,1P,EXTRA3,NO,d:RT,s:RA,s:RB,0,RA,RB,0,RT,0,0,0
 cntlzdm,NORMAL,,1P,EXTRA3,NO,d:RT,s:RA,s:RB,0,RS,RB,0,RA,0,0,0
 addex,NORMAL,,1P,EXTRA3,NO,d:RT,s:RA,s:RB,0,RA,RB,0,RT,0,0,0
+cfuged,NORMAL,,1P,EXTRA3,NO,d:RT,s:RA,s:RB,0,RS,RB,0,RA,0,0,0
 bpermd,NORMAL,,1P,EXTRA3,NO,d:RA,s:RS,s:RB,0,RS,RB,0,RA,0,0,0
 modud,NORMAL,,1P,EXTRA3,NO,d:RT,s:RA,s:RB,0,RA,RB,0,RT,0,0,0
 moduw,NORMAL,,1P,EXTRA3,NO,d:RT,s:RA,s:RB,0,RA,RB,0,RT,0,0,0
index b10dbf76a7e4bb39bbab98f1d7c9a5e3cfa18805..b77193ab0d27eb0d73c9df66097c0108db0d6017 100644 (file)
@@ -20,6 +20,7 @@ opcode,unit,internal op,in1,in2,in3,out,CR in,CR out,inv A,inv out,cry in,cry ou
 0b0010111011,LOGICAL,OP_BYTEREV,RS,NONE,NONE,RA,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,brd,X,,0,
 0b0100111010,ALU,OP_CBCDTD,RS,NONE,NONE,RA,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,cbcdtd,X,,,
 0b0100011010,ALU,OP_CDTBCD,RS,NONE,NONE,RA,NONE,NONE,1,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,cdtbcd,X,,,
+0b0011011100,LOGICAL,OP_CFUGE,RS,RB,NONE,RA,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,cfuged,X,,0,
 0b0011111100,LOGICAL,OP_BPERM,RS,RB,NONE,RA,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,bpermd,X,,,
 0b0000000000,ALU,OP_CMP,RA,RB,NONE,NONE,NONE,BF,1,0,ONE,0,NONE,0,0,0,0,0,1,NONE,0,0,cmp,X,,,
 0b0111111100,LOGICAL,OP_CMPB,RS,RB,NONE,RA,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,cmpb,X,,,
index b79295ccc518a7861a5fc81bf0ab791664ad5c5a..4e12c4d4e05abe96f7a290acbb78a492cd9ff571 100644 (file)
@@ -1969,7 +1969,7 @@ class ISACaller(ISACallerHelper, ISAFPHelpers, StepLoop):
                        "ctfpr", "ctfprs",
                        "mtfpr", "mtfprs",
                        "maddsubrs", "maddrs", "msubrs",
-                       "cntlzdm", "cnttzdm",
+                       "cfuged", "cntlzdm", "cnttzdm",
                        ]:
             illegal = False
             ins_name = dotstrp
index 1b37bf3e12ed748b9d5aeb8d2ad725ae6e46cc9e..54959a29b981ef5a9c1aa4c043c32741c7a2face 100644 (file)
@@ -741,6 +741,7 @@ _insns = [
     "bpermd",
     "cbcdtd",
     "cdtbcd",
+    "cfuged",
     "cmp", "cmpb", "cmpeqb", "cmpi", "cmpl", "cmpli", "cmprb",
     "cntlzd", "cntlzdm", "cntlzw", "cnttzd", "cnttzdm", "cnttzw",
     "cprop", # AV bitmanip
@@ -957,6 +958,7 @@ class MicrOp(Enum):
     OP_MADDRS = 105
     OP_MSUBRS = 106
     OP_BYTEREV = 107
+    OP_CFUGE = 108
 
 
 class SelType(Enum):
index 6e5709d0aad6d3cfc31819bd31e65126715db144..809096e68d4c1ef05ff523fdad19ce5f3eea0b4e 100644 (file)
@@ -127,6 +127,30 @@ class LogicalTestCase(TestAccumulatorBase):
             initial_regs[2] = random.randint(0, (1 << 64)-1)
             self.add_case(Program(lst, bigendian), initial_regs)
 
+    def case_cfuged(self):
+        prog = Program(list(SVP64Asm(["cfuged 3,4,5"])), bigendian)
+        for case_idx in range(200):
+            gprs = [0] * 32
+            gprs[4] = hash_256(f"cfuged {case_idx} r4") % 2**64
+            gprs[5] = hash_256(f"cfuged {case_idx} r5") % 2**64
+            e = ExpectedState(pc=4, int_regs=gprs)
+            zeros = []
+            ones = []
+            for i in range(64):
+                bit = 1 << i
+                if gprs[5] & bit:
+                    ones.append(bool(gprs[4] & bit))
+                else:
+                    zeros.append(bool(gprs[4] & bit))
+            bits = ones + zeros
+            e.intregs[3] = 0
+            for i, v in enumerate(bits):
+                e.intregs[3] |= v << i
+            with self.subTest(
+                    case_idx=case_idx, RS_in=hex(gprs[4]),
+                    RB_in=hex(gprs[5]), expected_RA=hex(e.intregs[3])):
+                self.add_case(prog, gprs, expected=e)
+
     def case_cntlzdm(self):
         prog = Program(list(SVP64Asm(["cntlzdm 3,4,5"])), bigendian)
         for case_idx in range(200):