OLD | NEW |
---|---|
1 // | 1 // |
2 // The Subzero Code Generator | 2 // The Subzero Code Generator |
3 // | 3 // |
4 // This file is distributed under the University of Illinois Open Source | 4 // This file is distributed under the University of Illinois Open Source |
5 // License. See LICENSE.TXT for details. | 5 // License. See LICENSE.TXT for details. |
6 // | 6 // |
7 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
8 /// | 8 /// |
9 /// \file | 9 /// \file |
10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost | 10 /// \brief Implements the TargetLoweringMIPS32 class, which consists almost |
(...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2546 lowerInt64Arithmetic(Instr, Instr->getDest(), Src0, Src1); | 2546 lowerInt64Arithmetic(Instr, Instr->getDest(), Src0, Src1); |
2547 return; | 2547 return; |
2548 } | 2548 } |
2549 if (isVectorType(Dest->getType())) { | 2549 if (isVectorType(Dest->getType())) { |
2550 llvm::report_fatal_error("Arithmetic: Destination type is vector"); | 2550 llvm::report_fatal_error("Arithmetic: Destination type is vector"); |
2551 return; | 2551 return; |
2552 } | 2552 } |
2553 | 2553 |
2554 Variable *T = makeReg(Dest->getType()); | 2554 Variable *T = makeReg(Dest->getType()); |
2555 Variable *Src0R = legalizeToReg(Src0); | 2555 Variable *Src0R = legalizeToReg(Src0); |
2556 Variable *Src1R = legalizeToReg(Src1); | 2556 Variable *Src1R = nullptr; |
2557 uint32_t Value = 0; | |
2558 auto *Const32 = llvm::dyn_cast<ConstantInteger32>(Src1); | |
Jim Stichnoth
2016/11/04 13:18:48
Can you move the definition of Const32 into the sw
jaydeep.patil
2016/11/07 03:55:11
Done.
| |
2559 | |
2560 switch (Instr->getOp()) { | |
2561 case InstArithmetic::Add: | |
2562 case InstArithmetic::And: | |
2563 case InstArithmetic::Or: | |
2564 case InstArithmetic::Xor: | |
2565 case InstArithmetic::Sub: | |
2566 case InstArithmetic::Shl: | |
2567 case InstArithmetic::Lshr: | |
2568 case InstArithmetic::Ashr: | |
2569 if (Const32 != nullptr && isInt<16>(int32_t(Const32->getValue()))) { | |
2570 Value = Const32->getValue(); | |
2571 } else { | |
2572 Src1R = legalizeToReg(Src1); | |
2573 } | |
2574 break; | |
2575 default: | |
2576 Src1R = legalizeToReg(Src1); | |
2577 break; | |
2578 } | |
2557 constexpr uint32_t DivideByZeroTrapCode = 7; | 2579 constexpr uint32_t DivideByZeroTrapCode = 7; |
2558 | 2580 |
2559 switch (Instr->getOp()) { | 2581 switch (Instr->getOp()) { |
2560 case InstArithmetic::_num: | 2582 case InstArithmetic::_num: |
2561 break; | 2583 break; |
2562 case InstArithmetic::Add: | 2584 case InstArithmetic::Add: |
2563 _addu(T, Src0R, Src1R); | 2585 if (Src1R == nullptr) { |
Jim Stichnoth
2016/11/04 13:18:47
Instead of the "(Src1R == nullptr)" idiom, I think
jaydeep.patil
2016/11/07 03:55:11
Done.
| |
2586 _addiu(T, Src0R, Value); | |
2587 } else { | |
2588 _addu(T, Src0R, Src1R); | |
2589 } | |
2564 _mov(Dest, T); | 2590 _mov(Dest, T); |
2565 return; | 2591 return; |
2566 case InstArithmetic::And: | 2592 case InstArithmetic::And: |
2567 _and(T, Src0R, Src1R); | 2593 if (Src1R == nullptr) { |
2594 _andi(T, Src0R, Value); | |
2595 } else { | |
2596 _and(T, Src0R, Src1R); | |
2597 } | |
2568 _mov(Dest, T); | 2598 _mov(Dest, T); |
2569 return; | 2599 return; |
2570 case InstArithmetic::Or: | 2600 case InstArithmetic::Or: |
2571 _or(T, Src0R, Src1R); | 2601 if (Src1R == nullptr) { |
2602 _ori(T, Src0R, Value); | |
2603 } else { | |
2604 _or(T, Src0R, Src1R); | |
2605 } | |
2572 _mov(Dest, T); | 2606 _mov(Dest, T); |
2573 return; | 2607 return; |
2574 case InstArithmetic::Xor: | 2608 case InstArithmetic::Xor: |
2575 _xor(T, Src0R, Src1R); | 2609 if (Src1R == nullptr) { |
2610 _xori(T, Src0R, Value); | |
2611 } else { | |
2612 _xor(T, Src0R, Src1R); | |
2613 } | |
2576 _mov(Dest, T); | 2614 _mov(Dest, T); |
2577 return; | 2615 return; |
2578 case InstArithmetic::Sub: | 2616 case InstArithmetic::Sub: |
2579 _subu(T, Src0R, Src1R); | 2617 if (Src1R == nullptr) { |
2618 _addiu(T, Src0R, -Value); | |
2619 } else { | |
2620 _subu(T, Src0R, Src1R); | |
2621 } | |
2580 _mov(Dest, T); | 2622 _mov(Dest, T); |
2581 return; | 2623 return; |
2582 case InstArithmetic::Mul: { | 2624 case InstArithmetic::Mul: { |
2583 _mul(T, Src0R, Src1R); | 2625 _mul(T, Src0R, Src1R); |
2584 _mov(Dest, T); | 2626 _mov(Dest, T); |
2585 return; | 2627 return; |
2586 } | 2628 } |
2587 case InstArithmetic::Shl: { | 2629 case InstArithmetic::Shl: { |
2588 _sllv(T, Src0R, Src1R); | 2630 if (Src1R == nullptr) { |
2631 _sll(T, Src0R, Value); | |
2632 } else { | |
2633 _sllv(T, Src0R, Src1R); | |
2634 } | |
2589 _mov(Dest, T); | 2635 _mov(Dest, T); |
2590 return; | 2636 return; |
2591 } | 2637 } |
2592 case InstArithmetic::Lshr: { | 2638 case InstArithmetic::Lshr: { |
2593 auto *T0R = Src0R; | 2639 auto *T0R = Src0R; |
2594 auto *T1R = Src1R; | 2640 auto *T1R = Src1R; |
2595 if (Dest->getType() != IceType_i32) { | 2641 if (Dest->getType() != IceType_i32) { |
2596 T0R = makeReg(IceType_i32); | 2642 T0R = makeReg(IceType_i32); |
2597 lowerCast(InstCast::create(Func, InstCast::Zext, T0R, Src0R)); | 2643 lowerCast(InstCast::create(Func, InstCast::Zext, T0R, Src0R)); |
2598 T1R = makeReg(IceType_i32); | 2644 if (Src1R != nullptr) { |
2599 lowerCast(InstCast::create(Func, InstCast::Zext, T1R, Src1R)); | 2645 T1R = makeReg(IceType_i32); |
2646 lowerCast(InstCast::create(Func, InstCast::Zext, T1R, Src1R)); | |
2647 } | |
2600 } | 2648 } |
2601 _srlv(T, T0R, T1R); | 2649 if (Src1R == nullptr) { |
2650 _srl(T, T0R, Value); | |
2651 } else { | |
2652 _srlv(T, T0R, T1R); | |
2653 } | |
2602 _mov(Dest, T); | 2654 _mov(Dest, T); |
2603 return; | 2655 return; |
2604 } | 2656 } |
2605 case InstArithmetic::Ashr: { | 2657 case InstArithmetic::Ashr: { |
2606 _srav(T, Src0R, Src1R); | 2658 if (Src1R == nullptr) { |
2659 _sra(T, Src0R, Value); | |
2660 } else { | |
2661 _srav(T, Src0R, Src1R); | |
2662 } | |
2607 _mov(Dest, T); | 2663 _mov(Dest, T); |
2608 return; | 2664 return; |
2609 } | 2665 } |
2610 case InstArithmetic::Udiv: { | 2666 case InstArithmetic::Udiv: { |
2611 auto *T_Zero = I32Reg(RegMIPS32::Reg_ZERO); | 2667 auto *T_Zero = I32Reg(RegMIPS32::Reg_ZERO); |
2612 auto *T0R = Src0R; | 2668 auto *T0R = Src0R; |
2613 auto *T1R = Src1R; | 2669 auto *T1R = Src1R; |
2614 if (Dest->getType() != IceType_i32) { | 2670 if (Dest->getType() != IceType_i32) { |
2615 T0R = makeReg(IceType_i32); | 2671 T0R = makeReg(IceType_i32); |
2616 lowerCast(InstCast::create(Func, InstCast::Zext, T0R, Src0R)); | 2672 lowerCast(InstCast::create(Func, InstCast::Zext, T0R, Src0R)); |
(...skipping 2752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5369 Str << "\t.set\t" | 5425 Str << "\t.set\t" |
5370 << "noat\n"; | 5426 << "noat\n"; |
5371 } | 5427 } |
5372 | 5428 |
5373 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; | 5429 SmallBitVector TargetMIPS32::TypeToRegisterSet[RCMIPS32_NUM]; |
5374 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; | 5430 SmallBitVector TargetMIPS32::TypeToRegisterSetUnfiltered[RCMIPS32_NUM]; |
5375 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; | 5431 SmallBitVector TargetMIPS32::RegisterAliases[RegMIPS32::Reg_NUM]; |
5376 | 5432 |
5377 } // end of namespace MIPS32 | 5433 } // end of namespace MIPS32 |
5378 } // end of namespace Ice | 5434 } // end of namespace Ice |
OLD | NEW |