OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PPC_MACRO_ASSEMBLER_PPC_H_ | 5 #ifndef V8_PPC_MACRO_ASSEMBLER_PPC_H_ |
6 #define V8_PPC_MACRO_ASSEMBLER_PPC_H_ | 6 #define V8_PPC_MACRO_ASSEMBLER_PPC_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/frames.h" | 10 #include "src/frames.h" |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 Label* zero_and_neg, | 1112 Label* zero_and_neg, |
1113 Label* not_power_of_two); | 1113 Label* not_power_of_two); |
1114 | 1114 |
1115 // --------------------------------------------------------------------------- | 1115 // --------------------------------------------------------------------------- |
1116 // Bit testing/extraction | 1116 // Bit testing/extraction |
1117 // | 1117 // |
1118 // Bit numbering is such that the least significant bit is bit 0 | 1118 // Bit numbering is such that the least significant bit is bit 0 |
1119 // (for consistency between 32/64-bit). | 1119 // (for consistency between 32/64-bit). |
1120 | 1120 |
1121 // Extract consecutive bits (defined by rangeStart - rangeEnd) from src | 1121 // Extract consecutive bits (defined by rangeStart - rangeEnd) from src |
1122 // and place them into the least significant bits of dst. | 1122 // and, if !test, shift them into the least significant bits of dst. |
1123 inline void ExtractBitRange(Register dst, Register src, int rangeStart, | 1123 inline void ExtractBitRange(Register dst, Register src, int rangeStart, |
1124 int rangeEnd, RCBit rc = LeaveRC) { | 1124 int rangeEnd, RCBit rc = LeaveRC, |
| 1125 bool test = false) { |
1125 DCHECK(rangeStart >= rangeEnd && rangeStart < kBitsPerPointer); | 1126 DCHECK(rangeStart >= rangeEnd && rangeStart < kBitsPerPointer); |
1126 int rotate = (rangeEnd == 0) ? 0 : kBitsPerPointer - rangeEnd; | 1127 int rotate = (rangeEnd == 0) ? 0 : kBitsPerPointer - rangeEnd; |
1127 int width = rangeStart - rangeEnd + 1; | 1128 int width = rangeStart - rangeEnd + 1; |
1128 if (rc == SetRC && rangeEnd == 0 && width <= 16) { | 1129 if (rc == SetRC && rangeStart < 16 && (rangeEnd == 0 || test)) { |
1129 andi(dst, src, Operand((1 << width) - 1)); | 1130 // Prefer faster andi when applicable. |
| 1131 andi(dst, src, Operand(((1 << width) - 1) << rangeEnd)); |
1130 } else { | 1132 } else { |
1131 #if V8_TARGET_ARCH_PPC64 | 1133 #if V8_TARGET_ARCH_PPC64 |
1132 rldicl(dst, src, rotate, kBitsPerPointer - width, rc); | 1134 rldicl(dst, src, rotate, kBitsPerPointer - width, rc); |
1133 #else | 1135 #else |
1134 rlwinm(dst, src, rotate, kBitsPerPointer - width, kBitsPerPointer - 1, | 1136 rlwinm(dst, src, rotate, kBitsPerPointer - width, kBitsPerPointer - 1, |
1135 rc); | 1137 rc); |
1136 #endif | 1138 #endif |
1137 } | 1139 } |
1138 } | 1140 } |
1139 | 1141 |
1140 inline void ExtractBit(Register dst, Register src, uint32_t bitNumber, | 1142 inline void ExtractBit(Register dst, Register src, uint32_t bitNumber, |
1141 RCBit rc = LeaveRC) { | 1143 RCBit rc = LeaveRC, bool test = false) { |
1142 ExtractBitRange(dst, src, bitNumber, bitNumber, rc); | 1144 ExtractBitRange(dst, src, bitNumber, bitNumber, rc, test); |
1143 } | 1145 } |
1144 | 1146 |
1145 // Extract consecutive bits (defined by mask) from src and place them | 1147 // Extract consecutive bits (defined by mask) from src and place them |
1146 // into the least significant bits of dst. | 1148 // into the least significant bits of dst. |
1147 inline void ExtractBitMask(Register dst, Register src, uintptr_t mask, | 1149 inline void ExtractBitMask(Register dst, Register src, uintptr_t mask, |
1148 RCBit rc = LeaveRC) { | 1150 RCBit rc = LeaveRC, bool test = false) { |
1149 int start = kBitsPerPointer - 1; | 1151 int start = kBitsPerPointer - 1; |
1150 int end; | 1152 int end; |
1151 uintptr_t bit = (1L << start); | 1153 uintptr_t bit = (1L << start); |
1152 | 1154 |
1153 while (bit && (mask & bit) == 0) { | 1155 while (bit && (mask & bit) == 0) { |
1154 start--; | 1156 start--; |
1155 bit >>= 1; | 1157 bit >>= 1; |
1156 } | 1158 } |
1157 end = start; | 1159 end = start; |
1158 bit >>= 1; | 1160 bit >>= 1; |
1159 | 1161 |
1160 while (bit && (mask & bit)) { | 1162 while (bit && (mask & bit)) { |
1161 end--; | 1163 end--; |
1162 bit >>= 1; | 1164 bit >>= 1; |
1163 } | 1165 } |
1164 | 1166 |
1165 // 1-bits in mask must be contiguous | 1167 // 1-bits in mask must be contiguous |
1166 DCHECK(bit == 0 || (mask & ((bit << 1) - 1)) == 0); | 1168 DCHECK(bit == 0 || (mask & ((bit << 1) - 1)) == 0); |
1167 | 1169 |
1168 ExtractBitRange(dst, src, start, end, rc); | 1170 ExtractBitRange(dst, src, start, end, rc, test); |
1169 } | 1171 } |
1170 | 1172 |
1171 // Test single bit in value. | 1173 // Test single bit in value. |
1172 inline void TestBit(Register value, int bitNumber, Register scratch = r0) { | 1174 inline void TestBit(Register value, int bitNumber, Register scratch = r0) { |
1173 ExtractBitRange(scratch, value, bitNumber, bitNumber, SetRC); | 1175 ExtractBitRange(scratch, value, bitNumber, bitNumber, SetRC, true); |
1174 } | 1176 } |
1175 | 1177 |
1176 // Test consecutive bit range in value. Range is defined by | 1178 // Test consecutive bit range in value. Range is defined by |
1177 // rangeStart - rangeEnd. | 1179 // rangeStart - rangeEnd. |
1178 inline void TestBitRange(Register value, int rangeStart, int rangeEnd, | 1180 inline void TestBitRange(Register value, int rangeStart, int rangeEnd, |
1179 Register scratch = r0) { | 1181 Register scratch = r0) { |
1180 ExtractBitRange(scratch, value, rangeStart, rangeEnd, SetRC); | 1182 ExtractBitRange(scratch, value, rangeStart, rangeEnd, SetRC, true); |
1181 } | 1183 } |
1182 | 1184 |
1183 // Test consecutive bit range in value. Range is defined by mask. | 1185 // Test consecutive bit range in value. Range is defined by mask. |
1184 inline void TestBitMask(Register value, uintptr_t mask, | 1186 inline void TestBitMask(Register value, uintptr_t mask, |
1185 Register scratch = r0) { | 1187 Register scratch = r0) { |
1186 ExtractBitMask(scratch, value, mask, SetRC); | 1188 ExtractBitMask(scratch, value, mask, SetRC, true); |
1187 } | 1189 } |
1188 | 1190 |
1189 | 1191 |
1190 // --------------------------------------------------------------------------- | 1192 // --------------------------------------------------------------------------- |
1191 // Smi utilities | 1193 // Smi utilities |
1192 | 1194 |
1193 // Shift left by kSmiShift | 1195 // Shift left by kSmiShift |
1194 void SmiTag(Register reg, RCBit rc = LeaveRC) { SmiTag(reg, reg, rc); } | 1196 void SmiTag(Register reg, RCBit rc = LeaveRC) { SmiTag(reg, reg, rc); } |
1195 void SmiTag(Register dst, Register src, RCBit rc = LeaveRC) { | 1197 void SmiTag(Register dst, Register src, RCBit rc = LeaveRC) { |
1196 ShiftLeftImm(dst, src, Operand(kSmiShift), rc); | 1198 ShiftLeftImm(dst, src, Operand(kSmiShift), rc); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 #define ACCESS_MASM(masm) \ | 1635 #define ACCESS_MASM(masm) \ |
1634 masm->stop(__FILE_LINE__); \ | 1636 masm->stop(__FILE_LINE__); \ |
1635 masm-> | 1637 masm-> |
1636 #else | 1638 #else |
1637 #define ACCESS_MASM(masm) masm-> | 1639 #define ACCESS_MASM(masm) masm-> |
1638 #endif | 1640 #endif |
1639 } // namespace internal | 1641 } // namespace internal |
1640 } // namespace v8 | 1642 } // namespace v8 |
1641 | 1643 |
1642 #endif // V8_PPC_MACRO_ASSEMBLER_PPC_H_ | 1644 #endif // V8_PPC_MACRO_ASSEMBLER_PPC_H_ |
OLD | NEW |