Mercurial > projects > ldc
comparison ir/irfunction.cpp @ 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 |
---|---|
91 | 91 |
92 ////////////////////////////////////////////////////////////////////////////// | 92 ////////////////////////////////////////////////////////////////////////////// |
93 ////////////////////////////////////////////////////////////////////////////// | 93 ////////////////////////////////////////////////////////////////////////////// |
94 ////////////////////////////////////////////////////////////////////////////// | 94 ////////////////////////////////////////////////////////////////////////////// |
95 | 95 |
96 FuncGen::FuncGen() | |
97 { | |
98 landingPad = NULL; | |
99 nextUnique.push(0); | |
100 } | |
101 | |
102 std::string FuncGen::getScopedLabelName(const char* ident) | |
103 { | |
104 if(labelScopes.empty()) | |
105 return std::string(ident); | |
106 | |
107 std::string result = "__"; | |
108 for(unsigned int i = 0; i < labelScopes.size(); ++i) | |
109 result += labelScopes[i] + "_"; | |
110 return result + ident; | |
111 } | |
112 | |
113 void FuncGen::pushUniqueLabelScope(const char* name) | |
114 { | |
115 std::ostringstream uniquename; | |
116 uniquename << name << nextUnique.top()++; | |
117 nextUnique.push(0); | |
118 labelScopes.push_back(uniquename.str()); | |
119 } | |
120 | |
121 void FuncGen::popLabelScope() | |
122 { | |
123 labelScopes.pop_back(); | |
124 nextUnique.pop(); | |
125 } | |
126 | |
96 IrFunction::IrFunction(FuncDeclaration* fd) | 127 IrFunction::IrFunction(FuncDeclaration* fd) |
97 { | 128 { |
98 decl = fd; | 129 decl = fd; |
99 | 130 |
100 Type* t = fd->type->toBasetype(); | 131 Type* t = fd->type->toBasetype(); |
114 frameType = NULL; | 145 frameType = NULL; |
115 depth = -1; | 146 depth = -1; |
116 | 147 |
117 _arguments = NULL; | 148 _arguments = NULL; |
118 _argptr = NULL; | 149 _argptr = NULL; |
119 | |
120 landingPad = NULL; | |
121 | |
122 nextUnique.push(0); | |
123 } | |
124 | |
125 std::string IrFunction::getScopedLabelName(const char* ident) | |
126 { | |
127 if(labelScopes.empty()) | |
128 return std::string(ident); | |
129 | |
130 std::string result = "__"; | |
131 for(unsigned int i = 0; i < labelScopes.size(); ++i) | |
132 result += labelScopes[i] + "_"; | |
133 return result + ident; | |
134 } | |
135 | |
136 void IrFunction::pushUniqueLabelScope(const char* name) | |
137 { | |
138 std::ostringstream uniquename; | |
139 uniquename << name << nextUnique.top()++; | |
140 nextUnique.push(0); | |
141 labelScopes.push_back(uniquename.str()); | |
142 } | |
143 | |
144 void IrFunction::popLabelScope() | |
145 { | |
146 labelScopes.pop_back(); | |
147 nextUnique.pop(); | |
148 } | 150 } |
149 | 151 |
150 void IrFunction::setNeverInline() | 152 void IrFunction::setNeverInline() |
151 { | 153 { |
152 assert(!func->hasFnAttr(llvm::Attribute::AlwaysInline) && "function can't be never- and always-inline at the same time"); | 154 assert(!func->hasFnAttr(llvm::Attribute::AlwaysInline) && "function can't be never- and always-inline at the same time"); |