r240462 - PR22560: Fix argument order for ARM _MoveToCoprocessor builtins.
Bob Wilson
bob.wilson at apple.com
Tue Jun 23 14:10:15 PDT 2015
Author: bwilson
Date: Tue Jun 23 16:10:15 2015
New Revision: 240462
URL: http://llvm.org/viewvc/llvm-project?rev=240462&view=rev
Log:
PR22560: Fix argument order for ARM _MoveToCoprocessor builtins.
The Microsoft-extension _MoveToCoprocessor and _MoveToCoprocessor2
builtins take the register value to be moved as the first argument,
but the corresponding mcr and mcr2 LLVM intrinsics expect that value
to be the third argument. Handle this as a special case, while still
leaving those intrinsics as generic MSBuiltins. I considered the
alternative of handling these in EmitARMBuiltinExpr, but that does
not work well for the follow-up change that I'm going to make to improve
the error handling for PR22560 -- we need the GetBuiltinType() checks
for ICEArguments, and the ARM version of that code is only used for
Neon intrinsics where the last argument is special and not
checked in the normal way.
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=240462&r1=240461&r2=240462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jun 23 16:10:15 2015
@@ -1831,6 +1831,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(
Args.push_back(ArgValue);
}
+ // The ARM _MoveToCoprocessor builtins put the input register value as
+ // the first argument, but the LLVM intrinsic expects it as the third one.
+ if (BuiltinID == ARM::BI_MoveToCoprocessor ||
+ BuiltinID == ARM::BI_MoveToCoprocessor2) {
+ return RValue::get(Builder.CreateCall(F, {Args[1], Args[2], Args[0],
+ Args[3], Args[4], Args[5]}));
+ }
+
Value *V = Builder.CreateCall(F, Args);
QualType BuiltinRetType = E->getType();
Modified: cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c?rev=240462&r1=240461&r2=240462&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/arm-microsoft-intrinsics.c Tue Jun 23 16:10:15 2015
@@ -47,17 +47,17 @@ unsigned int check_MoveFromCoprocessor2(
// 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);
+void check_MoveToCoprocessor(unsigned int value) {
+ _MoveToCoprocessor(value, 10, 7, 1, 0, 0);
}
-// CHECK-MSVC: @llvm.arm.mcr(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
+// CHECK-MSVC: @llvm.arm.mcr(i32 10, i32 7, i32 %0, i32 1, i32 0, i32 0)
// CHECK-EABI: error: implicit declaration of function '_MoveToCoprocessor'
-void check_MoveToCoprocessor2(void) {
- _MoveToCoprocessor2(0, 0, 0, 0, 0, 0);
+void check_MoveToCoprocessor2(unsigned int value) {
+ _MoveToCoprocessor2(value, 10, 7, 1, 0, 0);
}
-// CHECK-MSVC: @llvm.arm.mcr2(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
+// CHECK-MSVC: @llvm.arm.mcr2(i32 10, i32 7, i32 %0, i32 1, i32 0, i32 0)
// CHECK-EABI: error: implicit declaration of function '_MoveToCoprocessor2'
More information about the cfe-commits
mailing list