1 //=====-- NVPTXTargetStreamer.h - NVPTX Target Streamer ------*- 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 10 #ifndef LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H 11 #define LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H 12 13 #include "llvm/MC/MCStreamer.h" 14 15 namespace llvm { 16 class MCSection; 17 18 /// Implments NVPTX-specific streamer. 19 class NVPTXTargetStreamer : public MCTargetStreamer { 20 private: 21 SmallVector<std::string, 4> DwarfFiles; 22 23 public: 24 NVPTXTargetStreamer(MCStreamer &S); 25 ~NVPTXTargetStreamer() override; 26 27 /// Record DWARF file directives for later output. 28 /// According to PTX ISA, CUDA Toolkit documentation, 11.5.3. Debugging 29 /// Directives: .file 30 /// (http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-file), 31 /// The .file directive is allowed only in the outermost scope, i.e., at the 32 /// same level as kernel and device function declarations. Also, the order of 33 /// the .loc and .file directive does not matter, .file directives may follow 34 /// the .loc directives where the file is referenced. 35 /// LLVM emits .file directives immediately the location debug info is 36 /// emitted, i.e. they may be emitted inside functions. We gather all these 37 /// directives and emit them outside of the sections and, thus, outside of the 38 /// functions. 39 void emitDwarfFileDirective(StringRef Directive) override; 40 void changeSection(const MCSection *CurSection, MCSection *Section, 41 const MCExpr *SubSection, raw_ostream &OS) override; 42 }; 43 44 } // end namespace llvm 45 46 #endif 47