| //===-- AMDGPUMachineInstrs.h -*- C++ -*-----------------------------------===// | |
| // | |
| // 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 | |
| // | |
| //===----------------------------------------------------------------------===// | |
| // | |
| /// Convenience wrappers and helpers for AMDGPU-specific machine instructions. | |
| // | |
| //===----------------------------------------------------------------------===// | |
| #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEINSTRS_H | |
| #define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEINSTRS_H | |
| #include "SIInstrInfo.h" | |
| #include "Utils/AMDGPUBaseInfo.h" | |
| #include "llvm/CodeGen/MachineInstr.h" | |
| namespace llvm { | |
| namespace AMDGPUMI { | |
| // Wrapper for the whole-dword VGPR "as memory" (address space 13) load/store | |
| // pseudos. The movrel form reads its index from M0, the GPR_IDX form from $idx: | |
| // movrel: load (outs data), (ins offset) store (ins data, offset) | |
| // gpr_idx: load (outs data), (ins idx, offset) store (ins data, idx, offset) | |
| class VLoadStoreIdxInst : public MachineInstr { | |
| const AMDGPU::VLdStIdxOpcodeInfo &getInfo() const { | |
| return *AMDGPU::getVLdStIdxOpcodeInfoByOpcode(getOpcode()); | |
| } | |
| public: | |
| bool isGPRIdx() const { return getInfo().IsGPRIdx; } | |
| MachineOperand &getDataOp() { return getOperand(0); } | |
| MachineOperand &getIdxOp() { | |
| assert(isGPRIdx() && "movrel form reads its index from M0"); | |
| return getOperand(1); | |
| } | |
| MachineOperand &getOffsetOp() { return getOperand(isGPRIdx() ? 2 : 1); } | |
| const MachineOperand &getDataOp() const { return getOperand(0); } | |
| const MachineOperand &getIdxOp() const { | |
| assert(isGPRIdx() && "movrel form reads its index from M0"); | |
| return getOperand(1); | |
| } | |
| const MachineOperand &getOffsetOp() const { | |
| return getOperand(isGPRIdx() ? 2 : 1); | |
| } | |
| unsigned getBitWidth() const { return getInfo().BitWidth; } | |
| // The VGPRs an index can reach, which excludes the AGPRs that gfx90a+ counts | |
| // as addressable. | |
| static unsigned getNumIndexableVGPRs(const MachineFunction &MF); | |
| // Whether an access of this many bits is supported. Each supported width has | |
| // a load and a store pseudo of both forms. | |
| static bool isSupportedBitWidth(unsigned Bits); | |
| static bool classof(const MachineInstr *MI) { | |
| return SIInstrFlags::isVGPRAsMem(*MI); | |
| } | |
| }; | |
| } // end namespace AMDGPUMI | |
| } // end namespace llvm | |
| #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEINSTRS_H |