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

Side by Side Diff: src/IceTranslator.cpp

Issue 848193003: Subzero: Add locking to prepare for multithreaded translation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 5 years, 11 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/IceTranslator.h ('k') | src/PNaClTranslator.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/IceTranslator.cpp - ICE to machine code ------*- C++ -*-===// 1 //===- subzero/src/IceTranslator.cpp - ICE to machine code ------*- C++ -*-===//
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 // This file defines the general driver class for translating ICE to 10 // This file defines the general driver class for translating ICE to
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { 43 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) {
44 if (Index == 0) 44 if (Index == 0)
45 return Prefix; 45 return Prefix;
46 std::string Buffer; 46 std::string Buffer;
47 llvm::raw_string_ostream StrBuf(Buffer); 47 llvm::raw_string_ostream StrBuf(Buffer);
48 StrBuf << Prefix << Index; 48 StrBuf << Prefix << Index;
49 return StrBuf.str(); 49 return StrBuf.str();
50 } 50 }
51 51
52 bool Translator::checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, 52 bool Translator::checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
53 const IceString &Prefix, 53 const IceString &Prefix) {
54 Ostream &Stream) {
55 if (Name.find(Prefix) == 0) { 54 if (Name.find(Prefix) == 0) {
56 for (size_t i = Prefix.size(); i < Name.size(); ++i) { 55 for (size_t i = Prefix.size(); i < Name.size(); ++i) {
57 if (!isdigit(Name[i])) { 56 if (!isdigit(Name[i])) {
58 return false; 57 return false;
59 } 58 }
60 } 59 }
60 OstreamLocker L(Ctx);
61 Ostream &Stream = Ctx->getStrDump();
61 Stream << "Warning : Default " << Kind << " prefix '" << Prefix 62 Stream << "Warning : Default " << Kind << " prefix '" << Prefix
62 << "' potentially conflicts with name '" << Name << "'.\n"; 63 << "' potentially conflicts with name '" << Name << "'.\n";
63 return true; 64 return true;
64 } 65 }
65 return false; 66 return false;
66 } 67 }
67 68
68 void Translator::translateFcn(Cfg *Fcn) { 69 void Translator::translateFcn(Cfg *Fcn) {
69 Ctx->resetStats(); 70 Ctx->resetStats();
70 Func.reset(Fcn); 71 Func.reset(Fcn);
(...skipping 30 matching lines...) Expand all
101 Func->getTarget()->emitConstants(); 102 Func->getTarget()->emitConstants();
102 } 103 }
103 104
104 void Translator::lowerGlobals( 105 void Translator::lowerGlobals(
105 const VariableDeclarationListType &VariableDeclarations) { 106 const VariableDeclarationListType &VariableDeclarations) {
106 std::unique_ptr<TargetGlobalInitLowering> GlobalLowering( 107 std::unique_ptr<TargetGlobalInitLowering> GlobalLowering(
107 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); 108 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
108 bool DisableTranslation = Ctx->getFlags().DisableTranslation; 109 bool DisableTranslation = Ctx->getFlags().DisableTranslation;
109 const bool DumpGlobalVariables = 110 const bool DumpGlobalVariables =
110 ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty(); 111 ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
112 OstreamLocker L(Ctx);
111 Ostream &Stream = Ctx->getStrDump(); 113 Ostream &Stream = Ctx->getStrDump();
112 const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly; 114 const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
113 for (const Ice::VariableDeclaration *Global : VariableDeclarations) { 115 for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
114 if (DumpGlobalVariables) 116 if (DumpGlobalVariables)
115 Global->dump(getContext(), Stream); 117 Global->dump(getContext(), Stream);
116 if (!DisableTranslation && 118 if (!DisableTranslation &&
117 matchSymbolName(Global->getName(), TranslateOnly)) 119 matchSymbolName(Global->getName(), TranslateOnly))
118 GlobalLowering->lower(*Global); 120 GlobalLowering->lower(*Global);
119 } 121 }
120 GlobalLowering.reset(); 122 GlobalLowering.reset();
121 } 123 }
OLDNEW
« no previous file with comments | « src/IceTranslator.h ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698