From: Micah Villmow Date: Thu, 13 Sep 2012 15:11:12 +0000 (+0000) Subject: Unify the emission of the calling conventions into a single function to reduce code... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d3766dfd2cc105465300ef1b688086def757e645;p=oota-llvm.git 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 --- diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index f2945ac88ff..1fd649b0a00 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -66,6 +66,24 @@ static const Module *getModuleFromVal(const Value *V) { 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 // it if it is not printable or if it is an escape char. static void PrintEscapedString(StringRef Name, raw_ostream &Out) { @@ -1530,20 +1548,9 @@ void AssemblyWriter::printFunction(const Function *F) { PrintVisibility(F->getVisibility(), Out); // Print the calling convention. - switch (F->getCallingConv()) { - case CallingConv::C: break; // default - 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" << F->getCallingConv() << " "; break; + if (F->getCallingConv() != CallingConv::C) { + PrintCallingConv(F->getCallingConv(), Out); + Out << " "; } FunctionType *FT = F->getFunctionType(); @@ -1831,20 +1838,9 @@ void AssemblyWriter::printInstruction(const Instruction &I) { Out << " void"; } else if (const CallInst *CI = dyn_cast(&I)) { // Print the calling convention being used. - switch (CI->getCallingConv()) { - case CallingConv::C: break; // default - 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" << CI->getCallingConv(); break; + if (CI->getCallingConv() != CallingConv::C) { + Out << " "; + PrintCallingConv(CI->getCallingConv(), Out); } Operand = CI->getCalledValue(); @@ -1887,20 +1883,9 @@ void AssemblyWriter::printInstruction(const Instruction &I) { const AttrListPtr &PAL = II->getAttributes(); // Print the calling convention being used. - switch (II->getCallingConv()) { - case CallingConv::C: break; // default - 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" << II->getCallingConv(); break; + if (II->getCallingConv() != CallingConv::C) { + Out << " "; + PrintCallingConv(II->getCallingConv(), Out); } if (PAL.getRetAttributes() != Attribute::None)