Created
November 11, 2013 20:29
-
-
Save wbrown/7419814 to your computer and use it in GitHub Desktop.
Output of: `clouddrift:experiments wbrown$ opt-3.3 -std-link-opts -S` on https://github.com/ephsec/svforth/blob/master/experiments/forth.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'forth.ll' | |
@stackString = internal constant [13 x i8] c"%llu: %llu\0D\0A\00" | |
@heapPtr = internal unnamed_addr global i64* null | |
@heapSize = internal unnamed_addr global i1 false | |
@execIdx = internal unnamed_addr global i64 0 | |
@stackIdx = internal unnamed_addr global i64 0 | |
; Function Attrs: nounwind | |
declare i32 @printf(i8* nocapture, ...) #0 | |
define internal void @SWAP() { | |
%stackIdx.i = load i64* @stackIdx | |
%heapPtr.i.i.i = load i64** @heapPtr | |
%valuePtr.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %stackIdx.i | |
%value.i.i = load i64* %valuePtr.i.i.i | |
%newStackIdx.i = add i64 %stackIdx.i, 1 | |
%valuePtr.i.i.i3 = getelementptr i64* %heapPtr.i.i.i, i64 %newStackIdx.i | |
%value.i.i4 = load i64* %valuePtr.i.i.i3 | |
store i64 %value.i.i, i64* %valuePtr.i.i.i3 | |
store i64 %value.i.i4, i64* %valuePtr.i.i.i | |
%execIdx.i.i = load i64* @execIdx | |
%valuePtr.i.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %execIdx.i.i | |
%value.i.i.i = load i64* %valuePtr.i.i.i.i | |
%nextExec.i.i = add i64 %execIdx.i.i, 1 | |
store i64 %nextExec.i.i, i64* @execIdx | |
%is_done.i = icmp eq i64 %value.i.i.i, 0 | |
br i1 %is_done.i, label %next.exit, label %execIns.i | |
execIns.i: ; preds = %0 | |
%functionPtr.i = inttoptr i64 %value.i.i.i to void ()* | |
call void %functionPtr.i() | |
br label %next.exit | |
next.exit: ; preds = %0, %execIns.i | |
ret void | |
} | |
define internal void @DUP() { | |
%stackIdx.i = load i64* @stackIdx | |
%heapPtr.i.i.i = load i64** @heapPtr | |
%valuePtr.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %stackIdx.i | |
%value.i.i = load i64* %valuePtr.i.i.i | |
%newStackIdx.i = add i64 %stackIdx.i, -1 | |
%valuePtr.i.i.i3 = getelementptr i64* %heapPtr.i.i.i, i64 %newStackIdx.i | |
store i64 %value.i.i, i64* %valuePtr.i.i.i3 | |
store i64 %newStackIdx.i, i64* @stackIdx | |
%execIdx.i.i = load i64* @execIdx | |
%valuePtr.i.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %execIdx.i.i | |
%value.i.i.i = load i64* %valuePtr.i.i.i.i | |
%nextExec.i.i = add i64 %execIdx.i.i, 1 | |
store i64 %nextExec.i.i, i64* @execIdx | |
%is_done.i = icmp eq i64 %value.i.i.i, 0 | |
br i1 %is_done.i, label %next.exit, label %execIns.i | |
execIns.i: ; preds = %0 | |
%functionPtr.i = inttoptr i64 %value.i.i.i to void ()* | |
call void %functionPtr.i() | |
br label %next.exit | |
next.exit: ; preds = %0, %execIns.i | |
ret void | |
} | |
define internal void @ADD() { | |
%stackIdx.i = load i64* @stackIdx | |
%heapPtr.i.i.i = load i64** @heapPtr | |
%valuePtr.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %stackIdx.i | |
%value.i.i = load i64* %valuePtr.i.i.i | |
%newStackIdx.i = add i64 %stackIdx.i, 1 | |
%valuePtr.i.i.i3 = getelementptr i64* %heapPtr.i.i.i, i64 %newStackIdx.i | |
%value.i.i4 = load i64* %valuePtr.i.i.i3 | |
%result = add i64 %value.i.i, %value.i.i4 | |
store i64 %result, i64* %valuePtr.i.i.i3 | |
store i64 %newStackIdx.i, i64* @stackIdx | |
%execIdx.i.i = load i64* @execIdx | |
%valuePtr.i.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %execIdx.i.i | |
%value.i.i.i = load i64* %valuePtr.i.i.i.i | |
%nextExec.i.i = add i64 %execIdx.i.i, 1 | |
store i64 %nextExec.i.i, i64* @execIdx | |
%is_done.i = icmp eq i64 %value.i.i.i, 0 | |
br i1 %is_done.i, label %next.exit, label %execIns.i | |
execIns.i: ; preds = %0 | |
%functionPtr.i = inttoptr i64 %value.i.i.i to void ()* | |
call void %functionPtr.i() | |
br label %next.exit | |
next.exit: ; preds = %0, %execIns.i | |
ret void | |
} | |
define internal void @MUL() { | |
%stackIdx.i = load i64* @stackIdx | |
%heapPtr.i.i.i = load i64** @heapPtr | |
%valuePtr.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %stackIdx.i | |
%value.i.i = load i64* %valuePtr.i.i.i | |
%newStackIdx.i = add i64 %stackIdx.i, 1 | |
%valuePtr.i.i.i3 = getelementptr i64* %heapPtr.i.i.i, i64 %newStackIdx.i | |
%value.i.i4 = load i64* %valuePtr.i.i.i3 | |
%result = mul i64 %value.i.i, %value.i.i4 | |
store i64 %result, i64* %valuePtr.i.i.i3 | |
store i64 %newStackIdx.i, i64* @stackIdx | |
%execIdx.i.i = load i64* @execIdx | |
%valuePtr.i.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %execIdx.i.i | |
%value.i.i.i = load i64* %valuePtr.i.i.i.i | |
%nextExec.i.i = add i64 %execIdx.i.i, 1 | |
store i64 %nextExec.i.i, i64* @execIdx | |
%is_done.i = icmp eq i64 %value.i.i.i, 0 | |
br i1 %is_done.i, label %next.exit, label %execIns.i | |
execIns.i: ; preds = %0 | |
%functionPtr.i = inttoptr i64 %value.i.i.i to void ()* | |
call void %functionPtr.i() | |
br label %next.exit | |
next.exit: ; preds = %0, %execIns.i | |
ret void | |
} | |
define internal void @DISPSTACK() { | |
%getStackIdx.i = load i64* @stackIdx | |
%heapSize.i.b = load i1* @heapSize | |
%heapSize.i = select i1 %heapSize.i.b, i64 1048576, i64 0 | |
br label %loop.i | |
loop.i: ; preds = %continue_loop.i, %0 | |
%stackIdx.i = phi i64 [ %newStackIdx.i, %continue_loop.i ], [ %getStackIdx.i, %0 ] | |
%is_done.i = icmp ult i64 %stackIdx.i, %heapSize.i | |
br i1 %is_done.i, label %continue_loop.i, label %showStack.exit | |
continue_loop.i: ; preds = %loop.i | |
%heapPtr.i.i.i = load i64** @heapPtr | |
%valuePtr.i.i.i = getelementptr i64* %heapPtr.i.i.i, i64 %stackIdx.i | |
%value.i.i = load i64* %valuePtr.i.i.i | |
%relStackIdx.i = sub i64 %heapSize.i, %stackIdx.i | |
%1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @stackString, i64 0, i64 0), i64 %relStackIdx.i, i64 %value.i.i) | |
%newStackIdx.i = add i64 %stackIdx.i, 1 | |
br label %loop.i | |
showStack.exit: ; preds = %loop.i | |
%execIdx.i.i = load i64* @execIdx | |
%heapPtr.i.i.i.i = load i64** @heapPtr | |
%valuePtr.i.i.i.i = getelementptr i64* %heapPtr.i.i.i.i, i64 %execIdx.i.i | |
%value.i.i.i = load i64* %valuePtr.i.i.i.i | |
%nextExec.i.i = add i64 %execIdx.i.i, 1 | |
store i64 %nextExec.i.i, i64* @execIdx | |
%is_done.i1 = icmp eq i64 %value.i.i.i, 0 | |
br i1 %is_done.i1, label %next.exit, label %execIns.i | |
execIns.i: ; preds = %showStack.exit | |
%functionPtr.i = inttoptr i64 %value.i.i.i to void ()* | |
call void %functionPtr.i() | |
br label %next.exit | |
next.exit: ; preds = %showStack.exit, %execIns.i | |
ret void | |
} | |
define i64 @main() { | |
store i1 true, i1* @heapSize | |
%heapPtr1 = alloca [1048576 x i64] | |
%heapPtr1.sub = getelementptr inbounds [1048576 x i64]* %heapPtr1, i32 0, i32 0 | |
store i64* %heapPtr1.sub, i64** @heapPtr | |
%valuePtr.i.i.i = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 1048575 | |
store i64 1, i64* %valuePtr.i.i.i | |
%valuePtr.i.i.i5 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 1048574 | |
store i64 2, i64* %valuePtr.i.i.i5 | |
%valuePtr.i.i.i41 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 1048573 | |
store i64 3, i64* %valuePtr.i.i.i41 | |
store i64 1048573, i64* @stackIdx | |
store i64 ptrtoint (void ()* @DISPSTACK to i64), i64* %heapPtr1.sub | |
%valuePtr.i.i.i35 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 1 | |
store i64 ptrtoint (void ()* @ADD to i64), i64* %valuePtr.i.i.i35 | |
%valuePtr.i.i.i31 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 2 | |
store i64 ptrtoint (void ()* @SWAP to i64), i64* %valuePtr.i.i.i31 | |
%valuePtr.i.i.i27 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 3 | |
store i64 ptrtoint (void ()* @DISPSTACK to i64), i64* %valuePtr.i.i.i27 | |
%valuePtr.i.i.i23 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 4 | |
store i64 ptrtoint (void ()* @SWAP to i64), i64* %valuePtr.i.i.i23 | |
%valuePtr.i.i.i19 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 5 | |
store i64 ptrtoint (void ()* @DUP to i64), i64* %valuePtr.i.i.i19 | |
%valuePtr.i.i.i15 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 6 | |
store i64 ptrtoint (void ()* @DUP to i64), i64* %valuePtr.i.i.i15 | |
%valuePtr.i.i.i11 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 7 | |
store i64 ptrtoint (void ()* @MUL to i64), i64* %valuePtr.i.i.i11 | |
%valuePtr.i.i.i7 = getelementptr [1048576 x i64]* %heapPtr1, i32 0, i64 8 | |
store i64 ptrtoint (void ()* @DISPSTACK to i64), i64* %valuePtr.i.i.i7 | |
%value.i.i.i = load i64* %heapPtr1.sub | |
store i64 1, i64* @execIdx | |
%is_done.i = icmp eq i64 %value.i.i.i, 0 | |
br i1 %is_done.i, label %next.exit, label %execIns.i | |
execIns.i: ; preds = %0 | |
%functionPtr.i = inttoptr i64 %value.i.i.i to void ()* | |
call void %functionPtr.i() | |
br label %next.exit | |
next.exit: ; preds = %0, %execIns.i | |
ret i64 0 | |
} | |
attributes #0 = { nounwind } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment