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 // This file declares the general driver class for translating ICE to | 10 // This file declares the general driver class for translating ICE to |
(...skipping 16 matching lines...) Expand all Loading... |
27 class GlobalContext; | 27 class GlobalContext; |
28 | 28 |
29 // Base class for translating ICE to machine code. Derived classes convert | 29 // Base class for translating ICE to machine code. Derived classes convert |
30 // other intermediate representations down to ICE, and then call the appropriate | 30 // other intermediate representations down to ICE, and then call the appropriate |
31 // (inherited) methods to convert ICE into machine instructions. | 31 // (inherited) methods to convert ICE into machine instructions. |
32 class Translator { | 32 class Translator { |
33 Translator(const Translator &) = delete; | 33 Translator(const Translator &) = delete; |
34 Translator &operator=(const Translator &) = delete; | 34 Translator &operator=(const Translator &) = delete; |
35 | 35 |
36 public: | 36 public: |
37 typedef std::vector<VariableDeclaration *> VariableDeclarationListType; | 37 Translator(GlobalContext *Ctx, const ClFlags &Flags); |
38 | 38 |
39 Translator(GlobalContext *Ctx, const ClFlags &Flags); | |
40 ~Translator(); | 39 ~Translator(); |
41 const ErrorCode &getErrorStatus() const { return ErrorStatus; } | 40 const ErrorCode &getErrorStatus() const { return ErrorStatus; } |
42 | 41 |
43 GlobalContext *getContext() const { return Ctx; } | 42 GlobalContext *getContext() const { return Ctx; } |
44 | 43 |
45 const ClFlags &getFlags() const { return Flags; } | 44 const ClFlags &getFlags() const { return Flags; } |
46 | 45 |
47 /// Translates the constructed ICE function Fcn to machine code. | 46 /// Translates the constructed ICE function Fcn to machine code. |
48 /// Takes ownership of Func. | 47 /// Takes ownership of Func. |
49 void translateFcn(Cfg *Func); | 48 void translateFcn(Cfg *Func); |
50 | 49 |
51 /// Emits the constant pool. | 50 /// Emits the constant pool. |
52 void emitConstants(); | 51 void emitConstants(); |
53 | 52 |
54 /// If there was an error during bitcode reading/parsing, copy the | 53 /// If there was an error during bitcode reading/parsing, copy the |
55 /// error code into the GlobalContext. | 54 /// error code into the GlobalContext. |
56 void transferErrorCode() const; | 55 void transferErrorCode() const; |
57 | 56 |
58 /// Lowers the given list of global addresses to target. Generates | 57 /// Lowers the given list of global addresses to target. Generates |
59 /// list of corresponding variable declarations. | 58 /// list of corresponding variable declarations. |
60 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations); | 59 void lowerGlobals(const VariableDeclarationList &VariableDeclarations); |
61 | 60 |
62 /// Creates a name using the given prefix and corresponding index. | 61 /// Creates a name using the given prefix and corresponding index. |
63 std::string createUnnamedName(const IceString &Prefix, SizeT Index); | 62 std::string createUnnamedName(const IceString &Prefix, SizeT Index); |
64 | 63 |
65 /// Reports if there is a (potential) conflict between Name, and using | 64 /// Reports if there is a (potential) conflict between Name, and using |
66 /// Prefix to name unnamed names. Errors are put on Ostream. | 65 /// Prefix to name unnamed names. Errors are put on Ostream. |
67 /// Returns true if there isn't a potential conflict. | 66 /// Returns true if there isn't a potential conflict. |
68 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, | 67 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, |
69 const IceString &Prefix); | 68 const IceString &Prefix); |
70 | 69 |
71 protected: | 70 protected: |
72 GlobalContext *Ctx; | 71 GlobalContext *Ctx; |
73 const ClFlags &Flags; | 72 const ClFlags &Flags; |
74 std::unique_ptr<TargetGlobalLowering> GlobalLowering; | 73 std::unique_ptr<TargetGlobalLowering> GlobalLowering; |
75 // Exit status of the translation. False is successful. True otherwise. | 74 // Exit status of the translation. False is successful. True otherwise. |
76 ErrorCode ErrorStatus; | 75 ErrorCode ErrorStatus; |
77 }; | 76 }; |
78 | 77 |
79 } // end of namespace Ice | 78 } // end of namespace Ice |
80 | 79 |
81 #endif // SUBZERO_SRC_ICETRANSLATOR_H | 80 #endif // SUBZERO_SRC_ICETRANSLATOR_H |
OLD | NEW |