1 // Copyright (c) 2022 Advanced Micro Devices, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef _VAR_FUNC_CALL_PASS_H 16 #define _VAR_FUNC_CALL_PASS_H 17 18 #include "source/opt/pass.h" 19 20 namespace spvtools { 21 namespace opt { 22 class FixFuncCallArgumentsPass : public Pass { 23 public: FixFuncCallArgumentsPass()24 FixFuncCallArgumentsPass() {} name()25 const char* name() const override { return "fix-for-funcall-param"; } 26 Status Process() override; 27 // Returns true if the module has one one function. 28 bool ModuleHasASingleFunction(); 29 // Copies from the memory pointed to by |operand_inst| to a new function scope 30 // variable created before |func_call_inst|, and 31 // copies the value of the new variable back to the memory pointed to by 32 // |operand_inst| after |funct_call_inst| Returns the id of 33 // the new variable. 34 uint32_t ReplaceAccessChainFuncCallArguments(Instruction* func_call_inst, 35 Instruction* operand_inst); 36 37 // Fix function call |func_call_inst| non memory object arguments 38 bool FixFuncCallArguments(Instruction* func_call_inst); 39 GetPreservedAnalyses()40 IRContext::Analysis GetPreservedAnalyses() override { 41 return IRContext::kAnalysisTypes; 42 } 43 }; 44 } // namespace opt 45 } // namespace spvtools 46 47 #endif // _VAR_FUNC_CALL_PASS_H