LLVM 24.0.0git
AMDGPULaneMaskUtils.h
Go to the documentation of this file.
1//===- AMDGPULaneMaskUtils.h - Exec/lane mask helper functions -*- 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#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPULANEMASKUTILS_H
10#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPULANEMASKUTILS_H
11
12#include "GCNSubtarget.h"
14
15namespace llvm {
16
17class GCNSubtarget;
18
19namespace AMDGPU {
20
22public:
25 const unsigned AndOpc;
26 const unsigned AndTermOpc;
27 const unsigned AndN2Opc;
28 const unsigned AndN2SaveExecOpc;
29 const unsigned AndN2TermOpc;
30 const unsigned AndN2WrExecOpc; // GFX10+ (HasNoSdstCMPX) only
31 const unsigned AndSaveExecOpc;
32 const unsigned AndSaveExecTermOpc;
33 const unsigned BfmOpc;
34 const unsigned CMovOpc;
35 const unsigned CmpLgOpc; // GFX8+ only in wave64
36 const unsigned CSelectOpc;
37 const unsigned MovOpc;
38 const unsigned MovTermOpc;
39 const unsigned OrOpc;
40 const unsigned OrN2Opc;
41 const unsigned OrTermOpc;
42 const unsigned OrSaveExecOpc;
43 const unsigned XorOpc;
44 const unsigned XorTermOpc;
45 const unsigned WQMOpc;
46
47 constexpr LaneMaskConstants(bool IsWave32)
48 : ExecReg(IsWave32 ? AMDGPU::EXEC_LO : AMDGPU::EXEC),
49 VccReg(IsWave32 ? AMDGPU::VCC_LO : AMDGPU::VCC),
50 AndOpc(IsWave32 ? AMDGPU::S_AND_B32 : AMDGPU::S_AND_B64),
51 AndTermOpc(IsWave32 ? AMDGPU::S_AND_B32_term : AMDGPU::S_AND_B64_term),
52 AndN2Opc(IsWave32 ? AMDGPU::S_ANDN2_B32 : AMDGPU::S_ANDN2_B64),
53 AndN2SaveExecOpc(IsWave32 ? AMDGPU::S_ANDN2_SAVEEXEC_B32
54 : AMDGPU::S_ANDN2_SAVEEXEC_B64),
55 AndN2TermOpc(IsWave32 ? AMDGPU::S_ANDN2_B32_term
56 : AMDGPU::S_ANDN2_B64_term),
57 AndN2WrExecOpc(IsWave32 ? AMDGPU::S_ANDN2_WREXEC_B32
58 : AMDGPU::S_ANDN2_WREXEC_B64),
59 AndSaveExecOpc(IsWave32 ? AMDGPU::S_AND_SAVEEXEC_B32
60 : AMDGPU::S_AND_SAVEEXEC_B64),
61 AndSaveExecTermOpc(IsWave32 ? AMDGPU::S_AND_SAVEEXEC_B32_term
62 : AMDGPU::S_AND_SAVEEXEC_B64_term),
63 BfmOpc(IsWave32 ? AMDGPU::S_BFM_B32 : AMDGPU::S_BFM_B64),
64 CMovOpc(IsWave32 ? AMDGPU::S_CMOV_B32 : AMDGPU::S_CMOV_B64),
65 CmpLgOpc(IsWave32 ? AMDGPU::S_CMP_LG_U32 : AMDGPU::S_CMP_LG_U64),
66 CSelectOpc(IsWave32 ? AMDGPU::S_CSELECT_B32 : AMDGPU::S_CSELECT_B64),
67 MovOpc(IsWave32 ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64),
68 MovTermOpc(IsWave32 ? AMDGPU::S_MOV_B32_term : AMDGPU::S_MOV_B64_term),
69 OrOpc(IsWave32 ? AMDGPU::S_OR_B32 : AMDGPU::S_OR_B64),
70 OrN2Opc(IsWave32 ? AMDGPU::S_ORN2_B32 : AMDGPU::S_ORN2_B64),
71 OrTermOpc(IsWave32 ? AMDGPU::S_OR_B32_term : AMDGPU::S_OR_B64_term),
72 OrSaveExecOpc(IsWave32 ? AMDGPU::S_OR_SAVEEXEC_B32
73 : AMDGPU::S_OR_SAVEEXEC_B64),
74 XorOpc(IsWave32 ? AMDGPU::S_XOR_B32 : AMDGPU::S_XOR_B64),
75 XorTermOpc(IsWave32 ? AMDGPU::S_XOR_B32_term : AMDGPU::S_XOR_B64_term),
76 WQMOpc(IsWave32 ? AMDGPU::S_WQM_B32 : AMDGPU::S_WQM_B64) {}
77
78 static inline const LaneMaskConstants &get(const GCNSubtarget &ST);
79};
80
82 LaneMaskConstants(/*IsWave32=*/true);
84 LaneMaskConstants(/*IsWave32=*/false);
85
87 unsigned WavefrontSize = ST.getWavefrontSize();
88 assert(WavefrontSize == 32 || WavefrontSize == 64);
89 return WavefrontSize == 32 ? LaneMaskConstants32 : LaneMaskConstants64;
90}
91
92} // end namespace AMDGPU
93
94} // end namespace llvm
95
96#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPULANEMASKUTILS_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMD GCN specific subclass of TargetSubtarget.
constexpr LaneMaskConstants(bool IsWave32)
static const LaneMaskConstants & get(const GCNSubtarget &ST)
Wrapper class representing virtual and physical registers.
Definition Register.h:20
static constexpr LaneMaskConstants LaneMaskConstants32
static constexpr LaneMaskConstants LaneMaskConstants64
This is an optimization pass for GlobalISel generic memory operations.