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 /// \file | 10 /// \file |
11 /// \brief Defines the general driver class for translating ICE to machine code. | 11 /// \brief Defines the general driver class for translating ICE to machine code. |
12 /// | 12 /// |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #include "IceTranslator.h" | 15 #include "IceTranslator.h" |
16 | 16 |
17 #include "IceDefs.h" | 17 #include "IceDefs.h" |
18 #include "IceCfg.h" | 18 #include "IceCfg.h" |
19 #include "IceClFlags.h" | 19 #include "IceClFlags.h" |
20 #include "IceGlobalInits.h" | 20 #include "IceGlobalInits.h" |
21 #include "IceTargetLowering.h" | 21 #include "IceTargetLowering.h" |
22 | 22 |
23 #include <utility> | 23 #include <utility> |
24 | 24 |
25 namespace Ice { | 25 namespace Ice { |
26 | 26 |
| 27 class CfgOptWorkItem final : public OptWorkItem { |
| 28 CfgOptWorkItem() = delete; |
| 29 CfgOptWorkItem(const CfgOptWorkItem &) = delete; |
| 30 CfgOptWorkItem &operator=(const CfgOptWorkItem &) = delete; |
| 31 |
| 32 public: |
| 33 CfgOptWorkItem(std::unique_ptr<Cfg> Func) : Func(std::move(Func)) {} |
| 34 std::unique_ptr<Cfg> getParsedCfg() override { return std::move(Func); } |
| 35 ~CfgOptWorkItem() override = default; |
| 36 |
| 37 private: |
| 38 std::unique_ptr<Ice::Cfg> Func; |
| 39 }; |
| 40 |
27 Translator::Translator(GlobalContext *Ctx) | 41 Translator::Translator(GlobalContext *Ctx) |
28 : Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()), | 42 : Ctx(Ctx), NextSequenceNumber(GlobalContext::getFirstSequenceNumber()), |
29 ErrorStatus() {} | 43 ErrorStatus() {} |
30 | 44 |
31 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { | 45 IceString Translator::createUnnamedName(const IceString &Prefix, SizeT Index) { |
32 if (Index == 0) | 46 if (Index == 0) |
33 return Prefix; | 47 return Prefix; |
34 std::string Buffer; | 48 std::string Buffer; |
35 llvm::raw_string_ostream StrBuf(Buffer); | 49 llvm::raw_string_ostream StrBuf(Buffer); |
36 StrBuf << Prefix << Index; | 50 StrBuf << Prefix << Index; |
(...skipping 11 matching lines...) Expand all Loading... |
48 OstreamLocker L(Ctx); | 62 OstreamLocker L(Ctx); |
49 Ostream &Stream = Ctx->getStrDump(); | 63 Ostream &Stream = Ctx->getStrDump(); |
50 Stream << "Warning : Default " << Kind << " prefix '" << Prefix | 64 Stream << "Warning : Default " << Kind << " prefix '" << Prefix |
51 << "' potentially conflicts with name '" << Name << "'.\n"; | 65 << "' potentially conflicts with name '" << Name << "'.\n"; |
52 return true; | 66 return true; |
53 } | 67 } |
54 return false; | 68 return false; |
55 } | 69 } |
56 | 70 |
57 void Translator::translateFcn(std::unique_ptr<Cfg> Func) { | 71 void Translator::translateFcn(std::unique_ptr<Cfg> Func) { |
58 Ctx->optQueueBlockingPush(std::move(Func)); | 72 Ctx->optQueueBlockingPush(makeUnique<CfgOptWorkItem>(std::move(Func))); |
59 } | 73 } |
60 | 74 |
61 void Translator::lowerGlobals( | 75 void Translator::lowerGlobals( |
62 std::unique_ptr<VariableDeclarationList> VariableDeclarations) { | 76 std::unique_ptr<VariableDeclarationList> VariableDeclarations) { |
63 Ctx->emitQueueBlockingPush(makeUnique<EmitterWorkItem>( | 77 Ctx->emitQueueBlockingPush(makeUnique<EmitterWorkItem>( |
64 getNextSequenceNumber(), std::move(VariableDeclarations))); | 78 getNextSequenceNumber(), std::move(VariableDeclarations))); |
65 } | 79 } |
66 | 80 |
67 } // end of namespace Ice | 81 } // end of namespace Ice |
OLD | NEW |