From c1b8bcb51753b4b96fd51dc6033c7d1c9e0ab85c Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Fri, 2 Sep 2016 18:53:00 +0300 Subject: [PATCH] translator: make fully auto generated .ll in kotlin native lib --- kotstd/Makefile | 31 +- kotstd/include/BooleanArray.kt | 10 +- kotstd/include/ByteArray.kt | 10 +- kotstd/include/IntArray.kt | 9 +- kotstd/include/LongArray.kt | 8 +- kotstd/include/ShortArray.kt | 8 +- kotstd/lib/arm/array_c.ll | 155 ------- kotstd/lib/arm/assert_c.ll | 12 - kotstd/lib/arm/console_c.ll | 136 ------ kotstd/lib/arm/primitives_c.ll | 419 ----------------- kotstd/lib/x86/array_c.ll | 176 -------- kotstd/lib/x86/assert_c.ll | 36 -- kotstd/lib/x86/console_c.ll | 213 --------- kotstd/lib/x86/primitives_c.ll | 425 ------------------ kotstd/libc/arm.c | 11 + kotstd/libc/array_c.c | 45 +- kotstd/libc/assert_c.c | 12 +- kotstd/libc/console_c.c | 92 ++++ kotstd/libc/primitives_c.c | 37 +- .../translator/codegens/BlockCodegen.kt | 9 +- .../translator/codegens/FunctionCodegen.kt | 2 +- 21 files changed, 231 insertions(+), 1625 deletions(-) delete mode 100644 kotstd/lib/arm/array_c.ll delete mode 100644 kotstd/lib/arm/assert_c.ll delete mode 100644 kotstd/lib/arm/console_c.ll delete mode 100644 kotstd/lib/arm/primitives_c.ll delete mode 100644 kotstd/lib/x86/array_c.ll delete mode 100644 kotstd/lib/x86/assert_c.ll delete mode 100644 kotstd/lib/x86/console_c.ll delete mode 100644 kotstd/lib/x86/primitives_c.ll create mode 100644 kotstd/libc/arm.c create mode 100644 kotstd/libc/console_c.c diff --git a/kotstd/Makefile b/kotstd/Makefile index fdd6cf55107..56b86a69890 100644 --- a/kotstd/Makefile +++ b/kotstd/Makefile @@ -1,32 +1,37 @@ BUILD_DIR=$(PWD)/build INCLUDE_DIR=$(PWD)/include -LIB_ARM_DIR=$(PWD)/lib/arm -LIB_X86_DIR=$(PWD)/lib/x86 +LIB_DIR=$(PWD)/lib +LIB_ARM_DIR=$(LIB_DIR)/arm +LIB_X86_DIR=$(LIB_DIR)/x86 LIBC=$(PWD)/libc +LLVM_ARM_FILES = $(patsubst $(LIBC)/%.c,$(LIB_ARM_DIR)/%.ll,$(wildcard $(LIBC)/*.c)) +LLVM_X86_FILES = $(patsubst $(LIBC)/%.c,$(LIB_X86_DIR)/%.ll,$(wildcard $(LIBC)/*.c)) KT=$(PWD)/../translator/build/libs/translator-1.0.jar LLINK=llvm-link-3.6 CC=clang-3.6 -CCFLAGS_ARM=-g -S -Wall -m32 -emit-llvm -nostdlib -ffreestanding -march=armv7-m -mthumb -flto -O0 -target arm-none-eabi -DARM -CCFLAGS=-g -O0 -S -Wall -emit-llvm -nostdlib -ffreestanding +CCFLAGS_ARM=-g -S -Wall -m32 -emit-llvm -nostdlib -ffreestanding -march=armv7-m -mthumb -flto -O0 -target arm-none-eabi -DARM -Wno-int-to-pointer-cast -Wno-gcc-compat +CCFLAGS=-g -O0 -S -Wall -emit-llvm -nostdlib -ffreestanding -Wno-int-to-pointer-cast -Wno-gcc-compat CCFLAGS_DEBUG=-g -O0 -S -Wall -emit-llvm -nostdlib -ffreestanding -DDBG LLINK_FLAGS=-S KT_ALL_DEPS=java -jar $(KT) LLINK_ALL_DEPS=$(LLINK) $(LLINK_FLAGS) $(filter %.ll,$^) > $@ -all: memory $(BUILD_DIR) $(BUILD_DIR)/stdlib_arm.ll $(BUILD_DIR)/stdlib_x86.ll +all: $(BUILD_DIR) $(BUILD_DIR)/stdlib_arm.ll $(BUILD_DIR)/stdlib_x86.ll debug: memory_debug $(BUILD_DIR) $(BUILD_DIR)/stdlib_arm.ll $(BUILD_DIR)/stdlib_x86.ll $(BUILD_DIR): mkdir -p $(BUILD_DIR) + mkdir -p $(LIB_ARM_DIR) + mkdir -p $(LIB_X86_DIR) -$(BUILD_DIR)/stdlib_x86.ll: $(LIB_X86_DIR)/*.ll +$(BUILD_DIR)/stdlib_arm.ll: $(LLVM_ARM_FILES) $(LLINK_ALL_DEPS) -$(BUILD_DIR)/stdlib_arm.ll: $(LIB_ARM_DIR)/*.ll +$(BUILD_DIR)/stdlib_x86.ll: $(LLVM_X86_FILES) $(LLINK_ALL_DEPS) $(BUILD_DIR)/classes_x86.ll: $(INCLUDE_DIR)/*.kt @@ -35,15 +40,21 @@ $(BUILD_DIR)/classes_x86.ll: $(INCLUDE_DIR)/*.kt $(BUILD_DIR)/classes_arm.ll: $(INCLUDE_DIR)/*.kt $(KT_ALL_DEPS) --arm -o $@ $(filter %.kt,$^) -memory: - $(CC) $(CCFLAGS) $(LIBC)/memory.c -o $(LIB_X86_DIR)/memory.ll - $(CC) $(CCFLAGS_ARM) $(LIBC)/memory.c -o $(LIB_ARM_DIR)/memory.ll +$(LIB_X86_DIR)/%.ll: $(LIBC)/%.c + $(CC) $(CCFLAGS) -c $< -o $(LIB_X86_DIR)/$(basename $(notdir $<)).ll + +$(LIB_ARM_DIR)/%.ll: $(LIBC)/%.c + $(CC) $(CCFLAGS_ARM) -c $< -o $(LIB_ARM_DIR)/$(basename $(notdir $<)).ll memory_debug: $(CC) $(CCFLAGS_DEBUG) $(LIBC)/memory.c -o $(LIB_X86_DIR)/memory.ll clean: rm -rf $(BUILD_DIR) + rm -rf $(LIB_DIR) + +aaa: + @echo $(LLVM_ARM_FILES) .PHONY: all clean diff --git a/kotstd/include/BooleanArray.kt b/kotstd/include/BooleanArray.kt index 9c34c90ca11..8a6da5a3095 100644 --- a/kotstd/include/BooleanArray.kt +++ b/kotstd/include/BooleanArray.kt @@ -1,5 +1,7 @@ package kotlin +external fun kotlinclib_boolean_array_get_ix(dataRawPtr: Int, index: Int): Byte +external fun kotlinclib_boolean_array_set_ix(dataRawPtr: Int, index: Int, value: Byte) external fun kotlinclib_boolean_size(): Int class BooleanArray(var size: Int) { @@ -19,7 +21,7 @@ class BooleanArray(var size: Int) { /** Returns the array element at the given [index]. This method can be called using the index operator. */ operator fun get(index: Int): Boolean { - val res = kotlinclib_get_byte(this.dataRawPtr, index) == 1.toByte() + val res = kotlinclib_boolean_array_get_ix(this.dataRawPtr, index) == 1.toByte() return res } @@ -27,9 +29,9 @@ class BooleanArray(var size: Int) { /** 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: Boolean) { if (value == true) { - kotlinclib_set_byte(this.dataRawPtr, index, 1.toByte()) + kotlinclib_boolean_array_set_ix(this.dataRawPtr, index, 1.toByte()) } else { - kotlinclib_set_byte(this.dataRawPtr, index, 0.toByte()) + kotlinclib_boolean_array_set_ix(this.dataRawPtr, index, 0.toByte()) } } @@ -52,7 +54,7 @@ fun BooleanArray.print() { while (index < size) { print(get(index)) index++ - if (index < size){ + if (index < size) { print(';') print(' ') } diff --git a/kotstd/include/ByteArray.kt b/kotstd/include/ByteArray.kt index b222fd43e99..6543e0f6d8a 100644 --- a/kotstd/include/ByteArray.kt +++ b/kotstd/include/ByteArray.kt @@ -1,8 +1,8 @@ package kotlin 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_array_get_ix(dataRawPtr: Int, index: Int): Byte +external fun kotlinclib_byte_array_set_ix(dataRawPtr: Int, index: Int, value: Byte) external fun kotlinclib_byte_size(): Int @@ -24,13 +24,13 @@ class ByteArray(var size: Int) { /** Returns the array element at the given [index]. This method can be called using the index operator. */ operator fun get(index: Int): Byte { - return kotlinclib_get_byte(this.dataRawPtr, index) + return kotlinclib_byte_array_get_ix(this.dataRawPtr, 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: Byte) { - kotlinclib_set_byte(this.dataRawPtr, index, value) + kotlinclib_byte_array_set_ix(this.dataRawPtr, index, value) } @@ -54,7 +54,7 @@ fun ByteArray.print() { while (index < size) { print(get(index)) index++ - if (index < size){ + if (index < size) { print(';') print(' ') } diff --git a/kotstd/include/IntArray.kt b/kotstd/include/IntArray.kt index da6b43d9a94..52cb222b767 100644 --- a/kotstd/include/IntArray.kt +++ b/kotstd/include/IntArray.kt @@ -1,13 +1,14 @@ package kotlin -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_array_get_ix(dataRawPtr: Int, index: Int): Int +external fun kotlinclib_int_array_set_ix(dataRawPtr: Int, index: Int, value: Int) external fun kotlinclib_int_size(): Int class IntArray(var size: Int) { val dataRawPtr: Int + //[TODO move up] /** Returns the number of elements in the array. */ //size: Int @@ -22,13 +23,13 @@ class IntArray(var size: Int) { /** Returns the array element at the given [index]. This method can be called using the index operator. */ operator fun get(index: Int): Int { - return kotlinclib_get_int(this.dataRawPtr, index) + return kotlinclib_int_array_get_ix(this.dataRawPtr, 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: Int) { - kotlinclib_set_int(this.dataRawPtr, index, value) + kotlinclib_int_array_set_ix(this.dataRawPtr, index, value) } diff --git a/kotstd/include/LongArray.kt b/kotstd/include/LongArray.kt index e06dbf57f20..c5953e5b741 100644 --- a/kotstd/include/LongArray.kt +++ b/kotstd/include/LongArray.kt @@ -1,7 +1,7 @@ package kotlin -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_array_get_ix(dataRawPtr: Int, index: Int): Long +external fun kotlinclib_long_array_set_ix(dataRawPtr: Int, index: Int, value: Long) external fun kotlinclib_long_size(): Int @@ -22,13 +22,13 @@ class LongArray(var size: Int) { /** 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.dataRawPtr, index) + return kotlinclib_long_array_get_ix(this.dataRawPtr, 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.dataRawPtr, index, value) + kotlinclib_long_array_set_ix(this.dataRawPtr, index, value) } diff --git a/kotstd/include/ShortArray.kt b/kotstd/include/ShortArray.kt index b3225f57086..7b7023ba9af 100644 --- a/kotstd/include/ShortArray.kt +++ b/kotstd/include/ShortArray.kt @@ -1,7 +1,7 @@ package kotlin -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_array_get_ix(dataRawPtr: Int, index: Int): Short +external fun kotlinclib_short_array_set_ix(dataRawPtr: Int, index: Int, value: Short) external fun kotlinclib_short_size(): Int @@ -22,13 +22,13 @@ class ShortArray(var size: Int) { /** Returns the array element at the given [index]. This method can be called using the index operator. */ operator fun get(index: Int): Short { - return kotlinclib_get_short(this.dataRawPtr, index) + return kotlinclib_short_array_get_ix(this.dataRawPtr, 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: Short) { - kotlinclib_set_short(this.dataRawPtr, index, value) + kotlinclib_short_array_set_ix(this.dataRawPtr, index, value) } diff --git a/kotstd/lib/arm/array_c.ll b/kotstd/lib/arm/array_c.ll deleted file mode 100644 index 259acac1d4e..00000000000 --- a/kotstd/lib/arm/array_c.ll +++ /dev/null @@ -1,155 +0,0 @@ -; ModuleID = 'array.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 i32 @kotlin.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_heap(i32 %2) #2 - %4 = ptrtoint i8* %3 to i32 - ret i32 %4 -} - -declare i8* @malloc_heap(i32) #1 - -; Function Attrs: nounwind -define weak zeroext i8 @kotlin.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 - store i32 %index, i32* %2, align 4 - %3 = load i32* %1, align 4 - %4 = inttoptr i32 %3 to i8* - %5 = load i32* %2, align 4 - %6 = getelementptr inbounds i8* %4, i32 %5 - %7 = load i8* %6, align 1 - ret i8 %7 -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_set_byte(i32 %data, i32 %index, i8 zeroext %value) #0 { - %1 = alloca i32, align 4 - %2 = alloca i32, align 4 - %3 = alloca i8, align 1 - %ptr = alloca i8*, align 4 - store i32 %data, i32* %1, align 4 - store i32 %index, i32* %2, align 4 - store i8 %value, i8* %3, align 1 - %4 = load i32* %1, align 4 - %5 = inttoptr i32 %4 to i8* - store i8* %5, i8** %ptr, align 4 - %6 = load i8* %3, align 1 - %7 = load i8** %ptr, align 4 - %8 = load i32* %2, align 4 - %9 = getelementptr inbounds i8* %7, i32 %8 - store i8 %6, i8* %9, align 1 - ret void -} - -; Function Attrs: nounwind -define weak i32 @kotlin.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 - 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 @kotlin.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 - %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 -} - -; Function Attrs: nounwind -define weak signext i16 @kotlin.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 - store i32 %index, i32* %2, align 4 - %3 = load i32* %1, align 4 - %4 = inttoptr i32 %3 to i16* - %5 = load i32* %2, align 4 - %6 = getelementptr inbounds i16* %4, i32 %5 - %7 = load i16* %6, align 2 - ret i16 %7 -} - -; Function Attrs: nounwind -define weak void @kotlin.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 - %ptr = alloca i16*, align 4 - store i32 %data, i32* %1, align 4 - store i32 %index, i32* %2, align 4 - store i16 %value, i16* %3, align 2 - %4 = load i32* %1, align 4 - %5 = inttoptr i32 %4 to i16* - store i16* %5, i16** %ptr, align 4 - %6 = load i16* %3, align 2 - %7 = load i16** %ptr, align 4 - %8 = load i32* %2, align 4 - %9 = getelementptr inbounds i16* %7, i32 %8 - store i16 %6, i16* %9, align 2 - ret void -} - -; Function Attrs: nounwind -define weak i32 @kotlin.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 @kotlin.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-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-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 } diff --git a/kotstd/lib/arm/assert_c.ll b/kotstd/lib/arm/assert_c.ll deleted file mode 100644 index 5460e0f8de1..00000000000 --- a/kotstd/lib/arm/assert_c.ll +++ /dev/null @@ -1,12 +0,0 @@ -; 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 @kotlin.assert_c(i1 %value) #0 { - %1 = alloca i1, align 4 - store i1 %value, i1* %1, align 4 - ret void -} - -attributes #0 = { nounwind "less-precise-fpmad"="false" "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/arm/console_c.ll b/kotstd/lib/arm/console_c.ll deleted file mode 100644 index 1c9a64a230f..00000000000 --- a/kotstd/lib/arm/console_c.ll +++ /dev/null @@ -1,136 +0,0 @@ -; ModuleID = 'console_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 @kotlin.kotlinclib_print_int(i32 %message) #0 { - %1 = alloca i32, align 4 - store i32 %message, i32* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_print_long(i32 %message) #0 { - %1 = alloca i32, align 4 - store i32 %message, i32* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.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 weak void @kotlin.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 weak void @kotlin.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 weak void @kotlin.kotlinclib_print_boolean(i1 %message) #0 { - %1 = alloca i1, align 4 - store i1 %message, i1* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_print_float(float %message) #0 { - %1 = alloca float, align 4 - store float %message, float* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_print_double(double %message) #0 { - %1 = alloca double, align 8 - store double %message, double* %1, align 8 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_print_string(i8* %message) #0 { - %1 = alloca i8*, align 4 - store i8* %message, i8** %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_println_int(i32 %message) #0 { - %1 = alloca i32, align 4 - store i32 %message, i32* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_println_long(i32 %message) #0 { - %1 = alloca i32, align 4 - store i32 %message, i32* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.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 weak void @kotlin.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 weak void @kotlin.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 weak void @kotlin.kotlinclib_println_boolean(i1 %message) #0 { - %1 = alloca i1, align 4 - store i1 %message, i1* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_println_float(float %message) #0 { - %1 = alloca float, align 4 - store float %message, float* %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_println_double(double %message) #0 { - %1 = alloca double, align 8 - store double %message, double* %1, align 8 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_println_string(i8* %message) #0 { - %1 = alloca i8*, align 4 - store i8* %message, i8** %1, align 4 - ret void -} - -; Function Attrs: nounwind -define weak void @kotlin.kotlinclib_println() #0 { - ret void -} - -attributes #0 = { nounwind "less-precise-fpmad"="false" "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/arm/primitives_c.ll b/kotstd/lib/arm/primitives_c.ll deleted file mode 100644 index 8dfd9c89f2a..00000000000 --- a/kotstd/lib/arm/primitives_c.ll +++ /dev/null @@ -1,419 +0,0 @@ -; ModuleID = 'primitives.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 zeroext i8 @kotlin.kotlinclib_intToByte(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 -define zeroext i8 @kotlin.kotlinclib_intToChar(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 -define signext i16 @kotlin.kotlinclib_intToShort(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 -define i32 @kotlin.kotlinclib_intToLong(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 -define float @kotlin.kotlinclib_intToFloat(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 -define double @kotlin.kotlinclib_intToDouble(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 -define zeroext i8 @kotlin.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 -define signext i16 @kotlin.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 = zext i8 %2 to i16 - ret i16 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 = zext i8 %2 to i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 = zext i8 %2 to i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define float @kotlin.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 = uitofp i8 %2 to float - ret float %3 -} - -; Function Attrs: nounwind -define double @kotlin.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 = uitofp i8 %2 to double - ret double %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.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 -define signext i16 @kotlin.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 = zext i8 %2 to i16 - ret i16 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 = zext i8 %2 to i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 = zext i8 %2 to i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define float @kotlin.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 = uitofp i8 %2 to float - ret float %3 -} - -; Function Attrs: nounwind -define double @kotlin.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 = uitofp i8 %2 to double - ret double %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.kotlinclib_shortToByte(i16 signext %value) #0 { - %1 = alloca i16, align 2 - store i16 %value, i16* %1, align 2 - %2 = load i16* %1, align 2 - %3 = trunc i16 %2 to i8 - ret i8 %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.kotlinclib_shortToChar(i16 signext %value) #0 { - %1 = alloca i16, align 2 - store i16 %value, i16* %1, align 2 - %2 = load i16* %1, align 2 - %3 = trunc i16 %2 to i8 - ret i8 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_shortToInt(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 i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define float @kotlin.kotlinclib_shortToFloat(i16 signext %value) #0 { - %1 = alloca i16, align 2 - store i16 %value, i16* %1, align 2 - %2 = load i16* %1, align 2 - %3 = sitofp i16 %2 to float - ret float %3 -} - -; Function Attrs: nounwind -define double @kotlin.kotlinclib_shortToDouble(i16 signext %value) #0 { - %1 = alloca i16, align 2 - store i16 %value, i16* %1, align 2 - %2 = load i16* %1, align 2 - %3 = sitofp i16 %2 to double - ret double %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.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 -define zeroext i8 @kotlin.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 -define signext i16 @kotlin.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 -define i32 @kotlin.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 -define float @kotlin.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 -define double @kotlin.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 -define zeroext i8 @kotlin.kotlinclib_floatToByte(float %value) #0 { - %1 = alloca float, align 4 - store float %value, float* %1, align 4 - %2 = load float* %1, align 4 - %3 = fptoui float %2 to i8 - ret i8 %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.kotlinclib_floatToChar(float %value) #0 { - %1 = alloca float, align 4 - store float %value, float* %1, align 4 - %2 = load float* %1, align 4 - %3 = fptoui float %2 to i8 - ret i8 %3 -} - -; Function Attrs: nounwind -define signext i16 @kotlin.kotlinclib_floatToShort(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 i16 - ret i16 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_floatToInt(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 i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define double @kotlin.kotlinclib_floatToDouble(float %value) #0 { - %1 = alloca float, align 4 - store float %value, float* %1, align 4 - %2 = load float* %1, align 4 - %3 = fpext float %2 to double - ret double %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.kotlinclib_doubleToByte(double %value) #0 { - %1 = alloca double, align 8 - store double %value, double* %1, align 8 - %2 = load double* %1, align 8 - %3 = fptoui double %2 to i8 - ret i8 %3 -} - -; Function Attrs: nounwind -define zeroext i8 @kotlin.kotlinclib_doubleToChar(double %value) #0 { - %1 = alloca double, align 8 - store double %value, double* %1, align 8 - %2 = load double* %1, align 8 - %3 = fptoui double %2 to i8 - ret i8 %3 -} - -; Function Attrs: nounwind -define signext i16 @kotlin.kotlinclib_doubleToShort(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 i16 - ret i16 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_doubleToInt(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 i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.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 i32 - ret i32 %3 -} - -; Function Attrs: nounwind -define float @kotlin.kotlinclib_doubleToFloat(double %value) #0 { - %1 = alloca double, align 8 - store double %value, double* %1, align 8 - %2 = load double* %1, align 8 - %3 = fptrunc double %2 to float - ret float %3 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_int_size() #0 { - ret i32 4 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_long_size() #0 { - ret i32 4 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_boolean_size() #0 { - ret i32 1 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_short_size() #0 { - ret i32 2 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_double_size() #0 { - ret i32 8 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_float_size() #0 { - ret i32 4 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_char_size() #0 { - ret i32 1 -} - -; Function Attrs: nounwind -define i32 @kotlin.kotlinclib_byte_size() #0 { - ret i32 1 -} - -attributes #0 = { nounwind "less-precise-fpmad"="false" "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/array_c.ll b/kotstd/lib/x86/array_c.ll deleted file mode 100644 index 64e40f0fbd0..00000000000 --- a/kotstd/lib/x86/array_c.ll +++ /dev/null @@ -1,176 +0,0 @@ -; ModuleID = 'array.c' -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-linux-gnu" - -declare i8* @malloc_heap(i32) #1 - -; Function Attrs: nounwind uwtable -define weak i32 @kotlin.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_heap(i32 %2) - %4 = ptrtoint i8* %3 to i32 - ret i32 %4 -} - -declare i8* @malloc(i32) #1 - -; Function Attrs: nounwind uwtable -define weak signext i8 @kotlin.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 - store i32 %index, i32* %2, align 4 - %3 = load i32* %1, align 4 - %4 = sext i32 %3 to i64 - %5 = inttoptr i64 %4 to i8* - %6 = load i32* %2, align 4 - %7 = sext i32 %6 to i64 - %8 = getelementptr inbounds i8* %5, i64 %7 - %9 = load i8* %8, align 1 - ret i8 %9 -} - -; Function Attrs: nounwind uwtable -define weak void @kotlin.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 - %ptr = alloca i8*, align 8 - store i32 %data, i32* %1, align 4 - store i32 %index, i32* %2, align 4 - store i8 %value, i8* %3, align 1 - %4 = load i32* %1, align 4 - %5 = sext i32 %4 to i64 - %6 = inttoptr i64 %5 to i8* - store i8* %6, i8** %ptr, align 8 - %7 = load i8* %3, align 1 - %8 = load i8** %ptr, align 8 - %9 = load i32* %2, align 4 - %10 = sext i32 %9 to i64 - %11 = getelementptr inbounds i8* %8, i64 %10 - store i8 %7, i8* %11, align 1 - ret void -} - -; Function Attrs: nounwind uwtable -define weak i32 @kotlin.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 - store i32 %index, i32* %2, align 4 - %3 = load i32* %1, align 4 - %4 = sext i32 %3 to i64 - %5 = inttoptr i64 %4 to i32* - %6 = load i32* %2, align 4 - %7 = sext i32 %6 to i64 - %8 = getelementptr inbounds i32* %5, i64 %7 - %9 = load i32* %8, align 4 - ret i32 %9 -} - -; Function Attrs: nounwind uwtable -define weak void @kotlin.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 - %ptr = alloca i32*, align 8 - 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 = sext i32 %4 to i64 - %6 = inttoptr i64 %5 to i32* - store i32* %6, i32** %ptr, align 8 - %7 = load i32* %3, align 4 - %8 = load i32** %ptr, align 8 - %9 = load i32* %2, align 4 - %10 = sext i32 %9 to i64 - %11 = getelementptr inbounds i32* %8, i64 %10 - store i32 %7, i32* %11, align 4 - ret void -} - -; Function Attrs: nounwind uwtable -define weak signext i16 @kotlin.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 - store i32 %index, i32* %2, align 4 - %3 = load i32* %1, align 4 - %4 = sext i32 %3 to i64 - %5 = inttoptr i64 %4 to i16* - %6 = load i32* %2, align 4 - %7 = sext i32 %6 to i64 - %8 = getelementptr inbounds i16* %5, i64 %7 - %9 = load i16* %8, align 2 - ret i16 %9 -} - -; Function Attrs: nounwind uwtable -define weak void @kotlin.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 - %ptr = alloca i16*, align 8 - store i32 %data, i32* %1, align 4 - store i32 %index, i32* %2, align 4 - store i16 %value, i16* %3, align 2 - %4 = load i32* %1, align 4 - %5 = sext i32 %4 to i64 - %6 = inttoptr i64 %5 to i16* - store i16* %6, i16** %ptr, align 8 - %7 = load i16* %3, align 2 - %8 = load i16** %ptr, align 8 - %9 = load i32* %2, align 4 - %10 = sext i32 %9 to i64 - %11 = getelementptr inbounds i16* %8, i64 %10 - store i16 %7, i16* %11, align 2 - ret void -} - -; Function Attrs: nounwind uwtable -define weak i64 @kotlin.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 @kotlin.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-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-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)"} diff --git a/kotstd/lib/x86/assert_c.ll b/kotstd/lib/x86/assert_c.ll deleted file mode 100644 index eca3ed99ad8..00000000000 --- a/kotstd/lib/x86/assert_c.ll +++ /dev/null @@ -1,36 +0,0 @@ -; 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 weak void @kotlin.assert_c(i1 %value) #0 { - %1 = alloca i1, align 4 - store i1 %value, i1* %1, align 4 - %2 = load i1* %1, align 4 - %3 = icmp ne i1 %2, 0 - br i1 %3, label %6, label %4 - -;