Skip to content

Commit 8464bf7

Browse files
authored
Revert "[libspirv] Define schar overloads via remangling; not source … (#18821)
…(#18626)" This reverts commit 23584c1. It exposed several issues not caught in pre-commit CI surrounding missing builtins, incorrect host selection of builtins, and remangling issues. I will add better tests for these before retrying.
1 parent 817c4ad commit 8464bf7

File tree

42 files changed

+424
-75
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+424
-75
lines changed

clang/lib/Sema/SPIRVBuiltins.td

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class ConstOCLSPVBuiltin<string _Name, list<Type> _Signature> :
322322
// OpenCL v1.0/1.2/2.0 s6.1.1: Built-in Scalar Data Types.
323323
def Bool : IntType<"bool", QualType<"Context.BoolTy">, 1>;
324324
def TrueChar : IntType<"_char", QualType<"Context.CharTy", 0, 1>, 8>;
325-
def Char : IntType<"char", QualTypeFromFunction<"GetCharType", 0, 1>, 8>;
325+
def Char : IntType<"char", QualType<"Context.SignedCharTy", 0, 1>, 8>;
326+
def SChar : IntType<"schar", QualType<"Context.SignedCharTy", 0, 1>, 8>;
326327
def UChar : UIntType<"uchar", QualType<"Context.UnsignedCharTy">, 8>;
327328
def Short : IntType<"short", QualType<"Context.ShortTy", 0, 1>, 16>;
328329
def UShort : UIntType<"ushort", QualType<"Context.UnsignedShortTy">, 16>;
@@ -411,7 +412,7 @@ def IntLongFloatGenType1 : GenericType<"IntLongFloatGenType1", TLIntLongFloats
411412

412413
// GenType definitions for every single base type (e.g. fp32 only).
413414
// Names are like: GenTypeFloatVecAndScalar.
414-
foreach Type = [Char, UChar, Short, UShort,
415+
foreach Type = [Char, UChar, SChar, Short, UShort,
415416
Int, UInt, Long, ULong,
416417
Float, Double, Half] in {
417418
foreach VecSizes = [VecAndScalar, VecNoScalar] in {
@@ -871,16 +872,16 @@ foreach name = ["Dot"] in {
871872
}
872873

873874
foreach name = ["Any", "All"] in {
874-
def : SPVBuiltin<name, [Bool, GenTypeCharVecNoScalar], Attr.Const>;
875+
def : SPVBuiltin<name, [Bool, GenTypeSCharVecNoScalar], Attr.Const>;
875876
}
876877

877878
foreach name = ["IsNan", "IsInf", "IsFinite", "IsNormal", "SignBitSet"] in {
878879
def : SPVBuiltin<name, [Bool, Float], Attr.Const>;
879880
def : SPVBuiltin<name, [Bool, Double], Attr.Const>;
880881
def : SPVBuiltin<name, [Bool, Half], Attr.Const>;
881-
def : SPVBuiltin<name, [GenTypeCharVecNoScalar, GenTypeFloatVecNoScalar], Attr.Const>;
882-
def : SPVBuiltin<name, [GenTypeCharVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
883-
def : SPVBuiltin<name, [GenTypeCharVecNoScalar, GenTypeHalfVecNoScalar], 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>;
884885
}
885886

886887
foreach name = ["LessOrGreater",
@@ -894,9 +895,9 @@ foreach name = ["LessOrGreater",
894895
def : SPVBuiltin<name, [Bool, Float, Float], Attr.Const>;
895896
def : SPVBuiltin<name, [Bool, Double, Double], Attr.Const>;
896897
def : SPVBuiltin<name, [Bool, Half, Half], Attr.Const>;
897-
def : SPVBuiltin<name, [GenTypeCharVecNoScalar, GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar], Attr.Const>;
898-
def : SPVBuiltin<name, [GenTypeCharVecNoScalar, GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
899-
def : SPVBuiltin<name, [GenTypeCharVecNoScalar, GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], 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>;
900901
}
901902

902903
foreach name = ["BitCount"] in {

clang/lib/Sema/SemaLookup.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#include <utility>
5252
#include <vector>
5353

54-
static inline clang::QualType GetCharType(clang::ASTContext &Context);
5554
static inline clang::QualType GetFloat16Type(clang::ASTContext &Context);
5655

5756
#include "OpenCLBuiltins.inc"
@@ -702,10 +701,6 @@ LLVM_DUMP_METHOD void LookupResult::dump() {
702701
D->dump();
703702
}
704703

705-
static inline QualType GetCharType(clang::ASTContext &Context) {
706-
return Context.getLangOpts().OpenCL ? Context.CharTy : Context.SignedCharTy;
707-
}
708-
709704
static inline QualType GetFloat16Type(clang::ASTContext &Context) {
710705
return Context.getLangOpts().OpenCL ? Context.HalfTy : Context.Float16Ty;
711706
}

clang/test/CodeGenSPIRV/spirv-builtin-lookup-group.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool group_any(bool predicate) {
2727

2828
char group_broad_cast(char a) {
2929
// CHECK-LABEL: @group_broad_cast(
30-
// CHECK: call spir_func signext i8 @_Z22__spirv_GroupBroadcasticj(
30+
// CHECK: call spir_func i32 @_Z22__spirv_GroupBroadcastiij(
3131
return __spirv_GroupBroadcast(2, a, 0u);
3232
}
3333

@@ -87,7 +87,7 @@ unsigned long group_umax(unsigned long a) {
8787

8888
char group_smin(char a) {
8989
// CHECK-LABEL: @group_smin(
90-
// CHECK: call spir_func signext i8 @_Z17__spirv_GroupSMiniic(
90+
// CHECK: call spir_func i32 @_Z17__spirv_GroupSMiniii(
9191
return __spirv_GroupSMin(2, 0, a);
9292
}
9393

libclc/clc/include/clc/clc_as_type.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define __CLC_CLC_AS_TYPE_H__
1111

1212
#define __clc_as_char(x) __builtin_astype(x, char)
13+
#define __clc_as_schar(x) __builtin_astype(x, schar)
1314
#define __clc_as_uchar(x) __builtin_astype(x, uchar)
1415
#define __clc_as_short(x) __builtin_astype(x, short)
1516
#define __clc_as_ushort(x) __builtin_astype(x, ushort)
@@ -20,6 +21,7 @@
2021
#define __clc_as_float(x) __builtin_astype(x, float)
2122

2223
#define __clc_as_char2(x) __builtin_astype(x, char2)
24+
#define __clc_as_schar2(x) __builtin_astype(x, schar2)
2325
#define __clc_as_uchar2(x) __builtin_astype(x, uchar2)
2426
#define __clc_as_short2(x) __builtin_astype(x, short2)
2527
#define __clc_as_ushort2(x) __builtin_astype(x, ushort2)
@@ -30,6 +32,7 @@
3032
#define __clc_as_float2(x) __builtin_astype(x, float2)
3133

3234
#define __clc_as_char3(x) __builtin_astype(x, char3)
35+
#define __clc_as_schar3(x) __builtin_astype(x, schar3)
3336
#define __clc_as_uchar3(x) __builtin_astype(x, uchar3)
3437
#define __clc_as_short3(x) __builtin_astype(x, short3)
3538
#define __clc_as_ushort3(x) __builtin_astype(x, ushort3)
@@ -40,6 +43,7 @@
4043
#define __clc_as_float3(x) __builtin_astype(x, float3)
4144

4245
#define __clc_as_char4(x) __builtin_astype(x, char4)
46+
#define __clc_as_schar4(x) __builtin_astype(x, schar4)
4347
#define __clc_as_uchar4(x) __builtin_astype(x, uchar4)
4448
#define __clc_as_short4(x) __builtin_astype(x, short4)
4549
#define __clc_as_ushort4(x) __builtin_astype(x, ushort4)
@@ -50,7 +54,9 @@
5054
#define __clc_as_float4(x) __builtin_astype(x, float4)
5155

5256
#define __clc_as_char8(x) __builtin_astype(x, char8)
57+
#define __clc_as_schar8(x) __builtin_astype(x, schar8)
5358
#define __clc_as_uchar8(x) __builtin_astype(x, uchar8)
59+
#define __clc_as_schar8(x) __builtin_astype(x, schar8)
5460
#define __clc_as_short8(x) __builtin_astype(x, short8)
5561
#define __clc_as_ushort8(x) __builtin_astype(x, ushort8)
5662
#define __clc_as_int8(x) __builtin_astype(x, int8)
@@ -60,6 +66,7 @@
6066
#define __clc_as_float8(x) __builtin_astype(x, float8)
6167

6268
#define __clc_as_char16(x) __builtin_astype(x, char16)
69+
#define __clc_as_schar16(x) __builtin_astype(x, schar16)
6370
#define __clc_as_uchar16(x) __builtin_astype(x, uchar16)
6471
#define __clc_as_short16(x) __builtin_astype(x, short16)
6572
#define __clc_as_ushort16(x) __builtin_astype(x, ushort16)

libclc/clc/include/clc/clc_convert.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#define _CLC_VECTOR_CONVERT_FROM1(FROM_TYPE, SUFFIX) \
2626
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, char, SUFFIX) \
27+
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, schar, SUFFIX) \
2728
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uchar, SUFFIX) \
2829
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, int, SUFFIX) \
2930
_CLC_VECTOR_CONVERT_DECL(FROM_TYPE, uint, SUFFIX) \
@@ -57,6 +58,7 @@
5758

5859
#define _CLC_VECTOR_CONVERT_TO1(SUFFIX) \
5960
_CLC_VECTOR_CONVERT_FROM(char, SUFFIX) \
61+
_CLC_VECTOR_CONVERT_FROM(schar, SUFFIX) \
6062
_CLC_VECTOR_CONVERT_FROM(uchar, SUFFIX) \
6163
_CLC_VECTOR_CONVERT_FROM(int, SUFFIX) \
6264
_CLC_VECTOR_CONVERT_FROM(uint, SUFFIX) \

libclc/clc/include/clc/clctypes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
/* 6.1.1 Built-in Scalar Data Types */
1313

14+
typedef signed char schar;
1415
typedef unsigned char uchar;
1516
typedef unsigned short ushort;
1617
typedef unsigned int uint;
@@ -39,6 +40,12 @@ typedef __attribute__((ext_vector_type(4))) char char4;
3940
typedef __attribute__((ext_vector_type(8))) char char8;
4041
typedef __attribute__((ext_vector_type(16))) char char16;
4142

43+
typedef __attribute__((ext_vector_type(2))) schar schar2;
44+
typedef __attribute__((ext_vector_type(3))) schar schar3;
45+
typedef __attribute__((ext_vector_type(4))) schar schar4;
46+
typedef __attribute__((ext_vector_type(8))) schar schar8;
47+
typedef __attribute__((ext_vector_type(16))) schar schar16;
48+
4249
typedef __attribute__((ext_vector_type(2))) uchar uchar2;
4350
typedef __attribute__((ext_vector_type(3))) uchar uchar3;
4451
typedef __attribute__((ext_vector_type(4))) uchar uchar4;

0 commit comments

Comments
 (0)