blob: 34d93ecafce81d34a714ce57716b8a4ae072d0ca [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//===-- WebAssemblySelectionDAGInfo.cpp - WebAssembly SelectionDAG Info ---===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Dan Gohman10e730a2015-06-29 23:51:55 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file implements the WebAssemblySelectionDAGInfo class.
Dan Gohman10e730a2015-06-29 23:51:55 +000011///
12//===----------------------------------------------------------------------===//
13
14#include "WebAssemblyTargetMachine.h"
15using namespace llvm;
16
17#define DEBUG_TYPE "wasm-selectiondag-info"
18
Heejin Ahn18c56a02019-02-04 19:13:39 +000019WebAssemblySelectionDAGInfo::~WebAssemblySelectionDAGInfo() = default; // anchor
Thomas Livelyd99af232019-02-05 00:49:55 +000020
21SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemcpy(
Thomas Livelyde7a0a12019-02-13 22:11:16 +000022 SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
23 SDValue Size, unsigned Align, bool IsVolatile, bool AlwaysInline,
Thomas Livelyd99af232019-02-05 00:49:55 +000024 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
25 if (!DAG.getMachineFunction()
26 .getSubtarget<WebAssemblySubtarget>()
27 .hasBulkMemory())
28 return SDValue();
29
Thomas Livelyde7a0a12019-02-13 22:11:16 +000030 SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
31 return DAG.getNode(WebAssemblyISD::MEMORY_COPY, DL, MVT::Other,
32 {Chain, MemIdx, MemIdx, Dst, Src,
33 DAG.getZExtOrTrunc(Size, DL, MVT::i32)});
Thomas Livelyd99af232019-02-05 00:49:55 +000034}
Thomas Lively31505662019-02-05 20:57:40 +000035
36SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemmove(
37 SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Op1, SDValue Op2,
38 SDValue Op3, unsigned Align, bool IsVolatile,
39 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
40 return EmitTargetCodeForMemcpy(DAG, DL, Chain, Op1, Op2, Op3, Align,
41 IsVolatile, false, DstPtrInfo,
42 SrcPtrInfo);
43}