ARMMachORelocationInfo.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===- ARMMachORelocationInfo.cpp -----------------------------------------===//
  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 "MCTargetDesc/ARMMCTargetDesc.h"
  10. #include "llvm-c/Disassembler.h"
  11. #include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
  12. #include "llvm/MC/MCExpr.h"
  13. using namespace llvm;
  14. namespace {
  15. class ARMMachORelocationInfo : public MCRelocationInfo {
  16. public:
  17. ARMMachORelocationInfo(MCContext &Ctx) : MCRelocationInfo(Ctx) {}
  18. const MCExpr *createExprForCAPIVariantKind(const MCExpr *SubExpr,
  19. unsigned VariantKind) override {
  20. switch(VariantKind) {
  21. case LLVMDisassembler_VariantKind_ARM_HI16:
  22. return ARMMCExpr::createUpper16(SubExpr, Ctx);
  23. case LLVMDisassembler_VariantKind_ARM_LO16:
  24. return ARMMCExpr::createLower16(SubExpr, Ctx);
  25. default:
  26. return MCRelocationInfo::createExprForCAPIVariantKind(SubExpr,
  27. VariantKind);
  28. }
  29. }
  30. };
  31. } // end anonymous namespace
  32. /// createARMMachORelocationInfo - Construct an ARM Mach-O RelocationInfo.
  33. MCRelocationInfo *llvm::createARMMachORelocationInfo(MCContext &Ctx) {
  34. return new ARMMachORelocationInfo(Ctx);
  35. }