This commit is contained in:
e5l
2016-08-11 19:24:26 +03:00
19 changed files with 516 additions and 182 deletions
+4 -3
View File
@@ -1,3 +1,5 @@
external fun kotlinclib_boolean_size(): Int
class BooleanArray(var size: Int) {
val data: Int
@@ -5,7 +7,7 @@ class BooleanArray(var size: Int) {
//size: Int
init {
this.data = malloc_array(this.size)
this.data = malloc_array(kotlinclib_boolean_size() * this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
@@ -19,8 +21,7 @@ class BooleanArray(var size: Int) {
operator fun set(index: Int, value: Boolean) {
if (value == true) {
kotlinclib_set_byte(this.data, index, 1.toByte())
}
else{
} else {
kotlinclib_set_byte(this.data, index, 0.toByte())
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
external fun malloc_array(size: Int): Int
external fun kotlinclib_get_byte(src: Int, index: Int): Byte
external fun kotlinclib_set_byte(src: Int, index: Int, value: Byte)
external fun kotlinclib_byte_size(): Int
class ByteArray(var size: Int) {
@@ -10,7 +11,7 @@ class ByteArray(var size: Int) {
//size: Int
init {
this.data = malloc_array(this.size)
this.data = malloc_array(kotlinclib_byte_size() * this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
+2 -1
View File
@@ -1,5 +1,6 @@
external fun kotlinclib_get_int(src: Int, index: Int): Int
external fun kotlinclib_set_int(src: Int, index: Int, value: Int)
external fun kotlinclib_int_size(): Int
class IntArray(var size: Int) {
@@ -9,7 +10,7 @@ class IntArray(var size: Int) {
//size: Int
init {
this.data = malloc_array(4 * this.size)
this.data = malloc_array(kotlinclib_int_size() * this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
+92
View File
@@ -0,0 +1,92 @@
external fun kotlinclib_get_long(src: Int, index: Int): Long
external fun kotlinclib_set_long(src: Int, index: Int, value: Long)
external fun kotlinclib_long_size(): Int
class LongArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//size: Int
init {
this.data = malloc_array(kotlinclib_long_size() * this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
operator fun get(index: Int): Long {
return kotlinclib_get_long(this.data, index)
}
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
operator fun set(index: Int, value: Long) {
kotlinclib_set_long(this.data, index, value)
}
fun clone(): LongArray {
val newInstance = LongArray(this.size)
var index = 0
while (index < this.size) {
val value = this.get(index)
newInstance.set(index, value)
index = index + 1
}
return newInstance
}
}
fun LongArray.copyOf(newSize: Int): LongArray {
val newInstance = LongArray(newSize)
var index = 0
val end = if (newSize > this.size) this.size else newSize
while (index < end) {
val value = this.get(index)
newInstance.set(index, value)
index = index + 1
}
while (index < newSize) {
newInstance.set(index, 0)
index = index + 1
}
return newInstance
}
fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
val newInstance = LongArray(toIndex - fromIndex)
var index = fromIndex
while (index < toIndex) {
val value = this.get(index)
newInstance.set(index - fromIndex, value)
index = index + 1
}
return newInstance
}
operator fun LongArray.plus(element: Long): LongArray {
val index = size
val result = this.copyOf(index + 1)
result[index] = element
return result
}
operator fun LongArray.plus(elements: LongArray): LongArray {
val thisSize = size
val arraySize = elements.size
val resultSize = thisSize + arraySize
val newInstance = this.copyOf(resultSize)
var index = thisSize
while (index < resultSize) {
val value = elements.get(index - thisSize)
newInstance.set(index, value)
index = index + 1
}
return newInstance
}
+2 -1
View File
@@ -1,5 +1,6 @@
external fun kotlinclib_get_short(src: Int, index: Int): Short
external fun kotlinclib_set_short(src: Int, index: Int, value: Short)
external fun kotlinclib_short_size(): Int
class ShortArray(var size: Int) {
@@ -9,7 +10,7 @@ class ShortArray(var size: Int) {
//size: Int
init {
this.data = malloc_array(this.size)
this.data = malloc_array(kotlinclib_short_size() * this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
+45 -3
View File
@@ -2,18 +2,17 @@
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7m-none--eabi"
declare i8* @malloc_static(i32) #0
; Function Attrs: nounwind
define weak i32 @malloc_array(i32 %x) #0 {
%1 = alloca i32, align 4
store i32 %x, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = call i8* @malloc_static(i32 %2)
%3 = call i8* @malloc(i32 %2) #2
%4 = ptrtoint i8* %3 to i32
ret i32 %4
}
declare i8* @malloc(i32) #1
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_get_byte(i32 %data, i32 %index) #0 {
@@ -117,4 +116,47 @@ define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value
ret void
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_get_long(i32 %data, i32 %index) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 %data, i32* %1, align 4
store i32 %index, i32* %2, align 4
%3 = load i32* %1, align 4
%4 = inttoptr i32 %3 to i32*
%5 = load i32* %2, align 4
%6 = getelementptr inbounds i32* %4, i32 %5
%7 = load i32* %6, align 4
ret i32 %7
}
; Function Attrs: nounwind
define weak void @kotlinclib_set_long(i32 %data, i32 %index, i32 %value) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i32, align 4
%ptr = alloca i32*, align 4
store i32 %data, i32* %1, align 4
store i32 %index, i32* %2, align 4
store i32 %value, i32* %3, align 4
%4 = load i32* %1, align 4
%5 = inttoptr i32 %4 to i32*
store i32* %5, i32** %ptr, align 4
%6 = load i32* %3, align 4
%7 = load i32** %ptr, align 4
%8 = load i32* %2, align 4
%9 = getelementptr inbounds i32* %7, i32 %8
store i32 %6, i32* %9, 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" }
attributes #1 = { "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" }
attributes #2 = { nobuiltin }
!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, !"min_enum_size", i32 4}
!2 = !{!"Ubuntu clang version 3.6.2-3ubuntu2 (tags/RELEASE_362/final) (based on LLVM 3.6.2)"}
+19 -19
View File
@@ -3,133 +3,133 @@ 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 void @kotlinclib_print_int(i32 %message) #0 {
define weak void @kotlinclib_print_int(i32 %message) #0 {
%1 = alloca i32, align 4
store i32 %message, i32* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_long(i32 %message) #0 {
define weak void @kotlinclib_print_long(i32 %message) #0 {
%1 = alloca i32, align 4
store i32 %message, i32* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_byte(i8 zeroext %message) #0 {
define weak void @kotlinclib_print_byte(i8 zeroext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_short(i16 signext %message) #0 {
define weak void @kotlinclib_print_short(i16 signext %message) #0 {
%1 = alloca i16, align 2
store i16 %message, i16* %1, align 2
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_char(i8 zeroext %message) #0 {
define weak void @kotlinclib_print_char(i8 zeroext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_boolean(i1 %message) #0 {
define weak void @kotlinclib_print_boolean(i1 %message) #0 {
%1 = alloca i1, align 4
store i1 %message, i1* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_float(float %message) #0 {
define weak void @kotlinclib_print_float(float %message) #0 {
%1 = alloca float, align 4
store float %message, float* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_double(double %message) #0 {
define weak void @kotlinclib_print_double(double %message) #0 {
%1 = alloca double, align 8
store double %message, double* %1, align 8
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_print_string(i8* %message) #0 {
define weak void @kotlinclib_print_string(i8* %message) #0 {
%1 = alloca i8*, align 4
store i8* %message, i8** %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_int(i32 %message) #0 {
define weak void @kotlinclib_println_int(i32 %message) #0 {
%1 = alloca i32, align 4
store i32 %message, i32* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_long(i32 %message) #0 {
define weak void @kotlinclib_println_long(i32 %message) #0 {
%1 = alloca i32, align 4
store i32 %message, i32* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_byte(i8 zeroext %message) #0 {
define weak void @kotlinclib_println_byte(i8 zeroext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_short(i16 signext %message) #0 {
define weak void @kotlinclib_println_short(i16 signext %message) #0 {
%1 = alloca i16, align 2
store i16 %message, i16* %1, align 2
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_char(i8 zeroext %message) #0 {
define weak void @kotlinclib_println_char(i8 zeroext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_boolean(i1 %message) #0 {
define weak void @kotlinclib_println_boolean(i1 %message) #0 {
%1 = alloca i1, align 4
store i1 %message, i1* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_float(float %message) #0 {
define weak void @kotlinclib_println_float(float %message) #0 {
%1 = alloca float, align 4
store float %message, float* %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_double(double %message) #0 {
define weak void @kotlinclib_println_double(double %message) #0 {
%1 = alloca double, align 8
store double %message, double* %1, align 8
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println_string(i8* %message) #0 {
define weak void @kotlinclib_println_string(i8* %message) #0 {
%1 = alloca i8*, align 4
store i8* %message, i8** %1, align 4
ret void
}
; Function Attrs: nounwind
define void @kotlinclib_println() #0 {
define weak void @kotlinclib_println() #0 {
ret void
}
+43 -1
View File
@@ -260,7 +260,7 @@ define weak float @kotlinclib_longToFloat(i32 %value) #0 {
}
; Function Attrs: nounwind
define double @kotlinclib_longToDouble(i32 %value) #0 {
define weak double @kotlinclib_longToDouble(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
@@ -376,4 +376,46 @@ define weak float @kotlinclib_doubleToFloat(double %value) #0 {
ret float %3
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_int_size() #0 {
ret i32 4
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_long_size() #0 {
ret i32 8
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_boolean_size() #0 {
ret i32 1
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_short_size() #0 {
ret i32 2
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_double_size() #0 {
ret i32 8
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_float_size() #0 {
ret i32 4
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_char_size() #0 {
ret i32 1
}
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" }
!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, !"min_enum_size", i32 4}
!2 = !{!"Ubuntu clang version 3.6.2-3ubuntu2 (tags/RELEASE_362/final) (based on LLVM 3.6.2)"}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+58 -10
View File
@@ -1,16 +1,21 @@
declare i8* @malloc_static(i32)
; ModuleID = 'array.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: nounwind uwtable
define weak i32 @malloc_array(i32 %x) #0 {
%1 = alloca i32, align 4
store i32 %x, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = call i8* @malloc_static(i32 %2)
%3 = call i8* @malloc(i32 %2)
%4 = ptrtoint i8* %3 to i32
ret i32 %4
}
declare i8* @malloc(i32) #1
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_get_byte(i32 %data, i32 %index) {
define weak signext i8 @kotlinclib_get_byte(i32 %data, i32 %index) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 %data, i32* %1, align 4
@@ -26,7 +31,7 @@ define weak signext i8 @kotlinclib_get_byte(i32 %data, i32 %index) {
}
; Function Attrs: nounwind uwtable
define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value) {
define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i8, align 1
@@ -47,9 +52,8 @@ define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value)
ret void
}
; Function Attrs: nounwind uwtable
define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) {
define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 %data, i32* %1, align 4
@@ -65,7 +69,7 @@ define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) {
}
; Function Attrs: nounwind uwtable
define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) {
define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i32, align 4
@@ -86,9 +90,8 @@ define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) {
ret void
}
; Function Attrs: nounwind uwtable
define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) {
define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 %data, i32* %1, align 4
@@ -104,7 +107,7 @@ define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) {
}
; Function Attrs: nounwind uwtable
define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) {
define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i16, align 2
@@ -124,3 +127,48 @@ define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value
store i16 %7, i16* %11, align 2
ret void
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_get_long(i32 %data, i32 %index) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 %data, i32* %1, align 4
store i32 %index, i32* %2, align 4
%3 = load i32* %1, align 4
%4 = sext i32 %3 to i64
%5 = inttoptr i64 %4 to i64*
%6 = load i32* %2, align 4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i64* %5, i64 %7
%9 = load i64* %8, align 8
ret i64 %9
}
; Function Attrs: nounwind uwtable
define weak void @kotlinclib_set_long(i32 %data, i32 %index, i64 %value) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i64, align 8
%ptr = alloca i64*, align 8
store i32 %data, i32* %1, align 4
store i32 %index, i32* %2, align 4
store i64 %value, i64* %3, align 8
%4 = load i32* %1, align 4
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to i64*
store i64* %6, i64** %ptr, align 8
%7 = load i64* %3, align 8
%8 = load i64** %ptr, align 8
%9 = load i32* %2, align 4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i64* %8, i64 %10
store i64 %7, i64* %11, align 8
ret void
}
attributes #0 = { nounwind uwtable "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" }
attributes #1 = { "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" }
!llvm.ident = !{!0}
!0 = !{!"Ubuntu clang version 3.6.2-3ubuntu2 (tags/RELEASE_362/final) (based on LLVM 3.6.2)"}
+19 -19
View File
@@ -12,7 +12,7 @@ target triple = "x86_64-pc-linux-gnu"
@.str7 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_int(i32 %message) #0 {
define weak void @kotlinclib_print_int(i32 %message) #0 {
%1 = alloca i32, align 4
store i32 %message, i32* %1, align 4
%2 = load i32* %1, align 4
@@ -23,7 +23,7 @@ define void @kotlinclib_print_int(i32 %message) #0 {
declare i32 @printf(i8*, ...) #1
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_long(i64 %message) #0 {
define weak void @kotlinclib_print_long(i64 %message) #0 {
%1 = alloca i64, align 8
store i64 %message, i64* %1, align 8
%2 = load i64* %1, align 8
@@ -32,7 +32,7 @@ define void @kotlinclib_print_long(i64 %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_byte(i8 signext %message) #0 {
define weak void @kotlinclib_print_byte(i8 signext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
%2 = load i8* %1, align 1
@@ -42,7 +42,7 @@ define void @kotlinclib_print_byte(i8 signext %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_short(i16 signext %message) #0 {
define weak void @kotlinclib_print_short(i16 signext %message) #0 {
%1 = alloca i16, align 2
store i16 %message, i16* %1, align 2
%2 = load i16* %1, align 2
@@ -52,7 +52,7 @@ define void @kotlinclib_print_short(i16 signext %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_char(i8 signext %message) #0 {
define weak void @kotlinclib_print_char(i8 signext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
%2 = load i8* %1, align 1
@@ -62,7 +62,7 @@ define void @kotlinclib_print_char(i8 signext %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_boolean(i1 %message) #0 {
define weak void @kotlinclib_print_boolean(i1 %message) #0 {
%1 = alloca i1, align 4
store i1 %message, i1* %1, align 4
%2 = load i1* %1, align 4
@@ -82,7 +82,7 @@ define void @kotlinclib_print_boolean(i1 %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_float(float %message) #0 {
define weak void @kotlinclib_print_float(float %message) #0 {
%1 = alloca float, align 4
store float %message, float* %1, align 4
%2 = load float* %1, align 4
@@ -92,7 +92,7 @@ define void @kotlinclib_print_float(float %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_double(double %message) #0 {
define weak void @kotlinclib_print_double(double %message) #0 {
%1 = alloca double, align 8
store double %message, double* %1, align 8
%2 = load double* %1, align 8
@@ -101,7 +101,7 @@ define void @kotlinclib_print_double(double %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_print_string(i8* %message) #0 {
define weak void @kotlinclib_print_string(i8* %message) #0 {
%1 = alloca i8*, align 8
store i8* %message, i8** %1, align 8
%2 = load i8** %1, align 8
@@ -110,13 +110,13 @@ define void @kotlinclib_print_string(i8* %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println() #0 {
define weak void @kotlinclib_println() #0 {
call void @kotlinclib_print_char(i8 signext 10)
ret void
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_int(i32 %message) #0 {
define weak void @kotlinclib_println_int(i32 %message) #0 {
%1 = alloca i32, align 4
store i32 %message, i32* %1, align 4
%2 = load i32* %1, align 4
@@ -126,7 +126,7 @@ define void @kotlinclib_println_int(i32 %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_long(i64 %message) #0 {
define weak void @kotlinclib_println_long(i64 %message) #0 {
%1 = alloca i64, align 8
store i64 %message, i64* %1, align 8
%2 = load i64* %1, align 8
@@ -136,7 +136,7 @@ define void @kotlinclib_println_long(i64 %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_byte(i8 signext %message) #0 {
define weak void @kotlinclib_println_byte(i8 signext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
%2 = load i8* %1, align 1
@@ -146,7 +146,7 @@ define void @kotlinclib_println_byte(i8 signext %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_short(i16 signext %message) #0 {
define weak void @kotlinclib_println_short(i16 signext %message) #0 {
%1 = alloca i16, align 2
store i16 %message, i16* %1, align 2
%2 = load i16* %1, align 2
@@ -156,7 +156,7 @@ define void @kotlinclib_println_short(i16 signext %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_char(i8 signext %message) #0 {
define weak void @kotlinclib_println_char(i8 signext %message) #0 {
%1 = alloca i8, align 1
store i8 %message, i8* %1, align 1
%2 = load i8* %1, align 1
@@ -166,7 +166,7 @@ define void @kotlinclib_println_char(i8 signext %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_boolean(i1 %message) #0 {
define weak void @kotlinclib_println_boolean(i1 %message) #0 {
%1 = alloca i1, align 4
store i1 %message, i1* %1, align 4
%2 = load i1* %1, align 4
@@ -176,7 +176,7 @@ define void @kotlinclib_println_boolean(i1 %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_float(float %message) #0 {
define weak void @kotlinclib_println_float(float %message) #0 {
%1 = alloca float, align 4
store float %message, float* %1, align 4
%2 = load float* %1, align 4
@@ -186,7 +186,7 @@ define void @kotlinclib_println_float(float %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_double(double %message) #0 {
define weak void @kotlinclib_println_double(double %message) #0 {
%1 = alloca double, align 8
store double %message, double* %1, align 8
%2 = load double* %1, align 8
@@ -196,7 +196,7 @@ define void @kotlinclib_println_double(double %message) #0 {
}
; Function Attrs: nounwind uwtable
define void @kotlinclib_println_string(i8* %message) #0 {
define weak void @kotlinclib_println_string(i8* %message) #0 {
%1 = alloca i8*, align 8
store i8* %message, i8** %1, align 8
%2 = load i8** %1, align 8
+165 -124
View File
@@ -1,10 +1,9 @@
; ModuleID = 'primitives.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7m-none--eabi"
attributes #0 = { nounwind "stack-protector-buffer-size"="8" "target-cpu"="cortex-m3" "target-features"="+hwdiv,+strict-align" }
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_intToByte(i32 %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_intToByte(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
@@ -12,8 +11,8 @@ define weak signext i8 @kotlinclib_intToByte(i32 %value) #0 {
ret i8 %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_intToChar(i32 %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_intToChar(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
@@ -21,7 +20,7 @@ define weak signext i8 @kotlinclib_intToChar(i32 %value) #0 {
ret i8 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak signext i16 @kotlinclib_intToShort(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
@@ -30,16 +29,15 @@ define weak signext i16 @kotlinclib_intToShort(i32 %value) #0 {
ret i16 %3
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_intToLong(i32 %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_intToLong(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = sext i32 %2 to i64
ret i64 %3
ret i32 %2
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak float @kotlinclib_intToFloat(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
@@ -48,7 +46,7 @@ define weak float @kotlinclib_intToFloat(i32 %value) #0 {
ret float %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak double @kotlinclib_intToDouble(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
@@ -57,114 +55,114 @@ define weak double @kotlinclib_intToDouble(i32 %value) #0 {
ret double %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_byteToChar(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_byteToChar(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
ret i8 %2
}
; Function Attrs: nounwind uwtable
define weak signext i16 @kotlinclib_byteToShort(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak signext i16 @kotlinclib_byteToShort(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sext i8 %2 to i16
%3 = zext i8 %2 to i16
ret i16 %3
}
; Function Attrs: nounwind uwtable
define weak i32 @kotlinclib_byteToInt(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_byteToInt(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sext i8 %2 to i32
%3 = zext i8 %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_byteToLong(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_byteToLong(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sext i8 %2 to i64
ret i64 %3
%3 = zext i8 %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak float @kotlinclib_byteToFloat(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak float @kotlinclib_byteToFloat(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sitofp i8 %2 to float
%3 = uitofp i8 %2 to float
ret float %3
}
; Function Attrs: nounwind uwtable
define weak double @kotlinclib_byteToDouble(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak double @kotlinclib_byteToDouble(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sitofp i8 %2 to double
%3 = uitofp i8 %2 to double
ret double %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_charToByte(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_charToByte(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
ret i8 %2
}
; Function Attrs: nounwind uwtable
define weak signext i16 @kotlinclib_charToShort(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak signext i16 @kotlinclib_charToShort(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sext i8 %2 to i16
%3 = zext i8 %2 to i16
ret i16 %3
}
; Function Attrs: nounwind uwtable
define weak i32 @kotlinclib_charToInt(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_charToInt(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sext i8 %2 to i32
%3 = zext i8 %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_charToLong(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_charToLong(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sext i8 %2 to i64
ret i64 %3
%3 = zext i8 %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak float @kotlinclib_charToFloat(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak float @kotlinclib_charToFloat(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sitofp i8 %2 to float
%3 = uitofp i8 %2 to float
ret float %3
}
; Function Attrs: nounwind uwtable
define weak double @kotlinclib_charToDouble(i8 signext %value) #0 {
; Function Attrs: nounwind
define weak double @kotlinclib_charToDouble(i8 zeroext %value) #0 {
%1 = alloca i8, align 1
store i8 %value, i8* %1, align 1
%2 = load i8* %1, align 1
%3 = sitofp i8 %2 to double
%3 = uitofp i8 %2 to double
ret double %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
%1 = alloca i16, align 2
store i16 %value, i16* %1, align 2
%2 = load i16* %1, align 2
@@ -172,8 +170,8 @@ define weak signext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
ret i8 %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
%1 = alloca i16, align 2
store i16 %value, i16* %1, align 2
%2 = load i16* %1, align 2
@@ -181,7 +179,7 @@ define weak signext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
ret i8 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak i32 @kotlinclib_shortToInt(i16 signext %value) #0 {
%1 = alloca i16, align 2
store i16 %value, i16* %1, align 2
@@ -190,16 +188,16 @@ define weak i32 @kotlinclib_shortToInt(i16 signext %value) #0 {
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_shortToLong(i16 signext %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_shortToLong(i16 signext %value) #0 {
%1 = alloca i16, align 2
store i16 %value, i16* %1, align 2
%2 = load i16* %1, align 2
%3 = sext i16 %2 to i64
ret i64 %3
%3 = sext i16 %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak float @kotlinclib_shortToFloat(i16 signext %value) #0 {
%1 = alloca i16, align 2
store i16 %value, i16* %1, align 2
@@ -208,7 +206,7 @@ define weak float @kotlinclib_shortToFloat(i16 signext %value) #0 {
ret float %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak double @kotlinclib_shortToDouble(i16 signext %value) #0 {
%1 = alloca i16, align 2
store i16 %value, i16* %1, align 2
@@ -217,79 +215,78 @@ define weak double @kotlinclib_shortToDouble(i16 signext %value) #0 {
ret double %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_longToByte(i64 %value) #0 {
%1 = alloca i64, align 8
store i64 %value, i64* %1, align 8
%2 = load i64* %1, align 8
%3 = trunc i64 %2 to i8
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_longToByte(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = trunc i32 %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_longToChar(i64 %value) #0 {
%1 = alloca i64, align 8
store i64 %value, i64* %1, align 8
%2 = load i64* %1, align 8
%3 = trunc i64 %2 to i8
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_longToChar(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = trunc i32 %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
define weak signext i16 @kotlinclib_longToShort(i64 %value) #0 {
%1 = alloca i64, align 8
store i64 %value, i64* %1, align 8
%2 = load i64* %1, align 8
%3 = trunc i64 %2 to i16
; Function Attrs: nounwind
define weak signext i16 @kotlinclib_longToShort(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = trunc i32 %2 to i16
ret i16 %3
}
; Function Attrs: nounwind uwtable
define weak i32 @kotlinclib_longToInt(i64 %value) #0 {
%1 = alloca i64, align 8
store i64 %value, i64* %1, align 8
%2 = load i64* %1, align 8
%3 = trunc i64 %2 to i32
ret i32 %3
; Function Attrs: nounwind
define weak i32 @kotlinclib_longToInt(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
ret i32 %2
}
; Function Attrs: nounwind uwtable
define weak float @kotlinclib_longToFloat(i64 %value) #0 {
%1 = alloca i64, align 8
store i64 %value, i64* %1, align 8
%2 = load i64* %1, align 8
%3 = sitofp i64 %2 to float
; Function Attrs: nounwind
define weak float @kotlinclib_longToFloat(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = sitofp i32 %2 to float
ret float %3
}
; Function Attrs: nounwind uwtable
define weak double @kotlinclib_longToDouble(i64 %value) #0 {
%1 = alloca i64, align 8
store i64 %value, i64* %1, align 8
%2 = load i64* %1, align 8
%3 = sitofp i64 %2 to double
; Function Attrs: nounwind
define weak double @kotlinclib_longToDouble(i32 %value) #0 {
%1 = alloca i32, align 4
store i32 %value, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = sitofp i32 %2 to double
ret double %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_floatToByte(float %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_floatToByte(float %value) #0 {
%1 = alloca float, align 4
store float %value, float* %1, align 4
%2 = load float* %1, align 4
%3 = fptosi float %2 to i8
%3 = fptoui float %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_floatToChar(float %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_floatToChar(float %value) #0 {
%1 = alloca float, align 4
store float %value, float* %1, align 4
%2 = load float* %1, align 4
%3 = fptosi float %2 to i8
%3 = fptoui float %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak signext i16 @kotlinclib_floatToShort(float %value) #0 {
%1 = alloca float, align 4
store float %value, float* %1, align 4
@@ -298,7 +295,7 @@ define weak signext i16 @kotlinclib_floatToShort(float %value) #0 {
ret i16 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak i32 @kotlinclib_floatToInt(float %value) #0 {
%1 = alloca float, align 4
store float %value, float* %1, align 4
@@ -307,16 +304,16 @@ define weak i32 @kotlinclib_floatToInt(float %value) #0 {
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_floatToLong(float %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_floatToLong(float %value) #0 {
%1 = alloca float, align 4
store float %value, float* %1, align 4
%2 = load float* %1, align 4
%3 = fptosi float %2 to i64
ret i64 %3
%3 = fptosi float %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak double @kotlinclib_floatToDouble(float %value) #0 {
%1 = alloca float, align 4
store float %value, float* %1, align 4
@@ -325,25 +322,25 @@ define weak double @kotlinclib_floatToDouble(float %value) #0 {
ret double %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_doubleToByte(double %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_doubleToByte(double %value) #0 {
%1 = alloca double, align 8
store double %value, double* %1, align 8
%2 = load double* %1, align 8
%3 = fptosi double %2 to i8
%3 = fptoui double %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
define weak signext i8 @kotlinclib_doubleToChar(double %value) #0 {
; Function Attrs: nounwind
define weak zeroext i8 @kotlinclib_doubleToChar(double %value) #0 {
%1 = alloca double, align 8
store double %value, double* %1, align 8
%2 = load double* %1, align 8
%3 = fptosi double %2 to i8
%3 = fptoui double %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak signext i16 @kotlinclib_doubleToShort(double %value) #0 {
%1 = alloca double, align 8
store double %value, double* %1, align 8
@@ -352,7 +349,7 @@ define weak signext i16 @kotlinclib_doubleToShort(double %value) #0 {
ret i16 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak i32 @kotlinclib_doubleToInt(double %value) #0 {
%1 = alloca double, align 8
store double %value, double* %1, align 8
@@ -361,16 +358,16 @@ define weak i32 @kotlinclib_doubleToInt(double %value) #0 {
ret i32 %3
}
; Function Attrs: nounwind uwtable
define weak i64 @kotlinclib_doubleToLong(double %value) #0 {
; Function Attrs: nounwind
define weak i32 @kotlinclib_doubleToLong(double %value) #0 {
%1 = alloca double, align 8
store double %value, double* %1, align 8
%2 = load double* %1, align 8
%3 = fptosi double %2 to i64
ret i64 %3
%3 = fptosi double %2 to i32
ret i32 %3
}
; Function Attrs: nounwind uwtable
; Function Attrs: nounwind
define weak float @kotlinclib_doubleToFloat(double %value) #0 {
%1 = alloca double, align 8
store double %value, double* %1, align 8
@@ -378,3 +375,47 @@ define weak float @kotlinclib_doubleToFloat(double %value) #0 {
%3 = fptrunc double %2 to float
ret float %3
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_int_size() #0 {
ret i32 4
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_long_size() #0 {
ret i32 4
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_boolean_size() #0 {
ret i32 1
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_short_size() #0 {
ret i32 2
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_double_size() #0 {
ret i32 8
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_float_size() #0 {
ret i32 4
}
; Function Attrs: nounwind
define weak i32 @kotlinclib_char_size() #0 {
ret i32 1
}
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" }
!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, !"min_enum_size", i32 4}
!2 = !{!"Ubuntu clang version 3.6.2-3ubuntu2 (tags/RELEASE_362/final) (based on LLVM 3.6.2)"}
@@ -18,6 +18,30 @@ class LLVMDoubleType() : LLVMType() {
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fadd double $firstOp, $secondOp")
override fun operatorInc(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fadd double $firstOp, 1.0")
override fun operatorDec(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fsub double $firstOp, 1.0")
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp olt double $firstOp, $secondOp")
override fun operatorGt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp ogt double $firstOp, $secondOp")
override fun operatorLeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp ole double i32 $firstOp, $secondOp")
override fun operatorGeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp oge double i32 $firstOp, $secondOp")
override fun operatorEq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp oeq double $firstOp, $secondOp")
override fun operatorNeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp one double $firstOp, $secondOp")
override fun equals(other: Any?): Boolean {
return other is LLVMDoubleType
}
@@ -18,6 +18,30 @@ class LLVMFloatType() : LLVMType() {
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMFloatType(), "fadd float $firstOp, $secondOp")
override fun operatorInc(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fadd float $firstOp, 1.0")
override fun operatorDec(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fsub float $firstOp, 1.0")
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp olt float $firstOp, $secondOp")
override fun operatorGt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp ogt float $firstOp, $secondOp")
override fun operatorLeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp ole float i32 $firstOp, $secondOp")
override fun operatorGeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp oge float i32 $firstOp, $secondOp")
override fun operatorEq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp oeq float $firstOp, $secondOp")
override fun operatorNeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "fcmp one float $firstOp, $secondOp")
override fun equals(other: Any?): Boolean {
return other is LLVMFloatType
}
@@ -28,4 +28,7 @@ class LLVMReferenceType(val type: String, var prefix: String = "", override val
override fun operatorEq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "icmp eq ${firstOp.getType()} $firstOp, ${if (secondOp.type is LLVMNullType) "null" else "$secondOp"}")
override fun operatorNeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "icmp neq ${firstOp.getType()} $firstOp, ${if (secondOp.type is LLVMNullType) "null" else "$secondOp"}")
}
@@ -0,0 +1,2 @@
floating_point_operators_1_double_leq_Double_Double(14.9301, 5.6) == 0
floating_point_operators_1_double_leq_Double_Double(1.49301, 5.6) == 1
@@ -0,0 +1,12 @@
fun floating_point_operators_1_double_leq(x: Double, y: Double): Int {
if (x < y){
return 1
}
else{
return 0
}
}
fun floating_point_operators_1_getValue(b: Boolean): Boolean{
return b
}