LLVM 24.0.0git
NVPTXTargetStreamer.h
Go to the documentation of this file.
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
9#ifndef LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H
10#define LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/MC/MCStreamer.h"
14#include <optional>
15
16namespace llvm {
17class MCSection;
18class MCSymbol;
20
21/// Implments NVPTX-specific streamer.
23private:
25 bool HasSections = false;
26
27public:
30
31 /// Emit the banner which specifies details of PTX generator.
32 virtual void emitBanner() {}
33
34 /// Emit the PTX ISA version number.
35 virtual void emitVersionDirective(unsigned PTXVersion) {}
36
37 /// Emit architecture and platform target.
38 virtual void emitTargetDirective(StringRef Target, bool TexModeIndependent,
39 bool HasDebug) {}
40
41 /// Emit address size used for this PTX module.
42 virtual void emitAddressSizeDirective(unsigned AddrSize) {}
43
44 /// Emit the list of branch targets a brx.idx may jump to.
46
47 /// Declare a register \p SizeInBits wide. \p Count declares a numbered bank
48 /// of that many registers sharing \p Name as their prefix, rather than a
49 /// single register named \p Name.
50 virtual void emitRegDirective(unsigned SizeInBits, StringRef Name,
51 std::optional<unsigned> Count = std::nullopt) {}
52
53 /// Declare \p Size bytes of local (stack) memory named \p Name.
54 virtual void emitLocalDirective(Align Alignment, const MCSymbol *Name,
55 uint64_t Size) {}
56
57 /// Emit an alias from \p Name to \p Aliasee.
58 virtual void emitAliasDirective(const MCSymbol *Name,
59 const MCSymbol *Aliasee) {}
60
61 /// Emit a pragma governing the code that follows it.
62 virtual void emitPragmaDirective(StringRef Pragma) {}
63
64 /// Emit a section with an empty body.
66
67 /// Outputs the list of the DWARF '.file' directives to the streamer.
69 /// Close last section.
70 void closeLastSection();
71
72 /// Record DWARF file directives for later output.
73 /// According to PTX ISA, CUDA Toolkit documentation, 11.5.3. Debugging
74 /// Directives: .file
75 /// (http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-file),
76 /// The .file directive is allowed only in the outermost scope, i.e., at the
77 /// same level as kernel and device function declarations. Also, the order of
78 /// the .loc and .file directive does not matter, .file directives may follow
79 /// the .loc directives where the file is referenced.
80 /// LLVM emits .file directives immediately the location debug info is
81 /// emitted, i.e. they may be emitted inside functions. We gather all these
82 /// directives and emit them outside of the sections and, thus, outside of the
83 /// functions.
85 void changeSection(const MCSection *CurSection, MCSection *Section,
86 uint32_t SubSection, raw_ostream &OS) override;
87 /// Emit the bytes in \p Data into the output.
88 ///
89 /// This is used to emit bytes in \p Data as sequence of .byte directives.
90 void emitRawBytes(StringRef Data) override;
91 /// Makes sure that labels are mangled the same way as the actual symbols.
92 void emitValue(const MCExpr *Value) override;
93};
94
97
98public:
101
102 void emitBanner() override;
103
104 void emitVersionDirective(unsigned PTXVersion) override;
105
106 void emitTargetDirective(StringRef Target, bool TexModeIndependent,
107 bool HasDebug) override;
108
109 void emitAddressSizeDirective(unsigned AddrSize) override;
110
112
113 void emitRegDirective(unsigned SizeInBits, StringRef Name,
114 std::optional<unsigned> Count) override;
115
116 void emitLocalDirective(Align Alignment, const MCSymbol *Name,
117 uint64_t Size) override;
118
119 void emitAliasDirective(const MCSymbol *Name,
120 const MCSymbol *Aliasee) override;
121
122 void emitPragmaDirective(StringRef Pragma) override;
123
124 void emitEmptySectionDirective(StringRef Name) override;
125};
126
127} // end namespace llvm
128
129#endif
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:573
Streaming machine code generation interface.
Definition MCStreamer.h:222
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
MCTargetStreamer(MCStreamer &S)
void emitBanner() override
Emit the banner which specifies details of PTX generator.
void emitVersionDirective(unsigned PTXVersion) override
Emit the PTX ISA version number.
void emitTargetDirective(StringRef Target, bool TexModeIndependent, bool HasDebug) override
Emit architecture and platform target.
void emitPragmaDirective(StringRef Pragma) override
Emit a pragma governing the code that follows it.
void emitBranchTargetsDirective(ArrayRef< const MCSymbol * > Targets) override
Emit the list of branch targets a brx.idx may jump to.
void emitRegDirective(unsigned SizeInBits, StringRef Name, std::optional< unsigned > Count) override
Declare a register SizeInBits wide.
void emitEmptySectionDirective(StringRef Name) override
Emit a section with an empty body.
void emitLocalDirective(Align Alignment, const MCSymbol *Name, uint64_t Size) override
Declare Size bytes of local (stack) memory named Name.
void emitAddressSizeDirective(unsigned AddrSize) override
Emit address size used for this PTX module.
void emitAliasDirective(const MCSymbol *Name, const MCSymbol *Aliasee) override
Emit an alias from Name to Aliasee.
NVPTXAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS)
virtual void emitRegDirective(unsigned SizeInBits, StringRef Name, std::optional< unsigned > Count=std::nullopt)
Declare a register SizeInBits wide.
void emitDwarfFileDirective(StringRef Directive) override
Record DWARF file directives for later output.
virtual void emitAliasDirective(const MCSymbol *Name, const MCSymbol *Aliasee)
Emit an alias from Name to Aliasee.
virtual void emitTargetDirective(StringRef Target, bool TexModeIndependent, bool HasDebug)
Emit architecture and platform target.
virtual void emitVersionDirective(unsigned PTXVersion)
Emit the PTX ISA version number.
virtual void emitBranchTargetsDirective(ArrayRef< const MCSymbol * > Targets)
Emit the list of branch targets a brx.idx may jump to.
virtual void emitBanner()
Emit the banner which specifies details of PTX generator.
virtual void emitAddressSizeDirective(unsigned AddrSize)
Emit address size used for this PTX module.
void outputDwarfFileDirectives()
Outputs the list of the DWARF '.file' directives to the streamer.
void emitRawBytes(StringRef Data) override
Emit the bytes in Data into the output.
virtual void emitLocalDirective(Align Alignment, const MCSymbol *Name, uint64_t Size)
Declare Size bytes of local (stack) memory named Name.
void changeSection(const MCSection *CurSection, MCSection *Section, uint32_t SubSection, raw_ostream &OS) override
Update streamer for a new active section.
virtual void emitEmptySectionDirective(StringRef Name)
Emit a section with an empty body.
void emitValue(const MCExpr *Value) override
Makes sure that labels are mangled the same way as the actual symbols.
void closeLastSection()
Close last section.
virtual void emitPragmaDirective(StringRef Pragma)
Emit a pragma governing the code that follows it.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Target - Wrapper for Target specific information.
LLVM Value Representation.
Definition Value.h:75
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39