xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelDivergenceLowering.cpp (revision 5b56413d04e608379c9a306373554a8e4d321bc0)
1 //===-- AMDGPUGlobalISelDivergenceLowering.cpp ----------------------------===//
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 /// GlobalISel pass that selects divergent i1 phis as lane mask phis.
11 /// Lane mask merging uses same algorithm as SDAG in SILowerI1Copies.
12 /// Handles all cases of temporal divergence.
13 /// For divergent non-phi i1 and uniform i1 uses outside of the cycle this pass
14 /// currently depends on LCSSA to insert phis with one incoming.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #include "AMDGPU.h"
19 #include "llvm/CodeGen/MachineFunctionPass.h"
20 
21 #define DEBUG_TYPE "amdgpu-global-isel-divergence-lowering"
22 
23 using namespace llvm;
24 
25 namespace {
26 
27 class AMDGPUGlobalISelDivergenceLowering : public MachineFunctionPass {
28 public:
29   static char ID;
30 
31 public:
32   AMDGPUGlobalISelDivergenceLowering() : MachineFunctionPass(ID) {
33     initializeAMDGPUGlobalISelDivergenceLoweringPass(
34         *PassRegistry::getPassRegistry());
35   }
36 
37   bool runOnMachineFunction(MachineFunction &MF) override;
38 
39   StringRef getPassName() const override {
40     return "AMDGPU GlobalISel divergence lowering";
41   }
42 
43   void getAnalysisUsage(AnalysisUsage &AU) const override {
44     AU.setPreservesCFG();
45     MachineFunctionPass::getAnalysisUsage(AU);
46   }
47 };
48 
49 } // End anonymous namespace.
50 
51 INITIALIZE_PASS_BEGIN(AMDGPUGlobalISelDivergenceLowering, DEBUG_TYPE,
52                       "AMDGPU GlobalISel divergence lowering", false, false)
53 INITIALIZE_PASS_END(AMDGPUGlobalISelDivergenceLowering, DEBUG_TYPE,
54                     "AMDGPU GlobalISel divergence lowering", false, false)
55 
56 char AMDGPUGlobalISelDivergenceLowering::ID = 0;
57 
58 char &llvm::AMDGPUGlobalISelDivergenceLoweringID =
59     AMDGPUGlobalISelDivergenceLowering::ID;
60 
61 FunctionPass *llvm::createAMDGPUGlobalISelDivergenceLoweringPass() {
62   return new AMDGPUGlobalISelDivergenceLowering();
63 }
64 
65 bool AMDGPUGlobalISelDivergenceLowering::runOnMachineFunction(
66     MachineFunction &MF) {
67   return false;
68 }
69