Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: src/IceGlobalInits.cpp

Issue 1766233002: Subzero: Fix symbol name mangling. Make flags global. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceGlobalInits.h ('k') | src/IceInstARM32.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 StrBuf << " " << getName() << ": " << getSignature(); 109 StrBuf << " " << getName() << ": " << getSignature();
110 return StrBuf.str(); 110 return StrBuf.str();
111 } 111 }
112 112
113 void FunctionDeclaration::dumpType(Ostream &Stream) const { 113 void FunctionDeclaration::dumpType(Ostream &Stream) const {
114 if (!Ice::BuildDefs::dump()) 114 if (!Ice::BuildDefs::dump())
115 return; 115 return;
116 Stream << Signature; 116 Stream << Signature;
117 } 117 }
118 118
119 void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { 119 void FunctionDeclaration::dump(Ostream &Stream) const {
120 if (!Ice::BuildDefs::dump()) 120 if (!Ice::BuildDefs::dump())
121 return; 121 return;
122 if (IsProto) 122 if (IsProto)
123 Stream << "declare "; 123 Stream << "declare ";
124 ::dumpLinkage(Stream, Linkage); 124 ::dumpLinkage(Stream, Linkage);
125 ::dumpCallingConv(Stream, CallingConv); 125 ::dumpCallingConv(Stream, CallingConv);
126 Stream << Signature.getReturnType() << " @" 126 Stream << Signature.getReturnType() << " @" << Name << "(";
127 << (Ctx ? Ctx->mangleName(Name) : Name) << "(";
128 bool IsFirst = true; 127 bool IsFirst = true;
129 for (Type ArgTy : Signature.getArgList()) { 128 for (Type ArgTy : Signature.getArgList()) {
130 if (IsFirst) 129 if (IsFirst)
131 IsFirst = false; 130 IsFirst = false;
132 else 131 else
133 Stream << ", "; 132 Stream << ", ";
134 Stream << ArgTy; 133 Stream << ArgTy;
135 } 134 }
136 Stream << ")"; 135 Stream << ")";
137 } 136 }
(...skipping 11 matching lines...) Expand all
149 IsFirst = false; 148 IsFirst = false;
150 } else { 149 } else {
151 Stream << ", "; 150 Stream << ", ";
152 } 151 }
153 Init->dumpType(Stream); 152 Init->dumpType(Stream);
154 } 153 }
155 Stream << " }>"; 154 Stream << " }>";
156 } 155 }
157 } 156 }
158 157
159 void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { 158 void VariableDeclaration::dump(Ostream &Stream) const {
160 if (!Ice::BuildDefs::dump()) 159 if (!Ice::BuildDefs::dump())
161 return; 160 return;
162 Stream << "@" 161 Stream << "@" << Name << " = ";
163 << ((Ctx && !getSuppressMangling()) ? Ctx->mangleName(Name) : Name)
164 << " = ";
165 ::dumpLinkage(Stream, Linkage); 162 ::dumpLinkage(Stream, Linkage);
166 Stream << " " << (IsConstant ? "constant" : "global") << " "; 163 Stream << " " << (IsConstant ? "constant" : "global") << " ";
167 164
168 // Add initializer. 165 // Add initializer.
169 if (Initializers->size() == 1) { 166 if (Initializers->size() == 1) {
170 Initializers->front()->dump(Stream); 167 Initializers->front()->dump(Stream);
171 } else { 168 } else {
172 dumpType(Stream); 169 dumpType(Stream);
173 Stream << " <{ "; 170 Stream << " <{ ";
174 bool IsFirst = true; 171 bool IsFirst = true;
175 for (const std::unique_ptr<Initializer> &Init : *Initializers) { 172 for (const std::unique_ptr<Initializer> &Init : *Initializers) {
176 if (IsFirst) { 173 if (IsFirst) {
177 IsFirst = false; 174 IsFirst = false;
178 } else { 175 } else {
179 Stream << ", "; 176 Stream << ", ";
180 } 177 }
181 Init->dump(Ctx, Stream); 178 Init->dump(Stream);
182 } 179 }
183 Stream << " }>"; 180 Stream << " }>";
184 } 181 }
185 182
186 // Add alignment. 183 // Add alignment.
187 if (Alignment > 0) 184 if (Alignment > 0)
188 Stream << ", align " << Alignment; 185 Stream << ", align " << Alignment;
189 Stream << "\n"; 186 Stream << "\n";
190 } 187 }
191 188
192 void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const { 189 void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const {
193 if (!Ice::BuildDefs::dump()) 190 if (!Ice::BuildDefs::dump())
194 return; 191 return;
195 Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]"; 192 Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]";
196 } 193 }
197 194
198 void VariableDeclaration::DataInitializer::dump(GlobalContext *, 195 void VariableDeclaration::DataInitializer::dump(Ostream &Stream) const {
199 Ostream &Stream) const {
200 if (!Ice::BuildDefs::dump()) 196 if (!Ice::BuildDefs::dump())
201 return; 197 return;
202 dumpType(Stream); 198 dumpType(Stream);
203 Stream << " c\""; 199 Stream << " c\"";
204 // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep the strings in 200 // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep the strings in
205 // the same format as the .ll file for practical diffing. 201 // the same format as the .ll file for practical diffing.
206 for (uint8_t C : Contents) { 202 for (uint8_t C : Contents) {
207 if (isprint(C) && C != '\\' && C != '"') 203 if (isprint(C) && C != '\\' && C != '"')
208 Stream << C; 204 Stream << C;
209 else 205 else
210 Stream << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F); 206 Stream << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F);
211 } 207 }
212 Stream << "\""; 208 Stream << "\"";
213 } 209 }
214 210
215 void VariableDeclaration::ZeroInitializer::dump(GlobalContext *, 211 void VariableDeclaration::ZeroInitializer::dump(Ostream &Stream) const {
216 Ostream &Stream) const {
217 if (!Ice::BuildDefs::dump()) 212 if (!Ice::BuildDefs::dump())
218 return; 213 return;
219 dumpType(Stream); 214 dumpType(Stream);
220 Stream << " zeroinitializer"; 215 Stream << " zeroinitializer";
221 } 216 }
222 217
223 void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const { 218 void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const {
224 if (!Ice::BuildDefs::dump()) 219 if (!Ice::BuildDefs::dump())
225 return; 220 return;
226 Stream << Ice::IceType_i32; 221 Stream << Ice::IceType_i32;
227 } 222 }
228 223
229 void VariableDeclaration::RelocInitializer::dump(GlobalContext *Ctx, 224 void VariableDeclaration::RelocInitializer::dump(Ostream &Stream) const {
230 Ostream &Stream) const {
231 if (!Ice::BuildDefs::dump()) 225 if (!Ice::BuildDefs::dump())
232 return; 226 return;
233 const RelocOffsetT Offset = getOffset(); 227 const RelocOffsetT Offset = getOffset();
234 if (Offset != 0) { 228 if (Offset != 0) {
235 dumpType(Stream); 229 dumpType(Stream);
236 Stream << " add ("; 230 Stream << " add (";
237 } 231 }
238 dumpType(Stream); 232 dumpType(Stream);
239 Stream << " ptrtoint ("; 233 Stream << " ptrtoint (";
240 Declaration->dumpType(Stream); 234 Declaration->dumpType(Stream);
241 Stream << "* @"; 235 Stream << "* @" << Declaration->getName() << " to ";
242 if (Ctx)
243 Stream << Ctx->mangleName(Declaration->getName());
244 else
245 Stream << Declaration->getName();
246 Stream << " to ";
247 dumpType(Stream); 236 dumpType(Stream);
248 Stream << ")"; 237 Stream << ")";
249 if (Offset != 0) { 238 if (Offset != 0) {
250 Stream << ", "; 239 Stream << ", ";
251 dumpType(Stream); 240 dumpType(Stream);
252 Stream << " " << Offset << ")"; 241 Stream << " " << Offset << ")";
253 } 242 }
254 } 243 }
255 244
256 } // end of namespace Ice 245 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceGlobalInits.h ('k') | src/IceInstARM32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698