@@ -274,10 +274,13 @@ def Event : Type<"Event", QualType<"OCLEventTy">>;
274
274
def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>;
275
275
def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>;
276
276
def Vec1 : IntList<"Vec1", [1]>;
277
+ def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
277
278
278
279
// Type lists.
279
280
def TLAll : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
280
281
def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>;
282
+ def TLSignedInts : TypeList<"TLSignedInts", [Char, Short, Int, Long]>;
283
+ def TLUnsignedInts : TypeList<"TLUnsignedInts", [UChar, UShort, UInt, ULong]>;
281
284
282
285
// All unsigned integer types twice, to facilitate unsigned return types for e.g.
283
286
// uchar abs(char) and
@@ -297,6 +300,10 @@ def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>;
297
300
def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>;
298
301
// All integer to unsigned
299
302
def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>;
303
+ // Signed integer
304
+ def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar>;
305
+ // Unsigned integer
306
+ def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>;
300
307
// Float
301
308
def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>;
302
309
@@ -313,6 +320,14 @@ foreach Type = [Char, UChar, Short, UShort,
313
320
}
314
321
}
315
322
323
+ // GenType definitions for vec1234.
324
+ foreach Type = [Float, Double, Half] in {
325
+ def "GenType" # Type # Vec1234 :
326
+ GenericType<"GenType" # Type # Vec1234,
327
+ TypeList<"GL" # Type.Name, [Type]>,
328
+ Vec1234>;
329
+ }
330
+
316
331
317
332
//===----------------------------------------------------------------------===//
318
333
// Definitions of OpenCL builtin functions
@@ -566,6 +581,91 @@ foreach name = ["smoothstep"] in {
566
581
}
567
582
568
583
584
+ //--------------------------------------------------------------------
585
+ // OpenCL v1.1 s6.11.5, v1.2 s6.12.5, v2.0 s6.13.5 - Geometric Functions
586
+ // OpenCL Extension v2.0 s5.1.4 and s6.1.4 - Geometric Functions
587
+ // --- Table 13 ---
588
+ // --- 1 argument ---
589
+ foreach name = ["length"] in {
590
+ def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>;
591
+ def : Builtin<name, [Double, GenTypeDoubleVec1234], Attr.Const>;
592
+ def : Builtin<name, [Half, GenTypeHalfVec1234], Attr.Const>;
593
+ }
594
+ foreach name = ["normalize"] in {
595
+ def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
596
+ def : Builtin<name, [GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>;
597
+ def : Builtin<name, [GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>;
598
+ }
599
+ foreach name = ["fast_length"] in {
600
+ def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>;
601
+ }
602
+ foreach name = ["fast_normalize"] in {
603
+ def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
604
+ }
605
+
606
+ // --- 2 arguments ---
607
+ foreach name = ["cross"] in {
608
+ foreach VSize = [3, 4] in {
609
+ def : Builtin<name, [VectorType<Float, VSize>, VectorType<Float, VSize>, VectorType<Float, VSize>], Attr.Const>;
610
+ def : Builtin<name, [VectorType<Double, VSize>, VectorType<Double, VSize>, VectorType<Double, VSize>], Attr.Const>;
611
+ def : Builtin<name, [VectorType<Half, VSize>, VectorType<Half, VSize>, VectorType<Half, VSize>], Attr.Const>;
612
+ }
613
+ }
614
+ foreach name = ["dot", "distance"] in {
615
+ def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
616
+ def : Builtin<name, [Double, GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>;
617
+ def : Builtin<name, [Half, GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>;
618
+ }
619
+ foreach name = ["fast_distance"] in {
620
+ def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
621
+ }
622
+
623
+
624
+ //--------------------------------------------------------------------
625
+ // OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
626
+ // OpenCL Extension v2.0 s5.1.5 and s6.1.5 - Relational Functions
627
+ // --- Table 14 ---
628
+ // --- 1 argument ---
629
+ foreach name = ["isfinite", "isinf", "isnan", "isnormal", "signbit"] in {
630
+ def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
631
+ def : Builtin<name, [Int, Double], Attr.Const>;
632
+ def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
633
+ def : Builtin<name, [Int, Half], Attr.Const>;
634
+ def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
635
+ }
636
+ foreach name = ["any", "all"] in {
637
+ def : Builtin<name, [Int, AIGenTypeN], Attr.Const>;
638
+ }
639
+
640
+ // --- 2 arguments ---
641
+ foreach name = ["isequal", "isnotequal", "isgreater", "isgreaterequal",
642
+ "isless", "islessequal", "islessgreater", "isordered",
643
+ "isunordered"] in {
644
+ def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
645
+ def : Builtin<name, [Int, Double, Double], Attr.Const>;
646
+ def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
647
+ def : Builtin<name, [Int, Half, Half], Attr.Const>;
648
+ def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
649
+ }
650
+
651
+ // --- 3 arguments ---
652
+ foreach name = ["bitselect"] in {
653
+ def : Builtin<name, [AGenTypeN, AGenTypeN, AGenTypeN, AGenTypeN], Attr.Const>;
654
+ }
655
+ foreach name = ["select"] in {
656
+ def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, SGenTypeN], Attr.Const>;
657
+ def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UGenTypeN], Attr.Const>;
658
+ def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, UGenTypeN], Attr.Const>;
659
+ def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, SGenTypeN], Attr.Const>;
660
+ def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
661
+ def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
662
+ def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeLongVecAndScalar], Attr.Const>;
663
+ def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>;
664
+ def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeShortVecAndScalar], Attr.Const>;
665
+ def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
666
+ }
667
+
668
+
569
669
// OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions
570
670
// OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s9.4.6, v2.0 s5.1.6 and 6.1.6 - Vector Data Load and Store Functions
571
671
// --- Table 15 ---
0 commit comments