on master help sign in
LLVM codegen: Print runtime errors
commitf5530768c9b0d431c1c5ed82d7e9006f4efc7f74 authorBenjamin Saunders <besaunde@sfu.ca> dateMon 24 Jun 2013, 21:36 (13 years ago) parent961e0f7
1 file changed+4
src/IRTS/CodegenLLVM.hs+4
src/IRTS/CodegenLLVM.hs+4
@@ -388,6 +388,10 @@ cgExpr (SOp fn args) = do
388388 Nothing -> return Nothing
389389cgExpr SNothing = return . Just . ConstantOperand $ nullValue
390390cgExpr (SError msg) = do -- TODO: Print message
391+ str <- addGlobal' (ArrayType (2 + fromIntegral (length msg)) (IntegerType 8))
392+ (cgConst' (TT.Str (msg ++ "\n")))
393+ inst' $ simpleCall "putStr" [ConstantOperand $ C.GetElementPtr True str [ C.Int 32 0
394+ , C.Int 32 0]]
391395 inst' $ Call { isTailCall = True
392396 , callingConvention = CC.C
393397 , returnAttributes = []