Commit d94bd95a authored by Benedikt Geßele's avatar Benedikt Geßele

mips translator update floating sem

parent 4ea89b20
......@@ -38,6 +38,38 @@ val arch-show-id r =
| Sem_RA: "ra"
| Sem_HI: "HI"
| Sem_LO: "LO"
| Sem_F0: "f0"
| Sem_F1: "f1"
| Sem_F2: "f2"
| Sem_F3: "f3"
| Sem_F4: "f4"
| Sem_F5: "f5"
| Sem_F6: "f6"
| Sem_F7: "f7"
| Sem_F8: "f8"
| Sem_F9: "f9"
| Sem_F10: "f10"
| Sem_F11: "f11"
| Sem_F12: "f12"
| Sem_F13: "f13"
| Sem_F14: "f14"
| Sem_F15: "f15"
| Sem_F16: "f16"
| Sem_F17: "f17"
| Sem_F18: "f18"
| Sem_F19: "f19"
| Sem_F20: "f20"
| Sem_F21: "f21"
| Sem_F22: "f22"
| Sem_F23: "f23"
| Sem_F24: "f24"
| Sem_F25: "f25"
| Sem_F26: "f26"
| Sem_F27: "f27"
| Sem_F28: "f28"
| Sem_F29: "f29"
| Sem_F30: "f30"
| Sem_F31: "f31"
| Sem_SREG: "SREG"
end
......
......@@ -38,6 +38,40 @@ type sem_id =
| Sem_HI
| Sem_LO
type sem_id =
Sem_F0
| Sem_F1
| Sem_F2
| Sem_F3
| Sem_F4
| Sem_F5
| Sem_F6
| Sem_F7
| Sem_F8
| Sem_F9
| Sem_F10
| Sem_F11
| Sem_F12
| Sem_F13
| Sem_F14
| Sem_F15
| Sem_F16
| Sem_F17
| Sem_F18
| Sem_F19
| Sem_F20
| Sem_F21
| Sem_F22
| Sem_F23
| Sem_F24
| Sem_F25
| Sem_F26
| Sem_F27
| Sem_F28
| Sem_F29
| Sem_F30
| Sem_F31
val fRE = sem-reg-offset (sreg-get) 25
val sem-reg-offset r o = @{offset=r.offset + o}r
......@@ -82,3 +116,39 @@ val semantic-gpr-of r =
| S8 : {id=Sem_S8 ,offset=0,size=32}
| RA : {id=Sem_RA ,offset=0,size=32}
end
val semantic-fpr-of f =
case f of
F0 : {id=Sem_F0 ,offset=0,size=32}
| F1 : {id=Sem_F1 ,offset=0,size=32}
| F2 : {id=Sem_F2 ,offset=0,size=32}
| F3 : {id=Sem_F3 ,offset=0,size=32}
| F4 : {id=Sem_F4 ,offset=0,size=32}
| F5 : {id=Sem_F5 ,offset=0,size=32}
| F6 : {id=Sem_F6 ,offset=0,size=32}
| F7 : {id=Sem_F7 ,offset=0,size=32}
| F8 : {id=Sem_F8 ,offset=0,size=32}
| F9 : {id=Sem_F9 ,offset=0,size=32}
| F10 : {id=Sem_F10 ,offset=0,size=32}
| F11 : {id=Sem_F11 ,offset=0,size=32}
| F12 : {id=Sem_F12 ,offset=0,size=32}
| F13 : {id=Sem_F13 ,offset=0,size=32}
| F14 : {id=Sem_F14 ,offset=0,size=32}
| F15 : {id=Sem_F15 ,offset=0,size=32}
| F16 : {id=Sem_F16 ,offset=0,size=32}
| F17 : {id=Sem_F17 ,offset=0,size=32}
| F18 : {id=Sem_F18 ,offset=0,size=32}
| F19 : {id=Sem_F19 ,offset=0,size=32}
| F20 : {id=Sem_F20 ,offset=0,size=32}
| F21 : {id=Sem_F21 ,offset=0,size=32}
| F22 : {id=Sem_F22 ,offset=0,size=32}
| F23 : {id=Sem_F23 ,offset=0,size=32}
| F24 : {id=Sem_F24 ,offset=0,size=32}
| F25 : {id=Sem_F25 ,offset=0,size=32}
| F26 : {id=Sem_F26 ,offset=0,size=32}
| F27 : {id=Sem_F27 ,offset=0,size=32}
| F28 : {id=Sem_F28 ,offset=0,size=32}
| F29 : {id=Sem_F29 ,offset=0,size=32}
| F30 : {id=Sem_F30 ,offset=0,size=32}
| F31 : {id=Sem_F31 ,offset=0,size=32}
end
......@@ -12,6 +12,7 @@ val write to from =
val lval sn x =
case x of
GPR r: return (var (semantic-gpr-of r))
| FPR f: return (var (semantic-fpr-of f))
end
val rval sn x = let
......@@ -90,6 +91,130 @@ val sizeof-rval x =
end
end
val mnemonic-with-format insn x = (mnemonic-of insn) +++ "." +++ show/format x.fmt
val sem-default-unop-src-ro-generic insn x = do
src-sz <- return (sizeof-rval x.source);
src <- rval Signed x.source;
src-up <- unpack-lin src-sz src;
prim-generic (mnemonic-of insn) varls-none (varls-one (varl src-sz src-up))
end
val sem-default-binop-ro-generic insn x = do
src-sz <- return (sizeof-rval x.source);
dst-sz <- return (sizeof-lval x.destination);
src <- rval Signed x.source;
dst <- lval Signed x.destination;
src-up <- unpack-lin src-sz src;
dst-up <- unpack-lin dst-sz dst;
prim-generic (mnemonic-of insn) (varls-one (varl dst-sz dst-up)) (varls-one (varl src-sz src-up))
end
val sem-default-binop-fmt-ro-generic insn x = do
src-sz <- return (sizeof-rval x.source);
dst-sz <- return (sizeof-lval x.destination);
src <- rval Signed x.source;
dst <- lval Signed x.destination;
src-up <- unpack-lin src-sz src;
dst-up <- unpack-lin dst-sz dst;
prim-generic (mnemonic-with-format insn x) (varls-one (varl dst-sz dst-up)) (varls-one (varl src-sz src-up))
end
val sem-default-binop-src-ro-generic insn x = do
src1-sz <- return (sizeof-rval x.source1);
src2-sz <- return (sizeof-rval x.source2);
src1 <- rval Signed x.source1;
src2 <- rval Signed x.source2;
src1-up <- unpack-lin src1-sz src1;
src2-up <- unpack-lin src2-sz src2;
prim-generic (mnemonic-of insn) varls-none (varls-more (varl src2-sz src2-up) (varls-one (varl src1-sz src1-up)))
end
val sem-default-ternop-fmt-ro-generic insn x = do
src1-sz <- return (sizeof-rval x.source1);
src2-sz <- return (sizeof-rval x.source2);
dst-sz <- return (sizeof-lval x.destination);
src1 <- rval Signed x.source1;
src2 <- rval Signed x.source2;
dst <- lval Signed x.destination;
src1-up <- unpack-lin src1-sz src1;
src2-up <- unpack-lin src2-sz src2;
dst-up <- unpack-lin dst-sz dst;
prim-generic (mnemonic-with-format insn x) (varls-one (varl dst-sz dst-up)) (varls-more (varl src2-sz src2-up) (varls-one (varl src1-sz src1-up)))
end
val sem-default-quadop-ro-generic insn x = do
src1-sz <- return (sizeof-rval x.source1);
src2-sz <- return (sizeof-rval x.source2);
src3-sz <- return (sizeof-rval x.source3);
dst-sz <- return (sizeof-lval x.destination);
src1 <- rval Signed x.source1;
src2 <- rval Signed x.source2;
src3 <- rval Signed x.source3;
dst <- lval Signed x.destination;
src1-up <- unpack-lin src1-sz src1;
src2-up <- unpack-lin src2-sz src2;
src3-up <- unpack-lin src3-sz src3;
dst-up <- unpack-lin dst-sz dst;
prim-generic (mnemonic-of insn) (varls-one (varl dst-sz dst-up)) (varls-more (varl src3-sz src3-up) (varls-more (varl src2-sz src2-up) (varls-one (varl src1-sz src1-up))))
end
val sem-default-quadop-fmt-ro-generic insn x = do
src1-sz <- return (sizeof-rval x.source1);
src2-sz <- return (sizeof-rval x.source2);
src3-sz <- return (sizeof-rval x.source3);
dst-sz <- return (sizeof-lval x.destination);
src1 <- rval Signed x.source1;
src2 <- rval Signed x.source2;
src3 <- rval Signed x.source3;
dst <- lval Signed x.destination;
src1-up <- unpack-lin src1-sz src1;
src2-up <- unpack-lin src2-sz src2;
src3-up <- unpack-lin src3-sz src3;
dst-up <- unpack-lin dst-sz dst;
prim-generic (mnemonic-with-format insn x) (varls-one (varl dst-sz dst-up)) (varls-more (varl src3-sz src3-up) (varls-more (varl src2-sz src2-up) (varls-one (varl src1-sz src1-up))))
end
val sem-default-quadop-fmt-src-ro-generic insn x = do
src1-sz <- return (sizeof-rval x.source1);
src2-sz <- return (sizeof-rval x.source2);
src3-sz <- return (sizeof-rval x.source3);
src4-sz <- return (sizeof-rval x.source4);
src1 <- rval Signed x.source1;
src2 <- rval Signed x.source2;
src3 <- rval Signed x.source3;
src4 <- rval Signed x.source4;
src1-up <- unpack-lin src1-sz src1;
src2-up <- unpack-lin src2-sz src2;
src3-up <- unpack-lin src3-sz src3;
src4-up <- unpack-lin src4-sz src4;
prim-generic (mnemonic-with-format insn x) varls-none (varls-more (varl src4-sz src4-up) (varls-more (varl src3-sz src3-up) (varls-more (varl src2-sz src2-up) (varls-one (varl src1-sz src1-up)))))
end
###########
### semantics of instructions
###########
......@@ -771,23 +896,23 @@ val sem-srlv x = sem-sllv-srav-srlv shr x
val semantics i =
case i of
ABS-fmt x: sem-fp
ABS-fmt x: sem-default-binop-fmt-ro-generic i x
| ADD x: sem-add x
| ADD-fmt x: sem-fp
| ADD-fmt x: sem-default-ternop-fmt-ro-generic i x
| ADDI x: sem-addi x
| ADDIU x: sem-addiu x
| ADDU x: sem-addu x
| ALNV-PS x: sem-fp
| ALNV-PS x: sem-default-quadop-ro-generic i x
| AND x: sem-and x
| ANDI x: sem-andi x
| BC1F x: sem-fp
| BC1FL x: sem-fp
| BC1T x: sem-fp
| BC1TL x: sem-fp
| BC2F x: sem-fp2
| BC2FL x: sem-fp2
| BC2T x: sem-fp2
| BC2TL x: sem-fp2
| BC1F x: sem-default-binop-src-ro-generic i x
| BC1FL x: sem-default-binop-src-ro-generic i x
| BC1T x: sem-default-binop-src-ro-generic i x
| BC1TL x: sem-default-binop-src-ro-generic i x
| BC2F x: sem-default-binop-src-ro-generic i x
| BC2FL x: sem-default-binop-src-ro-generic i x
| BC2T x: sem-default-binop-src-ro-generic i x
| BC2TL x: sem-default-binop-src-ro-generic i x
| BEQ x: sem-beq x
| BEQL x: sem-beql x
| BGEZ x: sem-bgez x
......@@ -805,20 +930,20 @@ val semantics i =
| BNE x: sem-bne x
| BNEL x: sem-bnel x
| BREAK x: sem-break x
| C-cond-fmt x: sem-fp
| C-cond-fmt x: sem-default-quadop-fmt-src-ro-generic i x
| CACHE x: sem-cache x
| CACHEE x: sem-cachee x
| CEIL-L-fmt x: sem-fp
| CEIL-W-fmt x: sem-fp
| CFC1 x: sem-fp
| CFC2 x: sem-fp2
| CEIL-L-fmt x: sem-default-binop-fmt-ro-generic i x
| CEIL-W-fmt x: sem-default-binop-fmt-ro-generic i x
| CFC1 x: sem-default-binop-ro-generic i x
| CFC2 x: sem-default-binop-ro-generic i x
| CLO x: sem-cl 1 x
| CLZ x: sem-cl 0 x
| COP2 x: sem-fp2
| CTC1 x: sem-fp
| CTC2 x: sem-fp2
| CVT-D-fmt x: sem-fp
| CVT-L-fmt x: sem-fp
| COP2 x: sem-default-unop-src-ro-generic i x
| CTC1 x: sem-default-binop-ro-generic i x
| CTC2 x: sem-default-binop-src-ro-generic i x
| CVT-D-fmt x: sem-default-binop-fmt-ro-generic i x
| CVT-L-fmt x: sem-default-binop-fmt-ro-generic i x
| CVT-PS-S x: sem-fp
| CVT-S-fmt x: sem-fp
| CVT-S-PL x: sem-fp
......
......@@ -4,6 +4,12 @@ in
traverse f insn
end
val mnemonic-of insn = let
val f a b = a
in
traverse f insn
end
# -> sftl
type uarity =
NULLOP
......
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