mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 00:04:10 -08:00
Intrinsify numberOfLeadingZeros, numberOfTrailingZeros, bitCount
This commit is contained in:
parent
bf15f0e299
commit
739cb2ba7e
|
@ -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.WasmIntBinaryOperation;
|
||||
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;
|
||||
|
||||
public class IntegerIntrinsic implements WasmIntrinsic {
|
||||
|
@ -38,6 +40,9 @@ public class IntegerIntrinsic implements WasmIntrinsic {
|
|||
case "divideUnsigned":
|
||||
case "remainderUnsigned":
|
||||
case "compareUnsigned":
|
||||
case "numberOfLeadingZeros":
|
||||
case "numberOfTrailingZeros":
|
||||
case "bitCount":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -59,6 +64,15 @@ public class IntegerIntrinsic implements WasmIntrinsic {
|
|||
return new WasmCall(manager.getFunctions().forStaticMethod(COMPARE_UNSIGNED),
|
||||
manager.generate(invocation.getArguments().get(0)),
|
||||
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:
|
||||
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.WasmIntBinaryOperation;
|
||||
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;
|
||||
|
||||
public class LongIntrinsic implements WasmIntrinsic {
|
||||
|
@ -38,6 +40,9 @@ public class LongIntrinsic implements WasmIntrinsic {
|
|||
case "divideUnsigned":
|
||||
case "remainderUnsigned":
|
||||
case "compareUnsigned":
|
||||
case "numberOfLeadingZeros":
|
||||
case "numberOfTrailingZeros":
|
||||
case "bitCount":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -59,6 +64,15 @@ public class LongIntrinsic implements WasmIntrinsic {
|
|||
return new WasmCall(manager.getFunctions().forStaticMethod(COMPARE_UNSIGNED),
|
||||
manager.generate(invocation.getArguments().get(0)),
|
||||
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:
|
||||
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.WasmIntBinaryOperation;
|
||||
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;
|
||||
|
||||
public class IntNumIntrinsic implements WasmGCIntrinsic {
|
||||
|
@ -48,6 +50,15 @@ public class IntNumIntrinsic implements WasmGCIntrinsic {
|
|||
return new WasmCall(context.functions().forStaticMethod(compareUnsigned),
|
||||
context.generate(invocation.getArguments().get(0)),
|
||||
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:
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
|
|
@ -126,6 +126,9 @@ public class WasmGCIntrinsics implements WasmGCIntrinsicProvider {
|
|||
add(new MethodReference(wrapperClass, "divideUnsigned", 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, "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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user