LLVM 22.0.0git
HexagonMCExpr.cpp
Go to the documentation of this file.
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"
16
17using namespace llvm;
18
19#define DEBUG_TYPE "hexagon-mcexpr"
20
21HexagonMCExpr *HexagonMCExpr::create(MCExpr const *Expr, MCContext &Ctx) {
22 return new (Ctx) HexagonMCExpr(Expr);
23}
24
26 const MCAssembler *Asm) const {
27 return Expr->evaluateAsRelocatable(Res, Asm);
28}
29
31 Streamer.visitUsedExpr(*Expr);
32}
33
35 return Expr->findAssociatedFragment();
36}
37
38MCExpr const *HexagonMCExpr::getExpr() const { return Expr; }
39
41 assert((!Val || !MustNotExtend) && "Extension contradiction");
42 MustExtend = Val;
43}
44
45bool HexagonMCExpr::mustExtend() const { return MustExtend; }
47 assert((!Val || !MustExtend) && "Extension contradiction");
48 MustNotExtend = Val;
49}
50bool HexagonMCExpr::mustNotExtend() const { return MustNotExtend; }
51
52bool HexagonMCExpr::s27_2_reloc() const { return S27_2_reloc; }
54 S27_2_reloc = Val;
55}
56
57HexagonMCExpr::HexagonMCExpr(MCExpr const *Expr)
58 : Expr(Expr), MustNotExtend(false), MustExtend(false), S27_2_reloc(false),
59 SignMismatch(false) {}
60
61void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
62 MAI->printExpr(OS, *Expr);
63}
64
66 SignMismatch = Val;
67}
68
70 return SignMismatch;
71}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
void setMustNotExtend(bool Val=true)
bool mustNotExtend() const
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
bool signMismatch() const
bool mustExtend() const
static HexagonMCExpr * create(MCExpr const *Expr, MCContext &Ctx)
bool s27_2_reloc() const
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const override
void setMustExtend(bool Val=true)
MCFragment * findAssociatedFragment() const override
MCExpr const * getExpr() const
void setS27_2_reloc(bool Val=true)
void setSignMismatch(bool Val=true)
void visitUsedExpr(MCStreamer &Streamer) const override
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
void printExpr(raw_ostream &, const MCExpr &) const
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Streaming machine code generation interface.
Definition MCStreamer.h:220
void visitUsedExpr(const MCExpr &Expr)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.