diff options
author | Wayde Reitsma <pootisspencerherenao@gmail.com> | 2017-12-31 06:52:17 +0300 |
---|---|---|
committer | Morgan Brown <morganbr@users.noreply.github.com> | 2017-12-31 06:52:16 +0300 |
commit | 875551cf874443ecc8077783785264f11d6c4a52 (patch) | |
tree | 85b6897500627d1c2606c7b63b501a0303b4a805 /src/ILCompiler.WebAssembly | |
parent | 2c0a57703a96af79b3c7ac4184c737bbb9a6fc09 (diff) |
Implement cpobj opcode for wasm (#5151)
* Implement cpobj opcode for wasm
Implements the ILToWebAssembly.ImportCpObj method using an LLVM load and
store.
Adds a test for for wasm cpobj to the HelloWasm test using an IL
project.
Diffstat (limited to 'src/ILCompiler.WebAssembly')
-rw-r--r-- | src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs index 420d12f2e..71da8d50a 100644 --- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs +++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs @@ -1651,6 +1651,32 @@ namespace Internal.IL private void ImportCpOpj(int token) { + var type = ResolveTypeToken(token); + + if (!type.IsValueType) + { + throw new InvalidOperationException(); + } + + var src = _stack.Pop(); + + if (src.Kind != StackValueKind.NativeInt && src.Kind != StackValueKind.ByRef && src.Kind != StackValueKind.ObjRef) + { + throw new InvalidOperationException(); + } + + var dest = _stack.Pop(); + + if (dest.Kind != StackValueKind.NativeInt && dest.Kind != StackValueKind.ByRef && dest.Kind != StackValueKind.ObjRef) + { + throw new InvalidOperationException(); + } + + var pointerType = GetLLVMTypeForTypeDesc(type.MakePointerType()); + + var value = LLVM.BuildLoad(_builder, src.ValueAsType(pointerType, _builder), "cpobj.load"); + + LLVM.BuildStore(_builder, value, dest.ValueAsType(pointerType, _builder)); } private void ImportUnbox(int token, ILOpcode opCode) |