Debian Codegraph @

js/src/jit/Lowering.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_Lowering_h
8 #define jit_Lowering_h
9
10 // This file declares the structures that are used for attaching LIR to a
11 // MIRGraph.
12
13 #include "jit/LIR.h"
14 #if defined(JS_CODEGEN_X86)
15 # include "jit/x86/Lowering-x86.h"
16 #elif defined(JS_CODEGEN_X64)
17 # include "jit/x64/Lowering-x64.h"
18 #elif defined(JS_CODEGEN_ARM)
19 # include "jit/arm/Lowering-arm.h"
20 #elif defined(JS_CODEGEN_ARM64)
21 # include "jit/arm64/Lowering-arm64.h"
22 #elif defined(JS_CODEGEN_MIPS64)
23 # include "jit/mips64/Lowering-mips64.h"
24 #elif defined(JS_CODEGEN_LOONG64)
25 # include "jit/loong64/Lowering-loong64.h"
26 #elif defined(JS_CODEGEN_RISCV64)
27 # include "jit/riscv64/Lowering-riscv64.h"
28 #elif defined(JS_CODEGEN_WASM32)
29 # include "jit/wasm32/Lowering-wasm32.h"
30 #elif defined(JS_CODEGEN_NONE)
31 # include "jit/none/Lowering-none.h"
32 #else
33 # error "Unknown architecture!"
34 #endif
35
36 namespace js {
37 namespace jit {
38
39 class LIRGenerator final : public LIRGeneratorSpecific {
40 void updateResumeState(MInstruction* ins);
41 void updateResumeState(MBasicBlock* block);
42
43 // The maximum depth, for framesizeclass determination.
44 uint32_t maxargslots_;
45
46 public:
47 LIRGenerator(MIRGenerator* gen, MIRGraph& graph, LIRGraph& lirGraph)
48 : LIRGeneratorSpecific(gen, graph, lirGraph), maxargslots_(0) {}
49
50 [[nodiscard]] bool generate();
51
52 private:
53 LBoxAllocation useBoxFixedAtStart(MDefinition* mir, Register reg1,
54 Register reg2) {
55 return useBoxFixed(mir, reg1, reg2, /* useAtStart = */ true);
56 }
57
58 LBoxAllocation useBoxFixedAtStart(MDefinition* mir, ValueOperand op);
59 LBoxAllocation useBoxAtStart(MDefinition* mir,
60 LUse::Policy policy = LUse::REGISTER);
61
62 void lowerBitOp(JSOp op, MBinaryInstruction* ins);
63 void lowerShiftOp(JSOp op, MShiftInstruction* ins);
64 LInstructionHelper<1, 1, 0>* allocateAbs(MAbs* ins, LAllocation input);
65 bool definePhis();
66
67 template <typename T>
68 [[nodiscard]] bool lowerCallArguments(T* call);
69
70 friend class LIRGeneratorShared;
71 void visitInstructionDispatch(MInstruction* ins);
72
73 void visitReturnImpl(MDefinition* def, bool isGenerator = false);
74
75 [[nodiscard]] bool visitInstruction(MInstruction* ins);
76 [[nodiscard]] bool visitBlock(MBasicBlock* block);
77
78 #define MIR_OP(op) void visit##op(M##op* ins);
79 MIR_OPCODE_LIST(MIR_OP)
80 #undef MIR_OP
81
82 template <class MWasmCallT>
83 void visitWasmCall(MWasmCallT ins);
84
85 WasmRefIsSubtypeDefs useWasmRefIsSubtype(wasm::RefType destType,
86 MDefinition* superSTV);
87 };
88
89 } // namespace jit
90 } // namespace js
91
92 #endif /* jit_Lowering_h */