Commit 76e69141 authored by Benedikt Geßele's avatar Benedikt Geßele

B<cond>C implemented ;(

parent ce6b6c04
......@@ -4,6 +4,7 @@ in case i of
IMM21 i: inner i 21
| IMM32 i: inner i 32
| BP i: inner i 2
| OFFSET23 i: inner i 23
| OFFSET28 i: inner i 28
| C2CONDITION i: inner i 5
end end
......
......@@ -3,6 +3,7 @@ val revision/show/immediate imm =
IMM21 x: show-int (zx x)
| IMM32 x: show-int (zx x)
| BP x: show-int (zx x)
| OFFSET23 x: show-int (zx x)
| OFFSET28 x: show-int (zx x)
| C2CONDITION x: show-int (zx x)
end
......
......@@ -1551,7 +1551,6 @@ val semantics i =
| LBU x: sem-lbu x
| LBUE x: sem-lbu x
| LDC1 x: sem-default-binop-lr-tuple-generic i x
| LDC2 x: sem-default-binop-rr-tuple-generic i x
| LDXC1 x: sem-default-binop-lr-tuple-generic i x
| LH x: sem-lh x
| LHE x: sem-lh x
......@@ -1625,7 +1624,6 @@ val semantics i =
| SCE x: sem-sc x
| SDBBP x: sem-sdbbp x
| SDC1 x: sem-default-binop-rr-tuple-generic i x
| SDC2 x: sem-default-binop-rr-tuple-generic i x
| SDXC1 x: sem-default-binop-rr-tuple-generic i x
| SEB x: sem-seb x
| SEH x: sem-seh x
......@@ -1648,6 +1646,7 @@ val semantics i =
| SUXC1 x: sem-default-binop-rr-tuple-generic i x
| SW x: sem-sw x
| SWC1 x: sem-default-binop-rr-tuple-generic i x
| SWC2 x: sem-default-binop-rr-tuple-generic i x
| SWE x: sem-sw x
| SWL x: sem-swl x
| SWLE x: sem-swl x
......
......@@ -125,11 +125,12 @@ val revision/semantics i =
| BLTZALL x: sem-bltzall x
| BLTZL x: sem-bltzl x
| BNEL x: sem-bnel x
| LDC2 x: sem-default-binop-rr-tuple-generic i x
| LWC2 x: sem-default-binop-rr-tuple-generic i x
| LWL x: sem-lwl x
| LWLE x: sem-lwl x
| LWR x: sem-lwr x
| LWRE x: sem-lwr x
| LWXC1 x: sem-default-binop-lr-tuple-generic i x
| SWC2 x: sem-default-binop-rr-tuple-generic i x
| SDC2 x: sem-default-binop-rr-tuple-generic i x
end
......@@ -3,6 +3,7 @@ val revision/sizeof-imm imm =
IMM21 i: 21
| IMM32 i: 32
| BP i: 2
| OFFSET23 i: 23
| OFFSET28 i: 28
| C2CONDITION i: 5
end
......@@ -18,6 +19,7 @@ in
IMM21 i: from-vec sn i
| IMM32 i: from-vec sn i
| BP i: from-vec sn i
| OFFSET23 i: from-vec sn i
| OFFSET28 i: from-vec sn i
| C2CONDITION i: from-vec sn i
end
......@@ -143,6 +145,19 @@ val sem-bltzalc x = sem-bzalc /lts x
val sem-beqzalc x = sem-bzalc /eq x
val sem-bnezalc x = sem-bzalc /neq x
val sem-blezc x = sem-bz /les x
val sem-bgezc x = sem-bz /ges x
val sem-bgec x = sem-b /ges x
val sem-bgtzc x = sem-bz /gts x
val sem-bltzc x = sem-bz /lts x
val sem-bltc x = sem-b /lts x
val sem-bgeuc x = sem-b /geu x
val sem-bltuc x = sem-b /ltu x
val sem-beqc x = sem-b /eq x
val sem-bnec x = sem-b /neq x
val sem-beqzc x = sem-bz /eq x
val sem-bnezc x = sem-bz /neq x
val revision/semantics i =
case i of
ADDIUPC x: sem-addiupc x
......@@ -162,4 +177,16 @@ val revision/semantics i =
| BLTZALC x: sem-bltzalc x
| BEQZALC x: sem-beqzalc x
| BNEZALC x: sem-bnezalc x
| BLEZC x: sem-blezc x
| BGEZC x: sem-bgezc x
| BGEC x: sem-bgec x
| BGTZC x: sem-bgtzc x
| BLTZC x: sem-bltzc x
| BLTC x: sem-bltc x
| BGEUC x: sem-bgeuc x
| BLTUC x: sem-bltuc x
| BEQC x: sem-beqc x
| BNEC x: sem-bnec x
| BEQZC x: sem-beqzc x
| BNEZC x: sem-bnezc x
end
......@@ -86,7 +86,6 @@ val traverse f insn =
| LBU x: f "LBU" (BINOP_LR x)
| LBUE x: f "LBUE" (BINOP_LR x)
| LDC1 x: f "LDC1" (BINOP_LR x)
| LDC2 x: f "LDC2" (BINOP_RR x)
| LDXC1 x: f "LDXC1" (BINOP_LR x)
| LH x: f "LH" (BINOP_LR x)
| LHE x: f "LHE" (BINOP_LR x)
......@@ -160,7 +159,6 @@ val traverse f insn =
| SCE x: f "SCE" (BINOP_LR x)
| SDBBP x: f "SDBBP" (UNOP_R x)
| SDC1 x: f "SDC1" (BINOP_RR x)
| SDC2 x: f "SDC2" (BINOP_RR x)
| SDXC1 x: f "SDXC1" (BINOP_RR x)
| SEB x: f "SEB" (BINOP_LR x)
| SEH x: f "SEH" (BINOP_LR x)
......@@ -183,6 +181,7 @@ val traverse f insn =
| SUXC1 x: f "SUXC1" (BINOP_RR x)
| SW x: f "SW" (BINOP_RR x)
| SWC1 x: f "SWC1" (BINOP_RR x)
| SWC2 x: f "SWC2" (BINOP_RR x)
| SWE x: f "SWE" (BINOP_RR x)
| SWL x: f "SWL" (BINOP_RR x)
| SWLE x: f "SWLE" (BINOP_RR x)
......
......@@ -20,11 +20,12 @@ val revision/traverse f insn =
| BLTZALL x: f "BLTZALL" (BINOP_RR x)
| BLTZL x: f "BLTZL" (BINOP_RR x)
| BNEL x: f "BNEL" (TERNOP_RRR x)
| LDC2 x: f "LDC2" (BINOP_RR x)
| LWC2 x: f "LWC2" (BINOP_RR x)
| LWL x: f "LWL" (BINOP_LR x)
| LWLE x: f "LWLE" (BINOP_LR x)
| LWR x: f "LWR" (BINOP_LR x)
| LWRE x: f "LWRE" (BINOP_LR x)
| LWXC1 x: f "LWXC1" (BINOP_LR x)
| SWC2 x: f "SWC2" (BINOP_RR x)
| SDC2 x: f "SDC2" (BINOP_RR x)
end
......@@ -17,4 +17,16 @@ val revision/traverse f insn =
| BLTZALC x: f "BLTZALC" (BINOP_RR x)
| BEQZALC x: f "BEQZALC" (BINOP_RR x)
| BNEZALC x: f "BNEZALC" (BINOP_RR x)
| BLEZC x: f "BLEZC" (BINOP_RR x)
| BGEZC x: f "BGEZC" (BINOP_RR x)
| BGEC x: f "BGEC" (TERNOP_RRR x)
| BGTZC x: f "BGTZC" (BINOP_RR x)
| BLTZC x: f "BLTZC" (BINOP_RR x)
| BLTC x: f "BLTC" (TERNOP_RRR x)
| BGEUC x: f "BGEUC" (TERNOP_RRR x)
| BLTUC x: f "BLTUC" (TERNOP_RRR x)
| BEQC x: f "BEQC" (TERNOP_RRR x)
| BNEC x: f "BNEC" (TERNOP_RRR x)
| BEQZC x: f "BEQZC" (BINOP_RR x)
| BNEZC x: f "BNEZC" (BINOP_RR x)
end
......@@ -411,10 +411,6 @@ val / ['011111 /base /rt /offset9 0 101000']
### - Load Doubleword to Floating Point
val / ['110101 /base /ft /offset16'] = binop LDC1 ft offset16/base
### LDC2
### - Load Doubleword to Coprocessor 2
val / ['110110 /base /rt /offset16'] = binop LDC2 rt/imm offset16/base
### LDXC1
### - Load Doubleword Indexed to Floating Point
val / ['010011 /base /index 00000 /fd 000001'] = binop LDXC1 fd index/base
......@@ -729,10 +725,6 @@ val / ['011100 /code20 111111'] = unop SDBBP code20
### - Store Doubleword from Floating Point
val / ['111101 /base /ft /offset16'] = binop SDC1 (right ft) offset16/base
### SDC2
### - Store Doubleword from Coprocessor 2
val / ['111110 /base /rt /offset16'] = binop SDC2 rt/imm offset16/base
### SDXC1
### - Store Doubleword Indexed from Floating Point
val / ['010011 /base /index /fs 00000 001001'] = binop SDXC1 (right fs) index/base
......@@ -1365,7 +1357,6 @@ type instruction =
| LBU of binop-lr
| LBUE of binop-lr
| LDC1 of binop-lr
| LDC2 of binop-rr
| LDXC1 of binop-lr
| LH of binop-lr
| LHE of binop-lr
......@@ -1439,7 +1430,6 @@ type instruction =
| SCE of binop-lr
| SDBBP of unop-r
| SDC1 of binop-rr
| SDC2 of binop-rr
| SDXC1 of binop-rr
| SEB of binop-lr
| SEH of binop-lr
......
......@@ -103,6 +103,10 @@ val / ['000001 /rs 00010 /offset16'] = binop BLTZL (right rs) offset18
### - Branch on Not Equal Likely
val / ['010101 /rs /rt /offset16'] = ternop BNEL (right rs) (right rt) offset18
### LDC2
### - Load Doubleword to Coprocessor 2
val / ['110110 /base /rt /offset16'] = binop LDC2 rt/imm offset16/base
### LUI
### - Load Upper Immediate
val / ['001111 00000 /rt /immediate16'] = binop LUI rt immediate16
......@@ -135,6 +139,10 @@ val / ['011111 /base /rt /offset9 0 011010']
### - Load Word Indexed to Floating Point
val / ['010011 /base /index 00000 /fd 000000'] = binop LWXC1 fd index/base
### SDC2
### - Store Doubleword from Coprocessor 2
val / ['111110 /base /rt /offset16'] = binop SDC2 rt/imm offset16/base
### SWC2
### - Store Word from Coprocessor 2
val / ['111010 /base /rt /offset16'] = binop SWC2 rt/imm offset16/base
......@@ -161,13 +169,14 @@ type instruction =
| BLTZALL of binop-rr
| BLTZL of binop-rr
| BNEL of ternop-rrr
| LDC2 of binop-rr
| LWC2 of binop-rr
| LWL of binop-lr
| LWLE of binop-lr
| LWR of binop-lr
| LWRE of binop-lr
| LWXC1 of binop-lr
| SDC2 of binop-rr
type format =
PS
......
......@@ -8,13 +8,26 @@
val lui? s = (s.rs == '00000')
val bgtz? s = (s.rt == '00000')
val bgtzalc? s = (s.rs == '00000')
val bgtzalc? s = (s.rs == '00000') and (not (s.rt == '00000'))
val bgezalc? s = (s.rs == s.rt) and (not (s.rs == '00000'))
val blez? s = (s.rt == '00000')
val blezalc? s = (s.rs == '00000')
val blezalc? s = (s.rs == '00000') and (not (s.rt == '00000'))
val bltzalc? s = (s.rs == s.rt) and (not (s.rs == '00000'))
val beqzalc? s = not (s.rt == '00000')
val bnezalc? s = not (s.rt == '00000')
val beqzalc? s = ((zx s.rs) < (zx s.rt)) and (s.rs == '00000') and (not (s.rt == '00000'))
val bnezalc? s = ((zx s.rs) < (zx s.rt)) and (s.rs == '00000') and (not (s.rt == '00000'))
val blezc? s = (s.rs == '00000') and (not (s.rt == '00000'))
val bgezc? s = (s.rs == s.rt) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val bgec? s = (not (s.rs == s.rt)) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val bgtzc? s = (s.rs == '00000') and (not (s.rt == '00000'))
val bltzc? s = (s.rs == s.rt) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val bltc? s = (not (s.rs == s.rt)) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val bgeuc? s = (not (s.rs == s.rt)) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val bltuc? s = (not (s.rs == s.rt)) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val beqc? s = ((zx s.rs) < (zx s.rt)) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val bnec? s = ((zx s.rs) < (zx s.rt)) and (not (s.rs == '00000')) and (not (s.rt == '00000'))
val beqzc? s = not (s.rs == '00000')
val bnezc? s = not (s.rs == '00000')
######################
# decoder rules
......@@ -76,33 +89,77 @@ val / ['010010 01101 /ct /offset16'] = binop BC2NEZ ct offset18
### BGTZ
### - Branch on Greater Than Zero
### => see BGEZALC
### => see BLTUC
### BLEZ
### - Branch on Less Than or Equal to Zero
### => see BLTZALC
### => see BGEUC
### B{LE,GE,GT,LT,EQ,NE}ZALC
### - Compact zero-compare and branch-and-link instructions
### BLEZALC
### => see BGEUC
### BGEZALC
### => see BGEUC
### BGTZALC
### => see BLTTUC
### BLTZALC
### => see BLTTUC
### BEQZALC
### => see BEQC
### BNEZALC
### => see BNEC
### B<cond>C
### - Compact compare-and-branch instructions
### BGEC (BLEZ)
val / ['010110 /rs /rt /offset16']
| blezc? = binop BLEZC (right rt) offset18
| bgezc? = binop BGEZC (right rt) offset18
| bgec? = ternop BGEC (right rs) (right rt) offset18
### BLTC (BGTC)
val / ['010111 /rs /rt /offset16']
| bgtzc? = binop BGTZC (right rt) offset18
| bltzc? = binop BLTZC (right rt) offset18
| bltc? = ternop BLTC (right rs) (right rt) offset18
### BGEUC (BLEUC)
val / ['000110 /rs /rt /offset16']
| blez? = binop BLEZ (right rs) offset18
| blezalc? = binop BLEZALC (right rt) offset18
| bgezalc? = binop BGEZALC (right rt) offset18
| bgeuc? = ternop BGEUC (right rs) (right rt) offset18
### BLTZALC
### BLTUC (BGTUC)
val / ['000111 /rs /rt /offset16']
| bgtz? = binop BGTZ (right rs) offset18
| bgtzalc? = binop BGTZALC (right rt) offset18
| bltzalc? = binop BLTZALC (right rt) offset18
| bltuc? = ternop BLTUC (right rs) (right rt) offset18
### BEQZALC
val / ['001000 00000 /rt /offset16']
### BEQC
val / ['001000 /rs /rt /offset16']
| beqzalc? = binop BEQZALC (right rt) offset18
| beqc? = ternop BEQC (right rs) (right rt) offset18
### BNEZALC
val / ['011000 00000 /rt /offset16']
### BNEC
val / ['011000 /rs /rt /offset16']
| bnezalc? = binop BNEZALC (right rt) offset18
| bnec? = ternop BNEC (right rs) (right rt) offset18
### BEQZC
val / ['110110 /rs /offset21']
| beqzc? = binop BEQZC (right rs) offset23
### BNEZC
val / ['111110 /rs /offset21']
| bnezc? = binop BNEZC (right rs) offset23
### LUI
### - Load Upper Immediate
......@@ -127,11 +184,24 @@ type instruction =
| BLTZALC of binop-rr
| BEQZALC of binop-rr
| BNEZALC of binop-rr
| BLEZC of binop-rr
| BGEZC of binop-rr
| BGEC of ternop-rrr
| BGTZC of binop-rr
| BLTZC of binop-rr
| BLTC of ternop-rrr
| BGEUC of ternop-rrr
| BLTUC of ternop-rrr
| BEQC of ternop-rrr
| BNEC of ternop-rrr
| BEQZC of binop-rr
| BNEZC of binop-rr
type imm =
IMM21 of 21
| IMM32 of 32
| BP of 2
| OFFSET23 of 23
| OFFSET28 of 28
| C2CONDITION of 5
......@@ -141,6 +211,7 @@ type imm =
####
val /immediate19 ['immediate19:19'] = update@{immediate19=immediate19}
val /offset21 ['offset21:21'] = update@{offset21=offset21}
val /offset26 ['offset26:26'] = update@{offset26=offset26}
val /bp ['bp:2'] = update@{bp=bp}
val /ct ['ct:5'] = update@{ct=ct}
......@@ -159,6 +230,11 @@ val immediate32 = do
return (IMM (IMM32 (immediate16 ^ '0000000000000000')))
end
val offset23 = do
offset21 <- query $offset21;
return (IMM (OFFSET23 (offset21 ^ '00')))
end
val offset28 = do
offset26 <- query $offset26;
return (IMM (OFFSET28 (offset26 ^ '00')))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment