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

Side by Side Diff: src/IceUtils.h

Issue 1438773004: Subzero. ARM32. Improve constant lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 1 month 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/IceTargetLoweringX86BaseImpl.h ('k') | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('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/IceUtils.h - Utility functions ---------------*- C++ -*-===// 1 //===- subzero/src/IceUtils.h - Utility functions ---------------*- 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 /// \file 10 /// \file
11 /// This file declares some utility functions. 11 /// This file declares some utility functions.
12 /// 12 ///
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #ifndef SUBZERO_SRC_ICEUTILS_H 15 #ifndef SUBZERO_SRC_ICEUTILS_H
16 #define SUBZERO_SRC_ICEUTILS_H 16 #define SUBZERO_SRC_ICEUTILS_H
17 17
18 #include <climits> 18 #include <climits>
19 #include <cmath> // std::signbit()
19 20
20 namespace Ice { 21 namespace Ice {
21 22
22 /// Similar to bit_cast, but allows copying from types of unrelated sizes. This 23 /// Similar to bit_cast, but allows copying from types of unrelated sizes. This
23 /// method was introduced to enable the strict aliasing optimizations of GCC 24 /// method was introduced to enable the strict aliasing optimizations of GCC
24 /// 4.4. Basically, GCC mindlessly relies on obscure details in the C++ standard 25 /// 4.4. Basically, GCC mindlessly relies on obscure details in the C++ standard
25 /// that make reinterpret_cast virtually useless. 26 /// that make reinterpret_cast virtually useless.
26 template <class D, class S> inline D bit_copy(const S &source) { 27 template <class D, class S> inline D bit_copy(const S &source) {
27 D destination; 28 D destination;
28 // This use of memcpy is safe: source and destination cannot overlap. 29 // This use of memcpy is safe: source and destination cannot overlap.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return value; 111 return value;
111 return (value << shift) | (value >> (32 - shift)); 112 return (value << shift) | (value >> (32 - shift));
112 } 113 }
113 114
114 /// Rotate the value bit pattern to the right by shift bits. 115 /// Rotate the value bit pattern to the right by shift bits.
115 static inline uint32_t rotateRight32(uint32_t value, uint32_t shift) { 116 static inline uint32_t rotateRight32(uint32_t value, uint32_t shift) {
116 if (shift == 0) 117 if (shift == 0)
117 return value; 118 return value;
118 return (value >> shift) | (value << (32 - shift)); 119 return (value >> shift) | (value << (32 - shift));
119 } 120 }
121
122 /// Returns true if Val is +0.0. It requires T to be a floating point type.
123 template <typename T> static bool isPositiveZero(T Val) {
124 static_assert(std::is_floating_point<T>::value,
125 "Input type must be floating point");
126 return Val == 0 && !std::signbit(Val);
127 }
120 }; 128 };
121 129
122 } // end of namespace Ice 130 } // end of namespace Ice
123 131
124 #endif // SUBZERO_SRC_ICEUTILS_H 132 #endif // SUBZERO_SRC_ICEUTILS_H
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX86BaseImpl.h ('k') | tests_lit/llvm2ice_tests/64bit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698