LLVM  6.0.0svn
AVRMCExpr.h
Go to the documentation of this file.
1 //===-- AVRMCExpr.h - AVR specific MC expression classes --------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_AVR_MCEXPR_H
11 #define LLVM_AVR_MCEXPR_H
12 
13 #include "llvm/MC/MCExpr.h"
14 
16 
17 namespace llvm {
18 
19 /// A expression in AVR machine code.
20 class AVRMCExpr : public MCTargetExpr {
21 public:
22  /// Specifies the type of an expression.
23  enum VariantKind {
25 
26  VK_AVR_HI8, ///< Corresponds to `hi8()`.
27  VK_AVR_LO8, ///< Corresponds to `lo8()`.
28  VK_AVR_HH8, ///< Corresponds to `hlo8() and hh8()`.
29  VK_AVR_HHI8, ///< Corresponds to `hhi8()`.
30 
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 
36 public:
37  /// Creates an AVR machine code expression.
38  static const AVRMCExpr *create(VariantKind Kind, const MCExpr *Expr,
39  bool isNegated, MCContext &Ctx);
40 
41  /// Gets the type of the expression.
42  VariantKind getKind() const { return Kind; }
43  /// Gets the name of the expression.
44  const char *getName() const;
45  const MCExpr *getSubExpr() const { return SubExpr; }
46  /// Gets the fixup which corresponds to the expression.
47  AVR::Fixups getFixupKind() const;
48  /// Evaluates the fixup as a constant value.
49  bool evaluateAsConstant(int64_t &Result) const;
50 
51  bool isNegated() const { return Negated; }
52  void setNegated(bool negated = true) { Negated = negated; }
53 
54  void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
55  bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
56  const MCFixup *Fixup) const override;
57 
58  void visitUsedExpr(MCStreamer &streamer) const override;
59 
60  MCFragment *findAssociatedFragment() const override {
62  }
63 
64  void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
65 
66  static bool classof(const MCExpr *E) {
67  return E->getKind() == MCExpr::Target;
68  }
69 
70 public:
72 
73 private:
74  int64_t evaluateAsInt64(int64_t Value) const;
75 
76  const VariantKind Kind;
77  const MCExpr *SubExpr;
78  bool Negated;
79 
80 private:
81  explicit AVRMCExpr(VariantKind Kind, const MCExpr *Expr, bool Negated)
82  : Kind(Kind), SubExpr(Expr), Negated(Negated) {}
83  ~AVRMCExpr() {}
84 };
85 
86 } // end namespace llvm
87 
88 #endif // LLVM_AVR_MCEXPR_H
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
This represents an "assembler immediate".
Definition: MCValue.h:40
VariantKind getKind() const
Gets the type of the expression.
Definition: AVRMCExpr.h:42
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:66
void visitUsedExpr(MCStreamer &streamer) const override
Definition: AVRMCExpr.cpp:162
VariantKind
Specifies the type of an expression.
Definition: AVRMCExpr.h:23
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
A expression in AVR machine code.
Definition: AVRMCExpr.h:20
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:563
static bool classof(const MCExpr *E)
Definition: AVRMCExpr.h:66
Context object for machine code objects.
Definition: MCContext.h:59
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override
Definition: AVRMCExpr.h:64
const MCExpr * getSubExpr() const
Definition: AVRMCExpr.h:45
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
Definition: AVRMCExpr.cpp:41
AVR::Fixups getFixupKind() const
Gets the fixup which corresponds to the expression.
Definition: AVRMCExpr.cpp:128
void setNegated(bool negated=true)
Definition: AVRMCExpr.h:52
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:169
Corresponds to hlo8() and hh8().
Definition: AVRMCExpr.h:28
Corresponds to pm_lo8().
Definition: AVRMCExpr.h:31
bool evaluateAsConstant(int64_t &Result) const
Evaluates the fixup as a constant value.
Definition: AVRMCExpr.cpp:52
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const char * getName() const
Gets the name of the expression.
Definition: AVRMCExpr.cpp:166
Corresponds to hi8().
Definition: AVRMCExpr.h:26
PowerPC TLS Dynamic Call Fixup
Corresponds to pm_hh8().
Definition: AVRMCExpr.h:33
ExprKind getKind() const
Definition: MCExpr.h:73
Fixups
The set of supported fixups.
Definition: AVRFixupKinds.h:27
MCFragment * findAssociatedFragment() const
Find the "associated section" for this expression, which is currently defined as the absolute section...
Definition: MCExpr.cpp:782
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const override
Definition: AVRMCExpr.cpp:69
Corresponds to pm_hi8().
Definition: AVRMCExpr.h:32
MCFragment * findAssociatedFragment() const override
Definition: AVRMCExpr.h:60
bool isNegated() const
Definition: AVRMCExpr.h:51
Corresponds to lo8().
Definition: AVRMCExpr.h:27
static const AVRMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isNegated, MCContext &Ctx)
Creates an AVR machine code expression.
Definition: AVRMCExpr.cpp:36
static VariantKind getKindByName(StringRef Name)
Definition: AVRMCExpr.cpp:177
LLVM Value Representation.
Definition: Value.h:73
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Corresponds to hhi8().
Definition: AVRMCExpr.h:29
Target specific expression.
Definition: MCExpr.h:43