1 Description: More user-friendly "type not supported" errors
3 (It would be even better if these returned build failure
4 rather than asserting, but that's not as easy)
6 Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
7 Forwarded: https://lists.freedesktop.org/archives/beignet/2017-September/009169.html
9 --- a/backend/src/backend/gen_insn_selection.cpp
10 +++ b/backend/src/backend/gen_insn_selection.cpp
11 @@ -5253,7 +5253,7 @@ extern bool OCL_DEBUGINFO; // first defi
12 write64Stateless(sel, address, src);
15 - GBE_ASSERT(sel.hasLongType());
16 + GBE_ASSERTM(sel.hasLongType(), "Long (int64) not supported on this device");
17 write64Stateless(sel, address, src);
20 @@ -5838,7 +5838,7 @@ extern bool OCL_DEBUGINFO; // first defi
22 /* The special case, when dst is half, float->word->half will lose accuracy. */
23 if (dstType == TYPE_HALF) {
24 - GBE_ASSERT(sel.hasHalfType());
25 + GBE_ASSERTM(sel.hasHalfType(), "Half precision not supported on this device");
29 @@ -5879,7 +5879,7 @@ extern bool OCL_DEBUGINFO; // first defi
31 if (dstType == TYPE_HALF) {
32 /* There is no MOV for Long <---> Half. So Long-->Float-->half. */
33 - GBE_ASSERT(sel.hasLongType());
34 + GBE_ASSERTM(sel.hasLongType(), "Long (int64) not supported on this device");
35 GBE_ASSERT(sel.hasHalfType());
37 if (sel.isScalarReg(insn.getSrc(0))) {
38 @@ -6181,7 +6181,7 @@ extern bool OCL_DEBUGINFO; // first defi
40 } else if (srcType == ir::TYPE_HALF) {
41 /* No need to consider old platform. if we support half, we must have native long. */
42 - GBE_ASSERT(sel.hasLongType());
43 + GBE_ASSERTM(sel.hasLongType(), "Long (int64) not supported on this device");
44 GBE_ASSERT(sel.hasHalfType());
45 uint32_t type = dstType == TYPE_U64 ? GEN_TYPE_UD : GEN_TYPE_D;
46 GenRegister tmp = GenRegister::retype(sel.selReg(sel.reg(FAMILY_DWORD, sel.isScalarReg(insn.getSrc(0))), TYPE_U32), type);
47 @@ -6205,7 +6205,7 @@ extern bool OCL_DEBUGINFO; // first defi
50 } else if (src.type == GEN_TYPE_DF) {
51 - GBE_ASSERT(sel.hasDoubleType());
52 + GBE_ASSERTM(sel.hasDoubleType(), "Double precision not supported on this device");
53 GBE_ASSERT(sel.hasLongType()); //So far, if we support double, we support native long.
56 @@ -6224,7 +6224,7 @@ extern bool OCL_DEBUGINFO; // first defi
57 const GenRegister dst = sel.selReg(insn.getDst(0), dstType);
58 const GenRegister src = sel.selReg(insn.getSrc(0), srcType);
60 - GBE_ASSERT(sel.hasDoubleType());
61 + GBE_ASSERTM(sel.hasDoubleType(), "Double precision not supported on this device (if this is a literal, use '1.0f' not '1.0')");
63 if (sel.isScalarReg(insn.getDst(0))) {
64 // dst is scalar, just MOV and nothing more.
65 @@ -6263,7 +6263,7 @@ extern bool OCL_DEBUGINFO; // first defi
66 const GenRegister dst = sel.selReg(insn.getDst(0), dstType);
67 const GenRegister src = sel.selReg(insn.getSrc(0), srcType);
69 - GBE_ASSERT(sel.hasDoubleType());
70 + GBE_ASSERTM(sel.hasDoubleType(), "Double precision not supported on this device (if this is a literal, use '1.0f' not '1.0')");
71 GBE_ASSERT(sel.hasHalfType()); //So far, if we support double, we support half.
73 if (sel.isScalarReg(insn.getDst(0))) { // uniform case.
74 @@ -6329,7 +6329,7 @@ extern bool OCL_DEBUGINFO; // first defi
75 // Special case, half -> char/short.
76 /* [DevBDW+]: Format conversion to or from HF (Half Float) must be DWord-aligned and
77 strided by a DWord on the destination. */
78 - GBE_ASSERT(sel.hasHalfType());
79 + GBE_ASSERTM(sel.hasHalfType(), "Half precision not supported on this device");
82 if (sel.isScalarReg(insn.getSrc(0))) {
83 @@ -6361,7 +6361,7 @@ extern bool OCL_DEBUGINFO; // first defi
84 // Special case, char/uchar -> half
85 /* [DevBDW+]: Format conversion to or from HF (Half Float) must be DWord-aligned and
86 strided by a DWord on the destination. */
87 - GBE_ASSERT(sel.hasHalfType());
88 + GBE_ASSERTM(sel.hasHalfType(), "Half precision not supported on this device");
89 GenRegister tmp = GenRegister::retype(sel.unpacked_uw(sel.reg(FAMILY_DWORD, sel.isScalarReg(insn.getSrc(0)))), GEN_TYPE_HF);
91 if (sel.isScalarReg(insn.getSrc(0))) {
92 @@ -6383,7 +6383,7 @@ extern bool OCL_DEBUGINFO; // first defi
93 const GenRegister src = sel.selReg(insn.getSrc(0), srcType);
94 const RegisterFamily dstFamily = getFamily(dstType);
96 - GBE_ASSERT(sel.hasDoubleType());
97 + GBE_ASSERTM(sel.hasDoubleType(), "Double precision not supported on this device (if this is a literal, use '1.0f' not '1.0')");
98 GBE_ASSERT(sel.hasHalfType()); //So far, if we support double, we support half.
99 if (sel.isScalarReg(insn.getDst(0))) {
100 // dst is scalar, just MOV and nothing more.
101 @@ -6427,7 +6427,7 @@ extern bool OCL_DEBUGINFO; // first defi
102 const GenRegister dst = sel.selReg(insn.getDst(0), dstType);
103 const GenRegister src = sel.selReg(insn.getSrc(0), srcType);
105 - GBE_ASSERT(sel.hasDoubleType());
106 + GBE_ASSERTM(sel.hasDoubleType(), "Double precision not supported on this device");
107 GBE_ASSERT(sel.hasLongType()); //So far, if we support double, we support native long.
110 @@ -6442,7 +6442,7 @@ extern bool OCL_DEBUGINFO; // first defi
111 const GenRegister src = sel.selReg(insn.getSrc(0), srcType);
112 const RegisterFamily srcFamily = getFamily(srcType);
114 - GBE_ASSERT(sel.hasDoubleType());
115 + GBE_ASSERTM(sel.hasDoubleType(), "Double precision not supported on this device");
116 GBE_ASSERT(sel.hasLongType()); //So far, if we support double, we support native long.
118 if (sel.hasLongType() && sel.hasLongRegRestrict()) {