Files
kotlin-fork/backend.native
Konstantin Anisimov d4c3d6dabd plus'n'minus_eq operation: support for integer comparison operations
for code (plus_eq):

--------------8<------------------
> cat ../backend.native/tests/codegen/function/plus_eq.kt
fun plus_eq(a: Int): Int {
  var b = 11
  b += a
  return b
}
--------------8<------------------

generator produces:

--------------8<------------------
> llvm-dis-mp-3.8 ../backend.native/tests/codegen/function/plus_eq.kt.bc -o -
; ModuleID = '../backend.native/tests/codegen/function/plus_eq.kt.bc'
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:plus_eq"(i32) {
entry:
  %a = alloca i32
  store i32 %0, i32* %a
  %b = alloca i32
  store i32 11, i32* %b
  %tmp1 = load i32, i32* %b
  %tmp2 = load i32, i32* %a
  %tmp0 = add i32 %tmp1, %tmp2
  store i32 %tmp0, i32* %b
  %tmp3 = load i32, i32* %b
  ret i32 %tmp3
}
--------------8<------------------

and for (minus_eq):

--------------8<------------------
> cat ../backend.native/tests/codegen/function/minus_eq.kt
fun minus_eq(a: Int): Int {
  var b = 11
  b -= a
  return b
}

--------------8<------------------

generator produces:

--------------8<------------------
> llvm-dis-mp-3.8 ../backend.native/tests/codegen/function/minus_eq.kt.bc -o -
; ModuleID = '../backend.native/tests/codegen/function/minus_eq.kt.bc'
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:minus_eq"(i32) {
entry:
  %a = alloca i32
  store i32 %0, i32* %a
  %b = alloca i32
  store i32 11, i32* %b
  %tmp1 = load i32, i32* %b
  %tmp2 = load i32, i32* %a
  %tmp0 = sub i32 %tmp1, %tmp2
  store i32 %tmp0, i32* %b
  %tmp3 = load i32, i32* %b
  ret i32 %tmp3
}
--------------8<------------------
2016-11-07 18:00:30 +03:00
..
2016-11-07 18:00:30 +03:00