translator: new build system, translator build options, external stdlib, translator and hardware integration

This commit is contained in:
e5l
2016-08-09 16:04:39 +03:00
parent 7be9f69f77
commit 342edabc25
337 changed files with 464 additions and 76136 deletions
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
ast-kotlin
+2
View File
@@ -21,6 +21,8 @@
<bytecodeTargetLevel>
<module name="ast-kotlin_main" target="1.8" />
<module name="ast-kotlin_test" target="1.8" />
<module name="translator_main" target="1.8" />
<module name="translator_test" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>
@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="Gradle: com.github.jshmrsn:karg:a636b3e">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.jshmrsn/karg/a636b3e/3547a1b86ae936eca88ca44423f9231f23dcccfc/karg-a636b3e.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
@@ -1,11 +1,11 @@
<component name="libraryTable">
<library name="Gradle: junit:junit:4.11">
<library name="Gradle: junit:junit:4.12">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/28e0ad201304e4a4abf999ca0570b7cffc352c3c/junit-4.11-sources.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa/junit-4.12-sources.jar!/" />
</SOURCES>
</library>
</component>
+3 -3
View File
@@ -2,9 +2,9 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/ast-kotlin.iml" filepath="$PROJECT_DIR$/.idea/modules/ast-kotlin.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/ast-kotlin_main.iml" filepath="$PROJECT_DIR$/.idea/modules/ast-kotlin_main.iml" group="ast-kotlin" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/ast-kotlin_test.iml" filepath="$PROJECT_DIR$/.idea/modules/ast-kotlin_test.iml" group="ast-kotlin" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/translator.iml" filepath="$PROJECT_DIR$/.idea/modules/translator.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/translator_main.iml" filepath="$PROJECT_DIR$/.idea/modules/translator_main.iml" group="translator" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/translator_test.iml" filepath="$PROJECT_DIR$/.idea/modules/translator_test.iml" group="translator" />
</modules>
</component>
</project>
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="ast-kotlin" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="ast-kotlin" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../..">
+4 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="ast-kotlin:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="ast-kotlin" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<module external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../build/classes/main" />
<exclude-output />
@@ -12,6 +12,9 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler:1.0.3" level="project" />
<orderEntry type="library" name="Gradle: com.github.jshmrsn:karg:a636b3e" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-runtime:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
+4 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="ast-kotlin:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="ast-kotlin" external.system.module.type="sourceSet" external.system.module.version="1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<module external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
<exclude-output />
@@ -10,10 +10,12 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="ast-kotlin_main" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler:1.0.3" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.11" level="project" />
<orderEntry type="library" name="Gradle: com.github.jshmrsn:karg:a636b3e" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-runtime:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
<component name="TestModuleProperties" production-module="ast-kotlin_main" />
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="translator" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="translator" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../..">
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
<excludeFolder url="file://$MODULE_DIR$/../../build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="translator:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="translator" external.system.module.type="sourceSet" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/../../build/classes/main" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../src/main">
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler:1.0.3" level="project" />
<orderEntry type="library" name="Gradle: com.github.jshmrsn:karg:a636b3e" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-runtime:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="translator:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="translator" external.system.module.type="sourceSet" external.system.module.version="1.0" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../src/test">
<sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../../src/test/kotlin" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/../../src/test/resources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="translator_main" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-compiler:1.0.3" level="project" />
<orderEntry type="library" name="Gradle: com.github.jshmrsn:karg:a636b3e" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-runtime:1.0.1" level="project" />
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
<component name="TestModuleProperties" production-module="translator_main" />
</module>
+4 -3
View File
@@ -1,5 +1,5 @@
group 'ast-kotlin'
version '1.0-SNAPSHOT'
group 'translator'
version '1.0'
buildscript {
ext.kotlin_version = '1.0.3'
@@ -18,11 +18,13 @@ apply plugin: 'application'
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.1"
compile group: 'org.jetbrains.kotlin', name: 'kotlin-compiler', version: '1.0.3'
compile 'com.github.jshmrsn:karg:a636b3e'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
@@ -34,4 +36,3 @@ jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
mainClassName = 'MainKt'
+15 -16
View File
@@ -1,10 +1,13 @@
#!/bin/bash
if [ ! -d "src/test/kotlin/tests/linked" ]; then
# Создать папку, только если ее не было
mkdir src/test/kotlin/tests/linked
# Создать папку, только если ее не было
mkdir src/test/kotlin/tests/linked
fi
cd ../kotstd && make clean && make
cd ../translator
DIRECTORY="src/test/kotlin/tests"
MAIN="$DIRECTORY/linked/main.c"
for i in $( ls "$DIRECTORY/input" $1); do
@@ -12,34 +15,30 @@ for i in $( ls "$DIRECTORY/input" $1); do
TEST=`basename $i ".txt"`
echo test: $TEST
echo "#include <stdlib.h>" >> $MAIN
echo "#include <stdio.h>" >> $MAIN
echo "#include <assert.h>" >> $MAIN
echo "#include <stdio.h>" >> $MAIN
echo "#include <assert.h>" >> $MAIN
echo "int main(){" >> $MAIN
echo "int main(){" >> $MAIN
cat "$DIRECTORY/input/$i" | while read LINE
do
echo " assert($LINE);" >> $MAIN
echo " assert($LINE);" >> $MAIN
echo " printf(\"OK: $LINE\n\");" >> $MAIN
done
echo "printf(\"TEST RESULT: OK\n\");" >> $MAIN
echo "printf(\"TEST RESULT: OK\n\");" >> $MAIN
echo "return 0;}" >> $MAIN
echo "return 0;}" >> $MAIN
clang-3.6 -S -emit-llvm $DIRECTORY/linked/main.c -o $DIRECTORY/linked/main.ll -Wno-implicit-function-declaration
rm -f $DIRECTORY/linked/main.c
cp ./src/main/resources/kotlib/linked/x86/* $DIRECTORY/linked/
cp ../kotstd/build/stdlib_x86.ll $DIRECTORY/linked/
if [ -f "$DIRECTORY/c/$TEST.c" ]
then
clang-3.6 -S -emit-llvm "$DIRECTORY/c/$TEST.c" -o $DIRECTORY/linked/$TEST"_c.ll" -Wno-implicit-function-declaration
clang-3.6 -S -emit-llvm "$DIRECTORY/c/$TEST.c" -o $DIRECTORY/linked/$TEST"_c.ll" -Wno-implicit-function-declaration
fi
java -jar build/libs/ast-kotlin-1.0-SNAPSHOT.jar $DIRECTORY/kotlin/$TEST.kt > $DIRECTORY/linked/$TEST.ll
llvm-link-3.6 $DIRECTORY/linked/* > $DIRECTORY/linked/run.ll
java -jar build/libs/translator-1.0.jar -I ../kotstd/include $DIRECTORY/kotlin/$TEST.kt > $DIRECTORY/linked/$TEST.ll
llvm-link-3.6 -S $DIRECTORY/linked/* > $DIRECTORY/linked/run.ll
lli-3.6 $DIRECTORY/linked/run.ll
done
+1 -1
View File
@@ -1,2 +1,2 @@
rootProject.name = 'ast-kotlin'
rootProject.name = 'translator'
@@ -0,0 +1,29 @@
import com.jshmrsn.karg.Arguments
import com.jshmrsn.karg.RawArguments
class DefaultArguments(raw: RawArguments) : Arguments(raw, name = "default") {
val includeDir = optionalParameter(
name = "include directory",
aliasNames = listOf("include"),
shortNames = listOf('I')
)
val arm = optionalFlag(
name = "arm",
description = "enable arm build",
aliasNames = listOf("arm")
)
val output = optionalParameter(
name = "output",
description = "output file",
shortNames = listOf('o')
)
val sources = positionalArguments(
name = "sources",
description = "source files",
minCount = 1
)
}
+15 -16
View File
@@ -1,34 +1,33 @@
import com.intellij.openapi.util.Disposer
import com.jshmrsn.karg.parseArguments
import org.kotlinnative.translator.ProjectTranslator
import org.kotlinnative.translator.parseAndAnalyze
import java.io.File
import java.util.*
fun main(args: Array<String>) {
if (args.isEmpty()) {
println("Enter filename")
return
}
val arguments = parseArguments(args, ::DefaultArguments)
val disposer = Disposer.newDisposable()
val analyzedFiles = ArrayList<String>()
val kotlib = File("build/resources/main/kotlib/kotlin").listFiles()
for (resource in kotlib) {
analyzedFiles.add(resource.absolutePath)
val stdlib = mutableListOf<String>()
if (arguments.includeDir != null) {
stdlib.addAll(File(arguments.includeDir).listFiles().map { it.absolutePath })
analyzedFiles.addAll(stdlib)
}
analyzedFiles.addAll(args.toList())
val disposer = Disposer.newDisposable()
val state = parseAndAnalyze(analyzedFiles, disposer, arm = false)
analyzedFiles.addAll(arguments.sources)
val state = parseAndAnalyze(analyzedFiles, disposer, arguments.arm ?: false)
val files = state.environment.getSourceFiles()
if (files.isEmpty()) {
print("Empty")
val code = ProjectTranslator(files, state).generateCode()
if (arguments.output == null) {
println(code)
return
}
println(ProjectTranslator(files, state).generateCode())
val output = File(arguments.output)
output.writeText(code)
}
@@ -5,7 +5,7 @@ import org.kotlinnative.translator.llvm.types.LLVMIntType
import org.kotlinnative.translator.llvm.types.LLVMStringType
import org.kotlinnative.translator.llvm.types.LLVMType
class LLVMBuilder(val arm: Boolean) {
class LLVMBuilder(val arm: Boolean = false) {
private val POINTER_SIZE = 4
private var localCode: StringBuilder = StringBuilder()
@@ -20,18 +20,7 @@ class LLVMBuilder(val arm: Boolean) {
private fun initBuilder() {
val declares = arrayOf(
"declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1)",
if (arm) "declare i8* @malloc_static(i32)" else
"""
declare i8* @malloc(i32) #0
define i8* @malloc_static(i32 %size) #0 {
%1 = alloca i32, align 4
store i32 %size, i32* %1, align 4
%2 = load i32* %1, align 4
%3 = call i8* @malloc(i32 %2)
ret i8* %3
}
""")
"declare i8* @malloc_static(i32)")
declares.forEach { globalCode.appendln(it) }
@@ -174,7 +163,7 @@ class LLVMBuilder(val arm: Boolean) {
val allocedVar = getNewVariable(LLVMCharType(), pointer = 1)
val size = if (target.pointer > 0) POINTER_SIZE else target.type.size
val alloc = "$allocedVar = call i8* @${if (arm) "malloc_static" else "malloc"}(i32 $size)"
val alloc = "$allocedVar = call i8* @malloc_static(i32 $size)"
localCode.appendln(alloc)
val cast = "$target = bitcast ${allocedVar.getType()} $allocedVar to ${target.getType()}*"
@@ -8,10 +8,10 @@ import org.kotlinnative.translator.llvm.types.*
fun LLVMFunctionDescriptor(name: String, argTypes: List<LLVMVariable>?, returnType: LLVMType, declare: Boolean = false, arm: Boolean = false) =
"${if (declare) "declare" else "define"} $returnType @$name(${
"${if (declare) "declare" else "define weak"} $returnType @$name(${
argTypes?.mapIndexed { i: Int, s: LLVMVariable ->
"${s.getType()} ${if (s.type is LLVMReferenceType && !(s.type as LLVMReferenceType).byRef) "byval" else ""} %${s.label}"
}?.joinToString()}) ${if (arm) "#0" else ""}"
}?.joinToString()}) #0"
fun LLVMInstanceOfStandardType(name: String, type: KotlinType, scope: LLVMScope = LLVMRegisterScope()): LLVMVariable = when {
type.isFunctionTypeOrSubtype -> LLVMVariable(name, LLVMFunctionType(type), name, scope, pointer = 1)
@@ -1,42 +0,0 @@
class BooleanArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//size: Int
init {
this.data = malloc_array(this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Boolean {
val res = kotlinclib_get_byte(this.data, index) == 1.toByte()
return res
}
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Boolean) {
if (value == true) {
kotlinclib_set_byte(this.data, index, 1.toByte())
}
else{
kotlinclib_set_byte(this.data, index, 0.toByte())
}
}
fun clone(): BooleanArray {
val newInstance = BooleanArray(this.size)
var index = 0
while (index < this.size) {
val value = this.get(index)
newInstance.set(index, value)
index = index + 1
}
return newInstance
}
}
@@ -1,41 +0,0 @@
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)
class ByteArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//size: Int
init {
this.data = malloc_array(this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Byte {
return kotlinclib_get_byte(this.data, index)
}
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Byte) {
kotlinclib_set_byte(this.data, index, value)
}
fun clone(): ByteArray {
val newInstance = ByteArray(this.size)
var index = 0
while (index < this.size) {
val value = this.get(index)
newInstance.set(index, value)
index = index + 1
}
return newInstance
}
}
@@ -1,40 +0,0 @@
external fun kotlinclib_get_int(src: Int, index: Int): Int
external fun kotlinclib_set_int(src: Int, index: Int, value: Int)
class IntArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//size: Int
init {
this.data = malloc_array(4 * this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Int {
return kotlinclib_get_int(this.data, index)
}
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Int) {
kotlinclib_set_int(this.data, index, value)
}
fun clone(): IntArray {
val newInstance = IntArray(this.size)
var index = 0
while (index < this.size) {
val value = this.get(index)
newInstance.set(index, value)
index = index + 1
}
return newInstance
}
}
@@ -1,35 +0,0 @@
external fun kotlinclib_byteToChar(value: Byte): Char
external fun kotlinclib_byteToShort(value: Byte): Short
external fun kotlinclib_byteToInt(value: Byte): Int
external fun kotlinclib_byteToLong(value: Byte): Long
external fun kotlinclib_byteToFloat(value: Byte): Float
external fun kotlinclib_byteToDouble(value: Byte): Double
fun Byte.toByte(): Byte {
return this
}
fun Byte.toInt(): Int {
return kotlinclib_byteToInt(this)
}
fun Byte.toChar(): Char {
return kotlinclib_byteToChar(this)
}
fun Byte.toShort(): Short {
return kotlinclib_byteToShort(this)
}
fun Byte.toLong(): Long {
return kotlinclib_byteToLong(this)
}
fun Byte.toFloat(): Float {
return kotlinclib_byteToFloat(this)
}
fun Byte.toDouble(): Double {
return kotlinclib_byteToDouble(this)
}
@@ -1,35 +0,0 @@
external fun kotlinclib_charToByte(value: Char): Byte
external fun kotlinclib_charToShort(value: Char): Short
external fun kotlinclib_charToInt(value: Char): Int
external fun kotlinclib_charToLong(value: Char): Long
external fun kotlinclib_charToFloat(value: Char): Float
external fun kotlinclib_charToDouble(value: Char): Double
fun Char.toByte(): Byte {
return kotlinclib_charToByte(this)
}
fun Char.toInt(): Int {
return kotlinclib_charToInt(this)
}
fun Char.toChar(): Char {
return this
}
fun Char.toShort(): Short {
return kotlinclib_charToShort(this)
}
fun Char.toLong(): Long {
return kotlinclib_charToLong(this)
}
fun Char.toFloat(): Float {
return kotlinclib_charToFloat(this)
}
fun Char.toDouble(): Double {
return kotlinclib_charToDouble(this)
}
@@ -1,34 +0,0 @@
external fun kotlinclib_doubleToByte(value: Double): Byte
external fun kotlinclib_doubleToChar(value: Double): Char
external fun kotlinclib_doubleToShort(value: Double): Short
external fun kotlinclib_doubleToInt(value: Double): Int
external fun kotlinclib_doubleToLong(value: Double): Long
external fun kotlinclib_doubleToFloat(value: Double): Float
fun Double.toByte(): Byte {
return kotlinclib_doubleToByte(this)
}
fun Double.toChar(): Char {
return kotlinclib_doubleToChar(this)
}
fun Double.toShort(): Short {
return kotlinclib_doubleToShort(this)
}
fun Double.toInt(): Int {
return kotlinclib_doubleToInt(this)
}
fun Double.toLong(): Long {
return kotlinclib_doubleToLong(this)
}
fun Double.toFloat(): Float {
return kotlinclib_doubleToFloat(this)
}
fun Double.toDouble(): Double {
return this
}
@@ -1,34 +0,0 @@
external fun kotlinclib_floatToByte(value: Float): Byte
external fun kotlinclib_floatToChar(value: Float): Char
external fun kotlinclib_floatToShort(value: Float): Short
external fun kotlinclib_floatToInt(value: Float): Int
external fun kotlinclib_floatToLong(value: Float): Long
external fun kotlinclib_floatToDouble(value: Float): Double
fun Float.toByte(): Byte {
return kotlinclib_floatToByte(this)
}
fun Float.toChar(): Char {
return kotlinclib_floatToChar(this)
}
fun Float.toShort(): Short {
return kotlinclib_floatToShort(this)
}
fun Float.toInt(): Int {
return kotlinclib_floatToInt(this)
}
fun Float.toLong(): Long {
return kotlinclib_floatToLong(this)
}
fun Float.toFloat(): Float {
return this
}
fun Float.toDouble(): Double {
return kotlinclib_floatToDouble(this)
}
@@ -1,34 +0,0 @@
external fun kotlinclib_intToByte(value: Int): Byte
external fun kotlinclib_intToChar(value: Int): Char
external fun kotlinclib_intToShort(value: Int): Short
external fun kotlinclib_intToLong(value: Int): Long
external fun kotlinclib_intToFloat(value: Int): Float
external fun kotlinclib_intToDouble(value: Int): Double
fun Int.toByte(): Byte {
return kotlinclib_intToByte(this)
}
fun Int.toInt(): Int {
return this
}
fun Int.toChar(): Char {
return kotlinclib_intToChar(this)
}
fun Int.toShort(): Short {
return kotlinclib_intToShort(this)
}
fun Int.toLong(): Long {
return kotlinclib_intToLong(this)
}
fun Int.toFloat(): Float {
return kotlinclib_intToFloat(this)
}
fun Int.toDouble(): Double {
return kotlinclib_intToDouble(this)
}
@@ -1,34 +0,0 @@
external fun kotlinclib_longToByte(value: Long): Byte
external fun kotlinclib_longToChar(value: Long): Char
external fun kotlinclib_longToShort(value: Long): Short
external fun kotlinclib_longToInt(value: Long): Int
external fun kotlinclib_longToFloat(value: Long): Float
external fun kotlinclib_longToDouble(value: Long): Double
fun Long.toByte(): Byte {
return kotlinclib_longToByte(this)
}
fun Long.toLong(): Long {
return this
}
fun Long.toChar(): Char {
return kotlinclib_longToChar(this)
}
fun Long.toShort(): Short {
return kotlinclib_longToShort(this)
}
fun Long.toInt(): Int {
return kotlinclib_longToInt(this)
}
fun Long.toFloat(): Float {
return kotlinclib_longToFloat(this)
}
fun Long.toDouble(): Double {
return kotlinclib_longToDouble(this)
}
@@ -1,35 +0,0 @@
external fun kotlinclib_shortToByte(value: Short): Byte
external fun kotlinclib_shortToChar(value: Short): Char
external fun kotlinclib_shortToInt(value: Short): Int
external fun kotlinclib_shortToLong(value: Short): Long
external fun kotlinclib_shortToFloat(value: Short): Float
external fun kotlinclib_shortToDouble(value: Short): Double
fun Short.toByte(): Byte {
return kotlinclib_shortToByte(this)
}
fun Short.toInt(): Int {
return kotlinclib_shortToInt(this)
}
fun Short.toChar(): Char {
return kotlinclib_shortToChar(this)
}
fun Short.toShort(): Short {
return this
}
fun Short.toLong(): Long {
return kotlinclib_shortToLong(this)
}
fun Short.toFloat(): Float {
return kotlinclib_shortToFloat(this)
}
fun Short.toDouble(): Double {
return kotlinclib_shortToDouble(this)
}
@@ -1,40 +0,0 @@
external fun kotlinclib_get_short(src: Int, index: Int): Short
external fun kotlinclib_set_short(src: Int, index: Int, value: Short)
class ShortArray(var size: Int) {
val data: Int
/** Returns the number of elements in the array. */
//size: Int
init {
this.data = malloc_array(this.size)
}
/** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Short {
return kotlinclib_get_short(this.data, index)
}
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Short) {
kotlinclib_set_short(this.data, index, value)
}
fun clone(): ShortArray {
val newInstance = ShortArray(this.size)
var index = 0
while (index < this.size) {
val value = this.get(index)
newInstance.set(index, value)
index = index + 1
}
return newInstance
}
}
@@ -1,127 +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 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(i32 %2) #2
%4 = ptrtoint i8* %3 to i32
ret i32 %4
}
declare i8* @malloc(i32) #1
; Function Attrs: nounwind
define zeroext 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
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 void @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 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
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 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
%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 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
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 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
%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
}
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}
@@ -1,385 +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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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 @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
}
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}
@@ -1,126 +0,0 @@
declare i8* @malloc_static(i32)
define 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)
%4 = ptrtoint i8* %3 to i32
ret i32 %4
}
; Function Attrs: nounwind uwtable
define signext i8 @kotlinclib_get_byte(i32 %data, i32 %index) {
%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 void @kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value) {
%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 i32 @kotlinclib_get_int(i32 %data, i32 %index) {
%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 void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) {
%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 signext i16 @kotlinclib_get_short(i32 %data, i32 %index) {
%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 void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) {
%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
}
@@ -1,381 +0,0 @@
; ModuleID = 'primitives.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 signext i8 @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 uwtable
define signext i8 @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 uwtable
define signext i16 @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 uwtable
define i64 @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
}
; Function Attrs: nounwind uwtable
define float @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 uwtable
define double @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 uwtable
define signext i8 @kotlinclib_byteToChar(i8 signext %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 signext i16 @kotlinclib_byteToShort(i8 signext %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
ret i16 %3
}
; Function Attrs: nounwind uwtable
define i32 @kotlinclib_byteToInt(i8 signext %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
ret i32 %3
}
; Function Attrs: nounwind uwtable
define i64 @kotlinclib_byteToLong(i8 signext %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
}
; Function Attrs: nounwind uwtable
define float @kotlinclib_byteToFloat(i8 signext %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
ret float %3
}
; Function Attrs: nounwind uwtable
define double @kotlinclib_byteToDouble(i8 signext %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
ret double %3
}
; Function Attrs: nounwind uwtable
define signext i8 @kotlinclib_charToByte(i8 signext %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 signext i16 @kotlinclib_charToShort(i8 signext %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
ret i16 %3
}
; Function Attrs: nounwind uwtable
define i32 @kotlinclib_charToInt(i8 signext %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
ret i32 %3
}
; Function Attrs: nounwind uwtable
define i64 @kotlinclib_charToLong(i8 signext %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
}
; Function Attrs: nounwind uwtable
define float @kotlinclib_charToFloat(i8 signext %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
ret float %3
}
; Function Attrs: nounwind uwtable
define double @kotlinclib_charToDouble(i8 signext %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
ret double %3
}
; Function Attrs: nounwind uwtable
define signext 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
%3 = trunc i16 %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
define signext 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
%3 = trunc i16 %2 to i8
ret i8 %3
}
; Function Attrs: nounwind uwtable
define i32 @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 uwtable
define i64 @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
}
; Function Attrs: nounwind uwtable
define float @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 uwtable
define double @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 uwtable
define 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
ret i8 %3
}
; Function Attrs: nounwind uwtable
define 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
ret i8 %3
}
; Function Attrs: nounwind uwtable
define 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
ret i16 %3
}
; Function Attrs: nounwind uwtable
define 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 uwtable
define 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
ret float %3
}
; Function Attrs: nounwind uwtable
define 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
ret double %3
}
; Function Attrs: nounwind uwtable
define signext 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
ret i8 %3
}
; Function Attrs: nounwind uwtable
define signext 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
ret i8 %3
}
; Function Attrs: nounwind uwtable
define signext i16 @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 uwtable
define i32 @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 uwtable
define i64 @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
}
; Function Attrs: nounwind uwtable
define double @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 uwtable
define signext 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
ret i8 %3
}
; Function Attrs: nounwind uwtable
define signext 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
ret i8 %3
}
; Function Attrs: nounwind uwtable
define signext i16 @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 uwtable
define i32 @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 uwtable
define i64 @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
}
; Function Attrs: nounwind uwtable
define float @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
}
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" }