ARMMCExpr.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===-- ARMMCExpr.cpp - ARM specific MC expression classes ----------------===//
  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. #include "ARMMCExpr.h"
  9. #include "llvm/MC/MCContext.h"
  10. #include "llvm/MC/MCStreamer.h"
  11. using namespace llvm;
  12. #define DEBUG_TYPE "armmcexpr"
  13. const ARMMCExpr*
  14. ARMMCExpr::create(VariantKind Kind, const MCExpr *Expr,
  15. MCContext &Ctx) {
  16. return new (Ctx) ARMMCExpr(Kind, Expr);
  17. }
  18. void ARMMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
  19. switch (Kind) {
  20. default: llvm_unreachable("Invalid kind!");
  21. case VK_ARM_HI16: OS << ":upper16:"; break;
  22. case VK_ARM_LO16: OS << ":lower16:"; break;
  23. }
  24. const MCExpr *Expr = getSubExpr();
  25. if (Expr->getKind() != MCExpr::SymbolRef)
  26. OS << '(';
  27. Expr->print(OS, MAI);
  28. if (Expr->getKind() != MCExpr::SymbolRef)
  29. OS << ')';
  30. }
  31. void ARMMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
  32. Streamer.visitUsedExpr(*getSubExpr());
  33. }