LLVM  7.0.0svn
Go to the documentation of this file.
1 //===-- LanaiMCExpr.cpp - Lanai 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 //===----------------------------------------------------------------------===//
10 #include "LanaiMCExpr.h"
11 #include "llvm/MC/MCAssembler.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCStreamer.h"
14 using namespace llvm;
16 #define DEBUG_TYPE "lanaimcexpr"
19  MCContext &Ctx) {
20  return new (Ctx) LanaiMCExpr(Kind, Expr);
21 }
23 void LanaiMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
24  if (Kind == VK_Lanai_None) {
25  Expr->print(OS, MAI);
26  return;
27  }
29  switch (Kind) {
30  default:
31  llvm_unreachable("Invalid kind!");
32  case VK_Lanai_ABS_HI:
33  OS << "hi";
34  break;
35  case VK_Lanai_ABS_LO:
36  OS << "lo";
37  break;
38  }
40  OS << '(';
41  const MCExpr *Expr = getSubExpr();
42  Expr->print(OS, MAI);
43  OS << ')';
44 }
46 void LanaiMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
47  Streamer.visitUsedExpr(*getSubExpr());
48 }
51  const MCAsmLayout *Layout,
52  const MCFixup *Fixup) const {
53  if (!getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup))
54  return false;
56  Res =
57  MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), getKind());
59  return true;
60 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: LanaiMCExpr.cpp:50
static const LanaiMCExpr * create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
Definition: LanaiMCExpr.cpp:18
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:74
int64_t getConstant() const
Definition: MCValue.h:47
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:49
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
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
const MCExpr * getSubExpr() const
Definition: LanaiMCExpr.h:37
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Definition: MCExpr.cpp:633
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:183
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:42
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: LanaiMCExpr.cpp:23
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:48
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:881
static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=nullptr, int64_t Val=0, uint32_t RefKind=0)
Definition: MCValue.h:63
VariantKind getKind() const
Definition: LanaiMCExpr.h:34
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: LanaiMCExpr.cpp:46
const unsigned Kind
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46