comparison ir/irfunction.h @ 1508:e1e93343fc11

Move function codegen data from IrFunction to new FuncGen. This change reduces memory consumption significantly by releasing the memory held by the STL containers that are now inside FuncGen.
author Christian Kamm <kamm incasoftware de>
date Sat, 20 Jun 2009 19:11:44 +0200
parents 3f5ea912149d
children
comparison
equal deleted inserted replaced
1503:cc5fee7836dc 1508:e1e93343fc11
27 27
28 IRTargetScope(); 28 IRTargetScope();
29 IRTargetScope(Statement* s, EnclosingHandler* enclosinghandler, llvm::BasicBlock* continueTarget, llvm::BasicBlock* breakTarget); 29 IRTargetScope(Statement* s, EnclosingHandler* enclosinghandler, llvm::BasicBlock* continueTarget, llvm::BasicBlock* breakTarget);
30 }; 30 };
31 31
32 struct FuncGen
33 {
34 FuncGen();
35
36 // pushes a unique label scope of the given name
37 void pushUniqueLabelScope(const char* name);
38 // pops a label scope
39 void popLabelScope();
40
41 // gets the string under which the label's BB
42 // is stored in the labelToBB map.
43 // essentially prefixes ident by the strings in labelScopes
44 std::string getScopedLabelName(const char* ident);
45
46 // label to basic block lookup
47 typedef std::map<std::string, llvm::BasicBlock*> LabelToBBMap;
48 LabelToBBMap labelToBB;
49
50 // loop blocks
51 typedef std::vector<IRTargetScope> TargetScopeVec;
52 TargetScopeVec targetScopes;
53
54 // landing pads for try statements
55 IRLandingPad landingPadInfo;
56 llvm::BasicBlock* landingPad;
57
58 private:
59 // prefix for labels and gotos
60 // used for allowing labels to be emitted twice
61 std::vector<std::string> labelScopes;
62
63 // next unique id stack
64 std::stack<int> nextUnique;
65 };
66
32 // represents a function 67 // represents a function
33 struct IrFunction : IrBase 68 struct IrFunction : IrBase
34 { 69 {
70 // constructor
71 IrFunction(FuncDeclaration* fd);
72
73 // annotations
74 void setNeverInline();
75 void setAlwaysInline();
76
35 llvm::Function* func; 77 llvm::Function* func;
36 llvm::Instruction* allocapoint; 78 llvm::Instruction* allocapoint;
37 FuncDeclaration* decl; 79 FuncDeclaration* decl;
38 TypeFunction* type; 80 TypeFunction* type;
81
82 FuncGen* gen;
39 83
40 bool queued; 84 bool queued;
41 bool defined; 85 bool defined;
42 86
43 llvm::Value* retArg; // return in ptr arg 87 llvm::Value* retArg; // return in ptr arg
52 96
53 llvm::Value* _arguments; 97 llvm::Value* _arguments;
54 llvm::Value* _argptr; 98 llvm::Value* _argptr;
55 99
56 llvm::DISubprogram diSubprogram; 100 llvm::DISubprogram diSubprogram;
57
58 // pushes a unique label scope of the given name
59 void pushUniqueLabelScope(const char* name);
60 // pops a label scope
61 void popLabelScope();
62
63 // gets the string under which the label's BB
64 // is stored in the labelToBB map.
65 // essentially prefixes ident by the strings in labelScopes
66 std::string getScopedLabelName(const char* ident);
67
68 // label to basic block lookup
69 typedef std::map<std::string, llvm::BasicBlock*> LabelToBBMap;
70 LabelToBBMap labelToBB;
71
72 // landing pads for try statements
73 IRLandingPad landingPadInfo;
74 llvm::BasicBlock* landingPad;
75
76 // loop blocks
77 typedef std::vector<IRTargetScope> TargetScopeVec;
78 TargetScopeVec targetScopes;
79
80 // constructor
81 IrFunction(FuncDeclaration* fd);
82
83 // annotations
84 void setNeverInline();
85 void setAlwaysInline();
86
87 private:
88 // prefix for labels and gotos
89 // used for allowing labels to be emitted twice
90 std::vector<std::string> labelScopes;
91
92 // next unique id stack
93 std::stack<int> nextUnique;
94 }; 101 };
95 102
96 #endif 103 #endif