5#ifndef V8_COMPILER_BACKEND_INSTRUCTION_SELECTOR_IMPL_H_
6#define V8_COMPILER_BACKEND_INSTRUCTION_SELECTOR_IMPL_H_
26 return l.order <
r.order;
39 if (cases.
size() != 0) {
40 DCHECK_LE(min_value, max_value);
43 value_range_ = 1u + base::bit_cast<uint32_t>(max_value) -
44 base::bit_cast<uint32_t>(min_value);
102 template <
typename FPRegType>
111 int virtual_register =
GetVReg(node);
126 primary_location, secondary_location,
GetVReg(node)));
207 template <
typename FPRegType>
316 template <
typename FPRegType>
320 sequence()->NextVirtualRegister());
354 switch (constant->kind) {
356 return Constant(
static_cast<int32_t
>(constant->word32()));
358 return Constant(
static_cast<int64_t
>(constant->word64()));
360 if constexpr (
Is64()) {
361 return Constant(
static_cast<int64_t
>(constant->smi().ptr()));
363 return Constant(
static_cast<int32_t
>(constant->smi().ptr()));
365 case Kind::kHeapObject:
366 case Kind::kCompressedHeapObject:
367 case Kind::kTrustedHeapObject:
369 constant->kind == Kind::kCompressedHeapObject);
370 case Kind::kExternal:
371 return Constant(constant->external_reference());
373 return Constant(constant->number());
375 return Constant(constant->float32());
377 return Constant(constant->float64());
378 case Kind::kTaggedIndex: {
380 intptr_t value =
static_cast<intptr_t
>(constant->tagged_index());
385 return Constant(
static_cast<int32_t
>(tagged_index));
387 return Constant(
static_cast<int64_t
>(tagged_index));
390 case Kind::kRelocatableWasmCall:
391 case Kind::kRelocatableWasmStubCall: {
392 uint64_t value = constant->integral();
393 auto mode = constant->kind == Kind::kRelocatableWasmCall
396 using constant_type = std::conditional_t<
Is64(), int64_t, int32_t>;
398 base::checked_cast<constant_type>(value), mode));
400 case Kind::kRelocatableWasmCanonicalSignatureId:
402 base::checked_cast<int32_t>(constant->integral()),
404 case Kind::kRelocatableWasmIndirectCallTarget:
405 uint64_t value = constant->integral();
407 base::checked_cast<int32_t>(value),
417 switch (constant.kind) {
419 return Constant(-
static_cast<int32_t
>(constant.word32()));
421 return Constant(-
static_cast<int64_t
>(constant.word64()));
424 return Constant(-
static_cast<int64_t
>(constant.smi().ptr()));
426 return Constant(-
static_cast<int32_t
>(constant.smi().ptr()));
450 int virtual_register) {
461 int virtual_register) {
bool IsCalleeFrameSlot() const
bool IsAnyRegister() const
int32_t AsCalleeFrameSlot() const
MachineType GetType() const
int32_t AsRegister() const
bool IsCallerFrameSlot() const
bool IsNullRegister() const
NO_INLINE_FOR_ARM64_MSVC bool IsRegister() const
int32_t AsCallerFrameSlot() const
constexpr MachineRepresentation representation() const
@ WASM_CODE_POINTER_TABLE_ENTRY
V8_INLINE constexpr StorageType ptr() const
static Tagged< TaggedIndex > FromIntptr(intptr_t value)
static bool constexpr IsValid(intptr_t value)
static const int kInvalidVirtualRegister
int GetVirtualRegister(turboshaft::OpIndex node)
Instruction * Emit(InstructionCode opcode, InstructionOperand output, size_t temp_count=0, InstructionOperand *temps=nullptr)
void MarkAsDefined(turboshaft::OpIndex node)
void MarkAsUsed(turboshaft::OpIndex node)
Zone * instruction_zone() const
InstructionSequence * sequence() const
void AddConstant(int virtual_register, Constant constant)
ImmediateOperand AddImmediate(const Constant &constant)
int NextVirtualRegister()
void MarkAsRepresentation(MachineRepresentation rep, int virtual_register)
Constant ToNegatedConstant(turboshaft::OpIndex node)
InstructionOperand UseUniqueSlot(turboshaft::OpIndex node)
UnallocatedOperand ToUnallocatedOperand(LinkageLocation location, int virtual_register)
InstructionOperand UsePointerLocation(LinkageLocation to_location, LinkageLocation from_location)
UnallocatedOperand Use(turboshaft::OpIndex node, UnallocatedOperand operand)
InstructionOperand TempRegister()
InstructionOperand UseImmediate(int immediate)
InstructionOperand DefineSameAsFirstForVreg(int vreg)
InstructionOperand UseRegister(turboshaft::OpIndex node, RegisterUseKind unique_reg)
InstructionOperand UseAnyAtEnd(turboshaft::OpIndex node)
InstructionOperand DefineAsDualLocation(turboshaft::OpIndex node, LinkageLocation primary_location, LinkageLocation secondary_location)
InstructionOperand TempSimd128Register()
InstructionOperand DefineAsRegistertForVreg(int vreg)
InstructionOperand UseLocation(turboshaft::OpIndex node, LinkageLocation location)
InstructionOperand TempRegister(int code)
InstructionOperand UseFixed(turboshaft::OpIndex node, Register reg)
InstructionOperand UseRegisterForVreg(int vreg)
InstructionOperand DefineAsRegister(turboshaft::OpIndex node)
InstructionOperand UseFixed(turboshaft::OpIndex node, FPRegType reg)
InstructionOperand Use(turboshaft::OpIndex node)
Constant ToConstant(turboshaft::OpIndex node)
InstructionOperand UseNegatedImmediate(turboshaft::OpIndex node)
InstructionOperand DefineAsFixed(turboshaft::OpIndex node, FPRegType reg)
UnallocatedOperand ToDualLocationUnallocatedOperand(LinkageLocation primary_location, LinkageLocation secondary_location, int virtual_register)
int AllocateVirtualRegister()
InstructionOperand UseRegisterOrSlotOrConstant(turboshaft::OpIndex node)
InstructionOperand DefineSameAsFirst(turboshaft::OpIndex node)
InstructionSelectorT * selector_
InstructionOperand UseUniqueRegister(turboshaft::OpIndex node)
InstructionOperand UseImmediate(turboshaft::OpIndex node)
InstructionOperand TempImmediate(int32_t imm)
InstructionSelectorT * selector() const
InstructionOperand UseUniqueRegisterOrSlotOrConstant(turboshaft::OpIndex node)
InstructionOperand NoOutput()
InstructionOperand UseImmediate64(int64_t immediate)
InstructionOperand DefineAsConstant(turboshaft::OpIndex node)
OperandGeneratorT(InstructionSelectorT *selector)
InstructionOperand UseUnique(turboshaft::OpIndex node)
int GetVReg(turboshaft::OpIndex node) const
InstructionOperand UseRegisterAtEnd(turboshaft::OpIndex node)
InstructionSequence * sequence() const
InstructionOperand TempSimd256Register()
InstructionOperand TempRegister(Register reg)
InstructionOperand UseRegister(turboshaft::OpIndex node)
InstructionOperand DefineSameAsInput(turboshaft::OpIndex node, int input_index)
InstructionOperand TempFpRegister(FPRegType reg)
InstructionOperand UseAny(turboshaft::OpIndex node)
InstructionOperand DefineAsFixed(turboshaft::OpIndex node, Register reg)
InstructionOperand TempDoubleRegister()
InstructionOperand DefineAsLocation(turboshaft::OpIndex node, LinkageLocation location)
InstructionOperand TempLocation(LinkageLocation location)
UnallocatedOperand Define(turboshaft::OpIndex node, UnallocatedOperand operand)
InstructionOperand Label(turboshaft::Block *block)
InstructionOperand UseRegisterWithMode(turboshaft::OpIndex node, RegisterMode register_mode)
size_t case_count() const
turboshaft::Block * default_branch() const
SwitchInfoT(ZoneVector< CaseInfo > const &cases, int32_t min_value, int32_t max_value, turboshaft::Block *default_branch)
std::vector< CaseInfo > CasesSortedByValue() const
const ZoneVector< CaseInfo > & CasesUnsorted() const
turboshaft::Block * default_branch_
size_t value_range() const
const ZoneVector< CaseInfo > & cases_
int32_t max_value() const
int32_t min_value() const
int32_t virtual_register() const
@ REGISTER_OR_SLOT_OR_CONSTANT
const underlying_operation_t< Op > * TryCast(V< AnyOrNone > op_idx) const
ZoneVector< RpoNumber > & result
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
bool operator<(const CaseInfoT &l, const CaseInfoT &r)
constexpr int kSystemPointerSize
constexpr bool IsFloatingPoint(MachineRepresentation rep)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
turboshaft::Block * branch
RpoNumber rpo_number(const turboshaft::Block *block) const
turboshaft::Graph * turboshaft_graph() const
#define V8_LIKELY(condition)