Vasily Levchenko dbdbc9a844 Base level translator: it could compile primitive functions with arithmetic operations:
note: operations are hardcoded e.g. operato plus resolved in corresponding instruction.

fun sum(a:Int, b:Int) = a + b

produces following code:
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"

define i32 @"kfun:sum"(i32, i32) {
entry:
  %a = alloca i32
  store i32 %0, i32* %a
  %b = alloca i32
  store i32 %1, i32* %b
  %tmp1 = load i32, i32* %a
  %tmp2 = load i32, i32* %b
  %tmp0 = add i32 %tmp1, %tmp2
  ret i32 %tmp0
}

Note: this code is optimizable with -mem2reg
> opt-mp-3.8 -mem2reg sum.BCkt -o - | llvm-dis-mp-3.8 -o -
; ModuleID = '<stdin>'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"

define i32 @"kfun:sum"(i32, i32) {
entry:
  %tmp0 = add i32 %0, %1
  ret i32 %tmp0
}
2016-10-10 15:11:55 +03:00
2016-10-07 14:14:00 +03:00
2016-09-28 16:08:44 +03:00
2016-10-07 14:14:00 +03:00
2016-09-28 18:11:40 +03:00
2016-09-28 18:42:43 +03:00

Kotlin-native backend

Build

First, build Kotlin IR branch tree with: pushd backend.native/kotlin-ir ant -f ./update_dependencies.xml jb_update ant -f ./build.xml popd

To build native translator just use: gradle :backend.native:run

And it will run simple example (currently prints out IR of test file).

S
Description
The Kotlin Programming Language.
Readme 2.1 GiB
Languages
Kotlin 79.9%
Java 10.4%
Swift 4.3%
C 2.8%
C++ 2.1%
Other 0.3%