@@ -711,7 +711,7 @@ ffunDecl name rty argtys =
711ftyToTy :: FType -> Type
711ftyToTy :: FType -> Type
712ftyToTy (FInt ITNative) = IntegerType 32
712ftyToTy (FInt ITNative) = IntegerType 32
713ftyToTy (FInt ITBig) = PointerType mpzTy (AddrSpace 0)
713ftyToTy (FInt ITBig) = PointerType mpzTy (AddrSpace 0)
714−ftyToTy (FInt ty) = IntegerType (fromIntegral (itWidth ty))
714+ftyToTy (FInt ty) = IntegerType (itWidth ty)
715ftyToTy FChar = IntegerType 32
715ftyToTy FChar = IntegerType 32
716ftyToTy FString = PointerType (IntegerType 8) (AddrSpace 0)
716ftyToTy FString = PointerType (IntegerType 8) (AddrSpace 0)
717ftyToTy FUnit = VoidType
717ftyToTy FUnit = VoidType
@@ -725,7 +725,7 @@ cgOp (LTrunc ITBig ity) [x] = do
725 val <- inst $ simpleCall "mpz_get_ull" [nx]
725 val <- inst $ simpleCall "mpz_get_ull" [nx]
726 v <- case ity of
726 v <- case ity of
727 IT64 -> return val
727 IT64 -> return val
728− _ -> inst $ Trunc val (IntegerType . fromIntegral $ itWidth ity) []
728+ _ -> inst $ Trunc val (IntegerType $ itWidth ity) []
729 box (FInt ity) v
729 box (FInt ity) v
731cgOp (LLt ITBig) [x,y] = mpzCmp IPred.SLT x y
731cgOp (LLt ITBig) [x,y] = mpzCmp IPred.SLT x y
@@ -742,6 +742,11 @@ cgOp (LAnd ITBig) [x,y] = mpzBin "and" x y
742cgOp (LOr ITBig) [x,y] = mpzBin "ior" x y
742cgOp (LOr ITBig) [x,y] = mpzBin "ior" x y
743cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
743cgOp (LXOr ITBig) [x,y] = mpzBin "xor" x y
745+cgOp (LTrunc from to) [x] | itWidth from > itWidth to = do
746+ x' <- unbox (FInt from) x
747+ tx <- inst $ Trunc x' (IntegerType $ itWidth to) []
745cgOp (LLt ity) [x,y] = iCmp ity IPred.SLT x y
750cgOp (LLt ity) [x,y] = iCmp ity IPred.SLT x y
746cgOp (LLe ity) [x,y] = iCmp ity IPred.SLE x y
751cgOp (LLe ity) [x,y] = iCmp ity IPred.SLE x y
747cgOp (LEq ity) [x,y] = iCmp ity IPred.EQ x y
752cgOp (LEq ity) [x,y] = iCmp ity IPred.EQ x y