@@ -132,6 +132,8 @@ initDefs tgt =
132132 , exfun "GC_malloc" ptrI8 [intPtr] False
133133 , exfun "GC_malloc_atomic" ptrI8 [intPtr] False
134134 , exfun "__gmpz_init" VoidType [pmpz] False
135+ , exfun "__gmpz_init_set_str" (IntegerType 32) [pmpz, ptrI8, IntegerType 32] False
136+ , exfun "__gmpz_get_str" ptrI8 [ptrI8, IntegerType 32, pmpz] False
135137 , GlobalDefinition mainDef
136138 ] ++ map mpzBinFun ["add", "sub", "mul", "fdiv_q", "fdiv_r", "and", "ior", "xor"]
137139 where
@@ -668,8 +670,10 @@ cgConst c@(TT.Str s) = do
668670cgConst c@(TT.BI i) = do
669671 str <- addGlobal' (ArrayType (1 + fromInteger (numDigits 10 i)) (IntegerType 8)) (cgConst' c)
670672 mpz <- alloc mpzTy
671− inst $ simpleCall "__gmpz_init_set_str" [mpz, ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0
672− , C.Int 32 0]]
673+ inst $ simpleCall "__gmpz_init_set_str" [mpz
674+ , ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0, C.Int 32 0]
675+ , ConstantOperand $ C.Int 32 10
676+ ]
673677 box (FInt ITBig) mpz
674678cgConst x = return $ ConstantOperand nullValue
675679
@@ -751,7 +755,9 @@ cgOp (LIntStr ITBig) [x] = do
751755 x' <- unbox (FInt ITBig) x
752756 ustr <- inst $ simpleCall "__gmpz_get_str"
753757 [ ConstantOperand (C.Null (PointerType (IntegerType 8) (AddrSpace 0)))
754− , ConstantOperand (C.Int 32 10), x']
758+ , ConstantOperand (C.Int 32 10)
759+ , x'
760+ ]
755761 box FString ustr
756762cgOp (LIntStr ity) [x] = do
757763 x' <- unbox (FInt ity) x