blob: 570f764f664269e3504f776935763aeab054277f [file] [log] [blame]
Evan Cheng5928e692011-07-25 23:24:55 +00001//===-- MCAsmBackend.cpp - Target MC Assembly Backend ----------------------==//
Daniel Dunbar3bea9bf2010-02-21 21:53:53 +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
Evan Cheng5928e692011-07-25 23:24:55 +000010#include "llvm/MC/MCAsmBackend.h"
Craig Topper58713212013-07-15 04:27:47 +000011#include "llvm/ADT/STLExtras.h"
Craig Topper6e80c282012-03-26 06:58:25 +000012#include "llvm/MC/MCFixupKindInfo.h"
Daniel Dunbar3bea9bf2010-02-21 21:53:53 +000013using namespace llvm;
14
Tim Northoverc52c74e2016-04-21 23:00:17 +000015MCAsmBackend::MCAsmBackend() {}
Daniel Dunbar3bea9bf2010-02-21 21:53:53 +000016
Jim Grosbach745c52d2012-10-01 22:20:54 +000017MCAsmBackend::~MCAsmBackend() {}
Daniel Dunbar0c9d9fd2010-12-16 03:20:06 +000018
David Majnemerce108422016-01-19 23:05:27 +000019Optional<MCFixupKind> MCAsmBackend::getFixupKind(StringRef Name) const {
20 return None;
Daniel Sanders9f6ad492015-11-12 13:33:00 +000021}
22
Colin LeMahieua01780f2015-05-30 18:42:22 +000023const MCFixupKindInfo &MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
Daniel Dunbar0c9d9fd2010-12-16 03:20:06 +000024 static const MCFixupKindInfo Builtins[] = {
Colin LeMahieua01780f2015-05-30 18:42:22 +000025 {"FK_Data_1", 0, 8, 0},
26 {"FK_Data_2", 0, 16, 0},
27 {"FK_Data_4", 0, 32, 0},
28 {"FK_Data_8", 0, 64, 0},
29 {"FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel},
30 {"FK_PCRel_2", 0, 16, MCFixupKindInfo::FKF_IsPCRel},
31 {"FK_PCRel_4", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
32 {"FK_PCRel_8", 0, 64, MCFixupKindInfo::FKF_IsPCRel},
33 {"FK_GPRel_1", 0, 8, 0},
34 {"FK_GPRel_2", 0, 16, 0},
35 {"FK_GPRel_4", 0, 32, 0},
36 {"FK_GPRel_8", 0, 64, 0},
Simon Atanasyaneb9ed612016-08-22 16:18:42 +000037 {"FK_DTPRel_4", 0, 32, 0},
38 {"FK_DTPRel_8", 0, 64, 0},
39 {"FK_TPRel_4", 0, 32, 0},
40 {"FK_TPRel_8", 0, 64, 0},
Colin LeMahieua01780f2015-05-30 18:42:22 +000041 {"FK_SecRel_1", 0, 8, 0},
42 {"FK_SecRel_2", 0, 16, 0},
43 {"FK_SecRel_4", 0, 32, 0},
44 {"FK_SecRel_8", 0, 64, 0}};
Jim Grosbachdc1e36e2012-05-11 01:41:30 +000045
Craig Topper58713212013-07-15 04:27:47 +000046 assert((size_t)Kind <= array_lengthof(Builtins) && "Unknown fixup kind");
Daniel Dunbar0c9d9fd2010-12-16 03:20:06 +000047 return Builtins[Kind];
48}
Colin LeMahieua01780f2015-05-30 18:42:22 +000049
50bool MCAsmBackend::fixupNeedsRelaxationAdvanced(
51 const MCFixup &Fixup, bool Resolved, uint64_t Value,
52 const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const {
53 if (!Resolved)
54 return true;
55 return fixupNeedsRelaxation(Fixup, Value, DF, Layout);
56}