r204820 - Add support for __builtin___clear_cache in Clang
Renato Golin
renato.golin at linaro.org
Wed Mar 26 08:36:05 PDT 2014
Author: rengolin
Date: Wed Mar 26 10:36:05 2014
New Revision: 204820
URL: http://llvm.org/viewvc/llvm-project?rev=204820&view=rev
Log:
Add support for __builtin___clear_cache in Clang
Adding the mapping between __builtin___clear_cache into @llvm.clear_cache
Added:
cfe/trunk/test/CodeGen/clear_cache.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=204820&r1=204819&r2=204820&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Mar 26 10:36:05 2014
@@ -445,6 +445,7 @@ BUILTIN(__builtin_strstr, "c*cC*cC*", "n
BUILTIN(__builtin_return_address, "v*IUi", "n")
BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
BUILTIN(__builtin_frame_address, "v*IUi", "n")
+BUILTIN(__builtin___clear_cache, "vc*c*", "n")
BUILTIN(__builtin_flt_rounds, "i", "nc")
BUILTIN(__builtin_setjmp, "iv**", "j")
BUILTIN(__builtin_longjmp, "vv**i", "r")
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=204820&r1=204819&r2=204820&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Mar 26 10:36:05 2014
@@ -429,6 +429,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(
Value *F = CGM.getIntrinsic(Intrinsic::readcyclecounter);
return RValue::get(Builder.CreateCall(F));
}
+ case Builtin::BI__builtin___clear_cache: {
+ Value *Begin = EmitScalarExpr(E->getArg(0));
+ Value *End = EmitScalarExpr(E->getArg(1));
+ Value *F = CGM.getIntrinsic(Intrinsic::clear_cache);
+ return RValue::get(Builder.CreateCall2(F, Begin, End));
+ }
case Builtin::BI__builtin_trap: {
Value *F = CGM.getIntrinsic(Intrinsic::trap);
return RValue::get(Builder.CreateCall(F));
Added: cfe/trunk/test/CodeGen/clear_cache.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/clear_cache.c?rev=204820&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/clear_cache.c (added)
+++ cfe/trunk/test/CodeGen/clear_cache.c Wed Mar 26 10:36:05 2014
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+char buffer[32] = "This is a largely unused buffer";
+
+// __builtin___clear_cache always maps to @llvm.clear_cache, but what
+// each back-end produces is different, and this is tested in LLVM
+
+int main() {
+ __builtin___clear_cache(buffer, buffer+32);
+// CHECK: @llvm.clear_cache(i8* getelementptr {{.*}}, i8* getelementptr {{.*}} (i8* getelementptr {{.*}} 32))
+ return 0;
+}
More information about the cfe-commits
mailing list