Debian Codegraph @

js/src/jit/mips-shared/CodeGenerator-mips-shared.h

raw
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_mips_shared_CodeGenerator_mips_shared_h
8 #define jit_mips_shared_CodeGenerator_mips_shared_h
9
10 #include "jit/shared/CodeGenerator-shared.h"
11
12 namespace js {
13 namespace jit {
14
15 class CodeGeneratorMIPSShared;
16 class OutOfLineTableSwitch;
17
18 using OutOfLineWasmTruncateCheck =
19 OutOfLineWasmTruncateCheckBase<CodeGeneratorMIPSShared>;
20
21 class CodeGeneratorMIPSShared : public CodeGeneratorShared {
22 friend class MoveResolverMIPS;
23
24 protected:
25 CodeGeneratorMIPSShared(MIRGenerator* gen, LIRGraph* graph,
26 MacroAssembler* masm,
27 const wasm::CodeMetadata* wasmCodeMeta);
28
29 NonAssertingLabel deoptLabel_;
30
31 Operand ToOperand(const LAllocation& a);
32 Operand ToOperand(const LAllocation* a);
33 Operand ToOperand(const LDefinition* def);
34
35 Operand ToOperandOrRegister64(const LInt64Allocation& input);
36
37 MoveOperand toMoveOperand(LAllocation a) const;
38
39 template <typename T1, typename T2>
40 void bailoutCmp32(Assembler::Condition c, T1 lhs, T2 rhs,
41 LSnapshot* snapshot) {
42 Label bail;
43 masm.branch32(c, lhs, rhs, &bail);
44 bailoutFrom(&bail, snapshot);
45 }
46 template <typename T1, typename T2>
47 void bailoutTest32(Assembler::Condition c, T1 lhs, T2 rhs,
48 LSnapshot* snapshot) {
49 Label bail;
50 masm.branchTest32(c, lhs, rhs, &bail);
51 bailoutFrom(&bail, snapshot);
52 }
53 template <typename T1, typename T2>
54 void bailoutCmpPtr(Assembler::Condition c, T1 lhs, T2 rhs,
55 LSnapshot* snapshot) {
56 Label bail;
57 masm.branchPtr(c, lhs, rhs, &bail);
58 bailoutFrom(&bail, snapshot);
59 }
60 void bailoutTestPtr(Assembler::Condition c, Register lhs, Register rhs,
61 LSnapshot* snapshot) {
62 Label bail;
63 masm.branchTestPtr(c, lhs, rhs, &bail);
64 bailoutFrom(&bail, snapshot);
65 }
66 void bailoutIfFalseBool(Register reg, LSnapshot* snapshot) {
67 Label bail;
68 masm.branchTest32(Assembler::Zero, reg, Imm32(0xFF), &bail);
69 bailoutFrom(&bail, snapshot);
70 }
71
72 void bailoutFrom(Label* label, LSnapshot* snapshot);
73 void bailout(LSnapshot* snapshot);
74
75 bool generateOutOfLineCode();
76
77 template <typename T>
78 void branchToBlock(Register lhs, T rhs, MBasicBlock* mir,
79 Assembler::Condition cond) {
80 masm.ma_b(lhs, rhs, skipTrivialBlocks(mir)->lir()->label(), cond);
81 }
82 void branchToBlock(Assembler::FloatFormat fmt, FloatRegister lhs,
83 FloatRegister rhs, MBasicBlock* mir,
84 Assembler::DoubleCondition cond);
85
86 // Emits a branch that directs control flow to the true block if |cond| is
87 // true, and the false block if |cond| is false.
88 template <typename T>
89 void emitBranch(Register lhs, T rhs, Assembler::Condition cond,
90 MBasicBlock* mirTrue, MBasicBlock* mirFalse) {
91 if (isNextBlock(mirFalse->lir())) {
92 branchToBlock(lhs, rhs, mirTrue, cond);
93 } else {
94 branchToBlock(lhs, rhs, mirFalse, Assembler::InvertCondition(cond));
95 jumpToBlock(mirTrue);
96 }
97 }
98
99 void emitTableSwitchDispatch(MTableSwitch* mir, Register index,
100 Register base);
101
102 template <typename T>
103 void emitWasmLoad(T* ins);
104 template <typename T>
105 void emitWasmStore(T* ins);
106
107 void generateInvalidateEpilogue();
108
109 // Generating a result.
110 template <typename S, typename T>
111 void atomicBinopToTypedIntArray(AtomicOp op, Scalar::Type arrayType,
112 const S& value, const T& mem,
113 Register flagTemp, Register outTemp,
114 Register valueTemp, Register offsetTemp,
115 Register maskTemp, AnyRegister output);
116
117 // Generating no result.
118 template <typename S, typename T>
119 void atomicBinopToTypedIntArray(AtomicOp op, Scalar::Type arrayType,
120 const S& value, const T& mem,
121 Register flagTemp, Register valueTemp,
122 Register offsetTemp, Register maskTemp);
123
124 public:
125 // Out of line visitors.
126 void visitOutOfLineTableSwitch(OutOfLineTableSwitch* ool);
127 void visitOutOfLineWasmTruncateCheck(OutOfLineWasmTruncateCheck* ool);
128 };
129
130 } // namespace jit
131 } // namespace js
132
133 #endif /* jit_mips_shared_CodeGenerator_mips_shared_h */