1 // Copyright (c) 2017 The Khronos Group Inc. 2 // Copyright (c) 2017 Valve Corporation 3 // Copyright (c) 2017 LunarG Inc. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 #ifndef SOURCE_OPT_INLINE_OPAQUE_PASS_H_ 18 #define SOURCE_OPT_INLINE_OPAQUE_PASS_H_ 19 20 #include <algorithm> 21 #include <list> 22 #include <memory> 23 #include <unordered_map> 24 #include <vector> 25 26 #include "source/opt/def_use_manager.h" 27 #include "source/opt/inline_pass.h" 28 #include "source/opt/module.h" 29 30 namespace spvtools { 31 namespace opt { 32 33 // See optimizer.hpp for documentation. 34 class InlineOpaquePass : public InlinePass { 35 public: 36 InlineOpaquePass(); 37 Status Process() override; 38 name()39 const char* name() const override { return "inline-entry-points-opaque"; } 40 41 private: 42 // Return true if |typeId| is or contains opaque type 43 bool IsOpaqueType(uint32_t typeId); 44 45 // Return true if function call |callInst| has opaque argument or return type 46 bool HasOpaqueArgsOrReturn(const Instruction* callInst); 47 48 // Inline all function calls in |func| that have opaque params or return 49 // type. Inline similarly all code that is inlined into func. Return true 50 // if func is modified. 51 Status InlineOpaque(Function* func); 52 53 void Initialize(); 54 Pass::Status ProcessImpl(); 55 }; 56 57 } // namespace opt 58 } // namespace spvtools 59 60 #endif // SOURCE_OPT_INLINE_OPAQUE_PASS_H_ 61