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

Side by Side Diff: src/IceTranslator.h

Issue 870653002: Subzero: Initial implementation of multithreaded translation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes, continued Created 5 years, 11 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
OLDNEW
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
11 // machine code. 11 // machine code.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICETRANSLATOR_H 15 #ifndef SUBZERO_SRC_ICETRANSLATOR_H
16 #define SUBZERO_SRC_ICETRANSLATOR_H 16 #define SUBZERO_SRC_ICETRANSLATOR_H
17 17
18 #include <memory>
19
20 namespace llvm { 18 namespace llvm {
21 class Module; 19 class Module;
22 } 20 }
23 21
24 namespace Ice { 22 namespace Ice {
25 23
26 class ClFlags; 24 class ClFlags;
27 class Cfg; 25 class Cfg;
28 class VariableDeclaration; 26 class VariableDeclaration;
29 class GlobalContext; 27 class GlobalContext;
30 28
31 // Base class for translating ICE to machine code. Derived classes convert 29 // Base class for translating ICE to machine code. Derived classes convert
32 // other intermediate representations down to ICE, and then call the appropriate 30 // other intermediate representations down to ICE, and then call the appropriate
33 // (inherited) methods to convert ICE into machine instructions. 31 // (inherited) methods to convert ICE into machine instructions.
34 class Translator { 32 class Translator {
35 Translator(const Translator &) = delete; 33 Translator(const Translator &) = delete;
36 Translator &operator=(const Translator &) = delete; 34 Translator &operator=(const Translator &) = delete;
37 35
38 public: 36 public:
39 typedef std::vector<VariableDeclaration *> VariableDeclarationListType; 37 typedef std::vector<VariableDeclaration *> VariableDeclarationListType;
40 38
41 Translator(GlobalContext *Ctx, const ClFlags &Flags) 39 Translator(GlobalContext *Ctx, const ClFlags &Flags);
42 : Ctx(Ctx), Flags(Flags), ErrorStatus(0) {}
43
44 ~Translator(); 40 ~Translator();
45 bool getErrorStatus() const { return ErrorStatus; } 41 std::error_code getErrorStatus() const { return ErrorStatus; }
46 42
47 GlobalContext *getContext() const { return Ctx; } 43 GlobalContext *getContext() const { return Ctx; }
48 44
49 const ClFlags &getFlags() const { return Flags; } 45 const ClFlags &getFlags() const { return Flags; }
50 46
51 /// Translates the constructed ICE function Fcn to machine code. 47 /// Translates the constructed ICE function Fcn to machine code.
52 /// Takes ownership of Fcn. Note: As a side effect, Field Func is 48 /// Takes ownership of Func.
53 /// set to Fcn. 49 void translateFcn(Cfg *Func);
54 void translateFcn(Cfg *Fcn);
55 50
56 /// Emits the constant pool. 51 /// Emits the constant pool.
57 void emitConstants(); 52 void emitConstants();
58 53
59 /// Lowers the given list of global addresses to target. Generates 54 /// Lowers the given list of global addresses to target. Generates
60 /// list of corresponding variable declarations. 55 /// list of corresponding variable declarations.
61 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations); 56 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations);
62 57
63 /// Creates a name using the given prefix and corresponding index. 58 /// Creates a name using the given prefix and corresponding index.
64 std::string createUnnamedName(const IceString &Prefix, SizeT Index); 59 std::string createUnnamedName(const IceString &Prefix, SizeT Index);
65 60
66 /// Reports if there is a (potential) conflict between Name, and using 61 /// Reports if there is a (potential) conflict between Name, and using
67 /// Prefix to name unnamed names. Errors are put on Ostream. 62 /// Prefix to name unnamed names. Errors are put on Ostream.
68 /// Returns true if there isn't a potential conflict. 63 /// Returns true if there isn't a potential conflict.
69 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, 64 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
70 const IceString &Prefix); 65 const IceString &Prefix);
71 66
72 protected: 67 protected:
73 GlobalContext *Ctx; 68 GlobalContext *Ctx;
74 const ClFlags &Flags; 69 const ClFlags &Flags;
75 // The exit status of the translation. False is successful. True 70 std::unique_ptr<TargetGlobalLowering> GlobalLowering;
71 // the exit status of the translation. False is successful. True
jvoung (off chromium) 2015/01/23 22:56:37 Back to "The"?
Jim Stichnoth 2015/01/25 07:29:38 Done.
76 // otherwise. 72 // otherwise.
77 bool ErrorStatus; 73 std::error_code ErrorStatus;
78 // Ideally, Func would be inside the methods that converts IR to
79 // functions. However, emitting the constant pool requires a valid
80 // Cfg object, so we need to defer deleting the last non-empty Cfg
81 // object to emit the constant pool (via emitConstants). TODO:
82 // Since all constants are globally pooled in the GlobalContext
83 // object, change all Constant related functions to use
84 // GlobalContext instead of Cfg, and then make emitConstantPool use
85 // that.
86 std::unique_ptr<Cfg> Func;
87 }; 74 };
88 75
89 } // end of namespace Ice 76 } // end of namespace Ice
90 77
91 #endif // SUBZERO_SRC_ICETRANSLATOR_H 78 #endif // SUBZERO_SRC_ICETRANSLATOR_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698