forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuiltins.td
More file actions
4716 lines (3953 loc) · 136 KB
/
Copy pathBuiltins.td
File metadata and controls
4716 lines (3953 loc) · 136 KB
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
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//===--- Builtins.td - Builtins function info database-----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
include "clang/Basic/BuiltinsBase.td"
class FPMathTemplate : Template<["float", "double", "long double"],
["f", "", "l"]>;
class FPMathWithF16Template :
Template<["float", "double", "long double", "__fp16"],
["f", "", "l", "f16"]>;
class FPMathWithF16F128Template :
Template<["float", "double", "long double", "__fp16", "__float128"],
["f", "", "l", "f16", "f128"]>;
class FPMathWithF128Template :
Template<["float", "double", "long double", "__float128"],
["f", "", "l", "f128"]>;
class F16F128MathTemplate : Template<["__fp16", "__float128"],
["f16", "f128"]>;
class IntMathTemplate : Template<["int", "long int", "long long int"],
["", "l", "ll"], /*AsPrefix=*/1>;
class MSInt8_16_32Template : Template<["char", "short", "msint32_t"],
["8", "16", ""]>;
class Int8_16_32_64Template
: Template<["char", "short", "int", "long long int"],
["8", "16", "32", "64"]>;
class MSInt8_16_32_64Template
: Template<["char", "short", "msint32_t", "long long int"],
["8", "16", "", "64"]>;
class MSInt16_32Template : Template<["short", "msint32_t"],
["16", ""]>;
class MSUInt16_32_64Template :
Template<["unsigned short", "unsigned int", "uint64_t"],
["16", "", "64"]>;
class MSInt32_64Template : Template<["msint32_t", "int64_t"],
["", "64"]>;
class FloatDoubleTemplate : Template<["float", "double"],
["f", ""]>;
// FIXME: These assume that char -> i8, short -> i16, int -> i32,
// long long -> i64.
class SyncBuiltinsTemplate :
Template<["char", "short", "int", "long long int", "__int128_t"],
["1", "2", "4", "8", "16"]>;
class BitInt8_16_32_64BuiltinsTemplate :
Template<["unsigned char", "unsigned short", "uint32_t", "uint64_t"],
["8", "16", "32", "64"]>;
class BitShort_Int_Long_LongLongTemplate :
Template<["short", "int", "long int", "long long int"],
["s", "", "l", "ll"]>;
class BitInt_Long_LongLongTemplate :
Template<["int", "long int", "long long int"],
["", "l", "ll"]>;
// Most of the types used in the prototypes are types from C, C++ or ObjC. There
// are a few builtin-specific types and qualifiers.
//
// builtin-specific types:
// - __builtin_va_list: This is the internal representation for va_lists
// - __builtin_va_list_ref: A reference-like type to __builtin_va_list
// - msint32_t: 'int' size if target is LP64, 'L' otherwise.
//
// builtin-specific qualifiers:
// - _Constant: Argument has to constant-fold to an integer constant expression
// __fp16 and __float128 builtin variants of libc/libm functions.
def AcosF128 : Builtin {
let Spellings = ["__builtin_acosf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def AcoshF128 : Builtin {
let Spellings = ["__builtin_acoshf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def AsinF128 : Builtin {
let Spellings = ["__builtin_asinf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def AsinhF128 : Builtin {
let Spellings = ["__builtin_asinhf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def AtanF128 : Builtin {
let Spellings = ["__builtin_atanf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def AtanhF128 : Builtin {
let Spellings = ["__builtin_atanhf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def CbrtF128 : Builtin {
let Spellings = ["__builtin_cbrtf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "__float128(__float128)";
}
def CeilF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_ceil"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T)";
}
def CosF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_cos"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def CoshF128 : Builtin {
let Spellings = ["__builtin_coshf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def ErfF128 : Builtin {
let Spellings = ["__builtin_erff128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def ErfcF128 : Builtin {
let Spellings = ["__builtin_erfcf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def ExpF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_exp"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def Exp2F16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_exp2"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def Exp10F16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_exp10"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def Expm1F128 : Builtin {
let Spellings = ["__builtin_expm1f128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def FdimF128 : Builtin {
let Spellings = ["__builtin_fdimf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, __float128)";
}
def FloorF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_floor"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T)";
}
def FmaF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_fma"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T, T, T)";
}
def FmaxF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_fmax"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
let Prototype = "T(T, T)";
}
def FminF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_fmin"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
let Prototype = "T(T, T)";
}
def Atan2F128 : Builtin {
let Spellings = ["__builtin_atan2f128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, __float128)";
}
def CopysignF16 : Builtin {
let Spellings = ["__builtin_copysignf16"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "__fp16(__fp16, __fp16)";
}
def CopysignF128 : Builtin {
let Spellings = ["__builtin_copysignf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
let Prototype = "__float128(__float128, __float128)";
}
def FabsF16 : Builtin {
let Spellings = ["__builtin_fabsf16"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "__fp16(__fp16)";
}
def FabsF128 : Builtin {
let Spellings = ["__builtin_fabsf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
let Prototype = "__float128(__float128)";
}
def FmodF16F128 : F16F128MathTemplate, Builtin {
let Spellings = ["__builtin_fmod"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T, T)";
}
def FrexpF16F128 : F16F128MathTemplate, Builtin {
let Spellings = ["__builtin_frexp"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "T(T, int*)";
}
def HugeVal : Builtin, FPMathWithF128Template {
let Spellings = ["__builtin_huge_val"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T()";
}
def HugeValF16 : Builtin {
let Spellings = ["__builtin_huge_valf16"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "_Float16()";
}
def Inf : Builtin, FPMathWithF128Template {
let Spellings = ["__builtin_inf"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T()";
}
def InfF16 : Builtin {
let Spellings = ["__builtin_inff16"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "_Float16()";
}
def LdexpF16F128 : F16F128MathTemplate, Builtin {
let Spellings = ["__builtin_ldexp"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T, int)";
}
def ModfF128 : Builtin {
let Spellings = ["__builtin_modff128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "__float128(__float128, __float128*)";
}
// This isn't a FPMathWithF16F128Template because the f16
// version takes a _Float16 for some reason.
def NanF16 : Builtin {
let Spellings = ["__builtin_nanf16"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Pure, Constexpr];
let Prototype = "_Float16(char const*)";
}
def NanF128 : Builtin {
let Spellings = ["__builtin_nanf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Pure, Constexpr];
let Prototype = "__float128(char const*)";
}
def Nans : Builtin,
Template<["float", "double", "long double", "_Float16", "__float128"],
["f", "", "l", "f16", "f128"]> {
let Spellings = ["__builtin_nans"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Pure, Constexpr];
let Prototype = "T(char const*)";
}
def PowI : Builtin, FPMathTemplate {
let Spellings = ["__builtin_powi"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T, int)";
}
def PowF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_pow"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T, T)";
}
def HypotF128 : Builtin {
let Spellings = ["__builtin_hypotf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, __float128)";
}
def ILogbF128 : Builtin {
let Spellings = ["__builtin_ilogbf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "int(__float128)";
}
def LgammaF128 : Builtin {
let Spellings = ["__builtin_lgammaf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "__float128(__float128)";
}
def LLrintF128 : Builtin {
let Spellings = ["__builtin_llrintf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "long long int(__float128)";
}
def LLroundF128 : Builtin {
let Spellings = ["__builtin_llroundf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "long long int(__float128)";
}
def Log10F16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_log10"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def Log1pF128 : Builtin {
let Spellings = ["__builtin_log1pf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def Log2F16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_log2"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def LogbF128 : Builtin {
let Spellings = ["__builtin_logbf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def LogF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_log"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def LrintF128 : Builtin {
let Spellings = ["__builtin_lrintf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "long int(__float128)";
}
def LroundF128 : Builtin {
let Spellings = ["__builtin_lroundf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "long int(__float128)";
}
def NearbyintF128 : Builtin {
let Spellings = ["__builtin_nearbyintf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "__float128(__float128)";
}
def NextafterF128 : Builtin {
let Spellings = ["__builtin_nextafterf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, __float128)";
}
def NexttowardF128 : Builtin {
let Spellings = ["__builtin_nexttowardf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, __float128)";
}
def RemainderF128 : Builtin {
let Spellings = ["__builtin_remainderf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, __float128)";
}
def RemquoF128 : Builtin {
let Spellings = ["__builtin_remquof128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "__float128(__float128, __float128, int*)";
}
def RintF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_rint"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T)";
}
def RoundF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_round"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T)";
}
def RoundevenF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_roundeven"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T)";
}
def ScanlblnF128 : Builtin {
let Spellings = ["__builtin_scalblnf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, long int)";
}
def ScanlbnF128 : Builtin {
let Spellings = ["__builtin_scalbnf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128, int)";
}
def SinF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_sin"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def SinhF128 : Builtin {
let Spellings = ["__builtin_sinhf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def SqrtF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_sqrt"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def TanF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_tan"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
}
def TanhF128 : Builtin {
let Spellings = ["__builtin_tanhf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def TgammaF128 : Builtin {
let Spellings = ["__builtin_tgammaf128"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "__float128(__float128)";
}
def TruncF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_trunc"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "T(T)";
}
// Access to floating point environment.
def BuiltinFltRounds : Builtin {
let Spellings = ["__builtin_flt_rounds"];
let Attributes = [NoThrow];
let Prototype = "int()";
}
def BuiltinSetFltRounds : Builtin {
let Spellings = ["__builtin_set_flt_rounds"];
let Attributes = [NoThrow];
let Prototype = "void(int)";
}
// GCC-compatible C99 CMPLX implementation.
def BuiltinComplex : Builtin {
let Spellings = ["__builtin_complex"];
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
let Prototype = "void(...)";
}
// FP Comparison functions.
def IsGreater : Builtin {
let Spellings = ["__builtin_isgreater"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
def IsGreaterEqual : Builtin {
let Spellings = ["__builtin_isgreaterequal"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
def IsLess : Builtin {
let Spellings = ["__builtin_isless"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
def IsLessEqual : Builtin {
let Spellings = ["__builtin_islessequal"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
def IsLessGreater : Builtin {
let Spellings = ["__builtin_islessgreater"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
def IsUnordered : Builtin {
let Spellings = ["__builtin_isunordered"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
// Unary FP classification.
def FPClassify : Builtin {
let Spellings = ["__builtin_fpclassify"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(int, int, int, int, int, ...)";
}
def IsFinite : Builtin {
let Spellings = ["__builtin_isfinite"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsInf : Builtin {
let Spellings = ["__builtin_isinf"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsInfSign : Builtin {
let Spellings = ["__builtin_isinf_sign"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsNan : Builtin {
let Spellings = ["__builtin_isnan"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsNormal : Builtin {
let Spellings = ["__builtin_isnormal"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsSubnormal : Builtin {
let Spellings = ["__builtin_issubnormal"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsZero : Builtin {
let Spellings = ["__builtin_iszero"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsSignaling : Builtin {
let Spellings = ["__builtin_issignaling"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
def IsFPClass : Builtin {
let Spellings = ["__builtin_isfpclass"];
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
let Prototype = "int(...)";
}
// FP signbit builtins.
def Signbit : Builtin {
let Spellings = ["__builtin_signbit"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const,
CustomTypeChecking];
let Prototype = "int(...)";
}
def SignbitF : Builtin {
let Spellings = ["__builtin_signbitf"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "int(float)";
}
def SignbitL : Builtin {
let Spellings = ["__builtin_signbitl"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
let Prototype = "int(long double)";
}
// Special FP builtins.
def Canonicalize : Builtin, FPMathWithF16Template {
let Spellings = ["__builtin_canonicalize"];
let Attributes = [NoThrow, Const];
let Prototype = "T(T)";
}
// Builtins for arithmetic.
def Clz : Builtin, BitShort_Int_Long_LongLongTemplate {
let Spellings = ["__builtin_clz"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "int(unsigned T)";
}
def Clzg : Builtin {
let Spellings = ["__builtin_clzg"];
let Attributes = [NoThrow, Const, Constexpr, CustomTypeChecking];
let Prototype = "int(...)";
}
def Ctz : Builtin, BitShort_Int_Long_LongLongTemplate {
let Spellings = ["__builtin_ctz"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "int(unsigned T)";
}
def Ctzg : Builtin {
let Spellings = ["__builtin_ctzg"];
let Attributes = [NoThrow, Const, Constexpr, CustomTypeChecking];
let Prototype = "int(...)";
}
def FFS : Builtin, BitInt_Long_LongLongTemplate {
let Spellings = ["__builtin_ffs"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
let Prototype = "int(T)";
}
def Parity : Builtin, BitInt_Long_LongLongTemplate {
let Spellings = ["__builtin_parity"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "int(unsigned T)";
}
def Popcount : Builtin, BitInt_Long_LongLongTemplate {
let Spellings = ["__builtin_popcount"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "int(unsigned T)";
}
def Popcountg : Builtin {
let Spellings = ["__builtin_popcountg"];
let Attributes = [NoThrow, Const, Constexpr, CustomTypeChecking];
let Prototype = "int(...)";
}
def Clrsb : Builtin, BitInt_Long_LongLongTemplate {
let Spellings = ["__builtin_clrsb"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "int(T)";
}
// The following builtins rely on that char == 8 bits, short == 16 bits and that
// there exists native types on the target that are 32- and 64-bits wide, unless
// these conditions are fulfilled these builtins will operate on a not intended
// bitwidth.
def BSwap : Builtin, Template<["unsigned short", "uint32_t", "uint64_t"],
["16", "32", "64"]> {
let Spellings = ["__builtin_bswap"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T(T)";
}
def Bitreverse : BitInt8_16_32_64BuiltinsTemplate, Builtin {
let Spellings = ["__builtin_bitreverse"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T(T)";
}
def RotateLeft : BitInt8_16_32_64BuiltinsTemplate, Builtin {
let Spellings = ["__builtin_rotateleft"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T(T, T)";
}
def RotateRight : BitInt8_16_32_64BuiltinsTemplate, Builtin {
let Spellings = ["__builtin_rotateright"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T(T, T)";
}
// Random GCC builtins
// FIXME: The builtins marked FunctionWithBuiltinPrefix below should be
// merged with the library definitions. They are currently not because
// the attributes are different.
// Builtins for checking CPU features based on the GCC builtins.
def BuiltinCPUIs : Builtin {
let Spellings = ["__builtin_cpu_is"];
let Attributes = [NoThrow, Const];
let Prototype = "bool(char const*)";
}
def BuiltinCPUSupports : Builtin {
let Spellings = ["__builtin_cpu_supports"];
let Attributes = [NoThrow, Const];
let Prototype = "bool(char const*)";
}
def BuiltinCPUInit : Builtin {
let Spellings = ["__builtin_cpu_init"];
let Attributes = [NoThrow];
let Prototype = "void()";
}
def BuiltinCalloc : Builtin {
let Spellings = ["__builtin_calloc"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void*(size_t, size_t)";
}
def BuiltinConstantP : Builtin {
let Spellings = ["__builtin_constant_p"];
let Attributes = [NoThrow, Const, CustomTypeChecking, UnevaluatedArguments, Constexpr];
let Prototype = "int(...)";
}
def BuiltinClassifyType : Builtin {
let Spellings = ["__builtin_classify_type"];
let Attributes = [NoThrow, Const, CustomTypeChecking, UnevaluatedArguments, Constexpr];
let Prototype = "int(...)";
}
def BuiltinCFStringMakeConstantString : Builtin {
let Spellings = ["__builtin___CFStringMakeConstantString"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "constant_CFString const*(char const*)";
}
def BuiltinNSStringMakeConstantString : Builtin {
let Spellings = ["__builtin___NSStringMakeConstantString"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "constant_CFString const*(char const*)";
}
def BuiltinVaStart : Builtin {
let Spellings = ["__builtin_va_start"];
let Attributes = [NoThrow, CustomTypeChecking];
let Prototype = "void(__builtin_va_list_ref, ...)";
}
def BuiltinStdargStart : Builtin {
let Spellings = ["__builtin_stdarg_start"];
let Attributes = [NoThrow, CustomTypeChecking];
let Prototype = "void(__builtin_va_list_ref, ...)";
}
def BuiltinAssumeAligned : Builtin {
let Spellings = ["__builtin_assume_aligned"];
let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
let Prototype = "void*(void const*, size_t, ...)";
}
def BuiltinFree : Builtin {
let Spellings = ["__builtin_free"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void(void*)";
}
def BuiltinMalloc : Builtin {
let Spellings = ["__builtin_malloc"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void*(size_t)";
}
def BuiltinMemcpyInline : Builtin {
let Spellings = ["__builtin_memcpy_inline"];
let Attributes = [NoThrow];
let Prototype = "void(void*, void const*, _Constant size_t)";
}
def BuiltinMempcpy : Builtin {
let Spellings = ["__builtin_mempcpy"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void*(void*, void const*, size_t)";
}
def BuiltinMemsetInline : Builtin {
let Spellings = ["__builtin_memset_inline"];
let Attributes = [NoThrow];
let Prototype = "void(void*, int, _Constant size_t)";
}
def BuiltinStrcspn : Builtin {
let Spellings = ["__builtin_strcspn"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "size_t(char const*, char const*)";
}
def BuiltinRealloc : Builtin {
let Spellings = ["__builtin_realloc"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void*(void*, size_t)";
}
def BuiltinReturnAddress : Builtin {
let Spellings = ["__builtin_return_address"];
let Attributes = [NoThrow];
let Prototype = "void*(_Constant unsigned int)";
}
def ExtractReturnAddr : Builtin {
let Spellings = ["__builtin_extract_return_addr"];
let Attributes = [NoThrow];
let Prototype = "void*(void*)";
}
def FrameAddress : Builtin {
let Spellings = ["__builtin_frame_address"];
let Attributes = [NoThrow];
let Prototype = "void*(_Constant unsigned int)";
}
def ClearCache : Builtin {
let Spellings = ["__builtin___clear_cache"];
let Attributes = [NoThrow];
let Prototype = "void(char*, char*)";
}
def BuiltinSetjmp : Builtin {
let Spellings = ["__builtin_setjmp"];
let Attributes = [ReturnsTwice];
let Prototype = "int(void**)";
}
def BuiltinLongjmp : Builtin {
let Spellings = ["__builtin_longjmp"];
let Attributes = [NoReturn];
let Prototype = "void(void**, int)";
}
def UnwindInit : Builtin {
let Spellings = ["__builtin_unwind_init"];
let Prototype = "void()";
}
def EHReturnDataRegNo : Builtin {
let Spellings = ["__builtin_eh_return_data_regno"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "int(_Constant int)";
}
def ThreadPointer : Builtin {
let Spellings = ["__builtin_thread_pointer"];
let Attributes = [NoThrow, Const];
let Prototype = "void*()";
}
def Launder : Builtin {
let Spellings = ["__builtin_launder"];
let Attributes = [NoThrow, CustomTypeChecking, Constexpr];
let Prototype = "void*(void*)";
}
def IsConstantEvaluated : LangBuiltin<"CXX_LANG"> {
let Spellings = ["__builtin_is_constant_evaluated"];
let Attributes = [NoThrow, Constexpr];
let Prototype = "bool()";
}
// GCC exception builtins
def EHReturn : Builtin {
let Spellings = ["__builtin_eh_return"];
let Attributes = [NoReturn];
// FIXME: Takes intptr_t, not size_t!
let Prototype = "void(size_t, void*)";
}
def FrobReturnAddr : Builtin {
let Spellings = ["__builtin_frob_return_addr"];
let Attributes = [NoThrow];
let Prototype = "void*(void*)";
}
def DWARF_CFA : Builtin {
let Spellings = ["__builtin_dwarf_cfa"];
let Attributes = [NoThrow];
let Prototype = "void*()";
}
def InitDWARFRegSizeTable : Builtin {
let Spellings = ["__builtin_init_dwarf_reg_size_table"];
let Attributes = [NoThrow];
let Prototype = "void(void*)";
}
def DWARFSpColumn : Builtin {
let Spellings = ["__builtin_dwarf_sp_column"];
let Attributes = [NoThrow];
let Prototype = "unsigned int()";
}
def ExtendPointer : Builtin {
let Spellings = ["__builtin_extend_pointer"];
let Attributes = [NoThrow];
// _Unwind_Word == uint64_t
let Prototype = "unsigned long long int(void*)";
}
// GCC Object size checking builtins.
def ObjectSize : Builtin {
let Spellings = ["__builtin_object_size"];
let Attributes = [NoThrow, UnevaluatedArguments, Constexpr];
let Prototype = "size_t(void const*, int)";
}
def DynamicObjectSize : Builtin { // Clang only
let Spellings = ["__builtin_dynamic_object_size"];
let Attributes = [NoThrow, UnevaluatedArguments, Constexpr];
let Prototype = "size_t(void const*, int)";
}
def MemcpyChk : Builtin {
let Spellings = ["__builtin___memcpy_chk"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void*(void*, void const*, size_t, size_t)";
}
def MemccpyChk : Builtin {
let Spellings = ["__builtin___memccpy_chk"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
let Prototype = "void*(void*, void const*, int, size_t, size_t)";
}
def MemmoveChk : Builtin {
let Spellings = ["__builtin___memmove_chk"];