- Rename AnalysisUsage::preservesAll to getPreservesAll & preservesCFG to
[oota-llvm.git] / lib / CodeGen / Mapping / FInfo.cpp
1 #include "llvm/Reoptimizer/Mapping/FInfo.h"
2 #include "llvm/Pass.h"
3 #include "llvm/Module.h"
4
5
6 namespace {
7   class FunctionInfo : public Pass {
8     std::ostream &Out;
9   public:
10     FunctionInfo(std::ostream &out) : Out(out){}
11     const char* getPassName() const{return "Sparc FunctionInfo";}
12     bool run(Module &M);
13   private:
14     void FunctionInfo::writePrologue(const char *area,
15                                         const char *label);
16     void FunctionInfo::writeEpilogue(const char *area,
17                                         const char *label);
18   };
19 }
20
21 Pass *getFunctionInfo(std::ostream &out){
22   return new FunctionInfo(out);
23 }
24
25 bool FunctionInfo::run(Module &M){
26   unsigned f;
27   
28   writePrologue("FUNCTION MAP", "FunctionBB");
29   f=0;
30   for(Module::iterator FI=M.begin(), FE=M.end(); FE!=FI; ++FI){
31     if(FI->isExternal()) continue;
32     Out << "\t.xword BBMIMap"<<f<<"\n";
33     ++f;
34   }
35   writeEpilogue("FUNCTION MAP", "FunctionBB");
36   
37   writePrologue("FUNCTION MAP", "FunctionLI");
38   f=0;
39   for(Module::iterator FI=M.begin(), FE=M.end(); FE!=FI; ++FI){
40     if(FI->isExternal()) continue;
41     Out << "\t.xword LMIMap"<<f<<"\n";
42     ++f;
43   }
44   writeEpilogue("FUNCTION MAP", "FunctionLI");
45   
46   
47   return false;
48 }
49
50
51 void FunctionInfo::writePrologue(const char *area,
52                                     const char *label){
53   Out << "\n\n\n!"<<area<<"\n";   
54   Out << "\t.section \".rodata\"\n\t.align 8\n";  
55   Out << "\t.global "<<label<<"\n";    
56   Out << "\t.type "<<label<<",#object\n"; 
57   Out << label<<":\n"; 
58   //Out << "\t.word .end_"<<label<<"-"<<label<<"\n";
59 }
60
61 void FunctionInfo::writeEpilogue(const char *area,
62                                     const char *label){
63   Out << ".end_" << label << ":\n";    
64   Out << "\t.size " << label << ", .end_" 
65       << label << "-" << label << "\n\n\n\n";
66   
67   //Out << "\n\n!" << area << " Length\n";
68   //Out << "\t.section \".bbdata\",#alloc,#write\n";                                     
69   //Out << "\t.global " << label << "_length\n";          
70   //Out << "\t.align 4\n";
71   //Out << "\t.type " << label << "_length,#object\n";
72   //Out << "\t.size "<< label <<"_length,4\n";
73   //Out << label <<" _length:\n";
74   //Out << "\t.word\t.end_"<<label<<"-"<<label<<"\n\n\n\n";               
75 }