LLVM  14.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"
22 
23 namespace llvm {
24 
25 class X86MCExpr : public MCTargetExpr {
26 
27 private:
28  const int64_t RegNo; // All
29 
30  explicit X86MCExpr(int64_t R) : RegNo(R) {}
31 
32 public:
33  /// @name Construction
34  /// @{
35 
36  static const X86MCExpr *create(int64_t RegNo, MCContext &Ctx) {
37  return new (Ctx) X86MCExpr(RegNo);
38  }
39 
40  /// @}
41  /// @name Accessors
42  /// @{
43 
44  /// getSubExpr - Get the child of this expression.
45  int64_t getRegNo() const { return RegNo; }
46 
47  /// @}
48 
49  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override {
50  if (!MAI || MAI->getAssemblerDialect() == 0)
51  OS << '%';
53  }
54 
55  bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
56  const MCFixup *Fixup) const override {
57  return false;
58  }
59  // Register values should be inlined as they are not valid .set expressions.
60  bool inlineAssignedExpr() const override { return true; }
61  bool isEqualTo(const MCExpr *X) const override {
62  if (auto *E = dyn_cast<X86MCExpr>(X))
63  return getRegNo() == E->getRegNo();
64  return false;
65  }
66  void visitUsedExpr(MCStreamer &Streamer) const override{};
67  MCFragment *findAssociatedFragment() const override { return nullptr; }
68 
69  // There are no TLS X86MCExprs at the moment.
70  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
71 
72  static bool classof(const MCExpr *E) {
73  return E->getKind() == MCExpr::Target;
74  }
75 };
76 
77 } // end namespace llvm
78 
79 #endif
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::X86MCExpr::visitUsedExpr
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: X86MCExpr.h:66
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
ErrorHandling.h
llvm::X86MCExpr::evaluateAsRelocatableImpl
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: X86MCExpr.h:55
llvm::MCAsmInfo::getAssemblerDialect
unsigned getAssemblerDialect() const
Definition: MCAsmInfo.h:672
X86ATTInstPrinter.h
llvm::MCFragment
Definition: MCFragment.h:31
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MCExpr::Target
@ Target
Target specific expression.
Definition: MCExpr.h:42
MCContext.h
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::MCAssembler
Definition: MCAssembler.h:60
llvm::X86MCExpr::fixELFSymbolsInTLSFixups
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: X86MCExpr.h:70
llvm::X86MCExpr::create
static const X86MCExpr * create(int64_t RegNo, MCContext &Ctx)
Definition: X86MCExpr.h:36
llvm::X86MCExpr::findAssociatedFragment
MCFragment * findAssociatedFragment() const override
Definition: X86MCExpr.h:67
llvm::X86ATTInstPrinter::getRegisterName
static const char * getRegisterName(unsigned RegNo)
MCAsmInfo.h
llvm::X86MCExpr::inlineAssignedExpr
bool inlineAssignedExpr() const override
Definition: X86MCExpr.h:60
llvm::MCAsmLayout
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
llvm::X86MCExpr::classof
static bool classof(const MCExpr *E)
Definition: X86MCExpr.h:72
llvm::X86MCExpr::isEqualTo
bool isEqualTo(const MCExpr *X) const override
Definition: X86MCExpr.h:61
llvm::X86MCExpr
Definition: X86MCExpr.h:25
llvm::HexStyle::Asm
@ Asm
0ffh
Definition: MCInstPrinter.h:34
llvm::X86MCExpr::printImpl
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: X86MCExpr.h:49
llvm::MCValue
This represents an "assembler immediate".
Definition: MCValue.h:37
llvm::MCTargetExpr
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:644
llvm::X86MCExpr::getRegNo
int64_t getRegNo() const
getSubExpr - Get the child of this expression.
Definition: X86MCExpr.h:45
MCExpr.h
llvm::MCFixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35