diff --git a/src/Codegen/Codegen.hs b/src/Codegen/Codegen.hs index 0d011e8..6ad7c5d 100644 --- a/src/Codegen/Codegen.hs +++ b/src/Codegen/Codegen.hs @@ -58,6 +58,7 @@ defaultStart = , UnsafeRaw "@.non_exhaustive_patterns = private unnamed_addr constant [41 x i8] c\"Non-exhaustive patterns in case at %i:%i\n\"\n" , UnsafeRaw "@.char_print = private unnamed_addr constant [2 x i8] c\"%c\"\n" , UnsafeRaw "@.char_print_no_nl = private unnamed_addr constant [3 x i8] c\"%c\0\"\n" + , UnsafeRaw "@.int_print_no_nl = private unnamed_addr constant [3 x i8] c\"%i\0\"\n" , UnsafeRaw "declare i32 @printf(ptr noalias nocapture, ...)\n" , UnsafeRaw "declare i32 @exit(i32 noundef)\n" , UnsafeRaw "declare ptr @malloc(i32 noundef)\n" diff --git a/src/Codegen/Emits.hs b/src/Codegen/Emits.hs index ba91bda..72711f4 100644 --- a/src/Codegen/Emits.hs +++ b/src/Codegen/Emits.hs @@ -381,6 +381,7 @@ preludeFuns def xs arg1 arg2 = case xs of "$minus$$Int_Int_Int" -> pure $ Sub I64 arg1 arg2 "$plus$$Int_Int_Int" -> pure $ Add I64 arg1 arg2 "printChar$Char_Unit" -> pure . UnsafeRaw $ "add i16 0,0\n call void (ptr, ...) @printf(ptr noundef @.char_print_no_nl, i8 noundef " <> toIr arg1 <> ")\n" + "printInt$Int_Unit" -> pure . UnsafeRaw $ "add i16 0,0\n call void (ptr, ...) @printf(ptr noundef @.int_print_no_nl, i8 noundef " <> toIr arg1 <> ")\n" _ -> pure def -- | Emits a function call.