llvm.org GIT mirror llvm / e87e115
Various random and minor code cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30608 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
6 changed file(s) with 43 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
4747
4848 // Populate function information map. Actually, We don't want to populate
4949 // non-stdcall or non-fastcall functions' information right now.
50 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall) {
51 FunctionInfoMap[F] = *(MF.getInfo());
52 }
50 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
51 FunctionInfoMap[F] = *MF.getInfo();
5352
5453 X86SharedAsmPrinter::decorateName(CurrentFnName, F);
5554
199198 bool isExt = (GV->isExternal() || GV->hasWeakLinkage() ||
200199 GV->hasLinkOnceLinkage());
201200
202 X86SharedAsmPrinter::decorateName(Name, (Function*)GV);
201 X86SharedAsmPrinter::decorateName(Name, GV);
203202
204203 if (X86PICStyle == PICStyle::Stub &&
205204 TM.getRelocationModel() != Reloc::Static) {
3232 Statistic<> llvm::EmittedInsts("asm-printer",
3333 "Number of machine instrs printed");
3434
35 static X86FunctionInfo calculateFunctionInfo(const Function* F,
36 const TargetData* TD)
37 {
35 static X86FunctionInfo calculateFunctionInfo(const Function *F,
36 const TargetData *TD) {
3837 X86FunctionInfo Info;
39 uint64_t size = 0;
38 uint64_t Size = 0;
4039
4140 switch (F->getCallingConv()) {
42 case CallingConv::X86_StdCall:
41 case CallingConv::X86_StdCall:
4342 Info.setDecorationStyle(StdCall);
4443 break;
45 case CallingConv::X86_FastCall:
44 case CallingConv::X86_FastCall:
4645 Info.setDecorationStyle(FastCall);
4746 break;
48 default:
47 default:
4948 return Info;
5049 }
5150
52 for (Function::const_arg_iterator AI = F->arg_begin(),
53 AE = F->arg_end();
54 AI != AE;
55 ++AI) {
56 size += TD->getTypeSize(AI->getType());
57 }
51 for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
52 AI != AE; ++AI)
53 Size += TD->getTypeSize(AI->getType());
5854
5955 // We're not supporting tooooo huge arguments :)
60 Info.setBytesToPopOnReturn((unsigned int)size);
61
56 Info.setBytesToPopOnReturn((unsigned int)Size);
6257 return Info;
6358 }
6459
6560
66 // Query FunctionInfoMap and use this information for various name decoration
67 void X86SharedAsmPrinter::decorateName(std::string& Name, const GlobalValue* GV)
68 {
69 const X86FunctionInfo* Info;
70 const Function* F;
71
72 if ((F = dyn_cast(GV)) == NULL) {
61 /// decorateName - Query FunctionInfoMap and use this information for various
62 /// name decoration.
63 void X86SharedAsmPrinter::decorateName(std::string &Name,
64 const GlobalValue *GV) {
65 const Function *F = dyn_cast(GV);
66 if (!F) return;
67
68 // We don't want to decorate non-stdcall or non-fastcall functions right now
69 unsigned CC = F->getCallingConv();
70 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
7371 return;
74 }
75
76 unsigned CC = F->getCallingConv();
77
78 // We don't want to decorate non-stdcall or non-fastcall functions right now
79 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall) {
80 return;
81 }
8272
8373 FMFInfoMap::const_iterator info_item = FunctionInfoMap.find(F);
8474
75 const X86FunctionInfo *Info;
8576 if (info_item == FunctionInfoMap.end()) {
8677 // Calculate apropriate function info and populate map
8778 FunctionInfoMap[F] = calculateFunctionInfo(F, TM.getTargetData());
8879 Info = &FunctionInfoMap[F];
8980 } else {
90 Info = &(info_item->second);
81 Info = &info_item->second;
9182 }
9283
9384 switch (Info->getDecorationStyle()) {
94 case None:
95 break;
96 case StdCall:
97 if (!F->isVarArg()) {
98 // Variadic functions do not receive @0 suffix
85 case None:
86 break;
87 case StdCall:
88 if (!F->isVarArg()) // Variadic functions do not receive @0 suffix.
9989 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
100 }
101 break;
102 case FastCall:
103 if (!F->isVarArg()) {
104 // Variadic functions do not receive @0 suffix
90 break;
91 case FastCall:
92 if (!F->isVarArg()) // Variadic functions do not receive @0 suffix.
10593 Name += '@' + utostr_32(Info->getBytesToPopOnReturn());
106 }
94
10795 if (Name[0] == '_') {
10896 Name[0] = '@';
10997 } else {
11098 Name = '@' + Name;
11199 }
112100 break;
113 default:
101 default:
114102 assert(0 && "Unsupported DecorationStyle");
115103 }
116
117104 }
118105
119106 /// doInitialization
4545 Subtarget = &TM.getSubtarget();
4646 }
4747
48 typedef std::map FMFInfoMap ;
49
5048 // We have to propagate some information about MachineFunction to
5149 // AsmPrinter. It's ok, when we're printing the function, since we have
52 // access to MachineFunction and can get the appropriate MachineFunctionInfo.
50 // access to MachineFunction and can get the appropriate MachineFunctionInfo.
5351 // Unfortunately, this is not possible when we're printing reference to
5452 // Function (e.g. calling it and so on). Even more, there is no way to get the
5553 // corresponding MachineFunctions: it can even be not created at all. That's
5654 // why we should use additional structure, when we're collecting all necessary
5755 // information.
58
56 //
5957 // This structure is using e.g. for name decoration for stdcall & fastcall'ed
6058 // function, since we have to use arguments' size for decoration.
59 typedef std::map FMFInfoMap;
6160 FMFInfoMap FunctionInfoMap;
6261
6362 void decorateName(std::string& Name, const GlobalValue* GV);
15221522 return DAG.getNode(ISD::MERGE_VALUES, RetVTs, &ArgValues[0],ArgValues.size());
15231523 }
15241524
1525 SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op,
1526 SelectionDAG &DAG,
1527 bool isFastCall){
1525 SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG,
1526 bool isFastCall) {
15281527 SDOperand Chain = Op.getOperand(0);
15291528 unsigned CallingConv= cast(Op.getOperand(1))->getValue();
15301529 bool isVarArg = cast(Op.getOperand(2))->getValue() != 0;
3535 EmitConstantPool(MF.getConstantPool());
3636
3737 // Print out labels for the function.
38 const Function* F = MF.getFunction();
38 const Function *F = MF.getFunction();
3939 unsigned CC = F->getCallingConv();
4040
4141 // Populate function information map. Actually, We don't want to populate
4242 // non-stdcall or non-fastcall functions' information right now.
43 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall) {
44 FunctionInfoMap[F] = *(MF.getInfo());
45 }
43 if (CC == CallingConv::X86_StdCall || CC == CallingConv::X86_FastCall)
44 FunctionInfoMap[F] = *MF.getInfo();
4645
4746 X86SharedAsmPrinter::decorateName(CurrentFnName, F);
4847
4545 BytesToPopOnReturn(0),
4646 DecorationStyle(None) {}
4747
48 X86FunctionInfo(MachineFunction& MF) : ForceFramePointer(false),
48 X86FunctionInfo(MachineFunction &MF) : ForceFramePointer(false),
4949 BytesToPopOnReturn(0),
5050 DecorationStyle(None) {}
5151