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

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: Rebase 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
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | src/IceTranslator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const ErrorCode &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
54 /// If there was an error during bitcode reading/parsing, copy the
55 /// error code into the GlobalContext.
56 void transferErrorCode() const;
57
59 /// Lowers the given list of global addresses to target. Generates 58 /// Lowers the given list of global addresses to target. Generates
60 /// list of corresponding variable declarations. 59 /// list of corresponding variable declarations.
61 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations); 60 void lowerGlobals(const VariableDeclarationListType &VariableDeclarations);
62 61
63 /// Creates a name using the given prefix and corresponding index. 62 /// Creates a name using the given prefix and corresponding index.
64 std::string createUnnamedName(const IceString &Prefix, SizeT Index); 63 std::string createUnnamedName(const IceString &Prefix, SizeT Index);
65 64
66 /// Reports if there is a (potential) conflict between Name, and using 65 /// Reports if there is a (potential) conflict between Name, and using
67 /// Prefix to name unnamed names. Errors are put on Ostream. 66 /// Prefix to name unnamed names. Errors are put on Ostream.
68 /// Returns true if there isn't a potential conflict. 67 /// Returns true if there isn't a potential conflict.
69 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind, 68 bool checkIfUnnamedNameSafe(const IceString &Name, const char *Kind,
70 const IceString &Prefix); 69 const IceString &Prefix);
71 70
72 protected: 71 protected:
73 GlobalContext *Ctx; 72 GlobalContext *Ctx;
74 const ClFlags &Flags; 73 const ClFlags &Flags;
75 // The exit status of the translation. False is successful. True 74 std::unique_ptr<TargetGlobalLowering> GlobalLowering;
76 // otherwise. 75 // Exit status of the translation. False is successful. True otherwise.
77 bool ErrorStatus; 76 ErrorCode 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 }; 77 };
88 78
89 } // end of namespace Ice 79 } // end of namespace Ice
90 80
91 #endif // SUBZERO_SRC_ICETRANSLATOR_H 81 #endif // SUBZERO_SRC_ICETRANSLATOR_H
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | src/IceTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698