Commit 6454045a authored by Benedikt Geßele's avatar Benedikt Geßele

mips div,mod,divu,modu + bug fix in rev5 translator

parent 1f60e75a
......@@ -591,21 +591,6 @@ val sem-di x = do
write x.op (var temp)
end
val sem-div-divu div_op mod_op x = do
num <- rval Signed x.op1;
denom <- rval Signed x.op2;
size <- return (sizeof-rval x.op1);
hi <- return (semantic-reg-of Sem_HI);
lo <- return (semantic-reg-of Sem_LO);
div_op size lo num denom;
mod_op size hi num denom
end
val sem-div x = sem-div-divu div mod x
val sem-divu x = sem-div-divu divs mods x
val sem-ei x = do
sreg <- return (semantic-reg-of Sem_SREG);
......@@ -1526,9 +1511,7 @@ val semantics i =
| CVT-W-fmt x: sem-default-binop-flr-generic i x
| DERET: sem-deret
| DI x: sem-di x
| DIV x: sem-div x
| DIV-fmt x: sem-default-ternop-flrr-generic i x
| DIVU x: sem-divu x
| EI x: sem-ei x
| ERET: sem-eret
| EXT x: sem-ext x
......
......@@ -26,6 +26,21 @@ val sem-bltzall x = sem-bz-link /lts x
val sem-bltzl x = sem-bz /lts x
val sem-bnel x = sem-b /neq x
val sem-div-divu div_op mod_op x = do
num <- rval Signed x.op1;
denom <- rval Signed x.op2;
size <- return (sizeof-rval x.op1);
hi <- return (semantic-reg-of Sem_HI);
lo <- return (semantic-reg-of Sem_LO);
div_op size lo num denom;
mod_op size hi num denom
end
val sem-div x = sem-div-divu divs mods x
val sem-divu x = sem-div-divu div mod x
val sem-lwl x = do
off/base <- rval Signed x.op2;
base <- return (extract-tuple off/base).opnd1;
......@@ -129,6 +144,8 @@ val revision/semantics i =
| CVT-PS-S x: sem-default-ternop-lrr-generic i x
| CVT-S-PL x: sem-default-binop-lr-generic i x
| CVT-S-PU x: sem-default-binop-lr-generic i x
| DIV x: sem-div x
| DIVU x: sem-divu 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
......
......@@ -216,6 +216,22 @@ end
val sem-bovc x = branch-on-overflow x /lts
val sem-bnvc x = branch-on-overflow x /ges
val sem-div-divu-mod-modu op x = do
num <- rval Signed x.op2;
denom <- rval Signed x.op3;
size <- return (sizeof-rval x.op2);
res <- mktemp;
op size res num denom;
write x.op1 (var res)
end
val sem-div x = sem-div-divu-mod-modu divs x
val sem-divu x = sem-div-divu-mod-modu div x
val sem-mod x = sem-div-divu-mod-modu mods x
val sem-modu x = sem-div-divu-mod-modu mod x
val revision/semantics i =
case i of
ADDIUPC x: sem-addiupc x
......@@ -252,4 +268,8 @@ val revision/semantics i =
| BNVC x: sem-bnvc x
| CLASS-fmt x: sem-default-binop-flr-generic i x
| CMP-condn-fmt x: sem-default-ternop-cflrr-generic i x
| DIV x: sem-div x
| MOD x: sem-mod x
| DIVU x: sem-divu x
| MODU x: sem-modu x
end
......@@ -61,9 +61,7 @@ val traverse f insn =
| CVT-W-fmt x: f "CVT.W" (BINOP_FLR x)
| DERET: f "DERET" (NULLOP)
| DI x: f "DI" (UNOP_L x)
| DIV x: f "DIV" (BINOP_RR x)
| DIV-fmt x: f "DIV" (TERNOP_FLRR x)
| DIVU x: f "DIVU" (BINOP_RR x)
| EI x: f "EI" (UNOP_L x)
| ERET: f "ERET" (NULLOP)
| EXT x: f "EXT" (QUADOP_LRRR x)
......
......@@ -24,6 +24,8 @@ val revision/traverse f insn =
| CVT-PS-S x: f "CVT.PS.S" (TERNOP_LRR x)
| CVT-S-PL x: f "CVT.S.PL" (BINOP_LR x)
| CVT-S-PU x: f "CVT.S.PU" (BINOP_LR x)
| DIV x: f "DIV" (BINOP_RR x)
| DIVU x: f "DIVU" (BINOP_RR x)
| LDC2 x: f "LDC2" (BINOP_RR x)
| LWC2 x: f "LWC2" (BINOP_RR x)
| LWL x: f "LWL" (BINOP_LR x)
......
......@@ -34,4 +34,8 @@ val revision/traverse f insn =
| BNVC x: f "BNVC" (TERNOP_RRR x)
| CLASS-fmt x: f "CLASS" (BINOP_FLR x)
| CMP-condn-fmt x: f "CMP" (TERNOP_CFLRR x)
| DIV x: f "DIV" (TERNOP_LRR x)
| MOD x: f "MOD" (TERNOP_LRR x)
| DIVU x: f "DIVU" (TERNOP_LRR x)
| MODU x: f "MODU" (TERNOP_LRR x)
end
......@@ -272,18 +272,10 @@ val / ['010000 1 0000000000000000000 011111'] = nullop DERET
### - Disable Interrupts
val / ['010000 01011 /rt 01100 00000 0 00 000'] = unop DI rt
### DIV
### - Divide Word
val / ['000000 /rs /rt 0000000000 011010'] = binop DIV (right rs) (right rt)
### DIV-fmt
### - Floating Point Divide
val / ['010001 /fmt5sd /ft /fs /fd 000011'] = ternop-fmt DIV-fmt fmt fd (right fs) (right ft)
### DIVU
### - Divide Unsigned Word
val / ['000000 /rs /rt 0000000000 011011'] = binop DIVU (right rs) (right rt)
### EHB
### - Execution Hazard Barrier
### => see SLL r0, r0, 3
......@@ -1287,9 +1279,7 @@ type instruction =
| CVT-W-fmt of binop-flr
| DERET
| DI of unop-l
| DIV of binop-rr
| DIV-fmt of ternop-flrr
| DIVU of binop-rr
| EI of unop-l
| ERET
| EXT of quadop-lrrr
......
......@@ -123,6 +123,14 @@ val / ['010001 10110 00000 /fs /fd 101000'] = binop CVT-S-PL fd (right fs)
### - Floating Point Convert Pair Upper to Single Floating Point
val / ['010001 10110 00000 /fs /fd 100000'] = binop CVT-S-PU fd (right fs)
### DIV
### - Divide Word
val / ['000000 /rs /rt 0000000000 011010'] = binop DIV (right rs) (right rt)
### DIVU
### - Divide Unsigned Word
val / ['000000 /rs /rt 0000000000 011011'] = binop DIVU (right rs) (right rt)
### LDC2
### - Load Doubleword to Coprocessor 2
val / ['110110 /base /rt /offset16'] = binop LDC2 rt/imm offset16/base
......@@ -193,6 +201,8 @@ type instruction =
| CVT-PS-S of ternop-lrr
| CVT-S-PL of binop-lr
| CVT-S-PU of binop-lr
| DIV of binop-rr
| DIVU of binop-rr
| LDC2 of binop-rr
| LWC2 of binop-rr
| LWL of binop-lr
......
......@@ -189,6 +189,20 @@ val / ['010001 /fmt5sd 00000 /fs /fd 011011'] = binop-fmt CLASS-fmt fmt fd (righ
### - Floating Point Compare setting Mask
val / ['010001 /fmt5sd/wl /ft /fs /fd 0 /condn'] = ternop-cond-fmt CMP-condn-fmt condn fmt fd (right fs) (right ft)
### DIV, MOD, DIVU, MODU
### - Divide Integers (with result to GPR)
### DIV
val / ['000000 /rs /rt /rd 00010 011010'] = ternop DIV rd (right rs) (right rt)
### MOD
val / ['000000 /rs /rt /rd 00011 011010'] = ternop MOD rd (right rs) (right rt)
### DIVU
val / ['000000 /rs /rt /rd 00010 011011'] = ternop DIVU rd (right rs) (right rt)
### MODU
val / ['000000 /rs /rt /rd 00011 011011'] = ternop MODU rd (right rs) (right rt)
### LUI
### - Load Upper Immediate
### => see AUI r0, rt, immediate16
......@@ -229,6 +243,10 @@ type instruction =
| BNVC of ternop-rrr
| CLASS-fmt of binop-flr
| CMP-condn-fmt of ternop-cflrr
| DIV of ternop-lrr
| MOD of ternop-lrr
| DIVU of ternop-lrr
| MODU of ternop-lrr
type imm =
IMM21 of 21
......
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