llvm.org GIT mirror llvm / ec3579f
revert 79631 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79685 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
10 changed file(s) with 8 addition(s) and 197 deletion(s). Raw diff Collapse all Expand all
7272 DbgInfo.BeginFunction(MF);
7373
7474 // Emit the autos section of function.
75 EmitAutos(F);
75 EmitAutos(CurrentFnName);
7676
7777 // Now emit the instructions of function in its code section.
7878 const MCSection *fCodeSection =
361361 const TargetData *TD = TM.getTargetData();
362362 // Emit the data section name.
363363 O << "\n";
364
365 std::string SectionName = getObjFileLowering().getNameForFunctFrame(F);
364
366365 const MCSection *fPDataSection =
367 getObjFileLowering().getSectionForFunctionFrame(SectionName);
366 getObjFileLowering().getSectionForFunctionFrame(CurrentFnName);
368367 OutStreamer.SwitchSection(fPDataSection);
369368
370369 // Emit function frame label
440439 }
441440 }
442441
443 void PIC16AsmPrinter::EmitAutos(const Function *F) {
442 void PIC16AsmPrinter::EmitAutos(std::string FunctName) {
444443 // Section names for all globals are already set.
445444 const TargetData *TD = TM.getTargetData();
446445
447446 // Now print Autos section for this function.
448 std::string SectionName = PAN::getAutosSectionName(CurrentFnName);
447 std::string SectionName = PAN::getAutosSectionName(FunctName);
449448
450449 // If this function is a cloned function then the name of auto section
451450 // will not be present in the list of existing section. Hence this section
459458 if (AutosSections[i]->S_->getName() == SectionName) {
460459 // Set the printing status to true
461460 AutosSections[i]->setPrintedStatus(true);
462 // Overlay auto sections with same function color.
463 std::string BaseSectionName = getObjFileLowering().
464 getNameForFunctFrame(F, true);
465 if (BaseSectionName != F->getName()) {
466 std::string NewSectionName = PAN::getAutosSectionName(BaseSectionName);
467 const_cast(AutosSections[i]->S_)->setName(
468 NewSectionName);
469 }
470
471461 OutStreamer.SwitchSection(AutosSections[i]->S_);
472462 const std::vector &Items = AutosSections[i]->Items;
473463 for (unsigned j = 0; j < Items.size(); j++) {
5151 void EmitDefinedVars (Module &M);
5252 void EmitIData (Module &M);
5353 void EmitUData (Module &M);
54 void EmitAutos (const Function *F);
54 void EmitAutos (std::string FunctName);
5555 void EmitRemainingAutos ();
5656 void EmitRomData (Module &M);
5757 void EmitFunctionFrame(MachineFunction &MF);
2727 public:
2828
2929 const std::string &getName() const { return Name; }
30
31 void setName(std::string name) { Name = name; }
30
3231 static MCSectionPIC16 *Create(const StringRef &Name,
3332 SectionKind K, MCContext &Ctx);
3433
4343 UGE
4444 };
4545 }
46
4746 // External symbol names require memory to live till the program end.
4847 // So we have to allocate it and keep.
4948 inline static const char *createESName (const std::string &name) {
2121 #include
2222 #include
2323 #include
24
2425 namespace llvm {
25 namespace PIC16Overlay {
26 // Implement Overlay through colors because we may want to enhance overlay
27 // architecture later. More colors can be added then.
28 // Idea here is that functions with same color can be overlayed.
29 enum Overlay {
30 // A color name can only consist of upper case letters and underscore.
31 GREEN, // Stands for mainline functions that can be overlayed.
32 GREEN_IL, // Interrupt line version of GREEN.
33 RED // Stands for functions that can not be overlayed.
34 };
35 }
36
3726 // A Central class to manage all ABI naming conventions.
3827 // PAN - [P]ic16 [A]BI [N]ames
3928 class PAN {
424413 }
425414 }
426415 }
427 inline static std::string getOverlayStr(unsigned Color) {
428 std::string Str = "Overlay=";
429 Str.append(getSectionNameForColor(Color));
430 return Str;
431 }
432
433 inline static std::string getSectionNameForColor(unsigned Color) {
434 switch (Color) {
435 default:
436 assert( 0 && "Color not supported");
437 case PIC16Overlay::GREEN:
438 return "GREEN";
439 case PIC16Overlay::GREEN_IL:
440 return "GREEN_IL";
441 }
442 }
443416
444417 inline static std::string getAutosSectionForColor(std::string Color) {
445418 return Color.append("_AUTOS");
1111
1212 LOADABLE_MODULE = 1
1313
14 # Hack: we need to include 'main' pic16 target directory to grab private headers
15 CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
16
1714 include $(LEVEL)/Makefile.common
1815
None //===-- PIC16FrameOverlay.cpp - Implementation for PIC16 Frame Overlay===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the PIC16 Frame Overlay implementation.
10 //
11 //===----------------------------------------------------------------------===//
12
13
14 #include "llvm/Analysis/CallGraph.h"
15 #include "llvm/Pass.h"
16 #include "llvm/Module.h"
17 #include "llvm/Support/raw_ostream.h"
18 #include "PIC16.h"
19 #include "PIC16FrameOverlay.h"
20 #include
21 #include
22 using namespace llvm;
23 using std::vector;
24 using std::string;
25
26
27 void PIC16FrameOverlay::getAnalysisUsage(AnalysisUsage &AU) const {
28 AU.setPreservesCFG();
29 AU.addRequired();
30 }
31
32 bool PIC16FrameOverlay::runOnModule(Module &M) {
33 CallGraph &CG = getAnalysis();
34 for (CallGraph::iterator it = CG.begin() ; it != CG.end(); it++)
35 {
36 // External calling node doesn't have any function associated
37 // with it
38 if (!it->first)
39 continue;
40
41 if (it->second->size() == 0) {
42 if (PAN::isInterruptLineFunction(it->first))
43 ColorFunction(it->second, PIC16Overlay::GREEN_IL);
44 else
45 ColorFunction(it->second, PIC16Overlay::GREEN);
46 }
47 }
48 return false;
49 }
50
51 void PIC16FrameOverlay::ColorFunction(CallGraphNode *CGN, unsigned Color) {
52 switch (Color) {
53 case PIC16Overlay::GREEN:
54 case PIC16Overlay::GREEN_IL: {
55 Function *LeafFunct = CGN->getFunction();
56 std::string Section = "";
57 if (LeafFunct->hasSection()) {
58 Section = LeafFunct->getSection();
59 Section.append(" ");
60 }
61 Section.append(PAN::getOverlayStr(Color));
62 LeafFunct->setSection(Section);
63 break;
64 }
65 default:
66 assert( 0 && "Color not supported");
67 }
68 }
None //===-- PIC16FrameOverlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the PIC16 Frame Overlay infrastructure.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef PIC16FRAMEOVERLAY_H
14 #define PIC16FRAMEOVERLAY_H
15
16 #include "llvm/Analysis/CallGraph.h"
17 #include "llvm/Pass.h"
18 #include "llvm/Module.h"
19 #include "llvm/Support/raw_ostream.h"
20 #include
21 #include
22 using std::vector;
23 using std::string;
24 using namespace llvm;
25
26 namespace {
27
28 class PIC16FrameOverlay : public ModulePass {
29 public:
30 static char ID; // Class identification
31 PIC16FrameOverlay() : ModulePass(&ID) {}
32
33 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
34 virtual bool runOnModule(Module &M);
35 private:
36 void ColorFunction(CallGraphNode *CGN, unsigned Color);
37 };
38 char PIC16FrameOverlay::ID = 0;
39 static RegisterPass
40 Y("pic16overlay", "PIC16 Frame Overlay Analysis");
41
42 } // End of namespace
43
44 #endif
7979 getSectionForFunctionFrame(const std::string &FnName) const {
8080 std::string T = PAN::getFrameSectionName(FnName);
8181 return getPIC16Section(T.c_str(), SectionKind::getDataRel());
82 }
83
84 std::string PIC16TargetObjectFile::getNameForFunctFrame(const Function *F,
85 bool IsAutosSection) {
86 std::string SectionName = F->getName();
87 if (F->hasSection()) {
88 std::string Sectn = F->getSection();
89 std::string StrToFind = "Overlay=";
90 size_t Pos = Sectn.find(StrToFind);
91 if (Pos != std::string::npos) {
92 Pos += StrToFind.length();
93 std::string Color = "";
94 char c = Sectn.at(Pos);
95 // A Color can only consist on upper case letters or underscore.
96 while ((c >= 'A' && c<= 'Z') || c == '_') {
97 Color.append(1,c);
98 Pos++;
99 if (Pos >= Sectn.length())
100 break;
101 c = Sectn.at(Pos);
102 }
103 // Autos Section need to be given a different name from function frame.
104 if (IsAutosSection)
105 SectionName = PAN::getAutosSectionForColor(Color);
106 else
107 SectionName = Color;
108 }
109 }
110 return SectionName;
11182 }
11283
11384 const MCSection *
1111
1212 #include "llvm/Target/TargetLoweringObjectFile.h"
1313 #include "llvm/ADT/StringMap.h"
14 #include "llvm/Function.h"
1514 #include
1615 #include
1716
8483 // If the current function is cloned then create the new autos section
8584 // also.
8685 void createClonedSectionForAutos(const std::string &SecName);
87 std::string getNameForFunctFrame(const Function *F,
88 bool IsAutosSection = false);
89
9086 private:
9187 std::string getSectionNameForSym(const std::string &Sym) const;
9288