[JVM IR] Use JVM8 support for unsigned int operations

- unmute tests
- add test to ensure JVM target is respected
- add test to cover smart-casted cases
- implement function matching and replacement
- Switching on uint constants
- introduce lowering for standard library replacements
This commit is contained in:
Kristoffer Andersen
2020-05-18 09:57:53 +02:00
committed by Dmitry Petrov
parent c95216dc5d
commit f0ff8f202c
19 changed files with 302 additions and 43 deletions

View File

@@ -0,0 +1,15 @@
// WITH_RUNTIME
val ua = 1234U
val ub = 5678U
fun box(): String {
if (ua.compareTo(ub) > 0) {
throw AssertionError()
}
return "OK"
}
// 1 kotlin/UnsignedKt.uintCompare
// 0 INVOKESTATIC java/lang/Integer.compareUnsigned \(II\)I

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
val ua = 1234U
val ub = 5678U

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
val ua = 1234U
val ub = 5678U

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
val ua = 1234U
val ub = 5678U

View File

@@ -0,0 +1,7 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
fun both(a: Any?, b: Any?) = if (a is UInt && b is UInt) a < b else null!!
// 1 compareUnsigned
// 0 uintCompare

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
fun box(): String {
val min = 0U.toString()

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
val ua = 1234UL
val ub = 5678UL

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
val ua = 1234UL
val ub = 5678UL

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
val ua = 1234UL
val ub = 5678UL

View File

@@ -1,7 +1,5 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36838 Use potentially intrinsified methods for unsigned available in JDK 1.8+ in JVM_IR
fun box(): String {
val min = 0UL.toString()

View File

@@ -1,6 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
// TODO KT-36839 Generate 'when' with unsigned subject using TABLESWITCH/LOOKUPSWITCH in JVM_IR
const val M1: UInt = 2147483648u