on master help sign in
Restored missing Int to Integer conversion codegens
commiteca417f3be36e663c29c1f633bc1a1a806d649dd authorBenjamin Saunders <besaunde@sfu.ca> dateWed 10 Jul 2013, 14:49 (13 years ago) parent09bb6fc
2 files changed+18
src/IRTS/CodegenC.hs+4 src/IRTS/CodegenLLVM.hs+14
src/IRTS/CodegenC.hs+4
@@ -344,6 +344,8 @@ doOp v (LSRem (ATInt (ITFixed ty))) [x, y] = bitOp v "SRem" ty [x, y]
344344
345345doOp v (LSExt (ITFixed from) ITBig) [x]
346346 = v ++ "MKBIGSI(vm, (" ++ signedTy from ++ ")" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
347+doOp v (LZExt ITNative ITBig) [x]
348+ = v ++ "MKBIGSI(vm, GETINT(" ++ creg x ++ "))"
347349doOp v (LSExt ITNative (ITFixed to)) [x]
348350 = v ++ "idris_b" ++ show (nativeTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
349351doOp v (LSExt (ITFixed from) ITNative) [x]
@@ -356,6 +358,8 @@ doOp v (LZExt (ITFixed from) ITNative) [x]
356358 = v ++ "MKINT((i_int)" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
357359doOp v (LZExt (ITFixed from) ITBig) [x]
358360 = v ++ "MKBIGUI(vm, " ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
361+doOp v (LZExt ITNative ITBig) [x]
362+ = v ++ "MKBIGUI(vm, (uintptr_t)GETINT(" ++ creg x ++ "))"
359363doOp v (LZExt (ITFixed from) (ITFixed to)) [x]
360364 | nativeTyWidth from < nativeTyWidth to = bitCoerce v "Z" from to x
361365doOp v (LTrunc ITNative (ITFixed to)) [x]
src/IRTS/CodegenLLVM.hs+14
@@ -846,6 +846,20 @@ cgOp (LOr ITBig) [x,y] = mpzBin "ior" x y
846846cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
847847cgOp (LCompl ITBig) [x] = mpzUn "com" x
848848
849+cgOp (LTrunc ITNative (ITFixed to)) [x]
850+ | 32 >= nativeTyWidth to = iCoerce Trunc IT32 to x
851+cgOp (LZExt ITNative (ITFixed to)) [x]
852+ | 32 <= nativeTyWidth to = iCoerce ZExt IT32 to x
853+cgOp (LSExt ITNative (ITFixed to)) [x]
854+ | 32 <= nativeTyWidth to = iCoerce SExt IT32 to x
855+
856+cgOp (LTrunc (ITFixed from) ITNative) [x]
857+ | nativeTyWidth from >= 32 = iCoerce Trunc from IT32 x
858+cgOp (LZExt (ITFixed from) ITNative) [x]
859+ | nativeTyWidth from <= 32 = iCoerce ZExt from IT32 x
860+cgOp (LSExt (ITFixed from) ITNative) [x]
861+ | nativeTyWidth from <= 32 = iCoerce SExt from IT32 x
862+
849863cgOp (LTrunc (ITFixed from) (ITFixed to)) [x]
850864 | nativeTyWidth from > nativeTyWidth to = iCoerce Trunc from to x
851865cgOp (LZExt (ITFixed from) (ITFixed to)) [x]