xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.cpp (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric //===--------- AVRMCELFStreamer.cpp - AVR subclass of MCELFStreamer -------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file is a stub that parses a MCInst bundle and passes the
100b57cec5SDimitry Andric // instructions on to the real streamer.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric #include "MCTargetDesc/AVRMCELFStreamer.h"
140b57cec5SDimitry Andric #include "llvm/MC/MCContext.h"
150b57cec5SDimitry Andric #include "llvm/MC/MCExpr.h"
160b57cec5SDimitry Andric #include "llvm/MC/MCObjectWriter.h"
17*349cc55cSDimitry Andric #include "llvm/MC/MCSymbol.h"
180b57cec5SDimitry Andric 
19fe6060f1SDimitry Andric #define DEBUG_TYPE "avrmcelfstreamer"
20fe6060f1SDimitry Andric 
210b57cec5SDimitry Andric using namespace llvm;
220b57cec5SDimitry Andric 
emitValueForModiferKind(const MCSymbol * Sym,unsigned SizeInBytes,SMLoc Loc,AVRMCExpr::VariantKind ModifierKind)235ffd83dbSDimitry Andric void AVRMCELFStreamer::emitValueForModiferKind(
240b57cec5SDimitry Andric     const MCSymbol *Sym, unsigned SizeInBytes, SMLoc Loc,
250b57cec5SDimitry Andric     AVRMCExpr::VariantKind ModifierKind) {
260b57cec5SDimitry Andric   MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_AVR_NONE;
270b57cec5SDimitry Andric   if (ModifierKind == AVRMCExpr::VK_AVR_None) {
280b57cec5SDimitry Andric     Kind = MCSymbolRefExpr::VK_AVR_DIFF8;
290b57cec5SDimitry Andric     if (SizeInBytes == SIZE_LONG)
300b57cec5SDimitry Andric       Kind = MCSymbolRefExpr::VK_AVR_DIFF32;
310b57cec5SDimitry Andric     else if (SizeInBytes == SIZE_WORD)
320b57cec5SDimitry Andric       Kind = MCSymbolRefExpr::VK_AVR_DIFF16;
330b57cec5SDimitry Andric   } else if (ModifierKind == AVRMCExpr::VK_AVR_LO8)
340b57cec5SDimitry Andric     Kind = MCSymbolRefExpr::VK_AVR_LO8;
350b57cec5SDimitry Andric   else if (ModifierKind == AVRMCExpr::VK_AVR_HI8)
360b57cec5SDimitry Andric     Kind = MCSymbolRefExpr::VK_AVR_HI8;
370b57cec5SDimitry Andric   else if (ModifierKind == AVRMCExpr::VK_AVR_HH8)
380b57cec5SDimitry Andric     Kind = MCSymbolRefExpr::VK_AVR_HLO8;
395ffd83dbSDimitry Andric   MCELFStreamer::emitValue(MCSymbolRefExpr::create(Sym, Kind, getContext()),
400b57cec5SDimitry Andric                            SizeInBytes, Loc);
410b57cec5SDimitry Andric }
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric namespace llvm {
createAVRELFStreamer(Triple const & TT,MCContext & Context,std::unique_ptr<MCAsmBackend> MAB,std::unique_ptr<MCObjectWriter> OW,std::unique_ptr<MCCodeEmitter> CE)440b57cec5SDimitry Andric MCStreamer *createAVRELFStreamer(Triple const &TT, MCContext &Context,
450b57cec5SDimitry Andric                                  std::unique_ptr<MCAsmBackend> MAB,
460b57cec5SDimitry Andric                                  std::unique_ptr<MCObjectWriter> OW,
470b57cec5SDimitry Andric                                  std::unique_ptr<MCCodeEmitter> CE) {
480b57cec5SDimitry Andric   return new AVRMCELFStreamer(Context, std::move(MAB), std::move(OW),
490b57cec5SDimitry Andric                               std::move(CE));
500b57cec5SDimitry Andric }
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric } // end namespace llvm
53