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

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: Cleanup 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) {} 40 : Ctx(Ctx), Flags(Flags), ErrorStatus(false) {}
43 41
44 ~Translator(); 42 ~Translator();
45 bool getErrorStatus() const { return ErrorStatus; } 43 bool getErrorStatus() const { return ErrorStatus; }
46 44
47 GlobalContext *getContext() const { return Ctx; } 45 GlobalContext *getContext() const { return Ctx; }
48 46
49 const ClFlags &getFlags() const { return Flags; } 47 const ClFlags &getFlags() const { return Flags; }
50 48
51 /// Translates the constructed ICE function Fcn to machine code. 49 /// Translates the constructed ICE function Fcn to machine code.
52 /// Takes ownership of Fcn. Note: As a side effect, Field Func is 50 /// Takes ownership of Func.
53 /// set to Fcn. 51 void translateFcn(Cfg *Func);
54 void translateFcn(Cfg *Fcn);
55 52
56 /// Emits the constant pool. 53 /// Emits the constant pool.
57 void emitConstants(); 54 void emitConstants();
58 55
59 /// Lowers the given list of global addresses to target. Generates 56 /// Lowers the given list of global addresses to target. Generates
60 /// list of corresponding variable declarations. 57 /// list of corresponding variable declarations.
61 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations); 58 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations);
62 59
63 /// Creates a name using the given prefix and corresponding index. 60 /// Creates a name using the given prefix and corresponding index.
64 std::string createUnnamedName(const IceString &Prefix, SizeT Index); 61 std::string createUnnamedName(const IceString &Prefix, SizeT Index);
65 62
66 /// Reports if there is a (potential) conflict between Name, and using 63 /// Reports if there is a (potential) conflict between Name, and using
67 /// Prefix to name unnamed names. Errors are put on Ostream. 64 /// Prefix to name unnamed names. Errors are put on Ostream.
68 /// Returns true if there isn't a potential conflict. 65 /// Returns true if there isn't a potential conflict.
69 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, 66 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
70 const IceString &Prefix); 67 const IceString &Prefix);
71 68
72 protected: 69 protected:
73 GlobalContext *Ctx; 70 GlobalContext *Ctx;
74 const ClFlags &Flags; 71 const ClFlags &Flags;
75 // The exit status of the translation. False is successful. True 72 // The exit status of the translation. False is successful. True
76 // otherwise. 73 // otherwise.
77 bool ErrorStatus; 74 bool 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;
Karl 2015/01/22 20:41:13 Nice to see this wart go away!
Jim Stichnoth 2015/01/23 07:55:55 Indeed.
87 }; 75 };
88 76
89 } // end of namespace Ice 77 } // end of namespace Ice
90 78
91 #endif // SUBZERO_SRC_ICETRANSLATOR_H 79 #endif // SUBZERO_SRC_ICETRANSLATOR_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698