on master help sign in
Restored missing Int to Integer conversion codegens
commit53f344a63aa9e1981e5f9c22ac07984f3c193e0e authorBenjamin Saunders <besaunde@sfu.ca> dateWed 10 Jul 2013, 14:49 (13 years ago) parent8e0f138
2 files changed+18
src/IRTS/CodegenC.hs+4 src/IRTS/CodegenLLVM.hs+14
src/IRTS/CodegenC.hs+4
@@ -364,6 +364,8 @@ doOp v (LSRem (ATInt (ITFixed ty))) [x, y] = bitOp v "SRem" ty [x, y]
364364
365365doOp v (LSExt (ITFixed from) ITBig) [x]
366366 = v ++ "MKBIGSI(vm, (" ++ signedTy from ++ ")" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
367+doOp v (LZExt ITNative ITBig) [x]
368+ = v ++ "MKBIGSI(vm, GETINT(" ++ creg x ++ "))"
367369doOp v (LSExt ITNative (ITFixed to)) [x]
368370 = v ++ "idris_b" ++ show (nativeTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
369371doOp v (LSExt ITChar (ITFixed to)) [x]
@@ -384,6 +386,8 @@ doOp v (LZExt (ITFixed from) ITChar) [x]
384386 = doOp v (LZExt (ITFixed from) ITNative) [x]
385387doOp v (LZExt (ITFixed from) ITBig) [x]
386388 = v ++ "MKBIGUI(vm, " ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
389+doOp v (LZExt ITNative ITBig) [x]
390+ = v ++ "MKBIGUI(vm, (uintptr_t)GETINT(" ++ creg x ++ "))"
387391doOp v (LZExt (ITFixed from) (ITFixed to)) [x]
388392 | nativeTyWidth from < nativeTyWidth to = bitCoerce v "Z" from to x
389393doOp v (LTrunc ITNative (ITFixed to)) [x]
src/IRTS/CodegenLLVM.hs+14
@@ -857,6 +857,20 @@ cgOp (LOr ITBig) [x,y] = mpzBin "ior" x y
857857cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
858858cgOp (LCompl ITBig) [x] = mpzUn "com" x
859859
860+cgOp (LTrunc ITNative (ITFixed to)) [x]
861+ | 32 >= nativeTyWidth to = iCoerce Trunc IT32 to x
862+cgOp (LZExt ITNative (ITFixed to)) [x]
863+ | 32 <= nativeTyWidth to = iCoerce ZExt IT32 to x
864+cgOp (LSExt ITNative (ITFixed to)) [x]
865+ | 32 <= nativeTyWidth to = iCoerce SExt IT32 to x
866+
867+cgOp (LTrunc (ITFixed from) ITNative) [x]
868+ | nativeTyWidth from >= 32 = iCoerce Trunc from IT32 x
869+cgOp (LZExt (ITFixed from) ITNative) [x]
870+ | nativeTyWidth from <= 32 = iCoerce ZExt from IT32 x
871+cgOp (LSExt (ITFixed from) ITNative) [x]
872+ | nativeTyWidth from <= 32 = iCoerce SExt from IT32 x
873+
860874cgOp (LTrunc (ITFixed from) (ITFixed to)) [x]
861875 | nativeTyWidth from > nativeTyWidth to = iCoerce Trunc from to x
862876cgOp (LZExt (ITFixed from) (ITFixed to)) [x]