LLVM 19.0.0git
SystemZMCExpr.cpp
Go to the documentation of this file.
1//===-- SystemZMCExpr.cpp - SystemZ specific MC expression classes --------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "SystemZMCExpr.h"
10#include "llvm/MC/MCContext.h"
11using namespace llvm;
12
13#define DEBUG_TYPE "systemzmcexpr"
14
16 MCContext &Ctx) {
17 return new (Ctx) SystemZMCExpr(Kind, Expr);
18}
19
21 switch (static_cast<uint32_t>(getKind())) {
22 case VK_SystemZ_None:
23 return "A";
24 case VK_SystemZ_RCon:
25 return "R";
26 case VK_SystemZ_VCon:
27 return "V";
28 default:
29 llvm_unreachable("Invalid kind");
30 }
31}
32
34 OS << getVariantKindName() << '(';
35 Expr->print(OS, MAI);
36 OS << ')';
37}
38
40 const MCAsmLayout *Layout,
41 const MCFixup *Fixup) const {
42 if (!getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup))
43 return false;
44
45 Res =
46 MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), getKind());
47
48 return true;
49}
PowerPC TLS Dynamic Call Fixup
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
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
Context object for machine code objects.
Definition: MCContext.h:82
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
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:809
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:41
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
This represents an "assembler immediate".
Definition: MCValue.h:36
int64_t getConstant() const
Definition: MCValue.h:43
static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=nullptr, int64_t Val=0, uint32_t RefKind=0)
Definition: MCValue.h:59
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:45
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
StringRef getVariantKindName() const
static const SystemZMCExpr * create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
VariantKind getKind() const
getOpcode - Get the kind of this expression.
Definition: SystemZMCExpr.h:40
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
const MCExpr * getSubExpr() const
getSubExpr - Get the child of this expression.
Definition: SystemZMCExpr.h:43
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