1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  * vim: set ts=8 sts=2 et sw=2 tw=80:
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_x86_shared_Lowering_x86_shared_h
8 #define jit_x86_shared_Lowering_x86_shared_h
9 
10 #include "jit/shared/Lowering-shared.h"
11 
12 namespace js {
13 namespace jit {
14 
15 class LIRGeneratorX86Shared : public LIRGeneratorShared {
16  protected:
LIRGeneratorX86Shared(MIRGenerator * gen,MIRGraph & graph,LIRGraph & lirGraph)17   LIRGeneratorX86Shared(MIRGenerator* gen, MIRGraph& graph, LIRGraph& lirGraph)
18       : LIRGeneratorShared(gen, graph, lirGraph) {}
19 
20   LTableSwitch* newLTableSwitch(const LAllocation& in,
21                                 const LDefinition& inputCopy,
22                                 MTableSwitch* ins);
23   LTableSwitchV* newLTableSwitchV(MTableSwitch* ins);
24 
25   void lowerForShift(LInstructionHelper<1, 2, 0>* ins, MDefinition* mir,
26                      MDefinition* lhs, MDefinition* rhs);
27   void lowerForALU(LInstructionHelper<1, 1, 0>* ins, MDefinition* mir,
28                    MDefinition* input);
29   void lowerForALU(LInstructionHelper<1, 2, 0>* ins, MDefinition* mir,
30                    MDefinition* lhs, MDefinition* rhs);
31 
32   template <size_t Temps>
33   void lowerForShiftInt64(
34       LInstructionHelper<INT64_PIECES, INT64_PIECES + 1, Temps>* ins,
35       MDefinition* mir, MDefinition* lhs, MDefinition* rhs);
36 
37   void lowerForCompareI64AndBranch(MTest* mir, MCompare* comp, JSOp op,
38                                    MDefinition* left, MDefinition* right,
39                                    MBasicBlock* ifTrue, MBasicBlock* ifFalse);
40   template <size_t Temps>
41   void lowerForFPU(LInstructionHelper<1, 2, Temps>* ins, MDefinition* mir,
42                    MDefinition* lhs, MDefinition* rhs);
43   void lowerForBitAndAndBranch(LBitAndAndBranch* baab, MInstruction* mir,
44                                MDefinition* lhs, MDefinition* rhs);
45   void lowerNegI(MInstruction* ins, MDefinition* input);
46   void lowerNegI64(MInstruction* ins, MDefinition* input);
47   void lowerMulI(MMul* mul, MDefinition* lhs, MDefinition* rhs);
48   void lowerDivI(MDiv* div);
49   void lowerModI(MMod* mod);
50   void lowerUDiv(MDiv* div);
51   void lowerUMod(MMod* mod);
52   void lowerUrshD(MUrsh* mir);
53   void lowerPowOfTwoI(MPow* mir);
54   void lowerWasmSelectI(MWasmSelect* select);
55   void lowerWasmSelectI64(MWasmSelect* select);
56   void lowerBigIntLsh(MBigIntLsh* ins);
57   void lowerBigIntRsh(MBigIntRsh* ins);
58   void lowerWasmBuiltinTruncateToInt32(MWasmBuiltinTruncateToInt32* ins);
59   void lowerTruncateDToInt32(MTruncateToInt32* ins);
60   void lowerTruncateFToInt32(MTruncateToInt32* ins);
61   void lowerCompareExchangeTypedArrayElement(
62       MCompareExchangeTypedArrayElement* ins, bool useI386ByteRegisters);
63   void lowerAtomicExchangeTypedArrayElement(
64       MAtomicExchangeTypedArrayElement* ins, bool useI386ByteRegisters);
65   void lowerAtomicTypedArrayElementBinop(MAtomicTypedArrayElementBinop* ins,
66                                          bool useI386ByteRegisters);
67 
68 #ifdef ENABLE_WASM_SIMD
isThreeOpAllowed()69   bool isThreeOpAllowed() { return Assembler::HasAVX(); }
70   bool canFoldReduceSimd128AndBranch(wasm::SimdOp op);
71   bool canEmitWasmReduceSimd128AtUses(MWasmReduceSimd128* ins);
72 #endif
73 };
74 
75 }  // namespace jit
76 }  // namespace js
77 
78 #endif /* jit_x86_shared_Lowering_x86_shared_h */
79