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

Side by Side Diff: runtime/vm/simulator_arm64.cc

Issue 2639693002: VM: Fix umulh on simarm64 Windows. (Closed)
Patch Set: add unsigned Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <setjmp.h> // NOLINT 5 #include <setjmp.h> // NOLINT
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #if defined(TARGET_ARCH_ARM64) 9 #if defined(TARGET_ARCH_ARM64)
10 10
(...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 uint8_t s_shift = kXRegSizeInBits - reg_size; 2254 uint8_t s_shift = kXRegSizeInBits - reg_size;
2255 // Value with its sign restored. 2255 // Value with its sign restored.
2256 int64_t s_value = (value << s_shift) >> s_shift; 2256 int64_t s_value = (value << s_shift) >> s_shift;
2257 return (s_value >> amount) & mask; 2257 return (s_value >> amount) & mask;
2258 } 2258 }
2259 case ROR: { 2259 case ROR: {
2260 if (reg_size == kWRegSizeInBits) { 2260 if (reg_size == kWRegSizeInBits) {
2261 value &= kWRegMask; 2261 value &= kWRegMask;
2262 } 2262 }
2263 return (static_cast<uint64_t>(value) >> amount) | 2263 return (static_cast<uint64_t>(value) >> amount) |
2264 ((value & ((1L << amount) - 1L)) << (reg_size - amount)); 2264 ((static_cast<uint64_t>(value) & ((1ULL << amount) - 1ULL))
2265 << (reg_size - amount));
2265 } 2266 }
2266 default: 2267 default:
2267 UNIMPLEMENTED(); 2268 UNIMPLEMENTED();
2268 return 0; 2269 return 0;
2269 } 2270 }
2270 } 2271 }
2271 2272
2272 2273
2273 int64_t Simulator::ExtendOperand(uint8_t reg_size, 2274 int64_t Simulator::ExtendOperand(uint8_t reg_size,
2274 int64_t value, 2275 int64_t value,
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 const int64_t alu_out = static_cast<int64_t>(res >> 64); 2667 const int64_t alu_out = static_cast<int64_t>(res >> 64);
2667 #endif // TARGET_OS_WINDOWS 2668 #endif // TARGET_OS_WINDOWS
2668 set_register(instr, rd, alu_out, R31IsZR); 2669 set_register(instr, rd, alu_out, R31IsZR);
2669 } else if ((instr->Bits(29, 2) == 0) && (instr->Bits(21, 3) == 6) && 2670 } else if ((instr->Bits(29, 2) == 0) && (instr->Bits(21, 3) == 6) &&
2670 (instr->Bit(15) == 0)) { 2671 (instr->Bit(15) == 0)) {
2671 // Format(instr, "umulh 'rd, 'rn, 'rm"); 2672 // Format(instr, "umulh 'rd, 'rn, 'rm");
2672 const uint64_t rn_val = get_register(rn, R31IsZR); 2673 const uint64_t rn_val = get_register(rn, R31IsZR);
2673 const uint64_t rm_val = get_register(rm, R31IsZR); 2674 const uint64_t rm_val = get_register(rm, R31IsZR);
2674 #if defined(TARGET_OS_WINDOWS) 2675 #if defined(TARGET_OS_WINDOWS)
2675 // Visual Studio does not support __int128. 2676 // Visual Studio does not support __int128.
2676 int64_t alu_out; 2677 uint64_t alu_out;
2677 Multiply128(rn_val, rm_val, &alu_out); 2678 UnsignedMultiply128(rn_val, rm_val, &alu_out);
2678 #else 2679 #else
2679 const __int128 res = 2680 const unsigned __int128 res = static_cast<unsigned __int128>(rn_val) *
2680 static_cast<__int128>(rn_val) * static_cast<__int128>(rm_val); 2681 static_cast<unsigned __int128>(rm_val);
2681 const int64_t alu_out = static_cast<int64_t>(res >> 64); 2682 const uint64_t alu_out = static_cast<uint64_t>(res >> 64);
2682 #endif // TARGET_OS_WINDOWS 2683 #endif // TARGET_OS_WINDOWS
2683 set_register(instr, rd, alu_out, R31IsZR); 2684 set_register(instr, rd, alu_out, R31IsZR);
2684 } else if ((instr->Bits(29, 3) == 4) && (instr->Bits(21, 3) == 5) && 2685 } else if ((instr->Bits(29, 3) == 4) && (instr->Bits(21, 3) == 5) &&
2685 (instr->Bit(15) == 0)) { 2686 (instr->Bit(15) == 0)) {
2686 // Format(instr, "umaddl 'rd, 'rn, 'rm, 'ra"); 2687 // Format(instr, "umaddl 'rd, 'rn, 'rm, 'ra");
2687 const uint64_t rn_val = static_cast<uint32_t>(get_wregister(rn, R31IsZR)); 2688 const uint64_t rn_val = static_cast<uint32_t>(get_wregister(rn, R31IsZR));
2688 const uint64_t rm_val = static_cast<uint32_t>(get_wregister(rm, R31IsZR)); 2689 const uint64_t rm_val = static_cast<uint32_t>(get_wregister(rm, R31IsZR));
2689 const uint64_t ra_val = get_register(ra, R31IsZR); 2690 const uint64_t ra_val = get_register(ra, R31IsZR);
2690 const uint64_t alu_out = ra_val + (rn_val * rm_val); 2691 const uint64_t alu_out = ra_val + (rn_val * rm_val);
2691 set_register(instr, rd, alu_out, R31IsZR); 2692 set_register(instr, rd, alu_out, R31IsZR);
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 set_register(NULL, CODE_REG, code); 3647 set_register(NULL, CODE_REG, code);
3647 set_register(NULL, PP, pp); 3648 set_register(NULL, PP, pp);
3648 buf->Longjmp(); 3649 buf->Longjmp();
3649 } 3650 }
3650 3651
3651 } // namespace dart 3652 } // namespace dart
3652 3653
3653 #endif // !defined(USING_SIMULATOR) 3654 #endif // !defined(USING_SIMULATOR)
3654 3655
3655 #endif // defined TARGET_ARCH_ARM64 3656 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698