mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 00:04:10 -08:00
Fix 64 bit variants
This commit is contained in:
parent
739cb2ba7e
commit
bfd8b7b631
|
@ -17,7 +17,9 @@ package org.teavm.backend.wasm.intrinsics;
|
|||
|
||||
import org.teavm.ast.InvocationExpr;
|
||||
import org.teavm.backend.wasm.WasmRuntime;
|
||||
import org.teavm.backend.wasm.model.WasmNumType;
|
||||
import org.teavm.backend.wasm.model.expression.WasmCall;
|
||||
import org.teavm.backend.wasm.model.expression.WasmConversion;
|
||||
import org.teavm.backend.wasm.model.expression.WasmExpression;
|
||||
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
||||
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
||||
|
@ -65,16 +67,20 @@ public class LongIntrinsic implements WasmIntrinsic {
|
|||
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)));
|
||||
return castToInt(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)));
|
||||
return castToInt(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)));
|
||||
return castToInt(new WasmIntUnary(WasmIntType.INT64, WasmIntUnaryOperation.POPCNT,
|
||||
manager.generate(invocation.getArguments().get(0))));
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
private WasmExpression castToInt(WasmExpression expr) {
|
||||
return new WasmConversion(WasmNumType.INT64, WasmNumType.INT32, false, expr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@ package org.teavm.backend.wasm.intrinsics.gc;
|
|||
|
||||
import org.teavm.ast.InvocationExpr;
|
||||
import org.teavm.backend.wasm.WasmRuntime;
|
||||
import org.teavm.backend.wasm.model.WasmNumType;
|
||||
import org.teavm.backend.wasm.model.expression.WasmCall;
|
||||
import org.teavm.backend.wasm.model.expression.WasmConversion;
|
||||
import org.teavm.backend.wasm.model.expression.WasmExpression;
|
||||
import org.teavm.backend.wasm.model.expression.WasmIntBinary;
|
||||
import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation;
|
||||
|
@ -51,16 +53,24 @@ public class IntNumIntrinsic implements WasmGCIntrinsic {
|
|||
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)));
|
||||
return castToInt(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)));
|
||||
return castToInt(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)));
|
||||
return castToInt(new WasmIntUnary(wasmType, WasmIntUnaryOperation.POPCNT,
|
||||
context.generate(invocation.getArguments().get(0))));
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
private WasmExpression castToInt(WasmExpression expr) {
|
||||
if (wasmType == WasmIntType.INT64) {
|
||||
return new WasmConversion(WasmNumType.INT64, WasmNumType.INT32, false, expr);
|
||||
} else {
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user