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

Side by Side Diff: src/IceGlobalInits.h

Issue 874353006: Write out global initializers and data rel directly to ELF file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: tweak comment Created 5 years, 10 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/IceGlobalInits.h - Global declarations -------*- C++ -*-===// 1 //===- subzero/src/IceGlobalInits.h - Global declarations -------*- 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 representation of function declarations, 10 // This file declares the representation of function declarations,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 virtual void dumpType(Ostream &Stream) const; 150 virtual void dumpType(Ostream &Stream) const;
151 151
152 protected: 152 protected:
153 explicit Initializer(InitializerKind Kind) : Kind(Kind) {} 153 explicit Initializer(InitializerKind Kind) : Kind(Kind) {}
154 154
155 private: 155 private:
156 const InitializerKind Kind; 156 const InitializerKind Kind;
157 }; 157 };
158 158
159 // Models the data in a data initializer. 159 // Models the data in a data initializer.
160 typedef std::vector<uint8_t> DataVecType; 160 typedef std::vector<char> DataVecType;
161 161
162 /// Defines a sequence of byte values as a data initializer. 162 /// Defines a sequence of byte values as a data initializer.
163 class DataInitializer : public Initializer { 163 class DataInitializer : public Initializer {
164 DataInitializer(const DataInitializer &) = delete; 164 DataInitializer(const DataInitializer &) = delete;
165 DataInitializer &operator=(const DataInitializer &) = delete; 165 DataInitializer &operator=(const DataInitializer &) = delete;
166 166
167 public: 167 public:
168 template <class IntContainer> 168 template <class IntContainer>
169 DataInitializer(const IntContainer &Values) 169 DataInitializer(const IntContainer &Values)
170 : Initializer(DataInitializerKind), Contents(Values.size()) { 170 : Initializer(DataInitializerKind), Contents(Values.size()) {
171 size_t i = 0; 171 size_t i = 0;
172 for (auto &V : Values) { 172 for (auto &V : Values) {
173 Contents[i] = static_cast<uint8_t>(V); 173 Contents[i] = static_cast<int8_t>(V);
174 ++i; 174 ++i;
175 } 175 }
176 } 176 }
177 DataInitializer(const char *Str, size_t StrLen) 177 DataInitializer(const char *Str, size_t StrLen)
178 : Initializer(DataInitializerKind), Contents(StrLen) { 178 : Initializer(DataInitializerKind), Contents(StrLen) {
179 for (size_t i = 0; i < StrLen; ++i) 179 for (size_t i = 0; i < StrLen; ++i)
180 Contents[i] = static_cast<uint8_t>(Str[i]); 180 Contents[i] = Str[i];
181 } 181 }
182 ~DataInitializer() override {} 182 ~DataInitializer() override {}
183 const DataVecType &getContents() const { return Contents; } 183 const DataVecType &getContents() const { return Contents; }
184 SizeT getNumBytes() const final { return Contents.size(); } 184 SizeT getNumBytes() const final { return Contents.size(); }
185 void dump(GlobalContext *Ctx, Ostream &Stream) const final; 185 void dump(GlobalContext *Ctx, Ostream &Stream) const final;
186 static bool classof(const Initializer *D) { 186 static bool classof(const Initializer *D) {
187 return D->getKind() == DataInitializerKind; 187 return D->getKind() == DataInitializerKind;
188 } 188 }
189 189
190 private: 190 private:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 template <class StreamType> 311 template <class StreamType>
312 inline StreamType &operator<<(StreamType &Stream, 312 inline StreamType &operator<<(StreamType &Stream,
313 const GlobalDeclaration &Addr) { 313 const GlobalDeclaration &Addr) {
314 Addr.dump(Stream); 314 Addr.dump(Stream);
315 return Stream; 315 return Stream;
316 } 316 }
317 317
318 } // end of namespace Ice 318 } // end of namespace Ice
319 319
320 #endif // SUBZERO_SRC_ICEGLOBALINITS_H 320 #endif // SUBZERO_SRC_ICEGLOBALINITS_H
OLDNEW
« src/IceELFObjectWriter.cpp ('K') | « src/IceELFSection.cpp ('k') | src/IceTargetLowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698