on master help sign in
Restored missing Int to Integer conversion codegens
eca417fBenjamin Saunders
src/IRTS/CodegenC.hs+4
@@ -344,6 +344,8 @@ doOp v (LSRem (ATInt (ITFixed ty))) [x, y] = bitOp v "SRem" ty [x, y]
344
344
345doOp v (LSExt (ITFixed from) ITBig) [x]
345doOp v (LSExt (ITFixed from) ITBig) [x]
346 = v ++ "MKBIGSI(vm, (" ++ signedTy from ++ ")" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
346 = 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 ++ "))"
347doOp v (LSExt ITNative (ITFixed to)) [x]
349doOp v (LSExt ITNative (ITFixed to)) [x]
348 = v ++ "idris_b" ++ show (nativeTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
350 = v ++ "idris_b" ++ show (nativeTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
349doOp v (LSExt (ITFixed from) ITNative) [x]
351doOp v (LSExt (ITFixed from) ITNative) [x]
@@ -356,6 +358,8 @@ doOp v (LZExt (ITFixed from) ITNative) [x]
356 = v ++ "MKINT((i_int)" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
358 = v ++ "MKINT((i_int)" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
357doOp v (LZExt (ITFixed from) ITBig) [x]
359doOp v (LZExt (ITFixed from) ITBig) [x]
358 = v ++ "MKBIGUI(vm, " ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
360 = 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 ++ "))"
359doOp v (LZExt (ITFixed from) (ITFixed to)) [x]
363doOp v (LZExt (ITFixed from) (ITFixed to)) [x]
360 | nativeTyWidth from < nativeTyWidth to = bitCoerce v "Z" from to x
364 | nativeTyWidth from < nativeTyWidth to = bitCoerce v "Z" from to x
361doOp v (LTrunc ITNative (ITFixed to)) [x]
365doOp v (LTrunc ITNative (ITFixed to)) [x]
src/IRTS/CodegenLLVM.hs+14
@@ -846,6 +846,20 @@ cgOp (LOr ITBig) [x,y] = mpzBin "ior" x y
846cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
846cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
847cgOp (LCompl ITBig) [x] = mpzUn "com" x
847cgOp (LCompl ITBig) [x] = mpzUn "com" x
848
848
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+
849cgOp (LTrunc (ITFixed from) (ITFixed to)) [x]
863cgOp (LTrunc (ITFixed from) (ITFixed to)) [x]
850 | nativeTyWidth from > nativeTyWidth to = iCoerce Trunc from to x
864 | nativeTyWidth from > nativeTyWidth to = iCoerce Trunc from to x
851cgOp (LZExt (ITFixed from) (ITFixed to)) [x]
865cgOp (LZExt (ITFixed from) (ITFixed to)) [x]