OLD | NEW |
---|---|
1 //===- subzero/src/IceTranslator.h - ICE to machine code --------*- C++ -*-===// | 1 //===- subzero/src/IceTranslator.h - 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 Declares the general driver class for translating ICE to machine | 11 /// \brief Declares the general driver class for translating ICE to machine |
12 /// code. | 12 /// code. |
13 /// | 13 /// |
14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
15 | 15 |
16 #ifndef SUBZERO_SRC_ICETRANSLATOR_H | 16 #ifndef SUBZERO_SRC_ICETRANSLATOR_H |
17 #define SUBZERO_SRC_ICETRANSLATOR_H | 17 #define SUBZERO_SRC_ICETRANSLATOR_H |
18 | 18 |
19 #include "IceDefs.h" | 19 #include "IceDefs.h" |
20 #include "IceGlobalContext.h" | 20 #include "IceGlobalContext.h" |
21 | 21 |
22 #include <memory> | |
23 | |
22 namespace llvm { | 24 namespace llvm { |
23 class Module; | 25 class Module; |
24 } // end of namespace llvm | 26 } // end of namespace llvm |
25 | 27 |
26 namespace Ice { | 28 namespace Ice { |
27 | 29 |
28 class ClFlags; | 30 class ClFlags; |
29 class Cfg; | 31 class Cfg; |
30 class VariableDeclaration; | 32 class VariableDeclaration; |
31 class GlobalContext; | 33 class GlobalContext; |
32 | 34 |
33 /// Base class for translating ICE to machine code. Derived classes convert | 35 /// Base class for translating ICE to machine code. Derived classes convert |
34 /// other intermediate representations down to ICE, and then call the | 36 /// other intermediate representations down to ICE, and then call the |
35 /// appropriate (inherited) methods to convert ICE into machine instructions. | 37 /// appropriate (inherited) methods to convert ICE into machine instructions. |
36 class Translator { | 38 class Translator { |
37 Translator() = delete; | 39 Translator() = delete; |
38 Translator(const Translator &) = delete; | 40 Translator(const Translator &) = delete; |
39 Translator &operator=(const Translator &) = delete; | 41 Translator &operator=(const Translator &) = delete; |
40 | 42 |
41 public: | 43 public: |
42 explicit Translator(GlobalContext *Ctx); | 44 explicit Translator(GlobalContext *Ctx); |
43 | 45 |
44 virtual ~Translator() = default; | 46 virtual ~Translator() = default; |
45 const ErrorCode &getErrorStatus() const { return ErrorStatus; } | 47 const ErrorCode &getErrorStatus() const { return ErrorStatus; } |
46 | 48 |
47 GlobalContext *getContext() const { return Ctx; } | 49 GlobalContext *getContext() const { return Ctx; } |
48 | 50 |
49 const ClFlags &getFlags() const { return Ctx->getFlags(); } | 51 const ClFlags &getFlags() const { return Ctx->getFlags(); } |
50 | 52 |
51 /// Translates the constructed ICE function Fcn to machine code. Takes | 53 /// Translates the constructed ICE function Fcn to machine code. |
Jim Stichnoth
2016/03/15 17:56:08
s/Fcn/Func/
John
2016/03/15 17:57:58
Done.
| |
52 /// ownership of Func. | |
53 void translateFcn(std::unique_ptr<Cfg> Func); | 54 void translateFcn(std::unique_ptr<Cfg> Func); |
54 | 55 |
55 /// Lowers the given list of global addresses to target. Generates list of | 56 /// Lowers the given list of global addresses to target. Generates list of |
56 /// corresponding variable declarations. | 57 /// corresponding variable declarations. |
57 void | 58 void |
58 lowerGlobals(std::unique_ptr<VariableDeclarationList> VariableDeclarations); | 59 lowerGlobals(std::unique_ptr<VariableDeclarationList> VariableDeclarations); |
59 | 60 |
60 /// Creates a name using the given prefix and corresponding index. | 61 /// Creates a name using the given prefix and corresponding index. |
61 std::string createUnnamedName(const IceString &Prefix, SizeT Index); | 62 std::string createUnnamedName(const IceString &Prefix, SizeT Index); |
62 | 63 |
63 /// Reports if there is a (potential) conflict between Name, and using Prefix | 64 /// Reports if there is a (potential) conflict between Name, and using Prefix |
64 /// to name unnamed names. Errors are put on Ostream. Returns true if there | 65 /// to name unnamed names. Errors are put on Ostream. Returns true if there |
65 /// isn't a potential conflict. | 66 /// isn't a potential conflict. |
66 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, | 67 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, |
67 const IceString &Prefix); | 68 const IceString &Prefix); |
68 | 69 |
69 uint32_t getNextSequenceNumber() { return NextSequenceNumber++; } | 70 uint32_t getNextSequenceNumber() { return NextSequenceNumber++; } |
70 | 71 |
71 protected: | 72 protected: |
72 GlobalContext *Ctx; | 73 GlobalContext *Ctx; |
73 uint32_t NextSequenceNumber; | 74 uint32_t NextSequenceNumber; |
74 /// ErrorCode of the translation. | 75 /// ErrorCode of the translation. |
75 ErrorCode ErrorStatus; | 76 ErrorCode ErrorStatus; |
76 }; | 77 }; |
77 | 78 |
78 } // end of namespace Ice | 79 } // end of namespace Ice |
79 | 80 |
80 #endif // SUBZERO_SRC_ICETRANSLATOR_H | 81 #endif // SUBZERO_SRC_ICETRANSLATOR_H |
OLD | NEW |