Commit Graph

39 Commits

Author SHA1 Message Date
Vasily Levchenko b038dbc724 arithmetic added (minus, mul, div, mod) 2016-10-11 11:41:37 +03:00
Vasily Levchenko 97e31820ae inter-procedural call test 2016-10-11 11:24:47 +03:00
Vasily Levchenko 390edc146d interprocedural call implementation 2016-10-11 11:24:47 +03:00
Vasily Levchenko 31c022f0a6 g/c: cosmetic some clean up 2016-10-11 11:21:56 +03:00
Vasily Levchenko ce10b5fb15 fix run command 2016-10-10 17:25:24 +03:00
Vasily Levchenko 4c32689e1f unit test introduced:
User should create <test-name>-test.c file in the following manner:
> cat codegen/function/sum-test.c
extern void *resolve_symbol(const char*);

int
run_test() {
  int (*sum)(int, int) = resolve_symbol("kfun:sum");

  if (sum(2, 3) != 5) return 1;

  return 0;
}
and add <test-name> to the TESTS variable in the Makefile
to run tests:
> make clean run
Note: failing tests should return no zero values.
2016-10-10 15:11:55 +03:00
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
Vasily Levchenko bbe86f25bc hardcoded (temporary) path to extensions/common.xml, to fix fall on unresolved symbols 2016-10-07 17:17:53 +03:00
Vasily Levchenko 8c2a620c06 kotlin-ir: sync 2016-10-07 09:49:57 +03:00
Vasily Levchenko 75aaed1d07 kotlin-ir: sync 2016-10-05 20:52:25 +03:00
Nikolay Igotti 3a9d013c96 Typo. 2016-10-05 19:18:12 +03:00
Nikolay Igotti 488ca7170b Try to fix empty Linux lib problem. 2016-10-05 19:14:59 +03:00
Vasily Levchenko 71da52456e linux build fix: on linux we need to set LD_LIBRARY_PATH to launch jvm with native dependency to llvm 2016-10-05 16:19:54 +03:00
Svyatoslav Scherbina 38d0000242 backend.native: simplify build.gradle by making it more idiomatic 2016-10-05 08:28:47 +03:00
Vasily Levchenko deec80499c attempt to build linux build on team city.
it fails with message about missing noexecstack on load our library
2016-10-05 00:49:55 +03:00
Svyatoslav Scherbina e464989b1b backend.native: simplify build.gradle after improving Interop plugin 2016-10-04 16:32:15 +03:00
Svyatoslav Scherbina 33bfb2d063 Interop: improve support for multiple source sets in Gradle plugin 2016-10-04 16:25:18 +03:00
Svyatoslav Scherbina df6b4388a0 backend.native: add only overridable methods to vtable and lookup table 2016-10-04 14:08:36 +03:00
Svyatoslav Scherbina 3324527984 backend.native, runtime: add vtable to TypeInfo 2016-10-04 14:08:36 +03:00
Svyatoslav Scherbina 473816ea81 backend.native: make all RTTI constant 2016-10-04 14:08:36 +03:00
Svyatoslav Scherbina 5ea3c9521e backend.native: improve type mapping
including types of functions
2016-10-04 14:07:54 +03:00
Svyatoslav Scherbina ba69e02ea6 backend.native: enable assertions 2016-10-04 14:26:06 +07:00
Nikolay Igotti f92da32454 Add properties expansion. 2016-10-03 20:56:33 +03:00
Svyatoslav Scherbina 059f890a1e backend.native: support inheritance in RTTI
also
* distribute the code among several files
* use descriptors instead of IR (where it is possible)
* add other minor improvements
2016-10-03 16:28:51 +07:00
Vasily Levchenko fd2288c23f makes idea users more happy: fix dependencies to let idea build project correctly 2016-10-03 11:39:57 +03:00
Vasily Levchenko 43f10c9e8f g/c: removed unwanted patches 2016-10-03 09:58:00 +03:00
Vasily Levchenko 6bb976b89c sync: kotlin-ir 2016-09-30 13:53:53 +03:00
Svyatoslav Scherbina 6d70bc4625 backend.native: add remaining info to RTTI
inheritance is not supported yet
2016-09-30 17:01:11 +07:00
Vasily Levchenko d61bb4a6e5 add dependency to generated classes 2016-09-29 17:55:43 +03:00
Vasily Levchenko b1e89a4d41 backend.native and generated dependencies resolving 2016-09-29 17:49:14 +03:00
Vasily Levchenko 0de37420f0 makes gradle build friendly to idea 2016-09-29 14:57:12 +03:00
Vasily Levchenko 20bfd25a99 g/c: compiler/build.gradle deleted 2016-09-29 14:51:29 +03:00
Svyatoslav Scherbina 277835fccb backend.native: add some dirty code to emit bitcode with RTTI for fields 2016-09-29 17:41:54 +07:00
Svyatoslav Scherbina 78a912f637 backend.native: tie compiler to runtime
to make compiler able to refer entities declared in runtime
2016-09-29 17:41:54 +07:00
Vasily Levchenko 3b7af125f7 kotlin-ir: sync 2016-09-29 10:06:25 +03:00
Svyatoslav Scherbina 2ca6676674 backend.native: apply Interop and add LLVM bindings 2016-09-29 12:27:47 +07:00
Nikolay Igotti 5293abd3e9 Updated README.md 2016-09-28 18:42:43 +03:00
Vasily Levchenko c6cf10b1e8 backend.native: use once initialized property (path to kotlin dist) to initialize dependencies 2016-09-28 16:06:05 +03:00
Vasily Levchenko 0eaaa58ed9 HEAD UPS! Global move: experiments -> kotlin-native 2016-09-28 13:22:36 +03:00