LLVM: include/llvm/ExecutionEngine/JITLink/systemz.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_EXECUTIONENGINE_JITLINK_SYSTEMZ_H
14#define LLVM_EXECUTIONENGINE_JITLINK_SYSTEMZ_H
15
18
20
21namespace llvm {
24
25
27
28
29
30
31
32
34
35
36
37
38
39
40
41
42
43
45
46
47
48
49
50
51
52
53
54
56
57
58
59
60
61
62
63
64
65
67
68
69
70
71
72
73
74
75
76
78
79
80
81
82
83
84
85
86
87
89
90
91
92
93
94
95
96
98
99
100
101
102
103
104
105
106
107
108
109
111
112
113
114
115
116
117
118
119
120
121
122
124
125
126
127
128
129
130
131
132
133
134
135
136
137
139
140
141
142
143
144
145
146
147
148
149
150
151
152
154
155
156
157
158
159
160
161
162
163
164
165
166
167
169
170
171
172
173
174
175
176
177
178
179
180
181
182
184
185
186
187
188
189
190
191
193
194
195
196
197
198
199
200
201
202
203
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
269
270
271
272
273
274
275
276
277
279
280
281
282
283
284
285
286
287
288
289
290
291
293
294
295
296
297
298
299
300
301
302
304
305
306
307
308
309
310
311
312
313
314
315
317
318
319
320
321
322
323
324
325
326
327
328
330
331
332
333
334
335
336
337
338
339
341
342
343
344
345
346
347
348
349
350
351
352
354
355
356
357
358
359
360
361
362
363
364
365
367
368
369
370
371
372
373
374
375
376
377
378
380
381
382
383
384
385
386
387
388
389
390
391
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
509
510
511
512
513
514
515
516
517
518
519
520
522
523
524
525
526
527
528
529
530
531
532
533
534
535
537
538};
539
540
541
543
544
546 const Symbol *GOTSymbol) {
548
549 char *BlockWorkingMem = B.getAlreadyMutableContent().data();
550 char *FixupPtr = BlockWorkingMem + E.getOffset();
552 int64_t S = E.getTarget().getAddress().getValue();
553 int64_t A = E.getAddend();
554 int64_t P = FixupAddress.getValue();
555 int64_t GOTBase = GOTSymbol ? GOTSymbol->getAddress().getValue() : 0;
556 Edge::Kind K = E.getKind();
557
559 dbgs() << " Applying fixup on " << G.getEdgeKindName(K)
560 << " edge, (S, A, P, .GOT.) = (" << formatv("{0:x}", S) << ", "
561 << formatv("{0:x}", A) << ", " << formatv("{0:x}", P) << ", "
562 << formatv("{0:x}", GOTBase) << ")\n";
563 });
564
567 };
568
569 switch (K) {
573 break;
574 }
580 break;
581 }
587 ((Value & 0xFFF) << 16) | ((Value & 0xFF000) >> 4));
588 break;
589 }
595 break;
596 }
602 break;
603 }
609 break;
610 }
613 int64_t Value = S + A - P;
615 break;
616 }
619 int64_t Value = S + A - P;
623 break;
624 }
626 int64_t Value = S + A - P;
630 break;
631 }
633 int64_t Value = P + A - S;
637 break;
638 }
641 int64_t Value = S + A - P;
647 break;
648 }
651 int64_t Value = S + A - P;
656 FixupPtr[0] = Value >> 17;
657 FixupPtr[1] = Value >> 9;
658 FixupPtr[2] = Value >> 1;
659 break;
660 }
663 int64_t Value = S + A - P;
669 break;
670 }
673 int64_t Value = S + A - P;
679 (read16be(FixupPtr) & 0xF000) | ((Value >> 1) & 0x0FFF));
680 break;
681 }
683 assert(GOTSymbol && "No GOT section symbol");
684 int64_t Value = GOTBase + A - P;
688 break;
689 }
691 assert(GOTSymbol && "No GOT section symbol");
692 int64_t Value = GOTBase + A - P;
698 break;
699 }
702 assert(GOTSymbol && "No GOT section symbol");
703 int64_t Value = S + A - GOTBase;
705 break;
706 }
709 assert(GOTSymbol && "No GOT section symbol");
710 int64_t Value = S + A - GOTBase;
714 break;
715 }
718 assert(GOTSymbol && "No GOT section symbol");
719 int64_t Value = S + A - GOTBase;
723 break;
724 }
726 assert(GOTSymbol && "No GOT section symbol");
731 ((Value & 0xFFF) << 16) | ((Value & 0xFF000) >> 4));
732 break;
733 }
735 assert(GOTSymbol && "No GOT section symbol");
740 break;
741 }
742 default:
744 "In graph " + G.getName() + ", section " + B.getSection().getName() +
745 " unsupported edge kind " + getEdgeKindName(E.getKind()));
746 }
747
749}
750
751
755 G.getPointerSize()};
756}
757
758
759
760
761
762
763
768 return {reinterpret_cast<const char *>(StubContent), StubEntrySize};
769}
770
771
772
773
774
775
777 Symbol *InitialTarget = nullptr,
778 uint64_t InitialAddend = 0) {
781 if (InitialTarget)
782 B.addEdge(Pointer64, 0, *InitialTarget, InitialAddend);
783 return G.addAnonymousSymbol(B, 0, G.getPointerSize(), false, false);
784}
785
786
787
788
789
790
792 Symbol &PointerSymbol) {
795 B.addEdge(Delta32dbl, 2, PointerSymbol, 2);
796 return B;
797}
798
799
800
801
802
805 Symbol &PointerSymbol) {
806 return G.addAnonymousSymbol(
809}
810
811
813public:
815
817 if (E.getTarget().isDefined())
818 return false;
819 Edge::Kind KindToSet = Edge::Invalid;
820 switch (E.getKind()) {
823 break;
826 break;
829 break;
832 break;
835 break;
838 break;
839 default:
840 return false;
841 }
842 assert(KindToSet != Edge::Invalid &&
843 "Fell through switch, but no new kind to set");
845 dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "
846 << B->getFixupAddress(E) << " (" << B->getAddress() << " + "
847 << formatv("{0:x}", E.getOffset()) << ")\n";
848 });
849 E.setKind(KindToSet);
851 return true;
852 }
853
857
858private:
860 if (!GOTSection)
863 return *GOTSection;
864 }
865
866 Section *GOTSection = nullptr;
867};
868
869
871public:
873
875
877 if (E.getTarget().isDefined())
878 return false;
879
880 switch (E.getKind()) {
890 break;
891 default:
892 return false;
893 }
895 dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "
896 << B->getFixupAddress(E) << " (" << B->getAddress() << " + "
897 << formatv("{0:x}", E.getOffset()) << ")\n";
898 });
900 return true;
901 }
902
907
908public:
915
918};
919
920}
921}
922}
923
924#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_UNLIKELY(EXPR)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
LLVM Value Representation.
An Addressable with content and edges.
Represents fixups and constraints in the LinkGraph.
Represents an object file section.
orc::ExecutorAddr getAddress() const
Returns the address of this symbol.
A CRTP base for tables that are built on demand, e.g.
Symbol & getEntryForTarget(LinkGraph &G, Symbol &Target)
Global Offset Table Builder.
Definition systemz.h:812
Symbol & createEntry(LinkGraph &G, Symbol &Target)
Definition systemz.h:854
static StringRef getSectionName()
Definition systemz.h:814
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
Definition systemz.h:816
PLTTableManager(GOTTableManager &GOT)
Definition systemz.h:872
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
Definition systemz.h:876
GOTTableManager & GOT
Definition systemz.h:916
Section & getStubsSection(LinkGraph &G)
Definition systemz.h:909
static StringRef getSectionName()
Definition systemz.h:874
Section * StubsSection
Definition systemz.h:917
Symbol & createEntry(LinkGraph &G, Symbol &Target)
Definition systemz.h:903
Represents an address in the executor process.
uint64_t getValue() const
ArrayRef< char > getGOTEntryBlockContent(LinkGraph &G)
Definition systemz.h:753
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol)
Apply fixup expression for edge to block content.
Definition systemz.h:545
Symbol & createAnonymousPointerJumpStub(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Create a jump stub that jumps via the pointer at the given symbol and an anonymous symbol pointing to...
Definition systemz.h:803
Symbol & createAnonymousPointer(LinkGraph &G, Section &PointerSection, Symbol *InitialTarget=nullptr, uint64_t InitialAddend=0)
Creates a new pointer block in the given section and returns an Anonymous symbol pointing to it.
Definition systemz.h:776
const char NullPointerContent[8]
SystemZ null pointer content.
EdgeKind_systemz
Represents systemz fixups and other systemz-specific edge kinds.
Definition systemz.h:26
@ DeltaPLT32
A 32-bit Delta.
Definition systemz.h:292
@ Delta64PLTFromGOT
A 64-bit offset from GOT to PLT.
Definition systemz.h:303
@ Pointer16
A plain 16-bit pointer value relocation.
Definition systemz.h:66
@ RequestGOTAndTransformToDelta32FromGOT
A GOT entry getter/constructor, transformed to Delta32FromGOT pointing at the GOT entry for the origi...
Definition systemz.h:430
@ RequestGOTAndTransformToDelta32dbl
A GOT entry getter/constructor, transformed to Delta32dbl pointing at the GOT entry for the original ...
Definition systemz.h:508
@ Pointer64
A plain 64-bit pointer value relocation.
Definition systemz.h:33
@ Pointer20
A plain 20-bit pointer value relocation.
Definition systemz.h:55
@ RequestGOTAndTransformToDelta16FromGOT
A GOT entry getter/constructor, transformed to Delta16FromGOT pointing at the GOT entry for the origi...
Definition systemz.h:468
@ RequestGOTAndTransformToDelta12FromGOT
A GOT entry getter/constructor, transformed to Delta12FromGOT pointing at the GOT entry for the origi...
Definition systemz.h:488
@ RequestGOTAndTransformToDelta64FromGOT
A GOT entry getter/constructor, transformed to Delta64FromGOT pointing at the GOT entry for the origi...
Definition systemz.h:411
@ DeltaPLT16dbl
A 16-bit Delta shifted by 1.
Definition systemz.h:252
@ Delta20FromGOT
A 20-bit offset from GOT.
Definition systemz.h:379
@ Delta16FromGOT
A 16-bit offset from GOT.
Definition systemz.h:366
@ Pointer8
A plain 8-bit pointer value relocation.
Definition systemz.h:88
@ Delta16PLTFromGOT
A 16-bit offset from GOT to PLT.
Definition systemz.h:329
@ NegDelta64
A 64-bit negative delta.
Definition systemz.h:192
@ Delta32PLTFromGOT
A 32-bit offset from GOT to PLT.
Definition systemz.h:316
@ Delta32dblGOTBase
A 32-bit Delta to GOT base shifted by 1.
Definition systemz.h:536
@ Delta32FromGOT
A 32-bit offset from GOT.
Definition systemz.h:353
@ Delta32GOTBase
A 32-bit Delta to GOT base.
Definition systemz.h:521
@ Delta16
A 16-bit delta.
Definition systemz.h:123
@ DeltaPLT12dbl
A 12-bit Delta shifted by 1.
Definition systemz.h:268
@ Delta64
A 64-bit delta.
Definition systemz.h:97
@ RequestGOTAndTransformToDelta20FromGOT
A GOT entry getter/constructor, transformed to Delta20FromGOT pointing at the GOT entry for the origi...
Definition systemz.h:449
@ Delta16dbl
A 16-bit delta shifted by 1.
Definition systemz.h:168
@ Delta12FromGOT
A 12-bit offset from GOT.
Definition systemz.h:392
@ DeltaPLT32dbl
A 32-bit Delta shifted by 1.
Definition systemz.h:220
@ NegDelta32
A 32-bit negative delta.
Definition systemz.h:204
@ Delta24dbl
A 24-bit delta shifted by 1.
Definition systemz.h:153
@ Delta32
A 32-bit delta.
Definition systemz.h:110
@ DeltaPLT64
A 64-bit Delta.
Definition systemz.h:278
@ DeltaPLT24dbl
A 24-bit Delta shifted by 1.
Definition systemz.h:236
@ Pointer12
A plain 12-bit pointer value relocation.
Definition systemz.h:77
@ Delta12dbl
A 12-bit delta shifted by 1.
Definition systemz.h:183
@ Pointer32
A plain 32-bit pointer value relocation.
Definition systemz.h:44
@ Delta32dbl
A 32-bit delta shifted by 1.
Definition systemz.h:138
@ Delta64FromGOT
A 64-bit offset from GOT.
Definition systemz.h:340
const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given systemz edge.
Block & createPointerJumpStubBlock(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Create a jump stub block that jumps via the pointer at the given symbol.
Definition systemz.h:791
constexpr size_t StubEntrySize
SystemZ pointer jump stub content.
Definition systemz.h:764
ArrayRef< char > getStubBlockContent(LinkGraph &G)
Definition systemz.h:766
const char Pointer64JumpStubContent[StubEntrySize]
LLVM_ABI Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B, const Edge &E)
Create an out of range error for the given edge in the given block.
LLVM_ABI Error makeAlignmentError(llvm::orc::ExecutorAddr Loc, uint64_t Value, int N, const Edge &E)
static bool isAlignmentCorrect(uint64_t Value, int N)
void write16be(void *P, uint16_t V)
void write32be(void *P, uint32_t V)
uint32_t read32be(const void *P)
void write64be(void *P, uint64_t V)
uint16_t read16be(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.