xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCExpr.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===-- SystemZMCExpr.h - SystemZ 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 #ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZMCEXPR_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZMCEXPR_H
11 
12 #include "llvm/MC/MCExpr.h"
13 #include "llvm/MC/MCStreamer.h"
14 #include "llvm/MC/MCValue.h"
15 
16 namespace llvm {
17 
18 class SystemZMCExpr : public MCTargetExpr {
19 public:
20 // HLASM docs for address constants:
21 // https://www.ibm.com/docs/en/hla-and-tf/1.6?topic=value-address-constants
22   enum VariantKind {
23     VK_SystemZ_None,
24     VK_SystemZ_RCon,            // Address of ADA of symbol.
25     VK_SystemZ_VCon,            // Address of external function symbol.
26   };
27 
28 private:
29   const VariantKind Kind;
30   const MCExpr *Expr;
31 
SystemZMCExpr(VariantKind Kind,const MCExpr * Expr)32   explicit SystemZMCExpr(VariantKind Kind, const MCExpr *Expr)
33       : Kind(Kind), Expr(Expr) {}
34 
35 public:
36   static const SystemZMCExpr *create(VariantKind Kind, const MCExpr *Expr,
37                                      MCContext &Ctx);
38 
39   /// getOpcode - Get the kind of this expression.
getKind()40   VariantKind getKind() const { return Kind; }
41 
42   /// getSubExpr - Get the child of this expression.
getSubExpr()43   const MCExpr *getSubExpr() const { return Expr; }
44 
45   StringRef getVariantKindName() const;
46 
47   void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
48   bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
49                                  const MCFixup *Fixup) const override;
visitUsedExpr(MCStreamer & Streamer)50   void visitUsedExpr(MCStreamer &Streamer) const override {
51     Streamer.visitUsedExpr(*getSubExpr());
52   }
findAssociatedFragment()53   MCFragment *findAssociatedFragment() const override {
54     return getSubExpr()->findAssociatedFragment();
55   }
56 
57   // There are no TLS SystemZMCExprs at the moment.
fixELFSymbolsInTLSFixups(MCAssembler & Asm)58   void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
59 
classof(const MCExpr * E)60   static bool classof(const MCExpr *E) {
61     return E->getKind() == MCExpr::Target;
62   }
63 };
64 } // end namespace llvm
65 
66 #endif
67