From a37441344e33818411c6d261efb868182beead56 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 30 Jun 2020 12:19:16 +0100 Subject: [PATCH] add "Pseudo-code" keyword due to ikiwiki bug --- openpower/isa/bcd.mdwn | 8 +++ openpower/isa/branch.mdwn | 16 ++++- openpower/isa/comparefixed.mdwn | 17 +++++ openpower/isa/condition.mdwn | 28 +++++++- openpower/isa/fixedarith.mdwn | 122 ++++++++++++++++++++++++++++++++ openpower/isa/fixedload.mdwn | 83 ++++++++++++++++++++++ openpower/isa/fixedlogical.mdwn | 83 ++++++++++++++++++++++ openpower/isa/fixedshift.mdwn | 53 ++++++++++++++ openpower/isa/fixedstore.mdwn | 62 ++++++++++++++++ openpower/isa/fixedtrap.mdwn | 20 +++++- openpower/isa/sprset.mdwn | 29 ++++++++ openpower/isa/stringldst.mdwn | 11 +++ openpower/isa/system.mdwn | 24 +++++-- 13 files changed, 546 insertions(+), 10 deletions(-) diff --git a/openpower/isa/bcd.mdwn b/openpower/isa/bcd.mdwn index d29ff5f55..6704422a3 100644 --- a/openpower/isa/bcd.mdwn +++ b/openpower/isa/bcd.mdwn @@ -4,6 +4,8 @@ X-Form * cdtbcd RA, RS +Pseudo-code: + do i = 0 to 1 n <- i * 32 RA[n+0:n+7] <- 0 @@ -15,11 +17,14 @@ Special Registers Altered: None # Add and Generate Sixes +# Add and Generate Sixes XO-Form * addg6s RT,RA,RB +Pseudo-code: + do i = 0 to 15 dci <- carry_out(RA[4*i:63] + RB[4*i:63]) c <- ([dc[0]]*4 || [dc[1]]*4 || [dc[2]]*4 || [dc[3]]*4 || @@ -33,11 +38,14 @@ Special Registers Altered: None # Convert Binary Coded Decimal To Declets +# Convert Binary Coded Decimal To Declets X-Form * cbcdtd RA, RS +Pseudo-code: + do i = 0 to 1 n <- i * 32 RA[n+0:n+11] <- 0 diff --git a/openpower/isa/branch.mdwn b/openpower/isa/branch.mdwn index 095b2dc20..f9477e738 100644 --- a/openpower/isa/branch.mdwn +++ b/openpower/isa/branch.mdwn @@ -1,4 +1,4 @@ -# Branch +# Branch I-Form @@ -7,6 +7,8 @@ I-Form * bl target_addr (AA=0 LK=1) * bla target_addr (AA=1 LK=1) +Pseudo-code: + if AA then NIA <-iea EXTS(LI || 0b00) else NIA <-iea CIA + EXTS(LI || 0b00) if LK then LR <-iea CIA + 4 @@ -16,6 +18,7 @@ Special Registers Altered: LR (if LK=1) # Branch Conditional +# Branch Conditional B-Form @@ -24,6 +27,8 @@ B-Form * bcl BO,BI,target_addr (AA=0 LK=1) * bcla BO,BI,target_addr (AA=1 LK=1) +Pseudo-code: + if (mode_is_64bit) then M <- 0 else M <- 32 if ¬BO[2] then CTR <- CTR - 1 @@ -40,12 +45,15 @@ Special Registers Altered: LR (if LK=1) # Branch Conditional to Link Register +# Branch Conditional to Link Register XL-Form * bclr BO,BI,BH (LK=0) * bclrl BO,BI,BH (LK=1) +Pseudo-code: + if (mode_is_64bit) then M <- 0 else M <- 32 if ¬BO[2] then CTR <- CTR - 1 @@ -60,12 +68,15 @@ Special Registers Altered: LR (if LK=1) # Branch Conditional to Count Register +# Branch Conditional to Count Register XL-Form * bcctr BO,BI,BH (LK=0) * bcctrl BO,BI,BH (LK=1) +Pseudo-code: + cond_ok <- BO[0] | ¬(CR[BI+32] ^ BO[1]) if cond_ok then NIA <-iea CTR[0:61] || 0b00 if LK then LR <-iea CIA + 4 @@ -75,12 +86,15 @@ Special Registers Altered: LR (if LK=1) # Branch Conditional to Branch Target Address Register +# Branch Conditional to Branch Target Address Register XL-Form * bctar BO,BI,BH (LK=0) * bctarl BO,BI,BH (LK=1) +Pseudo-code: + if (mode_is_64bit) then M <- 0 else M <- 32 if ¬BO[2] then CTR <- CTR - 1 diff --git a/openpower/isa/comparefixed.mdwn b/openpower/isa/comparefixed.mdwn index 163b32096..48e45ec35 100644 --- a/openpower/isa/comparefixed.mdwn +++ b/openpower/isa/comparefixed.mdwn @@ -4,6 +4,8 @@ D-Form * cmpi BF,L,RA,SI +Pseudo-code: + if L = 0 then a <- EXTS((RA)[32:63]) else a <- (RA) if a < EXTS(SI) then c <- 0b100 @@ -16,11 +18,14 @@ Special Registers Altered: CR field BF # Compare +# Compare X-Form * cmp BF,L,RA,RB +Pseudo-code: + if L = 0 then a <- EXTS((RA)[32:63] ) b <- EXTS((RB)[32:63]) @@ -37,11 +42,14 @@ Special Registers Altered: CR field BF # Compare Logical Immediate +# Compare Logical Immediate D-Form * cmpli BF,L,RA,UI +Pseudo-code: + if L = 0 then a <- [0]*32 || (RA)[32:63] else a <- (RA) if a EXTS(SI)) & TO[1] then TRAP @@ -15,12 +17,15 @@ Special Registers Altered: None -# Trap Word +# Trap Word +# Trap Word X-Form * tw TO,RA,RB +Pseudo-code: + a <- EXTS((RA)[32:63]) b <- EXTS((RB)[32:63]) if (a < b) & TO[0] then TRAP @@ -33,12 +38,15 @@ Special Registers Altered: None -# Trap Doubleword Immediate +# Trap Doubleword Immediate +# Trap Doubleword Immediate D-Form * tdi TO,RA,SI +Pseudo-code: + a <- (RA) b <- EXTS(SI) if (a < b) & TO[0] then TRAP @@ -51,12 +59,15 @@ Special Registers Altered: None -# Trap Doubleword +# Trap Doubleword +# Trap Doubleword X-Form * td TO,RA,RB +Pseudo-code: + a <- (RA) b <- (RB) if (a < b) & TO[0] then TRAP @@ -70,11 +81,14 @@ Special Registers Altered: None # Integer Select +# Integer Select A-Form * isel RT,RA,RB,BC +Pseudo-code: + if RA=0 then a <-0 else a <- (RA) if CR[BC+32]=1 then RT <- a diff --git a/openpower/isa/sprset.mdwn b/openpower/isa/sprset.mdwn index d87f32d77..ba1445bc2 100644 --- a/openpower/isa/sprset.mdwn +++ b/openpower/isa/sprset.mdwn @@ -4,6 +4,8 @@ XFX-Form * mtspr SPR,RS +Pseudo-code: + n <- spr[5:9] || spr[0:4] switch (n) case(13): see(Book_III_p974) @@ -19,11 +21,14 @@ Special Registers Altered: See spec 3.3.17 # Move From Special Purpose Register +# Move From Special Purpose Register XFX-Form * mfspr RT,SPR +Pseudo-code: + n <- spr[5:9] || spr[0:4] switch (n) case(129): see(Book_III_p975) @@ -39,11 +44,14 @@ Special Registers Altered: None # Move to CR from XER Extended +# Move to CR from XER Extended X-Form * mcrxrx BF +Pseudo-code: + CR[4*BF+32:4*BF+35] <- XER[OV] || XER[OV32] || XER[CA] || XER[CA32] Special Registers Altered: @@ -51,11 +59,14 @@ Special Registers Altered: CR field BF # Move To One Condition Register Field +# Move To One Condition Register Field XFX-Form * mtocrf FXM,RS +Pseudo-code: + count <- 0 do i = 0 to 7 if FXM[i] = 1 then @@ -70,11 +81,14 @@ Special Registers Altered: CR field selected by FXM # Move To Condition Register Fields +# Move To Condition Register Fields XFX-Form * mtcrf FXM,RS +Pseudo-code: + mask <- ([FXM[0]]*4 || [FXM[1]]*4 || [FXM[2]]*4 || [FXM[3]]*4 || [FXM[4]]*4 || [FXM[5]]*4 || [FXM[6]]*4 || [FXM[7]]*4) CR <- ((RS)[32:63] & mask) | (CR & ¬mask) @@ -84,11 +98,14 @@ Special Registers Altered: CR fields selected by mask # Move From One Condition Register Field +# Move From One Condition Register Field XFX-Form * mfocrf RT,FXM +Pseudo-code: + RT <- undefined count <- 0 do i = 0 to 7 @@ -104,11 +121,14 @@ Special Registers Altered: None # Move From Condition Register +# Move From Condition Register XFX-Form * mfcr RT +Pseudo-code: + RT <- [0]*32 || CR Special Registers Altered: @@ -116,11 +136,14 @@ Special Registers Altered: None # Set Boolean +# Set Boolean X-Form * setb RT,BFA +Pseudo-code: + if CR[4*BFA+32] = 1 then RT <- 0xFFFF_FFFF_FFFF_FFFF else if CR[4*BFA+33]=1 then @@ -133,11 +156,14 @@ Special Registers Altered: None # Move To Machine State Register +# Move To Machine State Register X-Form * mtmsr RS,L +Pseudo-code: + if L = 0 then MSR[48] <- (RS)[48] | (RS)[49] MSR[58] <- ((RS)[58] | (RS)[49]) & ¬(MSR[41] & MSR[3] & (¬(RS)[49])) @@ -156,11 +182,14 @@ Special Registers Altered: MSR # Move From Machine State Register +# Move From Machine State Register X-Form * mfmsr RT +Pseudo-code: + RT <- MSR Special Registers Altered: diff --git a/openpower/isa/stringldst.mdwn b/openpower/isa/stringldst.mdwn index 8ef91dc37..a7bc46ff3 100644 --- a/openpower/isa/stringldst.mdwn +++ b/openpower/isa/stringldst.mdwn @@ -4,6 +4,8 @@ X-Form * lswi RT,RA,NB +Pseudo-code: + EA <- (RA|0) if NB = 0 then n <- 32 else n <- NB @@ -24,11 +26,14 @@ Special Registers Altered: None # Load String Word Indexed +# Load String Word Indexed X-Form * lswx RT,RA,RB +Pseudo-code: + b <- (RA|0) EA <- b + (RB) n <- XER[57:63] @@ -50,11 +55,14 @@ Special Registers Altered: None # Store String Word Immediate +# Store String Word Immediate X-Form * stswi RS,RA,NB +Pseudo-code: + EA <- (RA|0) if NB = 0 then n <- 32 else n <- NB @@ -73,11 +81,14 @@ Special Registers Altered: None # Store String Word Indexed +# Store String Word Indexed X-Form * stswx RS,RA,RB +Pseudo-code: + b <- (RA|0) EA <- b + (RB) n <- XER[57:63] diff --git a/openpower/isa/system.mdwn b/openpower/isa/system.mdwn index 48bacc2c4..a84db9353 100644 --- a/openpower/isa/system.mdwn +++ b/openpower/isa/system.mdwn @@ -1,16 +1,18 @@ -# System Call +# System Call SC-Form * sc LEV +Pseudo-code: + SRR0 <-iea CIA + 4 SRR1[33:36] <- 0 SRR1[42:47] <- 0 - SRR1[0:32] <- MSR[0:32] + SRR1[0:32] <- MSR[0:32] SRR1[37:41] <- MSR[37:41] SRR1[48:63] <- MSR[48:63] - MSR <- new_value + MSR <- new_value NIA <- 0x0000_0000_0000_0C00 Special Registers Altered: @@ -18,18 +20,21 @@ Special Registers Altered: SRR0 SRR1 MSR # System Call Vectored +# System Call Vectored SC-Form * scv LEV +Pseudo-code: + LR <- CIA + 4 SRR1[33:36] <- undefined SRR1[42:47] <- undefined - SRR1[0:32] <- MSR[0:32] + SRR1[0:32] <- MSR[0:32] SRR1[37:41] <- MSR[37:41] SRR1[48:63] <- MSR[48:63] - MSR <- new_value + MSR <- new_value NIA <- vectored Special Registers Altered: @@ -37,11 +42,14 @@ Special Registers Altered: LR CTR MSR # Return From System Call Vectored +# Return From System Call Vectored XL-Form * rfscv LEV +Pseudo-code: + if (MSR[29:31] != 0b010) | (CTR[29:31] != 0b000) then MSR[29:31] <- CTR[29:31] MSR[48] <- CTR[49] @@ -61,11 +69,14 @@ Special Registers Altered: MSR # Return From Interrupt Doubleword +# Return From Interrupt Doubleword XL-Form * rfid LEV +Pseudo-code: + MSR[51] <- (MSR[3] & SRR1[51]) | ((¬MSR[3] & MSR[51])) MSR[3] <- (MSR[3] & SRR1[3]) if (MSR[29:31] != 0b010) | (SRR1[29:31] != 0b000) then @@ -87,11 +98,14 @@ Special Registers Altered: MSR # Hypervisor Return From Interrupt Doubleword +# Hypervisor Return From Interrupt Doubleword XL-Form * hrfid LEV +Pseudo-code: + if (MSR[29:31] != 0b010) | (HSRR1[29:31] != 0b000) then MSR[29:31] <- HSRR1[29:31] MSR[48] <- HSRR1[48] | HSRR1[49] -- 2.30.2