LLVM 22.0.0git
X86MCExpr.h
Go to the documentation of this file.
1//=--- X86MCExpr.h - X86 specific MC expression classes ---*- C++ -*-=//
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// This file describes X86-specific MCExprs, i.e, registers used for
10// extended variable assignments.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCEXPR_H
15#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCEXPR_H
16
17#include "X86ATTInstPrinter.h"
18#include "llvm/MC/MCAsmInfo.h"
19#include "llvm/MC/MCContext.h"
20#include "llvm/MC/MCExpr.h"
23
24namespace llvm {
25
26class X86MCExpr : public MCTargetExpr {
27
28private:
29 const MCRegister Reg; // All
30
31 explicit X86MCExpr(MCRegister R) : Reg(R) {}
32
33public:
34 static const X86MCExpr *create(MCRegister Reg, MCContext &Ctx) {
35 return new (Ctx) X86MCExpr(Reg);
36 }
37
38 /// getSubExpr - Get the child of this expression.
39 MCRegister getReg() const { return Reg; }
40
41 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override {
42 if (!MAI || MAI->getAssemblerDialect() == 0)
43 OS << '%';
45 }
46
48 const MCAssembler *Asm) const override {
49 return false;
50 }
51 // Register values should be inlined as they are not valid .set expressions.
52 bool inlineAssignedExpr() const override { return true; }
53 bool isEqualTo(const MCExpr *X) const override {
54 if (auto *E = dyn_cast<X86MCExpr>(X))
55 return getReg() == E->getReg();
56 return false;
57 }
58 void visitUsedExpr(MCStreamer &Streamer) const override {}
59 MCFragment *findAssociatedFragment() const override { return nullptr; }
60
61 static bool classof(const MCExpr *E) {
62 return E->getKind() == MCExpr::Target;
63 }
64};
65} // end namespace llvm
66
67#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Register Reg
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
unsigned getAssemblerDialect() const
Definition MCAsmInfo.h:560
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
@ Target
Target specific expression.
Definition MCExpr.h:46
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:33
Streaming machine code generation interface.
Definition MCStreamer.h:220
static const char * getRegisterName(MCRegister Reg)
bool isEqualTo(const MCExpr *X) const override
Definition X86MCExpr.h:53
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm) const override
Definition X86MCExpr.h:47
void visitUsedExpr(MCStreamer &Streamer) const override
Definition X86MCExpr.h:58
static const X86MCExpr * create(MCRegister Reg, MCContext &Ctx)
Definition X86MCExpr.h:34
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition X86MCExpr.h:41
MCRegister getReg() const
getSubExpr - Get the child of this expression.
Definition X86MCExpr.h:39
MCFragment * findAssociatedFragment() const override
Definition X86MCExpr.h:59
static bool classof(const MCExpr *E)
Definition X86MCExpr.h:61
bool inlineAssignedExpr() const override
Definition X86MCExpr.h:52
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:649