LLVM  14.0.0git
WebAssemblySelectionDAGInfo.cpp
Go to the documentation of this file.
1 //===-- WebAssemblySelectionDAGInfo.cpp - WebAssembly SelectionDAG Info ---===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file implements the WebAssemblySelectionDAGInfo class.
11 ///
12 //===----------------------------------------------------------------------===//
13 
15 using namespace llvm;
16 
17 #define DEBUG_TYPE "wasm-selectiondag-info"
18 
20 
22  SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
23  SDValue Size, Align Alignment, bool IsVolatile, bool AlwaysInline,
24  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
26  if (!ST.hasBulkMemory())
27  return SDValue();
28 
29  SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
30  auto LenMVT = ST.hasAddr64() ? MVT::i64 : MVT::i32;
31  return DAG.getNode(WebAssemblyISD::MEMORY_COPY, DL, MVT::Other,
32  {Chain, MemIdx, MemIdx, Dst, Src,
33  DAG.getZExtOrTrunc(Size, DL, LenMVT)});
34 }
35 
37  SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Op1, SDValue Op2,
38  SDValue Op3, Align Alignment, bool IsVolatile,
39  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
40  return EmitTargetCodeForMemcpy(DAG, DL, Chain, Op1, Op2, Op3,
41  Alignment, IsVolatile, false,
42  DstPtrInfo, SrcPtrInfo);
43 }
44 
46  SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Val,
47  SDValue Size, Align Alignment, bool IsVolatile,
48  MachinePointerInfo DstPtrInfo) const {
50  if (!ST.hasBulkMemory())
51  return SDValue();
52 
53  SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
54  auto LenMVT = ST.hasAddr64() ? MVT::i64 : MVT::i32;
55  // Only low byte matters for val argument, so anyext the i8
56  return DAG.getNode(WebAssemblyISD::MEMORY_FILL, DL, MVT::Other, Chain, MemIdx,
57  Dst, DAG.getAnyExtOrTrunc(Val, DL, MVT::i32),
58  DAG.getZExtOrTrunc(Size, DL, LenMVT));
59 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::SDLoc
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Definition: SelectionDAGNodes.h:1085
WebAssemblyTargetMachine.h
llvm::SelectionDAG::getZExtOrTrunc
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
Definition: SelectionDAG.cpp:1328
llvm::WebAssemblySelectionDAGInfo::EmitTargetCodeForMemcpy
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
Definition: WebAssemblySelectionDAGInfo.cpp:21
llvm::SelectionDAG
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:216
llvm::SelectionDAG::getConstant
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
Definition: SelectionDAG.cpp:1398
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:641
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:38
llvm::SelectionDAG::getNode
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
Definition: SelectionDAG.cpp:8299
llvm::SelectionDAG::getAnyExtOrTrunc
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
Definition: SelectionDAG.cpp:1316
llvm::MVT::Other
@ Other
Definition: MachineValueType.h:42
llvm::MVT::i64
@ i64
Definition: MachineValueType.h:47
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::WebAssemblySelectionDAGInfo::EmitTargetCodeForMemmove
SDValue EmitTargetCodeForMemmove(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memmove.
Definition: WebAssemblySelectionDAGInfo.cpp:36
llvm::WebAssemblySubtarget
Definition: WebAssemblySubtarget.h:35
llvm::AMDGPU::HSAMD::Kernel::Arg::Key::IsVolatile
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
Definition: AMDGPUMetadata.h:194
llvm::MVT::i32
@ i32
Definition: MachineValueType.h:46
llvm::SDValue
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
Definition: SelectionDAGNodes.h:137
llvm::WebAssemblySelectionDAGInfo::EmitTargetCodeForMemset
SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool IsVolatile, MachinePointerInfo DstPtrInfo) const override
Emit target-specific code that performs a memset.
Definition: WebAssemblySelectionDAGInfo.cpp:45
llvm::SelectionDAG::getMachineFunction
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:437
llvm::WebAssemblySelectionDAGInfo::~WebAssemblySelectionDAGInfo
~WebAssemblySelectionDAGInfo() override