1616
1717using namespace llvm ;
1818
19- // / Obtain a reference to the global wavefront-size dependent constants
20- // / based on \p wavefrontSize.
21- const GCNLaneMaskConstants *
22- GCNLaneMaskUtils::getConsts (unsigned WavefrontSize) {
23- static const GCNLaneMaskConstants Wave32 = {
24- AMDGPU::EXEC_LO, AMDGPU::VCC_LO, &AMDGPU::SReg_32RegClass,
25- AMDGPU::S_MOV_B32, AMDGPU::S_MOV_B32_term, AMDGPU::S_AND_B32,
26- AMDGPU::S_OR_B32, AMDGPU::S_XOR_B32, AMDGPU::S_ANDN2_B32,
27- AMDGPU::S_ORN2_B32, AMDGPU::S_CSELECT_B32,
28- };
29- static const GCNLaneMaskConstants Wave64 = {
30- AMDGPU::EXEC,
31- AMDGPU::VCC,
32- &AMDGPU::SReg_64RegClass,
33- AMDGPU::S_MOV_B64,
34- AMDGPU::S_MOV_B64_term,
35- AMDGPU::S_AND_B64,
36- AMDGPU::S_OR_B64,
37- AMDGPU::S_XOR_B64,
38- AMDGPU::S_ANDN2_B64,
39- AMDGPU::S_ORN2_B64,
40- AMDGPU::S_CSELECT_B64,
41- };
42- assert (WavefrontSize == 32 || WavefrontSize == 64 );
43- return WavefrontSize == 32 ? &Wave32 : &Wave64;
44- }
4519
4620// / Obtain a reference to the global wavefront-size dependent constants
4721// / based on the wavefront-size of \p function.
48- const GCNLaneMaskConstants *GCNLaneMaskUtils::getConsts (MachineFunction &MF) {
49- const GCNSubtarget &ST = MF.getSubtarget <GCNSubtarget>();
50- return getConsts (ST.getWavefrontSize ());
22+ const AMDGPU::LaneMaskConstants &GCNLaneMaskUtils::getConsts (MachineFunction &MF) {
23+ return AMDGPU::LaneMaskConstants::get (MF.getSubtarget <GCNSubtarget>());
5124}
5225
5326// / Check whether the register could be a lane-mask register.
@@ -90,7 +63,7 @@ bool GCNLaneMaskUtils::isConstantLaneMask(Register Reg, bool &Val) const {
9063 return false ;
9164 }
9265
93- if (MI->getOpcode () != Constants->OpMov )
66+ if (MI->getOpcode () != Constants->MovOpc )
9467 return false ;
9568
9669 if (!MI->getOperand (1 ).isImm ())
@@ -112,7 +85,7 @@ bool GCNLaneMaskUtils::isConstantLaneMask(Register Reg, bool &Val) const {
11285// / Create a virtual lanemask register.
11386Register GCNLaneMaskUtils::createLaneMaskReg () const {
11487 MachineRegisterInfo &MRI = MF->getRegInfo ();
115- return MRI.createVirtualRegister (Constants->RegClass );
88+ return MRI.createVirtualRegister (Constants->SRegClass );
11689}
11790
11891// / Insert the moral equivalent of
@@ -155,10 +128,10 @@ void GCNLaneMaskUtils::buildMergeLaneMasks(MachineBasicBlock &MBB,
155128 } else if (CurVal) {
156129 // If PrevReg is undef, prefer to propagate a full constant.
157130 BuildMI (MBB, I, DL, TII->get (AMDGPU::COPY), DstReg)
158- .addReg (PrevReg ? Constants->RegExec : CurReg);
131+ .addReg (PrevReg ? Constants->ExecReg : CurReg);
159132 } else {
160- BuildMI (MBB, I, DL, TII->get (Constants->OpXor ), DstReg)
161- .addReg (Constants->RegExec )
133+ BuildMI (MBB, I, DL, TII->get (Constants->XorOpc ), DstReg)
134+ .addReg (Constants->ExecReg )
162135 .addImm (-1 );
163136 }
164137 return ;
@@ -174,9 +147,9 @@ void GCNLaneMaskUtils::buildMergeLaneMasks(MachineBasicBlock &MBB,
174147 } else {
175148 PrevMaskedReg = createLaneMaskReg ();
176149 PrevMaskedBuilt =
177- BuildMI (MBB, I, DL, TII->get (Constants->OpAndN2 ), PrevMaskedReg)
150+ BuildMI (MBB, I, DL, TII->get (Constants->AndN2Opc ), PrevMaskedReg)
178151 .addReg (PrevReg)
179- .addReg (Constants->RegExec );
152+ .addReg (Constants->ExecReg );
180153 }
181154 }
182155 if (!CurConstant) {
@@ -186,9 +159,9 @@ void GCNLaneMaskUtils::buildMergeLaneMasks(MachineBasicBlock &MBB,
186159 } else {
187160 CurMaskedReg = createLaneMaskReg ();
188161 CurMaskedBuilt =
189- BuildMI (MBB, I, DL, TII->get (Constants->OpAnd ), CurMaskedReg)
162+ BuildMI (MBB, I, DL, TII->get (Constants->AndOpc ), CurMaskedReg)
190163 .addReg (CurReg)
191- .addReg (Constants->RegExec );
164+ .addReg (Constants->ExecReg );
192165 }
193166 }
194167
@@ -208,13 +181,13 @@ void GCNLaneMaskUtils::buildMergeLaneMasks(MachineBasicBlock &MBB,
208181 BuildMI (MBB, I, DL, TII->get (AMDGPU::COPY), DstReg).addReg (PrevMaskedReg);
209182 }
210183 } else if (PrevConstant && PrevVal) {
211- BuildMI (MBB, I, DL, TII->get (Constants->OpOrN2 ), DstReg)
184+ BuildMI (MBB, I, DL, TII->get (Constants->OrN2Opc ), DstReg)
212185 .addReg (CurMaskedReg)
213- .addReg (Constants->RegExec );
186+ .addReg (Constants->ExecReg );
214187 } else {
215- BuildMI (MBB, I, DL, TII->get (Constants->OpOr ), DstReg)
188+ BuildMI (MBB, I, DL, TII->get (Constants->OrOpc ), DstReg)
216189 .addReg (PrevMaskedReg)
217- .addReg (CurMaskedReg ? CurMaskedReg : Constants->RegExec );
190+ .addReg (CurMaskedReg ? CurMaskedReg : Constants->ExecReg );
218191 }
219192}
220193
@@ -229,7 +202,7 @@ bool GCNLaneMaskAnalysis::isSubsetOfExec(Register Reg,
229202
230203 for (;;) {
231204 if (!Register::isVirtualRegister (Reg)) {
232- if (Reg == LMU.consts ().RegExec &&
205+ if (Reg == LMU.consts ().ExecReg &&
233206 (!DefInstr || DefInstr->getParent () == &UseBlock))
234207 return true ;
235208 return false ;
@@ -241,7 +214,7 @@ bool GCNLaneMaskAnalysis::isSubsetOfExec(Register Reg,
241214 continue ;
242215 }
243216
244- if (DefInstr->getOpcode () == LMU.consts ().OpMov ) {
217+ if (DefInstr->getOpcode () == LMU.consts ().MovOpc ) {
245218 if (DefInstr->getOperand (1 ).isImm () &&
246219 DefInstr->getOperand (1 ).getImm () == 0 )
247220 return true ;
@@ -268,11 +241,11 @@ bool GCNLaneMaskAnalysis::isSubsetOfExec(Register Reg,
268241 if (!RemainingDepth--)
269242 return false ;
270243
271- bool LikeOr = DefInstr->getOpcode () == LMU.consts ().OpOr ||
272- DefInstr->getOpcode () == LMU.consts ().OpXor ||
273- DefInstr->getOpcode () == LMU.consts ().OpCSelect ;
274- bool IsAnd = DefInstr->getOpcode () == LMU.consts ().OpAnd ;
275- bool IsAndN2 = DefInstr->getOpcode () == LMU.consts ().OpAndN2 ;
244+ bool LikeOr = DefInstr->getOpcode () == LMU.consts ().OrOpc ||
245+ DefInstr->getOpcode () == LMU.consts ().XorOpc ||
246+ DefInstr->getOpcode () == LMU.consts ().CSelectOpc ;
247+ bool IsAnd = DefInstr->getOpcode () == LMU.consts ().AndOpc ;
248+ bool IsAndN2 = DefInstr->getOpcode () == LMU.consts ().AndN2Opc ;
276249 if ((LikeOr || IsAnd || IsAndN2) &&
277250 (DefInstr->getOperand (1 ).isReg () && DefInstr->getOperand (2 ).isReg ())) {
278251 bool FirstIsSubset = isSubsetOfExec (DefInstr->getOperand (1 ).getReg (),
@@ -301,7 +274,7 @@ bool GCNLaneMaskAnalysis::isSubsetOfExec(Register Reg,
301274void GCNLaneMaskUpdater::init (Register Reg) {
302275 Processed = false ;
303276 Blocks.clear ();
304- // SSAUpdater.Initialize(LMU.consts().RegClass );
277+ // SSAUpdater.Initialize(LMU.consts().SRegClass );
305278 SSAUpdater.Initialize (Reg);
306279}
307280
@@ -451,7 +424,7 @@ void GCNLaneMaskUpdater::process() {
451424 // Prepare an all-zero value for the default and reset in accumulating mode.
452425 if (Accumulating && !ZeroReg) {
453426 ZeroReg = LMU.createLaneMaskReg ();
454- BuildMI (Entry, Entry.getFirstTerminator (), {}, TII->get (LMU.consts ().OpMov ),
427+ BuildMI (Entry, Entry.getFirstTerminator (), {}, TII->get (LMU.consts ().MovOpc ),
455428 ZeroReg)
456429 .addImm (0 );
457430 }
0 commit comments