Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion llvm/lib/Target/X86/X86CallingConv.td
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def RetCC_X86Common : CallingConv<[

// Long double types are always returned in FP0 (even with SSE),
// except on Win64.
CCIfNotSubtarget<"isTargetWin64()", CCIfType<[f80], CCAssignToReg<[FP0, FP1]>>>
CCIfNotSubtarget<"isTargetWinOrUEFI64()",
CCIfType<[f80], CCAssignToReg<[FP0, FP1]>>>
]>;

// X86-32 C return-value convention.
Expand Down Expand Up @@ -495,6 +496,9 @@ def RetCC_X86_64 : CallingConv<[
// Mingw64 and native Win64 use Win64 CC
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<RetCC_X86_Win64_C>>,

// UEFI64 uses Win64 CC
CCIfSubtarget<"isTargetUEFI64()", CCDelegateTo<RetCC_X86_Win64_C>>,

// Otherwise, drop to normal X86-64 CC
CCDelegateTo<RetCC_X86_64_C>
]>;
Expand Down Expand Up @@ -1085,6 +1089,9 @@ def CC_X86_64 : CallingConv<[
// Mingw64 and native Win64 use Win64 CC
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<CC_X86_Win64_C>>,

// UEFI uses Win64 CC
CCIfSubtarget<"isTargetUEFI64()", CCDelegateTo<CC_X86_Win64_C>>,

// Otherwise, drop to normal X86-64 CC
CCDelegateTo<CC_X86_64_C>
]>;
Expand Down
7 changes: 4 additions & 3 deletions llvm/lib/Target/X86/X86RegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ X86RegisterInfo::X86RegisterInfo(const Triple &TT)
// Cache some information.
Is64Bit = TT.isArch64Bit();
IsWin64 = Is64Bit && TT.isOSWindows();
IsUEFI64 = Is64Bit && TT.isUEFI();

// Use a callee-saved register as the base pointer. These registers must
// not conflict with any ABI requirements. For example, in 32-bit mode PIC
Expand Down Expand Up @@ -227,7 +228,7 @@ X86RegisterInfo::getPointerRegClass(const MachineFunction &MF,
const TargetRegisterClass *
X86RegisterInfo::getGPRsForTailCall(const MachineFunction &MF) const {
const Function &F = MF.getFunction();
if (IsWin64 || (F.getCallingConv() == CallingConv::Win64))
if (IsWin64 || IsUEFI64 || (F.getCallingConv() == CallingConv::Win64))
return &X86::GR64_TCW64RegClass;
else if (Is64Bit)
return &X86::GR64_TCRegClass;
Expand Down Expand Up @@ -389,7 +390,7 @@ X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
return IsWin64 ? CSR_Win64_SwiftError_SaveList
: CSR_64_SwiftError_SaveList;

if (IsWin64)
if (IsWin64 || IsUEFI64)
return HasSSE ? CSR_Win64_SaveList : CSR_Win64_NoSSE_SaveList;
if (CallsEHReturn)
return CSR_64EHRet_SaveList;
Expand Down Expand Up @@ -514,7 +515,7 @@ X86RegisterInfo::getCallPreservedMask(const MachineFunction &MF,
if (IsSwiftCC)
return IsWin64 ? CSR_Win64_SwiftError_RegMask : CSR_64_SwiftError_RegMask;

return IsWin64 ? CSR_Win64_RegMask : CSR_64_RegMask;
return (IsWin64 || IsUEFI64) ? CSR_Win64_RegMask : CSR_64_RegMask;
}

return CSR_32_RegMask;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/X86/X86RegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class X86RegisterInfo final : public X86GenRegisterInfo {
///
bool IsWin64;

/// IsUEFI64 - Is UEFI 64 bit target.
///
bool IsUEFI64;

/// SlotSize - Stack slot size in bytes.
///
unsigned SlotSize;
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Target/X86/X86Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ class X86Subtarget final : public X86GenSubtargetInfo {

bool isTargetWin64() const { return Is64Bit && isOSWindows(); }

bool isTargetWinOrUEFI64() const {
return isTargetWin64() || isTargetUEFI64();
}

bool isTargetWin32() const { return !Is64Bit && isOSWindows(); }

bool isPICStyleGOT() const { return PICStyle == PICStyles::Style::GOT; }
Expand All @@ -352,6 +356,7 @@ class X86Subtarget final : public X86GenSubtargetInfo {
switch (CC) {
// On Win64, all these conventions just use the default convention.
case CallingConv::C:
return isTargetWin64() || isTargetUEFI64();
case CallingConv::Fast:
case CallingConv::Tail:
case CallingConv::Swift:
Expand Down