blob: 6259c98321f4e72959812e29770ea22fcba70354 [file] [log] [blame]
Eugene Zelenko41e7e342017-02-08 22:19:56 +00001//===- ARMMachORelocationInfo.cpp -----------------------------------------===//
Ahmed Bougachaad1084d2013-05-24 00:39:57 +00002//
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
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000010#include "ARMMCExpr.h"
Eugene Zelenko41e7e342017-02-08 22:19:56 +000011#include "MCTargetDesc/ARMMCTargetDesc.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000012#include "llvm-c/Disassembler.h"
Benjamin Kramerf57c1972016-01-26 16:44:37 +000013#include "llvm/MC/MCDisassembler/MCRelocationInfo.h"
Eugene Zelenko41e7e342017-02-08 22:19:56 +000014#include "llvm/MC/MCExpr.h"
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000015
16using namespace llvm;
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000017
18namespace {
Eugene Zelenko41e7e342017-02-08 22:19:56 +000019
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000020class ARMMachORelocationInfo : public MCRelocationInfo {
21public:
22 ARMMachORelocationInfo(MCContext &Ctx) : MCRelocationInfo(Ctx) {}
23
24 const MCExpr *createExprForCAPIVariantKind(const MCExpr *SubExpr,
Craig Topperca7e3e52014-03-10 03:19:03 +000025 unsigned VariantKind) override {
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000026 switch(VariantKind) {
27 case LLVMDisassembler_VariantKind_ARM_HI16:
Jim Grosbach13760bd2015-05-30 01:25:56 +000028 return ARMMCExpr::createUpper16(SubExpr, Ctx);
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000029 case LLVMDisassembler_VariantKind_ARM_LO16:
Jim Grosbach13760bd2015-05-30 01:25:56 +000030 return ARMMCExpr::createLower16(SubExpr, Ctx);
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000031 default:
32 return MCRelocationInfo::createExprForCAPIVariantKind(SubExpr,
33 VariantKind);
34 }
35 }
36};
Eugene Zelenko41e7e342017-02-08 22:19:56 +000037
38} // end anonymous namespace
Ahmed Bougachaad1084d2013-05-24 00:39:57 +000039
40/// createARMMachORelocationInfo - Construct an ARM Mach-O RelocationInfo.
41MCRelocationInfo *llvm::createARMMachORelocationInfo(MCContext &Ctx) {
42 return new ARMMachORelocationInfo(Ctx);
43}