blob: 482bcf902518687aa18ed5e8fefdbd470e74fbe9 [file] [log] [blame]
Ahmed Bougachaad1084d2013-05-24 00:39:57 +00001//===-- ARMMachORelocationInfo.cpp ----------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "MCTargetDesc/ARMMCTargetDesc.h"
11#include "ARMMCExpr.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000012#include "llvm-c/Disassembler.h"
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000013#include "llvm/MC/MCContext.h"
14#include "llvm/MC/MCExpr.h"
Benjamin Kramerf57c1972016-01-26 16:44:37 +000015#include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000016
17using namespace llvm;
18using namespace object;
19
20namespace {
21class ARMMachORelocationInfo : public MCRelocationInfo {
22public:
23 ARMMachORelocationInfo(MCContext &Ctx) : MCRelocationInfo(Ctx) {}
24
25 const MCExpr *createExprForCAPIVariantKind(const MCExpr *SubExpr,
Craig Topperca7e3e52014-03-10 03:19:03 +000026 unsigned VariantKind) override {
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000027 switch(VariantKind) {
28 case LLVMDisassembler_VariantKind_ARM_HI16:
Jim Grosbach13760bd2015-05-30 01:25:56 +000029 return ARMMCExpr::createUpper16(SubExpr, Ctx);
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000030 case LLVMDisassembler_VariantKind_ARM_LO16:
Jim Grosbach13760bd2015-05-30 01:25:56 +000031 return ARMMCExpr::createLower16(SubExpr, Ctx);
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000032 default:
33 return MCRelocationInfo::createExprForCAPIVariantKind(SubExpr,
34 VariantKind);
35 }
36 }
37};
38} // End unnamed namespace
39
40/// createARMMachORelocationInfo - Construct an ARM Mach-O RelocationInfo.
41MCRelocationInfo *llvm::createARMMachORelocationInfo(MCContext &Ctx) {
42 return new ARMMachORelocationInfo(Ctx);
43}