@@ -98,6 +98,7 @@ enum EdgeKind_aarch32 : Edge::Kind {
98
98
Thumb_MovtPrel,
99
99
100
100
LastThumbRelocation = Thumb_MovtPrel,
101
+ LastRelocation = LastThumbRelocation,
101
102
};
102
103
103
104
// / Flags enum for AArch32-specific symbol properties
@@ -163,65 +164,107 @@ struct HalfWords {
163
164
const uint16_t Lo; // Second halfword
164
165
};
165
166
166
- // / Collection of named constants per fixup kind. It may contain but is not
167
- // / limited to the following entries:
167
+ // / FixupInfo base class is required for dynamic lookups.
168
+ struct FixupInfoBase {
169
+ static const FixupInfoBase *getDynFixupInfo (Edge::Kind K);
170
+ virtual ~FixupInfoBase () {}
171
+ };
172
+
173
+ // / FixupInfo checks for Arm edge kinds work on 32-bit words
174
+ struct FixupInfoArm : public FixupInfoBase {
175
+ bool (*checkOpcode)(uint32_t Wd) = nullptr ;
176
+ };
177
+
178
+ // / FixupInfo check for Thumb32 edge kinds work on a pair of 16-bit halfwords
179
+ struct FixupInfoThumb : public FixupInfoBase {
180
+ bool (*checkOpcode)(uint16_t Hi, uint16_t Lo) = nullptr ;
181
+ };
182
+
183
+ // / Collection of named constants per fixup kind
168
184
// /
185
+ // / Mandatory entries:
169
186
// / Opcode - Values of the op-code bits in the instruction, with
170
187
// / unaffected bits nulled
171
188
// / OpcodeMask - Mask with all bits set that encode the op-code
189
+ // /
190
+ // / Other common entries:
172
191
// / ImmMask - Mask with all bits set that encode the immediate value
173
192
// / RegMask - Mask with all bits set that encode the register
174
193
// /
194
+ // / Specializations can add further custom fields without restrictions.
195
+ // /
175
196
template <EdgeKind_aarch32 Kind> struct FixupInfo {};
176
197
177
- template <> struct FixupInfo <Arm_Jump24> {
198
+ namespace {
199
+ struct FixupInfoArmBranch : public FixupInfoArm {
178
200
static constexpr uint32_t Opcode = 0x0a000000 ;
179
- static constexpr uint32_t OpcodeMask = 0x0f000000 ;
180
201
static constexpr uint32_t ImmMask = 0x00ffffff ;
181
- static constexpr uint32_t Unconditional = 0xe0000000 ;
182
- static constexpr uint32_t CondMask = 0xe0000000 ; // excluding BLX bit
202
+ };
203
+ } // namespace
204
+
205
+ template <> struct FixupInfo <Arm_Jump24> : public FixupInfoArmBranch {
206
+ static constexpr uint32_t OpcodeMask = 0x0f000000 ;
183
207
};
184
208
185
- template <> struct FixupInfo <Arm_Call> : public FixupInfo<Arm_Jump24> {
209
+ template <> struct FixupInfo <Arm_Call> : public FixupInfoArmBranch {
186
210
static constexpr uint32_t OpcodeMask = 0x0e000000 ;
211
+ static constexpr uint32_t CondMask = 0xe0000000 ; // excluding BLX bit
212
+ static constexpr uint32_t Unconditional = 0xe0000000 ;
187
213
static constexpr uint32_t BitH = 0x01000000 ;
188
214
static constexpr uint32_t BitBlx = 0x10000000 ;
189
215
};
190
216
191
- template <> struct FixupInfo <Arm_MovtAbs> {
192
- static constexpr uint32_t Opcode = 0x03400000 ;
217
+ namespace {
218
+ struct FixupInfoArmMov : public FixupInfoArm {
193
219
static constexpr uint32_t OpcodeMask = 0x0ff00000 ;
194
220
static constexpr uint32_t ImmMask = 0x000f0fff ;
195
221
static constexpr uint32_t RegMask = 0x0000f000 ;
196
222
};
223
+ } // namespace
197
224
198
- template <> struct FixupInfo <Arm_MovwAbsNC> : public FixupInfo<Arm_MovtAbs> {
225
+ template <> struct FixupInfo <Arm_MovtAbs> : public FixupInfoArmMov {
226
+ static constexpr uint32_t Opcode = 0x03400000 ;
227
+ };
228
+
229
+ template <> struct FixupInfo <Arm_MovwAbsNC> : public FixupInfoArmMov {
199
230
static constexpr uint32_t Opcode = 0x03000000 ;
200
231
};
201
232
202
- template <> struct FixupInfo <Thumb_Jump24> {
233
+ template <> struct FixupInfo <Thumb_Jump24> : public FixupInfoThumb {
203
234
static constexpr HalfWords Opcode{0xf000 , 0x9000 };
204
235
static constexpr HalfWords OpcodeMask{0xf800 , 0x9000 };
205
236
static constexpr HalfWords ImmMask{0x07ff , 0x2fff };
206
237
};
207
238
208
- template <> struct FixupInfo <Thumb_Call> {
239
+ template <> struct FixupInfo <Thumb_Call> : public FixupInfoThumb {
209
240
static constexpr HalfWords Opcode{0xf000 , 0xc000 };
210
241
static constexpr HalfWords OpcodeMask{0xf800 , 0xc000 };
211
242
static constexpr HalfWords ImmMask{0x07ff , 0x2fff };
212
243
static constexpr uint16_t LoBitH = 0x0001 ;
213
244
static constexpr uint16_t LoBitNoBlx = 0x1000 ;
214
245
};
215
246
216
- template <> struct FixupInfo <Thumb_MovtAbs> {
217
- static constexpr HalfWords Opcode{ 0xf2c0 , 0x0000 };
247
+ namespace {
248
+ struct FixupInfoThumbMov : public FixupInfoThumb {
218
249
static constexpr HalfWords OpcodeMask{0xfbf0 , 0x8000 };
219
250
static constexpr HalfWords ImmMask{0x040f , 0x70ff };
220
251
static constexpr HalfWords RegMask{0x0000 , 0x0f00 };
221
252
};
253
+ } // namespace
222
254
223
- template <>
224
- struct FixupInfo <Thumb_MovwAbsNC> : public FixupInfo<Thumb_MovtAbs> {
255
+ template <> struct FixupInfo <Thumb_MovtAbs> : public FixupInfoThumbMov {
256
+ static constexpr HalfWords Opcode{0xf2c0 , 0x0000 };
257
+ };
258
+
259
+ template <> struct FixupInfo <Thumb_MovtPrel> : public FixupInfoThumbMov {
260
+ static constexpr HalfWords Opcode{0xf2c0 , 0x0000 };
261
+ };
262
+
263
+ template <> struct FixupInfo <Thumb_MovwAbsNC> : public FixupInfoThumbMov {
264
+ static constexpr HalfWords Opcode{0xf240 , 0x0000 };
265
+ };
266
+
267
+ template <> struct FixupInfo <Thumb_MovwPrelNC> : public FixupInfoThumbMov {
225
268
static constexpr HalfWords Opcode{0xf240 , 0x0000 };
226
269
};
227
270
@@ -295,7 +338,7 @@ class StubsManager : public TableManager<StubsManager<Flavor>> {
295
338
StubsManager () = default ;
296
339
297
340
// / Name of the object file section that will contain all our stubs.
298
- static StringRef getSectionName () { return " __llvm_jitlink_STUBS " ; }
341
+ static StringRef getSectionName ();
299
342
300
343
// / Implements link-graph traversal via visitExistingEdges().
301
344
bool visitEdge (LinkGraph &G, Block *B, Edge &E) {
@@ -345,6 +388,10 @@ class StubsManager : public TableManager<StubsManager<Flavor>> {
345
388
template <>
346
389
Symbol &StubsManager<Thumbv7>::createEntry(LinkGraph &G, Symbol &Target);
347
390
391
+ template <> inline StringRef StubsManager<Thumbv7>::getSectionName() {
392
+ return " __llvm_jitlink_aarch32_STUBS_Thumbv7" ;
393
+ }
394
+
348
395
} // namespace aarch32
349
396
} // namespace jitlink
350
397
} // namespace llvm
0 commit comments