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

Side by Side Diff: src/s390/simulator-s390.cc

Issue 2743803002: s390: implement atomic exchange on TF (Closed)
Patch Set: small fix Created 3 years, 9 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/s390/simulator-s390.h ('k') | 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 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 #include <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #if V8_TARGET_ARCH_S390 9 #if V8_TARGET_ARCH_S390
10 10
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 EvalTable[SLDA] = &Simulator::Evaluate_SLDA; 835 EvalTable[SLDA] = &Simulator::Evaluate_SLDA;
836 EvalTable[STM] = &Simulator::Evaluate_STM; 836 EvalTable[STM] = &Simulator::Evaluate_STM;
837 EvalTable[TM] = &Simulator::Evaluate_TM; 837 EvalTable[TM] = &Simulator::Evaluate_TM;
838 EvalTable[MVI] = &Simulator::Evaluate_MVI; 838 EvalTable[MVI] = &Simulator::Evaluate_MVI;
839 EvalTable[TS] = &Simulator::Evaluate_TS; 839 EvalTable[TS] = &Simulator::Evaluate_TS;
840 EvalTable[NI] = &Simulator::Evaluate_NI; 840 EvalTable[NI] = &Simulator::Evaluate_NI;
841 EvalTable[CLI] = &Simulator::Evaluate_CLI; 841 EvalTable[CLI] = &Simulator::Evaluate_CLI;
842 EvalTable[OI] = &Simulator::Evaluate_OI; 842 EvalTable[OI] = &Simulator::Evaluate_OI;
843 EvalTable[XI] = &Simulator::Evaluate_XI; 843 EvalTable[XI] = &Simulator::Evaluate_XI;
844 EvalTable[LM] = &Simulator::Evaluate_LM; 844 EvalTable[LM] = &Simulator::Evaluate_LM;
845 EvalTable[CS] = &Simulator::Evaluate_CS;
845 EvalTable[MVCLE] = &Simulator::Evaluate_MVCLE; 846 EvalTable[MVCLE] = &Simulator::Evaluate_MVCLE;
846 EvalTable[CLCLE] = &Simulator::Evaluate_CLCLE; 847 EvalTable[CLCLE] = &Simulator::Evaluate_CLCLE;
847 EvalTable[MC] = &Simulator::Evaluate_MC; 848 EvalTable[MC] = &Simulator::Evaluate_MC;
848 EvalTable[CDS] = &Simulator::Evaluate_CDS; 849 EvalTable[CDS] = &Simulator::Evaluate_CDS;
849 EvalTable[STCM] = &Simulator::Evaluate_STCM; 850 EvalTable[STCM] = &Simulator::Evaluate_STCM;
850 EvalTable[ICM] = &Simulator::Evaluate_ICM; 851 EvalTable[ICM] = &Simulator::Evaluate_ICM;
851 EvalTable[BPRP] = &Simulator::Evaluate_BPRP; 852 EvalTable[BPRP] = &Simulator::Evaluate_BPRP;
852 EvalTable[BPP] = &Simulator::Evaluate_BPP; 853 EvalTable[BPP] = &Simulator::Evaluate_BPP;
853 EvalTable[TRTR] = &Simulator::Evaluate_TRTR; 854 EvalTable[TRTR] = &Simulator::Evaluate_TRTR;
854 EvalTable[MVN] = &Simulator::Evaluate_MVN; 855 EvalTable[MVN] = &Simulator::Evaluate_MVN;
(...skipping 5584 matching lines...) Expand 10 before | Expand all | Expand 10 after
6439 selection_mask = (static_cast<uint64_t>(1) << width) - 1; 6440 selection_mask = (static_cast<uint64_t>(1) << width) - 1;
6440 } else { 6441 } else {
6441 selection_mask = static_cast<uint64_t>(static_cast<int64_t>(-1)); 6442 selection_mask = static_cast<uint64_t>(static_cast<int64_t>(-1));
6442 } 6443 }
6443 selection_mask = selection_mask << (63 - end_bit); 6444 selection_mask = selection_mask << (63 - end_bit);
6444 6445
6445 uint64_t selected_val = rotated_val & selection_mask; 6446 uint64_t selected_val = rotated_val & selection_mask;
6446 6447
6447 if (!zero_remaining) { 6448 if (!zero_remaining) {
6448 // Merged the unselected bits from the original value 6449 // Merged the unselected bits from the original value
6449 selected_val = (src_val & ~selection_mask) | selected_val; 6450 selected_val = (get_register(r1) & ~selection_mask) | selected_val;
6450 } 6451 }
6451 6452
6452 // Condition code is set by treating result as 64-bit signed int 6453 // Condition code is set by treating result as 64-bit signed int
6453 SetS390ConditionCode<int64_t>(selected_val, 0); 6454 SetS390ConditionCode<int64_t>(selected_val, 0);
6454 set_register(r1, selected_val); 6455 set_register(r1, selected_val);
6455 return length; 6456 return length;
6456 } 6457 }
6457 6458
6458 EVALUATE(AHIK) { 6459 EVALUATE(AHIK) {
6459 DCHECK_OPCODE(AHIK); 6460 DCHECK_OPCODE(AHIK);
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after
7804 return length; // Done! 7805 return length; // Done!
7805 } 7806 }
7806 7807
7807 // Now we know selected bits mixed zeros and ones 7808 // Now we know selected bits mixed zeros and ones
7808 // Test if the leftmost bit is zero or one 7809 // Test if the leftmost bit is zero or one
7809 #if defined(__GNUC__) 7810 #if defined(__GNUC__)
7810 int leadingZeros = __builtin_clz(mask); 7811 int leadingZeros = __builtin_clz(mask);
7811 mask = 0x80000000u >> leadingZeros; 7812 mask = 0x80000000u >> leadingZeros;
7812 if (mask & r1_val) { 7813 if (mask & r1_val) {
7813 // leftmost bit is one 7814 // leftmost bit is one
7814 condition_reg_ = 0x4; 7815 condition_reg_ = 0x2;
7815 } else { 7816 } else {
7816 // leftmost bit is zero 7817 // leftmost bit is zero
7817 condition_reg_ = 0x2; 7818 condition_reg_ = 0x4;
7818 } 7819 }
7819 return length; // Done! 7820 return length; // Done!
7820 #else 7821 #else
7821 for (int i = 15; i >= 0; i--) { 7822 for (int i = 15; i >= 0; i--) {
7822 if (mask & (1 << i)) { 7823 if (mask & (1 << i)) {
7823 if (r1_val & (1 << i)) { 7824 if (r1_val & (1 << i)) {
7824 // leftmost bit is one 7825 // leftmost bit is one
7825 condition_reg_ = 0x2; 7826 condition_reg_ = 0x2;
7826 } else { 7827 } else {
7827 // leftmost bit is zero 7828 // leftmost bit is zero
(...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after
10492 DCHECK_OPCODE(LLCR); 10493 DCHECK_OPCODE(LLCR);
10493 DECODE_RRE_INSTRUCTION(r1, r2); 10494 DECODE_RRE_INSTRUCTION(r1, r2);
10494 uint32_t r2_val = get_low_register<uint32_t>(r2); 10495 uint32_t r2_val = get_low_register<uint32_t>(r2);
10495 r2_val <<= 24; 10496 r2_val <<= 24;
10496 r2_val >>= 24; 10497 r2_val >>= 24;
10497 set_low_register(r1, r2_val); 10498 set_low_register(r1, r2_val);
10498 return length; 10499 return length;
10499 } 10500 }
10500 10501
10501 EVALUATE(LLHR) { 10502 EVALUATE(LLHR) {
10502 UNIMPLEMENTED(); 10503 DCHECK_OPCODE(LLHR);
10503 USE(instr); 10504 DECODE_RRE_INSTRUCTION(r1, r2);
10504 return 0; 10505 uint32_t r2_val = get_low_register<uint32_t>(r2);
10506 r2_val <<= 16;
10507 r2_val >>= 16;
10508 set_low_register(r1, r2_val);
10509 return length;
10505 } 10510 }
10506 10511
10507 EVALUATE(MLR) { 10512 EVALUATE(MLR) {
10508 DCHECK_OPCODE(MLR); 10513 DCHECK_OPCODE(MLR);
10509 DECODE_RRE_INSTRUCTION(r1, r2); 10514 DECODE_RRE_INSTRUCTION(r1, r2);
10510 DCHECK(r1 % 2 == 0); 10515 DCHECK(r1 % 2 == 0);
10511 10516
10512 uint32_t r1_val = get_low_register<uint32_t>(r1 + 1); 10517 uint32_t r1_val = get_low_register<uint32_t>(r1 + 1);
10513 uint32_t r2_val = get_low_register<uint32_t>(r2); 10518 uint32_t r2_val = get_low_register<uint32_t>(r2);
10514 uint64_t product = 10519 uint64_t product =
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
11972 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); 11977 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2);
11973 int shiftBits = (b2_val + d2) & 0x3F; 11978 int shiftBits = (b2_val + d2) & 0x3F;
11974 // unsigned 11979 // unsigned
11975 uint64_t r3_val = get_register(r3); 11980 uint64_t r3_val = get_register(r3);
11976 uint64_t alu_out = 0; 11981 uint64_t alu_out = 0;
11977 alu_out = r3_val << shiftBits; 11982 alu_out = r3_val << shiftBits;
11978 set_register(r1, alu_out); 11983 set_register(r1, alu_out);
11979 return length; 11984 return length;
11980 } 11985 }
11981 11986
11987 EVALUATE(CS) {
11988 DCHECK_OPCODE(CS);
11989 DECODE_RS_A_INSTRUCTION(r1, r3, rb, d2);
11990 int32_t offset = d2;
11991 int64_t rb_val = (rb == 0) ? 0 : get_register(rb);
11992 intptr_t target_addr = static_cast<intptr_t>(rb_val) + offset;
11993
11994 int32_t r1_val = get_low_register<int32_t>(r1);
11995 int32_t r3_val = get_low_register<int32_t>(r3);
11996
11997 DCHECK((target_addr & 0x3) == 0);
11998 bool is_success = __atomic_compare_exchange_n(
11999 reinterpret_cast<int32_t*>(target_addr), &r1_val, r3_val, true,
12000 __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
12001 if (!is_success) {
12002 set_low_register(r1, r1_val);
12003 condition_reg_ = 0x4;
12004 } else {
12005 condition_reg_ = 0x8;
12006 }
12007 return length;
12008 }
12009
11982 EVALUATE(CSY) { 12010 EVALUATE(CSY) {
12011 DCHECK_OPCODE(CSY);
12012 DECODE_RSY_A_INSTRUCTION(r1, r3, b2, d2);
12013 int32_t offset = d2;
12014 int64_t b2_val = (b2 == 0) ? 0 : get_register(b2);
12015 intptr_t target_addr = static_cast<intptr_t>(b2_val) + offset;
12016
12017 int32_t r1_val = get_low_register<int32_t>(r1);
12018 int32_t r3_val = get_low_register<int32_t>(r3);
12019
12020 DCHECK((target_addr & 0x3) == 0);
12021 bool is_success = __atomic_compare_exchange_n(
12022 reinterpret_cast<int32_t*>(target_addr), &r1_val, r3_val, true,
12023 __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
12024 if (!is_success) {
12025 set_low_register(r1, r1_val);
12026 condition_reg_ = 0x4;
12027 } else {
12028 condition_reg_ = 0x8;
12029 }
12030 return length;
12031 }
12032
12033 EVALUATE(CSG) {
11983 UNIMPLEMENTED(); 12034 UNIMPLEMENTED();
11984 USE(instr); 12035 USE(instr);
11985 return 0; 12036 return 0;
11986 } 12037 }
11987 12038
11988 EVALUATE(RLLG) { 12039 EVALUATE(RLLG) {
11989 DCHECK_OPCODE(RLLG); 12040 DCHECK_OPCODE(RLLG);
11990 // For SLLG/SRLG, the 64-bit third operand is shifted the number 12041 // For SLLG/SRLG, the 64-bit third operand is shifted the number
11991 // of bits specified by the second-operand address, and the result is 12042 // of bits specified by the second-operand address, and the result is
11992 // placed at the first-operand location. Except for when the R1 and R3 12043 // placed at the first-operand location. Except for when the R1 and R3
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
12918 return 0; 12969 return 0;
12919 } 12970 }
12920 12971
12921 #undef EVALUATE 12972 #undef EVALUATE
12922 12973
12923 } // namespace internal 12974 } // namespace internal
12924 } // namespace v8 12975 } // namespace v8
12925 12976
12926 #endif // USE_SIMULATOR 12977 #endif // USE_SIMULATOR
12927 #endif // V8_TARGET_ARCH_S390 12978 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/s390/simulator-s390.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698