| 1 | //===-- AMDGPUMachineInstrs.cpp -*- C++ -*---------------------------------===// |
|---|---|
| 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 | /// Convenience wrappers and helpers for AMDGPU-specific machine instructions. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "AMDGPUMachineInstrs.h" |
| 14 | #include "GCNSubtarget.h" |
| 15 | #include "SIMachineFunctionInfo.h" |
| 16 | #include "Utils/AMDGPUBaseInfo.h" |
| 17 | #include "llvm/CodeGen/MachineInstr.h" |
| 18 | |
| 19 | using namespace llvm; |
| 20 | using namespace AMDGPUMI; |
| 21 | |
| 22 | unsigned VLoadStoreIdxInst::getNumIndexableVGPRs(const MachineFunction &MF) { |
| 23 | const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>(); |
| 24 | unsigned DynamicVGPRBlockSize = |
| 25 | MF.getInfo<SIMachineFunctionInfo>()->getDynamicVGPRBlockSize(); |
| 26 | return std::min(a: ST.getAddressableNumArchVGPRs(), |
| 27 | b: ST.getAddressableNumVGPRs(DynamicVGPRBlockSize)); |
| 28 | } |
| 29 | |
| 30 | bool VLoadStoreIdxInst::isSupportedBitWidth(unsigned Bits) { |
| 31 | return AMDGPU::getVLdStIdxOpcodeInfoByKey(BitWidth: Bits, /*IsStore=*/false, |
| 32 | /*IsGPRIdx=*/false) != nullptr; |
| 33 | } |
| 34 |