r249179 - [WebAssembly] Add a __builtin_wasm_resize_memory() intrinsic.

Dan Gohman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 2 13:20:02 PDT 2015


Author: djg
Date: Fri Oct  2 15:20:01 2015
New Revision: 249179

URL: http://llvm.org/viewvc/llvm-project?rev=249179&view=rev
Log:
[WebAssembly] Add a __builtin_wasm_resize_memory() intrinsic.

Modified:
    cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp
    cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=249179&r1=249178&r2=249179&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Oct  2 15:20:01 2015
@@ -18,5 +18,6 @@
 
 BUILTIN(__builtin_wasm_page_size, "z", "nc")
 BUILTIN(__builtin_wasm_memory_size, "z", "nc")
+BUILTIN(__builtin_wasm_resize_memory, "vz", "n")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=249179&r1=249178&r2=249179&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Oct  2 15:20:01 2015
@@ -7053,6 +7053,11 @@ Value *CodeGenFunction::EmitWebAssemblyB
     Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_size, ResultType);
     return Builder.CreateCall(Callee);
   }
+  case WebAssembly::BI__builtin_wasm_resize_memory: {
+    Value *X = EmitScalarExpr(E->getArg(0));
+    Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_resize_memory, X->getType());
+    return Builder.CreateCall(Callee, X);
+  }
 
   default:
     return nullptr;

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=249179&r1=249178&r2=249179&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Fri Oct  2 15:20:01 2015
@@ -14,3 +14,9 @@ __SIZE_TYPE__ f1(void) {
 // WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32()
 // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64()
 }
+
+void f2(long delta) {
+  __builtin_wasm_resize_memory(delta);
+// WEBASSEMBLY32: call void @llvm.wasm.resize.memory.i32(i32 %{{.*}})
+// WEBASSEMBLY64: call void @llvm.wasm.resize.memory.i64(i64 %{{.*}})
+}




More information about the cfe-commits mailing list