Home | History | Annotate | Download | only in val
      1 // Copyright (c) 2015-2016 The Khronos Group 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 
     15 #include "source/val/instruction.h"
     16 
     17 #include <utility>
     18 
     19 namespace spvtools {
     20 namespace val {
     21 
     22 Instruction::Instruction(const spv_parsed_instruction_t* inst)
     23     : words_(inst->words, inst->words + inst->num_words),
     24       operands_(inst->operands, inst->operands + inst->num_operands),
     25       inst_({words_.data(), inst->num_words, inst->opcode, inst->ext_inst_type,
     26              inst->type_id, inst->result_id, operands_.data(),
     27              inst->num_operands}) {}
     28 
     29 void Instruction::RegisterUse(const Instruction* inst, uint32_t index) {
     30   uses_.push_back(std::make_pair(inst, index));
     31 }
     32 
     33 bool operator<(const Instruction& lhs, const Instruction& rhs) {
     34   return lhs.id() < rhs.id();
     35 }
     36 bool operator<(const Instruction& lhs, uint32_t rhs) { return lhs.id() < rhs; }
     37 bool operator==(const Instruction& lhs, const Instruction& rhs) {
     38   return lhs.id() == rhs.id();
     39 }
     40 bool operator==(const Instruction& lhs, uint32_t rhs) {
     41   return lhs.id() == rhs;
     42 }
     43 
     44 }  // namespace val
     45 }  // namespace spvtools
     46