LLVM  13.0.0git
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, ///< Corresponds to `pm()`, reference to program memory.
31  VK_AVR_PM_LO8, ///< Corresponds to `pm_lo8()`.
32  VK_AVR_PM_HI8, ///< Corresponds to `pm_hi8()`.
33  VK_AVR_PM_HH8, ///< Corresponds to `pm_hh8()`.
34 
35  VK_AVR_LO8_GS, ///< Corresponds to `lo8(gs())`.
36  VK_AVR_HI8_GS, ///< Corresponds to `hi8(gs())`.
37  VK_AVR_GS, ///< Corresponds to `gs()`.
38  };
39 
40 public:
41  /// Creates an AVR machine code expression.
42  static const AVRMCExpr *create(VariantKind Kind, const MCExpr *Expr,
43  bool isNegated, MCContext &Ctx);
44 
45  /// Gets the type of the expression.
46  VariantKind getKind() const { return Kind; }
47  /// Gets the name of the expression.
48  const char *getName() const;
49  const MCExpr *getSubExpr() const { return SubExpr; }
50  /// Gets the fixup which corresponds to the expression.
51  AVR::Fixups getFixupKind() const;
52  /// Evaluates the fixup as a constant value.
53  bool evaluateAsConstant(int64_t &Result) const;
54 
55  bool isNegated() const { return Negated; }
56  void setNegated(bool negated = true) { Negated = negated; }
57 
58  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
59  bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
60  const MCFixup *Fixup) const override;
61 
62  void visitUsedExpr(MCStreamer &streamer) const override;
63 
64  MCFragment *findAssociatedFragment() const override {
66  }
67 
68  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
69 
70  static bool classof(const MCExpr *E) {
71  return E->getKind() == MCExpr::Target;
72  }
73 
74 public:
76 
77 private:
78  int64_t evaluateAsInt64(int64_t Value) const;
79 
80  const VariantKind Kind;
81  const MCExpr *SubExpr;
82  bool Negated;
83 
84 private:
85  explicit AVRMCExpr(VariantKind Kind, const MCExpr *Expr, bool Negated)
86  : Kind(Kind), SubExpr(Expr), Negated(Negated) {}
87  ~AVRMCExpr() {}
88 };
89 
90 } // end namespace llvm
91 
92 #endif // LLVM_AVR_MCEXPR_H
llvm::AVRMCExpr::VK_AVR_PM_HI8
@ VK_AVR_PM_HI8
Corresponds to pm_hi8().
Definition: AVRMCExpr.h:32
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::AVRMCExpr::getKindByName
static VariantKind getKindByName(StringRef Name)
Definition: AVRMCExpr.cpp:209
llvm::AVRMCExpr::VK_AVR_HH8
@ VK_AVR_HH8
Corresponds to hlo8() and hh8().
Definition: AVRMCExpr.h:27
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:71
llvm::AVRMCExpr::isNegated
bool isNegated() const
Definition: AVRMCExpr.h:55
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::AVRMCExpr::fixELFSymbolsInTLSFixups
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: AVRMCExpr.h:68
llvm::AVRMCExpr::VK_AVR_LO8
@ VK_AVR_LO8
Corresponds to lo8().
Definition: AVRMCExpr.h:26
llvm::MCFragment
Definition: MCFragment.h:31
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:197
llvm::AVRMCExpr::VK_AVR_None
@ VK_AVR_None
Definition: AVRMCExpr.h:23
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MCExpr::Target
@ Target
Target specific expression.
Definition: MCExpr.h:42
llvm::AVRMCExpr::getKind
VariantKind getKind() const
Gets the type of the expression.
Definition: AVRMCExpr.h:46
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::AVRMCExpr
A expression in AVR machine code.
Definition: AVRMCExpr.h:19
llvm::AVRMCExpr::getSubExpr
const MCExpr * getSubExpr() const
Definition: AVRMCExpr.h:49
llvm::AVRMCExpr::VK_AVR_HI8_GS
@ VK_AVR_HI8_GS
Corresponds to hi8(gs()).
Definition: AVRMCExpr.h:36
llvm::AVRMCExpr::create
static const AVRMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isNegated, MCContext &Ctx)
Creates an AVR machine code expression.
Definition: AVRMCExpr.cpp:39
llvm::MCAssembler
Definition: MCAssembler.h:60
llvm::AVRMCExpr::VK_AVR_GS
@ VK_AVR_GS
Corresponds to gs().
Definition: AVRMCExpr.h:37
llvm::AVRMCExpr::getFixupKind
AVR::Fixups getFixupKind() const
Gets the fixup which corresponds to the expression.
Definition: AVRMCExpr.cpp:149
llvm::AVRMCExpr::findAssociatedFragment
MCFragment * findAssociatedFragment() const override
Definition: AVRMCExpr.h:64
llvm::AVRMCExpr::getName
const char * getName() const
Gets the name of the expression.
Definition: AVRMCExpr.cpp:197
llvm::AVRMCExpr::evaluateAsRelocatableImpl
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: AVRMCExpr.cpp:72
llvm::AVRMCExpr::VK_AVR_PM
@ VK_AVR_PM
Corresponds to pm(), reference to program memory.
Definition: AVRMCExpr.h:30
AVRFixupKinds.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::AVRMCExpr::VK_AVR_LO8_GS
@ VK_AVR_LO8_GS
Corresponds to lo8(gs()).
Definition: AVRMCExpr.h:35
llvm::AVRMCExpr::classof
static bool classof(const MCExpr *E)
Definition: AVRMCExpr.h:70
llvm::AVRMCExpr::printImpl
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: AVRMCExpr.cpp:44
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::AVR::Fixups
Fixups
The set of supported fixups.
Definition: AVRFixupKinds.h:26
llvm::MCAsmLayout
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:28
llvm::AVRMCExpr::VariantKind
VariantKind
Specifies the type of an expression.
Definition: AVRMCExpr.h:22
llvm::AVRMCExpr::visitUsedExpr
void visitUsedExpr(MCStreamer &streamer) const override
Definition: AVRMCExpr.cpp:193
llvm::AVRMCExpr::VK_AVR_PM_HH8
@ VK_AVR_PM_HH8
Corresponds to pm_hh8().
Definition: AVRMCExpr.h:33
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::AVRMCExpr::evaluateAsConstant
bool evaluateAsConstant(int64_t &Result) const
Evaluates the fixup as a constant value.
Definition: AVRMCExpr.cpp:55
llvm::HexStyle::Asm
@ Asm
0ffh
Definition: MCInstPrinter.h:34
llvm::MCValue
This represents an "assembler immediate".
Definition: MCValue.h:37
llvm::AVRMCExpr::setNegated
void setNegated(bool negated=true)
Definition: AVRMCExpr.h:56
llvm::AVRMCExpr::VK_AVR_HI8
@ VK_AVR_HI8
Corresponds to hi8().
Definition: AVRMCExpr.h: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
llvm::AVRMCExpr::VK_AVR_HHI8
@ VK_AVR_HHI8
Corresponds to hhi8().
Definition: AVRMCExpr.h:28
llvm::AVRMCExpr::VK_AVR_PM_LO8
@ VK_AVR_PM_LO8
Corresponds to pm_lo8().
Definition: AVRMCExpr.h:31