id_use_descriptor.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2019 Google LLC
  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. #ifndef SOURCE_FUZZ_ID_USE_DESCRIPTOR_H_
  15. #define SOURCE_FUZZ_ID_USE_DESCRIPTOR_H_
  16. #include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
  17. #include "source/opt/ir_context.h"
  18. namespace spvtools {
  19. namespace fuzz {
  20. // Looks for an instruction in |context| that contains a use
  21. // identified by |id_use_descriptor|.
  22. // Returns |nullptr| if no such instruction can be found.
  23. opt::Instruction* FindInstructionContainingUse(
  24. const protobufs::IdUseDescriptor& id_use_descriptor,
  25. opt::IRContext* context);
  26. // Creates an IdUseDescriptor protobuf message from the given components.
  27. // See the protobuf definition for details of what these components mean.
  28. protobufs::IdUseDescriptor MakeIdUseDescriptor(
  29. uint32_t id_of_interest,
  30. const protobufs::InstructionDescriptor& enclosing_instruction,
  31. uint32_t in_operand_index);
  32. // Given an id use, represented by the instruction |inst| that uses the id, and
  33. // the input operand index |in_operand_index| associated with the usage, returns
  34. // an IdUseDescriptor that represents the use.
  35. protobufs::IdUseDescriptor MakeIdUseDescriptorFromUse(
  36. opt::IRContext* context, opt::Instruction* inst, uint32_t in_operand_index);
  37. } // namespace fuzz
  38. } // namespace spvtools
  39. #endif // SOURCE_FUZZ_ID_USE_DESCRIPTOR_H_