blob: df1051b4f42cf931cb3f4355e0c5729262ac7054 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//=- WebAssemblyInstrInfo.h - WebAssembly Instruction Information -*- C++ -*-=//
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 contains the WebAssembly implementation of the
Dan Gohman10e730a2015-06-29 23:51:55 +000011/// TargetInstrInfo class.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYINSTRINFO_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYINSTRINFO_H
17
18#include "WebAssemblyRegisterInfo.h"
David Blaikie3f833ed2017-11-08 01:01:31 +000019#include "llvm/CodeGen/TargetInstrInfo.h"
Dan Gohman10e730a2015-06-29 23:51:55 +000020
JF Bastienb9073fb2015-07-22 21:28:15 +000021#define GET_INSTRINFO_HEADER
22#include "WebAssemblyGenInstrInfo.inc"
23
Thomas Lively972d7d52019-03-09 04:31:37 +000024#define GET_INSTRINFO_OPERAND_ENUM
25#include "WebAssemblyGenInstrInfo.inc"
26
Dan Gohman10e730a2015-06-29 23:51:55 +000027namespace llvm {
28
Thomas Lively972d7d52019-03-09 04:31:37 +000029namespace WebAssembly {
30
31int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIndex);
32
33}
34
Dan Gohman10e730a2015-06-29 23:51:55 +000035class WebAssemblySubtarget;
36
JF Bastienb9073fb2015-07-22 21:28:15 +000037class WebAssemblyInstrInfo final : public WebAssemblyGenInstrInfo {
Dan Gohman10e730a2015-06-29 23:51:55 +000038 const WebAssemblyRegisterInfo RI;
39
40public:
41 explicit WebAssemblyInstrInfo(const WebAssemblySubtarget &STI);
42
43 const WebAssemblyRegisterInfo &getRegisterInfo() const { return RI; }
Dan Gohman4f52e002015-09-09 00:52:47 +000044
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000045 bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
Dan Gohmanb6fd39a2016-01-19 16:59:23 +000046 AliasAnalysis *AA) const override;
47
Dan Gohman4f52e002015-09-09 00:52:47 +000048 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
Benjamin Kramerbdc49562016-06-12 15:39:02 +000049 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Dan Gohman4f52e002015-09-09 00:52:47 +000050 bool KillSrc) const override;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +000051 MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
Dan Gohmanadf28172016-01-28 01:22:44 +000052 unsigned OpIdx1,
53 unsigned OpIdx2) const override;
Dan Gohman950a13c2015-09-16 16:51:30 +000054
Jacques Pienaar71c30a12016-07-15 14:41:04 +000055 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Dan Gohman950a13c2015-09-16 16:51:30 +000056 MachineBasicBlock *&FBB,
57 SmallVectorImpl<MachineOperand> &Cond,
58 bool AllowModify = false) const override;
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +000059 unsigned removeBranch(MachineBasicBlock &MBB,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000060 int *BytesRemoved = nullptr) const override;
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +000061 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Dan Gohman7a6b9822015-11-29 22:32:02 +000062 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +000063 const DebugLoc &DL,
64 int *BytesAdded = nullptr) const override;
Dan Gohman950a13c2015-09-16 16:51:30 +000065 bool
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +000066 reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000067};
68
69} // end namespace llvm
70
71#endif