NVPTXTargetStreamer.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //=====-- NVPTXTargetStreamer.h - NVPTX Target Streamer ------*- C++ -*--=====//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H
  9. #define LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H
  10. #include "llvm/MC/MCStreamer.h"
  11. namespace llvm {
  12. class MCSection;
  13. /// Implments NVPTX-specific streamer.
  14. class NVPTXTargetStreamer : public MCTargetStreamer {
  15. private:
  16. SmallVector<std::string, 4> DwarfFiles;
  17. bool HasSections = false;
  18. public:
  19. NVPTXTargetStreamer(MCStreamer &S);
  20. ~NVPTXTargetStreamer() override;
  21. /// Outputs the list of the DWARF '.file' directives to the streamer.
  22. void outputDwarfFileDirectives();
  23. /// Close last section.
  24. void closeLastSection();
  25. /// Record DWARF file directives for later output.
  26. /// According to PTX ISA, CUDA Toolkit documentation, 11.5.3. Debugging
  27. /// Directives: .file
  28. /// (http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-file),
  29. /// The .file directive is allowed only in the outermost scope, i.e., at the
  30. /// same level as kernel and device function declarations. Also, the order of
  31. /// the .loc and .file directive does not matter, .file directives may follow
  32. /// the .loc directives where the file is referenced.
  33. /// LLVM emits .file directives immediately the location debug info is
  34. /// emitted, i.e. they may be emitted inside functions. We gather all these
  35. /// directives and emit them outside of the sections and, thus, outside of the
  36. /// functions.
  37. void emitDwarfFileDirective(StringRef Directive) override;
  38. void changeSection(const MCSection *CurSection, MCSection *Section,
  39. const MCExpr *SubSection, raw_ostream &OS) override;
  40. /// Emit the bytes in \p Data into the output.
  41. ///
  42. /// This is used to emit bytes in \p Data as sequence of .byte directives.
  43. void emitRawBytes(StringRef Data) override;
  44. };
  45. class NVPTXAsmTargetStreamer : public NVPTXTargetStreamer {
  46. public:
  47. NVPTXAsmTargetStreamer(MCStreamer &S);
  48. ~NVPTXAsmTargetStreamer() override;
  49. };
  50. } // end namespace llvm
  51. #endif