Home | History | Annotate | Download | only in MCTargetDesc
      1 //===-- HexagonMCExpr.cpp - Hexagon specific MC expression classes
      2 //----------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is distributed under the University of Illinois Open Source
      7 // License. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 #include "HexagonMCExpr.h"
     12 #include "llvm/MC/MCContext.h"
     13 #include "llvm/MC/MCStreamer.h"
     14 #include "llvm/MC/MCValue.h"
     15 #include "llvm/Support/raw_ostream.h"
     16 
     17 using namespace llvm;
     18 
     19 #define DEBUG_TYPE "hexagon-mcexpr"
     20 
     21 HexagonMCExpr *HexagonMCExpr::create(MCExpr const *Expr, MCContext &Ctx) {
     22   return new (Ctx) HexagonMCExpr(Expr);
     23 }
     24 
     25 bool HexagonMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
     26                                               MCAsmLayout const *Layout,
     27                                               MCFixup const *Fixup) const {
     28   return Expr->evaluateAsRelocatable(Res, Layout, Fixup);
     29 }
     30 
     31 void HexagonMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
     32   Streamer.visitUsedExpr(*Expr);
     33 }
     34 
     35 MCFragment *llvm::HexagonMCExpr::findAssociatedFragment() const {
     36   return Expr->findAssociatedFragment();
     37 }
     38 
     39 void HexagonMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
     40 
     41 MCExpr const *HexagonMCExpr::getExpr() const { return Expr; }
     42 
     43 void HexagonMCExpr::setMustExtend(bool Val) {
     44   assert((!Val || !MustNotExtend) && "Extension contradiction");
     45   MustExtend = Val;
     46 }
     47 
     48 bool HexagonMCExpr::mustExtend() const { return MustExtend; }
     49 void HexagonMCExpr::setMustNotExtend(bool Val) {
     50   assert((!Val || !MustExtend) && "Extension contradiction");
     51   MustNotExtend = Val;
     52 }
     53 bool HexagonMCExpr::mustNotExtend() const { return MustNotExtend; }
     54 
     55 bool HexagonMCExpr::s23_2_reloc() const { return S23_2_reloc; }
     56 void HexagonMCExpr::setS23_2_reloc(bool Val) {
     57   S23_2_reloc = Val;
     58 }
     59 
     60 bool HexagonMCExpr::classof(MCExpr const *E) {
     61   return E->getKind() == MCExpr::Target;
     62 }
     63 
     64 HexagonMCExpr::HexagonMCExpr(MCExpr const *Expr)
     65     : Expr(Expr), MustNotExtend(false), MustExtend(false), S23_2_reloc(false),
     66       SignMismatch(false) {}
     67 
     68 void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
     69   Expr->print(OS, MAI);
     70 }
     71 
     72 void HexagonMCExpr::setSignMismatch(bool Val) {
     73   SignMismatch = Val;
     74 }
     75 
     76 bool HexagonMCExpr::signMismatch() const {
     77   return SignMismatch;
     78 }