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

Side by Side Diff: src/IceUtils.h

Issue 1318553003: Compute the loop nest depth of each CfgNode and weight Variables by it. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 3 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/IceTimerTree.def ('k') | tests_lit/llvm2ice_tests/loop-nest-depth.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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return IsUint(N, Value); 63 return IsUint(N, Value);
64 } 64 }
65 65
66 /// Return true if the addition X + Y will cause integer overflow for 66 /// Return true if the addition X + Y will cause integer overflow for
67 /// integers of type T. 67 /// integers of type T.
68 template <typename T> static inline bool WouldOverflowAdd(T X, T Y) { 68 template <typename T> static inline bool WouldOverflowAdd(T X, T Y) {
69 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) || 69 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) ||
70 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y))); 70 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y)));
71 } 71 }
72 72
73 /// Adds x to y and stores the result in sum. Returns true if the addition
74 /// overflowed.
75 static inline bool add_overflow(uint32_t x, uint32_t y, uint32_t *sum) {
76 static_assert(std::is_same<uint32_t, unsigned>::value, "Must match type");
77 #if __has_builtin(__builtin_uadd_overflow)
78 return __builtin_uadd_overflow(x, y, sum);
79 #else
80 *sum = x + y;
81 return WouldOverflowAdd(x, y);
82 #endif
83 }
84
73 /// Return true if X is already aligned by N, where N is a power of 2. 85 /// Return true if X is already aligned by N, where N is a power of 2.
74 template <typename T> static inline bool IsAligned(T X, intptr_t N) { 86 template <typename T> static inline bool IsAligned(T X, intptr_t N) {
75 assert(llvm::isPowerOf2_64(N)); 87 assert(llvm::isPowerOf2_64(N));
76 return (X & (N - 1)) == 0; 88 return (X & (N - 1)) == 0;
77 } 89 }
78 90
79 /// Return Value adjusted to the next highest multiple of Alignment. 91 /// Return Value adjusted to the next highest multiple of Alignment.
80 static inline uint32_t applyAlignment(uint32_t Value, uint32_t Alignment) { 92 static inline uint32_t applyAlignment(uint32_t Value, uint32_t Alignment) {
81 assert(llvm::isPowerOf2_32(Alignment)); 93 assert(llvm::isPowerOf2_32(Alignment));
82 return (Value + Alignment - 1) & -Alignment; 94 return (Value + Alignment - 1) & -Alignment;
(...skipping 21 matching lines...) Expand all
104 static inline uint32_t rotateRight32(uint32_t value, uint32_t shift) { 116 static inline uint32_t rotateRight32(uint32_t value, uint32_t shift) {
105 if (shift == 0) 117 if (shift == 0)
106 return value; 118 return value;
107 return (value >> shift) | (value << (32 - shift)); 119 return (value >> shift) | (value << (32 - shift));
108 } 120 }
109 }; 121 };
110 122
111 } // end of namespace Ice 123 } // end of namespace Ice
112 124
113 #endif // SUBZERO_SRC_ICEUTILS_H 125 #endif // SUBZERO_SRC_ICEUTILS_H
OLDNEW
« no previous file with comments | « src/IceTimerTree.def ('k') | tests_lit/llvm2ice_tests/loop-nest-depth.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698