forked from OSchip/llvm-project
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. llvm-svn: 240462
This commit is contained in:
parent
60c915e96a
commit
09aa90bbe1
|
@ -1831,6 +1831,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
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();
|
||||
|
||||
|
|
|
@ -47,17 +47,17 @@ unsigned int check_MoveFromCoprocessor2(void) {
|
|||
// 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'
|
||||
|
||||
|
|
Loading…
Reference in New Issue