LLVM 22.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 "GCNSubtarget.h"
20
21namespace llvm {
22
23/// Incoming for lane maks phi as machine instruction, incoming register \p Reg
24/// and incoming block \p Block are taken from machine instruction.
25/// \p UpdatedReg (if valid) is \p Reg lane mask merged with another lane mask.
26struct Incoming {
30
33};
34
35Register createLaneMaskReg(MachineRegisterInfo *MRI,
36 MachineRegisterInfo::VRegAttrs LaneMaskRegAttrs);
37
39public:
42 virtual ~PhiLoweringHelper() = default;
43
44protected:
45 bool IsWave32 = false;
46 MachineFunction *MF = nullptr;
50 const GCNSubtarget *ST = nullptr;
51 const SIInstrInfo *TII = nullptr;
53
54#ifndef NDEBUG
56#endif
57
59 unsigned MovOp;
60 unsigned AndOp;
61 unsigned OrOp;
62 unsigned XorOp;
63 unsigned AndN2Op;
64 unsigned OrN2Op;
65
66public:
67 bool lowerPhis();
68 bool isConstantLaneMask(Register Reg, bool &Val) const;
71
74 }
75
76 void
78 LaneMaskRegAttrs = Attrs;
79 }
80
82 return TII->getRegisterInfo().isSGPRReg(*MRI, Reg) &&
83 TII->getRegisterInfo().getRegSizeInBits(Reg, *MRI) ==
85 }
86
87 // Helpers from lowerPhis that are different between sdag and global-isel.
88
89 virtual void markAsLaneMask(Register DstReg) const = 0;
91 SmallVectorImpl<MachineInstr *> &Vreg1Phis) const = 0;
92 virtual void
94 SmallVectorImpl<Incoming> &Incomings) const = 0;
95 virtual void replaceDstReg(Register NewReg, Register OldReg,
99 const DebugLoc &DL, Register DstReg,
100 Register PrevReg, Register CurReg) = 0;
101 virtual void constrainAsLaneMask(Incoming &In) = 0;
102};
103
104} // end namespace llvm
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
AMD GCN specific subclass of TargetSubtarget.
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition: MD5.cpp:58
Register Reg
unsigned getWavefrontSize() const
A debug info location.
Definition: DebugLoc.h:124
Implements a dense probed hash-table based set.
Definition: DenseSet.h:263
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
Definition: MachineInstr.h:72
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
VRegAttrs getVRegAttrs(Register Reg) const
Returns register class or bank and low level type of Reg.
bool isLaneMaskReg(Register Reg) const
virtual ~PhiLoweringHelper()=default
MachineRegisterInfo * MRI
MachineDominatorTree * DT
DenseSet< Register > PhiRegisters
virtual void getCandidatesForLowering(SmallVectorImpl< MachineInstr * > &Vreg1Phis) const =0
MachineFunction * MF
virtual void constrainAsLaneMask(Incoming &In)=0
virtual void collectIncomingValuesFromPhi(const MachineInstr *MI, SmallVectorImpl< Incoming > &Incomings) const =0
virtual void markAsLaneMask(Register DstReg) const =0
MachinePostDominatorTree * PDT
const GCNSubtarget * ST
const SIInstrInfo * TII
void initializeLaneMaskRegisterAttributes(MachineRegisterInfo::VRegAttrs Attrs)
MachineRegisterInfo::VRegAttrs LaneMaskRegAttrs
MachineBasicBlock::iterator getSaluInsertionAtEnd(MachineBasicBlock &MBB) const
Return a point at the end of the given MBB to insert SALU instructions for lane mask calculation.
void initializeLaneMaskRegisterAttributes(Register LaneMask)
bool isConstantLaneMask(Register Reg, bool &Val) const
virtual void buildMergeLaneMasks(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DstReg, Register PrevReg, Register CurReg)=0
virtual void replaceDstReg(Register NewReg, Register OldReg, MachineBasicBlock *MBB)=0
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
const SIRegisterInfo & getRegisterInfo() const
Definition: SIInstrInfo.h:235
bool isSGPRReg(const MachineRegisterInfo &MRI, Register Reg) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Register createLaneMaskReg(MachineRegisterInfo *MRI, MachineRegisterInfo::VRegAttrs LaneMaskRegAttrs)
Incoming for lane maks phi as machine instruction, incoming register Reg and incoming block Block are...
MachineBasicBlock * Block
Incoming(Register Reg, MachineBasicBlock *Block, Register UpdatedReg)
Register UpdatedReg
All attributes(register class or bank and low-level type) a virtual register can have.