function calls not working entirely >:(

This commit is contained in:
2025-10-15 15:32:40 +11:00
parent e0dd9ee541
commit a75dcb933e
7 changed files with 52 additions and 27 deletions

View File

@@ -66,11 +66,11 @@
"arguments": [
{
"type": "IntegerLiteral",
"value": 2
"value": 1
},
{
"type": "IntegerLiteral",
"value": 3
"value": 2
}
]
}

View File

@@ -1,7 +1,9 @@
; ModuleID = "main"
target triple = "x86_64-pc-windows-msvc"
target triple = "arm64-apple-darwin24.5.0"
target datalayout = ""
declare i32 @"printf"(i8* %".1", ...)
@"true" = constant i1 1
@"false" = constant i1 0
define i32 @"add"(i32 %".1", i32 %".2")
@@ -17,23 +19,12 @@ add_entry:
ret i32 %".10"
}
define i32 @"sub"(i32 %".1", i32 %".2")
{
sub_entry:
%".4" = alloca i32
store i32 %".1", i32* %".4"
%".6" = alloca i32
store i32 %".2", i32* %".6"
%".8" = load i32, i32* %".4"
%".9" = load i32, i32* %".6"
%".10" = sub i32 %".8", %".9"
ret i32 %".10"
}
define i32 @"main"()
{
main_entry:
%".2" = call i32 @"add"(i32 50, i32 50)
%".3" = call i32 @"sub"(i32 %".2", i32 125)
ret i32 %".3"
%".2" = call i32 @"add"(i32 1, i32 2)
%".3" = alloca i32
store i32 %".2", i32* %".3"
%".5" = load i32, i32* %".3"
ret i32 %".5"
}