diff --git a/kotstd/include/Assert.kt b/kotstd/include/Assert.kt new file mode 100644 index 00000000000..6f377396697 --- /dev/null +++ b/kotstd/include/Assert.kt @@ -0,0 +1,6 @@ +external fun assert_c(value: Boolean) + +fun assert(value: Boolean) { + println(value) + assert_c(value) +} \ No newline at end of file diff --git a/kotstd/lib/arm/assert_c.ll b/kotstd/lib/arm/assert_c.ll new file mode 100644 index 00000000000..ac836c118dc --- /dev/null +++ b/kotstd/lib/arm/assert_c.ll @@ -0,0 +1,12 @@ +; ModuleID = 'assert_arm.c' +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "thumbv7m-none--eabi" + +; Function Attrs: nounwind +define weak void @assert_c(i32 %value) #0 { + %1 = alloca i32, align 4 + store i32 %value, i32* %1, align 4 + ret void +} + +attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } diff --git a/kotstd/lib/x86/assert_c.ll b/kotstd/lib/x86/assert_c.ll new file mode 100644 index 00000000000..9f32a71fab7 --- /dev/null +++ b/kotstd/lib/x86/assert_c.ll @@ -0,0 +1,36 @@ +; ModuleID = 'assert_x86.c' +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@.str = private unnamed_addr constant [71 x i8] c"Exception in thread \22main\22 java.lang.AssertionError: Assertion failed\0A\00", align 1 + +; Function Attrs: nounwind uwtable +define void @assert_c(i32 %value) #0 { + %1 = alloca i32, align 4 + store i32 %value, i32* %1, align 4 + %2 = load i32* %1, align 4 + %3 = icmp ne i32 %2, 0 + br i1 %3, label %6, label %4 + +;