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/s390/macro-assembler-s390.cc

Issue 2662963002: s390: TF Optimize 32-bit Mul/Div/Mod/Popcnt (Closed)
Patch Set: fix dcheck Created 3 years, 10 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/macro-assembler-s390.h ('k') | src/s390/simulator-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 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 <assert.h> // For assert 5 #include <assert.h> // For assert
6 #include <limits.h> // For LONG_MIN, LONG_MAX. 6 #include <limits.h> // For LONG_MIN, LONG_MAX.
7 7
8 #if V8_TARGET_ARCH_S390 8 #if V8_TARGET_ARCH_S390
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 3263 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 UNIMPLEMENTED(); 3274 UNIMPLEMENTED();
3275 } 3275 }
3276 } 3276 }
3277 3277
3278 void MacroAssembler::Mul32(Register dst, Register src1) { msr(dst, src1); } 3278 void MacroAssembler::Mul32(Register dst, Register src1) { msr(dst, src1); }
3279 3279
3280 void MacroAssembler::Mul32(Register dst, const Operand& src1) { 3280 void MacroAssembler::Mul32(Register dst, const Operand& src1) {
3281 msfi(dst, src1); 3281 msfi(dst, src1);
3282 } 3282 }
3283 3283
3284 #define Generate_MulHigh32(instr) \
3285 { \
3286 lgfr(dst, src1); \
3287 instr(dst, src2); \
3288 srlg(dst, dst, Operand(32)); \
3289 }
3290
3284 void MacroAssembler::MulHigh32(Register dst, Register src1, 3291 void MacroAssembler::MulHigh32(Register dst, Register src1,
3285 const MemOperand& src2) { 3292 const MemOperand& src2) {
3286 lgfr(dst, src1); 3293 Generate_MulHigh32(msgf);
3287 msgf(dst, src2);
3288 srlg(dst, dst, Operand(32));
3289 } 3294 }
3290 3295
3291 void MacroAssembler::MulHigh32(Register dst, Register src1, Register src2) { 3296 void MacroAssembler::MulHigh32(Register dst, Register src1, Register src2) {
3292 if (dst.is(src2)) { 3297 if (dst.is(src2)) {
3293 std::swap(src1, src2); 3298 std::swap(src1, src2);
3294 } 3299 }
3295 lgfr(dst, src1); 3300 Generate_MulHigh32(msgfr);
3296 msgfr(dst, src2);
3297 srlg(dst, dst, Operand(32));
3298 } 3301 }
3299 3302
3300 void MacroAssembler::MulHigh32(Register dst, Register src1, 3303 void MacroAssembler::MulHigh32(Register dst, Register src1,
3301 const Operand& src2) { 3304 const Operand& src2) {
3302 lgfr(dst, src1); 3305 Generate_MulHigh32(msgfi);
3303 msgfi(dst, src2); 3306 }
3304 srlg(dst, dst, Operand(32)); 3307
3308 #undef Generate_MulHigh32
3309
3310 #define Generate_MulHighU32(instr) \
3311 { \
3312 lr(r1, src1); \
3313 instr(r0, src2); \
3314 LoadlW(dst, r0); \
3315 }
3316
3317 void MacroAssembler::MulHighU32(Register dst, Register src1,
3318 const MemOperand& src2) {
3319 Generate_MulHighU32(ml);
3320 }
3321
3322 void MacroAssembler::MulHighU32(Register dst, Register src1, Register src2) {
3323 Generate_MulHighU32(mlr);
3324 }
3325
3326 void MacroAssembler::MulHighU32(Register dst, Register src1,
3327 const Operand& src2) {
3328 USE(dst);
3329 USE(src1);
3330 USE(src2);
3331 UNREACHABLE();
3332 }
3333
3334 #undef Generate_MulHighU32
3335
3336 #define Generate_Mul32WithOverflowIfCCUnequal(instr) \
3337 { \
3338 lgfr(dst, src1); \
3339 instr(dst, src2); \
3340 cgfr(dst, dst); \
3341 }
3342
3343 void MacroAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1,
3344 const MemOperand& src2) {
3345 Generate_Mul32WithOverflowIfCCUnequal(msgf);
3305 } 3346 }
3306 3347
3307 void MacroAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1, 3348 void MacroAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1,
3308 const MemOperand& src2) {
3309 lgfr(dst, src1);
3310 msgf(dst, src2);
3311 cgfr(dst, dst);
3312 }
3313
3314 void MacroAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1,
3315 Register src2) { 3349 Register src2) {
3316 if (dst.is(src2)) { 3350 if (dst.is(src2)) {
3317 std::swap(src1, src2); 3351 std::swap(src1, src2);
3318 } 3352 }
3319 lgfr(dst, src1); 3353 Generate_Mul32WithOverflowIfCCUnequal(msgfr);
3320 msgfr(dst, src2);
3321 cgfr(dst, dst);
3322 } 3354 }
3323 3355
3324 void MacroAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1, 3356 void MacroAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1,
3325 const Operand& src2) { 3357 const Operand& src2) {
3326 lgfr(dst, src1); 3358 Generate_Mul32WithOverflowIfCCUnequal(msgfi);
3327 msgfi(dst, src2);
3328 cgfr(dst, dst);
3329 } 3359 }
3330 3360
3361 #undef Generate_Mul32WithOverflowIfCCUnequal
3362
3331 void MacroAssembler::Mul64(Register dst, const MemOperand& src1) { 3363 void MacroAssembler::Mul64(Register dst, const MemOperand& src1) {
3332 if (is_int20(src1.offset())) { 3364 if (is_int20(src1.offset())) {
3333 msg(dst, src1); 3365 msg(dst, src1);
3334 } else { 3366 } else {
3335 UNIMPLEMENTED(); 3367 UNIMPLEMENTED();
3336 } 3368 }
3337 } 3369 }
3338 3370
3339 void MacroAssembler::Mul64(Register dst, Register src1) { msgr(dst, src1); } 3371 void MacroAssembler::Mul64(Register dst, Register src1) { msgr(dst, src1); }
3340 3372
(...skipping 15 matching lines...) Expand all
3356 void MacroAssembler::DivP(Register dividend, Register divider) { 3388 void MacroAssembler::DivP(Register dividend, Register divider) {
3357 // have to make sure the src and dst are reg pairs 3389 // have to make sure the src and dst are reg pairs
3358 DCHECK(dividend.code() % 2 == 0); 3390 DCHECK(dividend.code() % 2 == 0);
3359 #if V8_TARGET_ARCH_S390X 3391 #if V8_TARGET_ARCH_S390X
3360 dsgr(dividend, divider); 3392 dsgr(dividend, divider);
3361 #else 3393 #else
3362 dr(dividend, divider); 3394 dr(dividend, divider);
3363 #endif 3395 #endif
3364 } 3396 }
3365 3397
3398 #define Generate_Div32(instr) \
3399 { \
3400 lgfr(r1, src1); \
3401 instr(r0, src2); \
3402 LoadlW(dst, r1); \
3403 }
3404
3405 void MacroAssembler::Div32(Register dst, Register src1,
3406 const MemOperand& src2) {
3407 Generate_Div32(dsgf);
3408 }
3409
3410 void MacroAssembler::Div32(Register dst, Register src1, Register src2) {
3411 Generate_Div32(dsgfr);
3412 }
3413
3414 void MacroAssembler::Div32(Register dst, Register src1, const Operand& src2) {
3415 USE(dst);
3416 USE(src1);
3417 USE(src2);
3418 UNREACHABLE();
3419 }
3420
3421 #undef Generate_Div32
3422
3423 #define Generate_DivU32(instr) \
3424 { \
3425 lr(r0, src1); \
3426 srdl(r0, Operand(32)); \
3427 instr(r0, src2); \
3428 LoadlW(dst, r1); \
3429 }
3430
3431 void MacroAssembler::DivU32(Register dst, Register src1,
3432 const MemOperand& src2) {
3433 Generate_DivU32(dl);
3434 }
3435
3436 void MacroAssembler::DivU32(Register dst, Register src1, Register src2) {
3437 Generate_DivU32(dlr);
3438 }
3439
3440 void MacroAssembler::DivU32(Register dst, Register src1, const Operand& src2) {
3441 USE(dst);
3442 USE(src1);
3443 USE(src2);
3444 UNREACHABLE();
3445 }
3446
3447 #undef Generate_DivU32
3448
3449 #define Generate_Mod32(instr) \
3450 { \
3451 lgfr(r1, src1); \
3452 instr(r0, src2); \
3453 LoadlW(dst, r0); \
3454 }
3455
3456 void MacroAssembler::Mod32(Register dst, Register src1,
3457 const MemOperand& src2) {
3458 Generate_Mod32(dsgf);
3459 }
3460
3461 void MacroAssembler::Mod32(Register dst, Register src1, Register src2) {
3462 Generate_Mod32(dsgfr);
3463 }
3464
3465 void MacroAssembler::Mod32(Register dst, Register src1, const Operand& src2) {
3466 USE(dst);
3467 USE(src1);
3468 USE(src2);
3469 UNREACHABLE();
3470 }
3471
3472 #undef Generate_Mod32
3473
3474 #define Generate_ModU32(instr) \
3475 { \
3476 lr(r0, src1); \
3477 srdl(r0, Operand(32)); \
3478 instr(r0, src2); \
3479 LoadlW(dst, r0); \
3480 }
3481
3482 void MacroAssembler::ModU32(Register dst, Register src1,
3483 const MemOperand& src2) {
3484 Generate_ModU32(dl);
3485 }
3486
3487 void MacroAssembler::ModU32(Register dst, Register src1, Register src2) {
3488 Generate_ModU32(dlr);
3489 }
3490
3491 void MacroAssembler::ModU32(Register dst, Register src1, const Operand& src2) {
3492 USE(dst);
3493 USE(src1);
3494 USE(src2);
3495 UNREACHABLE();
3496 }
3497
3498 #undef Generate_ModU32
3499
3366 void MacroAssembler::MulP(Register dst, const Operand& opnd) { 3500 void MacroAssembler::MulP(Register dst, const Operand& opnd) {
3367 #if V8_TARGET_ARCH_S390X 3501 #if V8_TARGET_ARCH_S390X
3368 msgfi(dst, opnd); 3502 msgfi(dst, opnd);
3369 #else 3503 #else
3370 msfi(dst, opnd); 3504 msfi(dst, opnd);
3371 #endif 3505 #endif
3372 } 3506 }
3373 3507
3374 void MacroAssembler::MulP(Register dst, Register src) { 3508 void MacroAssembler::MulP(Register dst, Register src) {
3375 #if V8_TARGET_ARCH_S390X 3509 #if V8_TARGET_ARCH_S390X
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
4759 } 4893 }
4760 4894
4761 void MacroAssembler::LoadlB(Register dst, const MemOperand& mem) { 4895 void MacroAssembler::LoadlB(Register dst, const MemOperand& mem) {
4762 #if V8_TARGET_ARCH_S390X 4896 #if V8_TARGET_ARCH_S390X
4763 llgc(dst, mem); 4897 llgc(dst, mem);
4764 #else 4898 #else
4765 llc(dst, mem); 4899 llc(dst, mem);
4766 #endif 4900 #endif
4767 } 4901 }
4768 4902
4903 void MacroAssembler::LoadlB(Register dst, Register src) {
4904 #if V8_TARGET_ARCH_S390X
4905 llgcr(dst, src);
4906 #else
4907 llcr(dst, src);
4908 #endif
4909 }
4910
4769 void MacroAssembler::LoadLogicalReversedWordP(Register dst, 4911 void MacroAssembler::LoadLogicalReversedWordP(Register dst,
4770 const MemOperand& mem) { 4912 const MemOperand& mem) {
4771 lrv(dst, mem); 4913 lrv(dst, mem);
4772 LoadlW(dst, dst); 4914 LoadlW(dst, dst);
4773 } 4915 }
4774 4916
4775 4917
4776 void MacroAssembler::LoadLogicalReversedHalfWordP(Register dst, 4918 void MacroAssembler::LoadLogicalReversedHalfWordP(Register dst,
4777 const MemOperand& mem) { 4919 const MemOperand& mem) {
4778 lrvh(dst, mem); 4920 lrvh(dst, mem);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
5114 5256
5115 void MacroAssembler::Popcnt32(Register dst, Register src) { 5257 void MacroAssembler::Popcnt32(Register dst, Register src) {
5116 DCHECK(!src.is(r0)); 5258 DCHECK(!src.is(r0));
5117 DCHECK(!dst.is(r0)); 5259 DCHECK(!dst.is(r0));
5118 5260
5119 popcnt(dst, src); 5261 popcnt(dst, src);
5120 ShiftRight(r0, dst, Operand(16)); 5262 ShiftRight(r0, dst, Operand(16));
5121 ar(dst, r0); 5263 ar(dst, r0);
5122 ShiftRight(r0, dst, Operand(8)); 5264 ShiftRight(r0, dst, Operand(8));
5123 ar(dst, r0); 5265 ar(dst, r0);
5124 LoadB(dst, dst); 5266 LoadlB(dst, dst);
5125 } 5267 }
5126 5268
5127 #ifdef V8_TARGET_ARCH_S390X 5269 #ifdef V8_TARGET_ARCH_S390X
5128 void MacroAssembler::Popcnt64(Register dst, Register src) { 5270 void MacroAssembler::Popcnt64(Register dst, Register src) {
5129 DCHECK(!src.is(r0)); 5271 DCHECK(!src.is(r0));
5130 DCHECK(!dst.is(r0)); 5272 DCHECK(!dst.is(r0));
5131 5273
5132 popcnt(dst, src); 5274 popcnt(dst, src);
5133 ShiftRightP(r0, dst, Operand(32)); 5275 ShiftRightP(r0, dst, Operand(32));
5134 AddP(dst, r0); 5276 AddP(dst, r0);
5135 ShiftRightP(r0, dst, Operand(16)); 5277 ShiftRightP(r0, dst, Operand(16));
5136 AddP(dst, r0); 5278 AddP(dst, r0);
5137 ShiftRightP(r0, dst, Operand(8)); 5279 ShiftRightP(r0, dst, Operand(8));
5138 AddP(dst, r0); 5280 AddP(dst, r0);
5139 LoadB(dst, dst); 5281 LoadlB(dst, dst);
5140 } 5282 }
5141 #endif 5283 #endif
5142 5284
5143 #ifdef DEBUG 5285 #ifdef DEBUG
5144 bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4, 5286 bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4,
5145 Register reg5, Register reg6, Register reg7, Register reg8, 5287 Register reg5, Register reg6, Register reg7, Register reg8,
5146 Register reg9, Register reg10) { 5288 Register reg9, Register reg10) {
5147 int n_of_valid_regs = reg1.is_valid() + reg2.is_valid() + reg3.is_valid() + 5289 int n_of_valid_regs = reg1.is_valid() + reg2.is_valid() + reg3.is_valid() +
5148 reg4.is_valid() + reg5.is_valid() + reg6.is_valid() + 5290 reg4.is_valid() + reg5.is_valid() + reg6.is_valid() +
5149 reg7.is_valid() + reg8.is_valid() + reg9.is_valid() + 5291 reg7.is_valid() + reg8.is_valid() + reg9.is_valid() +
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5221 } 5363 }
5222 if (mag.shift > 0) ShiftRightArith(result, result, Operand(mag.shift)); 5364 if (mag.shift > 0) ShiftRightArith(result, result, Operand(mag.shift));
5223 ExtractBit(r0, dividend, 31); 5365 ExtractBit(r0, dividend, 31);
5224 AddP(result, r0); 5366 AddP(result, r0);
5225 } 5367 }
5226 5368
5227 } // namespace internal 5369 } // namespace internal
5228 } // namespace v8 5370 } // namespace v8
5229 5371
5230 #endif // V8_TARGET_ARCH_S390 5372 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/s390/macro-assembler-s390.h ('k') | src/s390/simulator-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698