@@ -321,8 +321,8 @@ class ConstOCLSPVBuiltin<string _Name, list<Type> _Signature> :
321
321
322
322
// OpenCL v1.0/1.2/2.0 s6.1.1: Built-in Scalar Data Types.
323
323
def Bool : IntType<"bool", QualType<"Context.BoolTy">, 1>;
324
- def TrueChar : IntType<"_char", QualType<"Context.CharTy", 0, 1>, 8>;
325
- def Char : IntType<"char ", QualTypeFromFunction<"GetCharType ", 0, 1>, 8>;
324
+ def Char : IntType<"char", QualType<"Context.CharTy", 0, 1>, 8>;
325
+ def SChar : IntType<"schar ", QualType<"Context.SignedCharTy ", 0, 1>, 8>;
326
326
def UChar : UIntType<"uchar", QualType<"Context.UnsignedCharTy">, 8>;
327
327
def Short : IntType<"short", QualType<"Context.ShortTy", 0, 1>, 16>;
328
328
def UShort : UIntType<"ushort", QualType<"Context.UnsignedShortTy">, 16>;
@@ -355,19 +355,20 @@ def Vec16 : IntList<"Vec16", [16]>;
355
355
def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
356
356
357
357
// Type lists.
358
- def TLAll : TypeList<[Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
359
- def TLAllUnsigned : TypeList<[UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong, UInt, ULong, UShort]>;
360
- 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,
361
361
ULong, Float, Double, Half]>;
362
362
def TLFloat : TypeList<[Float, Double, Half]>;
363
363
// FIXME: handle properly char (signed or unsigned depending on host)
364
- def TLSignedInts : TypeList<[Char, Short, Int, Long]>;
365
- 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]>;
366
367
367
368
// Signed to Unsigned conversion
368
369
// FIXME: handle properly char (signed or unsigned depending on host)
369
- def TLSToUSignedInts : TypeList<[Char, Short, Int, Long]>;
370
- 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]>;
371
372
372
373
def TLIntLongFloats : TypeList<[Int, UInt, Long, ULong, Float, Double, Half]>;
373
374
@@ -376,7 +377,7 @@ def TLIntLongFloats : TypeList<[Int, UInt, Long, ULong, Float, Double, Half]>;
376
377
// uchar abs(uchar).
377
378
def TLAllUIntsTwice : TypeList<[UChar, UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong]>;
378
379
379
- def TLAllInts : TypeList<[Char, UChar, Short, UShort, Int, UInt, Long, ULong]>;
380
+ def TLAllInts : TypeList<[Char, SChar, UChar, Short, UShort, Int, UInt, Long, ULong]>;
380
381
381
382
// GenType definitions for multiple base types (e.g. all floating point types,
382
383
// or all integer types).
@@ -393,6 +394,8 @@ def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>;
393
394
def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>;
394
395
def AUIGenTypeN : GenericType<"AUIGenTypeN", TLUnsignedInts, VecAndScalar>;
395
396
def ASIGenTypeN : GenericType<"ASIGenTypeN", TLSignedInts, VecAndScalar>;
397
+ // unsigned integers matching 1:1 with signed ints
398
+ def AUIToSIGenTypeN : GenericType<"AUIToSIGenTypeN", TLUIToSIInts, VecAndScalar>;
396
399
def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>;
397
400
// All integer to unsigned
398
401
def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>;
@@ -402,6 +405,7 @@ def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar
402
405
// Unsigned integer
403
406
def UGenType1 : GenericType<"UGenType1", TLUnsignedInts, Vec1>;
404
407
def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>;
408
+ def UToSGenTypeN : GenericType<"UToSGenTypeN", TLUIToSIInts, VecAndScalar>;
405
409
def UInt4 : GenericType<"UInt4", TypeList<[UInt]>, Vec4>;
406
410
// Float
407
411
def FGenType1 : GenericType<"FGenType1", TLFloat, Vec1>;
@@ -411,7 +415,7 @@ def IntLongFloatGenType1 : GenericType<"IntLongFloatGenType1", TLIntLongFloats
411
415
412
416
// GenType definitions for every single base type (e.g. fp32 only).
413
417
// Names are like: GenTypeFloatVecAndScalar.
414
- foreach Type = [Char, UChar, Short, UShort,
418
+ foreach Type = [Char, SChar, UChar, Short, UShort,
415
419
Int, UInt, Long, ULong,
416
420
Float, Double, Half] in {
417
421
foreach VecSizes = [VecAndScalar, VecNoScalar] in {
@@ -549,9 +553,9 @@ foreach name = ["clz", "ctz", "popcount"] in {
549
553
550
554
def : ConstOCLSPVBuiltin<"rotate", [AIGenTypeN, AIGenTypeN, AIGenTypeN]>;
551
555
552
- def : ConstOCLSPVBuiltin<"s_abs", [AUIGenTypeN , ASIGenTypeN]>;
556
+ def : ConstOCLSPVBuiltin<"s_abs", [AUIToSIGenTypeN , ASIGenTypeN]>;
553
557
554
- def : ConstOCLSPVBuiltin<"s_abs_diff", [AUIGenTypeN , ASIGenTypeN, ASIGenTypeN]>;
558
+ def : ConstOCLSPVBuiltin<"s_abs_diff", [AUIToSIGenTypeN , ASIGenTypeN, ASIGenTypeN]>;
555
559
556
560
foreach name = ["s_add_sat",
557
561
"s_hadd", "s_rhadd",
@@ -651,9 +655,9 @@ def : ConstOCLSPVBuiltin<"bitselect", [AGenTypeN, AGenTypeN, AGenTypeN, AGenType
651
655
652
656
foreach name = ["select"] in {
653
657
def : ConstOCLSPVBuiltin<name, [SGenTypeN, SGenTypeN, SGenTypeN, SGenTypeN]>;
654
- def : ConstOCLSPVBuiltin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UGenTypeN ]>;
658
+ def : ConstOCLSPVBuiltin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UToSGenTypeN ]>;
655
659
def : ConstOCLSPVBuiltin<name, [UGenTypeN, UGenTypeN, UGenTypeN, UGenTypeN]>;
656
- def : ConstOCLSPVBuiltin<name, [UGenTypeN, UGenTypeN, UGenTypeN , SGenTypeN]>;
660
+ def : ConstOCLSPVBuiltin<name, [UToSGenTypeN, UToSGenTypeN, UToSGenTypeN , SGenTypeN]>;
657
661
def : ConstOCLSPVBuiltin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar]>;
658
662
def : ConstOCLSPVBuiltin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar]>;
659
663
def : ConstOCLSPVBuiltin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar]>;
@@ -988,7 +992,7 @@ foreach name = ["GroupLogicalAndKHR", "GroupLogicalOrKHR"] in {
988
992
989
993
def SubgroupShuffleINTELVecType
990
994
: GenericType<"SubgroupShuffleINTELVecType",
991
- TypeList<[Char, UChar, Short, UShort, Int, UInt, Float]>,
995
+ TypeList<[Char, SChar, UChar, Short, UShort, Int, UInt, Float]>,
992
996
VecNoScalar>;
993
997
994
998
foreach name = ["SubgroupShuffleINTEL", "SubgroupShuffleXorINTEL"] in {
0 commit comments