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

Side by Side Diff: src/IceGlobalContext.cpp

Issue 353553004: Add support for vector types and vector constants. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: 1) Fix alignment in type table. 2) Add VECT128_BYTES constant. 3) add _movp() function. Created 6 years, 6 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/IceGlobalContext.cpp - Global context defs ---*- C++ -*-===// 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs ---*- 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 defines aspects of the compilation that persist across 10 // This file defines aspects of the compilation that persist across
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // interest. 101 // interest.
102 class ConstantPool { 102 class ConstantPool {
103 ConstantPool(const ConstantPool &) LLVM_DELETED_FUNCTION; 103 ConstantPool(const ConstantPool &) LLVM_DELETED_FUNCTION;
104 ConstantPool &operator=(const ConstantPool &) LLVM_DELETED_FUNCTION; 104 ConstantPool &operator=(const ConstantPool &) LLVM_DELETED_FUNCTION;
105 105
106 public: 106 public:
107 ConstantPool() {} 107 ConstantPool() {}
108 TypePool<float, ConstantFloat, true> Floats; 108 TypePool<float, ConstantFloat, true> Floats;
109 TypePool<double, ConstantDouble, true> Doubles; 109 TypePool<double, ConstantDouble, true> Doubles;
110 TypePool<uint64_t, ConstantInteger> Integers; 110 TypePool<uint64_t, ConstantInteger> Integers;
111 TypePool<Vect128, ConstantVector> Vectors;
112 TypePool<BitVect, ConstantBitVector> BitVectors;
111 TypePool<RelocatableTuple, ConstantRelocatable> Relocatables; 113 TypePool<RelocatableTuple, ConstantRelocatable> Relocatables;
112 UndefPool Undefs; 114 UndefPool Undefs;
113 }; 115 };
114 116
115 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump, 117 GlobalContext::GlobalContext(llvm::raw_ostream *OsDump,
116 llvm::raw_ostream *OsEmit, VerboseMask Mask, 118 llvm::raw_ostream *OsEmit, VerboseMask Mask,
117 TargetArch Arch, OptLevel Opt, 119 TargetArch Arch, OptLevel Opt,
118 IceString TestPrefix) 120 IceString TestPrefix)
119 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask), 121 : StrDump(OsDump), StrEmit(OsEmit), VMask(Mask),
120 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt), 122 ConstPool(new ConstantPool()), Arch(Arch), Opt(Opt),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 204 }
203 205
204 Constant *GlobalContext::getConstantFloat(float ConstantFloat) { 206 Constant *GlobalContext::getConstantFloat(float ConstantFloat) {
205 return ConstPool->Floats.getOrAdd(this, IceType_f32, ConstantFloat); 207 return ConstPool->Floats.getOrAdd(this, IceType_f32, ConstantFloat);
206 } 208 }
207 209
208 Constant *GlobalContext::getConstantDouble(double ConstantDouble) { 210 Constant *GlobalContext::getConstantDouble(double ConstantDouble) {
209 return ConstPool->Doubles.getOrAdd(this, IceType_f64, ConstantDouble); 211 return ConstPool->Doubles.getOrAdd(this, IceType_f64, ConstantDouble);
210 } 212 }
211 213
214 Constant *GlobalContext::getConstantVector(Type Ty, const Vect128 &Vector) {
215 return ConstPool->Vectors.getOrAdd(this, Ty, Vector);
216 }
217
218 Constant *GlobalContext::getConstantBitVector(Type Ty, const BitVect &Vector) {
219 return ConstPool->BitVectors.getOrAdd(this, Ty, Vector);
220 }
221
212 Constant *GlobalContext::getConstantSym(Type Ty, int64_t Offset, 222 Constant *GlobalContext::getConstantSym(Type Ty, int64_t Offset,
213 const IceString &Name, 223 const IceString &Name,
214 bool SuppressMangling) { 224 bool SuppressMangling) {
215 return ConstPool->Relocatables.getOrAdd( 225 return ConstPool->Relocatables.getOrAdd(
216 this, Ty, RelocatableTuple(Offset, Name, SuppressMangling)); 226 this, Ty, RelocatableTuple(Offset, Name, SuppressMangling));
217 } 227 }
218 228
219 Constant *GlobalContext::getConstantUndef(Type Ty) { 229 Constant *GlobalContext::getConstantUndef(Type Ty) {
220 return ConstPool->Undefs.getOrAdd(this, Ty); 230 return ConstPool->Undefs.getOrAdd(this, Ty);
221 } 231 }
222 232
223 Constant *GlobalContext::getConstantZero(Type Ty) { 233 Constant *GlobalContext::getConstantZero(Type Ty) {
224 switch (Ty) { 234 switch (Ty) {
225 case IceType_i1: 235 case IceType_i1:
226 case IceType_i8: 236 case IceType_i8:
227 case IceType_i16: 237 case IceType_i16:
228 case IceType_i32: 238 case IceType_i32:
229 case IceType_i64: 239 case IceType_i64:
230 return getConstantInt(Ty, 0); 240 return getConstantInt(Ty, 0);
231 case IceType_f32: 241 case IceType_f32:
232 return getConstantFloat(0); 242 return getConstantFloat(0);
233 case IceType_f64: 243 case IceType_f64:
234 return getConstantDouble(0); 244 return getConstantDouble(0);
245 case IceType_v4i1:
246 case IceType_v8i1:
247 case IceType_v16i1: {
248 BitVect Zeros(typeNumElements(Ty));
249 return getConstantBitVector(Ty, Zeros);
250 }
251 case IceType_v16i8:
252 case IceType_v8i16:
253 case IceType_v4i32:
254 case IceType_v4f32: {
255 Vect128 Zeros(16);
Jim Stichnoth 2014/06/27 18:30:16 I don't understand why Zeros is defined with 16 el
wala 2014/06/27 21:09:19 A BitVect, unlike a Vect128, can have a differing
256 return getConstantVector(Ty, Zeros);
257 }
235 case IceType_void: 258 case IceType_void:
236 case IceType_NUM: 259 case IceType_NUM:
237 break; 260 break;
238 } 261 }
239 llvm_unreachable("Unknown type"); 262 llvm_unreachable("Unknown type");
240 } 263 }
241 264
242 ConstantList GlobalContext::getConstantPool(Type Ty) const { 265 ConstantList GlobalContext::getConstantPool(Type Ty) const {
243 switch (Ty) { 266 switch (Ty) {
244 case IceType_i1: 267 case IceType_i1:
245 case IceType_i8: 268 case IceType_i8:
246 case IceType_i16: 269 case IceType_i16:
247 case IceType_i32: 270 case IceType_i32:
248 case IceType_i64: 271 case IceType_i64:
249 return ConstPool->Integers.getConstantPool(); 272 return ConstPool->Integers.getConstantPool();
250 case IceType_f32: 273 case IceType_f32:
251 return ConstPool->Floats.getConstantPool(); 274 return ConstPool->Floats.getConstantPool();
252 case IceType_f64: 275 case IceType_f64:
253 return ConstPool->Doubles.getConstantPool(); 276 return ConstPool->Doubles.getConstantPool();
277 case IceType_v4i1:
278 case IceType_v8i1:
279 case IceType_v16i1:
280 return ConstPool->BitVectors.getConstantPool();
281 case IceType_v16i8:
282 case IceType_v8i16:
283 case IceType_v4i32:
284 case IceType_v4f32:
285 return ConstPool->Vectors.getConstantPool();
254 case IceType_void: 286 case IceType_void:
255 case IceType_NUM: 287 case IceType_NUM:
256 break; 288 break;
257 } 289 }
258 llvm_unreachable("Unknown type"); 290 llvm_unreachable("Unknown type");
259 } 291 }
260 292
261 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { 293 void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const {
262 if (Ctx->isVerbose(IceV_Timing)) { 294 if (Ctx->isVerbose(IceV_Timing)) {
263 // Prefixing with '#' allows timing strings to be included 295 // Prefixing with '#' allows timing strings to be included
264 // without error in textual assembly output. 296 // without error in textual assembly output.
265 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n"; 297 Ctx->getStrDump() << "# " << getElapsedUs() << " usec " << Tag << "\n";
266 } 298 }
267 } 299 }
268 300
269 } // end of namespace Ice 301 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698