diff options
| author | Reid Kleckner <rnk@google.com> | 2018-03-23 23:38:53 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2018-03-23 23:38:53 +0000 |
| commit | e27b410661f5e3a8ead2645eb27567a376668e0f (patch) | |
| tree | afe11a5bc3903ab05a8671a11075de5d3c0ad7bd /llvm/lib | |
| parent | 5cd35ed4fe72d96354c6f17ae071747ea62f0f14 (diff) | |
| download | bcm5719-llvm-e27b410661f5e3a8ead2645eb27567a376668e0f.tar.gz bcm5719-llvm-e27b410661f5e3a8ead2645eb27567a376668e0f.zip | |
[X86] Fix Windows `i1 zeroext` conventions to use i8 instead of i32
Both GCC and MSVC only look at the low byte of a boolean when it is
passed.
llvm-svn: 328386
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86CallingConv.td | 14 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Target/X86/X86CallingConv.td b/llvm/lib/Target/X86/X86CallingConv.td index 8d3e33d5703..5b7dd024dc4 100644 --- a/llvm/lib/Target/X86/X86CallingConv.td +++ b/llvm/lib/Target/X86/X86CallingConv.td @@ -593,8 +593,8 @@ def CC_X86_Win64_C : CallingConv<[ // FIXME: Handle byval stuff. // FIXME: Handle varargs. - // Promote i1/i8/i16/v1i1 arguments to i32. - CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>, + // Promote i1/i8/i16/v1i1 arguments to i8. + CCIfType<[i1, v1i1], CCPromoteToType<i8>>, // The 'nest' parameter, if any, is passed in R10. CCIfNest<CCAssignToReg<[R10]>>, @@ -619,6 +619,10 @@ def CC_X86_Win64_C : CallingConv<[ CCIfType<[x86mmx], CCBitConvertToType<i64>>, // The first 4 integer arguments are passed in integer registers. + CCIfType<[i8 ], CCAssignToRegWithShadow<[CL , DL , R8B , R9B ], + [XMM0, XMM1, XMM2, XMM3]>>, + CCIfType<[i16], CCAssignToRegWithShadow<[CX , DX , R8W , R9W ], + [XMM0, XMM1, XMM2, XMM3]>>, CCIfType<[i32], CCAssignToRegWithShadow<[ECX , EDX , R8D , R9D ], [XMM0, XMM1, XMM2, XMM3]>>, @@ -847,13 +851,15 @@ def CC_X86_32_MCU : CallingConv<[ ]>; def CC_X86_32_FastCall : CallingConv<[ - // Promote i1/i8/i16/v1i1 arguments to i32. - CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>, + // Promote i1 to i8. + CCIfType<[i1], CCPromoteToType<i8>>, // The 'nest' parameter, if any, is passed in EAX. CCIfNest<CCAssignToReg<[EAX]>>, // The first 2 integer arguments are passed in ECX/EDX + CCIfInReg<CCIfType<[ i8], CCAssignToReg<[ CL, DL]>>>, + CCIfInReg<CCIfType<[i16], CCAssignToReg<[ CX, DX]>>>, CCIfInReg<CCIfType<[i32], CCAssignToReg<[ECX, EDX]>>>, // Otherwise, same as everything else. diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 69ca1b8bca5..483cba3d314 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -3034,7 +3034,11 @@ SDValue X86TargetLowering::LowerFormalArguments( getv64i1Argument(VA, ArgLocs[++I], Chain, DAG, dl, Subtarget); } else { const TargetRegisterClass *RC; - if (RegVT == MVT::i32) + if (RegVT == MVT::i8) + RC = &X86::GR8RegClass; + else if (RegVT == MVT::i16) + RC = &X86::GR16RegClass; + else if (RegVT == MVT::i32) RC = &X86::GR32RegClass; else if (Is64Bit && RegVT == MVT::i64) RC = &X86::GR64RegClass; |

