Path: blob/main/contrib/llvm-project/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
35294 views
//===-- AVRMCExpr.h - AVR specific MC expression classes --------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_AVR_MCEXPR_H9#define LLVM_AVR_MCEXPR_H1011#include "llvm/MC/MCExpr.h"1213#include "MCTargetDesc/AVRFixupKinds.h"1415namespace llvm {1617/// A expression in AVR machine code.18class AVRMCExpr : public MCTargetExpr {19public:20/// Specifies the type of an expression.21enum VariantKind {22VK_AVR_None = 0,2324VK_AVR_HI8, ///< Corresponds to `hi8()`.25VK_AVR_LO8, ///< Corresponds to `lo8()`.26VK_AVR_HH8, ///< Corresponds to `hlo8() and hh8()`.27VK_AVR_HHI8, ///< Corresponds to `hhi8()`.2829VK_AVR_PM, ///< Corresponds to `pm()`, reference to program memory.30VK_AVR_PM_LO8, ///< Corresponds to `pm_lo8()`.31VK_AVR_PM_HI8, ///< Corresponds to `pm_hi8()`.32VK_AVR_PM_HH8, ///< Corresponds to `pm_hh8()`.3334VK_AVR_LO8_GS, ///< Corresponds to `lo8(gs())`.35VK_AVR_HI8_GS, ///< Corresponds to `hi8(gs())`.36VK_AVR_GS, ///< Corresponds to `gs()`.37};3839public:40/// Creates an AVR machine code expression.41static const AVRMCExpr *create(VariantKind Kind, const MCExpr *Expr,42bool isNegated, MCContext &Ctx);4344/// Gets the type of the expression.45VariantKind getKind() const { return Kind; }46/// Gets the name of the expression.47const char *getName() const;48const MCExpr *getSubExpr() const { return SubExpr; }49/// Gets the fixup which corresponds to the expression.50AVR::Fixups getFixupKind() const;51/// Evaluates the fixup as a constant value.52bool evaluateAsConstant(int64_t &Result) const;5354bool isNegated() const { return Negated; }55void setNegated(bool negated = true) { Negated = negated; }5657void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;58bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,59const MCFixup *Fixup) const override;6061void visitUsedExpr(MCStreamer &streamer) const override;6263MCFragment *findAssociatedFragment() const override {64return getSubExpr()->findAssociatedFragment();65}6667void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}6869static bool classof(const MCExpr *E) {70return E->getKind() == MCExpr::Target;71}7273public:74static VariantKind getKindByName(StringRef Name);7576private:77int64_t evaluateAsInt64(int64_t Value) const;7879const VariantKind Kind;80const MCExpr *SubExpr;81bool Negated;8283private:84explicit AVRMCExpr(VariantKind Kind, const MCExpr *Expr, bool Negated)85: Kind(Kind), SubExpr(Expr), Negated(Negated) {}86~AVRMCExpr() = default;87};8889} // end namespace llvm9091#endif // LLVM_AVR_MCEXPR_H929394