LLVM  9.0.0svn
AVRMCExpr.h
Go to the documentation of this file.
1 //===-- AVRMCExpr.h - AVR 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_AVR_MCEXPR_H
10 #define LLVM_AVR_MCEXPR_H
11 
12 #include "llvm/MC/MCExpr.h"
13 
15 
16 namespace llvm {
17 
18 /// A expression in AVR machine code.
19 class AVRMCExpr : public MCTargetExpr {
20 public:
21  /// Specifies the type of an expression.
22  enum VariantKind {
24 
25  VK_AVR_HI8, ///< Corresponds to `hi8()`.
26  VK_AVR_LO8, ///< Corresponds to `lo8()`.
27  VK_AVR_HH8, ///< Corresponds to `hlo8() and hh8()`.
28  VK_AVR_HHI8, ///< Corresponds to `hhi8()`.
29 
30  VK_AVR_PM_LO8, ///< Corresponds to `pm_lo8()`.
31  VK_AVR_PM_HI8, ///< Corresponds to `pm_hi8()`.
32  VK_AVR_PM_HH8, ///< Corresponds to `pm_hh8()`.
33 
34  VK_AVR_LO8_GS, ///< Corresponds to `lo8(gs())`.
35  VK_AVR_HI8_GS, ///< Corresponds to `hi8(gs())`.
36  VK_AVR_GS, ///< Corresponds to `gs()`.
37  };
38 
39 public:
40  /// Creates an AVR machine code expression.
41  static const AVRMCExpr *create(VariantKind Kind, const MCExpr *Expr,
42  bool isNegated, MCContext &Ctx);
43 
44  /// Gets the type of the expression.
45  VariantKind getKind() const { return Kind; }
46  /// Gets the name of the expression.
47  const char *getName() const;
48  const MCExpr *getSubExpr() const { return SubExpr; }
49  /// Gets the fixup which corresponds to the expression.
50  AVR::Fixups getFixupKind() const;
51  /// Evaluates the fixup as a constant value.
52  bool evaluateAsConstant(int64_t &Result) const;
53 
54  bool isNegated() const { return Negated; }
55  void setNegated(bool negated = true) { Negated = negated; }
56 
57  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
58  bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
59  const MCFixup *Fixup) const override;
60 
61  void visitUsedExpr(MCStreamer &streamer) const override;
62 
63  MCFragment *findAssociatedFragment() const override {
65  }
66 
67  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
68 
69  static bool classof(const MCExpr *E) {
70  return E->getKind() == MCExpr::Target;
71  }
72 
73 public:
75 
76 private:
77  int64_t evaluateAsInt64(int64_t Value) const;
78 
79  const VariantKind Kind;
80  const MCExpr *SubExpr;
81  bool Negated;
82 
83 private:
84  explicit AVRMCExpr(VariantKind Kind, const MCExpr *Expr, bool Negated)
85  : Kind(Kind), SubExpr(Expr), Negated(Negated) {}
86  ~AVRMCExpr() {}
87 };
88 
89 } // end namespace llvm
90 
91 #endif // LLVM_AVR_MCEXPR_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
This represents an "assembler immediate".
Definition: MCValue.h:39
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
Corresponds to gs().
Definition: AVRMCExpr.h:36
VariantKind getKind() const
Gets the type of the expression.
Definition: AVRMCExpr.h:45
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:73
void visitUsedExpr(MCStreamer &streamer) const override
Definition: AVRMCExpr.cpp:187
VariantKind
Specifies the type of an expression.
Definition: AVRMCExpr.h:22
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
A expression in AVR machine code.
Definition: AVRMCExpr.h:19
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:577
static bool classof(const MCExpr *E)
Definition: AVRMCExpr.h:69
Context object for machine code objects.
Definition: MCContext.h:62
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: AVRMCExpr.h:67
const MCExpr * getSubExpr() const
Definition: AVRMCExpr.h:48
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: AVRMCExpr.cpp:43
AVR::Fixups getFixupKind() const
Gets the fixup which corresponds to the expression.
Definition: AVRMCExpr.cpp:144
void setNegated(bool negated=true)
Definition: AVRMCExpr.h:55
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:55
Streaming machine code generation interface.
Definition: MCStreamer.h:188
Corresponds to hlo8() and hh8().
Definition: AVRMCExpr.h:27
Corresponds to pm_lo8().
Definition: AVRMCExpr.h:30
bool evaluateAsConstant(int64_t &Result) const
Evaluates the fixup as a constant value.
Definition: AVRMCExpr.cpp:54
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const char * getName() const
Gets the name of the expression.
Definition: AVRMCExpr.cpp:191
Corresponds to lo8(gs()).
Definition: AVRMCExpr.h:34
Corresponds to hi8().
Definition: AVRMCExpr.h:25
PowerPC TLS Dynamic Call Fixup
Corresponds to pm_hh8().
Definition: AVRMCExpr.h:32
Corresponds to hi8(gs()).
Definition: AVRMCExpr.h:35
ExprKind getKind() const
Definition: MCExpr.h:72
Fixups
The set of supported fixups.
Definition: AVRFixupKinds.h:26
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:860
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: AVRMCExpr.cpp:71
Corresponds to pm_hi8().
Definition: AVRMCExpr.h:31
MCFragment * findAssociatedFragment() const override
Definition: AVRMCExpr.h:63
bool isNegated() const
Definition: AVRMCExpr.h:54
Corresponds to lo8().
Definition: AVRMCExpr.h:26
static const AVRMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isNegated, MCContext &Ctx)
Creates an AVR machine code expression.
Definition: AVRMCExpr.cpp:38
static VariantKind getKindByName(StringRef Name)
Definition: AVRMCExpr.cpp:202
LLVM Value Representation.
Definition: Value.h:72
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Corresponds to hhi8().
Definition: AVRMCExpr.h:28
Target specific expression.
Definition: MCExpr.h:42