LLVM API Documentation

ARMMCExpr.cpp
Go to the documentation of this file.
00001 //===-- ARMMCExpr.cpp - ARM specific MC expression classes ----------------===//
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 #include "ARMMCExpr.h"
00011 #include "llvm/MC/MCAssembler.h"
00012 #include "llvm/MC/MCContext.h"
00013 using namespace llvm;
00014 
00015 #define DEBUG_TYPE "armmcexpr"
00016 
00017 const ARMMCExpr*
00018 ARMMCExpr::Create(VariantKind Kind, const MCExpr *Expr,
00019                        MCContext &Ctx) {
00020   return new (Ctx) ARMMCExpr(Kind, Expr);
00021 }
00022 
00023 void ARMMCExpr::PrintImpl(raw_ostream &OS) const {
00024   switch (Kind) {
00025   default: llvm_unreachable("Invalid kind!");
00026   case VK_ARM_HI16: OS << ":upper16:"; break;
00027   case VK_ARM_LO16: OS << ":lower16:"; break;
00028   }
00029 
00030   const MCExpr *Expr = getSubExpr();
00031   if (Expr->getKind() != MCExpr::SymbolRef)
00032     OS << '(';
00033   Expr->print(OS);
00034   if (Expr->getKind() != MCExpr::SymbolRef)
00035     OS << ')';
00036 }
00037 
00038 void ARMMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
00039   Streamer.visitUsedExpr(*getSubExpr());
00040 }