2015-06-30 07:51:55 +08:00
|
|
|
//===-- WebAssemblySelectionDAGInfo.cpp - WebAssembly SelectionDAG Info ---===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-06-30 07:51:55 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
2018-05-01 23:54:18 +08:00
|
|
|
/// This file implements the WebAssemblySelectionDAGInfo class.
|
2015-06-30 07:51:55 +08:00
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "WebAssemblyTargetMachine.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "wasm-selectiondag-info"
|
|
|
|
|
[WebAssembly] clang-tidy (NFC)
Summary:
This patch fixes clang-tidy warnings on wasm-only files.
The list of checks used is:
`-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*`
(LLVM's default .clang-tidy list is the same except it does not have
`modernize-*`. But I've seen in multiple CLs in LLVM the modernize style
was recommended and code was fixed based on the style, so I added it as
well.)
The common fixes are:
- Variable names start with an uppercase letter
- Function names start with a lowercase letter
- Use `auto` when you use casts so the type is evident
- Use inline initialization for class member variables
- Use `= default` for empty constructors / destructors
- Use `using` in place of `typedef`
Reviewers: sbc100, tlively, aardappel
Subscribers: dschuff, sunfish, jgravelle-google, yurydelendik, kripken, MatzeB, mgorny, rupprecht, llvm-commits
Differential Revision: https://reviews.llvm.org/D57500
llvm-svn: 353075
2019-02-05 03:13:39 +08:00
|
|
|
WebAssemblySelectionDAGInfo::~WebAssemblySelectionDAGInfo() = default; // anchor
|
2019-02-05 08:49:55 +08:00
|
|
|
|
|
|
|
SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemcpy(
|
2019-02-14 06:11:16 +08:00
|
|
|
SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
|
|
|
|
SDValue Size, unsigned Align, bool IsVolatile, bool AlwaysInline,
|
2019-02-05 08:49:55 +08:00
|
|
|
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
|
|
|
|
if (!DAG.getMachineFunction()
|
|
|
|
.getSubtarget<WebAssemblySubtarget>()
|
|
|
|
.hasBulkMemory())
|
|
|
|
return SDValue();
|
|
|
|
|
2019-02-14 06:11:16 +08:00
|
|
|
SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
|
|
|
|
return DAG.getNode(WebAssemblyISD::MEMORY_COPY, DL, MVT::Other,
|
|
|
|
{Chain, MemIdx, MemIdx, Dst, Src,
|
|
|
|
DAG.getZExtOrTrunc(Size, DL, MVT::i32)});
|
2019-02-05 08:49:55 +08:00
|
|
|
}
|
2019-02-06 04:57:40 +08:00
|
|
|
|
|
|
|
SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemmove(
|
|
|
|
SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Op1, SDValue Op2,
|
|
|
|
SDValue Op3, unsigned Align, bool IsVolatile,
|
|
|
|
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
|
|
|
|
return EmitTargetCodeForMemcpy(DAG, DL, Chain, Op1, Op2, Op3, Align,
|
|
|
|
IsVolatile, false, DstPtrInfo,
|
|
|
|
SrcPtrInfo);
|
|
|
|
}
|
2019-02-14 06:25:18 +08:00
|
|
|
|
|
|
|
SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemset(
|
|
|
|
SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Val,
|
|
|
|
SDValue Size, unsigned Align, bool IsVolatile,
|
|
|
|
MachinePointerInfo DstPtrInfo) const {
|
|
|
|
if (!DAG.getMachineFunction()
|
|
|
|
.getSubtarget<WebAssemblySubtarget>()
|
|
|
|
.hasBulkMemory())
|
|
|
|
return SDValue();
|
|
|
|
|
|
|
|
SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
|
|
|
|
// Only low byte matters for val argument, so anyext the i8
|
|
|
|
return DAG.getNode(WebAssemblyISD::MEMORY_FILL, DL, MVT::Other, Chain, MemIdx,
|
|
|
|
Dst, DAG.getAnyExtOrTrunc(Val, DL, MVT::i32),
|
|
|
|
DAG.getZExtOrTrunc(Size, DL, MVT::i32));
|
|
|
|
}
|