LLVM API Documentation

ARMAsmBackend.h
Go to the documentation of this file.
00001 //===-- ARMAsmBackend.h - ARM Assembler Backend -----------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
00011 #define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
00012 
00013 #include "MCTargetDesc/ARMFixupKinds.h"
00014 #include "llvm/MC/MCAsmBackend.h"
00015 #include "llvm/MC/MCSubtargetInfo.h"
00016 
00017 using namespace llvm;
00018 
00019 namespace {
00020 
00021 class ARMAsmBackend : public MCAsmBackend {
00022   const MCSubtargetInfo *STI;
00023   bool isThumbMode;    // Currently emitting Thumb code.
00024   bool IsLittleEndian; // Big or little endian.
00025 public:
00026   ARMAsmBackend(const Target &T, StringRef TT, bool IsLittle)
00027       : MCAsmBackend(), STI(ARM_MC::createARMMCSubtargetInfo(TT, "", "")),
00028         isThumbMode(TT.startswith("thumb")), IsLittleEndian(IsLittle) {}
00029 
00030   ~ARMAsmBackend() override { delete STI; }
00031 
00032   unsigned getNumFixupKinds() const override {
00033     return ARM::NumTargetFixupKinds;
00034   }
00035 
00036   bool hasNOP() const { return (STI->getFeatureBits() & ARM::HasV6T2Ops) != 0; }
00037 
00038   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
00039 
00040   /// processFixupValue - Target hook to process the literal value of a fixup
00041   /// if necessary.
00042   void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
00043                          const MCFixup &Fixup, const MCFragment *DF,
00044                          const MCValue &Target, uint64_t &Value,
00045                          bool &IsResolved) override;
00046 
00047   void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
00048                   uint64_t Value, bool IsPCRel) const override;
00049 
00050   bool mayNeedRelaxation(const MCInst &Inst) const override;
00051 
00052   bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
00053                             const MCRelaxableFragment *DF,
00054                             const MCAsmLayout &Layout) const override;
00055 
00056   void relaxInstruction(const MCInst &Inst, MCInst &Res) const override;
00057 
00058   bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
00059 
00060   void handleAssemblerFlag(MCAssemblerFlag Flag) override;
00061 
00062   unsigned getPointerSize() const { return 4; }
00063   bool isThumb() const { return isThumbMode; }
00064   void setIsThumb(bool it) { isThumbMode = it; }
00065   bool isLittle() const { return IsLittleEndian; }
00066 };
00067 } // end anonymous namespace
00068 
00069 #endif