1 //===-- llvm/CodeGen/ByteStreamer.h - ByteStreamer class --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains a class that can take bytes that would normally be
11 // streamed via the AsmPrinter.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_BYTESTREAMER_H
16 #define LLVM_CODEGEN_BYTESTREAMER_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/CodeGen/AsmPrinter.h"
20 #include "llvm/MC/MCStreamer.h"
26 virtual ~ByteStreamer() {}
28 // For now we're just handling the calls we need for dwarf emission/hashing.
29 virtual void EmitInt8(uint8_t Byte, const Twine &Comment = "") = 0;
30 virtual void EmitSLEB128(uint64_t DWord, const Twine &Comment = "") = 0;
31 virtual void EmitULEB128(uint64_t DWord, const Twine &Comment = "") = 0;
34 class APByteStreamer : public ByteStreamer {
39 APByteStreamer(AsmPrinter &Asm) : AP(Asm) {}
40 void EmitInt8(uint8_t Byte, const Twine &Comment) override {
41 AP.OutStreamer.AddComment(Comment);
44 void EmitSLEB128(uint64_t DWord, const Twine &Comment) override {
45 AP.OutStreamer.AddComment(Comment);
46 AP.EmitSLEB128(DWord);
48 void EmitULEB128(uint64_t DWord, const Twine &Comment) override {
49 AP.OutStreamer.AddComment(Comment);
50 AP.EmitULEB128(DWord);
54 class HashingByteStreamer : public ByteStreamer {
58 HashingByteStreamer(DIEHash &H) : Hash(H) {}
59 void EmitInt8(uint8_t Byte, const Twine &Comment) override {
62 void EmitSLEB128(uint64_t DWord, const Twine &Comment) override {
63 Hash.addSLEB128(DWord);
65 void EmitULEB128(uint64_t DWord, const Twine &Comment) override {
66 Hash.addULEB128(DWord);