LLVM: lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
19
20using namespace llvm;
21
22
24 switch (Kind) {
37 default:
39 }
40}
41
42namespace {
45
46public:
48 : MCAsmBackend(llvm::endianness::big), OSType(OST) {}
49
50 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
51 uint8_t *Data, uint64_t Value, bool IsResolved) override;
52
53 std::unique_ptr
54 createObjectTargetWriter() const override;
55
56 MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override;
57
58 bool writeNopData(raw_ostream &OS, uint64_t Count,
59 const MCSubtargetInfo *STI) const override;
60};
61
64 if ((Count % 4) != 0)
65 return false;
66
67 for (uint64_t i = 0; i < Count; i += 4)
68 OS.write("\x15\0\0\0", 4);
69
70 return true;
71}
72
73void LanaiAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
74 const MCValue &Target, uint8_t *Data,
75 uint64_t Value, bool IsResolved) {
76 if (!IsResolved)
77 Asm->getWriter().recordRelocation(F, Fixup, Target, Value);
78
82 return;
83
84
85
86 unsigned NumBytes = (getFixupKindInfo(Kind).TargetSize + 7) / 8;
87 unsigned FullSize = 4;
88
89
90 uint64_t CurVal = 0;
91
92
93 for (unsigned i = 0; i != NumBytes; ++i) {
94 unsigned Idx = (FullSize - 1 - i);
95 CurVal |= static_cast<uint64_t>(static_cast<uint8_t>(Data[Idx])) << (i * 8);
96 }
97
98 uint64_t Mask =
99 (static_cast<uint64_t>(-1) >> (64 - getFixupKindInfo(Kind).TargetSize));
101
102
103 for (unsigned i = 0; i != NumBytes; ++i) {
104 unsigned Idx = (FullSize - 1 - i);
105 Data[Idx] = static_cast<uint8_t>((CurVal >> (i * 8)) & 0xff);
106 }
107}
108
109std::unique_ptr
110LanaiAsmBackend::createObjectTargetWriter() const {
112}
113
114MCFixupKindInfo LanaiAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
116
117
118
119
120
121
122
123
124
125
126 {"FIXUP_LANAI_NONE", 0, 32, 0},
127 {"FIXUP_LANAI_21", 16, 16 , 0},
128 {"FIXUP_LANAI_21_F", 16, 16 , 0},
129 {"FIXUP_LANAI_25", 7, 25, 0},
130 {"FIXUP_LANAI_32", 0, 32, 0},
131 {"FIXUP_LANAI_HI16", 16, 16, 0},
132 {"FIXUP_LANAI_LO16", 16, 16, 0}};
133
136
138 "Invalid kind!");
140}
141
142}
143
149 if (!TT.isOSBinFormatELF())
151
152 return new LanaiAsmBackend(T, TT.getOS());
153}
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static unsigned adjustFixupValue(unsigned Kind, uint64_t Value)
Definition LanaiAsmBackend.cpp:23
PowerPC TLS Dynamic Call Fixup
Generic interface to target specific assembler backends.
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const ArmConfig &ArmCfg)
Apply fixup expression for edge to block content.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
MCAsmBackend * createLanaiAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Definition LanaiAsmBackend.cpp:144
FunctionAddr VTableAddr Count
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_2
A two-byte fixup.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
std::unique_ptr< MCObjectTargetWriter > createLanaiELFObjectWriter(uint8_t OSABI)