1//===--------- AVRMCELFStreamer.cpp - AVR subclass of MCELFStreamer -------===//
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// This file is a stub that parses a MCInst bundle and passes the
10// instructions on to the real streamer.
11//
12//===----------------------------------------------------------------------===//
13#include "MCTargetDesc/AVRMCELFStreamer.h"
14#include "llvm/MC/MCContext.h"
15#include "llvm/MC/MCExpr.h"
16#include "llvm/MC/MCObjectWriter.h"
17#include "llvm/MC/MCSymbol.h"
18
19#define DEBUG_TYPE "avrmcelfstreamer"
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(Value: MCSymbolRefExpr::create(Symbol: Sym, Kind, Ctx&: getContext()),
40 Size: SizeInBytes, Loc);
41}
42
43namespace llvm {
44MCStreamer *createAVRELFStreamer(Triple const &TT, MCContext &Context,
45 std::unique_ptr<MCAsmBackend> MAB,
46 std::unique_ptr<MCObjectWriter> OW,
47 std::unique_ptr<MCCodeEmitter> CE) {
48 return new AVRMCELFStreamer(Context, std::move(MAB), std::move(OW),
49 std::move(CE));
50}
51
52} // end namespace llvm
53