1 /* 2 * Copyright 2017, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef RSOV_COMPILER_SPIRIT_PASS_H 18 #define RSOV_COMPILER_SPIRIT_PASS_H 19 20 #include <stdint.h> 21 22 #include <vector> 23 24 namespace android { 25 namespace spirit { 26 27 class Module; 28 29 // The base class for a pass, either an analysis or a transformation of a 30 // Module. An instanace of a derived class can be added to a PassQueue and 31 // applied to a Module, and produce a result Module with other passes. 32 class Pass { 33 public: 34 virtual ~Pass() {} 35 36 // Runs the pass on the input module and returns the result module. 37 // If argument error is not null, set the error code. On a successful run, 38 // error code is set to zero. 39 virtual Module *run(Module *module, int *error); 40 41 // Runs the pass on the input module, serializes the result module, and 42 // returns the words as a vector. 43 // If argument error is not null, set the error code. On a successful run, 44 // error code is set to zero. 45 virtual std::vector<uint32_t> runAndSerialize(Module *module, int *error); 46 }; 47 48 } // namespace spirit 49 } // namespace android 50 51 #endif // RSOV_COMPILER_SPIRIT_PASS_H 52