LLVM  9.0.0svn
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  bool IsDarwin;
37 
38  int64_t evaluateAsInt64(int64_t Value) const;
39 
40  explicit PPCMCExpr(VariantKind Kind, const MCExpr *Expr, bool IsDarwin)
41  : Kind(Kind), Expr(Expr), IsDarwin(IsDarwin) {}
42 
43 public:
44  /// @name Construction
45  /// @{
46 
47  static const PPCMCExpr *create(VariantKind Kind, const MCExpr *Expr,
48  bool isDarwin, MCContext &Ctx);
49 
50  static const PPCMCExpr *createLo(const MCExpr *Expr,
51  bool isDarwin, MCContext &Ctx) {
52  return create(VK_PPC_LO, Expr, isDarwin, Ctx);
53  }
54 
55  static const PPCMCExpr *createHi(const MCExpr *Expr,
56  bool isDarwin, MCContext &Ctx) {
57  return create(VK_PPC_HI, Expr, isDarwin, Ctx);
58  }
59 
60  static const PPCMCExpr *createHa(const MCExpr *Expr,
61  bool isDarwin, MCContext &Ctx) {
62  return create(VK_PPC_HA, Expr, isDarwin, Ctx);
63  }
64 
65  /// @}
66  /// @name Accessors
67  /// @{
68 
69  /// getOpcode - Get the kind of this expression.
70  VariantKind getKind() const { return Kind; }
71 
72  /// getSubExpr - Get the child of this expression.
73  const MCExpr *getSubExpr() const { return Expr; }
74 
75  /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
76  bool isDarwinSyntax() const { return IsDarwin; }
77 
78 
79  /// @}
80 
81  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
83  const MCAsmLayout *Layout,
84  const MCFixup *Fixup) const override;
85  void visitUsedExpr(MCStreamer &Streamer) const override;
86  MCFragment *findAssociatedFragment() const override {
88  }
89 
90  // There are no TLS PPCMCExprs at the moment.
91  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
92 
93  bool evaluateAsConstant(int64_t &Res) const;
94 
95  static bool classof(const MCExpr *E) {
96  return E->getKind() == MCExpr::Target;
97  }
98 };
99 } // end namespace llvm
100 
101 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
VariantKind getKind() const
getOpcode - Get the kind of this expression.
Definition: PPCMCExpr.h:70
This represents an "assembler immediate".
Definition: MCValue.h:39
static bool classof(const MCExpr *E)
Definition: PPCMCExpr.h:95
static const PPCMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isDarwin, MCContext &Ctx)
Definition: PPCMCExpr.cpp:21
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: PPCMCExpr.h:91
static const PPCMCExpr * createHi(const MCExpr *Expr, bool isDarwin, MCContext &Ctx)
Definition: PPCMCExpr.h:55
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:74
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:579
Context object for machine code objects.
Definition: MCContext.h:62
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Streaming machine code generation interface.
Definition: MCStreamer.h:188
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isDarwin(object::Archive::Kind Kind)
static const PPCMCExpr * createLo(const MCExpr *Expr, bool isDarwin, MCContext &Ctx)
Definition: PPCMCExpr.h:50
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: PPCMCExpr.cpp:26
const MCExpr * getSubExpr() const
getSubExpr - Get the child of this expression.
Definition: PPCMCExpr.h:73
PowerPC TLS Dynamic Call Fixup
ExprKind getKind() const
Definition: MCExpr.h:72
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: PPCMCExpr.cpp:98
MCFragment * findAssociatedFragment() const override
Definition: PPCMCExpr.h:86
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:864
bool evaluateAsConstant(int64_t &Res) const
Definition: PPCMCExpr.cpp:57
bool isDarwinSyntax() const
isDarwinSyntax - True if expression is to be printed using Darwin syntax.
Definition: PPCMCExpr.h:76
LLVM Value Representation.
Definition: Value.h:72
static const PPCMCExpr * createHa(const MCExpr *Expr, bool isDarwin, MCContext &Ctx)
Definition: PPCMCExpr.h:60
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Target specific expression.
Definition: MCExpr.h:42
void visitUsedExpr(MCStreamer &Streamer) const override
Definition: PPCMCExpr.cpp:159