1 //=--- X86MCExpr.h - X86 specific MC expression classes ---*- C++ -*-=//
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
7 //===----------------------------------------------------------------------===//
9 // This file describes X86-specific MCExprs, i.e, registers used for
10 // extended variable assignments.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCEXPR_H
15 #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCEXPR_H
17 #include "X86ATTInstPrinter.h"
18 #include "llvm/MC/MCAsmInfo.h"
19 #include "llvm/MC/MCContext.h"
20 #include "llvm/MC/MCExpr.h"
21 #include "llvm/Support/ErrorHandling.h"
25 class X86MCExpr
: public MCTargetExpr
{
28 const int64_t RegNo
; // All
30 explicit X86MCExpr(int64_t R
) : RegNo(R
) {}
33 /// @name Construction
36 static const X86MCExpr
*create(int64_t RegNo
, MCContext
&Ctx
) {
37 return new (Ctx
) X86MCExpr(RegNo
);
44 /// getSubExpr - Get the child of this expression.
45 int64_t getRegNo() const { return RegNo
; }
49 void printImpl(raw_ostream
&OS
, const MCAsmInfo
*MAI
) const override
{
50 if (!MAI
|| MAI
->getAssemblerDialect() == 0)
52 OS
<< X86ATTInstPrinter::getRegisterName(RegNo
);
55 bool evaluateAsRelocatableImpl(MCValue
&Res
, const MCAsmLayout
*Layout
,
56 const MCFixup
*Fixup
) const override
{
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();
66 void visitUsedExpr(MCStreamer
&Streamer
) const override
{};
67 MCFragment
*findAssociatedFragment() const override
{ return nullptr; }
69 // There are no TLS X86MCExprs at the moment.
70 void fixELFSymbolsInTLSFixups(MCAssembler
&Asm
) const override
{}
72 static bool classof(const MCExpr
*E
) {
73 return E
->getKind() == MCExpr::Target
;
77 } // end namespace llvm