Files
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm
bindings
cmake
docs
examples
include
lib
Analysis
AsmParser
BinaryFormat
Bitcode
CodeGen
DebugInfo
Demangle
ExecutionEngine
FuzzMutate
Fuzzer
IR
IRReader
LTO
LineEditor
Linker
MC
Object
ObjectYAML
Option
Passes
ProfileData
Support
TableGen
Target
AArch64
AMDGPU
ARC
ARM
AVR
BPF
Hexagon
Lanai
MSP430
Mips
NVPTX
Nios2
PowerPC
RISCV
Sparc
SystemZ
WebAssembly
X86
AsmParser
Disassembler
InstPrinter
MCTargetDesc
TargetInfo
Utils
CMakeLists.txt
LLVMBuild.txt
README-FPStack.txt
README-MMX.txt
README-SSE.txt
README-UNIMPLEMENTED.txt
README-X86-64.txt
README.txt
X86.h
X86.td
X86AsmPrinter.cpp
X86AsmPrinter.h
X86CallFrameOptimization.cpp
X86CallLowering.cpp
X86CallLowering.h
X86CallingConv.cpp
X86CallingConv.h
X86CallingConv.td
X86CmovConversion.cpp
X86DomainReassignment.cpp
X86EvexToVex.cpp
X86ExpandPseudo.cpp
X86FastISel.cpp.REMOVED.git-id
X86FixupBWInsts.cpp
X86FixupLEAs.cpp
X86FixupSetCC.cpp
X86FlagsCopyLowering.cpp
X86FloatingPoint.cpp
X86FrameLowering.cpp.REMOVED.git-id
X86FrameLowering.h
X86GenRegisterBankInfo.def
X86ISelDAGToDAG.cpp.REMOVED.git-id
X86ISelLowering.cpp.REMOVED.git-id
X86ISelLowering.h
X86Instr3DNow.td
X86InstrAVX512.td.REMOVED.git-id
X86InstrArithmetic.td
X86InstrBuilder.h
X86InstrCMovSetCC.td
X86InstrCompiler.td
X86InstrControl.td
X86InstrExtension.td
X86InstrFMA.td
X86InstrFMA3Info.cpp
X86InstrFMA3Info.h
X86InstrFPStack.td
X86InstrFormats.td
X86InstrFragmentsSIMD.td
X86InstrInfo.cpp.REMOVED.git-id
X86InstrInfo.h
X86InstrInfo.td.REMOVED.git-id
X86InstrMMX.td
X86InstrMPX.td
X86InstrSGX.td
X86InstrSSE.td.REMOVED.git-id
X86InstrSVM.td
X86InstrShiftRotate.td
X86InstrSystem.td
X86InstrTSX.td
X86InstrVMX.td
X86InstrVecCompiler.td
X86InstrXOP.td
X86InstructionSelector.cpp
X86InterleavedAccess.cpp
X86IntrinsicsInfo.h.REMOVED.git-id
X86LegalizerInfo.cpp
X86LegalizerInfo.h
X86MCInstLower.cpp
X86MachineFunctionInfo.cpp
X86MachineFunctionInfo.h
X86MacroFusion.cpp
X86MacroFusion.h
X86OptimizeLEAs.cpp
X86PadShortFunction.cpp
X86RegisterBankInfo.cpp
X86RegisterBankInfo.h
X86RegisterBanks.td
X86RegisterInfo.cpp
X86RegisterInfo.h
X86RegisterInfo.td
X86RetpolineThunks.cpp
X86SchedBroadwell.td.REMOVED.git-id
X86SchedHaswell.td.REMOVED.git-id
X86SchedSandyBridge.td.REMOVED.git-id
X86SchedSkylakeClient.td.REMOVED.git-id
X86SchedSkylakeServer.td.REMOVED.git-id
X86Schedule.td
X86ScheduleAtom.td
X86ScheduleBtVer2.td
X86ScheduleSLM.td
X86ScheduleZnver1.td
X86SelectionDAGInfo.cpp
X86SelectionDAGInfo.h
X86ShuffleDecodeConstantPool.cpp
X86ShuffleDecodeConstantPool.h
X86Subtarget.cpp
X86Subtarget.h
X86TargetMachine.cpp
X86TargetMachine.h
X86TargetObjectFile.cpp
X86TargetObjectFile.h
X86TargetTransformInfo.cpp.REMOVED.git-id
X86TargetTransformInfo.h
X86VZeroUpper.cpp
X86WinAllocaExpander.cpp
X86WinEHState.cpp
XCore
CMakeLists.txt
LLVMBuild.txt
README.txt
Target.cpp
TargetIntrinsicInfo.cpp
TargetLoweringObjectFile.cpp
TargetMachine.cpp
TargetMachineC.cpp
Testing
ToolDrivers
Transforms
WindowsManifest
XRay
CMakeLists.txt
LLVMBuild.txt
projects
resources
runtimes
scripts
test
tools
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
libgc
llvm
m4
man
mcs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/external/llvm/lib/Target/X86/X86CallingConv.h

122 lines
4.8 KiB
C
Raw Normal View History

//=== X86CallingConv.h - X86 Custom Calling Convention Routines -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the custom routines for the X86 Calling Convention that
// aren't done by tablegen.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIB_TARGET_X86_X86CALLINGCONV_H
#define LLVM_LIB_TARGET_X86_X86CALLINGCONV_H
#include "MCTargetDesc/X86MCTargetDesc.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/IR/CallingConv.h"
namespace llvm {
/// When regcall calling convention compiled to 32 bit arch, special treatment
/// is required for 64 bit masks.
/// The value should be assigned to two GPRs.
/// \return true if registers were allocated and false otherwise.
bool CC_X86_32_RegCall_Assign2Regs(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
CCValAssign::LocInfo &LocInfo,
ISD::ArgFlagsTy &ArgFlags, CCState &State);
/// Vectorcall calling convention has special handling for vector types or
/// HVA for 64 bit arch.
/// For HVAs shadow registers might be allocated on the first pass
/// and actual XMM registers are allocated on the second pass.
/// For vector types, actual XMM registers are allocated on the first pass.
/// \return true if registers were allocated and false otherwise.
bool CC_X86_64_VectorCall(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
CCValAssign::LocInfo &LocInfo,
ISD::ArgFlagsTy &ArgFlags, CCState &State);
/// Vectorcall calling convention has special handling for vector types or
/// HVA for 32 bit arch.
/// For HVAs actual XMM registers are allocated on the second pass.
/// For vector types, actual XMM registers are allocated on the first pass.
/// \return true if registers were allocated and false otherwise.
bool CC_X86_32_VectorCall(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
CCValAssign::LocInfo &LocInfo,
ISD::ArgFlagsTy &ArgFlags, CCState &State);
inline bool CC_X86_AnyReg_Error(unsigned &, MVT &, MVT &,
CCValAssign::LocInfo &, ISD::ArgFlagsTy &,
CCState &) {
llvm_unreachable("The AnyReg calling convention is only supported by the " \
"stackmap and patchpoint intrinsics.");
// gracefully fallback to X86 C calling convention on Release builds.
return false;
}
inline bool CC_X86_32_MCUInReg(unsigned &ValNo, MVT &ValVT,
MVT &LocVT,
CCValAssign::LocInfo &LocInfo,
ISD::ArgFlagsTy &ArgFlags,
CCState &State) {
// This is similar to CCAssignToReg<[EAX, EDX, ECX]>, but makes sure
// not to split i64 and double between a register and stack
static const MCPhysReg RegList[] = {X86::EAX, X86::EDX, X86::ECX};
static const unsigned NumRegs = sizeof(RegList)/sizeof(RegList[0]);
SmallVectorImpl<CCValAssign> &PendingMembers = State.getPendingLocs();
// If this is the first part of an double/i64/i128, or if we're already
// in the middle of a split, add to the pending list. If this is not
// the end of the split, return, otherwise go on to process the pending
// list
if (ArgFlags.isSplit() || !PendingMembers.empty()) {
PendingMembers.push_back(
CCValAssign::getPending(ValNo, ValVT, LocVT, LocInfo));
if (!ArgFlags.isSplitEnd())
return true;
}
// If there are no pending members, we are not in the middle of a split,
// so do the usual inreg stuff.
if (PendingMembers.empty()) {
if (unsigned Reg = State.AllocateReg(RegList)) {
State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
return true;
}
return false;
}
assert(ArgFlags.isSplitEnd());
// We now have the entire original argument in PendingMembers, so decide
// whether to use registers or the stack.
// Per the MCU ABI:
// a) To use registers, we need to have enough of them free to contain
// the entire argument.
// b) We never want to use more than 2 registers for a single argument.
unsigned FirstFree = State.getFirstUnallocated(RegList);
bool UseRegs = PendingMembers.size() <= std::min(2U, NumRegs - FirstFree);
for (auto &It : PendingMembers) {
if (UseRegs)
It.convertToReg(State.AllocateReg(RegList[FirstFree++]));
else
It.convertToMem(State.AllocateStack(4, 4));
State.addLoc(It);
}
PendingMembers.clear();
return true;
}
} // End llvm namespace
#endif