1 <!-- DRAFT Instructions for PowerISA Version 3.0 B Book 1 -->
2 <!-- https://libre-soc.org/openpower/sv/bitmanip/ -->
3 <!-- https://libre-soc.org/openpower/sv/av_opcodes/ -->
5 # DRAFT Minimum/Maximum (Rc=1)
9 * minmax. RT,RA,RB,MMM (Rc=1)
15 if MMM[0] then # word mode
16 # shift left by XLEN/2 to make the dword comparison
17 # do word comparison of the original inputs
18 a <- a[XLEN/2:XLEN-1] || [0] * XLEN/2
19 b <- b[XLEN/2:XLEN-1] || [0] * XLEN/2
20 if MMM[1] then # signed mode
21 # invert sign bits to make the unsigned comparison
22 # do signed comparison of the original inputs
25 # if Rc = 1 then store the result of comparing a and b to CR0
28 CR0 <- 0b100 || XER[SO]
30 CR0 <- 0b001 || XER[SO]
32 CR0 <- 0b010 || XER[SO]
33 if MMM[2] then # max mode
34 # swap a and b to make the less than comparison do
35 # greater than comparison of the original inputs
39 # store the entire selected source (even in word mode)
40 # if Rc = 1 then store the result of comparing a and b to CR0
41 if a <u b then RT <- (RA|0)
44 Special Registers Altered:
48 # DRAFT Minimum/Maximum
52 * minmax RT,RA,RB,MMM (Rc=0)
58 if MMM[0] then # word mode
59 # shift left by XLEN/2 to make the dword comparison
60 # do word comparison of the original inputs
61 a <- a[XLEN/2:XLEN-1] || [0] * XLEN/2
62 b <- b[XLEN/2:XLEN-1] || [0] * XLEN/2
63 if MMM[1] then # signed mode
64 # invert sign bits to make the unsigned comparison
65 # do signed comparison of the original inputs
68 # if Rc = 1 then store the result of comparing a and b to CR0
71 # CR0 <- 0b100 || XER[SO]
73 # CR0 <- 0b001 || XER[SO]
75 # CR0 <- 0b010 || XER[SO]
76 if MMM[2] then # max mode
77 # swap a and b to make the less than comparison do
78 # greater than comparison of the original inputs
82 # store the entire selected source (even in word mode)
83 if a <u b then RT <- (RA|0)
86 Special Registers Altered:
94 * avgadd RT,RA,RB (Rc=0)
95 * avgadd. RT,RA,RB (Rc=1)
106 Special Registers Altered:
110 # DRAFT Absolute Signed Difference
114 * absds RT,RA,RB (Rc=0)
115 * absds. RT,RA,RB (Rc=1)
119 if (RA) < (RB) then RT <- ¬(RA) + (RB) + 1
120 else RT <- ¬(RB) + (RA) + 1
122 Special Registers Altered:
126 # DRAFT Absolute Unsigned Difference
130 * absdu RT,RA,RB (Rc=0)
131 * absdu. RT,RA,RB (Rc=1)
135 if (RA) <u (RB) then RT <- ¬(RA) + (RB) + 1
136 else RT <- ¬(RB) + (RA) + 1
138 Special Registers Altered:
142 # DRAFT Absolute Accumulate Unsigned Difference
146 * absdacu RT,RA,RB (Rc=0)
147 * absdacu. RT,RA,RB (Rc=1)
151 if (RA) <u (RB) then r <- ¬(RA) + (RB) + 1
152 else r <- ¬(RB) + (RA) + 1
155 Special Registers Altered:
159 # DRAFT Absolute Accumulate Signed Difference
163 * absdacs RT,RA,RB (Rc=0)
164 * absdacs. RT,RA,RB (Rc=1)
168 if (RA) < (RB) then r <- ¬(RA) + (RB) + 1
169 else r <- ¬(RB) + (RA) + 1
172 Special Registers Altered:
180 * cprop RT,RA,RB (Rc=0)
181 * cprop. RT,RA,RB (Rc=1)
190 Special Registers Altered:
194 # DRAFT Bitmanip Masked
198 * bmask RT,RA,RB,bm,L
202 if _RB = 0 then mask <- [1] * XLEN
206 if bm[4] = 0 then a1 <- ¬ra
208 if mode2 = 0 then a2 <- (¬ra)+1
209 if mode2 = 1 then a2 <- ra-1
210 if mode2 = 2 then a2 <- ra+1
211 if mode2 = 3 then a2 <- ¬(ra+1)
216 if mode3 = 0 then result <- a1 | a2
217 if mode3 = 1 then result <- a1 & a2
218 if mode3 = 2 then result <- a1 ^ a2
219 if mode3 = 3 then result <- undefined([0]*XLEN)
220 result <- result & mask
221 # optionally restore masked-out bits
223 result <- result | (RA & ¬mask)
226 Special Registers Altered:
230 # Load Floating-Point Immediate
238 bf16 <- d0 || d1 || d2
239 fp32 <- bf16 || [0]*16
242 Special Registers Altered:
246 # Float Replace Lower-Half Single, Immediate
254 fp32 <- SINGLE((FRS))
255 fp32[16:31] <- d0 || d1 || d2
258 Special Registers Altered: