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

Side by Side Diff: src/compiler/s390/code-generator-s390.cc

Issue 1939763003: S390X: Prevent upper 32bit corruption in 32bit ops (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 | « no previous file | src/s390/macro-assembler-s390.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 break; 801 break;
802 case kS390_OrComplement: 802 case kS390_OrComplement:
803 __ NotP(i.InputRegister(1)); 803 __ NotP(i.InputRegister(1));
804 __ OrP(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); 804 __ OrP(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
805 break; 805 break;
806 case kS390_Xor: 806 case kS390_Xor:
807 ASSEMBLE_BINOP(XorP, XorP); 807 ASSEMBLE_BINOP(XorP, XorP);
808 break; 808 break;
809 case kS390_ShiftLeft32: 809 case kS390_ShiftLeft32:
810 if (HasRegisterInput(instr, 1)) { 810 if (HasRegisterInput(instr, 1)) {
811 if (i.OutputRegister().is(i.InputRegister(1))) { 811 if (i.OutputRegister().is(i.InputRegister(1)) &&
JoranSiu 2016/05/02 18:22:22 ShiftLeft masm shoudl really handle all of these c
812 !CpuFeatures::IsSupported(DISTINCT_OPS)) {
812 __ LoadRR(kScratchReg, i.InputRegister(1)); 813 __ LoadRR(kScratchReg, i.InputRegister(1));
813 __ ShiftLeft(i.OutputRegister(), i.InputRegister(0), kScratchReg); 814 __ ShiftLeft(i.OutputRegister(), i.InputRegister(0), kScratchReg);
814 } else { 815 } else {
815 ASSEMBLE_BINOP(ShiftLeft, ShiftLeft); 816 ASSEMBLE_BINOP(ShiftLeft, ShiftLeft);
816 } 817 }
817 } else { 818 } else {
818 ASSEMBLE_BINOP(ShiftLeft, ShiftLeft); 819 ASSEMBLE_BINOP(ShiftLeft, ShiftLeft);
819 } 820 }
820 #if V8_TARGET_ARCH_S390X 821 #if V8_TARGET_ARCH_S390X
821 __ lgfr(i.OutputRegister(0), i.OutputRegister(0)); 822 __ lgfr(i.OutputRegister(0), i.OutputRegister(0));
822 #endif 823 #endif
823 break; 824 break;
824 #if V8_TARGET_ARCH_S390X 825 #if V8_TARGET_ARCH_S390X
825 case kS390_ShiftLeft64: 826 case kS390_ShiftLeft64:
826 ASSEMBLE_BINOP(sllg, sllg); 827 ASSEMBLE_BINOP(sllg, sllg);
827 break; 828 break;
828 #endif 829 #endif
829 case kS390_ShiftRight32: 830 case kS390_ShiftRight32:
830 if (HasRegisterInput(instr, 1)) { 831 if (HasRegisterInput(instr, 1)) {
831 if (i.OutputRegister().is(i.InputRegister(1))) { 832 if (i.OutputRegister().is(i.InputRegister(1)) &&
833 !CpuFeatures::IsSupported(DISTINCT_OPS)) {
832 __ LoadRR(kScratchReg, i.InputRegister(1)); 834 __ LoadRR(kScratchReg, i.InputRegister(1));
833 __ ShiftRight(i.OutputRegister(), i.InputRegister(0), kScratchReg); 835 __ ShiftRight(i.OutputRegister(), i.InputRegister(0), kScratchReg);
834 } else { 836 } else {
835 ASSEMBLE_BINOP(ShiftRight, ShiftRight); 837 ASSEMBLE_BINOP(ShiftRight, ShiftRight);
836 } 838 }
837 } else { 839 } else {
838 ASSEMBLE_BINOP(ShiftRight, ShiftRight); 840 ASSEMBLE_BINOP(ShiftRight, ShiftRight);
839 } 841 }
840 #if V8_TARGET_ARCH_S390X 842 #if V8_TARGET_ARCH_S390X
841 __ lgfr(i.OutputRegister(0), i.OutputRegister(0)); 843 __ lgfr(i.OutputRegister(0), i.OutputRegister(0));
842 #endif 844 #endif
843 break; 845 break;
844 #if V8_TARGET_ARCH_S390X 846 #if V8_TARGET_ARCH_S390X
845 case kS390_ShiftRight64: 847 case kS390_ShiftRight64:
846 ASSEMBLE_BINOP(srlg, srlg); 848 ASSEMBLE_BINOP(srlg, srlg);
847 break; 849 break;
848 #endif 850 #endif
849 case kS390_ShiftRightArith32: 851 case kS390_ShiftRightArith32:
850 if (HasRegisterInput(instr, 1)) { 852 if (HasRegisterInput(instr, 1)) {
851 if (i.OutputRegister().is(i.InputRegister(1))) { 853 if (i.OutputRegister().is(i.InputRegister(1)) &&
854 !CpuFeatures::IsSupported(DISTINCT_OPS)) {
852 __ LoadRR(kScratchReg, i.InputRegister(1)); 855 __ LoadRR(kScratchReg, i.InputRegister(1));
853 __ ShiftRightArith(i.OutputRegister(), i.InputRegister(0), 856 __ ShiftRightArith(i.OutputRegister(), i.InputRegister(0),
854 kScratchReg); 857 kScratchReg);
855 } else { 858 } else {
856 ASSEMBLE_BINOP(ShiftRightArith, ShiftRightArith); 859 ASSEMBLE_BINOP(ShiftRightArith, ShiftRightArith);
857 } 860 }
858 } else { 861 } else {
859 ASSEMBLE_BINOP(ShiftRightArith, ShiftRightArith); 862 ASSEMBLE_BINOP(ShiftRightArith, ShiftRightArith);
860 } 863 }
864 #if V8_TARGET_ARCH_S390X
865 __ lgfr(i.OutputRegister(), i.OutputRegister());
866 #endif
861 break; 867 break;
862 #if V8_TARGET_ARCH_S390X 868 #if V8_TARGET_ARCH_S390X
863 case kS390_ShiftRightArith64: 869 case kS390_ShiftRightArith64:
864 ASSEMBLE_BINOP(srag, srag); 870 ASSEMBLE_BINOP(srag, srag);
865 break; 871 break;
866 #endif 872 #endif
867 #if !V8_TARGET_ARCH_S390X 873 #if !V8_TARGET_ARCH_S390X
868 case kS390_AddPair: 874 case kS390_AddPair:
869 // i.InputRegister(0) ... left low word. 875 // i.InputRegister(0) ... left low word.
870 // i.InputRegister(1) ... left high word. 876 // i.InputRegister(1) ... left high word.
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 break; 1092 break;
1087 case kS390_Mul32: 1093 case kS390_Mul32:
1088 #if V8_TARGET_ARCH_S390X 1094 #if V8_TARGET_ARCH_S390X
1089 case kS390_Mul64: 1095 case kS390_Mul64:
1090 #endif 1096 #endif
1091 __ Mul(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); 1097 __ Mul(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1));
1092 break; 1098 break;
1093 case kS390_MulHigh32: 1099 case kS390_MulHigh32:
1094 __ LoadRR(r1, i.InputRegister(0)); 1100 __ LoadRR(r1, i.InputRegister(0));
1095 __ mr_z(r0, i.InputRegister(1)); 1101 __ mr_z(r0, i.InputRegister(1));
1102 #if V8_TARGET_ARCH_S390X
JoranSiu 2016/05/02 18:22:22 We should introduce a Load_ExtendSrc() in masm so
1103 __ lgfr(i.OutputRegister(), r0);
1104 #else
1096 __ LoadRR(i.OutputRegister(), r0); 1105 __ LoadRR(i.OutputRegister(), r0);
1106 #endif
1097 break; 1107 break;
1098 case kS390_MulHighU32: 1108 case kS390_MulHighU32:
1099 __ LoadRR(r1, i.InputRegister(0)); 1109 __ LoadRR(r1, i.InputRegister(0));
1100 __ mlr(r0, i.InputRegister(1)); 1110 __ mlr(r0, i.InputRegister(1));
1111 #if V8_TARGET_ARCH_S390X
1112 __ lgfr(i.OutputRegister(), r0);
1113 #else
1101 __ LoadRR(i.OutputRegister(), r0); 1114 __ LoadRR(i.OutputRegister(), r0);
1115 #endif
1102 break; 1116 break;
1103 case kS390_MulFloat: 1117 case kS390_MulFloat:
1104 // Ensure we don't clobber right 1118 // Ensure we don't clobber right
1105 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) { 1119 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) {
1106 ASSEMBLE_FLOAT_UNOP(meebr); 1120 ASSEMBLE_FLOAT_UNOP(meebr);
1107 } else { 1121 } else {
1108 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0))) 1122 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0)))
1109 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1123 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1110 __ meebr(i.OutputDoubleRegister(), i.InputDoubleRegister(1)); 1124 __ meebr(i.OutputDoubleRegister(), i.InputDoubleRegister(1));
1111 } 1125 }
(...skipping 12 matching lines...) Expand all
1124 case kS390_Div64: 1138 case kS390_Div64:
1125 __ LoadRR(r1, i.InputRegister(0)); 1139 __ LoadRR(r1, i.InputRegister(0));
1126 __ dsgr(r0, i.InputRegister(1)); // R1: Dividend 1140 __ dsgr(r0, i.InputRegister(1)); // R1: Dividend
1127 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output 1141 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1128 break; 1142 break;
1129 #endif 1143 #endif
1130 case kS390_Div32: 1144 case kS390_Div32:
1131 __ LoadRR(r0, i.InputRegister(0)); 1145 __ LoadRR(r0, i.InputRegister(0));
1132 __ srda(r0, Operand(32)); 1146 __ srda(r0, Operand(32));
1133 __ dr(r0, i.InputRegister(1)); 1147 __ dr(r0, i.InputRegister(1));
1134 __ ltr(i.OutputRegister(), r1); 1148 #if V8_TARGET_ARCH_S390X
JoranSiu 2016/05/02 18:22:22 I believe this is the same as : LoadAndTestP_Exten
1149 __ ltgfr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1150 #else
1151 __ ltr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1152 #endif
1135 break; 1153 break;
1136 #if V8_TARGET_ARCH_S390X 1154 #if V8_TARGET_ARCH_S390X
1137 case kS390_DivU64: 1155 case kS390_DivU64:
1138 __ LoadRR(r1, i.InputRegister(0)); 1156 __ LoadRR(r1, i.InputRegister(0));
1139 __ LoadImmP(r0, Operand::Zero()); 1157 __ LoadImmP(r0, Operand::Zero());
1140 __ dlgr(r0, i.InputRegister(1)); // R0:R1: Dividend 1158 __ dlgr(r0, i.InputRegister(1)); // R0:R1: Dividend
1141 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output 1159 __ ltgr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1142 break; 1160 break;
1143 #endif 1161 #endif
1144 case kS390_DivU32: 1162 case kS390_DivU32:
1145 __ LoadRR(r0, i.InputRegister(0)); 1163 __ LoadRR(r0, i.InputRegister(0));
1146 __ srdl(r0, Operand(32)); 1164 __ srdl(r0, Operand(32));
1147 __ dlr(r0, i.InputRegister(1)); // R0:R1: Dividend 1165 __ dlr(r0, i.InputRegister(1)); // R0:R1: Dividend
1166 #if V8_TARGET_ARCH_S390X
1167 __ ltgfr(i.OutputRegister(), r1);
1168 #else
1148 __ ltr(i.OutputRegister(), r1); // Copy R1: Quotient to output 1169 __ ltr(i.OutputRegister(), r1); // Copy R1: Quotient to output
1170 #endif
1149 break; 1171 break;
1150 1172
1151 case kS390_DivFloat: 1173 case kS390_DivFloat:
1152 // InputDoubleRegister(1)=InputDoubleRegister(0)/InputDoubleRegister(1) 1174 // InputDoubleRegister(1)=InputDoubleRegister(0)/InputDoubleRegister(1)
1153 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) { 1175 if (i.OutputDoubleRegister().is(i.InputDoubleRegister(1))) {
1154 __ ldr(kScratchDoubleReg, i.InputDoubleRegister(1)); 1176 __ ldr(kScratchDoubleReg, i.InputDoubleRegister(1));
1155 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); 1177 __ ldr(i.OutputDoubleRegister(), i.InputDoubleRegister(0));
1156 __ debr(i.OutputDoubleRegister(), kScratchDoubleReg); 1178 __ debr(i.OutputDoubleRegister(), kScratchDoubleReg);
1157 } else { 1179 } else {
1158 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0))) 1180 if (!i.OutputDoubleRegister().is(i.InputDoubleRegister(0)))
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 padding_size -= 2; 2145 padding_size -= 2;
2124 } 2146 }
2125 } 2147 }
2126 } 2148 }
2127 2149
2128 #undef __ 2150 #undef __
2129 2151
2130 } // namespace compiler 2152 } // namespace compiler
2131 } // namespace internal 2153 } // namespace internal
2132 } // namespace v8 2154 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/s390/macro-assembler-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698