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

Side by Side Diff: src/IceInstARM32.cpp

Issue 1575873006: Subzero: Fix g++ warnings. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 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/IceInstARM32.cpp - ARM32 instruction implementation ----===// 1 //===- subzero/src/IceInstARM32.cpp - ARM32 instruction implementation ----===//
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 /// \file 10 /// \file
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // named after the bit fields they represent. See "A7.5.1 Operation of 340 // named after the bit fields they represent. See "A7.5.1 Operation of
341 // modified immediate constants, Floating-point" in the ARM ARM. 341 // modified immediate constants, Floating-point" in the ARM ARM.
342 static constexpr uint32_t a = 0x80000000u; 342 static constexpr uint32_t a = 0x80000000u;
343 static constexpr uint32_t B = 0x40000000; 343 static constexpr uint32_t B = 0x40000000;
344 static constexpr uint32_t bbbbb = 0x3E000000; 344 static constexpr uint32_t bbbbb = 0x3E000000;
345 static constexpr uint32_t cdefgh = 0x01F80000; 345 static constexpr uint32_t cdefgh = 0x01F80000;
346 static constexpr uint32_t AllowedBits = a | B | bbbbb | cdefgh; 346 static constexpr uint32_t AllowedBits = a | B | bbbbb | cdefgh;
347 static_assert(AllowedBits == 0xFFF80000u, 347 static_assert(AllowedBits == 0xFFF80000u,
348 "Invalid mask for f32 modified immediates."); 348 "Invalid mask for f32 modified immediates.");
349 const float F32 = llvm::cast<ConstantFloat>(C)->getValue(); 349 const float F32 = llvm::cast<ConstantFloat>(C)->getValue();
350 const uint32_t I32 = *reinterpret_cast<const uint32_t *>(&F32); 350 const uint32_t I32 = Utils::bitCopy<uint32_t>(F32);
351 if (I32 & ~AllowedBits) { 351 if (I32 & ~AllowedBits) {
352 // constant has disallowed bits. 352 // constant has disallowed bits.
353 return false; 353 return false;
354 } 354 }
355 355
356 if ((I32 & bbbbb) != bbbbb && (I32 & bbbbb)) { 356 if ((I32 & bbbbb) != bbbbb && (I32 & bbbbb)) {
357 // not all bbbbb bits are 0 or 1. 357 // not all bbbbb bits are 0 or 1.
358 return false; 358 return false;
359 } 359 }
360 360
361 if (((I32 & B) != 0) == ((I32 & bbbbb) != 0)) { 361 if (((I32 & B) != 0) == ((I32 & bbbbb) != 0)) {
362 // B ^ b = 0; 362 // B ^ b = 0;
363 return false; 363 return false;
364 } 364 }
365 365
366 *ModifiedImm = ((I32 & a) ? 0x80 : 0x00) | ((I32 & bbbbb) ? 0x40 : 0x00) | 366 *ModifiedImm = ((I32 & a) ? 0x80 : 0x00) | ((I32 & bbbbb) ? 0x40 : 0x00) |
367 ((I32 & cdefgh) >> 19); 367 ((I32 & cdefgh) >> 19);
368 return true; 368 return true;
369 } 369 }
370 case IceType_f64: { 370 case IceType_f64: {
371 static constexpr uint32_t a = 0x80000000u; 371 static constexpr uint32_t a = 0x80000000u;
372 static constexpr uint32_t B = 0x40000000; 372 static constexpr uint32_t B = 0x40000000;
373 static constexpr uint32_t bbbbbbbb = 0x3FC00000; 373 static constexpr uint32_t bbbbbbbb = 0x3FC00000;
374 static constexpr uint32_t cdefgh = 0x003F0000; 374 static constexpr uint32_t cdefgh = 0x003F0000;
375 static constexpr uint32_t AllowedBits = a | B | bbbbbbbb | cdefgh; 375 static constexpr uint32_t AllowedBits = a | B | bbbbbbbb | cdefgh;
376 static_assert(AllowedBits == 0xFFFF0000u, 376 static_assert(AllowedBits == 0xFFFF0000u,
377 "Invalid mask for f64 modified immediates."); 377 "Invalid mask for f64 modified immediates.");
378 const double F64 = llvm::cast<ConstantDouble>(C)->getValue(); 378 const double F64 = llvm::cast<ConstantDouble>(C)->getValue();
379 const uint64_t I64 = *reinterpret_cast<const uint64_t *>(&F64); 379 const uint64_t I64 = Utils::bitCopy<uint64_t>(F64);
380 if (I64 & 0xFFFFFFFFu) { 380 if (I64 & 0xFFFFFFFFu) {
381 // constant has disallowed bits. 381 // constant has disallowed bits.
382 return false; 382 return false;
383 } 383 }
384 const uint32_t I32 = I64 >> 32; 384 const uint32_t I32 = I64 >> 32;
385 385
386 if (I32 & ~AllowedBits) { 386 if (I32 & ~AllowedBits) {
387 // constant has disallowed bits. 387 // constant has disallowed bits.
388 return false; 388 return false;
389 } 389 }
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 static_assert(AllowedBits == 0xFF, 2093 static_assert(AllowedBits == 0xFF,
2094 "Invalid mask for f32/f64 constant rematerialization."); 2094 "Invalid mask for f32/f64 constant rematerialization.");
2095 2095
2096 // There's no loss in always returning the modified immediate as float. 2096 // There's no loss in always returning the modified immediate as float.
2097 // TODO(jpp): returning a double causes problems when outputting the constants 2097 // TODO(jpp): returning a double causes problems when outputting the constants
2098 // for filetype=asm. Why? 2098 // for filetype=asm. Why?
2099 float materializeFloatImmediate(uint32_t ModifiedImm) { 2099 float materializeFloatImmediate(uint32_t ModifiedImm) {
2100 const uint32_t Ret = ((ModifiedImm & a) ? 0x80000000 : 0) | 2100 const uint32_t Ret = ((ModifiedImm & a) ? 0x80000000 : 0) |
2101 ((ModifiedImm & b) ? 0x3E000000 : 0x40000000) | 2101 ((ModifiedImm & b) ? 0x3E000000 : 0x40000000) |
2102 ((ModifiedImm & cdefgh) << 19); 2102 ((ModifiedImm & cdefgh) << 19);
2103 return *reinterpret_cast<const float *>(&Ret); 2103 return Utils::bitCopy<float>(Ret);
2104 } 2104 }
2105 2105
2106 } // end of anonymous namespace 2106 } // end of anonymous namespace
2107 2107
2108 void OperandARM32FlexFpImm::emit(const Cfg *Func) const { 2108 void OperandARM32FlexFpImm::emit(const Cfg *Func) const {
2109 if (!BuildDefs::dump()) 2109 if (!BuildDefs::dump())
2110 return; 2110 return;
2111 Ostream &Str = Func->getContext()->getStrEmit(); 2111 Ostream &Str = Func->getContext()->getStrEmit();
2112 switch (Ty) { 2112 switch (Ty) {
2113 default: 2113 default:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 2216
2217 template class InstARM32FourAddrGPR<InstARM32::Mla>; 2217 template class InstARM32FourAddrGPR<InstARM32::Mla>;
2218 template class InstARM32FourAddrGPR<InstARM32::Mls>; 2218 template class InstARM32FourAddrGPR<InstARM32::Mls>;
2219 2219
2220 template class InstARM32CmpLike<InstARM32::Cmn>; 2220 template class InstARM32CmpLike<InstARM32::Cmn>;
2221 template class InstARM32CmpLike<InstARM32::Cmp>; 2221 template class InstARM32CmpLike<InstARM32::Cmp>;
2222 template class InstARM32CmpLike<InstARM32::Tst>; 2222 template class InstARM32CmpLike<InstARM32::Tst>;
2223 2223
2224 } // end of namespace ARM32 2224 } // end of namespace ARM32
2225 } // end of namespace Ice 2225 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceGlobalInits.h ('k') | src/IceTargetLoweringARM32.cpp » ('j') | src/IceUtils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698