LLVM 24.0.0git
SILowerI1Copies.h
Go to the documentation of this file.
1//===-- SILowerI1Copies.h --------------------------------------*- 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/// \file
10/// Interface definition of the PhiLoweringHelper class that implements lane
11/// mask merging algorithm for divergent i1 phis.
12//
13//===----------------------------------------------------------------------===//
14
15#include "AMDGPULaneMaskUtils.h"
16#include "GCNSubtarget.h"
21
22namespace llvm {
24namespace AMDGPU {
25class LoopFinder;
27/// Incoming for lane mask phi as machine instruction, incoming register \p Reg
28/// and incoming block \p Block are taken from machine instruction.
29/// \p UpdatedReg (if valid) is \p Reg lane mask merged with another lane mask.
38
40 MachineRegisterInfo::VRegAttrs LaneMaskRegAttrs);
41
43public:
46 virtual ~PhiLoweringHelper() = default;
47
48protected:
49 bool IsWave32 = false;
54 const GCNSubtarget *ST = nullptr;
55 const SIInstrInfo *TII = nullptr;
58
59#ifndef NDEBUG
61#endif
62
63public:
64 bool lowerPhis();
65 bool isConstantLaneMask(Register Reg, bool &Val) const;
66
67 /// Merge the \p Incomings lane masks into \p DstReg, the value owned by \p
68 /// MBB. Builds the per-predecessor merges and leaves \p SSAUpdater calculated
69 /// so the caller can query the merged value with getValueInMiddleOfBlock. \p
70 /// Incomings is sorted and its UpdatedReg fields are filled in.
77
79 LaneMaskRegAttrs = MRI->getVRegAttrs(LaneMask);
80 }
81
82 void
86
88 return TII->getRegisterInfo().isSGPRReg(*MRI, Reg) &&
89 TII->getRegisterInfo().getRegSizeInBits(Reg, *MRI) ==
90 ST->getWavefrontSize();
91 }
92
93 // Helpers from lowerPhis that are different between sdag and global-isel.
94
95 virtual void markAsLaneMask(Register DstReg) const = 0;
97 SmallVectorImpl<MachineInstr *> &Vreg1Phis) const = 0;
98 virtual void
100 SmallVectorImpl<Incoming> &Incomings) const = 0;
101 virtual void replaceDstReg(Register NewReg, Register OldReg,
105 const DebugLoc &DL, Register DstReg,
106 Register PrevReg, Register CurReg) = 0;
107 virtual void constrainAsLaneMask(Incoming &In) = 0;
108};
109} // namespace AMDGPU
110} // end namespace llvm
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
AMD GCN specific subclass of TargetSubtarget.
IRTranslator LLVM IR MI
Register Reg
Helper class that detects loops which require us to lower an i1 COPY into bitwise manipulation.
Helper class that determines the relationship between incoming values of a phi in the control flow gr...
bool isLaneMaskReg(Register Reg) const
virtual void replaceDstReg(Register NewReg, Register OldReg, MachineBasicBlock *MBB)=0
MachineBasicBlock::iterator getSaluInsertionAtEnd(MachineBasicBlock &MBB) const
Return a point at the end of the given MBB to insert SALU instructions for lane mask calculation.
bool isConstantLaneMask(Register Reg, bool &Val) const
MachineRegisterInfo::VRegAttrs LaneMaskRegAttrs
void initializeLaneMaskRegisterAttributes(Register LaneMask)
virtual void buildMergeLaneMasks(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DstReg, Register PrevReg, Register CurReg)=0
virtual void getCandidatesForLowering(SmallVectorImpl< MachineInstr * > &Vreg1Phis) const =0
const AMDGPU::LaneMaskConstants * LMC
PhiLoweringHelper(MachineFunction &MF, MachineDominatorTree &DT, MachinePostDominatorTree &PDT)
virtual ~PhiLoweringHelper()=default
DenseSet< Register > PhiRegisters
virtual void markAsLaneMask(Register DstReg) const =0
virtual void constrainAsLaneMask(Incoming &In)=0
virtual void collectIncomingValuesFromPhi(const MachineInstr *MI, SmallVectorImpl< Incoming > &Incomings) const =0
void initializeLaneMaskRegisterAttributes(MachineRegisterInfo::VRegAttrs Attrs)
void mergeIncomingLaneMasks(Register DstReg, MachineBasicBlock &MBB, SmallVectorImpl< Incoming > &Incomings, MachineIDFSSAUpdater &SSAUpdater, LoopFinder &LF, PhiIncomingAnalysis &PIA)
Merge the Incomings lane masks into DstReg, the value owned by MBB.
MachinePostDominatorTree & PDT
A debug info location.
Definition DebugLoc.h:126
Implements a dense probed hash-table based set.
Definition DenseSet.h:281
MachineInstrBundleIterator< MachineInstr > iterator
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Helper class for SSA formation on a set of values defined in multiple blocks.
Definition SSAUpdater.h:39
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Register createLaneMaskReg(MachineRegisterInfo *MRI, MachineRegisterInfo::VRegAttrs LaneMaskRegAttrs)
This is an optimization pass for GlobalISel generic memory operations.
Incoming for lane mask phi as machine instruction, incoming register Reg and incoming block Block are...
MachineBasicBlock * Block
Incoming(Register Reg, MachineBasicBlock *Block, Register UpdatedReg)
All attributes(register class or bank and low-level type) a virtual register can have.