From c15c853c3a4bf16e6065ad326c7279d38dba57db Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 24 Oct 2018 14:04:00 +0000 Subject: [DEBUGINFO, NVPTX] Try to pack bytes data into a single string. Summary: If the target does not support `.asciz` and `.ascii` directives, the strings are represented as bytes and each byte is placed on the new line as a separate byte directive `.b8 `. NVPTX target allows to represent the vector of the data of the same type as a vector, where values are separated using `,` symbol: `.b8 ,,...`. This allows to reduce the size of the final PTX file. Ptxas tool includes ptx files into the resulting binary object, so reducing the size of the PTX file is important. Reviewers: tra, jlebar, echristo Subscribers: jholewinski, llvm-commits Differential Revision: https://reviews.llvm.org/D45822 llvm-svn: 345142 --- llvm/lib/MC/MCStreamer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/lib/MC/MCStreamer.cpp') diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index bfcf6d47..1b704b8 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -72,6 +72,18 @@ void MCTargetStreamer::emitValue(const MCExpr *Value) { Streamer.EmitRawText(OS.str()); } +void MCTargetStreamer::emitRawBytes(StringRef Data) { + const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo(); + const char *Directive = MAI->getData8bitsDirective(); + for (const unsigned char C : Data.bytes()) { + SmallString<128> Str; + raw_svector_ostream OS(Str); + + OS << Directive << (unsigned)C; + Streamer.EmitRawText(OS.str()); + } +} + void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {} MCStreamer::MCStreamer(MCContext &Ctx) -- cgit v1.1