diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2006-09-17 20:25:45 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2006-09-17 20:25:45 +0000 |
commit | bcb9770efe409f3291ce21269904744e7bf3397b (patch) | |
tree | 88414cb50a458549c4b76bc1f5c7b33cad02f991 /lib/Target | |
parent | 2f463865c2f03b8835e35d3499fcd95eed922bc6 (diff) |
Added some eye-candy for Subtarget type checking
Added X86 StdCall & FastCall calling conventions. Codegen will follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30446 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 10 | ||||
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 10 | ||||
-rw-r--r-- | lib/Target/X86/README.txt | 26 | ||||
-rwxr-xr-x | lib/Target/X86/X86ATTAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelDAGToDAG.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/X86RegisterInfo.cpp | 4 |
8 files changed, 51 insertions, 9 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 2aa36270bf..23bd41d8dd 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1278,7 +1278,15 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) { if (F->hasInternalLinkage()) Out << "static "; if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) "; if (F->hasDLLExportLinkage()) Out << "__declspec(dllexport) "; - + switch (F->getCallingConv()) { + case CallingConv::X86_StdCall: + Out << "__stdcall "; + break; + case CallingConv::X86_FastCall: + Out << "__fastcall "; + break; + } + // Loop over the arguments, printing them... const FunctionType *FT = cast<FunctionType>(F->getFunctionType()); diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 2aa36270bf..23bd41d8dd 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1278,7 +1278,15 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) { if (F->hasInternalLinkage()) Out << "static "; if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) "; if (F->hasDLLExportLinkage()) Out << "__declspec(dllexport) "; - + switch (F->getCallingConv()) { + case CallingConv::X86_StdCall: + Out << "__stdcall "; + break; + case CallingConv::X86_FastCall: + Out << "__fastcall "; + break; + } + // Loop over the arguments, printing them... const FunctionType *FT = cast<FunctionType>(F->getFunctionType()); diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index b6add7a494..62c8ab1dcc 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -707,3 +707,29 @@ etc. //===---------------------------------------------------------------------===// +Currently we don't have elimination of redundant stack manipulations. Consider +the code: + +int %main() { +entry: + call fastcc void %test1( ) + call fastcc void %test2( sbyte* cast (void ()* %test1 to sbyte*) ) + ret int 0 +} + +declare fastcc void %test1() + +declare fastcc void %test2(sbyte*) + + +This currently compiles to: + + subl $16, %esp + call _test5 + addl $12, %esp + subl $16, %esp + movl $_test5, (%esp) + call _test6 + addl $12, %esp + +The add\sub pair is really unneeded here. diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index 1ce24fda0c..52d551894a 100755 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -63,7 +63,7 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F); O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.weak_definition\t" << CurrentFnName << "\n"; - } else if (Subtarget->TargetType == X86Subtarget::isCygwin) { + } else if (Subtarget->isTargetCygwin()) { EmitAlignment(4, F); // FIXME: This should be parameterized somewhere. O << "\t.section\t.llvm.linkonce.t." << CurrentFnName << ",\"ax\"\n"; diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 08dc7b2650..d7dc70c567 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -83,7 +83,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { } else O << TAI->getCOMMDirective() << name << "," << Size; } else { - if (Subtarget->TargetType != X86Subtarget::isCygwin) { + if (!Subtarget->isTargetCygwin()) { if (I->hasInternalLinkage()) O << "\t.local\t" << name << "\n"; } @@ -101,7 +101,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) { O << "\t.globl " << name << "\n" << "\t.weak_definition " << name << "\n"; SwitchToDataSection(".section __DATA,__const_coal,coalesced", I); - } else if (Subtarget->TargetType == X86Subtarget::isCygwin) { + } else if (Subtarget->isTargetCygwin()) { O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\"\n" << "\t.weak " << name << "\n"; } else { diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 144776e68c..af54b7b6aa 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -468,7 +468,7 @@ void X86DAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) { /// the main function. void X86DAGToDAGISel::EmitSpecialCodeForMain(MachineBasicBlock *BB, MachineFrameInfo *MFI) { - if (Subtarget->TargetType == X86Subtarget::isCygwin) + if (Subtarget->isTargetCygwin()) BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("__main"); // Switch the FPU to 64-bit precision mode for better compatibility and speed. diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index c86d171197..3baff5cd93 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -3907,7 +3907,7 @@ X86TargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) { MachineFunction &MF = DAG.getMachineFunction(); const Function* Fn = MF.getFunction(); if (Fn->hasExternalLinkage() && - Subtarget->TargetType == X86Subtarget::isCygwin && + Subtarget->isTargetCygwin() && Fn->getName() == "main") MF.getInfo<X86FunctionInfo>()->setForceFramePointer(true); diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index 40d7a6c383..bfc99233e2 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -993,7 +993,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { MFI->setStackSize(NumBytes); if (NumBytes) { // adjust stack pointer: ESP -= numbytes - if (NumBytes >= 4096 && Subtarget->TargetType == X86Subtarget::isCygwin) { + if (NumBytes >= 4096 && Subtarget->isTargetCygwin()) { // Function prologue calls _alloca to probe the stack when allocating // more than 4k bytes in one go. Touching the stack at 4K increments is // necessary to ensure that the guard pages used by the OS virtual memory @@ -1035,7 +1035,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { // If it's main() on Cygwin\Mingw32 we should align stack as well if (Fn->hasExternalLinkage() && Fn->getName() == "main" && - Subtarget->TargetType == X86Subtarget::isCygwin) { + Subtarget->isTargetCygwin()) { MI = BuildMI(X86::AND32ri, 2, X86::ESP).addReg(X86::ESP).addImm(-Align); MBB.insert(MBBI, MI); |