aboutsummaryrefslogtreecommitdiff
path: root/rts.ll
diff options
context:
space:
mode:
authorCamil Staps2021-01-08 09:31:50 +0100
committerCamil Staps2021-01-08 09:31:50 +0100
commitc1713f3ee00eb507ea25f83390467f86a58674d9 (patch)
tree400cb44b139d6cd3f3878d214db9f4c7ad95a9cc /rts.ll
parentAdd version of nfib without strictness analysis (diff)
Use malloc to allocate heap and stack
Diffstat (limited to 'rts.ll')
-rw-r--r--rts.ll29
1 files changed, 26 insertions, 3 deletions
diff --git a/rts.ll b/rts.ll
index 1a7d587..1181167 100644
--- a/rts.ll
+++ b/rts.ll
@@ -1,15 +1,38 @@
target triple = "x86_64-pc-linux-gnu"
+declare i8* @malloc(i64)
+
declare i64 @printf(i8*, ...)
@printf_d = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@printf_c = private unnamed_addr constant [3 x i8] c"%c\00", align 1
@printf_cycle = private unnamed_addr constant [16 x i8] c"cycle in spine\0a\00", align 1
-@heap = global [100000000 x i64] zeroinitializer, align 16
-@astack = global [10000 x i64*] zeroinitializer, align 16
-
attributes #0 = { alwaysinline }
+define private i64* @_alloc_heap(i64 %n) alwaysinline {
+ %s.0 = alloca i64
+ %s.1 = getelementptr i64, i64* %s.0, i64 1
+ %s.0.0 = ptrtoint i64* %s.0 to i64
+ %s.1.0 = ptrtoint i64* %s.1 to i64
+ %s.2 = sub i64 %s.1.0, %s.0.0
+ %s.3 = mul i64 %s.2, %n
+ %r.0 = call i8* @malloc(i64 %s.3)
+ %r.1 = bitcast i8* %r.0 to i64*
+ ret i64* %r.1
+}
+
+define private i64** @_alloc_a_stack(i64 %n) alwaysinline {
+ %s.0 = alloca i64*
+ %s.1 = getelementptr i64*, i64** %s.0, i64 1
+ %s.0.0 = ptrtoint i64** %s.0 to i64
+ %s.1.0 = ptrtoint i64** %s.1 to i64
+ %s.2 = sub i64 %s.1.0, %s.0.0
+ %s.3 = mul i64 %s.2, %n
+ %r.0 = call i8* @malloc(i64 %s.3)
+ %r.1 = bitcast i8* %r.0 to i64**
+ ret i64** %r.1
+}
+
define private i64** @_push_local_astack(i64** %asp.0, i64** %aspstart, i64** %globasp.0) #0 {
entry:
br label %loop