OLD | NEW |
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" | |
16 | |
17 #include "IceCfg.h" | 15 #include "IceCfg.h" |
18 #include "IceClFlags.h" | 16 #include "IceClFlags.h" |
19 #include "IceDefs.h" | 17 #include "IceDefs.h" |
20 #include "IceTargetLowering.h" | 18 #include "IceTargetLowering.h" |
| 19 #include "IceTranslator.h" |
21 #include "llvm/IR/Module.h" | 20 #include "llvm/IR/Module.h" |
22 #include "llvm/IR/Constant.h" | 21 #include "llvm/IR/Constant.h" |
23 #include "llvm/IR/Constants.h" | 22 #include "llvm/IR/Constants.h" |
24 | 23 |
25 #include <iostream> | 24 #include <iostream> |
26 | 25 |
27 using namespace Ice; | 26 using namespace Ice; |
28 | 27 |
29 Translator::~Translator() {} | 28 Translator::~Translator() {} |
30 | 29 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 72 } |
74 | 73 |
75 void Translator::translateFcn(Cfg *Fcn) { | 74 void Translator::translateFcn(Cfg *Fcn) { |
76 Ctx->resetStats(); | 75 Ctx->resetStats(); |
77 Func.reset(Fcn); | 76 Func.reset(Fcn); |
78 if (Ctx->getFlags().DisableInternal) | 77 if (Ctx->getFlags().DisableInternal) |
79 Func->setInternal(false); | 78 Func->setInternal(false); |
80 if (Ctx->getFlags().DisableTranslation) { | 79 if (Ctx->getFlags().DisableTranslation) { |
81 Func->dump(); | 80 Func->dump(); |
82 } else { | 81 } else { |
83 Timer TTranslate; | |
84 Func->translate(); | 82 Func->translate(); |
85 if (Ctx->getFlags().SubzeroTimingEnabled) { | |
86 std::cerr << "[Subzero timing] Translate function " | |
87 << Func->getFunctionName() << ": " << TTranslate.getElapsedSec() | |
88 << " sec\n"; | |
89 } | |
90 if (Func->hasError()) { | 83 if (Func->hasError()) { |
91 std::cerr << "ICE translation error: " << Func->getError() << "\n"; | 84 std::cerr << "ICE translation error: " << Func->getError() << "\n"; |
92 ErrorStatus = true; | 85 ErrorStatus = true; |
93 } | 86 } |
94 | 87 |
95 Timer TEmit; | |
96 Func->emit(); | 88 Func->emit(); |
97 if (Ctx->getFlags().SubzeroTimingEnabled) { | |
98 std::cerr << "[Subzero timing] Emit function " << Func->getFunctionName() | |
99 << ": " << TEmit.getElapsedSec() << " sec\n"; | |
100 } | |
101 Ctx->dumpStats(Func->getFunctionName()); | 89 Ctx->dumpStats(Func->getFunctionName()); |
102 } | 90 } |
103 } | 91 } |
104 | 92 |
105 void Translator::emitConstants() { | 93 void Translator::emitConstants() { |
106 if (!Ctx->getFlags().DisableTranslation && Func) | 94 if (!Ctx->getFlags().DisableTranslation && Func) |
107 Func->getTarget()->emitConstants(); | 95 Func->getTarget()->emitConstants(); |
108 } | 96 } |
109 | 97 |
110 void Translator::convertGlobals(llvm::Module *Mod) { | 98 void Translator::convertGlobals(llvm::Module *Mod) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } else { | 133 } else { |
146 llvm_unreachable("Unhandled global initializer"); | 134 llvm_unreachable("Unhandled global initializer"); |
147 } | 135 } |
148 | 136 |
149 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, | 137 GlobalLowering->lower(Name, Align, IsInternal, IsConst, IsZeroInitializer, |
150 NumElements, Data, | 138 NumElements, Data, |
151 Ctx->getFlags().DisableTranslation); | 139 Ctx->getFlags().DisableTranslation); |
152 } | 140 } |
153 GlobalLowering.reset(); | 141 GlobalLowering.reset(); |
154 } | 142 } |
OLD | NEW |