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

Side by Side Diff: src/IceTranslator.h

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