Home | History | Annotate | Download | only in MCTargetDesc
      1 //===-- ARMMCExpr.cpp - ARM specific MC expression classes ----------------===//
      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 #include "ARMMCExpr.h"
     11 #include "llvm/MC/MCAssembler.h"
     12 #include "llvm/MC/MCContext.h"
     13 using namespace llvm;
     14 
     15 #define DEBUG_TYPE "armmcexpr"
     16 
     17 const ARMMCExpr*
     18 ARMMCExpr::Create(VariantKind Kind, const MCExpr *Expr,
     19                        MCContext &Ctx) {
     20   return new (Ctx) ARMMCExpr(Kind, Expr);
     21 }
     22 
     23 void ARMMCExpr::PrintImpl(raw_ostream &OS) const {
     24   switch (Kind) {
     25   default: llvm_unreachable("Invalid kind!");
     26   case VK_ARM_HI16: OS << ":upper16:"; break;
     27   case VK_ARM_LO16: OS << ":lower16:"; break;
     28   }
     29 
     30   const MCExpr *Expr = getSubExpr();
     31   if (Expr->getKind() != MCExpr::SymbolRef)
     32     OS << '(';
     33   Expr->print(OS);
     34   if (Expr->getKind() != MCExpr::SymbolRef)
     35     OS << ')';
     36 }
     37 
     38 bool
     39 ARMMCExpr::EvaluateAsRelocatableImpl(MCValue &Res,
     40                                      const MCAsmLayout *Layout) const {
     41   return false;
     42 }
     43 
     44 void ARMMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
     45   Streamer.visitUsedExpr(*getSubExpr());
     46 }
     47