5#ifndef V8_COMPILER_BACKEND_INSTRUCTION_SELECTOR_ADAPTER_H_
6#define V8_COMPILER_BACKEND_INSTRUCTION_SELECTOR_ADAPTER_H_
32 switch (graph->Get(
node_).opcode) {
33 case turboshaft::Opcode::kLoad:
34 load_ = &graph->Get(node_).Cast<turboshaft::LoadOp>();
36#if V8_ENABLE_WEBASSEMBLY
37 case turboshaft::Opcode::kSimd128LoadTransform:
39 &graph->Get(node_).Cast<turboshaft::Simd128LoadTransformOp>();
41#if V8_ENABLE_WASM_SIMD256_REVEC
42 case turboshaft::Opcode::kSimd256LoadTransform:
44 &graph->Get(node_).Cast<turboshaft::Simd256LoadTransformOp>();
54 return load_->machine_type();
58 return load_->loaded_rep;
62 return load_->result_rep;
65 if (
kind().with_trap_handler) {
67 *traps_on_null =
load_->kind.trap_on_null;
68#if V8_ENABLE_WEBASSEMBLY
70#if V8_ENABLE_WASM_SIMD256_REVEC
72 (load_transform_ && !load_transform_->load_kind.trap_on_null) ||
73 (load_transform256_ &&
74 !load_transform256_->load_kind.trap_on_null));
77 DCHECK(!load_transform_->load_kind.trap_on_null);
79 *traps_on_null =
false;
90#if V8_ENABLE_WEBASSEMBLY
91 if (load_transform_)
return load_transform_->base();
92#if V8_ENABLE_WASM_SIMD256_REVEC
93 if (load_transform256_)
return load_transform256_->base();
99 if (
load_)
return load_->index().value_or_invalid();
100#if V8_ENABLE_WEBASSEMBLY
101 if (load_transform_)
return load_transform_->index();
102#if V8_ENABLE_WASM_SIMD256_REVEC
103 if (load_transform256_)
return load_transform256_->index();
113 if (
load_->kind.tagged_base) {
119#if V8_ENABLE_WEBASSEMBLY
120 }
else if (load_transform_) {
121 int32_t
offset = load_transform_->offset;
122 DCHECK(!load_transform_->load_kind.tagged_base);
124#if V8_ENABLE_WASM_SIMD256_REVEC
125 }
else if (load_transform256_) {
126 int32_t
offset = load_transform256_->offset;
127 DCHECK(!load_transform256_->load_kind.tagged_base);
139#if V8_ENABLE_WEBASSEMBLY
140 if (load_transform_)
return 0;
141#if V8_ENABLE_WASM_SIMD256_REVEC
142 if (load_transform256_)
return 0;
153#if V8_ENABLE_WEBASSEMBLY
154 if (load_transform_)
return load_transform_->load_kind;
155#if V8_ENABLE_WASM_SIMD256_REVEC
156 if (load_transform256_)
return load_transform256_->load_kind;
164#if V8_ENABLE_WEBASSEMBLY
165 const turboshaft::Simd128LoadTransformOp* load_transform_ =
nullptr;
166#if V8_ENABLE_WASM_SIMD256_REVEC
167 const turboshaft::Simd256LoadTransformOp* load_transform256_ =
nullptr;
180 return {
op_->stored_rep.ToMachineType().representation(),
184 return op_->stored_rep;
192 return op_->kind.with_trap_handler
208 if (
op_->kind.tagged_base) {
218 return op_->element_size_log2;
222 return op_->kind.with_trap_handler &&
op_->kind.trap_on_null;
232#if V8_ENABLE_WEBASSEMBLY
234 class SimdShuffleView {
239 op128_ = &graph->Get(node).Cast<turboshaft::Simd128ShuffleOp>();
241 for (
int i = 0;
i < op128_->input_count; ++
i) {
242 input_mapping_.push_back(
i);
246 bool isSimd128()
const {
251 const uint8_t*
data()
const {
return op128_->shuffle; }
253 turboshaft::OpIndex input(
int index)
const {
255 return op128_->input(input_mapping_[index]);
258 void SwapInputs() { std::swap(input_mapping_[0], input_mapping_[1]); }
260 void DuplicateFirstInput() {
262 input_mapping_[1] = input_mapping_[0];
265 operator turboshaft::OpIndex()
const {
return node_; }
268 turboshaft::OpIndex
node_;
269 base::SmallVector<int, 2> input_mapping_;
270 const turboshaft::Simd128ShuffleOp* op128_;
276#
if V8_ENABLE_WEBASSEMBLY
277 ||
graph_->
Get(node).Is<turboshaft::Simd128LoadTransformOp>()
278#
if V8_ENABLE_WASM_SIMD256_REVEC
279 ||
graph_->
Get(node).Is<turboshaft::Simd256LoadTransformOp>()
295#if V8_ENABLE_WEBASSEMBLY
297 return SimdShuffleView(
graph_, node);
319 return block->IsLoop();
323 return block->PredecessorCount();
326 size_t index)
const {
341 if (constant ==
nullptr)
return false;
347 if (constant ==
nullptr)
return false;
353 if (constant ==
nullptr)
return false;
354 return constant->
kind ==
360 return graph_->
Get(node).opcode == turboshaft::Opcode::kLoad;
363#if V8_ENABLE_WEBASSEMBLY
364 if (
graph_->
Get(node).opcode == turboshaft::Opcode::kSimd128LoadTransform) {
367#if V8_ENABLE_WASM_SIMD256_REVEC
368 if (
graph_->
Get(node).opcode == turboshaft::Opcode::kSimd256LoadTransform) {
380#ifndef V8_TARGET_ARCH_X64
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
static RpoNumber FromInt(int index)
bool is_protected(bool *traps_on_null) const
turboshaft::MemoryRepresentation ts_loaded_rep() const
turboshaft::OpIndex base() const
turboshaft::OpIndex index() const
uint8_t element_size_log2() const
int32_t displacement() const
LoadView(turboshaft::Graph *graph, turboshaft::OpIndex node)
turboshaft::OpIndex node_
const turboshaft::LoadOp * load_
LoadRepresentation loaded_rep() const
turboshaft::RegisterRepresentation ts_result_rep() const
turboshaft::LoadOp::Kind kind() const
uint8_t element_size_log2() const
turboshaft::OpIndex node_
MemoryAccessKind access_kind() const
turboshaft::OptionalOpIndex index() const
std::optional< AtomicMemoryOrder > memory_order() const
IndirectPointerTag indirect_pointer_tag() const
turboshaft::OpIndex base() const
turboshaft::OpIndex value() const
turboshaft::MemoryRepresentation ts_stored_rep() const
const turboshaft::StoreOp * op_
int32_t displacement() const
StoreRepresentation stored_rep() const
bool is_store_trap_on_null() const
StoreView(turboshaft::Graph *graph, turboshaft::OpIndex node)
base::SmallVector< Block *, 8 > Predecessors() const
base::iterator_range< OpIndexIterator > OperationIndices(const Block &block) const
V8_INLINE const Operation & Get(OpIndex i) const
const underlying_operation_t< Op > & Cast(V< AnyOrNone > op_idx) const
any_of(const Args &...) -> any_of< Args... >
@ kProtectedByTrapHandler
#define DCHECK_LE(v1, v2)
#define CHECK_GE(lhs, rhs)
#define DCHECK_NOT_NULL(val)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
bool is_load_root_register(turboshaft::OpIndex node) const
TurboshaftAdapter(turboshaft::Graph *graph)
bool IsRelocatableWasmConstant(turboshaft::OpIndex node) const
bool IsExternalConstant(turboshaft::OpIndex node) const
static constexpr bool AllowsImplicitWord64ToWord32Truncation
RpoNumber rpo_number(const turboshaft::Block *block) const
static constexpr bool IsTurboshaft
const ZoneVector< turboshaft::Block * > & rpo_order(turboshaft::Graph *schedule)
turboshaft::OpIndex input_at(turboshaft::OpIndex node, size_t index) const
base::Vector< const turboshaft::OpIndex > inputs(turboshaft::OpIndex node) const
uint32_t id(turboshaft::OpIndex node) const
static constexpr bool IsTurbofan
bool is_load(turboshaft::OpIndex node) const
bool IsLoadOrLoadImmutable(turboshaft::OpIndex node) const
LoadView load_view(turboshaft::OpIndex node)
turboshaft::Opcode opcode(turboshaft::OpIndex node) const
bool IsProtectedLoad(turboshaft::OpIndex node) const
base::iterator_range< turboshaft::Graph::OpIndexIterator > nodes(const turboshaft::Block *block)
bool IsRetain(turboshaft::OpIndex node) const
static turboshaft::OpIndex value(turboshaft::OptionalOpIndex node)
turboshaft::Block * PredecessorAt(const turboshaft::Block *block, size_t index) const
turboshaft::Graph * graph_
turboshaft::Block * block(turboshaft::Graph *schedule, turboshaft::OpIndex node) const
bool IsHeapConstant(turboshaft::OpIndex node) const
size_t PredecessorCount(const turboshaft::Block *block) const
int value_input_count(turboshaft::OpIndex node) const
bool IsLoopHeader(const turboshaft::Block *block) const
turboshaft::Graph * turboshaft_graph() const
StoreView store_view(turboshaft::OpIndex node)
@ kRelocatableWasmStubCall
uint8_t element_size_log2