r212196 - CodeGen: make target builtins support languages
Saleem Abdulrasool
compnerd at compnerd.org
Wed Jul 2 10:41:27 PDT 2014
Author: compnerd
Date: Wed Jul 2 12:41:27 2014
New Revision: 212196
URL: http://llvm.org/viewvc/llvm-project?rev=212196&view=rev
Log:
CodeGen: make target builtins support languages
This extends the target builtin support to allow language specific annotations
(i.e. LANGBUILTIN). This is to allow MSVC compatibility whilst retaining the
ability to have EABI targets use a __builtin_ prefix. This is merely to allow
uniformity in the EABI case where the unprefixed name is provided as an alias in
the header.
Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/Basic/Builtins.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-arm-microsoft.c
cfe/trunk/test/CodeGen/builtins-arm.c
Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=212196&r1=212195&r2=212196&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Wed Jul 2 12:41:27 2014
@@ -14,6 +14,10 @@
// The format of this database matches clang/Basic/Builtins.def.
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+# define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
// In libgcc
BUILTIN(__clear_cache, "vv*v*", "i")
BUILTIN(__builtin_thread_pointer, "v*", "")
@@ -64,14 +68,22 @@ BUILTIN(__builtin_arm_crc32d, "UiUiLLUi"
BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc")
// HINT
-BUILTIN(__yield, "v", "")
-BUILTIN(__wfe, "v", "")
-BUILTIN(__wfi, "v", "")
-BUILTIN(__sev, "v", "")
-BUILTIN(__sevl, "v", "")
+BUILTIN(__builtin_yield, "v", "")
+BUILTIN(__builtin_wfe, "v", "")
+BUILTIN(__builtin_wfi, "v", "")
+BUILTIN(__builtin_sev, "v", "")
+BUILTIN(__builtin_sevl, "v", "")
// Data barrier
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
+// MSVC
+LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
+
#undef BUILTIN
+#undef LANGBUILTIN
Modified: cfe/trunk/lib/Basic/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Builtins.cpp?rev=212196&r1=212195&r2=212196&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Builtins.cpp (original)
+++ cfe/trunk/lib/Basic/Builtins.cpp Wed Jul 2 12:41:27 2014
@@ -76,7 +76,7 @@ void Builtin::Context::InitializeBuiltin
// Step #2: Register target-specific builtins.
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
- if (!LangOpts.NoBuiltin || !strchr(TSRecords[i].Attributes, 'f'))
+ if (BuiltinIsSupported(TSRecords[i], LangOpts))
Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin);
}
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=212196&r1=212195&r2=212196&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul 2 12:41:27 2014
@@ -4170,6 +4170,7 @@ const Builtin::Info ARMTargetInfo::Built
#include "clang/Basic/BuiltinsNEON.def"
#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES },
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) { #ID, TYPE, ATTRS, 0, LANG },
#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\
ALL_LANGUAGES },
#include "clang/Basic/BuiltinsARM.def"
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=212196&r1=212195&r2=212196&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jul 2 12:41:27 2014
@@ -3033,18 +3033,23 @@ Value *CodeGenFunction::EmitARMBuiltinEx
unsigned HintID = static_cast<unsigned>(-1);
switch (BuiltinID) {
default: break;
+ case ARM::BI__builtin_yield:
case ARM::BI__yield:
HintID = 1;
break;
+ case ARM::BI__builtin_wfe:
case ARM::BI__wfe:
HintID = 2;
break;
+ case ARM::BI__builtin_wfi:
case ARM::BI__wfi:
HintID = 3;
break;
+ case ARM::BI__builtin_sev:
case ARM::BI__sev:
HintID = 4;
break;
+ case ARM::BI__builtin_sevl:
case ARM::BI__sevl:
HintID = 5;
break;
Modified: cfe/trunk/test/CodeGen/builtins-arm-microsoft.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm-microsoft.c?rev=212196&r1=212195&r2=212196&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-arm-microsoft.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm-microsoft.c Wed Jul 2 12:41:27 2014
@@ -1,10 +1,41 @@
-// RUN: %clang_cc1 -triple thumbv7-windows -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple armv7-eabi -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix CHECK-MSVC
+// RUN: %clang_cc1 -triple armv7-eabi -emit-llvm %s -o - \
+// RUN: | FileCheck %s -check-prefix CHECK-EABI
// REQUIRES: arm-registered-target
void test_yield_intrinsic() {
__yield();
}
-// CHECK: call void @llvm.arm.hint(i32 1)
+// CHECK-MSVC: call void @llvm.arm.hint(i32 1)
+// CHECK-EABI-NOT: call void @llvm.arm.hint(i32 1)
+
+void wfe() {
+ __wfe();
+}
+
+// CHECK-MSVC: call {{.*}} @llvm.arm.hint(i32 2)
+// CHECK-EABI-NOT: call {{.*}} @llvm.arm.hint(i32 2)
+
+void wfi() {
+ __wfi();
+}
+
+// CHECK-MSVC: call {{.*}} @llvm.arm.hint(i32 3)
+// CHECK-EABI-NOT: call {{.*}} @llvm.arm.hint(i32 3)
+
+void sev() {
+ __sev();
+}
+
+// CHECK-MSVC: call {{.*}} @llvm.arm.hint(i32 4)
+// CHECK-EABI-NOT: call {{.*}} @llvm.arm.hint(i32 4)
+
+void sevl() {
+ __sevl();
+}
+
+// CHECK-MSVC: call {{.*}} @llvm.arm.hint(i32 5)
+// CHECK-EABI-NOT: call {{.*}} @llvm.arm.hint(i32 5)
Modified: cfe/trunk/test/CodeGen/builtins-arm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm.c?rev=212196&r1=212195&r2=212196&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-arm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm.c Wed Jul 2 12:41:27 2014
@@ -20,32 +20,33 @@ void test_eh_return_data_regno()
}
void yield() {
- __yield();
+ __builtin_yield();
}
// CHECK: call {{.*}} @llvm.arm.hint(i32 1)
void wfe() {
- __wfe();
+ __builtin_wfe();
}
// CHECK: call {{.*}} @llvm.arm.hint(i32 2)
void wfi() {
- __wfi();
+ __builtin_wfi();
}
// CHECK: call {{.*}} @llvm.arm.hint(i32 3)
void sev() {
- __sev();
+ __builtin_sev();
}
// CHECK: call {{.*}} @llvm.arm.hint(i32 4)
void sevl() {
- __sevl();
+ __builtin_sevl();
}
+
// CHECK: call {{.*}} @llvm.arm.hint(i32 5)
void test_barrier() {
More information about the cfe-commits
mailing list