diff options
author | Juan Antonio Cano <jacanosalado@gmail.com> | 2017-10-15 03:19:24 +0300 |
---|---|---|
committer | Morgan Brown <morganbr@users.noreply.github.com> | 2017-10-15 03:19:24 +0300 |
commit | ea81a1844f860d5b0548be2c4163c7216670c3bd (patch) | |
tree | bcfda1292f75e2c9315f096ba65ae3003baeec96 /src/ILCompiler.WebAssembly | |
parent | 2d187d8b28cdcce4b5d984c5fa37e6a9b1c58730 (diff) |
Implement neg (float/integer) and not IL instructions. Fixes #4524 and #4525 (#4725)
* Implement neg (float/integer) and not IL instructions. Fixes #4524 and #4525
* Neg and not basic tests added to HelloWasm.
Name parameter updated in LLVM build methods to reflect the operation being built.
Use PushExpression method instead of direct push to stack.
Diffstat (limited to 'src/ILCompiler.WebAssembly')
-rw-r--r-- | src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs index cd09a1ef9..7a465901f 100644 --- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs +++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs @@ -1087,6 +1087,29 @@ namespace Internal.IL private void ImportUnaryOperation(ILOpcode opCode) { + var argument = _stack.Pop(); + + LLVMValueRef result; + switch (opCode) + { + case ILOpcode.neg: + if (argument.Kind == StackValueKind.Float) + { + result = LLVM.BuildFNeg(_builder, argument.LLVMValue, "neg"); + } + else + { + result = LLVM.BuildNeg(_builder, argument.LLVMValue, "neg"); + } + break; + case ILOpcode.not: + result = LLVM.BuildNot(_builder, argument.LLVMValue, "not"); + break; + default: + throw new NotSupportedException(); // unreachable + } + + PushExpression(argument.Kind, "", result, argument.Type); } private void ImportCpOpj(int token) |