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

Side by Side Diff: src/IceTranslator.cpp

Issue 619893002: Subzero: Auto-awesome iterators. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Use AsmCodeByte instead of uint8_t Created 6 years, 2 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/IceTimerTree.cpp ('k') | src/IceTypeConverter.h » ('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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 V->setName(StrBuf.str()); 51 V->setName(StrBuf.str());
52 ++NameIndex; 52 ++NameIndex;
53 } 53 }
54 } // end of anonymous namespace 54 } // end of anonymous namespace
55 55
56 void Translator::nameUnnamedGlobalAddresses(llvm::Module *Mod) { 56 void Translator::nameUnnamedGlobalAddresses(llvm::Module *Mod) {
57 const IceString &GlobalPrefix = Flags.DefaultGlobalPrefix; 57 const IceString &GlobalPrefix = Flags.DefaultGlobalPrefix;
58 Ostream &errs = Ctx->getStrDump(); 58 Ostream &errs = Ctx->getStrDump();
59 if (!GlobalPrefix.empty()) { 59 if (!GlobalPrefix.empty()) {
60 uint32_t NameIndex = 0; 60 uint32_t NameIndex = 0;
61 for (llvm::Module::global_iterator I = Mod->global_begin(), 61 for (auto I = Mod->global_begin(), E = Mod->global_end(); I != E; ++I)
62 E = Mod->global_end();
63 I != E; ++I) {
64 setValueName(I, "global", GlobalPrefix, NameIndex, errs); 62 setValueName(I, "global", GlobalPrefix, NameIndex, errs);
65 }
66 } 63 }
67 const IceString &FunctionPrefix = Flags.DefaultFunctionPrefix; 64 const IceString &FunctionPrefix = Flags.DefaultFunctionPrefix;
68 if (FunctionPrefix.empty()) 65 if (FunctionPrefix.empty())
69 return; 66 return;
70 uint32_t NameIndex = 0; 67 uint32_t NameIndex = 0;
71 for (llvm::Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { 68 for (llvm::Function &I : *Mod)
72 setValueName(I, "function", FunctionPrefix, NameIndex, errs); 69 setValueName(&I, "function", FunctionPrefix, NameIndex, errs);
73 }
74 } 70 }
75 71
76 void Translator::translateFcn(Cfg *Fcn) { 72 void Translator::translateFcn(Cfg *Fcn) {
77 Ctx->resetStats(); 73 Ctx->resetStats();
78 Func.reset(Fcn); 74 Func.reset(Fcn);
79 if (Ctx->getFlags().DisableInternal) 75 if (Ctx->getFlags().DisableInternal)
80 Func->setInternal(false); 76 Func->setInternal(false);
81 if (Ctx->getFlags().DisableTranslation) { 77 if (Ctx->getFlags().DisableTranslation) {
82 Func->dump(); 78 Func->dump();
83 } else { 79 } else {
84 Func->translate(); 80 Func->translate();
85 if (Func->hasError()) { 81 if (Func->hasError()) {
86 std::cerr << "ICE translation error: " << Func->getError() << "\n"; 82 std::cerr << "ICE translation error: " << Func->getError() << "\n";
87 ErrorStatus = true; 83 ErrorStatus = true;
88 } 84 }
89 85
90 Func->emit(); 86 Func->emit();
91 Ctx->dumpStats(Func->getFunctionName()); 87 Ctx->dumpStats(Func->getFunctionName());
92 } 88 }
93 } 89 }
94 90
95 void Translator::emitConstants() { 91 void Translator::emitConstants() {
96 if (!Ctx->getFlags().DisableTranslation && Func) 92 if (!Ctx->getFlags().DisableTranslation && Func)
97 Func->getTarget()->emitConstants(); 93 Func->getTarget()->emitConstants();
98 } 94 }
99 95
100 void Translator::convertGlobals(llvm::Module *Mod) { 96 void Translator::convertGlobals(llvm::Module *Mod) {
101 std::unique_ptr<TargetGlobalInitLowering> GlobalLowering( 97 std::unique_ptr<TargetGlobalInitLowering> GlobalLowering(
102 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); 98 TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
103 for (llvm::Module::const_global_iterator I = Mod->global_begin(), 99 for (auto I = Mod->global_begin(), E = Mod->global_end(); I != E; ++I) {
104 E = Mod->global_end();
105 I != E; ++I) {
106 if (!I->hasInitializer()) 100 if (!I->hasInitializer())
107 continue; 101 continue;
108 const llvm::Constant *Initializer = I->getInitializer(); 102 const llvm::Constant *Initializer = I->getInitializer();
109 IceString Name = I->getName(); 103 IceString Name = I->getName();
110 unsigned Align = I->getAlignment(); 104 unsigned Align = I->getAlignment();
111 uint64_t NumElements = 0; 105 uint64_t NumElements = 0;
112 const char *Data = NULL; 106 const char *Data = NULL;
113 bool IsInternal = I->hasInternalLinkage(); 107 bool IsInternal = I->hasInternalLinkage();
114 bool IsConst = I->isConstant(); 108 bool IsConst = I->isConstant();
115 bool IsZeroInitializer = false; 109 bool IsZeroInitializer = false;
(...skipping 19 matching lines...) Expand all
135 } else { 129 } else {
136 llvm_unreachable("Unhandled global initializer"); 130 llvm_unreachable("Unhandled global initializer");
137 } 131 }
138 132
139 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, 133 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer,
140 NumElements, Data, 134 NumElements, Data,
141 Ctx->getFlags().DisableTranslation); 135 Ctx->getFlags().DisableTranslation);
142 } 136 }
143 GlobalLowering.reset(); 137 GlobalLowering.reset();
144 } 138 }
OLDNEW
« no previous file with comments | « src/IceTimerTree.cpp ('k') | src/IceTypeConverter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698