LLVM  8.0.1
ARMMCExpr.cpp
Go to the documentation of this file.
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/MCContext.h"
12 #include "llvm/MC/MCStreamer.h"
13 using namespace llvm;
14 
15 #define DEBUG_TYPE "armmcexpr"
16 
17 const ARMMCExpr*
19  MCContext &Ctx) {
20  return new (Ctx) ARMMCExpr(Kind, Expr);
21 }
22 
23 void ARMMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) 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, MAI);
34  if (Expr->getKind() != MCExpr::SymbolRef)
35  OS << ')';
36 }
37 
38 void ARMMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
39  Streamer.visitUsedExpr(*getSubExpr());
40 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
static const ARMMCExpr * create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
Definition: ARMMCExpr.cpp:18
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
Context object for machine code objects.
Definition: MCContext.h:63
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: ARMMCExpr.cpp:38
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Streaming machine code generation interface.
Definition: MCStreamer.h:189
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:42
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ExprKind getKind() const
Definition: MCExpr.h:73
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:930
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: ARMMCExpr.cpp:23
const MCExpr * getSubExpr() const
getSubExpr - Get the child of this expression.
Definition: ARMMCExpr.h:55
References to labels and assigned expressions.
Definition: MCExpr.h:41
const unsigned Kind
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46