Created
March 16, 2020 14:27
-
-
Save yhara/f557dd110d782ee680d1144c5cd754a8 to your computer and use it in GitHub Desktop.
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 = 'examples/mandel.sk.bc' | |
source_filename = "main" | |
%Void = type <{}> | |
%Math = type <{}> | |
%Object = type <{}> | |
@"::ITER" = internal unnamed_addr global i1 false | |
@"::Void" = internal unnamed_addr global %Void* null | |
@"::LIMIT_SQUARED" = internal unnamed_addr global double 0.000000e+00 | |
; Function Attrs: nounwind | |
declare i32 @putchar(i32) local_unnamed_addr #0 | |
declare void @GC_init() local_unnamed_addr | |
declare i8* @GC_malloc(i64) local_unnamed_addr | |
declare double @sin(double) local_unnamed_addr | |
declare double @cos(double) local_unnamed_addr | |
declare double @sqrt(double) local_unnamed_addr | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Float#=="(double %self, double %other) local_unnamed_addr #1 { | |
%eq = fcmp oeq double %self, %other | |
ret i1 %eq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Float#!="(double %self, double %other) local_unnamed_addr #1 { | |
%neq = fcmp une double %self, %other | |
ret i1 %neq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Float#<"(double %self, double %other) local_unnamed_addr #1 { | |
%lt = fcmp olt double %self, %other | |
ret i1 %lt | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Float#>"(double %self, double %other) local_unnamed_addr #1 { | |
%gt = fcmp ogt double %self, %other | |
ret i1 %gt | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Float#<="(double %self, double %other) local_unnamed_addr #1 { | |
%leq = fcmp ole double %self, %other | |
ret i1 %leq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Float#>="(double %self, double %other) local_unnamed_addr #1 { | |
%geq = fcmp oge double %self, %other | |
ret i1 %geq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define double @"Float#+"(double %self, double %other) local_unnamed_addr #1 { | |
%add = fadd double %self, %other | |
ret double %add | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define double @"Float#-"(double %self, double %other) local_unnamed_addr #1 { | |
%sub = fsub double %self, %other | |
ret double %sub | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define double @"Float#*"(double %self, double %other) local_unnamed_addr #1 { | |
%mul = fmul double %self, %other | |
ret double %mul | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define double @"Float#/"(double %self, double %other) local_unnamed_addr #1 { | |
%div = fdiv double %self, %other | |
ret double %div | |
} | |
; Function Attrs: nounwind readnone | |
define double @"Float#abs"(double %self) local_unnamed_addr #2 { | |
%result = tail call double @llvm.fabs.f64(double %self) | |
ret double %result | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Float#to_i"(double %self) local_unnamed_addr #1 { | |
%int = fptosi double %self to i32 | |
ret i32 %int | |
} | |
define double @"Meta:Math#sin"(%Math* nocapture readnone %self, double %x) local_unnamed_addr { | |
%result = tail call double @sin(double %x) | |
ret double %result | |
} | |
define double @"Meta:Math#cos"(%Math* nocapture readnone %self, double %x) local_unnamed_addr { | |
%result = tail call double @cos(double %x) | |
ret double %result | |
} | |
define double @"Meta:Math#sqrt"(%Math* nocapture readnone %self, double %x) local_unnamed_addr { | |
%result = tail call double @sqrt(double %x) | |
ret double %result | |
} | |
; Function Attrs: nounwind | |
define void @"Object#putchar"(%Object* nocapture readnone %self, i32 %ord) local_unnamed_addr #0 { | |
%1 = tail call i32 @putchar(i32 %ord) | |
ret void | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Int#=="(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%eq = icmp eq i32 %self, %other | |
ret i1 %eq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Int#!="(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%neq = icmp ne i32 %self, %other | |
ret i1 %neq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Int#<"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%lt = icmp slt i32 %self, %other | |
ret i1 %lt | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Int#>"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%gt = icmp sgt i32 %self, %other | |
ret i1 %gt | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Int#<="(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%leq = icmp sle i32 %self, %other | |
ret i1 %leq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i1 @"Int#>="(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%geq = icmp sge i32 %self, %other | |
ret i1 %geq | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#+"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%add = add i32 %other, %self | |
ret i32 %add | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#-"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%sub = sub i32 %self, %other | |
ret i32 %sub | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#*"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%mul = mul i32 %other, %self | |
ret i32 %mul | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#/"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%div = sdiv i32 %self, %other | |
ret i32 %div | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#&"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%and = and i32 %other, %self | |
ret i32 %and | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#|"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%or = or i32 %other, %self | |
ret i32 %or | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#^"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%xor = xor i32 %other, %self | |
ret i32 %xor | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#<<"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%lshift = shl i32 %self, %other | |
ret i32 %lshift | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define i32 @"Int#>>"(i32 %self, i32 %other) local_unnamed_addr #1 { | |
%rshift = ashr i32 %self, %other | |
ret i32 %rshift | |
} | |
; Function Attrs: norecurse nounwind readnone | |
define double @"Int#to_f"(i32 %self) local_unnamed_addr #1 { | |
%float = sitofp i32 %self to double | |
ret double %float | |
} | |
define i32 @main() local_unnamed_addr { | |
tail call void @GC_init() | |
%raw_addr = tail call i8* @GC_malloc(i64 0) | |
%raw_addr1 = tail call i8* @GC_malloc(i64 0) | |
store i8* %raw_addr1, i8** bitcast (%Void** @"::Void" to i8**), align 8 | |
store i1 true, i1* @"::ITER", align 1 | |
store double 4.000000e+00, double* @"::LIMIT_SQUARED", align 8 | |
%1 = tail call i32 @putchar(i32 80) #0 | |
%2 = tail call i32 @putchar(i32 52) #0 | |
%3 = tail call i32 @putchar(i32 10) #0 | |
%4 = tail call i32 @putchar(i32 54) #0 | |
%5 = tail call i32 @putchar(i32 48) #0 | |
%6 = tail call i32 @putchar(i32 48) #0 | |
%7 = tail call i32 @putchar(i32 32) #0 | |
%8 = tail call i32 @putchar(i32 54) #0 | |
%9 = tail call i32 @putchar(i32 48) #0 | |
%10 = tail call i32 @putchar(i32 48) #0 | |
%11 = tail call i32 @putchar(i32 10) #0 | |
store i1 true, i1* @"::ITER", align 1 | |
store double 4.000000e+00, double* @"::LIMIT_SQUARED", align 8 | |
br label %WhileBegin7.preheader | |
WhileBegin7.preheader: ; preds = %0, %WhileEnd12 | |
%y.047 = phi i32 [ 0, %0 ], [ %add.i28, %WhileEnd12 ] | |
%byte_acc.046 = phi i32 [ 0, %0 ], [ %byte_acc.254, %WhileEnd12 ] | |
%bit_num.045 = phi i32 [ 0, %0 ], [ %bit_num.253, %WhileEnd12 ] | |
%float.i = sitofp i32 %y.047 to double | |
%mul.i30 = fmul double %float.i, 2.000000e+00 | |
%div.i = fdiv double %mul.i30, 6.000000e+02 | |
%sub.i29 = fadd double %div.i, -1.000000e+00 | |
br label %WhileBody11 | |
WhileEnd: ; preds = %WhileEnd12 | |
ret i32 0 | |
WhileBody11: ; preds = %WhileBegin7.preheader, %IfEnd70 | |
%byte_acc.144 = phi i32 [ %byte_acc.046, %WhileBegin7.preheader ], [ %byte_acc.2, %IfEnd70 ] | |
%bit_num.143 = phi i32 [ %bit_num.045, %WhileBegin7.preheader ], [ %bit_num.2, %IfEnd70 ] | |
%storemerge42 = phi i32 [ 0, %WhileBegin7.preheader ], [ %add.i, %IfEnd70 ] | |
%float.i34 = sitofp i32 %storemerge42 to double | |
%mul.i33 = fmul double %float.i34, 2.000000e+00 | |
%div.i32 = fdiv double %mul.i33, 6.000000e+02 | |
%sub.i31 = fadd double %div.i32, -1.500000e+00 | |
%"::LIMIT_SQUARED" = load double, double* @"::LIMIT_SQUARED", align 8 | |
%"::ITER.b" = load i1, i1* @"::ITER", align 1 | |
%"::ITER" = select i1 %"::ITER.b", i32 49, i32 0 | |
br label %WhileBody30 | |
WhileEnd12: ; preds = %IfEnd70, %IfEnd70.thread | |
%byte_acc.254 = phi i32 [ 0, %IfEnd70.thread ], [ %byte_acc.2, %IfEnd70 ] | |
%bit_num.253 = phi i32 [ 0, %IfEnd70.thread ], [ %bit_num.2, %IfEnd70 ] | |
%add.i28 = add nuw nsw i32 %y.047, 1 | |
%leq.i = icmp ult i32 %add.i28, 600 | |
br i1 %leq.i, label %WhileBegin7.preheader, label %WhileEnd | |
WhileBegin27: ; preds = %WhileBody30 | |
%add.i14 = add nuw nsw i32 %storemerge1237, 1 | |
%leq.i27 = icmp ult i32 %storemerge1237, %"::ITER" | |
br i1 %leq.i27, label %WhileBody30, label %WhileEnd31 | |
WhileBody30: ; preds = %WhileBegin27, %WhileBody11 | |
%add.i2040 = phi double [ 0.000000e+00, %WhileBody11 ], [ %add.i20, %WhileBegin27 ] | |
%add.i2338 = phi double [ 0.000000e+00, %WhileBody11 ], [ %add.i23, %WhileBegin27 ] | |
%storemerge1237 = phi i32 [ 0, %WhileBody11 ], [ %add.i14, %WhileBegin27 ] | |
%mul.i26 = fmul double %add.i2338, %add.i2338 | |
%mul.i25 = fmul double %add.i2040, %add.i2040 | |
%sub.i24 = fsub double %mul.i26, %mul.i25 | |
%add.i23 = fadd double %sub.i31, %sub.i24 | |
%mul.i22 = fmul double %add.i2338, 2.000000e+00 | |
%mul.i21 = fmul double %mul.i22, %add.i2040 | |
%add.i20 = fadd double %sub.i29, %mul.i21 | |
%mul.i19 = fmul double %add.i23, %add.i23 | |
%mul.i = fmul double %add.i20, %add.i20 | |
%add.i18 = fadd double %mul.i, %mul.i19 | |
%gt.i = fcmp ogt double %add.i18, %"::LIMIT_SQUARED" | |
br i1 %gt.i, label %WhileEnd31, label %WhileBegin27 | |
WhileEnd31: ; preds = %WhileBody30, %WhileBegin27 | |
%escape63 = phi i32 [ 1, %WhileBegin27 ], [ 0, %WhileBody30 ] | |
%lshift.i17 = shl i32 %byte_acc.144, 1 | |
%or.i = or i32 %lshift.i17, %escape63 | |
%add.i16 = add i32 %bit_num.143, 1 | |
%eq.i15 = icmp eq i32 %add.i16, 8 | |
br i1 %eq.i15, label %IfThen68, label %IfBegin74 | |
IfThen68: ; preds = %WhileEnd31 | |
%12 = tail call i32 @putchar(i32 %or.i) #0 | |
br label %IfEnd70 | |
IfEnd70: ; preds = %IfBegin74, %IfThen68 | |
%bit_num.2 = phi i32 [ 0, %IfThen68 ], [ %add.i16, %IfBegin74 ] | |
%byte_acc.2 = phi i32 [ 0, %IfThen68 ], [ %or.i, %IfBegin74 ] | |
%add.i = add nuw nsw i32 %storemerge42, 1 | |
%leq.i13 = icmp ult i32 %add.i, 600 | |
br i1 %leq.i13, label %WhileBody11, label %WhileEnd12 | |
IfBegin74: ; preds = %WhileEnd31 | |
%eq.i = icmp eq i32 %storemerge42, 599 | |
br i1 %eq.i, label %IfEnd70.thread, label %IfEnd70 | |
IfEnd70.thread: ; preds = %IfBegin74 | |
%sub.i = sub i32 7, %bit_num.143 | |
%lshift.i = shl i32 %or.i, %sub.i | |
%13 = tail call i32 @putchar(i32 %lshift.i) #0 | |
br label %WhileEnd12 | |
} | |
; Function Attrs: nounwind readnone speculatable | |
declare double @llvm.fabs.f64(double) #3 | |
attributes #0 = { nounwind } | |
attributes #1 = { norecurse nounwind readnone } | |
attributes #2 = { nounwind readnone } | |
attributes #3 = { nounwind readnone speculatable } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment