2
0

fix_func_call_arguments.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #ifndef _VAR_FUNC_CALL_PASS_H
  15. #define _VAR_FUNC_CALL_PASS_H
  16. #include "source/opt/pass.h"
  17. namespace spvtools {
  18. namespace opt {
  19. class FixFuncCallArgumentsPass : public Pass {
  20. public:
  21. FixFuncCallArgumentsPass() {}
  22. const char* name() const override { return "fix-for-funcall-param"; }
  23. Status Process() override;
  24. // Returns true if the module has one one function.
  25. bool ModuleHasASingleFunction();
  26. // Copies from the memory pointed to by |operand_inst| to a new function scope
  27. // variable created before |func_call_inst|, and
  28. // copies the value of the new variable back to the memory pointed to by
  29. // |operand_inst| after |funct_call_inst| Returns the id of
  30. // the new variable.
  31. uint32_t ReplaceAccessChainFuncCallArguments(Instruction* func_call_inst,
  32. Instruction* operand_inst);
  33. // Fix function call |func_call_inst| non memory object arguments
  34. bool FixFuncCallArguments(Instruction* func_call_inst);
  35. IRContext::Analysis GetPreservedAnalyses() override {
  36. return IRContext::kAnalysisTypes;
  37. }
  38. };
  39. } // namespace opt
  40. } // namespace spvtools
  41. #endif // _VAR_FUNC_CALL_PASS_H