1 /*========================== begin_copyright_notice ============================ 2 3 Copyright (C) 2017-2021 Intel Corporation 4 5 SPDX-License-Identifier: MIT 6 7 ============================= end_copyright_notice ===========================*/ 8 9 #pragma once 10 11 #include "Compiler/MetaDataUtilsWrapper.h" 12 #include "Compiler/CodeGenContextWrapper.hpp" 13 #include "Compiler/Optimizer/OpenCLPasses/ExtenstionFuncs/ExtensionArgAnalysis.hpp" 14 15 #include "common/LLVMWarningsPush.hpp" 16 #include <llvm/Pass.h> 17 #include <llvm/IR/DataLayout.h> 18 #include "common/LLVMWarningsPop.hpp" 19 20 namespace IGC 21 { 22 /// @brief This pass allocates UAV and SRV numbers to kernel arguments. 23 class ResourceAllocator : public llvm::ModulePass 24 { 25 public: 26 // Pass identification, replacement for typeid 27 static char ID; 28 29 /// @brief Constructor 30 ResourceAllocator(); 31 32 /// @brief Destructor ~ResourceAllocator()33 ~ResourceAllocator() {} 34 35 /// @brief Provides name of pass getPassName() const36 virtual llvm::StringRef getPassName() const override 37 { 38 return "ResourceAllocatorPass"; 39 } 40 getAnalysisUsage(llvm::AnalysisUsage & AU) const41 virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override 42 { 43 AU.setPreservesCFG(); 44 AU.addRequired<MetaDataUtilsWrapper>(); 45 AU.addRequired<ExtensionArgAnalysis>(); 46 AU.addRequired<CodeGenContextWrapper>(); 47 } 48 49 /// @brief Main entry point. 50 /// @param M The destination module. 51 virtual bool runOnModule(llvm::Module& M) override; 52 53 protected: 54 55 bool runOnFunction(llvm::Function& F); 56 }; 57 58 } // namespace IGC 59