From 2fc8ce765c94ec3939b6168583314a12e5e3cca5 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 28 Mar 2020 19:37:00 +0000 Subject: [PATCH] add compare fixed ops --- openpower/isa/comparefixed.mdwn | 90 +++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 openpower/isa/comparefixed.mdwn diff --git a/openpower/isa/comparefixed.mdwn b/openpower/isa/comparefixed.mdwn new file mode 100644 index 000000000..600932cc0 --- /dev/null +++ b/openpower/isa/comparefixed.mdwn @@ -0,0 +1,90 @@ +# Compare Immediate + +cmpi BF,L,RA,SI + + if L = 0 then a <- EXTS((RA)[32:63]) + else a <- (RA) + if a < EXTS(SI) then c <- 0b100 + else if a > EXTS(SI) then c <- 0b010 + else c <- 0b001 + CR[4*BF+32:4*BF+35] <- c || XER[SO] + +# Compare + +cmp BF,L,RA,RB + + if L = 0 then a <- EXTS((RA)[32:63] ) + b <- EXTS((RB)[32:63]) + else a <- (RA) + b <- (RB) + if a < b then c <- 0b100 + else if a > b then c <- 0b010 + else c <- 0b001 + CR[4*BF+32:4*BF+35] <- c || XER[SO] + +# Compare Logical Immediate + +cmpli BF,L,RA,UI + + if L = 0 then a <- [0]*32 || (RA)[32:63] + else a <- (RA) + if a u ( [0]*48 || UI) then c <- 0b010 + else c <- 0b001 + CR[4*BF+32:4*BF+35] <- c || XER[SO] + +# Compare Logical + +cmpl BF,L,RA,RB + + if L = 0 then a <- [0]*32 || (RA)[32:63] + b <- [0]*32 || (RB)[32:63] + else a <- (RA) + b <- (RB) + if a u b then c <- 0b010 + else c <- 0b001 + CR[4*BF+32:4*BF+35] <- c || XER[SO] + +# Compare Ranged Byte X-form + +cmprb BF,L,RA,RB + + src1 <- EXTZ((RA)[56:63]) + + src21hi <- EXTZ((RB)[32:39]) + src21lo <- EXTZ((RB)[40:47]) + src22hi <- EXTZ((RB)[48:55]) + src22lo <- EXTZ((RB)[56:63]) + + if L=0 then + in_range <- (src22lo <= src1) & (src1 <= src22hi) + else + in_range <- ((src21lo <= src1) & (src1 <= src21hi)) | + in_range <- ((src22lo <= src1) & (src1 <= src22hi)) + + CR[4×BF+32] <- 0b0 + CR[4×BF+33] <- in_range + CR[4×BF+34] <- 0b0 + CR[4×BF+35] <- 0b0 + +# Compare Equal Byte X-form + +cmpeqb BF,RA,RB + + src1 <- GPR[RA].bit[56:63] + + match <- (src1 = (RB)[00:07]) | + match <- (src1 = (RB)[08:15]) | + match <- (src1 = (RB)[16:23]) | + match <- (src1 = (RB)[24:31]) | + match <- (src1 = (RB)[32:39]) | + match <- (src1 = (RB)[40:47]) | + match <- (src1 = (RB)[48:55]) | + match <- (src1 = (RB)[56:63]) + + CR[4×BF+32] <- 0b0 + CR[4×BF+33] <- match + CR[4×BF+34] <- 0b0 + CR[4×BF+35] <- 0b0 + -- 2.30.2