NonUniformVisitor.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //===--- NonUniformVisitor.h - NonUniform Visitor ----------------*- C++ -*-==//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_CLANG_LIB_SPIRV_NONUNIFORMVISITOR_H
  10. #define LLVM_CLANG_LIB_SPIRV_NONUNIFORMVISITOR_H
  11. #include "clang/SPIRV/FeatureManager.h"
  12. #include "clang/SPIRV/SpirvContext.h"
  13. #include "clang/SPIRV/SpirvVisitor.h"
  14. namespace clang {
  15. namespace spirv {
  16. class SpirvBuilder;
  17. /// Propagates the NonUniform decoration. According to the Vulkan Spec:
  18. ///
  19. /// If an instruction loads from or stores to a resource (including atomics and
  20. /// image instructions) and the resource descriptor being accessed is not
  21. /// dynamically uniform, then the operand corresponding to that resource (e.g.
  22. /// the pointer or sampled image operand) must be decorated with NonUniformEXT.
  23. ///
  24. class NonUniformVisitor : public Visitor {
  25. public:
  26. NonUniformVisitor(SpirvContext &spvCtx, const SpirvCodeGenOptions &opts)
  27. : Visitor(opts, spvCtx) {}
  28. bool visit(SpirvLoad *) override;
  29. bool visit(SpirvAccessChain *) override;
  30. bool visit(SpirvUnaryOp *) override;
  31. bool visit(SpirvBinaryOp *) override;
  32. bool visit(SpirvSampledImage *) override;
  33. bool visit(SpirvImageTexelPointer *) override;
  34. bool visit(SpirvAtomic *) override;
  35. using Visitor::visit;
  36. /// The "sink" visit function for all instructions.
  37. ///
  38. /// By default, all other visit instructions redirect to this visit function.
  39. /// So that you want override this visit function to handle all instructions,
  40. /// regardless of their polymorphism.
  41. bool visitInstruction(SpirvInstruction *instr) override { return true; }
  42. private:
  43. };
  44. } // end namespace spirv
  45. } // end namespace clang
  46. #endif // LLVM_CLANG_LIB_SPIRV_NONUNIFORMVISITOR_H