LLVM  13.0.0git
PPCMCExpr.h
Go to the documentation of this file.
1 //===-- PPCMCExpr.h - PPC 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_POWERPC_MCTARGETDESC_PPCMCEXPR_H
10 #define LLVM_LIB_TARGET_POWERPC_MCTARGETDESC_PPCMCEXPR_H
11 
12 #include "llvm/MC/MCAsmLayout.h"
13 #include "llvm/MC/MCExpr.h"
14 #include "llvm/MC/MCValue.h"
15 
16 namespace llvm {
17 
18 class PPCMCExpr : public MCTargetExpr {
19 public:
20  enum VariantKind {
31  };
32 
33 private:
34  const VariantKind Kind;
35  const MCExpr *Expr;
36 
37  int64_t evaluateAsInt64(int64_t Value) const;
38 
39  explicit PPCMCExpr(VariantKind Kind, const MCExpr *Expr)
40  : Kind(Kind), Expr(Expr) {}
41 
42 public:
43  /// @name Construction
44  /// @{
45 
46  static const PPCMCExpr *create(VariantKind Kind, const MCExpr *Expr,
47  MCContext &Ctx);
48 
49  static const PPCMCExpr *createLo(const MCExpr *Expr, MCContext &Ctx) {
50  return create(VK_PPC_LO, Expr, Ctx);
51  }
52 
53  static const PPCMCExpr *createHi(const MCExpr *Expr, MCContext &Ctx) {
54  return create(VK_PPC_HI, Expr, Ctx);
55  }
56 
57  static const PPCMCExpr *createHa(const MCExpr *Expr, MCContext &Ctx) {
58  return create(VK_PPC_HA, Expr, Ctx);
59  }
60 
61  /// @}
62  /// @name Accessors
63  /// @{
64 
65  /// getOpcode - Get the kind of this expression.
66  VariantKind getKind() const { return Kind; }
67 
68  /// getSubExpr - Get the child of this expression.
69  const MCExpr *getSubExpr() const { return Expr; }
70 
71  /// @}
72 
73  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
75  const MCAsmLayout *Layout,
76  const MCFixup *Fixup) const override;
77  void visitUsedExpr(MCStreamer &Streamer) const override;
78  MCFragment *findAssociatedFragment() const override {
80  }
81 
82  // There are no TLS PPCMCExprs at the moment.
83  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
84 
85  bool evaluateAsConstant(int64_t &Res) const;
86 
87  static bool classof(const MCExpr *E) {
88  return E->getKind() == MCExpr::Target;
89  }
90 };
91 } // end namespace llvm
92 
93 #endif
llvm::PPCMCExpr::VK_PPC_HA
@ VK_PPC_HA
Definition: PPCMCExpr.h:24
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::PPCMCExpr::evaluateAsRelocatableImpl
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: PPCMCExpr.cpp:103
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
llvm::PPCMCExpr::getSubExpr
const MCExpr * getSubExpr() const
getSubExpr - Get the child of this expression.
Definition: PPCMCExpr.h:69
llvm::PPCMCExpr::VK_PPC_LO
@ VK_PPC_LO
Definition: PPCMCExpr.h:22
llvm::PPCMCExpr::VK_PPC_HIGHA
@ VK_PPC_HIGHA
Definition: PPCMCExpr.h:26
llvm::PPCMCExpr::fixELFSymbolsInTLSFixups
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: PPCMCExpr.h:83
llvm::PPCMCExpr::createLo
static const PPCMCExpr * createLo(const MCExpr *Expr, MCContext &Ctx)
Definition: PPCMCExpr.h:49
llvm::PPCMCExpr
Definition: PPCMCExpr.h:18
llvm::MCFragment
Definition: MCFragment.h:31
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:197
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MCExpr::Target
@ Target
Target specific expression.
Definition: MCExpr.h:42
llvm::PPCMCExpr::VK_PPC_HIGHEST
@ VK_PPC_HIGHEST
Definition: PPCMCExpr.h:29
llvm::PPCMCExpr::VK_PPC_HI
@ VK_PPC_HI
Definition: PPCMCExpr.h:23
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::PPCMCExpr::VK_PPC_HIGHERA
@ VK_PPC_HIGHERA
Definition: PPCMCExpr.h:28
llvm::PPCMCExpr::VK_PPC_None
@ VK_PPC_None
Definition: PPCMCExpr.h:21
llvm::MCAssembler
Definition: MCAssembler.h:60
llvm::MCExpr::MCExpr
MCExpr(ExprKind Kind, SMLoc Loc, unsigned SubclassData=0)
Definition: MCExpr.h:61
llvm::PPCMCExpr::getKind
VariantKind getKind() const
getOpcode - Get the kind of this expression.
Definition: PPCMCExpr.h:66
llvm::PPCMCExpr::createHa
static const PPCMCExpr * createHa(const MCExpr *Expr, MCContext &Ctx)
Definition: PPCMCExpr.h:57
llvm::PPCMCExpr::create
static const PPCMCExpr * create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
Definition: PPCMCExpr.cpp:20
llvm::PPCMCExpr::createHi
static const PPCMCExpr * createHi(const MCExpr *Expr, MCContext &Ctx)
Definition: PPCMCExpr.h:53
llvm::PPCMCExpr::VK_PPC_HIGHESTA
@ VK_PPC_HIGHESTA
Definition: PPCMCExpr.h:30
MCAsmLayout.h
llvm::MCAsmLayout
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
MCValue.h
llvm::PPCMCExpr::evaluateAsConstant
bool evaluateAsConstant(int64_t &Res) const
Definition: PPCMCExpr.cpp:62
llvm::PPCMCExpr::classof
static bool classof(const MCExpr *E)
Definition: PPCMCExpr.h:87
llvm::PPCMCExpr::VariantKind
VariantKind
Definition: PPCMCExpr.h:20
llvm::MCExpr::findAssociatedFragment
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:983
llvm::PPCMCExpr::VK_PPC_HIGHER
@ VK_PPC_HIGHER
Definition: PPCMCExpr.h:27
llvm::HexStyle::Asm
@ Asm
0ffh
Definition: MCInstPrinter.h:34
llvm::PPCMCExpr::visitUsedExpr
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: PPCMCExpr.cpp:164
llvm::MCValue
This represents an "assembler immediate".
Definition: MCValue.h:37
llvm::PPCMCExpr::VK_PPC_HIGH
@ VK_PPC_HIGH
Definition: PPCMCExpr.h:25
llvm::PPCMCExpr::findAssociatedFragment
MCFragment * findAssociatedFragment() const override
Definition: PPCMCExpr.h:78
llvm::PPCMCExpr::printImpl
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: PPCMCExpr.cpp:25
llvm::MCTargetExpr
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:643
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::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35