r249176 - [WebAssembly] Add a __builtin_wasm_memory_size() intrinsic.
Dan Gohman via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 2 12:38:47 PDT 2015
Author: djg
Date: Fri Oct 2 14:38:47 2015
New Revision: 249176
URL: http://llvm.org/viewvc/llvm-project?rev=249176&view=rev
Log:
[WebAssembly] Add a __builtin_wasm_memory_size() 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=249176&r1=249175&r2=249176&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Oct 2 14:38:47 2015
@@ -17,5 +17,6 @@
// The format of this database matches clang/Basic/Builtins.def.
BUILTIN(__builtin_wasm_page_size, "z", "nc")
+BUILTIN(__builtin_wasm_memory_size, "z", "nc")
#undef BUILTIN
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=249176&r1=249175&r2=249176&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Oct 2 14:38:47 2015
@@ -7048,6 +7048,11 @@ Value *CodeGenFunction::EmitWebAssemblyB
Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_page_size, ResultType);
return Builder.CreateCall(Callee);
}
+ case WebAssembly::BI__builtin_wasm_memory_size: {
+ llvm::Type *ResultType = ConvertType(E->getType());
+ Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_size, ResultType);
+ return Builder.CreateCall(Callee);
+ }
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=249176&r1=249175&r2=249176&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Fri Oct 2 14:38:47 2015
@@ -8,3 +8,9 @@ __SIZE_TYPE__ f0(void) {
// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.page.size.i32()
// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.page.size.i64()
}
+
+__SIZE_TYPE__ f1(void) {
+ return __builtin_wasm_memory_size();
+// WEBASSEMBLY32: call {{i.*}} @llvm.wasm.memory.size.i32()
+// WEBASSEMBLY64: call {{i.*}} @llvm.wasm.memory.size.i64()
+}
More information about the cfe-commits
mailing list