blob: 3642f37aa855c4bfe69486b6883963bde40f347c [file] [log] [blame]
Eugene Zelenko3d8b0eb2017-02-08 22:23:19 +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
Chandler Carruth6bda14b2017-06-06 11:49:48 +000010#include "llvm/MC/MCAsmBackend.h"
Eugene Zelenko3d8b0eb2017-02-08 22:23:19 +000011#include "llvm/ADT/None.h"
Craig Topper58713212013-07-15 04:27:47 +000012#include "llvm/ADT/STLExtras.h"
Craig Topper6e80c282012-03-26 06:58:25 +000013#include "llvm/MC/MCFixupKindInfo.h"
Eugene Zelenko3d8b0eb2017-02-08 22:23:19 +000014#include <cassert>
15#include <cstddef>
16#include <cstdint>
17
Daniel Dunbar3bea9bf2010-02-21 21:53:53 +000018using namespace llvm;
19
Eugene Zelenko3d8b0eb2017-02-08 22:23:19 +000020MCAsmBackend::MCAsmBackend() = default;
Daniel Dunbar3bea9bf2010-02-21 21:53:53 +000021
Eugene Zelenko3d8b0eb2017-02-08 22:23:19 +000022MCAsmBackend::~MCAsmBackend() = default;
Daniel Dunbar0c9d9fd2010-12-16 03:20:06 +000023
David Majnemerce108422016-01-19 23:05:27 +000024Optional<MCFixupKind> MCAsmBackend::getFixupKind(StringRef Name) const {
25 return None;
Daniel Sanders9f6ad492015-11-12 13:33:00 +000026}
27
Colin LeMahieua01780f2015-05-30 18:42:22 +000028const MCFixupKindInfo &MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
Daniel Dunbar0c9d9fd2010-12-16 03:20:06 +000029 static const MCFixupKindInfo Builtins[] = {
Colin LeMahieua01780f2015-05-30 18:42:22 +000030 {"FK_Data_1", 0, 8, 0},
31 {"FK_Data_2", 0, 16, 0},
32 {"FK_Data_4", 0, 32, 0},
33 {"FK_Data_8", 0, 64, 0},
34 {"FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel},
35 {"FK_PCRel_2", 0, 16, MCFixupKindInfo::FKF_IsPCRel},
36 {"FK_PCRel_4", 0, 32, MCFixupKindInfo::FKF_IsPCRel},
37 {"FK_PCRel_8", 0, 64, MCFixupKindInfo::FKF_IsPCRel},
38 {"FK_GPRel_1", 0, 8, 0},
39 {"FK_GPRel_2", 0, 16, 0},
40 {"FK_GPRel_4", 0, 32, 0},
41 {"FK_GPRel_8", 0, 64, 0},
Simon Atanasyaneb9ed612016-08-22 16:18:42 +000042 {"FK_DTPRel_4", 0, 32, 0},
43 {"FK_DTPRel_8", 0, 64, 0},
44 {"FK_TPRel_4", 0, 32, 0},
45 {"FK_TPRel_8", 0, 64, 0},
Colin LeMahieua01780f2015-05-30 18:42:22 +000046 {"FK_SecRel_1", 0, 8, 0},
47 {"FK_SecRel_2", 0, 16, 0},
48 {"FK_SecRel_4", 0, 32, 0},
49 {"FK_SecRel_8", 0, 64, 0}};
Jim Grosbachdc1e36e2012-05-11 01:41:30 +000050
Craig Topper58713212013-07-15 04:27:47 +000051 assert((size_t)Kind <= array_lengthof(Builtins) && "Unknown fixup kind");
Daniel Dunbar0c9d9fd2010-12-16 03:20:06 +000052 return Builtins[Kind];
53}
Colin LeMahieua01780f2015-05-30 18:42:22 +000054
55bool MCAsmBackend::fixupNeedsRelaxationAdvanced(
56 const MCFixup &Fixup, bool Resolved, uint64_t Value,
57 const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const {
58 if (!Resolved)
59 return true;
60 return fixupNeedsRelaxation(Fixup, Value, DF, Layout);
61}