LLVM  7.0.0
Nios2MCExpr.cpp
Go to the documentation of this file.
1 //===-- Nios2MCExpr.cpp - Nios2 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 "Nios2.h"
11 
12 #include "Nios2MCExpr.h"
13 #include "llvm/MC/MCAsmInfo.h"
14 #include "llvm/MC/MCAssembler.h"
15 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCSymbolELF.h"
18 
19 using namespace llvm;
20 
21 #define DEBUG_TYPE "nios2mcexpr"
22 
24  const MCExpr *Expr, MCContext &Ctx) {
25  return new (Ctx) Nios2MCExpr(Kind, Expr);
26 }
27 
30  MCContext &Ctx) {
31  const MCSymbolRefExpr *MCSym =
33  return new (Ctx) Nios2MCExpr(Kind, MCSym);
34 }
35 
36 void Nios2MCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
37 
38  switch (Kind) {
39  case CEK_None:
40  case CEK_Special:
41  llvm_unreachable("CEK_None and CEK_Special are invalid");
42  break;
43  case CEK_ABS_HI:
44  OS << "%hiadj";
45  break;
46  case CEK_ABS_LO:
47  OS << "%lo";
48  break;
49  }
50 
51  OS << '(';
52  Expr->print(OS, MAI, true);
53  OS << ')';
54 }
55 
57  const MCAsmLayout *Layout,
58  const MCFixup *Fixup) const {
59  return getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup);
60 }
61 
62 void Nios2MCExpr::visitUsedExpr(MCStreamer &Streamer) const {
63  Streamer.visitUsedExpr(*getSubExpr());
64 }
65 
67  switch (getKind()) {
68  case CEK_None:
69  case CEK_Special:
70  llvm_unreachable("CEK_None and CEK_Special are invalid");
71  break;
72  case CEK_ABS_HI:
73  case CEK_ABS_LO:
74  break;
75  }
76 }
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:321
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
const MCExpr * getSubExpr() const
Get the child of this expression.
Definition: Nios2MCExpr.h:46
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:74
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
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:166
Context object for machine code objects.
Definition: MCContext.h:63
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
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: Nios2MCExpr.cpp:66
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
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: Nios2MCExpr.cpp:62
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: Nios2MCExpr.cpp:56
static const Nios2MCExpr * create(Nios2ExprKind Kind, const MCExpr *Expr, MCContext &Ctx)
Definition: Nios2MCExpr.cpp:23
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:883
const unsigned Kind
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
Nios2ExprKind getKind() const
Get the kind of this expression.
Definition: Nios2MCExpr.h:43
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: Nios2MCExpr.cpp:36