LLVM: lib/Target/NVPTX/NVPTXAsmPrinter.h Source File (original) (raw)

63

64 class AggBuffer {

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81 public:

82

83 unsigned numSymbols() const { return Symbols.size(); }

84

85 bool allSymbolsAligned(unsigned ptrSize) const {

87 [=](unsigned pos) { return pos % ptrSize == 0; });

88 }

89

90 private:

91 const unsigned size;

92 std::vector buffer;

95

96

97

98

99

100

101

103 unsigned curpos;

105 const bool EmitGeneric;

106

107 public:

109 : size(size), buffer(size), curpos(0), AP(AP),

110 EmitGeneric(AP.EmitGeneric) {}

111

112

113

114 void addBytes(const unsigned char *Ptr, unsigned Num, unsigned Bytes) {

116 addByte(Ptr[I]);

117 if (Bytes > Num)

118 addZeros(Bytes - Num);

119 }

120

121 void addByte(uint8_t Byte) {

123 buffer[curpos] = Byte;

124 curpos++;

125 }

126

127 void addZeros(unsigned Num) {

128 for ([[maybe_unused]] unsigned _ : llvm::seq(Num)) {

129 addByte(0);

130 }

131 }

132

134 symbolPosInBuffer.push_back(curpos);

135 Symbols.push_back(GVar);

136 SymbolsBeforeStripping.push_back(GVarBeforeStripping);

137 }

138

141

142 private:

143 void printSymbol(unsigned nSym, raw_ostream &os);

144 };

145

146 friend class AggBuffer;

147

148public:

150

152

153private:

155

156 void emitStartOfAsmFile(Module &M) override;

158 void emitFunctionEntryLabel() override;

159 void emitFunctionBodyStart() override;

160 void emitFunctionBodyEnd() override;

161 void emitImplicitDef(const MachineInstr *MI) const override;

162

163 void emitInstruction(const MachineInstr *) override;

167 unsigned encodeVirtualRegister(unsigned Reg);

168

170 const char *Modifier = nullptr);

173 void emitGlobals(const Module &M);

174 void emitGlobalAlias(const Module &M, const GlobalAlias &GA) override;

177 void emitVirtualRegister(unsigned int vr, raw_ostream &);

179 void setAndEmitFunctionVirtualRegisters(const MachineFunction &MF);

180 void encodeDebugInfoRegisterNumbers(const MachineFunction &MF);

183 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,

184 const char *ExtraCode, raw_ostream &) override;

186 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,

187 const char *ExtraCode, raw_ostream &) override;

188

190 bool ProcessingGeneric) const;

192

193protected:

194 bool doInitialization(Module &M) override;

195 bool doFinalization(Module &M) override;

196

197private:

198 bool GlobalsEmitted;

199

200

202

203

204

207 VRegRCMap VRegMapping;

208

209

210 std::map<const Function *, std::vector<const GlobalVariable *>> localDecls;

211

215 std::string getPTXFundamentalTypeStr(Type *Ty, bool = true) const;

218 void bufferLEByte(const Constant *CPV, int Bytes, AggBuffer *aggBuffer);

219 void bufferAggregateConstant(const Constant *CV, AggBuffer *aggBuffer);

220

227

229

230

231

232

233

234

235

236

237

238

239

240

241 const bool EmitGeneric;

242

243public:

248

250

255

256 std::string getVirtualRegisterName(unsigned) const;

257

258 const MCSymbol *getFunctionFrameSymbol() const override;

259

260

261

262

264};