| 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_arm_CodeGenerator_arm_h |
| 8 |
#define jit_arm_CodeGenerator_arm_h |
| 9 |
|
| 10 |
#include "jit/arm/Assembler-arm.h" |
| 11 |
#include "jit/shared/CodeGenerator-shared.h" |
| 12 |
#include "js/ScalarType.h" // js::Scalar::Type |
| 13 |
|
| 14 |
namespace js { |
| 15 |
namespace jit { |
| 16 |
|
| 17 |
class CodeGeneratorARM; |
| 18 |
class OutOfLineTableSwitch; |
| 19 |
|
| 20 |
using OutOfLineWasmTruncateCheck = |
| 21 |
OutOfLineWasmTruncateCheckBase<CodeGeneratorARM>; |
| 22 |
|
| 23 |
class CodeGeneratorARM : public CodeGeneratorShared { |
| 24 |
friend class MoveResolverARM; |
| 25 |
|
| 26 |
protected: |
| 27 |
CodeGeneratorARM(MIRGenerator* gen, LIRGraph* graph, MacroAssembler* masm, |
| 28 |
const wasm::CodeMetadata* wasmCodeMeta); |
| 29 |
|
| 30 |
NonAssertingLabel deoptLabel_; |
| 31 |
|
| 32 |
MoveOperand toMoveOperand(LAllocation a) const; |
| 33 |
|
| 34 |
void bailoutIf(Assembler::Condition condition, LSnapshot* snapshot); |
| 35 |
void bailoutFrom(Label* label, LSnapshot* snapshot); |
| 36 |
void bailout(LSnapshot* snapshot); |
| 37 |
|
| 38 |
template <typename T1, typename T2> |
| 39 |
void bailoutCmpPtr(Assembler::Condition c, T1 lhs, T2 rhs, |
| 40 |
LSnapshot* snapshot) { |
| 41 |
masm.cmpPtr(lhs, rhs); |
| 42 |
bailoutIf(c, snapshot); |
| 43 |
} |
| 44 |
void bailoutTestPtr(Assembler::Condition c, Register lhs, Register rhs, |
| 45 |
LSnapshot* snapshot) { |
| 46 |
masm.testPtr(lhs, rhs); |
| 47 |
bailoutIf(c, snapshot); |
| 48 |
} |
| 49 |
template <typename T1, typename T2> |
| 50 |
void bailoutCmp32(Assembler::Condition c, T1 lhs, T2 rhs, |
| 51 |
LSnapshot* snapshot) { |
| 52 |
masm.cmp32(lhs, rhs); |
| 53 |
bailoutIf(c, snapshot); |
| 54 |
} |
| 55 |
template <typename T1, typename T2> |
| 56 |
void bailoutTest32(Assembler::Condition c, T1 lhs, T2 rhs, |
| 57 |
LSnapshot* snapshot) { |
| 58 |
masm.test32(lhs, rhs); |
| 59 |
bailoutIf(c, snapshot); |
| 60 |
} |
| 61 |
void bailoutIfFalseBool(Register reg, LSnapshot* snapshot) { |
| 62 |
masm.test32(reg, Imm32(0xFF)); |
| 63 |
bailoutIf(Assembler::Zero, snapshot); |
| 64 |
} |
| 65 |
|
| 66 |
template <class T> |
| 67 |
void generateUDivModZeroCheck(Register rhs, Register output, Label* done, |
| 68 |
LSnapshot* snapshot, T* mir); |
| 69 |
|
| 70 |
bool generateOutOfLineCode(); |
| 71 |
|
| 72 |
// Emits a branch that directs control flow to the true block if |cond| is |
| 73 |
// true, and the false block if |cond| is false. |
| 74 |
void emitBranch(Assembler::Condition cond, MBasicBlock* ifTrue, |
| 75 |
MBasicBlock* ifFalse); |
| 76 |
|
| 77 |
void emitTableSwitchDispatch(MTableSwitch* mir, Register index, |
| 78 |
Register base); |
| 79 |
|
| 80 |
void emitBigIntPtrDiv(LBigIntPtrDiv* ins, Register dividend, Register divisor, |
| 81 |
Register output); |
| 82 |
void emitBigIntPtrMod(LBigIntPtrMod* ins, Register dividend, Register divisor, |
| 83 |
Register output); |
| 84 |
|
| 85 |
template <typename T> |
| 86 |
void emitWasmLoad(T* ins); |
| 87 |
template <typename T> |
| 88 |
void emitWasmUnalignedLoad(T* ins); |
| 89 |
template <typename T> |
| 90 |
void emitWasmStore(T* ins); |
| 91 |
template <typename T> |
| 92 |
void emitWasmUnalignedStore(T* ins); |
| 93 |
|
| 94 |
Register64 ToOperandOrRegister64(const LInt64Allocation& input); |
| 95 |
|
| 96 |
void divICommon(MDiv* mir, Register lhs, Register rhs, Register output, |
| 97 |
LSnapshot* snapshot, Label& done); |
| 98 |
void modICommon(MMod* mir, Register lhs, Register rhs, Register output, |
| 99 |
LSnapshot* snapshot, Label& done); |
| 100 |
|
| 101 |
void generateInvalidateEpilogue(); |
| 102 |
|
| 103 |
// Generating a result. |
| 104 |
template <typename S, typename T> |
| 105 |
void atomicBinopToTypedIntArray(AtomicOp op, Scalar::Type arrayType, |
| 106 |
const S& value, const T& mem, |
| 107 |
Register flagTemp, Register outTemp, |
| 108 |
AnyRegister output); |
| 109 |
|
| 110 |
// Generating no result. |
| 111 |
template <typename S, typename T> |
| 112 |
void atomicBinopToTypedIntArray(AtomicOp op, Scalar::Type arrayType, |
| 113 |
const S& value, const T& mem, |
| 114 |
Register flagTemp); |
| 115 |
|
| 116 |
public: |
| 117 |
void emitBailoutOOL(LSnapshot* snapshot); |
| 118 |
|
| 119 |
void visitOutOfLineTableSwitch(OutOfLineTableSwitch* ool); |
| 120 |
void visitOutOfLineWasmTruncateCheck(OutOfLineWasmTruncateCheck* ool); |
| 121 |
}; |
| 122 |
|
| 123 |
using CodeGeneratorSpecific = CodeGeneratorARM; |
| 124 |
|
| 125 |
} // namespace jit |
| 126 |
} // namespace js |
| 127 |
|
| 128 |
#endif /* jit_arm_CodeGenerator_arm_h */ |