|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_mips_Lowering_mips_h |
|
8 #define jit_mips_Lowering_mips_h |
|
9 |
|
10 #include "jit/shared/Lowering-shared.h" |
|
11 |
|
12 namespace js { |
|
13 namespace jit { |
|
14 |
|
15 class LIRGeneratorMIPS : public LIRGeneratorShared |
|
16 { |
|
17 protected: |
|
18 LIRGeneratorMIPS(MIRGenerator *gen, MIRGraph &graph, LIRGraph &lirGraph) |
|
19 : LIRGeneratorShared(gen, graph, lirGraph) |
|
20 { } |
|
21 |
|
22 protected: |
|
23 // Adds a box input to an instruction, setting operand |n| to the type and |
|
24 // |n+1| to the payload. |
|
25 bool useBox(LInstruction *lir, size_t n, MDefinition *mir, |
|
26 LUse::Policy policy = LUse::REGISTER, bool useAtStart = false); |
|
27 bool useBoxFixed(LInstruction *lir, size_t n, MDefinition *mir, Register reg1, Register reg2); |
|
28 |
|
29 // x86 has constraints on what registers can be formatted for 1-byte |
|
30 // stores and loads; on MIPS all registers are okay. |
|
31 LAllocation useByteOpRegister(MDefinition *mir); |
|
32 LAllocation useByteOpRegisterOrNonDoubleConstant(MDefinition *mir); |
|
33 |
|
34 inline LDefinition tempToUnbox() { |
|
35 return LDefinition::BogusTemp(); |
|
36 } |
|
37 |
|
38 // MIPS has a scratch register, so no need for another temp for dispatch |
|
39 // ICs. |
|
40 LDefinition tempForDispatchCache(MIRType outputType = MIRType_None) { |
|
41 return LDefinition::BogusTemp(); |
|
42 } |
|
43 |
|
44 void lowerUntypedPhiInput(MPhi *phi, uint32_t inputPosition, LBlock *block, size_t lirIndex); |
|
45 bool defineUntypedPhi(MPhi *phi, size_t lirIndex); |
|
46 bool lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, |
|
47 MDefinition *rhs); |
|
48 bool lowerUrshD(MUrsh *mir); |
|
49 |
|
50 bool lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, |
|
51 MDefinition *input); |
|
52 bool lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, |
|
53 MDefinition *lhs, MDefinition *rhs); |
|
54 |
|
55 bool lowerForFPU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, |
|
56 MDefinition *src); |
|
57 bool lowerForFPU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, |
|
58 MDefinition *lhs, MDefinition *rhs); |
|
59 bool lowerForBitAndAndBranch(LBitAndAndBranch *baab, MInstruction *mir, |
|
60 MDefinition *lhs, MDefinition *rhs); |
|
61 bool lowerConstantDouble(double d, MInstruction *ins); |
|
62 bool lowerConstantFloat32(float d, MInstruction *ins); |
|
63 bool lowerTruncateDToInt32(MTruncateToInt32 *ins); |
|
64 bool lowerTruncateFToInt32(MTruncateToInt32 *ins); |
|
65 bool lowerDivI(MDiv *div); |
|
66 bool lowerModI(MMod *mod); |
|
67 bool lowerMulI(MMul *mul, MDefinition *lhs, MDefinition *rhs); |
|
68 bool lowerUDiv(MDiv *div); |
|
69 bool lowerUMod(MMod *mod); |
|
70 bool visitPowHalf(MPowHalf *ins); |
|
71 bool visitAsmJSNeg(MAsmJSNeg *ins); |
|
72 |
|
73 LTableSwitch *newLTableSwitch(const LAllocation &in, const LDefinition &inputCopy, |
|
74 MTableSwitch *ins); |
|
75 LTableSwitchV *newLTableSwitchV(MTableSwitch *ins); |
|
76 |
|
77 public: |
|
78 bool visitConstant(MConstant *ins); |
|
79 bool visitBox(MBox *box); |
|
80 bool visitUnbox(MUnbox *unbox); |
|
81 bool visitReturn(MReturn *ret); |
|
82 bool lowerPhi(MPhi *phi); |
|
83 bool visitGuardShape(MGuardShape *ins); |
|
84 bool visitGuardObjectType(MGuardObjectType *ins); |
|
85 bool visitAsmJSUnsignedToDouble(MAsmJSUnsignedToDouble *ins); |
|
86 bool visitAsmJSUnsignedToFloat32(MAsmJSUnsignedToFloat32 *ins); |
|
87 bool visitAsmJSLoadHeap(MAsmJSLoadHeap *ins); |
|
88 bool visitAsmJSStoreHeap(MAsmJSStoreHeap *ins); |
|
89 bool visitAsmJSLoadFuncPtr(MAsmJSLoadFuncPtr *ins); |
|
90 bool visitStoreTypedArrayElementStatic(MStoreTypedArrayElementStatic *ins); |
|
91 bool visitForkJoinGetSlice(MForkJoinGetSlice *ins); |
|
92 |
|
93 static bool allowFloat32Optimizations() { |
|
94 return true; |
|
95 } |
|
96 }; |
|
97 |
|
98 typedef LIRGeneratorMIPS LIRGeneratorSpecific; |
|
99 |
|
100 } // namespace jit |
|
101 } // namespace js |
|
102 |
|
103 #endif /* jit_mips_Lowering_mips_h */ |