LLVM: lib/Target/VE/MCTargetDesc/VEAsmBackend.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
19
20using namespace llvm;
21
23 switch (Kind) {
24 default:
38 return (Value >> 32) & 0xffffffff;
48 return Value & 0xffffffff;
49 }
50}
51
52
54 switch (Kind) {
55 default:
58 return 1;
60 return 2;
78 return 4;
80 return 8;
81 }
82}
83
84namespace {
86protected:
87 const Target &TheTarget;
88
89public:
90 VEAsmBackend(const Target &T)
92
93 MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override {
95
96 {"fixup_ve_reflong", 0, 32, 0}, {"fixup_ve_srel32", 0, 32, 0},
97 {"fixup_ve_hi32", 0, 32, 0}, {"fixup_ve_lo32", 0, 32, 0},
98 {"fixup_ve_pc_hi32", 0, 32, 0}, {"fixup_ve_pc_lo32", 0, 32, 0},
99 {"fixup_ve_got_hi32", 0, 32, 0}, {"fixup_ve_got_lo32", 0, 32, 0},
100 {"fixup_ve_gotoff_hi32", 0, 32, 0}, {"fixup_ve_gotoff_lo32", 0, 32, 0},
101 {"fixup_ve_plt_hi32", 0, 32, 0}, {"fixup_ve_plt_lo32", 0, 32, 0},
102 {"fixup_ve_tls_gd_hi32", 0, 32, 0}, {"fixup_ve_tls_gd_lo32", 0, 32, 0},
103 {"fixup_ve_tpoff_hi32", 0, 32, 0}, {"fixup_ve_tpoff_lo32", 0, 32, 0},
104 };
105
108
110 "Invalid kind!");
112 }
113
114 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &,
115 uint8_t *, uint64_t Value, bool IsResolved) override;
116
118 const MCSubtargetInfo &STI) const override {
119
120
121
122 return false;
123 }
124
125 bool writeNopData(raw_ostream &OS, uint64_t Count,
126 const MCSubtargetInfo *STI) const override {
127 if ((Count % 8) != 0)
128 return false;
129
130 for (uint64_t i = 0; i < Count; i += 8)
133
134 return true;
135 }
136};
137
138class ELFVEAsmBackend : public VEAsmBackend {
140
141public:
143 : VEAsmBackend(T), OSType(OSType) {}
144
145 std::unique_ptr
146 createObjectTargetWriter() const override {
149 }
150};
151}
152
156 switch (Fixup.getKind()) {
161 IsResolved = false;
162 break;
163 }
164 maybeAddReloc(F, Fixup, Target, Value, IsResolved);
167 return;
168
169 MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
170
171
173
175 assert(Fixup.getOffset() + NumBytes <= F.getSize() &&
176 "Invalid fixup offset!");
177
178
179
180 for (unsigned i = 0; i != NumBytes; ++i) {
182 Data[Idx] |= static_cast<uint8_t>((Value >> (i * 8)) & 0xff);
183 }
184}
185
unsigned const MachineRegisterInfo * MRI
static unsigned getFixupKindNumBytes(unsigned Kind)
The number of bytes the fixup may change.
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!")
Analysis containing CSE Info
PowerPC TLS Dynamic Call Fixup
static uint64_t adjustFixupValue(unsigned Kind, uint64_t Value)
Definition VEAsmBackend.cpp:22
static unsigned getFixupKindNumBytes(unsigned Kind)
getFixupKindNumBytes - The number of bytes the fixup may change.
Definition VEAsmBackend.cpp:53
Generic interface to target specific assembler backends.
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
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.
OSType getOS() const
Get the parsed operating system type of this triple.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ fixup_ve_srel32
fixup_ve_srel32 - 32-bit fixup corresponding to foo for relative branch
@ fixup_ve_got_hi32
fixup_ve_got_hi32 - 32-bit fixup corresponding to foo@got_hi
@ fixup_ve_gotoff_hi32
fixup_ve_gotoff_hi32 - 32-bit fixup corresponding to foo@gotoff_hi
@ fixup_ve_got_lo32
fixup_ve_got_lo32 - 32-bit fixup corresponding to foo@got_lo
@ fixup_ve_pc_hi32
fixup_ve_pc_hi32 - 32-bit fixup corresponding to foo@pc_hi
@ fixup_ve_lo32
fixup_ve_lo32 - 32-bit fixup corresponding to foo@lo
@ fixup_ve_gotoff_lo32
fixup_ve_gotoff_lo32 - 32-bit fixup corresponding to foo@gotoff_lo
@ fixup_ve_hi32
fixup_ve_hi32 - 32-bit fixup corresponding to foo@hi
@ fixup_ve_pc_lo32
fixup_ve_pc_lo32 - 32-bit fixup corresponding to foo@pc_lo
@ fixup_ve_plt_hi32
fixup_ve_plt_hi32/lo32
@ fixup_ve_reflong
fixup_ve_reflong - 32-bit fixup corresponding to foo
@ fixup_ve_tls_gd_hi32
fixups for Thread Local Storage
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const ArmConfig &ArmCfg)
Apply fixup expression for edge to block content.
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
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.
FunctionAddr VTableAddr Count
MCAsmBackend * createVEAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Definition VEAsmBackend.cpp:186
@ 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
ArrayRef(const T &OneElt) -> ArrayRef< T >
std::unique_ptr< MCObjectTargetWriter > createVEELFObjectWriter(uint8_t OSABI)