/
LLVM.pm
938 lines (751 loc) · 31.1 KB
/
LLVM.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
module LLVM {
our %F;
=item call
Call LLVM with check that function is actually bound.
sub call($name, *@args) {
my $m := %F{$name};
pir::die("Function LLVM{ $name } isn't bound") unless pir::defined($m);
$m(|@args);
}
=item convert_to_array
Convert @args to array used in LLVM API.
sub to_array(@args) {
my @init;
for @args {
@init.push(-100); # INTVAL. BAD. WE NEED PTR
@init.push(0);
@init.push(0);
}
my $struct := pir::new__psp('ManagedStruct', @init);
my $count := 0;
for @args {
Q:PIR{
.local pmc args, count, arg
args = find_lex '$struct'
count = find_lex '$count'
$I0 = count
arg = find_lex '$_'
$I1 = get_addr arg
args[$I0] = $I1
};
$count++;
}
$struct;
}
INIT {
pir::load_bytecode("nqp-setting.pbc");
#### Bind enums
# For enums we generate new class and bunch of methods.
sub generate_enum_class($name, $from, @values, &inc?) {
my $enum := P6metaclass.new_class($name);
my $how := $enum.HOW;
for @values {
my $c := +$from; # Force clone of $count.
$how.add_method( $_, method () { $c }, to => $enum);
$from := &inc ?? &inc($from) !! $from++;
}
};
=begin
typedef enum {
LLVMIntEQ = 32, /**< equal */
LLVMIntNE, /**< not equal */
LLVMIntUGT, /**< unsigned greater than */
LLVMIntUGE, /**< unsigned greater or equal */
LLVMIntULT, /**< unsigned less than */
LLVMIntULE, /**< unsigned less or equal */
LLVMIntSGT, /**< signed greater than */
LLVMIntSGE, /**< signed greater or equal */
LLVMIntSLT, /**< signed less than */
LLVMIntSLE /**< signed less or equal */
} LLVMIntPredicate;
=end
generate_enum_class("LLVM::INT_PREDICATE", 32, <EQ NE UGT UGE ULT ULE SGT SGE SLT SLE>);
=begin
typedef enum {
LLVMRealPredicateFalse, /**< Always false (always folded) */
LLVMRealOEQ, /**< True if ordered and equal */
LLVMRealOGT, /**< True if ordered and greater than */
LLVMRealOGE, /**< True if ordered and greater than or equal */
LLVMRealOLT, /**< True if ordered and less than */
LLVMRealOLE, /**< True if ordered and less than or equal */
LLVMRealONE, /**< True if ordered and operands are unequal */
LLVMRealORD, /**< True if ordered (no nans) */
LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
LLVMRealUEQ, /**< True if unordered or equal */
LLVMRealUGT, /**< True if unordered or greater than */
LLVMRealUGE, /**< True if unordered, greater than, or equal */
LLVMRealULT, /**< True if unordered or less than */
LLVMRealULE, /**< True if unordered, less than, or equal */
LLVMRealUNE, /**< True if unordered or not equal */
LLVMRealPredicateTrue /**< Always true (always folded) */
} LLVMRealPredicate;
=end
generate_enum_class("LLVM::REAL_PREDICATE", 0, <FALSE OEQ OGT OGE OLT OLE ONE ORD UNO UEQ UGT UGE ULT ULE UNE TRUE>);
=begin
typedef enum {
LLVMAbortProcessAction, /* verifier will print to stderr and abort() */
LLVMPrintMessageAction, /* verifier will print to stderr and return 1 */
LLVMReturnStatusAction /* verifier will just return 1 */
} LLVMVerifierFailureAction;
=end
generate_enum_class("LLVM::VERIFYER_FAILURE_ACTION", 0, <ABORT_PROCESSING PRINT_MESSAGE RETURN_STATUS>);
#### Bind functions
my $lib := pir::loadlib("/usr/lib/libLLVM-2.7.so.1");
my %funcs := hash(
#/*===-- Error handling ----------------------------------------------------===*/
DisposeMessage => "vt",
#/*===-- Contexts ----------------------------------------------------------===*/
#/* Create and destroy contexts. */
ContextCreate => "p",
GetGlobalContext => "p",
ContextDispose => "vp",
GetMDKindIDInContext => "ipti",
GetMDKindID => "iti",
#/*===-- Modules -----------------------------------------------------------===*/
#/* Create and destroy modules. */
#/** See llvm::Module::Module. */
ModuleCreateWithName => "pt",
ModuleCreateWithNameInContext => "ptp",
#/** See llvm::Module::~Module. */
DisposeModule => "vp",
#/** Data layout. See Module::getDataLayout. */
GetDataLayout => "tp",
SetDataLayout => "vpt",
#/** Target triple. See Module::getTargetTriple. */
GetTarget => "tp",
SetTarget => "vpt",
#/** See Module::addTypeName. */
AddTypeName => "iptp",
DeleteTypeName => "vpt",
GetTypeByName => "ppt",
#/** See Module::dump. */
DumpModule => "vp",
#/*===-- Types -------------------------------------------------------------===*/
#/** See llvm::LLVMTypeKind::getTypeID. */
GetTypeKind => "pp",
#/** See llvm::LLVMType::getContext. */
GetTypeContext => "pp",
#/* Operations on integer types */
Int1TypeInContext => "pp",
Int8TypeInContext => "pp",
Int16TypeInContext => "pp",
Int32TypeInContext => "pp",
Int64TypeInContext => "pp",
IntTypeInContext => "ppi",
Int1Type => "p",
Int8Type => "p",
Int16Type => "p",
Int32Type => "p",
Int64Type => "p",
IntType => "pi",
GetIntTypeWidth => "ip",
#/* Operations on real types */
FloatTypeInContext => "pp",
DoubleTypeInContext => "pp",
X86FP80TypeInContext => "pp",
FP128TypeInContext => "pp",
PPCFP128TypeInContext => "pp",
FloatType => "p",
DoubleType => "p",
X86FP80Type => "p",
FP128Type => "p",
PPCFP128Type => "p",
#/* Operations on function types */
FunctionType => "pppii",
IsFunctionVarArg => "ip",
GetReturnType => "pp",
CountParamTypes => "ip",
GetParamTypes => "vpp",
#/* Operations on struct types */
StructTypeInContext => "pppii",
StructType => "ppii",
CountStructElementTypes => "ip",
GetStructElementTypes => "vpp",
IsPackedStruct => "ip",
#/* Operations on union types */
UnionTypeInContext => "pppi",
UnionType => "ppi",
CountUnionElementTypes => "ip",
GetUnionElementTypes => "vpp",
#/* Operations on array, pointer, and vector types (sequence types) */
ArrayType => "ppi",
PointerType => "ppi",
VectorType => "ppi",
GetElementType => "pp",
GetArrayLength => "ip",
GetPointerAddressSpace => "ip",
GetVectorSize => "ip",
#/* Operations on other types */
VoidTypeInContext => "pp",
LabelTypeInContext => "pp",
OpaqueTypeInContext => "pp",
VoidType => "p",
LabelType => "p",
OpaqueType => "p",
#/* Operations on type handles */
CreateTypeHandle => "pp",
RefineType => "vpp",
ResolveTypeHandle => "pp",
DisposeTypeHandle => "vp",
#/*===-- Values ------------------------------------------------------------===*/
#/* Operations on all values */
TypeOf => "pp",
GetValueName => "tp",
SetValueName => "vpt",
DumpValue => "vp",
ReplaceAllUsesWith => "vpp",
HasMetadata => "ip",
GetMetadata => "ppi",
SetMetadata => "vpip",
# Conversion functions. Return the input value if it is an instance of the
# specified class, otherwise NULL. See llvm::dyn_cast_or_null<>.
# #define LLVM_DECLARE_VALUE_CAST(name) \
# LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
# LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
#/* Operations on Uses */
GetFirstUse => "pp",
GetNextUse => "pp",
GetUser => "pp",
GetUsedValue => "pp",
#/* Operations on Users */
GetOperand => "ppi",
#/* Operations on constants of any type */
ConstNull => "pp",
ConstAllOnes => "pp",
GetUndef => "pp",
IsConstant => "ip",
IsNull => "ip",
IsUndef => "ip",
ConstPointerNull => "pp",
#/* Operations on metadata */
MDStringInContext => "ppti",
MDString => "pti",
MDNodeInContext => "pppi",
MDNode => "ppi",
#/* Operations on scalar constants */
ConstInt => "ppii",
ConstIntOfString => "ppti",
ConstIntOfStringAndSize => "pptii",
ConstReal => "ppd",
ConstRealOfString => "ppt",
ConstRealOfStringAndSize => "ppti",
ConstIntGetZExtValue => "ip",
ConstIntGetSExtValue => "ip",
#/* Operations on composite constants */
ConstStringInContext => "pptii",
ConstStructInContext => "pppii",
ConstString => "ptii",
ConstArray => "pppi",
ConstStruct => "ppii",
ConstVector => "ppi",
ConstUnion => "ppp",
#/* Constant expressions */
GetConstOpcode => "ip",
AlignOf => "pp",
SizeOf => "pp",
ConstNeg => "pp",
ConstNSWNeg => "pp",
ConstNUWNeg => "pp",
ConstFNeg => "pp",
ConstNot => "pp",
ConstAdd => "ppp",
ConstNSWAdd => "ppp",
ConstNUWAdd => "ppp",
ConstFAdd => "ppp",
ConstSub => "ppp",
ConstNSWSub => "ppp",
ConstNUWSub => "ppp",
ConstFSub => "ppp",
ConstMul => "ppp",
ConstNSWMul => "ppp",
ConstNUWMul => "ppp",
ConstFMul => "ppp",
ConstUDiv => "ppp",
ConstSDiv => "ppp",
ConstExactSDiv => "ppp",
ConstFDiv => "ppp",
ConstURem => "ppp",
ConstSRem => "ppp",
ConstFRem => "ppp",
ConstAnd => "ppp",
ConstOr => "ppp",
ConstXor => "ppp",
ConstICmp => "pppp",
ConstFCmp => "pppp",
ConstShl => "ppp",
ConstLShr => "ppp",
ConstAShr => "ppp",
ConstGEP => "pppi",
ConstInBoundsGEP => "pppi",
ConstTrunc => "ppp",
ConstSExt => "ppp",
ConstZExt => "ppp",
ConstFPTrunc => "ppp",
ConstFPExt => "ppp",
ConstUIToFP => "ppp",
ConstSIToFP => "ppp",
ConstFPToUI => "ppp",
ConstFPToSI => "ppp",
ConstPtrToInt => "ppp",
ConstIntToPtr => "ppp",
ConstBitCast => "ppp",
ConstZExtOrBitCast => "ppp",
ConstSExtOrBitCast => "ppp",
ConstTruncOrBitCast => "ppp",
ConstPointerCast => "ppp",
ConstIntCast => "pppp",
ConstFPCast => "ppp",
ConstSelect => "pppp",
ConstExtractElement => "ppp",
ConstInsertElement => "pppp",
ConstShuffleVector => "pppp",
ConstExtractValue => "pppi",
ConstInsertValue => "pppii", # FIXME
ConstInlineAsm => "ppttii",
BlockAddress => "ppp",
#/* Operations on global variables, functions, and aliases (globals) */
GetGlobalParent => "pp",
IsDeclaration => "ip",
GetLinkage => "ip",
SetLinkage => "vpi",
GetSection => "tp",
SetSection => "vpt",
GetVisibility => "ip",
SetVisibility => "vpi",
GetAlignment => "ip",
SetAlignment => "vpi",
#/* Operations on global variables */
AddGlobal => "pppt",
AddGlobalInAddressSpace => "pppti",
GetNamedGlobal => "ppt",
GetFirstGlobal => "pp",
GetLastGlobal => "pp",
GetNextGlobal => "pp",
GetPreviousGlobal => "pp",
DeleteGlobal => "vp",
GetInitializer => "vp",
SetInitializer => "vpp",
IsThreadLocal => "ip",
SetThreadLocal => "vpi",
IsGlobalConstant => "ip",
SetGlobalConstant => "vpi",
#/* Operations on aliases */
AddAlias => "ppppt",
#/* Operations on functions */
AddFunction => "pptp",
GetNamedFunction => "ppt",
GetFirstFunction => "pp",
GetLastFunction => "pp",
GetNextFunction => "pp",
GetPreviousFunction => "pp",
DeleteFunction => "vp",
GetIntrinsicID => "ip",
GetFunctionCallConv => "ip",
SetFunctionCallConv => "vpi",
GetGC => "tp",
SetGC => "vpt",
AddFunctionAttr => "vpi",
GetFunctionAttr => "ip",
RemoveFunctionAttr => "vpi",
#/* Operations on parameters */
CountParams => "ip",
GetParams => "vpp",
GetParam => "ppi",
GetParamParent => "pp",
GetFirstParam => "pp",
GetLastParam => "pp",
GetNextParam => "pp",
GetPreviousParam => "pp",
AddAttribute => "vpi",
RemoveAttribute => "vpi",
GetAttribute => "ip",
SetParamAlignment => "vpi",
#/* Operations on basic blocks */
BasicBlockAsValue => "pp",
ValueIsBasicBlock => "ip",
ValueAsBasicBlock => "pp",
GetBasicBlockParent => "pp",
CountBasicBlocks => "ip",
GetBasicBlocks => "vpp",
GetFirstBasicBlock => "pp",
GetLastBasicBlock => "pp",
GetNextBasicBlock => "pp",
GetPreviousBasicBlock => "pp",
GetEntryBasicBlock => "pp",
AppendBasicBlockInContext => "pppt",
InsertBasicBlockInContext => "pppt",
AppendBasicBlock => "ppt",
InsertBasicBlock => "ppt",
DeleteBasicBlock => "vp",
#/* Operations on instructions */
GetInstructionParent => "pp",
GetFirstInstruction => "pp",
GetLastInstruction => "pp",
GetNextInstruction => "pp",
GetPreviousInstruction => "pp",
#/* Operations on call sites */
SetInstructionCallConv => "vpi",
GetInstructionCallConv => "ip",
AddInstrAttribute => "vpii",
RemoveInstrAttribute => "vpii",
SetInstrParamAlignment => "vpii",
#/* Operations on call instructions (only) */
IsTailCall => "ip",
SetTailCall => "vpi",
#/* Operations on phi nodes */
AddIncoming => "vpppi",
CountIncoming => "ip",
GetIncomingValue => "ppi",
GetIncomingBlock => "ppi",
#/*===-- Instruction builders ----------------------------------------------===*/
# An instruction builder represents a point within a basic block, and is the
# exclusive means of building instructions using the C interface.
CreateBuilderInContext => "pp",
CreateBuilder => "p",
PositionBuilder => "vppp",
PositionBuilderBefore => "vpp",
PositionBuilderAtEnd => "vpp",
GetInsertBlock => "pp",
ClearInsertionPosition => "vp",
InsertIntoBuilder => "vpp",
InsertIntoBuilderWithName => "vppt",
DisposeBuilder => "vp",
#/* Metadata */
SetCurrentDebugLocation => "vpp",
GetCurrentDebugLocation => "pp",
SetInstDebugLocation => "vpp",
#/* Terminators */
BuildRetVoid => "pp",
BuildRet => "ppp",
BuildAggregateRet => "pppi",
BuildBr => "ppp",
BuildCondBr => "ppppp",
BuildSwitch => "ppppi",
BuildIndirectBr => "pppi",
BuildInvoke => "ppppippt",
BuildUnwind => "pp",
BuildUnreachable => "pp",
#/* Add a case to the switch instruction */
AddCase => "vppp",
#/* Add a destination to the indirectbr instruction */
AddDestination => "vpp",
#/* Arithmetic */
BuildAdd => "ppppt",
BuildNSWAdd => "ppppt",
BuildNUWAdd => "ppppt",
BuildFAdd => "ppppt",
BuildSub => "ppppt",
BuildNSWSub => "ppppt",
BuildNUWSub => "ppppt",
BuildFSub => "ppppt",
BuildMul => "ppppt",
BuildNSWMul => "ppppt",
BuildNUWMul => "ppppt",
BuildFMul => "ppppt",
BuildUDiv => "ppppt",
BuildSDiv => "ppppt",
BuildExactSDiv => "ppppt",
BuildFDiv => "ppppt",
BuildURem => "ppppt",
BuildSRem => "ppppt",
BuildFRem => "ppppt",
BuildShl => "ppppt",
BuildLShr => "ppppt",
BuildAShr => "ppppt",
BuildAnd => "ppppt",
BuildOr => "ppppt",
BuildXor => "ppppt",
BuildBinOp => "ppippt",
BuildNeg => "pppt",
BuildNSWNeg => "pppt",
BuildNUWNeg => "pppt",
BuildFNeg => "pppt",
BuildNot => "pppt",
#/* Memory */
BuildMalloc => "pppt",
BuildArrayMalloc => "ppppt",
BuildAlloca => "pppt",
BuildArrayAlloca => "ppppt",
BuildFree => "ppp",
BuildLoad => "pppt",
BuildStore => "pppp",
BuildGEP => "ppppit",
BuildInBoundsGEP => "ppppit",
BuildStructGEP => "pppit",
BuildGlobalString => "pptt",
BuildGlobalStringPtr => "pptt",
#/* Casts */
BuildTrunc => "ppppt",
BuildZExt => "ppppt",
BuildSExt => "ppppt",
BuildFPToUI => "ppppt",
BuildFPToSI => "ppppt",
BuildUIToFP => "ppppt",
BuildSIToFP => "ppppt",
BuildFPTrunc => "ppppt",
BuildFPExt => "ppppt",
BuildPtrToInt => "ppppt",
BuildIntToPtr => "ppppt",
BuildBitCast => "ppppt",
BuildZExtOrBitCast => "ppppt",
BuildSExtOrBitCast => "ppppt",
BuildTruncOrBitCast => "ppppt",
BuildCast => "ppppt",
BuildPointerCast => "ppppt",
BuildIntCast => "ppppt",
BuildFPCast => "ppppt",
#/* Comparisons */
BuildICmp => "ppippt",
BuildFCmp => "ppippt",
#/* Miscellaneous instructions */
BuildPhi => "pppt",
BuildCall => "ppppit",
BuildSelect => "pppppt",
BuildVAArg => "ppppt",
BuildExtractElement => "ppppt",
BuildInsertElement => "pppppt",
BuildShuffleVector => "pppppt",
BuildExtractValue => "ppppit",
BuildInsertValue => "ppppit",
BuildIsNull => "pppt",
BuildIsNotNull => "pppt",
BuildPtrDiff => "ppppt",
#/*===-- Module providers --------------------------------------------------===*/
# Changes the type of M so it can be passed to FunctionPassManagers and the
# JIT. They take ModuleProviders for historical reasons.
CreateModuleProviderForExistingModule => "pp",
# Destroys the module M.
DisposeModuleProvider => "vp",
#/*===-- Memory buffers ----------------------------------------------------===*/
CreateMemoryBufferWithContentsOfFile => "itpt", # FIXME
CreateMemoryBufferWithSTDIN => "ipt", # FIXME
DisposeMemoryBuffer => "vp",
#/*===-- Pass Managers -----------------------------------------------------===*/
# Constructs a new whole-module pass pipeline. This type of pipeline is
# suitable for link-time optimization and whole-module transformations.
# See llvm::PassManager::PassManager.
CreatePassManager => "p",
# Constructs a new function-by-function pass pipeline over the module
# provider. It does not take ownership of the module provider. This type of
# pipeline is suitable for code generation and JIT compilation tasks.
# See llvm::FunctionPassManager::FunctionPassManager. */
CreateFunctionPassManagerForModule => "pp",
# Deprecated: UseCreateFunctionPassManagerForModule instead. */
#LLVMPassManagerRefCreateFunctionPassManager(LLVMModuleProviderRef MP);
# Initializes, executes on the provided module, and finalizes all of the
# passes scheduled in the pass manager. Returns 1 if any of the passes
# modified the module, 0 otherwise. See llvm::PassManager::run(Module&). */
RunPassManager => "ipp",
# Initializes all of the function passes scheduled in the function pass
# manager. Returns 1 if any of the passes modified the module, 0 otherwise.
# See llvm::FunctionPassManager::doInitialization. */
InitializeFunctionPassManager => "ip",
# Executes all of the function passes scheduled in the function pass manager
# on the provided function. Returns 1 if any of the passes modified the
# function, false otherwise.
# See llvm::FunctionPassManager::run(Function&). */
RunFunctionPassManager => "ipp",
# Finalizes all of the function passes scheduled in in the function pass
# manager. Returns 1 if any of the passes modified the module, 0 otherwise.
# See llvm::FunctionPassManager::doFinalization. */
FinalizeFunctionPassManager => "ip",
# Frees the memory of a pass pipeline. For function pipelines, does not free
# the module provider.
# See llvm::PassManagerBase::~PassManagerBase. */
DisposePassManager => "vp",
##### Transform/Scalar.h
# See llvm::createAggressiveDCEPass function.
AddAggressiveDCEPass => "vp",
# See llvm::createCFGSimplificationPass function. */
AddCFGSimplificationPass => "vp",
# See llvm::createDeadStoreEliminationPass function. */
AddDeadStoreEliminationPass => "vp",
# See llvm::createGVNPass function. */
AddGVNPass => "vp",
# See llvm::createIndVarSimplifyPass function. */
AddIndVarSimplifyPass => "vp",
# See llvm::createInstructionCombiningPass function. */
AddInstructionCombiningPass => "vp",
# See llvm::createJumpThreadingPass function. */
AddJumpThreadingPass => "vp",
# See llvm::createLICMPass function. */
AddLICMPass => "vp",
# See llvm::createLoopDeletionPass function. */
AddLoopDeletionPass => "vp",
# See llvm::createLoopIndexSplitPass function. */
AddLoopIndexSplitPass => "vp",
# See llvm::createLoopRotatePass function. */
AddLoopRotatePass => "vp",
# See llvm::createLoopUnrollPass function. */
AddLoopUnrollPass => "vp",
# See llvm::createLoopUnswitchPass function. */
AddLoopUnswitchPass => "vp",
# See llvm::createMemCpyOptPass function. */
AddMemCpyOptPass => "vp",
# See llvm::createPromoteMemoryToRegisterPass function. */
AddPromoteMemoryToRegisterPass => "vp",
# See llvm::createReassociatePass function. */
AddReassociatePass => "vp",
# See llvm::createSCCPPass function. */
AddSCCPPass => "vp",
# See llvm::createScalarReplAggregatesPass function. */
AddScalarReplAggregatesPass => "vp",
# See llvm::createSimplifyLibCallsPass function. */
AddSimplifyLibCallsPass => "vp",
# See llvm::createTailCallEliminationPass function. */
AddTailCallEliminationPass => "vp",
# See llvm::createConstantPropagationPass function. */
AddConstantPropagationPass => "vp",
# See llvm::demotePromoteMemoryToRegisterPass function. */
AddDemoteMemoryToRegisterPass => "vp",
##### Target.h
#/*===-- Target Data -------------------------------------------------------===*/
# Creates target data from a target layout string.
# See the constructor llvm::TargetData::TargetData. */
CreateTargetData => "pt",
# Adds target data information to a pass manager. This does not take ownership
# of the target data.
# See the method llvm::PassManagerBase::add. */
AddTargetData => "vpp",
# Converts target data to a target layout string. The string must be disposed
# with LLVMDisposeMessage.
# See the constructor llvm::TargetData::TargetData. */
CopyStringRepOfTargetData => "tp",
# Returns the byte order of a target, either LLVMBigEndian or
# LLVMLittleEndian.
# See the method llvm::TargetData::isLittleEndian. */
ByteOrder => "ip",
# Returns the pointer size in bytes for a target.
# See the method llvm::TargetData::getPointerSize. */
PointerSize => "ip",
# Returns the integer type that is the same size as a pointer on a target.
# See the method llvm::TargetData::getIntPtrType. */
IntPtrType => "pp",
# Computes the size of a type in bytes for a target.
# See the method llvm::TargetData::getTypeSizeInBits. */
SizeOfTypeInBits => "lpp", # FIXME
# Computes the storage size of a type in bytes for a target.
# See the method llvm::TargetData::getTypeStoreSize. */
StoreSizeOfType => "lpp", # FIXME
# Computes the ABI size of a type in bytes for a target.
# See the method llvm::TargetData::getTypeAllocSize. */
ABISizeOfType => "lpp", # FIXME
# Computes the ABI alignment of a type in bytes for a target.
# See the method llvm::TargetData::getTypeABISize. */
ABIAlignmentOfType => "ipp",
# Computes the call frame alignment of a type in bytes for a target.
# See the method llvm::TargetData::getTypeABISize. */
CallFrameAlignmentOfType => "ipp",
# Computes the preferred alignment of a type in bytes for a target.
# See the method llvm::TargetData::getTypeABISize. */
PreferredAlignmentOfType => "ipp",
# Computes the preferred alignment of a global variable in bytes for a target.
# See the method llvm::TargetData::getPreferredAlignment. */
PreferredAlignmentOfGlobal => "ipp",
# Computes the structure element that contains the byte offset for a target.
# See the method llvm::StructLayout::getElementContainingOffset. */
ElementAtOffset => "ippl", # FIXME
# Computes the byte offset of the indexed struct element for a target.
# See the method llvm::StructLayout::getElementContainingOffset. */
OffsetOfElement => "lppi", # FIXME
# Struct layouts are speculatively cached. If a TargetDataRef is alive when
# types are being refined and removed, this method must be called whenever a
# struct type is removed to avoid a dangling pointer in this cache.
# See the method llvm::TargetData::InvalidateStructLayoutInfo. */
InvalidateStructLayout => "vpp",
# Deallocates a TargetData.
# See the destructor llvm::TargetData::~TargetData. */
DisposeTargetData => "vp",
# ExecutionEngine.h
LinkInJIT => "v",
LinkInInterpreter => "v",
CreateGenericValueOfInt => "ppli", # FIXME
CreateGenericValueOfPointer => "pV",
CreateGenericValueOfFloat => "ppd",
GenericValueIntWidth => "ip",
GenericValueToInt => "lpi", # FIXME
GenericValueToPointer => "Vp",
GenericValueToFloat => "dpp",
DisposeGenericValue => "vp",
#/*===-- Operations on execution engines -----------------------------------===*/
#LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE,
# LLVMModuleRef M,
# char **OutError);
#LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp,
# LLVMModuleRef M,
# char **OutError);
#LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT,
# LLVMModuleRef M,
# unsigned OptLevel,
# char **OutError);
DisposeExecutionEngine => "vp",
RunStaticConstructors => "vp",
RunStaticDestructors => "vp",
#int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
# unsigned ArgC, const char * const *ArgV,
# const char * const *EnvP);
#LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
# unsigned NumArgs,
# LLVMGenericValueRef *Args);
FreeMachineCodeForFunction => "vpp",
AddModule => "vpp",
#LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M,
# LLVMModuleRef *OutMod, char **OutError);
#LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
# LLVMValueRef *OutFn);
GetExecutionEngineTargetData => "pp",
AddGlobalMapping => "vppV",
GetPointerToGlobal => "Vpp",
# Transform/IPO.h
# See llvm::createArgumentPromotionPass function. */
AddArgumentPromotionPass => "vp",
# See llvm::createConstantMergePass function. */
AddConstantMergePass => "vp",
# See llvm::createDeadArgEliminationPass function. */
AddDeadArgEliminationPass => "vp",
# See llvm::createDeadTypeEliminationPass function. */
AddDeadTypeEliminationPass => "vp",
# See llvm::createFunctionAttrsPass function. */
AddFunctionAttrsPass => "vp",
# See llvm::createFunctionInliningPass function. */
AddFunctionInliningPass => "vp",
# See llvm::createGlobalDCEPass function. */
AddGlobalDCEPass => "vp",
# See llvm::createGlobalOptimizerPass function. */
AddGlobalOptimizerPass => "vp",
# See llvm::createIPConstantPropagationPass function. */
AddIPConstantPropagationPass => "vp",
# See llvm::createLowerSetJmpPass function. */
AddLowerSetJmpPass => "vp",
# See llvm::createPruneEHPass function. */
AddPruneEHPass => "vp",
# See llvm::createStripDeadPrototypesPass function. */
AddStripDeadPrototypesPass => "vp",
# See llvm::createStripSymbolsPass function. */
AddStripSymbolsPass => "vp",
####### Analysis.h
#typedef enum {
# LLVMAbortProcessAction, /* verifier will print to stderr and abort() */
# LLVMPrintMessageAction, /* verifier will print to stderr and return 1 */
# LLVMReturnStatusAction /* verifier will just return 1 */
#} LLVMVerifierFailureAction;
# Verifies that a module is valid, taking the specified action if not.
# Optionally returns a human-readable description of any invalid constructs.
# OutMessage must be disposed with LLVMDisposeMessage. */
VerifyModule => "ipiB", # FIXME
# Verifies that a single function is valid, taking the specified action. Useful
# for debugging. */
VerifyFunction => "ipi",
####### BitWriter.h
WriteBitcodeToFile => "ipt",
####### BitReader.h
GetBitcodeModule => "vPpB",
####### Core.h
LLVMCreateMemoryBufferWithContentsOfFile => "vPB",
);
for %funcs.kv -> $name, $signature {
%F{$name} := pir::dlfunc__ppss($lib, "LLVM" ~ $name, $signature);
}
}
}
# vim: ft=perl6