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 | |
14 | #include "MCTargetDesc/AVRFixupKinds.h" |
15 | |
16 | namespace llvm { |
17 | |
18 | /// A expression in AVR machine code. |
19 | class AVRMCExpr : public MCSpecifierExpr { |
20 | public: |
21 | friend class AVRMCAsmInfo; |
22 | using Specifier = Spec; |
23 | /// Specifies the type of an expression. |
24 | |
25 | public: |
26 | /// Creates an AVR machine code expression. |
27 | static const AVRMCExpr *create(Specifier S, const MCExpr *Expr, |
28 | bool isNegated, MCContext &Ctx); |
29 | |
30 | /// Gets the name of the expression. |
31 | const char *getName() const; |
32 | /// Gets the fixup which corresponds to the expression. |
33 | AVR::Fixups getFixupKind() const; |
34 | /// Evaluates the fixup as a constant value. |
35 | bool evaluateAsConstant(int64_t &Result) const; |
36 | |
37 | bool isNegated() const { return Negated; } |
38 | void setNegated(bool negated = true) { Negated = negated; } |
39 | |
40 | public: |
41 | static Specifier parseSpecifier(StringRef Name); |
42 | |
43 | private: |
44 | int64_t evaluateAsInt64(int64_t Value) const; |
45 | |
46 | bool Negated; |
47 | |
48 | private: |
49 | explicit AVRMCExpr(Specifier S, const MCExpr *Expr, bool Negated) |
50 | : MCSpecifierExpr(Expr, S), Negated(Negated) {} |
51 | }; |
52 | |
53 | } // end namespace llvm |
54 | |
55 | #endif // LLVM_AVR_MCEXPR_H |
56 | |