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

Side by Side Diff: src/IceTranslator.cpp

Issue 567703003: Allow ability to name unnamed global addresses in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 3 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
11 // machine code. 11 // machine code.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "IceTranslator.h" 15 #include "IceTranslator.h"
16 16
17 #include "IceCfg.h" 17 #include "IceCfg.h"
18 #include "IceClFlags.h" 18 #include "IceClFlags.h"
19 #include "IceDefs.h"
19 #include "IceTargetLowering.h" 20 #include "IceTargetLowering.h"
21 #include "llvm/IR/Module.h"
20 22
21 #include <iostream> 23 #include <iostream>
22 24
23 using namespace Ice; 25 using namespace Ice;
24 26
25 Translator::~Translator() {} 27 Translator::~Translator() {}
26 28
29 namespace {
30 static inline void setValueName(llvm::Value *V, const char *Kind,
Jim Stichnoth 2014/09/12 17:20:09 Don't use static. And can you omit inline?
Karl 2014/09/12 17:41:58 Done.
31 const std::string &Prefix, uint32_t &NameIndex,
Jim Stichnoth 2014/09/12 17:20:09 IceString
Karl 2014/09/12 17:41:58 Done.
32 Ice::Ostream &errs) {
Jim Stichnoth 2014/09/12 17:20:09 Remove Ice:: everywhere in this file (or maybe bet
Karl 2014/09/12 17:41:58 Done.
33 if (V->hasName()) {
34 const std::string &Name(V->getName());
35 if (Name.find(Prefix) == 0) {
36 errs << "Warning: Default " << Kind << " prefix '" << Prefix
37 << "' conflicts with name '" << Name << "'.\n";
38 }
39 return;
40 }
Karl 2014/09/12 17:41:59 Added check if NameIndex == 0, then use prefix as
41 std::string Buffer;
42 llvm::raw_string_ostream StrBuf(Buffer);
43 StrBuf << Prefix << NameIndex;
44 V->setName(StrBuf.str());
45 ++NameIndex;
46 }
47 }
Jim Stichnoth 2014/09/12 17:20:09 // end of anonymous namespace
Karl 2014/09/12 17:41:59 Done.
48
49 void Translator::nameUnnamedGlobalAddresses(llvm::Module *Mod) {
50 const std::string &GlobalPrefix = Flags.DefaultGlobalPrefix;
Jim Stichnoth 2014/09/12 17:20:09 IceString
Karl 2014/09/12 17:41:58 Done.
51 Ice::Ostream &errs = Ctx->getStrDump();
52 if (!GlobalPrefix.empty()) {
53 uint32_t NameIndex = 0;
54 for (llvm::Module::global_iterator I = Mod->global_begin(),
55 E = Mod->global_end();
56 I != E; ++I) {
57 setValueName(I, "global", GlobalPrefix, NameIndex, errs);
58 }
59 }
60 const std::string &FunctionPrefix = Flags.DefaultFunctionPrefix;
Jim Stichnoth 2014/09/12 17:20:09 IceString
Karl 2014/09/12 17:41:58 Done.
61 if (FunctionPrefix.empty())
62 return;
63 uint32_t NameIndex = 0;
64 for (llvm::Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
65 setValueName(I, "function", FunctionPrefix, NameIndex, errs);
66 }
67 }
68
27 void Translator::translateFcn(Ice::Cfg *Fcn) { 69 void Translator::translateFcn(Ice::Cfg *Fcn) {
28 Func.reset(Fcn); 70 Func.reset(Fcn);
29 if (Ctx->getFlags().DisableInternal) 71 if (Ctx->getFlags().DisableInternal)
30 Func->setInternal(false); 72 Func->setInternal(false);
31 if (Ctx->getFlags().DisableTranslation) { 73 if (Ctx->getFlags().DisableTranslation) {
32 Func->dump(); 74 Func->dump();
33 } else { 75 } else {
34 Ice::Timer TTranslate; 76 Ice::Timer TTranslate;
35 Func->translate(); 77 Func->translate();
36 if (Ctx->getFlags().SubzeroTimingEnabled) { 78 if (Ctx->getFlags().SubzeroTimingEnabled) {
(...skipping 12 matching lines...) Expand all
49 std::cerr << "[Subzero timing] Emit function " << Func->getFunctionName() 91 std::cerr << "[Subzero timing] Emit function " << Func->getFunctionName()
50 << ": " << TEmit.getElapsedSec() << " sec\n"; 92 << ": " << TEmit.getElapsedSec() << " sec\n";
51 } 93 }
52 } 94 }
53 } 95 }
54 96
55 void Translator::emitConstants() { 97 void Translator::emitConstants() {
56 if (!Ctx->getFlags().DisableTranslation && Func) 98 if (!Ctx->getFlags().DisableTranslation && Func)
57 Func->getTarget()->emitConstants(); 99 Func->getTarget()->emitConstants();
58 } 100 }
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