blob: c60ea7a92e6f268c3b528333795f95b06ca4296c [file] [log] [blame]
Dylan McKayba233432017-12-09 08:01:28 +00001//===--------- AVRMCELFStreamer.cpp - AVR subclass of MCELFStreamer -------===//
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// This file is a stub that parses a MCInst bundle and passes the
11// instructions on to the real streamer.
12//
13//===----------------------------------------------------------------------===//
14#define DEBUG_TYPE "avrmcelfstreamer"
15
16#include "MCTargetDesc/AVRMCELFStreamer.h"
17#include "llvm/MC/MCContext.h"
18#include "llvm/MC/MCExpr.h"
19#include "llvm/MC/MCSymbol.h"
20
21using namespace llvm;
22
23void AVRMCELFStreamer::EmitValueForModiferKind(
24 const MCSymbol *Sym, unsigned SizeInBytes, SMLoc Loc,
25 AVRMCExpr::VariantKind ModifierKind) {
26 MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_AVR_NONE;
27 if (ModifierKind == AVRMCExpr::VK_AVR_None) {
28 Kind = MCSymbolRefExpr::VK_AVR_DIFF8;
29 if (SizeInBytes == SIZE_LONG)
30 Kind = MCSymbolRefExpr::VK_AVR_DIFF32;
31 else if (SizeInBytes == SIZE_WORD)
32 Kind = MCSymbolRefExpr::VK_AVR_DIFF16;
33 } else if (ModifierKind == AVRMCExpr::VK_AVR_LO8)
34 Kind = MCSymbolRefExpr::VK_AVR_LO8;
35 else if (ModifierKind == AVRMCExpr::VK_AVR_HI8)
36 Kind = MCSymbolRefExpr::VK_AVR_HI8;
37 else if (ModifierKind == AVRMCExpr::VK_AVR_HH8)
38 Kind = MCSymbolRefExpr::VK_AVR_HLO8;
39 MCELFStreamer::EmitValue(MCSymbolRefExpr::create(Sym, Kind, getContext()),
40 SizeInBytes, Loc);
41}
42
43namespace llvm {
44MCStreamer *createAVRELFStreamer(Triple const &TT, MCContext &Context,
45 std::unique_ptr<MCAsmBackend> MAB,
46 raw_pwrite_stream &OS,
47 std::unique_ptr<MCCodeEmitter> CE) {
48 return new AVRMCELFStreamer(Context, std::move(MAB), OS, std::move(CE));
49}
50
51} // end namespace llvm