1 // Copyright 2021 The Tint Authors. 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 SRC_INTRINSIC_TABLE_H_ 16 #define SRC_INTRINSIC_TABLE_H_ 17 18 #include <memory> 19 #include <string> 20 #include <vector> 21 22 #include "src/sem/intrinsic.h" 23 24 namespace tint { 25 26 // Forward declarations 27 class ProgramBuilder; 28 29 /// IntrinsicTable is a lookup table of all the WGSL intrinsic functions 30 class IntrinsicTable { 31 public: 32 /// @param builder the program builder 33 /// @return a pointer to a newly created IntrinsicTable 34 static std::unique_ptr<IntrinsicTable> Create(ProgramBuilder& builder); 35 36 /// Destructor 37 virtual ~IntrinsicTable(); 38 39 /// Lookup looks for the intrinsic overload with the given signature, raising 40 /// an error diagnostic if the intrinsic was not found. 41 /// @param type the intrinsic type 42 /// @param args the argument types passed to the intrinsic function 43 /// @param source the source of the intrinsic call 44 /// @return the semantic intrinsic if found, otherwise nullptr 45 virtual const sem::Intrinsic* Lookup( 46 sem::IntrinsicType type, 47 const std::vector<const sem::Type*>& args, 48 const Source& source) = 0; 49 }; 50 51 } // namespace tint 52 53 #endif // SRC_INTRINSIC_TABLE_H_ 54