diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td --- a/clang/lib/Sema/OpenCLBuiltins.td +++ b/clang/lib/Sema/OpenCLBuiltins.td @@ -274,10 +274,13 @@ def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>; def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>; def Vec1 : IntList<"Vec1", [1]>; +def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>; // Type lists. def TLAll : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>; def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>; +def TLSignedInts : TypeList<"TLSignedInts", [Char, Short, Int, Long]>; +def TLUnsignedInts : TypeList<"TLUnsignedInts", [UChar, UShort, UInt, ULong]>; // All unsigned integer types twice, to facilitate unsigned return types for e.g. // uchar abs(char) and @@ -297,6 +300,10 @@ def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>; // All integer to unsigned def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>; +// Signed integer +def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar>; +// Unsigned integer +def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>; // Float def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>; @@ -313,6 +320,14 @@ } } +// GenType definitions for vec1234. +foreach Type = [Float, Double, Half] in { + def "GenType" # Type # Vec1234 : + GenericType<"GenType" # Type # Vec1234, + TypeList<"GL" # Type.Name, [Type]>, + Vec1234>; +} + //===----------------------------------------------------------------------===// // Definitions of OpenCL builtin functions @@ -566,6 +581,91 @@ } +//-------------------------------------------------------------------- +// OpenCL v1.1 s6.11.5, v1.2 s6.12.5, v2.0 s6.13.5 - Geometric Functions +// OpenCL Extension v2.0 s5.1.4 and s6.1.4 - Geometric Functions +// --- Table 13 --- +// --- 1 argument --- +foreach name = ["length"] in { + def : Builtin; + def : Builtin; + def : Builtin; +} +foreach name = ["normalize"] in { + def : Builtin; + def : Builtin; + def : Builtin; +} +foreach name = ["fast_length"] in { + def : Builtin; +} +foreach name = ["fast_normalize"] in { + def : Builtin; +} + +// --- 2 arguments --- +foreach name = ["cross"] in { + foreach VSize = [3, 4] in { + def : Builtin, VectorType, VectorType], Attr.Const>; + def : Builtin, VectorType, VectorType], Attr.Const>; + def : Builtin, VectorType, VectorType], Attr.Const>; + } +} +foreach name = ["dot", "distance"] in { + def : Builtin; + def : Builtin; + def : Builtin; +} +foreach name = ["fast_distance"] in { + def : Builtin; +} + + +//-------------------------------------------------------------------- +// OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions +// OpenCL Extension v2.0 s5.1.5 and s6.1.5 - Relational Functions +// --- Table 14 --- +// --- 1 argument --- +foreach name = ["isfinite", "isinf", "isnan", "isnormal", "signbit"] in { + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; +} +foreach name = ["any", "all"] in { + def : Builtin; +} + +// --- 2 arguments --- +foreach name = ["isequal", "isnotequal", "isgreater", "isgreaterequal", + "isless", "islessequal", "islessgreater", "isordered", + "isunordered"] in { + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; +} + +// --- 3 arguments --- +foreach name = ["bitselect"] in { + def : Builtin; +} +foreach name = ["select"] in { + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; + def : Builtin; +} + + // OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions // 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 // --- Table 15 ---