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

Side by Side Diff: src/IceUtils.h

Issue 1136793002: Handle ARM "ret void" and function alignment with proper padding. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: note moved to cpp Created 5 years, 7 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/IceTargetLoweringX8632.cpp ('k') | src/assembler.h » ('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 // This file declares some utility functions. 10 // This file declares some utility functions.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return (-limit <= value) && (value < limit); 44 return (-limit <= value) && (value < limit);
45 } 45 }
46 46
47 template <typename T> static inline bool IsUint(int N, T value) { 47 template <typename T> static inline bool IsUint(int N, T value) {
48 assert((0 < N) && 48 assert((0 < N) &&
49 (static_cast<unsigned int>(N) < (CHAR_BIT * sizeof(value)))); 49 (static_cast<unsigned int>(N) < (CHAR_BIT * sizeof(value))));
50 T limit = static_cast<T>(1) << N; 50 T limit = static_cast<T>(1) << N;
51 return (0 <= value) && (value < limit); 51 return (0 <= value) && (value < limit);
52 } 52 }
53 53
54 // Check whether the magnitude of value fits in N bits, i.e., whether an
55 // (N+1)-bit sign-magnitude representation can hold value.
56 template <typename T> static inline bool IsAbsoluteUint(int N, T Value) {
57 assert((0 < N) &&
58 (static_cast<unsigned int>(N) < (CHAR_BIT * sizeof(Value))));
59 if (Value < 0)
60 Value = -Value;
61 return IsUint(N, Value);
62 }
63
54 template <typename T> static inline bool WouldOverflowAdd(T X, T Y) { 64 template <typename T> static inline bool WouldOverflowAdd(T X, T Y) {
55 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) || 65 return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) ||
56 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y))); 66 (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y)));
57 } 67 }
58 68
69 template <typename T> static inline bool IsAligned(T X, intptr_t N) {
70 assert(llvm::isPowerOf2_64(N));
71 return (X & (N - 1)) == 0;
72 }
73
59 static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) { 74 static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) {
60 assert(llvm::isPowerOf2_64(Align)); 75 assert(llvm::isPowerOf2_64(Align));
61 uint64_t Mod = Pos & (Align - 1); 76 uint64_t Mod = Pos & (Align - 1);
62 if (Mod == 0) 77 if (Mod == 0)
63 return 0; 78 return 0;
64 return Align - Mod; 79 return Align - Mod;
65 } 80 }
66 }; 81 };
67 82
68 } // end of namespace Ice 83 } // end of namespace Ice
69 84
70 #endif // SUBZERO_SRC_ICEUTILS_H 85 #endif // SUBZERO_SRC_ICEUTILS_H
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698