Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>2017-10-15 07:12:29 +0300
committerMorgan Brown <morganbr@users.noreply.github.com>2017-10-15 07:12:29 +0300
commit18f3c7773c6aebab639311481cad6ebf550bdead (patch)
tree20b66915c9786df7ba66c1207198bd49876edb08 /src/ILCompiler.WebAssembly
parentea81a1844f860d5b0548be2c4163c7216670c3bd (diff)
Implement Shift Opcodes for WebAssembly (#4721)
* Implement shift opcodes * Fix HelloWasm test. * FIx HelloWasm test program.
Diffstat (limited to 'src/ILCompiler.WebAssembly')
-rw-r--r--src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
index 7a465901f..ef6421831 100644
--- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
+++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
@@ -1025,6 +1025,27 @@ namespace Internal.IL
private void ImportShiftOperation(ILOpcode opcode)
{
+ LLVMValueRef result;
+
+ StackEntry numBitsToShift = _stack.Pop();
+ StackEntry valueToShift = _stack.Pop();
+
+ switch (opcode)
+ {
+ case ILOpcode.shl:
+ result = LLVM.BuildShl(_builder, valueToShift.LLVMValue, numBitsToShift.LLVMValue, "shl");
+ break;
+ case ILOpcode.shr:
+ result = LLVM.BuildAShr(_builder, valueToShift.LLVMValue, numBitsToShift.LLVMValue, "shr");
+ break;
+ case ILOpcode.shr_un:
+ result = LLVM.BuildLShr(_builder, valueToShift.LLVMValue, numBitsToShift.LLVMValue, "shr");
+ break;
+ default:
+ throw new InvalidOperationException(); // Should be unreachable
+ }
+
+ PushExpression(valueToShift.Kind, "", result, valueToShift.Type);
}
private void ImportCompareOperation(ILOpcode opcode)