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 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/mips/macro-assembler-mips.h" | 10 #include "src/mips/macro-assembler-mips.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 __ srav(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 233 __ srav(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
234 } else { | 234 } else { |
235 int32_t imm = i.InputOperand(1).immediate(); | 235 int32_t imm = i.InputOperand(1).immediate(); |
236 __ sra(i.OutputRegister(), i.InputRegister(0), imm); | 236 __ sra(i.OutputRegister(), i.InputRegister(0), imm); |
237 } | 237 } |
238 break; | 238 break; |
239 case kMipsRor: | 239 case kMipsRor: |
240 __ Ror(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); | 240 __ Ror(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); |
241 break; | 241 break; |
242 case kMipsTst: | 242 case kMipsTst: |
243 // Psuedo-instruction used for tst/branch. | 243 // Psuedo-instruction used for tst/branch. |
paul.l...
2014/11/04 19:04:27
Suggest adding "No opcode emitted here." to commen
dusmil.imgtec
2014/11/04 19:46:11
Done.
| |
244 __ And(kCompareReg, i.InputRegister(0), i.InputOperand(1)); | |
245 break; | |
246 case kMipsCmp: | 244 case kMipsCmp: |
247 // Psuedo-instruction used for cmp/branch. No opcode emitted here. | 245 // Psuedo-instruction used for cmp/branch. No opcode emitted here. |
248 break; | 246 break; |
249 case kMipsMov: | 247 case kMipsMov: |
250 // TODO(plind): Should we combine mov/li like this, or use separate instr? | 248 // TODO(plind): Should we combine mov/li like this, or use separate instr? |
251 // - Also see x64 ASSEMBLE_BINOP & RegisterOrOperandType | 249 // - Also see x64 ASSEMBLE_BINOP & RegisterOrOperandType |
252 if (HasRegisterInput(instr, 0)) { | 250 if (HasRegisterInput(instr, 0)) { |
253 __ mov(i.OutputRegister(), i.InputRegister(0)); | 251 __ mov(i.OutputRegister(), i.InputRegister(0)); |
254 } else { | 252 } else { |
255 __ li(i.OutputRegister(), i.InputOperand(0)); | 253 __ li(i.OutputRegister(), i.InputOperand(0)); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 // MIPS does not have condition code flags, so compare and branch are | 409 // MIPS does not have condition code flags, so compare and branch are |
412 // implemented differently than on the other arch's. The compare operations | 410 // implemented differently than on the other arch's. The compare operations |
413 // emit mips psuedo-instructions, which are handled here by branch | 411 // emit mips psuedo-instructions, which are handled here by branch |
414 // instructions that do the actual comparison. Essential that the input | 412 // instructions that do the actual comparison. Essential that the input |
415 // registers to compare psuedo-op are not modified before this branch op, as | 413 // registers to compare psuedo-op are not modified before this branch op, as |
416 // they are tested here. | 414 // they are tested here. |
417 // TODO(plind): Add CHECK() to ensure that test/cmp and this branch were | 415 // TODO(plind): Add CHECK() to ensure that test/cmp and this branch were |
418 // not separated by other instructions. | 416 // not separated by other instructions. |
419 | 417 |
420 if (instr->arch_opcode() == kMipsTst) { | 418 if (instr->arch_opcode() == kMipsTst) { |
421 // The kMipsTst psuedo-instruction emits And to 'kCompareReg' register. | |
422 switch (condition) { | 419 switch (condition) { |
423 case kNotEqual: | 420 case kNotEqual: |
424 cc = ne; | 421 cc = ne; |
425 break; | 422 break; |
426 case kEqual: | 423 case kEqual: |
427 cc = eq; | 424 cc = eq; |
428 break; | 425 break; |
429 default: | 426 default: |
430 UNSUPPORTED_COND(kMipsTst, condition); | 427 UNSUPPORTED_COND(kMipsTst, condition); |
431 break; | 428 break; |
432 } | 429 } |
433 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); | 430 __ And(at, i.InputRegister(0), i.InputOperand(1)); |
431 __ Branch(tlabel, cc, at, Operand(zero_reg)); | |
434 | 432 |
435 } else if (instr->arch_opcode() == kMipsAddOvf || | 433 } else if (instr->arch_opcode() == kMipsAddOvf || |
436 instr->arch_opcode() == kMipsSubOvf) { | 434 instr->arch_opcode() == kMipsSubOvf) { |
437 // kMipsAddOvf, SubOvf emit negative result to 'kCompareReg' on overflow. | 435 // kMipsAddOvf, SubOvf emit negative result to 'kCompareReg' on overflow. |
438 switch (condition) { | 436 switch (condition) { |
439 case kOverflow: | 437 case kOverflow: |
440 cc = lt; | 438 cc = lt; |
441 break; | 439 break; |
442 case kNotOverflow: | 440 case kNotOverflow: |
443 cc = ge; | 441 cc = ge; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 // implemented differently than on the other arch's. The compare operations | 548 // implemented differently than on the other arch's. The compare operations |
551 // emit mips psuedo-instructions, which are checked and handled here. | 549 // emit mips psuedo-instructions, which are checked and handled here. |
552 | 550 |
553 // For materializations, we use delay slot to set the result true, and | 551 // For materializations, we use delay slot to set the result true, and |
554 // in the false case, where we fall thru the branch, we reset the result | 552 // in the false case, where we fall thru the branch, we reset the result |
555 // false. | 553 // false. |
556 | 554 |
557 // TODO(plind): Add CHECK() to ensure that test/cmp and this branch were | 555 // TODO(plind): Add CHECK() to ensure that test/cmp and this branch were |
558 // not separated by other instructions. | 556 // not separated by other instructions. |
559 if (instr->arch_opcode() == kMipsTst) { | 557 if (instr->arch_opcode() == kMipsTst) { |
560 // The kMipsTst psuedo-instruction emits And to 'kCompareReg' register. | |
561 switch (condition) { | 558 switch (condition) { |
562 case kNotEqual: | 559 case kNotEqual: |
563 cc = ne; | 560 cc = ne; |
564 break; | 561 break; |
565 case kEqual: | 562 case kEqual: |
566 cc = eq; | 563 cc = eq; |
567 break; | 564 break; |
568 default: | 565 default: |
569 UNSUPPORTED_COND(kMipsTst, condition); | 566 UNSUPPORTED_COND(kMipsTst, condition); |
570 break; | 567 break; |
571 } | 568 } |
572 __ Branch(USE_DELAY_SLOT, &done, cc, kCompareReg, Operand(zero_reg)); | 569 __ And(at, i.InputRegister(0), i.InputOperand(1)); |
570 __ Branch(USE_DELAY_SLOT, &done, cc, at, Operand(zero_reg)); | |
573 __ li(result, Operand(1)); // In delay slot. | 571 __ li(result, Operand(1)); // In delay slot. |
574 | 572 |
575 } else if (instr->arch_opcode() == kMipsAddOvf || | 573 } else if (instr->arch_opcode() == kMipsAddOvf || |
576 instr->arch_opcode() == kMipsSubOvf) { | 574 instr->arch_opcode() == kMipsSubOvf) { |
577 // kMipsAddOvf, SubOvf emits negative result to 'kCompareReg' on overflow. | 575 // kMipsAddOvf, SubOvf emits negative result to 'kCompareReg' on overflow. |
578 switch (condition) { | 576 switch (condition) { |
579 case kOverflow: | 577 case kOverflow: |
580 cc = lt; | 578 cc = lt; |
581 break; | 579 break; |
582 case kNotOverflow: | 580 case kNotOverflow: |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 } | 960 } |
963 } | 961 } |
964 MarkLazyDeoptSite(); | 962 MarkLazyDeoptSite(); |
965 } | 963 } |
966 | 964 |
967 #undef __ | 965 #undef __ |
968 | 966 |
969 } // namespace compiler | 967 } // namespace compiler |
970 } // namespace internal | 968 } // namespace internal |
971 } // namespace v8 | 969 } // namespace v8 |
OLD | NEW |