// Copyright (c) 2016 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "source/opt/fold_spec_constant_op_and_composite_pass.h" #include <algorithm> #include <tuple> #include "source/opt/constants.h" #include "source/util/make_unique.h" namespace spvtools { namespace opt { Pass::Status FoldSpecConstantOpAndCompositePass::Process() { … } bool FoldSpecConstantOpAndCompositePass::ProcessOpSpecConstantOp( Module::inst_iterator* pos) { … } Instruction* FoldSpecConstantOpAndCompositePass::FoldWithInstructionFolder( Module::inst_iterator* inst_iter_ptr) { … } namespace { // A helper function to check the type for component wise operations. Returns // true if the type: // 1) is bool type; // 2) is 32-bit int type; // 3) is vector of bool type; // 4) is vector of 32-bit integer type. // Otherwise returns false. bool IsValidTypeForComponentWiseOperation(const analysis::Type* type) { … } // Encodes the integer |value| of in a word vector format appropriate for // representing this value as a operands for a constant definition. Performs // zero-extension/sign-extension/truncation when needed, based on the signess of // the given target type. // // Note: type |type| argument must be either Integer or Bool. utils::SmallVector<uint32_t, 2> EncodeIntegerAsWords(const analysis::Type& type, uint32_t value) { … } } // namespace Instruction* FoldSpecConstantOpAndCompositePass::DoComponentWiseOperation( Module::inst_iterator* pos) { … } } // namespace opt } // namespace spvtools