[ARM] VQADD instructions
[llvm-complete.git] / lib / Target / AVR / MCTargetDesc / AVRMCExpr.h
blob3b696bab1715de955cd81d9567abde8d7b8db6af
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_AVR_MCEXPR_H
10 #define LLVM_AVR_MCEXPR_H
12 #include "llvm/MC/MCExpr.h"
14 #include "MCTargetDesc/AVRFixupKinds.h"
16 namespace llvm {
18 /// A expression in AVR machine code.
19 class AVRMCExpr : public MCTargetExpr {
20 public:
21 /// Specifies the type of an expression.
22 enum VariantKind {
23 VK_AVR_None,
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()`.
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()`.
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()`.
39 public:
40 /// Creates an AVR machine code expression.
41 static const AVRMCExpr *create(VariantKind Kind, const MCExpr *Expr,
42 bool isNegated, MCContext &Ctx);
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;
54 bool isNegated() const { return Negated; }
55 void setNegated(bool negated = true) { Negated = negated; }
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;
61 void visitUsedExpr(MCStreamer &streamer) const override;
63 MCFragment *findAssociatedFragment() const override {
64 return getSubExpr()->findAssociatedFragment();
67 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
69 static bool classof(const MCExpr *E) {
70 return E->getKind() == MCExpr::Target;
73 public:
74 static VariantKind getKindByName(StringRef Name);
76 private:
77 int64_t evaluateAsInt64(int64_t Value) const;
79 const VariantKind Kind;
80 const MCExpr *SubExpr;
81 bool Negated;
83 private:
84 explicit AVRMCExpr(VariantKind Kind, const MCExpr *Expr, bool Negated)
85 : Kind(Kind), SubExpr(Expr), Negated(Negated) {}
86 ~AVRMCExpr() {}
89 } // end namespace llvm
91 #endif // LLVM_AVR_MCEXPR_H