LLVM 20.0.0git
XtensaMCExpr.cpp
Go to the documentation of this file.
1//===-- XtensaMCExpr.cpp - Xtensa specific MC expression classes ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9//===----------------------------------------------------------------------===//
10//
11// This file contains the implementation of the assembly expression modifiers
12// accepted by the Xtensa architecture
13//
14//===----------------------------------------------------------------------===//
15
16#include "XtensaMCExpr.h"
17#include "llvm/MC/MCAssembler.h"
18#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCStreamer.h"
20#include "llvm/MC/MCSymbolELF.h"
21#include "llvm/MC/MCValue.h"
22#include "llvm/Object/ELF.h"
24
25using namespace llvm;
26
27#define DEBUG_TYPE "xtensamcexpr"
28
30 MCContext &Ctx) {
31 return new (Ctx) XtensaMCExpr(Expr, Kind);
32}
33
35 bool HasVariant = getKind() != VK_Xtensa_None;
36 if (HasVariant)
37 OS << '%' << getVariantKindName(getKind()) << '(';
38 Expr->print(OS, MAI);
39 if (HasVariant)
40 OS << ')';
41}
42
44 const MCAssembler *Asm,
45 const MCFixup *Fixup) const {
46 return getSubExpr()->evaluateAsRelocatable(Res, Asm, Fixup);
47}
48
50 Streamer.visitUsedExpr(*getSubExpr());
51}
52
56}
57
59 switch (Kind) {
60 default:
61 llvm_unreachable("Invalid ELF symbol kind");
62 }
63}
PowerPC TLS Dynamic Call Fixup
static const char * name
Definition: SMEABIPass.cpp:46
raw_pwrite_stream & OS
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
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
bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Definition: MCExpr.cpp:819
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:40
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
Streaming machine code generation interface.
Definition: MCStreamer.h:213
void visitUsedExpr(const MCExpr &Expr)
This represents an "assembler immediate".
Definition: MCValue.h:36
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:44
R Default(T Value)
Definition: StringSwitch.h:182
static const XtensaMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
static VariantKind getVariantKindForName(StringRef name)
VariantKind getKind() const
Definition: XtensaMCExpr.h:38
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
static StringRef getVariantKindName(VariantKind Kind)
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const override
void visitUsedExpr(MCStreamer &Streamer) const override
const MCExpr * getSubExpr() const
Definition: XtensaMCExpr.h:40
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18