1 //===-- HexagonMCExpr.cpp - Hexagon specific MC expression classes
2 //----------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #include "HexagonMCExpr.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCStreamer.h"
14 #include "llvm/MC/MCValue.h"
15 #include "llvm/Support/raw_ostream.h"
16
17 using namespace llvm;
18
19 #define DEBUG_TYPE "hexagon-mcexpr"
20
create(MCExpr const * Expr,MCContext & Ctx)21 HexagonMCExpr *HexagonMCExpr::create(MCExpr const *Expr, MCContext &Ctx) {
22 return new (Ctx) HexagonMCExpr(Expr);
23 }
24
evaluateAsRelocatableImpl(MCValue & Res,MCAsmLayout const * Layout,MCFixup const * Fixup) const25 bool HexagonMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
26 MCAsmLayout const *Layout,
27 MCFixup const *Fixup) const {
28 return Expr->evaluateAsRelocatable(Res, Layout, Fixup);
29 }
30
visitUsedExpr(MCStreamer & Streamer) const31 void HexagonMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
32 Streamer.visitUsedExpr(*Expr);
33 }
34
findAssociatedFragment() const35 MCFragment *llvm::HexagonMCExpr::findAssociatedFragment() const {
36 return Expr->findAssociatedFragment();
37 }
38
fixELFSymbolsInTLSFixups(MCAssembler & Asm) const39 void HexagonMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
40
getExpr() const41 MCExpr const *HexagonMCExpr::getExpr() const { return Expr; }
42
setMustExtend(bool Val)43 void HexagonMCExpr::setMustExtend(bool Val) {
44 assert((!Val || !MustNotExtend) && "Extension contradiction");
45 MustExtend = Val;
46 }
47
mustExtend() const48 bool HexagonMCExpr::mustExtend() const { return MustExtend; }
setMustNotExtend(bool Val)49 void HexagonMCExpr::setMustNotExtend(bool Val) {
50 assert((!Val || !MustExtend) && "Extension contradiction");
51 MustNotExtend = Val;
52 }
mustNotExtend() const53 bool HexagonMCExpr::mustNotExtend() const { return MustNotExtend; }
54
s23_2_reloc() const55 bool HexagonMCExpr::s23_2_reloc() const { return S23_2_reloc; }
setS23_2_reloc(bool Val)56 void HexagonMCExpr::setS23_2_reloc(bool Val) {
57 S23_2_reloc = Val;
58 }
59
classof(MCExpr const * E)60 bool HexagonMCExpr::classof(MCExpr const *E) {
61 return E->getKind() == MCExpr::Target;
62 }
63
HexagonMCExpr(MCExpr const * Expr)64 HexagonMCExpr::HexagonMCExpr(MCExpr const *Expr)
65 : Expr(Expr), MustNotExtend(false), MustExtend(false), S23_2_reloc(false),
66 SignMismatch(false) {}
67
printImpl(raw_ostream & OS,const MCAsmInfo * MAI) const68 void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
69 Expr->print(OS, MAI);
70 }
71
setSignMismatch(bool Val)72 void HexagonMCExpr::setSignMismatch(bool Val) {
73 SignMismatch = Val;
74 }
75
signMismatch() const76 bool HexagonMCExpr::signMismatch() const {
77 return SignMismatch;
78 }