mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 00:04:10 -08:00
Merge branch 'more-integer-intrinsics' into eagler-r1
This commit is contained in:
commit
b47bbcbc02
|
@ -22,6 +22,8 @@ import org.teavm.backend.wasm.model.expression.WasmExpression;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntType;
|
import org.teavm.backend.wasm.model.expression.WasmIntType;
|
||||||
|
import org.teavm.backend.wasm.model.expression.WasmIntUnary;
|
||||||
|
import org.teavm.backend.wasm.model.expression.WasmIntUnaryOperation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
public class IntegerIntrinsic implements WasmIntrinsic {
|
public class IntegerIntrinsic implements WasmIntrinsic {
|
||||||
|
@ -38,6 +40,9 @@ public class IntegerIntrinsic implements WasmIntrinsic {
|
||||||
case "divideUnsigned":
|
case "divideUnsigned":
|
||||||
case "remainderUnsigned":
|
case "remainderUnsigned":
|
||||||
case "compareUnsigned":
|
case "compareUnsigned":
|
||||||
|
case "numberOfLeadingZeros":
|
||||||
|
case "numberOfTrailingZeros":
|
||||||
|
case "bitCount":
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -59,6 +64,15 @@ public class IntegerIntrinsic implements WasmIntrinsic {
|
||||||
return new WasmCall(manager.getFunctions().forStaticMethod(COMPARE_UNSIGNED),
|
return new WasmCall(manager.getFunctions().forStaticMethod(COMPARE_UNSIGNED),
|
||||||
manager.generate(invocation.getArguments().get(0)),
|
manager.generate(invocation.getArguments().get(0)),
|
||||||
manager.generate(invocation.getArguments().get(1)));
|
manager.generate(invocation.getArguments().get(1)));
|
||||||
|
case "numberOfLeadingZeros":
|
||||||
|
return new WasmIntUnary(WasmIntType.INT32, WasmIntUnaryOperation.CLZ,
|
||||||
|
manager.generate(invocation.getArguments().get(0)));
|
||||||
|
case "numberOfTrailingZeros":
|
||||||
|
return new WasmIntUnary(WasmIntType.INT32, WasmIntUnaryOperation.CTZ,
|
||||||
|
manager.generate(invocation.getArguments().get(0)));
|
||||||
|
case "bitCount":
|
||||||
|
return new WasmIntUnary(WasmIntType.INT32, WasmIntUnaryOperation.POPCNT,
|
||||||
|
manager.generate(invocation.getArguments().get(0)));
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.teavm.backend.wasm.model.expression.WasmExpression;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntType;
|
import org.teavm.backend.wasm.model.expression.WasmIntType;
|
||||||
|
import org.teavm.backend.wasm.model.expression.WasmIntUnary;
|
||||||
|
import org.teavm.backend.wasm.model.expression.WasmIntUnaryOperation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
public class LongIntrinsic implements WasmIntrinsic {
|
public class LongIntrinsic implements WasmIntrinsic {
|
||||||
|
@ -38,6 +40,9 @@ public class LongIntrinsic implements WasmIntrinsic {
|
||||||
case "divideUnsigned":
|
case "divideUnsigned":
|
||||||
case "remainderUnsigned":
|
case "remainderUnsigned":
|
||||||
case "compareUnsigned":
|
case "compareUnsigned":
|
||||||
|
case "numberOfLeadingZeros":
|
||||||
|
case "numberOfTrailingZeros":
|
||||||
|
case "bitCount":
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -59,6 +64,15 @@ public class LongIntrinsic implements WasmIntrinsic {
|
||||||
return new WasmCall(manager.getFunctions().forStaticMethod(COMPARE_UNSIGNED),
|
return new WasmCall(manager.getFunctions().forStaticMethod(COMPARE_UNSIGNED),
|
||||||
manager.generate(invocation.getArguments().get(0)),
|
manager.generate(invocation.getArguments().get(0)),
|
||||||
manager.generate(invocation.getArguments().get(1)));
|
manager.generate(invocation.getArguments().get(1)));
|
||||||
|
case "numberOfLeadingZeros":
|
||||||
|
return new WasmIntUnary(WasmIntType.INT64, WasmIntUnaryOperation.CLZ,
|
||||||
|
manager.generate(invocation.getArguments().get(0)));
|
||||||
|
case "numberOfTrailingZeros":
|
||||||
|
return new WasmIntUnary(WasmIntType.INT64, WasmIntUnaryOperation.CTZ,
|
||||||
|
manager.generate(invocation.getArguments().get(0)));
|
||||||
|
case "bitCount":
|
||||||
|
return new WasmIntUnary(WasmIntType.INT64, WasmIntUnaryOperation.POPCNT,
|
||||||
|
manager.generate(invocation.getArguments().get(0)));
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.teavm.backend.wasm.model.expression.WasmExpression;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
||||||
import org.teavm.backend.wasm.model.expression.WasmIntType;
|
import org.teavm.backend.wasm.model.expression.WasmIntType;
|
||||||
|
import org.teavm.backend.wasm.model.expression.WasmIntUnary;
|
||||||
|
import org.teavm.backend.wasm.model.expression.WasmIntUnaryOperation;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
|
|
||||||
public class IntNumIntrinsic implements WasmGCIntrinsic {
|
public class IntNumIntrinsic implements WasmGCIntrinsic {
|
||||||
|
@ -48,6 +50,15 @@ public class IntNumIntrinsic implements WasmGCIntrinsic {
|
||||||
return new WasmCall(context.functions().forStaticMethod(compareUnsigned),
|
return new WasmCall(context.functions().forStaticMethod(compareUnsigned),
|
||||||
context.generate(invocation.getArguments().get(0)),
|
context.generate(invocation.getArguments().get(0)),
|
||||||
context.generate(invocation.getArguments().get(1)));
|
context.generate(invocation.getArguments().get(1)));
|
||||||
|
case "numberOfLeadingZeros":
|
||||||
|
return new WasmIntUnary(wasmType, WasmIntUnaryOperation.CLZ,
|
||||||
|
context.generate(invocation.getArguments().get(0)));
|
||||||
|
case "numberOfTrailingZeros":
|
||||||
|
return new WasmIntUnary(wasmType, WasmIntUnaryOperation.CTZ,
|
||||||
|
context.generate(invocation.getArguments().get(0)));
|
||||||
|
case "bitCount":
|
||||||
|
return new WasmIntUnary(wasmType, WasmIntUnaryOperation.POPCNT,
|
||||||
|
context.generate(invocation.getArguments().get(0)));
|
||||||
default:
|
default:
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,9 @@ public class WasmGCIntrinsics implements WasmGCIntrinsicProvider {
|
||||||
add(new MethodReference(wrapperClass, "divideUnsigned", javaClass, javaClass, javaClass), intrinsic);
|
add(new MethodReference(wrapperClass, "divideUnsigned", javaClass, javaClass, javaClass), intrinsic);
|
||||||
add(new MethodReference(wrapperClass, "remainderUnsigned", javaClass, javaClass, javaClass), intrinsic);
|
add(new MethodReference(wrapperClass, "remainderUnsigned", javaClass, javaClass, javaClass), intrinsic);
|
||||||
add(new MethodReference(wrapperClass, "compareUnsigned", javaClass, javaClass, int.class), intrinsic);
|
add(new MethodReference(wrapperClass, "compareUnsigned", javaClass, javaClass, int.class), intrinsic);
|
||||||
|
add(new MethodReference(wrapperClass, "numberOfLeadingZeros", javaClass, int.class), intrinsic);
|
||||||
|
add(new MethodReference(wrapperClass, "numberOfTrailingZeros", javaClass, int.class), intrinsic);
|
||||||
|
add(new MethodReference(wrapperClass, "bitCount", javaClass, int.class), intrinsic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillFloat() {
|
private void fillFloat() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user