1 | //===-- HexagonMCExpr.cpp - Hexagon specific MC expression classes |
2 | //----------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #include "HexagonMCExpr.h" |
11 | #include "llvm/MC/MCAsmInfo.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 | |
21 | HexagonMCExpr *HexagonMCExpr::create(MCExpr const *Expr, MCContext &Ctx) { |
22 | return new (Ctx) HexagonMCExpr(Expr); |
23 | } |
24 | |
25 | bool HexagonMCExpr::evaluateAsRelocatableImpl(MCValue &Res, |
26 | const MCAssembler *Asm) const { |
27 | return Expr->evaluateAsRelocatable(Res, Asm); |
28 | } |
29 | |
30 | void HexagonMCExpr::visitUsedExpr(MCStreamer &Streamer) const { |
31 | Streamer.visitUsedExpr(Expr: *Expr); |
32 | } |
33 | |
34 | MCFragment *llvm::HexagonMCExpr::findAssociatedFragment() const { |
35 | return Expr->findAssociatedFragment(); |
36 | } |
37 | |
38 | MCExpr const *HexagonMCExpr::getExpr() const { return Expr; } |
39 | |
40 | void HexagonMCExpr::setMustExtend(bool Val) { |
41 | assert((!Val || !MustNotExtend) && "Extension contradiction" ); |
42 | MustExtend = Val; |
43 | } |
44 | |
45 | bool HexagonMCExpr::mustExtend() const { return MustExtend; } |
46 | void HexagonMCExpr::setMustNotExtend(bool Val) { |
47 | assert((!Val || !MustExtend) && "Extension contradiction" ); |
48 | MustNotExtend = Val; |
49 | } |
50 | bool HexagonMCExpr::mustNotExtend() const { return MustNotExtend; } |
51 | |
52 | bool HexagonMCExpr::s27_2_reloc() const { return S27_2_reloc; } |
53 | void HexagonMCExpr::setS27_2_reloc(bool Val) { |
54 | S27_2_reloc = Val; |
55 | } |
56 | |
57 | HexagonMCExpr::HexagonMCExpr(MCExpr const *Expr) |
58 | : Expr(Expr), MustNotExtend(false), MustExtend(false), S27_2_reloc(false), |
59 | SignMismatch(false) {} |
60 | |
61 | void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const { |
62 | MAI->printExpr(OS, *Expr); |
63 | } |
64 | |
65 | void HexagonMCExpr::setSignMismatch(bool Val) { |
66 | SignMismatch = Val; |
67 | } |
68 | |
69 | bool HexagonMCExpr::signMismatch() const { |
70 | return SignMismatch; |
71 | } |
72 | |