ARMMCExpr.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //===-- ARMMCExpr.h - ARM 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. #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H
  9. #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCEXPR_H
  10. #include "llvm/MC/MCExpr.h"
  11. namespace llvm {
  12. class ARMMCExpr : public MCTargetExpr {
  13. public:
  14. enum VariantKind {
  15. VK_ARM_None,
  16. VK_ARM_HI16, // The R_ARM_MOVT_ABS relocation (:upper16: in the .s file)
  17. VK_ARM_LO16 // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the .s file)
  18. };
  19. private:
  20. const VariantKind Kind;
  21. const MCExpr *Expr;
  22. explicit ARMMCExpr(VariantKind Kind, const MCExpr *Expr)
  23. : Kind(Kind), Expr(Expr) {}
  24. public:
  25. /// @name Construction
  26. /// @{
  27. static const ARMMCExpr *create(VariantKind Kind, const MCExpr *Expr,
  28. MCContext &Ctx);
  29. static const ARMMCExpr *createUpper16(const MCExpr *Expr, MCContext &Ctx) {
  30. return create(VK_ARM_HI16, Expr, Ctx);
  31. }
  32. static const ARMMCExpr *createLower16(const MCExpr *Expr, MCContext &Ctx) {
  33. return create(VK_ARM_LO16, Expr, Ctx);
  34. }
  35. /// @}
  36. /// @name Accessors
  37. /// @{
  38. /// getOpcode - Get the kind of this expression.
  39. VariantKind getKind() const { return Kind; }
  40. /// getSubExpr - Get the child of this expression.
  41. const MCExpr *getSubExpr() const { return Expr; }
  42. /// @}
  43. void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
  44. bool evaluateAsRelocatableImpl(MCValue &Res,
  45. const MCAsmLayout *Layout,
  46. const MCFixup *Fixup) const override {
  47. return false;
  48. }
  49. void visitUsedExpr(MCStreamer &Streamer) const override;
  50. MCFragment *findAssociatedFragment() const override {
  51. return getSubExpr()->findAssociatedFragment();
  52. }
  53. // There are no TLS ARMMCExprs at the moment.
  54. void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
  55. static bool classof(const MCExpr *E) {
  56. return E->getKind() == MCExpr::Target;
  57. }
  58. };
  59. } // end namespace llvm
  60. #endif