@@ -321,8 +321,7 @@ class ConstOCLSPVBuiltin<string _Name, list<Type> _Signature> :
321321
322322// OpenCL v1.0/1.2/2.0 s6.1.1: Built-in Scalar Data Types.
323323def Bool : IntType<"bool", QualType<"Context.BoolTy">, 1>;
324- def TrueChar : IntType<"_char", QualType<"Context.CharTy", 0, 1>, 8>;
325- def Char : IntType<"char", QualType<"Context.SignedCharTy", 0, 1>, 8>;
324+ def Char : IntType<"char", QualType<"Context.CharTy", 0, 1>, 8>;
326325def SChar : IntType<"schar", QualType<"Context.SignedCharTy", 0, 1>, 8>;
327326def UChar : UIntType<"uchar", QualType<"Context.UnsignedCharTy">, 8>;
328327def Short : IntType<"short", QualType<"Context.ShortTy", 0, 1>, 16>;
@@ -356,19 +355,20 @@ def Vec16 : IntList<"Vec16", [16]>;
356355def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
357356
358357// Type lists.
359- def TLAll : TypeList<[Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
360- def TLAllUnsigned : TypeList<[UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong, UInt, ULong, UShort]>;
361- def TLAllWithBool : TypeList<[Bool, Char, UChar, Short, UShort, Int, UInt, Long,
358+ def TLAll : TypeList<[Char, SChar, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
359+ def TLAllUnsigned : TypeList<[UChar, UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong, UInt, ULong, UShort]>;
360+ def TLAllWithBool : TypeList<[Bool, Char, SChar, UChar, Short, UShort, Int, UInt, Long,
362361 ULong, Float, Double, Half]>;
363362def TLFloat : TypeList<[Float, Double, Half]>;
364363// FIXME: handle properly char (signed or unsigned depending on host)
365- def TLSignedInts : TypeList<[Char, Short, Int, Long]>;
366- def TLUnsignedInts : TypeList<[UChar, UShort, UInt, ULong]>;
364+ def TLSignedInts : TypeList<[Char, SChar, Short, Int, Long]>;
365+ def TLUIToSIInts : TypeList<[UChar, UChar, UShort, UInt, ULong]>;
366+ def TLUnsignedInts : TypeList<[UChar, UShort, UInt, ULong]>;
367367
368368// Signed to Unsigned conversion
369369// FIXME: handle properly char (signed or unsigned depending on host)
370- def TLSToUSignedInts : TypeList<[Char, Short, Int, Long]>;
371- def TLSToUUnsignedInts : TypeList<[UChar, UShort, UInt, ULong]>;
370+ def TLSToUSignedInts : TypeList<[Char, SChar, Short, Int, Long]>;
371+ def TLSToUUnsignedInts : TypeList<[UChar, UChar, UShort, UInt, ULong]>;
372372
373373def TLIntLongFloats : TypeList<[Int, UInt, Long, ULong, Float, Double, Half]>;
374374
@@ -377,7 +377,7 @@ def TLIntLongFloats : TypeList<[Int, UInt, Long, ULong, Float, Double, Half]>;
377377// uchar abs(uchar).
378378def TLAllUIntsTwice : TypeList<[UChar, UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong]>;
379379
380- def TLAllInts : TypeList<[Char, UChar, Short, UShort, Int, UInt, Long, ULong]>;
380+ def TLAllInts : TypeList<[Char, SChar, UChar, Short, UShort, Int, UInt, Long, ULong]>;
381381
382382// GenType definitions for multiple base types (e.g. all floating point types,
383383// or all integer types).
@@ -394,6 +394,8 @@ def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>;
394394def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>;
395395def AUIGenTypeN : GenericType<"AUIGenTypeN", TLUnsignedInts, VecAndScalar>;
396396def ASIGenTypeN : GenericType<"ASIGenTypeN", TLSignedInts, VecAndScalar>;
397+ // unsigned integers matching 1:1 with signed ints
398+ def AUIToSIGenTypeN : GenericType<"AUIToSIGenTypeN", TLUIToSIInts, VecAndScalar>;
397399def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>;
398400// All integer to unsigned
399401def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>;
@@ -403,6 +405,7 @@ def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar
403405// Unsigned integer
404406def UGenType1 : GenericType<"UGenType1", TLUnsignedInts, Vec1>;
405407def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>;
408+ def UToSGenTypeN : GenericType<"UToSGenTypeN", TLUIToSIInts, VecAndScalar>;
406409def UInt4 : GenericType<"UInt4", TypeList<[UInt]>, Vec4>;
407410// Float
408411def FGenType1 : GenericType<"FGenType1", TLFloat, Vec1>;
@@ -412,7 +415,7 @@ def IntLongFloatGenType1 : GenericType<"IntLongFloatGenType1", TLIntLongFloats
412415
413416// GenType definitions for every single base type (e.g. fp32 only).
414417// Names are like: GenTypeFloatVecAndScalar.
415- foreach Type = [Char, UChar, SChar , Short, UShort,
418+ foreach Type = [Char, SChar, UChar , Short, UShort,
416419 Int, UInt, Long, ULong,
417420 Float, Double, Half] in {
418421 foreach VecSizes = [VecAndScalar, VecNoScalar] in {
@@ -550,9 +553,9 @@ foreach name = ["clz", "ctz", "popcount"] in {
550553
551554def : ConstOCLSPVBuiltin<"rotate", [AIGenTypeN, AIGenTypeN, AIGenTypeN]>;
552555
553- def : ConstOCLSPVBuiltin<"s_abs", [AUIGenTypeN , ASIGenTypeN]>;
556+ def : ConstOCLSPVBuiltin<"s_abs", [AUIToSIGenTypeN , ASIGenTypeN]>;
554557
555- def : ConstOCLSPVBuiltin<"s_abs_diff", [AUIGenTypeN , ASIGenTypeN, ASIGenTypeN]>;
558+ def : ConstOCLSPVBuiltin<"s_abs_diff", [AUIToSIGenTypeN , ASIGenTypeN, ASIGenTypeN]>;
556559
557560foreach name = ["s_add_sat",
558561 "s_hadd", "s_rhadd",
@@ -652,9 +655,9 @@ def : ConstOCLSPVBuiltin<"bitselect", [AGenTypeN, AGenTypeN, AGenTypeN, AGenType
652655
653656foreach name = ["select"] in {
654657 def : ConstOCLSPVBuiltin<name, [SGenTypeN, SGenTypeN, SGenTypeN, SGenTypeN]>;
655- def : ConstOCLSPVBuiltin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UGenTypeN ]>;
658+ def : ConstOCLSPVBuiltin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UToSGenTypeN ]>;
656659 def : ConstOCLSPVBuiltin<name, [UGenTypeN, UGenTypeN, UGenTypeN, UGenTypeN]>;
657- def : ConstOCLSPVBuiltin<name, [UGenTypeN, UGenTypeN, UGenTypeN , SGenTypeN]>;
660+ def : ConstOCLSPVBuiltin<name, [UToSGenTypeN, UToSGenTypeN, UToSGenTypeN , SGenTypeN]>;
658661 def : ConstOCLSPVBuiltin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar]>;
659662 def : ConstOCLSPVBuiltin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar]>;
660663 def : ConstOCLSPVBuiltin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar]>;
@@ -872,16 +875,16 @@ foreach name = ["Dot"] in {
872875}
873876
874877foreach name = ["Any", "All"] in {
875- def : SPVBuiltin<name, [Bool, GenTypeSCharVecNoScalar ], Attr.Const>;
878+ def : SPVBuiltin<name, [Bool, GenTypeCharVecNoScalar ], Attr.Const>;
876879}
877880
878881foreach name = ["IsNan", "IsInf", "IsFinite", "IsNormal", "SignBitSet"] in {
879882 def : SPVBuiltin<name, [Bool, Float], Attr.Const>;
880883 def : SPVBuiltin<name, [Bool, Double], Attr.Const>;
881884 def : SPVBuiltin<name, [Bool, Half], Attr.Const>;
882- def : SPVBuiltin<name, [GenTypeSCharVecNoScalar , GenTypeFloatVecNoScalar], Attr.Const>;
883- def : SPVBuiltin<name, [GenTypeSCharVecNoScalar , GenTypeDoubleVecNoScalar], Attr.Const>;
884- def : SPVBuiltin<name, [GenTypeSCharVecNoScalar , GenTypeHalfVecNoScalar], Attr.Const>;
885+ def : SPVBuiltin<name, [GenTypeCharVecNoScalar , GenTypeFloatVecNoScalar], Attr.Const>;
886+ def : SPVBuiltin<name, [GenTypeCharVecNoScalar , GenTypeDoubleVecNoScalar], Attr.Const>;
887+ def : SPVBuiltin<name, [GenTypeCharVecNoScalar , GenTypeHalfVecNoScalar], Attr.Const>;
885888}
886889
887890foreach name = ["LessOrGreater",
@@ -895,9 +898,9 @@ foreach name = ["LessOrGreater",
895898 def : SPVBuiltin<name, [Bool, Float, Float], Attr.Const>;
896899 def : SPVBuiltin<name, [Bool, Double, Double], Attr.Const>;
897900 def : SPVBuiltin<name, [Bool, Half, Half], Attr.Const>;
898- def : SPVBuiltin<name, [GenTypeSCharVecNoScalar , GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar], Attr.Const>;
899- def : SPVBuiltin<name, [GenTypeSCharVecNoScalar , GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
900- def : SPVBuiltin<name, [GenTypeSCharVecNoScalar , GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
901+ def : SPVBuiltin<name, [GenTypeCharVecNoScalar , GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar], Attr.Const>;
902+ def : SPVBuiltin<name, [GenTypeCharVecNoScalar , GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
903+ def : SPVBuiltin<name, [GenTypeCharVecNoScalar , GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
901904}
902905
903906foreach name = ["BitCount"] in {
@@ -989,7 +992,7 @@ foreach name = ["GroupLogicalAndKHR", "GroupLogicalOrKHR"] in {
989992
990993def SubgroupShuffleINTELVecType
991994 : GenericType<"SubgroupShuffleINTELVecType",
992- TypeList<[Char, UChar, Short, UShort, Int, UInt, Float]>,
995+ TypeList<[Char, SChar, UChar, Short, UShort, Int, UInt, Float]>,
993996 VecNoScalar>;
994997
995998foreach name = ["SubgroupShuffleINTEL", "SubgroupShuffleXorINTEL"] in {
0 commit comments