1 //====- SparcMCExpr.h - Sparc 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 Sparc-specific MCExprs, used for modifiers like
10 // "%hi" or "%lo" etc.,
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCEXPR_H
15 #define LLVM_LIB_TARGET_SPARC_MCTARGETDESC_SPARCMCEXPR_H
17 #include "SparcFixupKinds.h"
18 #include "llvm/MC/MCExpr.h"
23 class SparcMCExpr
: public MCTargetExpr
{
46 VK_Sparc_TLS_LDM_HI22
,
47 VK_Sparc_TLS_LDM_LO10
,
49 VK_Sparc_TLS_LDM_CALL
,
50 VK_Sparc_TLS_LDO_HIX22
,
51 VK_Sparc_TLS_LDO_LOX10
,
58 VK_Sparc_TLS_LE_HIX22
,
63 const VariantKind Kind
;
66 explicit SparcMCExpr(VariantKind Kind
, const MCExpr
*Expr
)
67 : Kind(Kind
), Expr(Expr
) {}
70 /// @name Construction
73 static const SparcMCExpr
*create(VariantKind Kind
, const MCExpr
*Expr
,
79 /// getOpcode - Get the kind of this expression.
80 VariantKind
getKind() const { return Kind
; }
82 /// getSubExpr - Get the child of this expression.
83 const MCExpr
*getSubExpr() const { return Expr
; }
85 /// getFixupKind - Get the fixup kind of this expression.
86 Sparc::Fixups
getFixupKind() const { return getFixupKind(Kind
); }
89 void printImpl(raw_ostream
&OS
, const MCAsmInfo
*MAI
) const override
;
90 bool evaluateAsRelocatableImpl(MCValue
&Res
,
91 const MCAsmLayout
*Layout
,
92 const MCFixup
*Fixup
) const override
;
93 void visitUsedExpr(MCStreamer
&Streamer
) const override
;
94 MCFragment
*findAssociatedFragment() const override
{
95 return getSubExpr()->findAssociatedFragment();
98 void fixELFSymbolsInTLSFixups(MCAssembler
&Asm
) const override
;
100 static bool classof(const MCExpr
*E
) {
101 return E
->getKind() == MCExpr::Target
;
104 static bool classof(const SparcMCExpr
*) { return true; }
106 static VariantKind
parseVariantKind(StringRef name
);
107 static bool printVariantKind(raw_ostream
&OS
, VariantKind Kind
);
108 static Sparc::Fixups
getFixupKind(VariantKind Kind
);
111 } // end namespace llvm.