aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-06-02 14:08:58 +0200
committerAndrew Kelley <andrew@ziglang.org>2020-06-09 00:22:34 -0400
commit8ffa8ed9a8c66d2c8cbdffe619b2c5302d17b814 (patch)
treeeb309d44785d885af6b1684c6dd93e775b5d8539 /src/codegen.cpp
parent73a3bfd1dd63a160fd3776b8394d9336abd1ae99 (diff)
downloadzig-8ffa8ed9a8c66d2c8cbdffe619b2c5302d17b814.tar.gz
zig-8ffa8ed9a8c66d2c8cbdffe619b2c5302d17b814.zip
Expose full llvm intrinsic
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 765d57d7db..f945dd6545 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -5620,26 +5620,16 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir
}
static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, IrExecutableGen *executable, IrInstGenWasmMemorySize *instruction) {
- // When Wasm lands multi-memory support, we can relax this to permit the user specify
- // memory index to inquire about. For now, we pass in the recommended default of index 0.
- //
- // More info:
- // https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#current-linear-memory-size
// TODO adjust for wasm64
- LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type);
- LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &zero, 1, "");
+ LLVMValueRef param = ir_llvm_value(g, instruction->index);
+ LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &param, 1, "");
return val;
}
static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *executable, IrInstGenWasmMemoryGrow *instruction) {
- // When Wasm lands multi-memory support, we can relax this to permit the user specify
- // memory index to inquire about. For now, we pass in the recommended default of index 0.
- //
- // More info:
- // https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#grow-linear-memory-size
// TODO adjust for wasm64
LLVMValueRef params[] = {
- LLVMConstNull(g->builtin_types.entry_i32->llvm_type),
+ ir_llvm_value(g, instruction->index),
ir_llvm_value(g, instruction->delta),
};
LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_grow(g), params, 2, "");
@@ -8722,8 +8712,8 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdAs, "as", 2);
create_builtin_fn(g, BuiltinFnIdCall, "call", 3);
create_builtin_fn(g, BuiltinFnIdBitSizeof, "bitSizeOf", 1);
- create_builtin_fn(g, BuiltinFnIdWasmMemorySize, "wasmMemorySize", 0);
- create_builtin_fn(g, BuiltinFnIdWasmMemoryGrow, "wasmMemoryGrow", 1);
+ create_builtin_fn(g, BuiltinFnIdWasmMemorySize, "wasmMemorySize", 1);
+ create_builtin_fn(g, BuiltinFnIdWasmMemoryGrow, "wasmMemoryGrow", 2);
}
static const char *bool_to_str(bool b) {