r212378 - CodeGen: add support for a few MSVC ARM intrinsics
Saleem Abdulrasool
compnerd at compnerd.org
Sat Jul 5 13:10:06 PDT 2014
Author: compnerd
Date: Sat Jul 5 15:10:05 2014
New Revision: 212378
URL: http://llvm.org/viewvc/llvm-project?rev=212378&view=rev
Log:
CodeGen: add support for a few MSVC ARM intrinsics
This adds support for simple MSVC compatibility mode intrinsics. These
intrinsics are simple in that they are either directly passed through to the
annotated MSBuiltin intrinsic or they mirror existing GCC builtins.
Added:
cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=212378&r1=212377&r2=212378&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Sat Jul 5 15:10:05 2014
@@ -86,5 +86,14 @@ LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGU
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__ldrexd, "WiCDWi*", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(_MoveFromCoprocessor, "UiUiUiUiUiUi", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(_MoveFromCoprocessor2, "UiUiUiUiUiUi", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(_MoveToCoprocessor, "vUiUiUiUiUiUi", "", ALL_MS_LANGUAGES)
+LANGBUILTIN(_MoveToCoprocessor2, "vUiUiUiUiUiUi", "", ALL_MS_LANGUAGES)
+
#undef BUILTIN
#undef LANGBUILTIN
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=212378&r1=212377&r2=212378&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Jul 5 15:10:05 2014
@@ -3087,10 +3087,21 @@ Value *CodeGenFunction::EmitARMBuiltinEx
if (BuiltinID == ARM::BI__builtin_arm_ldrexd ||
((BuiltinID == ARM::BI__builtin_arm_ldrex ||
BuiltinID == ARM::BI__builtin_arm_ldaex) &&
- getContext().getTypeSize(E->getType()) == 64)) {
- Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_ldaex
- ? Intrinsic::arm_ldaexd
- : Intrinsic::arm_ldrexd);
+ getContext().getTypeSize(E->getType()) == 64) ||
+ BuiltinID == ARM::BI__ldrexd) {
+ Function *F;
+
+ switch (BuiltinID) {
+ default: llvm_unreachable("unexpected builtin");
+ case ARM::BI__builtin_arm_ldaex:
+ F = CGM.getIntrinsic(Intrinsic::arm_ldaexd);
+ break;
+ case ARM::BI__builtin_arm_ldrexd:
+ case ARM::BI__builtin_arm_ldrex:
+ case ARM::BI__ldrexd:
+ F = CGM.getIntrinsic(Intrinsic::arm_ldrexd);
+ break;
+ }
Value *LdPtr = EmitScalarExpr(E->getArg(0));
Value *Val = Builder.CreateCall(F, Builder.CreateBitCast(LdPtr, Int8PtrTy),
Added: cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c?rev=212378&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c (added)
+++ cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c Sat Jul 5 15:10:05 2014
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple armv7-eabi -Werror -S -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-EABI
+
+void check__dmb(void) {
+ __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.arm.dmb(i32 0)
+// CHECK-EABI: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+ __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.arm.dsb(i32 0)
+// CHECK-EABI: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+ __isb(0);
+}
+
+// CHECK-MSVC: @llvm.arm.isb(i32 0)
+// CHECK-EABI: error: implicit declaration of function '__isb'
+
+__INT64_TYPE__ check__ldrexd(void) {
+ __INT64_TYPE__ i64;
+ return __ldrexd(&i64);
+}
+
+// CHECK-MSVC: @llvm.arm.ldrexd(i8* {{.*}})
+// CHECK-EABI: error: implicit declaration of function '__ldrexd'
+
+unsigned int check_MoveFromCoprocessor(void) {
+ return _MoveFromCoprocessor(0, 0, 0, 0, 0);
+}
+
+// CHECK-MSVC: @llvm.arm.mrc(i32 0, i32 0, i32 0, i32 0, i32 0)
+// CHECK-EABI: error: implicit declaration of function '_MoveFromCoprocessor'
+
+unsigned int check_MoveFromCoprocessor2(void) {
+ return _MoveFromCoprocessor2(0, 0, 0, 0, 0);
+}
+
+// CHECK-MSVC: @llvm.arm.mrc2(i32 0, i32 0, i32 0, i32 0, i32 0)
+// CHECK-EABI: error: implicit declaration of function '_MoveFromCoprocessor2'
+
+void check_MoveToCoprocessor(void) {
+ _MoveToCoprocessor(0, 0, 0, 0, 0, 0);
+}
+
+// CHECK-MSVC: @llvm.arm.mcr(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
+// CHECK-EABI: error: implicit declaration of function '_MoveToCoprocessor'
+
+void check_MoveToCoprocessor2(void) {
+ _MoveToCoprocessor2(0, 0, 0, 0, 0, 0);
+}
+
+// CHECK-MSVC: @llvm.arm.mcr2(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
+// CHECK-EABI: error: implicit declaration of function '_MoveToCoprocessor2'
+
More information about the cfe-commits
mailing list