| 1 | //===- GCNVOPDUtils.h - GCN VOPD Utils ------------------------===// |
| 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 This file contains the AMDGPU DAG scheduling |
| 10 | /// mutation to pair VOPD instructions back to back. It also contains |
| 11 | // subroutines useful in the creation of VOPD instructions |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_LIB_TARGET_AMDGPU_VOPDUTILS_H |
| 16 | #define LLVM_LIB_TARGET_AMDGPU_VOPDUTILS_H |
| 17 | |
| 18 | #include "llvm/CodeGen/MachineScheduler.h" |
| 19 | #include <optional> |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | class MachineInstr; |
| 24 | class SIInstrInfo; |
| 25 | |
| 26 | bool checkVOPDRegConstraints(const SIInstrInfo &TII, |
| 27 | const MachineInstr &FirstMI, |
| 28 | const MachineInstr &SecondMI, bool IsVOPD3, |
| 29 | bool AllowSameVGPR); |
| 30 | |
| 31 | /// Describes a matched VOPD pair: which instruction is the X component and |
| 32 | /// which is the Y component, and whether this is a VOPD3 encoding. |
| 33 | struct VOPDMatchInfo { |
| 34 | MachineInstr *MIX; |
| 35 | MachineInstr *MIY; |
| 36 | bool IsVOPD3; |
| 37 | }; |
| 38 | |
| 39 | /// Check whether FirstMI and SecondMI can be |
| 40 | /// combined into a VOPD instruction. Returns the match info (X/Y assignment |
| 41 | /// and encoding variant) on success, or std::nullopt if they cannot be paired. |
| 42 | std::optional<VOPDMatchInfo> tryMatchVOPDPair(const SIInstrInfo &TII, |
| 43 | MachineInstr &FirstMI, |
| 44 | MachineInstr &SecondMI); |
| 45 | |
| 46 | std::unique_ptr<ScheduleDAGMutation> createVOPDPairingMutation(); |
| 47 | |
| 48 | } // namespace llvm |
| 49 | |
| 50 | #endif // LLVM_LIB_TARGET_AMDGPU_VOPDUTILS_H |
| 51 | |