mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-01 01:30:36 +00:00
Unify the emission of the calling conventions into a single function to reduce code duplication.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
616471d4bf
commit
d3766dfd2c
@ -66,6 +66,24 @@ static const Module *getModuleFromVal(const Value *V) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PrintCallingConv(unsigned cc, raw_ostream &Out)
|
||||||
|
{
|
||||||
|
switch (cc) {
|
||||||
|
case CallingConv::Fast: Out << "fastcc"; break;
|
||||||
|
case CallingConv::Cold: Out << "coldcc"; break;
|
||||||
|
case CallingConv::X86_StdCall: Out << "x86_stdcallcc"; break;
|
||||||
|
case CallingConv::X86_FastCall: Out << "x86_fastcallcc"; break;
|
||||||
|
case CallingConv::X86_ThisCall: Out << "x86_thiscallcc"; break;
|
||||||
|
case CallingConv::ARM_APCS: Out << "arm_apcscc"; break;
|
||||||
|
case CallingConv::ARM_AAPCS: Out << "arm_aapcscc"; break;
|
||||||
|
case CallingConv::ARM_AAPCS_VFP:Out << "arm_aapcs_vfpcc"; break;
|
||||||
|
case CallingConv::MSP430_INTR: Out << "msp430_intrcc"; break;
|
||||||
|
case CallingConv::PTX_Kernel: Out << "ptx_kernel"; break;
|
||||||
|
case CallingConv::PTX_Device: Out << "ptx_device"; break;
|
||||||
|
default: Out << "cc" << cc; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PrintEscapedString - Print each character of the specified string, escaping
|
// PrintEscapedString - Print each character of the specified string, escaping
|
||||||
// it if it is not printable or if it is an escape char.
|
// it if it is not printable or if it is an escape char.
|
||||||
static void PrintEscapedString(StringRef Name, raw_ostream &Out) {
|
static void PrintEscapedString(StringRef Name, raw_ostream &Out) {
|
||||||
@ -1530,20 +1548,9 @@ void AssemblyWriter::printFunction(const Function *F) {
|
|||||||
PrintVisibility(F->getVisibility(), Out);
|
PrintVisibility(F->getVisibility(), Out);
|
||||||
|
|
||||||
// Print the calling convention.
|
// Print the calling convention.
|
||||||
switch (F->getCallingConv()) {
|
if (F->getCallingConv() != CallingConv::C) {
|
||||||
case CallingConv::C: break; // default
|
PrintCallingConv(F->getCallingConv(), Out);
|
||||||
case CallingConv::Fast: Out << "fastcc "; break;
|
Out << " ";
|
||||||
case CallingConv::Cold: Out << "coldcc "; break;
|
|
||||||
case CallingConv::X86_StdCall: Out << "x86_stdcallcc "; break;
|
|
||||||
case CallingConv::X86_FastCall: Out << "x86_fastcallcc "; break;
|
|
||||||
case CallingConv::X86_ThisCall: Out << "x86_thiscallcc "; break;
|
|
||||||
case CallingConv::ARM_APCS: Out << "arm_apcscc "; break;
|
|
||||||
case CallingConv::ARM_AAPCS: Out << "arm_aapcscc "; break;
|
|
||||||
case CallingConv::ARM_AAPCS_VFP:Out << "arm_aapcs_vfpcc "; break;
|
|
||||||
case CallingConv::MSP430_INTR: Out << "msp430_intrcc "; break;
|
|
||||||
case CallingConv::PTX_Kernel: Out << "ptx_kernel "; break;
|
|
||||||
case CallingConv::PTX_Device: Out << "ptx_device "; break;
|
|
||||||
default: Out << "cc" << F->getCallingConv() << " "; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionType *FT = F->getFunctionType();
|
FunctionType *FT = F->getFunctionType();
|
||||||
@ -1831,20 +1838,9 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||||||
Out << " void";
|
Out << " void";
|
||||||
} else if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
|
} else if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
|
||||||
// Print the calling convention being used.
|
// Print the calling convention being used.
|
||||||
switch (CI->getCallingConv()) {
|
if (CI->getCallingConv() != CallingConv::C) {
|
||||||
case CallingConv::C: break; // default
|
Out << " ";
|
||||||
case CallingConv::Fast: Out << " fastcc"; break;
|
PrintCallingConv(CI->getCallingConv(), Out);
|
||||||
case CallingConv::Cold: Out << " coldcc"; break;
|
|
||||||
case CallingConv::X86_StdCall: Out << " x86_stdcallcc"; break;
|
|
||||||
case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break;
|
|
||||||
case CallingConv::X86_ThisCall: Out << " x86_thiscallcc"; break;
|
|
||||||
case CallingConv::ARM_APCS: Out << " arm_apcscc "; break;
|
|
||||||
case CallingConv::ARM_AAPCS: Out << " arm_aapcscc "; break;
|
|
||||||
case CallingConv::ARM_AAPCS_VFP:Out << " arm_aapcs_vfpcc "; break;
|
|
||||||
case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break;
|
|
||||||
case CallingConv::PTX_Kernel: Out << " ptx_kernel"; break;
|
|
||||||
case CallingConv::PTX_Device: Out << " ptx_device"; break;
|
|
||||||
default: Out << " cc" << CI->getCallingConv(); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Operand = CI->getCalledValue();
|
Operand = CI->getCalledValue();
|
||||||
@ -1887,20 +1883,9 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||||||
const AttrListPtr &PAL = II->getAttributes();
|
const AttrListPtr &PAL = II->getAttributes();
|
||||||
|
|
||||||
// Print the calling convention being used.
|
// Print the calling convention being used.
|
||||||
switch (II->getCallingConv()) {
|
if (II->getCallingConv() != CallingConv::C) {
|
||||||
case CallingConv::C: break; // default
|
Out << " ";
|
||||||
case CallingConv::Fast: Out << " fastcc"; break;
|
PrintCallingConv(II->getCallingConv(), Out);
|
||||||
case CallingConv::Cold: Out << " coldcc"; break;
|
|
||||||
case CallingConv::X86_StdCall: Out << " x86_stdcallcc"; break;
|
|
||||||
case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break;
|
|
||||||
case CallingConv::X86_ThisCall: Out << " x86_thiscallcc"; break;
|
|
||||||
case CallingConv::ARM_APCS: Out << " arm_apcscc "; break;
|
|
||||||
case CallingConv::ARM_AAPCS: Out << " arm_aapcscc "; break;
|
|
||||||
case CallingConv::ARM_AAPCS_VFP:Out << " arm_aapcs_vfpcc "; break;
|
|
||||||
case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break;
|
|
||||||
case CallingConv::PTX_Kernel: Out << " ptx_kernel"; break;
|
|
||||||
case CallingConv::PTX_Device: Out << " ptx_device"; break;
|
|
||||||
default: Out << " cc" << II->getCallingConv(); break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PAL.getRetAttributes() != Attribute::None)
|
if (PAL.getRetAttributes() != Attribute::None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user