LLVM 22.0.0git
|
Lower VGPRs above first 256 on gfx1250. More...
#include "AMDGPULowerVGPREncoding.h"
#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "SIInstrInfo.h"
#include "llvm/ADT/PackedVector.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "amdgpu-lower-vgpr-encoding" |
Functions | |
INITIALIZE_PASS (AMDGPULowerVGPREncodingLegacy, DEBUG_TYPE, "AMDGPU Lower VGPR Encoding", false, false) PreservedAnalyses AMDGPULowerVGPREncodingPass |
Lower VGPRs above first 256 on gfx1250.
The pass scans used VGPRs and inserts S_SET_VGPR_MSB instructions to switch VGPR addressing mode. The mode change is effective until the next change. This instruction provides high bits of a VGPR address for four of the operands: vdst, src0, src1, and src2, or other 4 operands depending on the instruction encoding. If bits are set they are added as MSB to the corresponding operand VGPR number.
There is no need to replace actual register operands because encoding of the high and low VGPRs is the same. I.e. v0 has the encoding 0x100, so does v256. v1 has the encoding 0x101 and v257 has the same encoding. So high VGPRs will survive until actual encoding and will result in a same actual bit encoding.
As a result the pass only inserts S_SET_VGPR_MSB to provide an actual offset to a VGPR address of the subseqent instructions. The InstPrinter will take care of the printing a low VGPR instead of a high one. In prinicple this shall be viable to print actual high VGPR numbers, but that would disagree with a disasm printing and create a situation where asm text is not deterministic.
This pass creates a convention where non-fall through basic blocks shall start with all 4 MSBs zero. Otherwise a disassembly would not be readable. An optimization here is possible but deemed not desirable because of the readbility concerns.
Consequentially the ABI is set to expect all 4 MSBs to be zero on entry. The pass must run very late in the pipeline to make sure no changes to VGPR operands will be made after it.
Definition in file AMDGPULowerVGPREncoding.cpp.
#define DEBUG_TYPE "amdgpu-lower-vgpr-encoding" |
Definition at line 52 of file AMDGPULowerVGPREncoding.cpp.
INITIALIZE_PASS | ( | AMDGPULowerVGPREncodingLegacy | , |
DEBUG_TYPE | , | ||
"AMDGPU Lower VGPR Encoding" | , | ||
false | , | ||
false | ) |
Definition at line 361 of file AMDGPULowerVGPREncoding.cpp.
References llvm::PreservedAnalyses::all(), DEBUG_TYPE, and llvm::PreservedAnalyses::preserveSet().