Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | //=- WebAssemblyInstrInfo.h - WebAssembly Instruction Information -*- C++ -*-=// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// This file contains the WebAssembly implementation of the |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 11 | /// 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 Blaikie | 3f833ed | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/TargetInstrInfo.h" |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 20 | |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 21 | #define GET_INSTRINFO_HEADER |
| 22 | #include "WebAssemblyGenInstrInfo.inc" |
| 23 | |
Thomas Lively | 972d7d5 | 2019-03-09 04:31:37 +0000 | [diff] [blame] | 24 | #define GET_INSTRINFO_OPERAND_ENUM |
| 25 | #include "WebAssemblyGenInstrInfo.inc" |
| 26 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 27 | namespace llvm { |
| 28 | |
Thomas Lively | 972d7d5 | 2019-03-09 04:31:37 +0000 | [diff] [blame] | 29 | namespace WebAssembly { |
| 30 | |
| 31 | int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIndex); |
| 32 | |
| 33 | } |
| 34 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 35 | class WebAssemblySubtarget; |
| 36 | |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 37 | class WebAssemblyInstrInfo final : public WebAssemblyGenInstrInfo { |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 38 | const WebAssemblyRegisterInfo RI; |
| 39 | |
| 40 | public: |
| 41 | explicit WebAssemblyInstrInfo(const WebAssemblySubtarget &STI); |
| 42 | |
| 43 | const WebAssemblyRegisterInfo &getRegisterInfo() const { return RI; } |
Dan Gohman | 4f52e00 | 2015-09-09 00:52:47 +0000 | [diff] [blame] | 44 | |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 45 | bool isReallyTriviallyReMaterializable(const MachineInstr &MI, |
Dan Gohman | b6fd39a | 2016-01-19 16:59:23 +0000 | [diff] [blame] | 46 | AliasAnalysis *AA) const override; |
| 47 | |
Dan Gohman | 4f52e00 | 2015-09-09 00:52:47 +0000 | [diff] [blame] | 48 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 49 | const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, |
Dan Gohman | 4f52e00 | 2015-09-09 00:52:47 +0000 | [diff] [blame] | 50 | bool KillSrc) const override; |
Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 51 | MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI, |
Dan Gohman | adf2817 | 2016-01-28 01:22:44 +0000 | [diff] [blame] | 52 | unsigned OpIdx1, |
| 53 | unsigned OpIdx2) const override; |
Dan Gohman | 950a13c | 2015-09-16 16:51:30 +0000 | [diff] [blame] | 54 | |
Jacques Pienaar | 71c30a1 | 2016-07-15 14:41:04 +0000 | [diff] [blame] | 55 | bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, |
Dan Gohman | 950a13c | 2015-09-16 16:51:30 +0000 | [diff] [blame] | 56 | MachineBasicBlock *&FBB, |
| 57 | SmallVectorImpl<MachineOperand> &Cond, |
| 58 | bool AllowModify = false) const override; |
Matt Arsenault | 1b9fc8e | 2016-09-14 20:43:16 +0000 | [diff] [blame] | 59 | unsigned removeBranch(MachineBasicBlock &MBB, |
Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame] | 60 | int *BytesRemoved = nullptr) const override; |
Matt Arsenault | e8e0f5c | 2016-09-14 17:24:15 +0000 | [diff] [blame] | 61 | unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
Dan Gohman | 7a6b982 | 2015-11-29 22:32:02 +0000 | [diff] [blame] | 62 | MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, |
Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame] | 63 | const DebugLoc &DL, |
| 64 | int *BytesAdded = nullptr) const override; |
Dan Gohman | 950a13c | 2015-09-16 16:51:30 +0000 | [diff] [blame] | 65 | bool |
Matt Arsenault | 1b9fc8e | 2016-09-14 20:43:16 +0000 | [diff] [blame] | 66 | reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // end namespace llvm |
| 70 | |
| 71 | #endif |