aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86COFFMachineModuleInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-12 19:42:40 +0000
committerChris Lattner <sabre@nondot.org>2010-03-12 19:42:40 +0000
commitc9747c05d1fc01678fb86b3bc4674656228269bc (patch)
tree358dae643112b22e265461ef3e8b5c01882f622e /lib/Target/X86/X86COFFMachineModuleInfo.cpp
parent355670bf0fe759b6562ad1411642806fcc64af3c (diff)
eliminate the string form of DecorateCygMingName
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86COFFMachineModuleInfo.cpp')
-rw-r--r--lib/Target/X86/X86COFFMachineModuleInfo.cpp45
1 files changed, 15 insertions, 30 deletions
diff --git a/lib/Target/X86/X86COFFMachineModuleInfo.cpp b/lib/Target/X86/X86COFFMachineModuleInfo.cpp
index fcdeba1b1c..8fbd20714d 100644
--- a/lib/Target/X86/X86COFFMachineModuleInfo.cpp
+++ b/lib/Target/X86/X86COFFMachineModuleInfo.cpp
@@ -22,65 +22,50 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-X86COFFMachineModuleInfo::X86COFFMachineModuleInfo(const MachineModuleInfo &) {
-}
-X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() {
-}
-void X86COFFMachineModuleInfo::addExternalFunction(const StringRef& Name) {
- CygMingStubs.insert(Name);
+X86COFFMachineModuleInfo::~X86COFFMachineModuleInfo() {
}
-/// DecorateCygMingName - Apply various name decorations if the function uses
-/// stdcall or fastcall calling convention.
-void X86COFFMachineModuleInfo::DecorateCygMingName(SmallVectorImpl<char> &Name,
- const GlobalValue *GV,
+/// DecorateCygMingName - Query FunctionInfoMap and use this information for
+/// various name decorations for Cygwin and MingW.
+void X86COFFMachineModuleInfo::DecorateCygMingName(MCSymbol *&NameSym,
+ MCContext &Ctx,
+ const Function *F,
const TargetData &TD) {
- const Function *F = dyn_cast<Function>(GV);
- if (!F) return;
-
+ SmallString<128> Name(NameSym->getName().begin(), NameSym->getName().end());
+
// We don't want to decorate non-stdcall or non-fastcall functions right now
CallingConv::ID CC = F->getCallingConv();
if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
return;
-
+
unsigned ArgWords = 0;
// Calculate arguments sizes
for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
AI != AE; ++AI) {
const Type *Ty = AI->getType();
-
+
// 'Dereference' type in case of byval parameter attribute
if (AI->hasByValAttr())
Ty = cast<PointerType>(Ty)->getElementType();
-
+
// Size should be aligned to DWORD boundary
ArgWords += ((TD.getTypeAllocSize(Ty) + 3)/4)*4;
}
-
+
const FunctionType *FT = F->getFunctionType();
// "Pure" variadic functions do not receive @0 suffix.
if (!FT->isVarArg() || FT->getNumParams() == 0 ||
(FT->getNumParams() == 1 && F->hasStructRetAttr()))
raw_svector_ostream(Name) << '@' << ArgWords;
-
+
if (CC == CallingConv::X86_FastCall) {
if (Name[0] == '_')
Name[0] = '@';
else
Name.insert(Name.begin(), '@');
}
-}
-
-/// DecorateCygMingName - Query FunctionInfoMap and use this information for
-/// various name decorations for Cygwin and MingW.
-void X86COFFMachineModuleInfo::DecorateCygMingName(MCSymbol *&Name,
- MCContext &Ctx,
- const GlobalValue *GV,
- const TargetData &TD) {
- SmallString<128> NameStr(Name->getName().begin(), Name->getName().end());
- DecorateCygMingName(NameStr, GV, TD);
-
- Name = Ctx.GetOrCreateSymbol(NameStr.str());
+
+ NameSym = Ctx.GetOrCreateSymbol(Name.str());
}