authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-28 13:11:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-28 13:11:47-07:00
logdb4fea6689eb34959028cad3b63de45da65683d3
treea35545e60b6828c72b3101143834bf3f384921b9
parent6aeab0f323ff14d7ad248e18c372573f7a5a8cd1

update libcxx, libcxxabi, and C headers to release/13.x branch

upstream commit 9c49fee5e7ac0ca8bc4ec1c3738ca0d83df65852

12 files changed, 476 insertions(+), 190 deletions(-)

lib/include/__clang_cuda_device_functions.h+174-102
...@@ -34,10 +34,12 @@ __DEVICE__ unsigned long long __brevll(unsigned long long __a) {...@@ -34,10 +34,12 @@ __DEVICE__ unsigned long long __brevll(unsigned long long __a) {
34 return __nv_brevll(__a);34 return __nv_brevll(__a);
35}35}
36#if defined(__cplusplus)36#if defined(__cplusplus)
37__DEVICE__ void __brkpt() { asm volatile("brkpt;"); }37__DEVICE__ void __brkpt() { __asm__ __volatile__("brkpt;"); }
38__DEVICE__ void __brkpt(int __a) { __brkpt(); }38__DEVICE__ void __brkpt(int __a) { __brkpt(); }
39#else39#else
40__DEVICE__ void __attribute__((overloadable)) __brkpt(void) { asm volatile("brkpt;"); }40__DEVICE__ void __attribute__((overloadable)) __brkpt(void) {
41 __asm__ __volatile__("brkpt;");
42}
41__DEVICE__ void __attribute__((overloadable)) __brkpt(int __a) { __brkpt(); }43__DEVICE__ void __attribute__((overloadable)) __brkpt(int __a) { __brkpt(); }
42#endif44#endif
43__DEVICE__ unsigned int __byte_perm(unsigned int __a, unsigned int __b,45__DEVICE__ unsigned int __byte_perm(unsigned int __a, unsigned int __b,
...@@ -507,7 +509,7 @@ __DEVICE__ float __powf(float __a, float __b) {...@@ -507,7 +509,7 @@ __DEVICE__ float __powf(float __a, float __b) {
507}509}
508510
509// Parameter must have a known integer value.511// Parameter must have a known integer value.
510#define __prof_trigger(__a) asm __volatile__("pmevent \t%0;" ::"i"(__a))512#define __prof_trigger(__a) __asm__ __volatile__("pmevent \t%0;" ::"i"(__a))
511__DEVICE__ int __rhadd(int __a, int __b) { return __nv_rhadd(__a, __b); }513__DEVICE__ int __rhadd(int __a, int __b) { return __nv_rhadd(__a, __b); }
512__DEVICE__ unsigned int __sad(int __a, int __b, unsigned int __c) {514__DEVICE__ unsigned int __sad(int __a, int __b, unsigned int __c) {
513 return __nv_sad(__a, __b, __c);515 return __nv_sad(__a, __b, __c);
...@@ -526,7 +528,7 @@ __DEVICE__ float __tanf(float __a) { return __nv_fast_tanf(__a); }...@@ -526,7 +528,7 @@ __DEVICE__ float __tanf(float __a) { return __nv_fast_tanf(__a); }
526__DEVICE__ void __threadfence(void) { __nvvm_membar_gl(); }528__DEVICE__ void __threadfence(void) { __nvvm_membar_gl(); }
527__DEVICE__ void __threadfence_block(void) { __nvvm_membar_cta(); };529__DEVICE__ void __threadfence_block(void) { __nvvm_membar_cta(); };
528__DEVICE__ void __threadfence_system(void) { __nvvm_membar_sys(); };530__DEVICE__ void __threadfence_system(void) { __nvvm_membar_sys(); };
529__DEVICE__ void __trap(void) { asm volatile("trap;"); }531__DEVICE__ void __trap(void) { __asm__ __volatile__("trap;"); }
530__DEVICE__ unsigned int __uAtomicAdd(unsigned int *__p, unsigned int __v) {532__DEVICE__ unsigned int __uAtomicAdd(unsigned int *__p, unsigned int __v) {
531 return __nvvm_atom_add_gen_i((int *)__p, __v);533 return __nvvm_atom_add_gen_i((int *)__p, __v);
532}534}
...@@ -1051,122 +1053,136 @@ __DEVICE__ unsigned int __bool2mask(unsigned int __a, int shift) {...@@ -1051,122 +1053,136 @@ __DEVICE__ unsigned int __bool2mask(unsigned int __a, int shift) {
1051}1053}
1052__DEVICE__ unsigned int __vabs2(unsigned int __a) {1054__DEVICE__ unsigned int __vabs2(unsigned int __a) {
1053 unsigned int r;1055 unsigned int r;
1054 asm("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;"1056 __asm__("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;"
1055 : "=r"(r)1057 : "=r"(r)
1056 : "r"(__a), "r"(0), "r"(0));1058 : "r"(__a), "r"(0), "r"(0));
1057 return r;1059 return r;
1058}1060}
1059__DEVICE__ unsigned int __vabs4(unsigned int __a) {1061__DEVICE__ unsigned int __vabs4(unsigned int __a) {
1060 unsigned int r;1062 unsigned int r;
1061 asm("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;"1063 __asm__("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;"
1062 : "=r"(r)1064 : "=r"(r)
1063 : "r"(__a), "r"(0), "r"(0));1065 : "r"(__a), "r"(0), "r"(0));
1064 return r;1066 return r;
1065}1067}
1066__DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) {1068__DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) {
1067 unsigned int r;1069 unsigned int r;
1068 asm("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;"1070 __asm__("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;"
1069 : "=r"(r)1071 : "=r"(r)
1070 : "r"(__a), "r"(__b), "r"(0));1072 : "r"(__a), "r"(__b), "r"(0));
1071 return r;1073 return r;
1072}1074}
10731075
1074__DEVICE__ unsigned int __vabsdiffs4(unsigned int __a, unsigned int __b) {1076__DEVICE__ unsigned int __vabsdiffs4(unsigned int __a, unsigned int __b) {
1075 unsigned int r;1077 unsigned int r;
1076 asm("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;"1078 __asm__("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;"
1077 : "=r"(r)1079 : "=r"(r)
1078 : "r"(__a), "r"(__b), "r"(0));1080 : "r"(__a), "r"(__b), "r"(0));
1079 return r;1081 return r;
1080}1082}
1081__DEVICE__ unsigned int __vabsdiffu2(unsigned int __a, unsigned int __b) {1083__DEVICE__ unsigned int __vabsdiffu2(unsigned int __a, unsigned int __b) {
1082 unsigned int r;1084 unsigned int r;
1083 asm("vabsdiff2.u32.u32.u32 %0,%1,%2,%3;"1085 __asm__("vabsdiff2.u32.u32.u32 %0,%1,%2,%3;"
1084 : "=r"(r)1086 : "=r"(r)
1085 : "r"(__a), "r"(__b), "r"(0));1087 : "r"(__a), "r"(__b), "r"(0));
1086 return r;1088 return r;
1087}1089}
1088__DEVICE__ unsigned int __vabsdiffu4(unsigned int __a, unsigned int __b) {1090__DEVICE__ unsigned int __vabsdiffu4(unsigned int __a, unsigned int __b) {
1089 unsigned int r;1091 unsigned int r;
1090 asm("vabsdiff4.u32.u32.u32 %0,%1,%2,%3;"1092 __asm__("vabsdiff4.u32.u32.u32 %0,%1,%2,%3;"
1091 : "=r"(r)1093 : "=r"(r)
1092 : "r"(__a), "r"(__b), "r"(0));1094 : "r"(__a), "r"(__b), "r"(0));
1093 return r;1095 return r;
1094}1096}
1095__DEVICE__ unsigned int __vabsss2(unsigned int __a) {1097__DEVICE__ unsigned int __vabsss2(unsigned int __a) {
1096 unsigned int r;1098 unsigned int r;
1097 asm("vabsdiff2.s32.s32.s32.sat %0,%1,%2,%3;"1099 __asm__("vabsdiff2.s32.s32.s32.sat %0,%1,%2,%3;"
1098 : "=r"(r)1100 : "=r"(r)
1099 : "r"(__a), "r"(0), "r"(0));1101 : "r"(__a), "r"(0), "r"(0));
1100 return r;1102 return r;
1101}1103}
1102__DEVICE__ unsigned int __vabsss4(unsigned int __a) {1104__DEVICE__ unsigned int __vabsss4(unsigned int __a) {
1103 unsigned int r;1105 unsigned int r;
1104 asm("vabsdiff4.s32.s32.s32.sat %0,%1,%2,%3;"1106 __asm__("vabsdiff4.s32.s32.s32.sat %0,%1,%2,%3;"
1105 : "=r"(r)1107 : "=r"(r)
1106 : "r"(__a), "r"(0), "r"(0));1108 : "r"(__a), "r"(0), "r"(0));
1107 return r;1109 return r;
1108}1110}
1109__DEVICE__ unsigned int __vadd2(unsigned int __a, unsigned int __b) {1111__DEVICE__ unsigned int __vadd2(unsigned int __a, unsigned int __b) {
1110 unsigned int r;1112 unsigned int r;
1111 asm("vadd2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1113 __asm__("vadd2.u32.u32.u32 %0,%1,%2,%3;"
1114 : "=r"(r)
1115 : "r"(__a), "r"(__b), "r"(0));
1112 return r;1116 return r;
1113}1117}
1114__DEVICE__ unsigned int __vadd4(unsigned int __a, unsigned int __b) {1118__DEVICE__ unsigned int __vadd4(unsigned int __a, unsigned int __b) {
1115 unsigned int r;1119 unsigned int r;
1116 asm("vadd4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1120 __asm__("vadd4.u32.u32.u32 %0,%1,%2,%3;"
1121 : "=r"(r)
1122 : "r"(__a), "r"(__b), "r"(0));
1117 return r;1123 return r;
1118}1124}
1119__DEVICE__ unsigned int __vaddss2(unsigned int __a, unsigned int __b) {1125__DEVICE__ unsigned int __vaddss2(unsigned int __a, unsigned int __b) {
1120 unsigned int r;1126 unsigned int r;
1121 asm("vadd2.s32.s32.s32.sat %0,%1,%2,%3;"1127 __asm__("vadd2.s32.s32.s32.sat %0,%1,%2,%3;"
1122 : "=r"(r)1128 : "=r"(r)
1123 : "r"(__a), "r"(__b), "r"(0));1129 : "r"(__a), "r"(__b), "r"(0));
1124 return r;1130 return r;
1125}1131}
1126__DEVICE__ unsigned int __vaddss4(unsigned int __a, unsigned int __b) {1132__DEVICE__ unsigned int __vaddss4(unsigned int __a, unsigned int __b) {
1127 unsigned int r;1133 unsigned int r;
1128 asm("vadd4.s32.s32.s32.sat %0,%1,%2,%3;"1134 __asm__("vadd4.s32.s32.s32.sat %0,%1,%2,%3;"
1129 : "=r"(r)1135 : "=r"(r)
1130 : "r"(__a), "r"(__b), "r"(0));1136 : "r"(__a), "r"(__b), "r"(0));
1131 return r;1137 return r;
1132}1138}
1133__DEVICE__ unsigned int __vaddus2(unsigned int __a, unsigned int __b) {1139__DEVICE__ unsigned int __vaddus2(unsigned int __a, unsigned int __b) {
1134 unsigned int r;1140 unsigned int r;
1135 asm("vadd2.u32.u32.u32.sat %0,%1,%2,%3;"1141 __asm__("vadd2.u32.u32.u32.sat %0,%1,%2,%3;"
1136 : "=r"(r)1142 : "=r"(r)
1137 : "r"(__a), "r"(__b), "r"(0));1143 : "r"(__a), "r"(__b), "r"(0));
1138 return r;1144 return r;
1139}1145}
1140__DEVICE__ unsigned int __vaddus4(unsigned int __a, unsigned int __b) {1146__DEVICE__ unsigned int __vaddus4(unsigned int __a, unsigned int __b) {
1141 unsigned int r;1147 unsigned int r;
1142 asm("vadd4.u32.u32.u32.sat %0,%1,%2,%3;"1148 __asm__("vadd4.u32.u32.u32.sat %0,%1,%2,%3;"
1143 : "=r"(r)1149 : "=r"(r)
1144 : "r"(__a), "r"(__b), "r"(0));1150 : "r"(__a), "r"(__b), "r"(0));
1145 return r;1151 return r;
1146}1152}
1147__DEVICE__ unsigned int __vavgs2(unsigned int __a, unsigned int __b) {1153__DEVICE__ unsigned int __vavgs2(unsigned int __a, unsigned int __b) {
1148 unsigned int r;1154 unsigned int r;
1149 asm("vavrg2.s32.s32.s32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1155 __asm__("vavrg2.s32.s32.s32 %0,%1,%2,%3;"
1156 : "=r"(r)
1157 : "r"(__a), "r"(__b), "r"(0));
1150 return r;1158 return r;
1151}1159}
1152__DEVICE__ unsigned int __vavgs4(unsigned int __a, unsigned int __b) {1160__DEVICE__ unsigned int __vavgs4(unsigned int __a, unsigned int __b) {
1153 unsigned int r;1161 unsigned int r;
1154 asm("vavrg4.s32.s32.s32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1162 __asm__("vavrg4.s32.s32.s32 %0,%1,%2,%3;"
1163 : "=r"(r)
1164 : "r"(__a), "r"(__b), "r"(0));
1155 return r;1165 return r;
1156}1166}
1157__DEVICE__ unsigned int __vavgu2(unsigned int __a, unsigned int __b) {1167__DEVICE__ unsigned int __vavgu2(unsigned int __a, unsigned int __b) {
1158 unsigned int r;1168 unsigned int r;
1159 asm("vavrg2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1169 __asm__("vavrg2.u32.u32.u32 %0,%1,%2,%3;"
1170 : "=r"(r)
1171 : "r"(__a), "r"(__b), "r"(0));
1160 return r;1172 return r;
1161}1173}
1162__DEVICE__ unsigned int __vavgu4(unsigned int __a, unsigned int __b) {1174__DEVICE__ unsigned int __vavgu4(unsigned int __a, unsigned int __b) {
1163 unsigned int r;1175 unsigned int r;
1164 asm("vavrg4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1176 __asm__("vavrg4.u32.u32.u32 %0,%1,%2,%3;"
1177 : "=r"(r)
1178 : "r"(__a), "r"(__b), "r"(0));
1165 return r;1179 return r;
1166}1180}
1167__DEVICE__ unsigned int __vseteq2(unsigned int __a, unsigned int __b) {1181__DEVICE__ unsigned int __vseteq2(unsigned int __a, unsigned int __b) {
1168 unsigned int r;1182 unsigned int r;
1169 asm("vset2.u32.u32.eq %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1183 __asm__("vset2.u32.u32.eq %0,%1,%2,%3;"
1184 : "=r"(r)
1185 : "r"(__a), "r"(__b), "r"(0));
1170 return r;1186 return r;
1171}1187}
1172__DEVICE__ unsigned int __vcmpeq2(unsigned int __a, unsigned int __b) {1188__DEVICE__ unsigned int __vcmpeq2(unsigned int __a, unsigned int __b) {
...@@ -1174,7 +1190,9 @@ __DEVICE__ unsigned int __vcmpeq2(unsigned int __a, unsigned int __b) {...@@ -1174,7 +1190,9 @@ __DEVICE__ unsigned int __vcmpeq2(unsigned int __a, unsigned int __b) {
1174}1190}
1175__DEVICE__ unsigned int __vseteq4(unsigned int __a, unsigned int __b) {1191__DEVICE__ unsigned int __vseteq4(unsigned int __a, unsigned int __b) {
1176 unsigned int r;1192 unsigned int r;
1177 asm("vset4.u32.u32.eq %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1193 __asm__("vset4.u32.u32.eq %0,%1,%2,%3;"
1194 : "=r"(r)
1195 : "r"(__a), "r"(__b), "r"(0));
1178 return r;1196 return r;
1179}1197}
1180__DEVICE__ unsigned int __vcmpeq4(unsigned int __a, unsigned int __b) {1198__DEVICE__ unsigned int __vcmpeq4(unsigned int __a, unsigned int __b) {
...@@ -1182,7 +1200,9 @@ __DEVICE__ unsigned int __vcmpeq4(unsigned int __a, unsigned int __b) {...@@ -1182,7 +1200,9 @@ __DEVICE__ unsigned int __vcmpeq4(unsigned int __a, unsigned int __b) {
1182}1200}
1183__DEVICE__ unsigned int __vsetges2(unsigned int __a, unsigned int __b) {1201__DEVICE__ unsigned int __vsetges2(unsigned int __a, unsigned int __b) {
1184 unsigned int r;1202 unsigned int r;
1185 asm("vset2.s32.s32.ge %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1203 __asm__("vset2.s32.s32.ge %0,%1,%2,%3;"
1204 : "=r"(r)
1205 : "r"(__a), "r"(__b), "r"(0));
1186 return r;1206 return r;
1187}1207}
1188__DEVICE__ unsigned int __vcmpges2(unsigned int __a, unsigned int __b) {1208__DEVICE__ unsigned int __vcmpges2(unsigned int __a, unsigned int __b) {
...@@ -1190,7 +1210,9 @@ __DEVICE__ unsigned int __vcmpges2(unsigned int __a, unsigned int __b) {...@@ -1190,7 +1210,9 @@ __DEVICE__ unsigned int __vcmpges2(unsigned int __a, unsigned int __b) {
1190}1210}
1191__DEVICE__ unsigned int __vsetges4(unsigned int __a, unsigned int __b) {1211__DEVICE__ unsigned int __vsetges4(unsigned int __a, unsigned int __b) {
1192 unsigned int r;1212 unsigned int r;
1193 asm("vset4.s32.s32.ge %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1213 __asm__("vset4.s32.s32.ge %0,%1,%2,%3;"
1214 : "=r"(r)
1215 : "r"(__a), "r"(__b), "r"(0));
1194 return r;1216 return r;
1195}1217}
1196__DEVICE__ unsigned int __vcmpges4(unsigned int __a, unsigned int __b) {1218__DEVICE__ unsigned int __vcmpges4(unsigned int __a, unsigned int __b) {
...@@ -1198,7 +1220,9 @@ __DEVICE__ unsigned int __vcmpges4(unsigned int __a, unsigned int __b) {...@@ -1198,7 +1220,9 @@ __DEVICE__ unsigned int __vcmpges4(unsigned int __a, unsigned int __b) {
1198}1220}
1199__DEVICE__ unsigned int __vsetgeu2(unsigned int __a, unsigned int __b) {1221__DEVICE__ unsigned int __vsetgeu2(unsigned int __a, unsigned int __b) {
1200 unsigned int r;1222 unsigned int r;
1201 asm("vset2.u32.u32.ge %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1223 __asm__("vset2.u32.u32.ge %0,%1,%2,%3;"
1224 : "=r"(r)
1225 : "r"(__a), "r"(__b), "r"(0));
1202 return r;1226 return r;
1203}1227}
1204__DEVICE__ unsigned int __vcmpgeu2(unsigned int __a, unsigned int __b) {1228__DEVICE__ unsigned int __vcmpgeu2(unsigned int __a, unsigned int __b) {
...@@ -1206,7 +1230,9 @@ __DEVICE__ unsigned int __vcmpgeu2(unsigned int __a, unsigned int __b) {...@@ -1206,7 +1230,9 @@ __DEVICE__ unsigned int __vcmpgeu2(unsigned int __a, unsigned int __b) {
1206}1230}
1207__DEVICE__ unsigned int __vsetgeu4(unsigned int __a, unsigned int __b) {1231__DEVICE__ unsigned int __vsetgeu4(unsigned int __a, unsigned int __b) {
1208 unsigned int r;1232 unsigned int r;
1209 asm("vset4.u32.u32.ge %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1233 __asm__("vset4.u32.u32.ge %0,%1,%2,%3;"
1234 : "=r"(r)
1235 : "r"(__a), "r"(__b), "r"(0));
1210 return r;1236 return r;
1211}1237}
1212__DEVICE__ unsigned int __vcmpgeu4(unsigned int __a, unsigned int __b) {1238__DEVICE__ unsigned int __vcmpgeu4(unsigned int __a, unsigned int __b) {
...@@ -1214,7 +1240,9 @@ __DEVICE__ unsigned int __vcmpgeu4(unsigned int __a, unsigned int __b) {...@@ -1214,7 +1240,9 @@ __DEVICE__ unsigned int __vcmpgeu4(unsigned int __a, unsigned int __b) {
1214}1240}
1215__DEVICE__ unsigned int __vsetgts2(unsigned int __a, unsigned int __b) {1241__DEVICE__ unsigned int __vsetgts2(unsigned int __a, unsigned int __b) {
1216 unsigned int r;1242 unsigned int r;
1217 asm("vset2.s32.s32.gt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1243 __asm__("vset2.s32.s32.gt %0,%1,%2,%3;"
1244 : "=r"(r)
1245 : "r"(__a), "r"(__b), "r"(0));
1218 return r;1246 return r;
1219}1247}
1220__DEVICE__ unsigned int __vcmpgts2(unsigned int __a, unsigned int __b) {1248__DEVICE__ unsigned int __vcmpgts2(unsigned int __a, unsigned int __b) {
...@@ -1222,7 +1250,9 @@ __DEVICE__ unsigned int __vcmpgts2(unsigned int __a, unsigned int __b) {...@@ -1222,7 +1250,9 @@ __DEVICE__ unsigned int __vcmpgts2(unsigned int __a, unsigned int __b) {
1222}1250}
1223__DEVICE__ unsigned int __vsetgts4(unsigned int __a, unsigned int __b) {1251__DEVICE__ unsigned int __vsetgts4(unsigned int __a, unsigned int __b) {
1224 unsigned int r;1252 unsigned int r;
1225 asm("vset4.s32.s32.gt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1253 __asm__("vset4.s32.s32.gt %0,%1,%2,%3;"
1254 : "=r"(r)
1255 : "r"(__a), "r"(__b), "r"(0));
1226 return r;1256 return r;
1227}1257}
1228__DEVICE__ unsigned int __vcmpgts4(unsigned int __a, unsigned int __b) {1258__DEVICE__ unsigned int __vcmpgts4(unsigned int __a, unsigned int __b) {
...@@ -1230,7 +1260,9 @@ __DEVICE__ unsigned int __vcmpgts4(unsigned int __a, unsigned int __b) {...@@ -1230,7 +1260,9 @@ __DEVICE__ unsigned int __vcmpgts4(unsigned int __a, unsigned int __b) {
1230}1260}
1231__DEVICE__ unsigned int __vsetgtu2(unsigned int __a, unsigned int __b) {1261__DEVICE__ unsigned int __vsetgtu2(unsigned int __a, unsigned int __b) {
1232 unsigned int r;1262 unsigned int r;
1233 asm("vset2.u32.u32.gt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1263 __asm__("vset2.u32.u32.gt %0,%1,%2,%3;"
1264 : "=r"(r)
1265 : "r"(__a), "r"(__b), "r"(0));
1234 return r;1266 return r;
1235}1267}
1236__DEVICE__ unsigned int __vcmpgtu2(unsigned int __a, unsigned int __b) {1268__DEVICE__ unsigned int __vcmpgtu2(unsigned int __a, unsigned int __b) {
...@@ -1238,7 +1270,9 @@ __DEVICE__ unsigned int __vcmpgtu2(unsigned int __a, unsigned int __b) {...@@ -1238,7 +1270,9 @@ __DEVICE__ unsigned int __vcmpgtu2(unsigned int __a, unsigned int __b) {
1238}1270}
1239__DEVICE__ unsigned int __vsetgtu4(unsigned int __a, unsigned int __b) {1271__DEVICE__ unsigned int __vsetgtu4(unsigned int __a, unsigned int __b) {
1240 unsigned int r;1272 unsigned int r;
1241 asm("vset4.u32.u32.gt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1273 __asm__("vset4.u32.u32.gt %0,%1,%2,%3;"
1274 : "=r"(r)
1275 : "r"(__a), "r"(__b), "r"(0));
1242 return r;1276 return r;
1243}1277}
1244__DEVICE__ unsigned int __vcmpgtu4(unsigned int __a, unsigned int __b) {1278__DEVICE__ unsigned int __vcmpgtu4(unsigned int __a, unsigned int __b) {
...@@ -1246,7 +1280,9 @@ __DEVICE__ unsigned int __vcmpgtu4(unsigned int __a, unsigned int __b) {...@@ -1246,7 +1280,9 @@ __DEVICE__ unsigned int __vcmpgtu4(unsigned int __a, unsigned int __b) {
1246}1280}
1247__DEVICE__ unsigned int __vsetles2(unsigned int __a, unsigned int __b) {1281__DEVICE__ unsigned int __vsetles2(unsigned int __a, unsigned int __b) {
1248 unsigned int r;1282 unsigned int r;
1249 asm("vset2.s32.s32.le %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1283 __asm__("vset2.s32.s32.le %0,%1,%2,%3;"
1284 : "=r"(r)
1285 : "r"(__a), "r"(__b), "r"(0));
1250 return r;1286 return r;
1251}1287}
1252__DEVICE__ unsigned int __vcmples2(unsigned int __a, unsigned int __b) {1288__DEVICE__ unsigned int __vcmples2(unsigned int __a, unsigned int __b) {
...@@ -1254,7 +1290,9 @@ __DEVICE__ unsigned int __vcmples2(unsigned int __a, unsigned int __b) {...@@ -1254,7 +1290,9 @@ __DEVICE__ unsigned int __vcmples2(unsigned int __a, unsigned int __b) {
1254}1290}
1255__DEVICE__ unsigned int __vsetles4(unsigned int __a, unsigned int __b) {1291__DEVICE__ unsigned int __vsetles4(unsigned int __a, unsigned int __b) {
1256 unsigned int r;1292 unsigned int r;
1257 asm("vset4.s32.s32.le %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1293 __asm__("vset4.s32.s32.le %0,%1,%2,%3;"
1294 : "=r"(r)
1295 : "r"(__a), "r"(__b), "r"(0));
1258 return r;1296 return r;
1259}1297}
1260__DEVICE__ unsigned int __vcmples4(unsigned int __a, unsigned int __b) {1298__DEVICE__ unsigned int __vcmples4(unsigned int __a, unsigned int __b) {
...@@ -1262,7 +1300,9 @@ __DEVICE__ unsigned int __vcmples4(unsigned int __a, unsigned int __b) {...@@ -1262,7 +1300,9 @@ __DEVICE__ unsigned int __vcmples4(unsigned int __a, unsigned int __b) {
1262}1300}
1263__DEVICE__ unsigned int __vsetleu2(unsigned int __a, unsigned int __b) {1301__DEVICE__ unsigned int __vsetleu2(unsigned int __a, unsigned int __b) {
1264 unsigned int r;1302 unsigned int r;
1265 asm("vset2.u32.u32.le %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1303 __asm__("vset2.u32.u32.le %0,%1,%2,%3;"
1304 : "=r"(r)
1305 : "r"(__a), "r"(__b), "r"(0));
1266 return r;1306 return r;
1267}1307}
1268__DEVICE__ unsigned int __vcmpleu2(unsigned int __a, unsigned int __b) {1308__DEVICE__ unsigned int __vcmpleu2(unsigned int __a, unsigned int __b) {
...@@ -1270,7 +1310,9 @@ __DEVICE__ unsigned int __vcmpleu2(unsigned int __a, unsigned int __b) {...@@ -1270,7 +1310,9 @@ __DEVICE__ unsigned int __vcmpleu2(unsigned int __a, unsigned int __b) {
1270}1310}
1271__DEVICE__ unsigned int __vsetleu4(unsigned int __a, unsigned int __b) {1311__DEVICE__ unsigned int __vsetleu4(unsigned int __a, unsigned int __b) {
1272 unsigned int r;1312 unsigned int r;
1273 asm("vset4.u32.u32.le %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1313 __asm__("vset4.u32.u32.le %0,%1,%2,%3;"
1314 : "=r"(r)
1315 : "r"(__a), "r"(__b), "r"(0));
1274 return r;1316 return r;
1275}1317}
1276__DEVICE__ unsigned int __vcmpleu4(unsigned int __a, unsigned int __b) {1318__DEVICE__ unsigned int __vcmpleu4(unsigned int __a, unsigned int __b) {
...@@ -1278,7 +1320,9 @@ __DEVICE__ unsigned int __vcmpleu4(unsigned int __a, unsigned int __b) {...@@ -1278,7 +1320,9 @@ __DEVICE__ unsigned int __vcmpleu4(unsigned int __a, unsigned int __b) {
1278}1320}
1279__DEVICE__ unsigned int __vsetlts2(unsigned int __a, unsigned int __b) {1321__DEVICE__ unsigned int __vsetlts2(unsigned int __a, unsigned int __b) {
1280 unsigned int r;1322 unsigned int r;
1281 asm("vset2.s32.s32.lt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1323 __asm__("vset2.s32.s32.lt %0,%1,%2,%3;"
1324 : "=r"(r)
1325 : "r"(__a), "r"(__b), "r"(0));
1282 return r;1326 return r;
1283}1327}
1284__DEVICE__ unsigned int __vcmplts2(unsigned int __a, unsigned int __b) {1328__DEVICE__ unsigned int __vcmplts2(unsigned int __a, unsigned int __b) {
...@@ -1286,7 +1330,9 @@ __DEVICE__ unsigned int __vcmplts2(unsigned int __a, unsigned int __b) {...@@ -1286,7 +1330,9 @@ __DEVICE__ unsigned int __vcmplts2(unsigned int __a, unsigned int __b) {
1286}1330}
1287__DEVICE__ unsigned int __vsetlts4(unsigned int __a, unsigned int __b) {1331__DEVICE__ unsigned int __vsetlts4(unsigned int __a, unsigned int __b) {
1288 unsigned int r;1332 unsigned int r;
1289 asm("vset4.s32.s32.lt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1333 __asm__("vset4.s32.s32.lt %0,%1,%2,%3;"
1334 : "=r"(r)
1335 : "r"(__a), "r"(__b), "r"(0));
1290 return r;1336 return r;
1291}1337}
1292__DEVICE__ unsigned int __vcmplts4(unsigned int __a, unsigned int __b) {1338__DEVICE__ unsigned int __vcmplts4(unsigned int __a, unsigned int __b) {
...@@ -1294,7 +1340,9 @@ __DEVICE__ unsigned int __vcmplts4(unsigned int __a, unsigned int __b) {...@@ -1294,7 +1340,9 @@ __DEVICE__ unsigned int __vcmplts4(unsigned int __a, unsigned int __b) {
1294}1340}
1295__DEVICE__ unsigned int __vsetltu2(unsigned int __a, unsigned int __b) {1341__DEVICE__ unsigned int __vsetltu2(unsigned int __a, unsigned int __b) {
1296 unsigned int r;1342 unsigned int r;
1297 asm("vset2.u32.u32.lt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1343 __asm__("vset2.u32.u32.lt %0,%1,%2,%3;"
1344 : "=r"(r)
1345 : "r"(__a), "r"(__b), "r"(0));
1298 return r;1346 return r;
1299}1347}
1300__DEVICE__ unsigned int __vcmpltu2(unsigned int __a, unsigned int __b) {1348__DEVICE__ unsigned int __vcmpltu2(unsigned int __a, unsigned int __b) {
...@@ -1302,7 +1350,9 @@ __DEVICE__ unsigned int __vcmpltu2(unsigned int __a, unsigned int __b) {...@@ -1302,7 +1350,9 @@ __DEVICE__ unsigned int __vcmpltu2(unsigned int __a, unsigned int __b) {
1302}1350}
1303__DEVICE__ unsigned int __vsetltu4(unsigned int __a, unsigned int __b) {1351__DEVICE__ unsigned int __vsetltu4(unsigned int __a, unsigned int __b) {
1304 unsigned int r;1352 unsigned int r;
1305 asm("vset4.u32.u32.lt %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1353 __asm__("vset4.u32.u32.lt %0,%1,%2,%3;"
1354 : "=r"(r)
1355 : "r"(__a), "r"(__b), "r"(0));
1306 return r;1356 return r;
1307}1357}
1308__DEVICE__ unsigned int __vcmpltu4(unsigned int __a, unsigned int __b) {1358__DEVICE__ unsigned int __vcmpltu4(unsigned int __a, unsigned int __b) {
...@@ -1310,7 +1360,9 @@ __DEVICE__ unsigned int __vcmpltu4(unsigned int __a, unsigned int __b) {...@@ -1310,7 +1360,9 @@ __DEVICE__ unsigned int __vcmpltu4(unsigned int __a, unsigned int __b) {
1310}1360}
1311__DEVICE__ unsigned int __vsetne2(unsigned int __a, unsigned int __b) {1361__DEVICE__ unsigned int __vsetne2(unsigned int __a, unsigned int __b) {
1312 unsigned int r;1362 unsigned int r;
1313 asm("vset2.u32.u32.ne %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1363 __asm__("vset2.u32.u32.ne %0,%1,%2,%3;"
1364 : "=r"(r)
1365 : "r"(__a), "r"(__b), "r"(0));
1314 return r;1366 return r;
1315}1367}
1316__DEVICE__ unsigned int __vcmpne2(unsigned int __a, unsigned int __b) {1368__DEVICE__ unsigned int __vcmpne2(unsigned int __a, unsigned int __b) {
...@@ -1318,7 +1370,9 @@ __DEVICE__ unsigned int __vcmpne2(unsigned int __a, unsigned int __b) {...@@ -1318,7 +1370,9 @@ __DEVICE__ unsigned int __vcmpne2(unsigned int __a, unsigned int __b) {
1318}1370}
1319__DEVICE__ unsigned int __vsetne4(unsigned int __a, unsigned int __b) {1371__DEVICE__ unsigned int __vsetne4(unsigned int __a, unsigned int __b) {
1320 unsigned int r;1372 unsigned int r;
1321 asm("vset4.u32.u32.ne %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1373 __asm__("vset4.u32.u32.ne %0,%1,%2,%3;"
1374 : "=r"(r)
1375 : "r"(__a), "r"(__b), "r"(0));
1322 return r;1376 return r;
1323}1377}
1324__DEVICE__ unsigned int __vcmpne4(unsigned int __a, unsigned int __b) {1378__DEVICE__ unsigned int __vcmpne4(unsigned int __a, unsigned int __b) {
...@@ -1345,94 +1399,112 @@ __DEVICE__ unsigned int __vmaxs2(unsigned int __a, unsigned int __b) {...@@ -1345,94 +1399,112 @@ __DEVICE__ unsigned int __vmaxs2(unsigned int __a, unsigned int __b) {
1345 unsigned mask = __vcmpgts2(__a, __b);1399 unsigned mask = __vcmpgts2(__a, __b);
1346 r = (__a & mask) | (__b & ~mask);1400 r = (__a & mask) | (__b & ~mask);
1347 } else {1401 } else {
1348 asm("vmax2.s32.s32.s32 %0,%1,%2,%3;"1402 __asm__("vmax2.s32.s32.s32 %0,%1,%2,%3;"
1349 : "=r"(r)1403 : "=r"(r)
1350 : "r"(__a), "r"(__b), "r"(0));1404 : "r"(__a), "r"(__b), "r"(0));
1351 }1405 }
1352 return r;1406 return r;
1353}1407}
1354__DEVICE__ unsigned int __vmaxs4(unsigned int __a, unsigned int __b) {1408__DEVICE__ unsigned int __vmaxs4(unsigned int __a, unsigned int __b) {
1355 unsigned int r;1409 unsigned int r;
1356 asm("vmax4.s32.s32.s32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1410 __asm__("vmax4.s32.s32.s32 %0,%1,%2,%3;"
1411 : "=r"(r)
1412 : "r"(__a), "r"(__b), "r"(0));
1357 return r;1413 return r;
1358}1414}
1359__DEVICE__ unsigned int __vmaxu2(unsigned int __a, unsigned int __b) {1415__DEVICE__ unsigned int __vmaxu2(unsigned int __a, unsigned int __b) {
1360 unsigned int r;1416 unsigned int r;
1361 asm("vmax2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1417 __asm__("vmax2.u32.u32.u32 %0,%1,%2,%3;"
1418 : "=r"(r)
1419 : "r"(__a), "r"(__b), "r"(0));
1362 return r;1420 return r;
1363}1421}
1364__DEVICE__ unsigned int __vmaxu4(unsigned int __a, unsigned int __b) {1422__DEVICE__ unsigned int __vmaxu4(unsigned int __a, unsigned int __b) {
1365 unsigned int r;1423 unsigned int r;
1366 asm("vmax4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1424 __asm__("vmax4.u32.u32.u32 %0,%1,%2,%3;"
1425 : "=r"(r)
1426 : "r"(__a), "r"(__b), "r"(0));
1367 return r;1427 return r;
1368}1428}
1369__DEVICE__ unsigned int __vmins2(unsigned int __a, unsigned int __b) {1429__DEVICE__ unsigned int __vmins2(unsigned int __a, unsigned int __b) {
1370 unsigned int r;1430 unsigned int r;
1371 asm("vmin2.s32.s32.s32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1431 __asm__("vmin2.s32.s32.s32 %0,%1,%2,%3;"
1432 : "=r"(r)
1433 : "r"(__a), "r"(__b), "r"(0));
1372 return r;1434 return r;
1373}1435}
1374__DEVICE__ unsigned int __vmins4(unsigned int __a, unsigned int __b) {1436__DEVICE__ unsigned int __vmins4(unsigned int __a, unsigned int __b) {
1375 unsigned int r;1437 unsigned int r;
1376 asm("vmin4.s32.s32.s32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1438 __asm__("vmin4.s32.s32.s32 %0,%1,%2,%3;"
1439 : "=r"(r)
1440 : "r"(__a), "r"(__b), "r"(0));
1377 return r;1441 return r;
1378}1442}
1379__DEVICE__ unsigned int __vminu2(unsigned int __a, unsigned int __b) {1443__DEVICE__ unsigned int __vminu2(unsigned int __a, unsigned int __b) {
1380 unsigned int r;1444 unsigned int r;
1381 asm("vmin2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1445 __asm__("vmin2.u32.u32.u32 %0,%1,%2,%3;"
1446 : "=r"(r)
1447 : "r"(__a), "r"(__b), "r"(0));
1382 return r;1448 return r;
1383}1449}
1384__DEVICE__ unsigned int __vminu4(unsigned int __a, unsigned int __b) {1450__DEVICE__ unsigned int __vminu4(unsigned int __a, unsigned int __b) {
1385 unsigned int r;1451 unsigned int r;
1386 asm("vmin4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1452 __asm__("vmin4.u32.u32.u32 %0,%1,%2,%3;"
1453 : "=r"(r)
1454 : "r"(__a), "r"(__b), "r"(0));
1387 return r;1455 return r;
1388}1456}
1389__DEVICE__ unsigned int __vsads2(unsigned int __a, unsigned int __b) {1457__DEVICE__ unsigned int __vsads2(unsigned int __a, unsigned int __b) {
1390 unsigned int r;1458 unsigned int r;
1391 asm("vabsdiff2.s32.s32.s32.add %0,%1,%2,%3;"1459 __asm__("vabsdiff2.s32.s32.s32.add %0,%1,%2,%3;"
1392 : "=r"(r)1460 : "=r"(r)
1393 : "r"(__a), "r"(__b), "r"(0));1461 : "r"(__a), "r"(__b), "r"(0));
1394 return r;1462 return r;
1395}1463}
1396__DEVICE__ unsigned int __vsads4(unsigned int __a, unsigned int __b) {1464__DEVICE__ unsigned int __vsads4(unsigned int __a, unsigned int __b) {
1397 unsigned int r;1465 unsigned int r;
1398 asm("vabsdiff4.s32.s32.s32.add %0,%1,%2,%3;"1466 __asm__("vabsdiff4.s32.s32.s32.add %0,%1,%2,%3;"
1399 : "=r"(r)1467 : "=r"(r)
1400 : "r"(__a), "r"(__b), "r"(0));1468 : "r"(__a), "r"(__b), "r"(0));
1401 return r;1469 return r;
1402}1470}
1403__DEVICE__ unsigned int __vsadu2(unsigned int __a, unsigned int __b) {1471__DEVICE__ unsigned int __vsadu2(unsigned int __a, unsigned int __b) {
1404 unsigned int r;1472 unsigned int r;
1405 asm("vabsdiff2.u32.u32.u32.add %0,%1,%2,%3;"1473 __asm__("vabsdiff2.u32.u32.u32.add %0,%1,%2,%3;"
1406 : "=r"(r)1474 : "=r"(r)
1407 : "r"(__a), "r"(__b), "r"(0));1475 : "r"(__a), "r"(__b), "r"(0));
1408 return r;1476 return r;
1409}1477}
1410__DEVICE__ unsigned int __vsadu4(unsigned int __a, unsigned int __b) {1478__DEVICE__ unsigned int __vsadu4(unsigned int __a, unsigned int __b) {
1411 unsigned int r;1479 unsigned int r;
1412 asm("vabsdiff4.u32.u32.u32.add %0,%1,%2,%3;"1480 __asm__("vabsdiff4.u32.u32.u32.add %0,%1,%2,%3;"
1413 : "=r"(r)1481 : "=r"(r)
1414 : "r"(__a), "r"(__b), "r"(0));1482 : "r"(__a), "r"(__b), "r"(0));
1415 return r;1483 return r;
1416}1484}
14171485
1418__DEVICE__ unsigned int __vsub2(unsigned int __a, unsigned int __b) {1486__DEVICE__ unsigned int __vsub2(unsigned int __a, unsigned int __b) {
1419 unsigned int r;1487 unsigned int r;
1420 asm("vsub2.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1488 __asm__("vsub2.u32.u32.u32 %0,%1,%2,%3;"
1489 : "=r"(r)
1490 : "r"(__a), "r"(__b), "r"(0));
1421 return r;1491 return r;
1422}1492}
1423__DEVICE__ unsigned int __vneg2(unsigned int __a) { return __vsub2(0, __a); }1493__DEVICE__ unsigned int __vneg2(unsigned int __a) { return __vsub2(0, __a); }
14241494
1425__DEVICE__ unsigned int __vsub4(unsigned int __a, unsigned int __b) {1495__DEVICE__ unsigned int __vsub4(unsigned int __a, unsigned int __b) {
1426 unsigned int r;1496 unsigned int r;
1427 asm("vsub4.u32.u32.u32 %0,%1,%2,%3;" : "=r"(r) : "r"(__a), "r"(__b), "r"(0));1497 __asm__("vsub4.u32.u32.u32 %0,%1,%2,%3;"
1498 : "=r"(r)
1499 : "r"(__a), "r"(__b), "r"(0));
1428 return r;1500 return r;
1429}1501}
1430__DEVICE__ unsigned int __vneg4(unsigned int __a) { return __vsub4(0, __a); }1502__DEVICE__ unsigned int __vneg4(unsigned int __a) { return __vsub4(0, __a); }
1431__DEVICE__ unsigned int __vsubss2(unsigned int __a, unsigned int __b) {1503__DEVICE__ unsigned int __vsubss2(unsigned int __a, unsigned int __b) {
1432 unsigned int r;1504 unsigned int r;
1433 asm("vsub2.s32.s32.s32.sat %0,%1,%2,%3;"1505 __asm__("vsub2.s32.s32.s32.sat %0,%1,%2,%3;"
1434 : "=r"(r)1506 : "=r"(r)
1435 : "r"(__a), "r"(__b), "r"(0));1507 : "r"(__a), "r"(__b), "r"(0));
1436 return r;1508 return r;
1437}1509}
1438__DEVICE__ unsigned int __vnegss2(unsigned int __a) {1510__DEVICE__ unsigned int __vnegss2(unsigned int __a) {
...@@ -1440,9 +1512,9 @@ __DEVICE__ unsigned int __vnegss2(unsigned int __a) {...@@ -1440,9 +1512,9 @@ __DEVICE__ unsigned int __vnegss2(unsigned int __a) {
1440}1512}
1441__DEVICE__ unsigned int __vsubss4(unsigned int __a, unsigned int __b) {1513__DEVICE__ unsigned int __vsubss4(unsigned int __a, unsigned int __b) {
1442 unsigned int r;1514 unsigned int r;
1443 asm("vsub4.s32.s32.s32.sat %0,%1,%2,%3;"1515 __asm__("vsub4.s32.s32.s32.sat %0,%1,%2,%3;"
1444 : "=r"(r)1516 : "=r"(r)
1445 : "r"(__a), "r"(__b), "r"(0));1517 : "r"(__a), "r"(__b), "r"(0));
1446 return r;1518 return r;
1447}1519}
1448__DEVICE__ unsigned int __vnegss4(unsigned int __a) {1520__DEVICE__ unsigned int __vnegss4(unsigned int __a) {
...@@ -1450,16 +1522,16 @@ __DEVICE__ unsigned int __vnegss4(unsigned int __a) {...@@ -1450,16 +1522,16 @@ __DEVICE__ unsigned int __vnegss4(unsigned int __a) {
1450}1522}
1451__DEVICE__ unsigned int __vsubus2(unsigned int __a, unsigned int __b) {1523__DEVICE__ unsigned int __vsubus2(unsigned int __a, unsigned int __b) {
1452 unsigned int r;1524 unsigned int r;
1453 asm("vsub2.u32.u32.u32.sat %0,%1,%2,%3;"1525 __asm__("vsub2.u32.u32.u32.sat %0,%1,%2,%3;"
1454 : "=r"(r)1526 : "=r"(r)
1455 : "r"(__a), "r"(__b), "r"(0));1527 : "r"(__a), "r"(__b), "r"(0));
1456 return r;1528 return r;
1457}1529}
1458__DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) {1530__DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) {
1459 unsigned int r;1531 unsigned int r;
1460 asm("vsub4.u32.u32.u32.sat %0,%1,%2,%3;"1532 __asm__("vsub4.u32.u32.u32.sat %0,%1,%2,%3;"
1461 : "=r"(r)1533 : "=r"(r)
1462 : "r"(__a), "r"(__b), "r"(0));1534 : "r"(__a), "r"(__b), "r"(0));
1463 return r;1535 return r;
1464}1536}
1465#endif // CUDA_VERSION >= 90201537#endif // CUDA_VERSION >= 9020
lib/include/__clang_hip_cmath.h+110-78
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#ifndef __CLANG_HIP_CMATH_H__10#ifndef __CLANG_HIP_CMATH_H__
11#define __CLANG_HIP_CMATH_H__11#define __CLANG_HIP_CMATH_H__
1212
13#if !defined(__HIP__)13#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__)
14#error "This file is for HIP and OpenMP AMDGCN device compilation only."14#error "This file is for HIP and OpenMP AMDGCN device compilation only."
15#endif15#endif
1616
...@@ -25,31 +25,43 @@...@@ -25,31 +25,43 @@
25#endif // !defined(__HIPCC_RTC__)25#endif // !defined(__HIPCC_RTC__)
2626
27#pragma push_macro("__DEVICE__")27#pragma push_macro("__DEVICE__")
28#pragma push_macro("__CONSTEXPR__")
29#ifdef __OPENMP_AMDGCN__
30#define __DEVICE__ static __attribute__((always_inline, nothrow))
31#define __CONSTEXPR__ constexpr
32#else
28#define __DEVICE__ static __device__ inline __attribute__((always_inline))33#define __DEVICE__ static __device__ inline __attribute__((always_inline))
34#define __CONSTEXPR__
35#endif // __OPENMP_AMDGCN__
2936
30// Start with functions that cannot be defined by DEF macros below.37// Start with functions that cannot be defined by DEF macros below.
31#if defined(__cplusplus)38#if defined(__cplusplus)
32__DEVICE__ double abs(double __x) { return ::fabs(__x); }39#if defined __OPENMP_AMDGCN__
33__DEVICE__ float abs(float __x) { return ::fabsf(__x); }40__DEVICE__ __CONSTEXPR__ float fabs(float __x) { return ::fabsf(__x); }
34__DEVICE__ long long abs(long long __n) { return ::llabs(__n); }41__DEVICE__ __CONSTEXPR__ float sin(float __x) { return ::sinf(__x); }
35__DEVICE__ long abs(long __n) { return ::labs(__n); }42__DEVICE__ __CONSTEXPR__ float cos(float __x) { return ::cosf(__x); }
36__DEVICE__ float fma(float __x, float __y, float __z) {43#endif
44__DEVICE__ __CONSTEXPR__ double abs(double __x) { return ::fabs(__x); }
45__DEVICE__ __CONSTEXPR__ float abs(float __x) { return ::fabsf(__x); }
46__DEVICE__ __CONSTEXPR__ long long abs(long long __n) { return ::llabs(__n); }
47__DEVICE__ __CONSTEXPR__ long abs(long __n) { return ::labs(__n); }
48__DEVICE__ __CONSTEXPR__ float fma(float __x, float __y, float __z) {
37 return ::fmaf(__x, __y, __z);49 return ::fmaf(__x, __y, __z);
38}50}
39#if !defined(__HIPCC_RTC__)51#if !defined(__HIPCC_RTC__)
40// The value returned by fpclassify is platform dependent, therefore it is not52// The value returned by fpclassify is platform dependent, therefore it is not
41// supported by hipRTC.53// supported by hipRTC.
42__DEVICE__ int fpclassify(float __x) {54__DEVICE__ __CONSTEXPR__ int fpclassify(float __x) {
43 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,55 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
44 FP_ZERO, __x);56 FP_ZERO, __x);
45}57}
46__DEVICE__ int fpclassify(double __x) {58__DEVICE__ __CONSTEXPR__ int fpclassify(double __x) {
47 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,59 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
48 FP_ZERO, __x);60 FP_ZERO, __x);
49}61}
50#endif // !defined(__HIPCC_RTC__)62#endif // !defined(__HIPCC_RTC__)
5163
52__DEVICE__ float frexp(float __arg, int *__exp) {64__DEVICE__ __CONSTEXPR__ float frexp(float __arg, int *__exp) {
53 return ::frexpf(__arg, __exp);65 return ::frexpf(__arg, __exp);
54}66}
5567
...@@ -71,93 +83,101 @@ __DEVICE__ float frexp(float __arg, int *__exp) {...@@ -71,93 +83,101 @@ __DEVICE__ float frexp(float __arg, int *__exp) {
71// of the variants inside the inner region and avoid the clash.83// of the variants inside the inner region and avoid the clash.
72#pragma omp begin declare variant match(implementation = {vendor(llvm)})84#pragma omp begin declare variant match(implementation = {vendor(llvm)})
7385
74__DEVICE__ int isinf(float __x) { return ::__isinff(__x); }86__DEVICE__ __CONSTEXPR__ int isinf(float __x) { return ::__isinff(__x); }
75__DEVICE__ int isinf(double __x) { return ::__isinf(__x); }87__DEVICE__ __CONSTEXPR__ int isinf(double __x) { return ::__isinf(__x); }
76__DEVICE__ int isfinite(float __x) { return ::__finitef(__x); }88__DEVICE__ __CONSTEXPR__ int isfinite(float __x) { return ::__finitef(__x); }
77__DEVICE__ int isfinite(double __x) { return ::__finite(__x); }89__DEVICE__ __CONSTEXPR__ int isfinite(double __x) { return ::__finite(__x); }
78__DEVICE__ int isnan(float __x) { return ::__isnanf(__x); }90__DEVICE__ __CONSTEXPR__ int isnan(float __x) { return ::__isnanf(__x); }
79__DEVICE__ int isnan(double __x) { return ::__isnan(__x); }91__DEVICE__ __CONSTEXPR__ int isnan(double __x) { return ::__isnan(__x); }
8092
81#pragma omp end declare variant93#pragma omp end declare variant
82#endif // defined(__OPENMP_AMDGCN__)94#endif // defined(__OPENMP_AMDGCN__)
8395
84__DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }96__DEVICE__ __CONSTEXPR__ bool isinf(float __x) { return ::__isinff(__x); }
85__DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }97__DEVICE__ __CONSTEXPR__ bool isinf(double __x) { return ::__isinf(__x); }
86__DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }98__DEVICE__ __CONSTEXPR__ bool isfinite(float __x) { return ::__finitef(__x); }
87__DEVICE__ bool isfinite(double __x) { return ::__finite(__x); }99__DEVICE__ __CONSTEXPR__ bool isfinite(double __x) { return ::__finite(__x); }
88__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }100__DEVICE__ __CONSTEXPR__ bool isnan(float __x) { return ::__isnanf(__x); }
89__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }101__DEVICE__ __CONSTEXPR__ bool isnan(double __x) { return ::__isnan(__x); }
90102
91#if defined(__OPENMP_AMDGCN__)103#if defined(__OPENMP_AMDGCN__)
92#pragma omp end declare variant104#pragma omp end declare variant
93#endif // defined(__OPENMP_AMDGCN__)105#endif // defined(__OPENMP_AMDGCN__)
94106
95__DEVICE__ bool isgreater(float __x, float __y) {107__DEVICE__ __CONSTEXPR__ bool isgreater(float __x, float __y) {
96 return __builtin_isgreater(__x, __y);108 return __builtin_isgreater(__x, __y);
97}109}
98__DEVICE__ bool isgreater(double __x, double __y) {110__DEVICE__ __CONSTEXPR__ bool isgreater(double __x, double __y) {
99 return __builtin_isgreater(__x, __y);111 return __builtin_isgreater(__x, __y);
100}112}
101__DEVICE__ bool isgreaterequal(float __x, float __y) {113__DEVICE__ __CONSTEXPR__ bool isgreaterequal(float __x, float __y) {
102 return __builtin_isgreaterequal(__x, __y);114 return __builtin_isgreaterequal(__x, __y);
103}115}
104__DEVICE__ bool isgreaterequal(double __x, double __y) {116__DEVICE__ __CONSTEXPR__ bool isgreaterequal(double __x, double __y) {
105 return __builtin_isgreaterequal(__x, __y);117 return __builtin_isgreaterequal(__x, __y);
106}118}
107__DEVICE__ bool isless(float __x, float __y) {119__DEVICE__ __CONSTEXPR__ bool isless(float __x, float __y) {
108 return __builtin_isless(__x, __y);120 return __builtin_isless(__x, __y);
109}121}
110__DEVICE__ bool isless(double __x, double __y) {122__DEVICE__ __CONSTEXPR__ bool isless(double __x, double __y) {
111 return __builtin_isless(__x, __y);123 return __builtin_isless(__x, __y);
112}124}
113__DEVICE__ bool islessequal(float __x, float __y) {125__DEVICE__ __CONSTEXPR__ bool islessequal(float __x, float __y) {
114 return __builtin_islessequal(__x, __y);126 return __builtin_islessequal(__x, __y);
115}127}
116__DEVICE__ bool islessequal(double __x, double __y) {128__DEVICE__ __CONSTEXPR__ bool islessequal(double __x, double __y) {
117 return __builtin_islessequal(__x, __y);129 return __builtin_islessequal(__x, __y);
118}130}
119__DEVICE__ bool islessgreater(float __x, float __y) {131__DEVICE__ __CONSTEXPR__ bool islessgreater(float __x, float __y) {
120 return __builtin_islessgreater(__x, __y);132 return __builtin_islessgreater(__x, __y);
121}133}
122__DEVICE__ bool islessgreater(double __x, double __y) {134__DEVICE__ __CONSTEXPR__ bool islessgreater(double __x, double __y) {
123 return __builtin_islessgreater(__x, __y);135 return __builtin_islessgreater(__x, __y);
124}136}
125__DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }137__DEVICE__ __CONSTEXPR__ bool isnormal(float __x) {
126__DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }138 return __builtin_isnormal(__x);
127__DEVICE__ bool isunordered(float __x, float __y) {139}
140__DEVICE__ __CONSTEXPR__ bool isnormal(double __x) {
141 return __builtin_isnormal(__x);
142}
143__DEVICE__ __CONSTEXPR__ bool isunordered(float __x, float __y) {
128 return __builtin_isunordered(__x, __y);144 return __builtin_isunordered(__x, __y);
129}145}
130__DEVICE__ bool isunordered(double __x, double __y) {146__DEVICE__ __CONSTEXPR__ bool isunordered(double __x, double __y) {
131 return __builtin_isunordered(__x, __y);147 return __builtin_isunordered(__x, __y);
132}148}
133__DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); }149__DEVICE__ __CONSTEXPR__ float modf(float __x, float *__iptr) {
134__DEVICE__ float pow(float __base, int __iexp) {150 return ::modff(__x, __iptr);
151}
152__DEVICE__ __CONSTEXPR__ float pow(float __base, int __iexp) {
135 return ::powif(__base, __iexp);153 return ::powif(__base, __iexp);
136}154}
137__DEVICE__ double pow(double __base, int __iexp) {155__DEVICE__ __CONSTEXPR__ double pow(double __base, int __iexp) {
138 return ::powi(__base, __iexp);156 return ::powi(__base, __iexp);
139}157}
140__DEVICE__ float remquo(float __x, float __y, int *__quo) {158__DEVICE__ __CONSTEXPR__ float remquo(float __x, float __y, int *__quo) {
141 return ::remquof(__x, __y, __quo);159 return ::remquof(__x, __y, __quo);
142}160}
143__DEVICE__ float scalbln(float __x, long int __n) {161__DEVICE__ __CONSTEXPR__ float scalbln(float __x, long int __n) {
144 return ::scalblnf(__x, __n);162 return ::scalblnf(__x, __n);
145}163}
146__DEVICE__ bool signbit(float __x) { return ::__signbitf(__x); }164__DEVICE__ __CONSTEXPR__ bool signbit(float __x) { return ::__signbitf(__x); }
147__DEVICE__ bool signbit(double __x) { return ::__signbit(__x); }165__DEVICE__ __CONSTEXPR__ bool signbit(double __x) { return ::__signbit(__x); }
148166
149// Notably missing above is nexttoward. We omit it because167// Notably missing above is nexttoward. We omit it because
150// ocml doesn't provide an implementation, and we don't want to be in the168// ocml doesn't provide an implementation, and we don't want to be in the
151// business of implementing tricky libm functions in this header.169// business of implementing tricky libm functions in this header.
152170
153// Other functions.171// Other functions.
154__DEVICE__ _Float16 fma(_Float16 __x, _Float16 __y, _Float16 __z) {172__DEVICE__ __CONSTEXPR__ _Float16 fma(_Float16 __x, _Float16 __y,
173 _Float16 __z) {
155 return __ocml_fma_f16(__x, __y, __z);174 return __ocml_fma_f16(__x, __y, __z);
156}175}
157__DEVICE__ _Float16 pow(_Float16 __base, int __iexp) {176__DEVICE__ __CONSTEXPR__ _Float16 pow(_Float16 __base, int __iexp) {
158 return __ocml_pown_f16(__base, __iexp);177 return __ocml_pown_f16(__base, __iexp);
159}178}
160179
180#ifndef __OPENMP_AMDGCN__
161// BEGIN DEF_FUN and HIP_OVERLOAD181// BEGIN DEF_FUN and HIP_OVERLOAD
162182
163// BEGIN DEF_FUN183// BEGIN DEF_FUN
...@@ -168,18 +188,19 @@ __DEVICE__ _Float16 pow(_Float16 __base, int __iexp) {...@@ -168,18 +188,19 @@ __DEVICE__ _Float16 pow(_Float16 __base, int __iexp) {
168188
169// Define cmath functions with float argument and returns __retty.189// Define cmath functions with float argument and returns __retty.
170#define __DEF_FUN1(__retty, __func) \190#define __DEF_FUN1(__retty, __func) \
171 __DEVICE__ \191 __DEVICE__ __CONSTEXPR__ __retty __func(float __x) { return __func##f(__x); }
172 __retty __func(float __x) { return __func##f(__x); }
173192
174// Define cmath functions with two float arguments and returns __retty.193// Define cmath functions with two float arguments and returns __retty.
175#define __DEF_FUN2(__retty, __func) \194#define __DEF_FUN2(__retty, __func) \
176 __DEVICE__ \195 __DEVICE__ __CONSTEXPR__ __retty __func(float __x, float __y) { \
177 __retty __func(float __x, float __y) { return __func##f(__x, __y); }196 return __func##f(__x, __y); \
197 }
178198
179// Define cmath functions with a float and an int argument and returns __retty.199// Define cmath functions with a float and an int argument and returns __retty.
180#define __DEF_FUN2_FI(__retty, __func) \200#define __DEF_FUN2_FI(__retty, __func) \
181 __DEVICE__ \201 __DEVICE__ __CONSTEXPR__ __retty __func(float __x, int __y) { \
182 __retty __func(float __x, int __y) { return __func##f(__x, __y); }202 return __func##f(__x, __y); \
203 }
183204
184__DEF_FUN1(float, acos)205__DEF_FUN1(float, acos)
185__DEF_FUN1(float, acosh)206__DEF_FUN1(float, acosh)
...@@ -426,7 +447,7 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};...@@ -426,7 +447,7 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
426// floor(double).447// floor(double).
427#define __HIP_OVERLOAD1(__retty, __fn) \448#define __HIP_OVERLOAD1(__retty, __fn) \
428 template <typename __T> \449 template <typename __T> \
429 __DEVICE__ \450 __DEVICE__ __CONSTEXPR__ \
430 typename __hip_enable_if<__hip::is_integral<__T>::value, __retty>::type \451 typename __hip_enable_if<__hip::is_integral<__T>::value, __retty>::type \
431 __fn(__T __x) { \452 __fn(__T __x) { \
432 return ::__fn((double)__x); \453 return ::__fn((double)__x); \
...@@ -438,7 +459,7 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};...@@ -438,7 +459,7 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
438#if __cplusplus >= 201103L459#if __cplusplus >= 201103L
439#define __HIP_OVERLOAD2(__retty, __fn) \460#define __HIP_OVERLOAD2(__retty, __fn) \
440 template <typename __T1, typename __T2> \461 template <typename __T1, typename __T2> \
441 __DEVICE__ typename __hip_enable_if< \462 __DEVICE__ __CONSTEXPR__ typename __hip_enable_if< \
442 __hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value, \463 __hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value, \
443 typename __hip::__promote<__T1, __T2>::type>::type \464 typename __hip::__promote<__T1, __T2>::type>::type \
444 __fn(__T1 __x, __T2 __y) { \465 __fn(__T1 __x, __T2 __y) { \
...@@ -448,10 +469,11 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};...@@ -448,10 +469,11 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
448#else469#else
449#define __HIP_OVERLOAD2(__retty, __fn) \470#define __HIP_OVERLOAD2(__retty, __fn) \
450 template <typename __T1, typename __T2> \471 template <typename __T1, typename __T2> \
451 __DEVICE__ typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && \472 __DEVICE__ __CONSTEXPR__ \
452 __hip::is_arithmetic<__T2>::value, \473 typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && \
453 __retty>::type \474 __hip::is_arithmetic<__T2>::value, \
454 __fn(__T1 __x, __T2 __y) { \475 __retty>::type \
476 __fn(__T1 __x, __T2 __y) { \
455 return __fn((double)__x, (double)__y); \477 return __fn((double)__x, (double)__y); \
456 }478 }
457#endif479#endif
...@@ -526,7 +548,7 @@ __HIP_OVERLOAD2(double, min)...@@ -526,7 +548,7 @@ __HIP_OVERLOAD2(double, min)
526// Additional Overloads that don't quite match HIP_OVERLOAD.548// Additional Overloads that don't quite match HIP_OVERLOAD.
527#if __cplusplus >= 201103L549#if __cplusplus >= 201103L
528template <typename __T1, typename __T2, typename __T3>550template <typename __T1, typename __T2, typename __T3>
529__DEVICE__ typename __hip_enable_if<551__DEVICE__ __CONSTEXPR__ typename __hip_enable_if<
530 __hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value &&552 __hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value &&
531 __hip::is_arithmetic<__T3>::value,553 __hip::is_arithmetic<__T3>::value,
532 typename __hip::__promote<__T1, __T2, __T3>::type>::type554 typename __hip::__promote<__T1, __T2, __T3>::type>::type
...@@ -536,31 +558,32 @@ fma(__T1 __x, __T2 __y, __T3 __z) {...@@ -536,31 +558,32 @@ fma(__T1 __x, __T2 __y, __T3 __z) {
536}558}
537#else559#else
538template <typename __T1, typename __T2, typename __T3>560template <typename __T1, typename __T2, typename __T3>
539__DEVICE__ typename __hip_enable_if<__hip::is_arithmetic<__T1>::value &&561__DEVICE__ __CONSTEXPR__
540 __hip::is_arithmetic<__T2>::value &&562 typename __hip_enable_if<__hip::is_arithmetic<__T1>::value &&
541 __hip::is_arithmetic<__T3>::value,563 __hip::is_arithmetic<__T2>::value &&
542 double>::type564 __hip::is_arithmetic<__T3>::value,
543fma(__T1 __x, __T2 __y, __T3 __z) {565 double>::type
566 fma(__T1 __x, __T2 __y, __T3 __z) {
544 return ::fma((double)__x, (double)__y, (double)__z);567 return ::fma((double)__x, (double)__y, (double)__z);
545}568}
546#endif569#endif
547570
548template <typename __T>571template <typename __T>
549__DEVICE__572__DEVICE__ __CONSTEXPR__
550 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type573 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type
551 frexp(__T __x, int *__exp) {574 frexp(__T __x, int *__exp) {
552 return ::frexp((double)__x, __exp);575 return ::frexp((double)__x, __exp);
553}576}
554577
555template <typename __T>578template <typename __T>
556__DEVICE__579__DEVICE__ __CONSTEXPR__
557 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type580 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type
558 ldexp(__T __x, int __exp) {581 ldexp(__T __x, int __exp) {
559 return ::ldexp((double)__x, __exp);582 return ::ldexp((double)__x, __exp);
560}583}
561584
562template <typename __T>585template <typename __T>
563__DEVICE__586__DEVICE__ __CONSTEXPR__
564 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type587 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type
565 modf(__T __x, double *__exp) {588 modf(__T __x, double *__exp) {
566 return ::modf((double)__x, __exp);589 return ::modf((double)__x, __exp);
...@@ -568,7 +591,7 @@ __DEVICE__...@@ -568,7 +591,7 @@ __DEVICE__
568591
569#if __cplusplus >= 201103L592#if __cplusplus >= 201103L
570template <typename __T1, typename __T2>593template <typename __T1, typename __T2>
571__DEVICE__594__DEVICE__ __CONSTEXPR__
572 typename __hip_enable_if<__hip::is_arithmetic<__T1>::value &&595 typename __hip_enable_if<__hip::is_arithmetic<__T1>::value &&
573 __hip::is_arithmetic<__T2>::value,596 __hip::is_arithmetic<__T2>::value,
574 typename __hip::__promote<__T1, __T2>::type>::type597 typename __hip::__promote<__T1, __T2>::type>::type
...@@ -578,23 +601,24 @@ __DEVICE__...@@ -578,23 +601,24 @@ __DEVICE__
578}601}
579#else602#else
580template <typename __T1, typename __T2>603template <typename __T1, typename __T2>
581__DEVICE__ typename __hip_enable_if<__hip::is_arithmetic<__T1>::value &&604__DEVICE__ __CONSTEXPR__
582 __hip::is_arithmetic<__T2>::value,605 typename __hip_enable_if<__hip::is_arithmetic<__T1>::value &&
583 double>::type606 __hip::is_arithmetic<__T2>::value,
584remquo(__T1 __x, __T2 __y, int *__quo) {607 double>::type
608 remquo(__T1 __x, __T2 __y, int *__quo) {
585 return ::remquo((double)__x, (double)__y, __quo);609 return ::remquo((double)__x, (double)__y, __quo);
586}610}
587#endif611#endif
588612
589template <typename __T>613template <typename __T>
590__DEVICE__614__DEVICE__ __CONSTEXPR__
591 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type615 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type
592 scalbln(__T __x, long int __exp) {616 scalbln(__T __x, long int __exp) {
593 return ::scalbln((double)__x, __exp);617 return ::scalbln((double)__x, __exp);
594}618}
595619
596template <typename __T>620template <typename __T>
597__DEVICE__621__DEVICE__ __CONSTEXPR__
598 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type622 typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type
599 scalbn(__T __x, int __exp) {623 scalbn(__T __x, int __exp) {
600 return ::scalbn((double)__x, __exp);624 return ::scalbn((double)__x, __exp);
...@@ -607,8 +631,10 @@ __DEVICE__...@@ -607,8 +631,10 @@ __DEVICE__
607631
608// END DEF_FUN and HIP_OVERLOAD632// END DEF_FUN and HIP_OVERLOAD
609633
634#endif // ifndef __OPENMP_AMDGCN__
610#endif // defined(__cplusplus)635#endif // defined(__cplusplus)
611636
637#ifndef __OPENMP_AMDGCN__
612// Define these overloads inside the namespace our standard library uses.638// Define these overloads inside the namespace our standard library uses.
613#if !defined(__HIPCC_RTC__)639#if !defined(__HIPCC_RTC__)
614#ifdef _LIBCPP_BEGIN_NAMESPACE_STD640#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
...@@ -781,22 +807,26 @@ _GLIBCXX_END_NAMESPACE_VERSION...@@ -781,22 +807,26 @@ _GLIBCXX_END_NAMESPACE_VERSION
781#if defined(__cplusplus)807#if defined(__cplusplus)
782extern "C" {808extern "C" {
783#endif // defined(__cplusplus)809#endif // defined(__cplusplus)
784__DEVICE__ __attribute__((overloadable)) double _Cosh(double x, double y) {810__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) double _Cosh(double x,
811 double y) {
785 return cosh(x) * y;812 return cosh(x) * y;
786}813}
787__DEVICE__ __attribute__((overloadable)) float _FCosh(float x, float y) {814__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) float _FCosh(float x,
815 float y) {
788 return coshf(x) * y;816 return coshf(x) * y;
789}817}
790__DEVICE__ __attribute__((overloadable)) short _Dtest(double *p) {818__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) short _Dtest(double *p) {
791 return fpclassify(*p);819 return fpclassify(*p);
792}820}
793__DEVICE__ __attribute__((overloadable)) short _FDtest(float *p) {821__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) short _FDtest(float *p) {
794 return fpclassify(*p);822 return fpclassify(*p);
795}823}
796__DEVICE__ __attribute__((overloadable)) double _Sinh(double x, double y) {824__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) double _Sinh(double x,
825 double y) {
797 return sinh(x) * y;826 return sinh(x) * y;
798}827}
799__DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {828__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) float _FSinh(float x,
829 float y) {
800 return sinhf(x) * y;830 return sinhf(x) * y;
801}831}
802#if defined(__cplusplus)832#if defined(__cplusplus)
...@@ -804,7 +834,9 @@ __DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {...@@ -804,7 +834,9 @@ __DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) {
804#endif // defined(__cplusplus)834#endif // defined(__cplusplus)
805#endif // defined(_MSC_VER)835#endif // defined(_MSC_VER)
806#endif // !defined(__HIPCC_RTC__)836#endif // !defined(__HIPCC_RTC__)
837#endif // ifndef __OPENMP_AMDGCN__
807838
808#pragma pop_macro("__DEVICE__")839#pragma pop_macro("__DEVICE__")
840#pragma pop_macro("__CONSTEXPR__")
809841
810#endif // __CLANG_HIP_CMATH_H__842#endif // __CLANG_HIP_CMATH_H__
lib/include/__clang_hip_math.h+46-4
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#ifndef __CLANG_HIP_MATH_H__9#ifndef __CLANG_HIP_MATH_H__
10#define __CLANG_HIP_MATH_H__10#define __CLANG_HIP_MATH_H__
1111
12#if !defined(__HIP__)12#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__)
13#error "This file is for HIP and OpenMP AMDGCN device compilation only."13#error "This file is for HIP and OpenMP AMDGCN device compilation only."
14#endif14#endif
1515
...@@ -19,18 +19,30 @@...@@ -19,18 +19,30 @@
19#endif19#endif
20#include <limits.h>20#include <limits.h>
21#include <stdint.h>21#include <stdint.h>
22#endif // __HIPCC_RTC__22#ifdef __OPENMP_AMDGCN__
23#include <omp.h>
24#endif
25#endif // !defined(__HIPCC_RTC__)
2326
24#pragma push_macro("__DEVICE__")27#pragma push_macro("__DEVICE__")
28
29#ifdef __OPENMP_AMDGCN__
30#define __DEVICE__ static inline __attribute__((always_inline, nothrow))
31#else
25#define __DEVICE__ static __device__ inline __attribute__((always_inline))32#define __DEVICE__ static __device__ inline __attribute__((always_inline))
33#endif
2634
27// A few functions return bool type starting only in C++11.35// A few functions return bool type starting only in C++11.
28#pragma push_macro("__RETURN_TYPE")36#pragma push_macro("__RETURN_TYPE")
37#ifdef __OPENMP_AMDGCN__
38#define __RETURN_TYPE int
39#else
29#if defined(__cplusplus)40#if defined(__cplusplus)
30#define __RETURN_TYPE bool41#define __RETURN_TYPE bool
31#else42#else
32#define __RETURN_TYPE int43#define __RETURN_TYPE int
33#endif44#endif
45#endif // __OPENMP_AMDGCN__
3446
35#if defined (__cplusplus) && __cplusplus < 201103L47#if defined (__cplusplus) && __cplusplus < 201103L
36// emulate static_assert on type sizes48// emulate static_assert on type sizes
...@@ -249,6 +261,9 @@ float fmodf(float __x, float __y) { return __ocml_fmod_f32(__x, __y); }...@@ -249,6 +261,9 @@ float fmodf(float __x, float __y) { return __ocml_fmod_f32(__x, __y); }
249__DEVICE__261__DEVICE__
250float frexpf(float __x, int *__nptr) {262float frexpf(float __x, int *__nptr) {
251 int __tmp;263 int __tmp;
264#ifdef __OPENMP_AMDGCN__
265#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
266#endif
252 float __r =267 float __r =
253 __ocml_frexp_f32(__x, (__attribute__((address_space(5))) int *)&__tmp);268 __ocml_frexp_f32(__x, (__attribute__((address_space(5))) int *)&__tmp);
254 *__nptr = __tmp;269 *__nptr = __tmp;
...@@ -334,6 +349,9 @@ long int lroundf(float __x) { return __ocml_round_f32(__x); }...@@ -334,6 +349,9 @@ long int lroundf(float __x) { return __ocml_round_f32(__x); }
334__DEVICE__349__DEVICE__
335float modff(float __x, float *__iptr) {350float modff(float __x, float *__iptr) {
336 float __tmp;351 float __tmp;
352#ifdef __OPENMP_AMDGCN__
353#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
354#endif
337 float __r =355 float __r =
338 __ocml_modf_f32(__x, (__attribute__((address_space(5))) float *)&__tmp);356 __ocml_modf_f32(__x, (__attribute__((address_space(5))) float *)&__tmp);
339 *__iptr = __tmp;357 *__iptr = __tmp;
...@@ -414,6 +432,9 @@ float remainderf(float __x, float __y) {...@@ -414,6 +432,9 @@ float remainderf(float __x, float __y) {
414__DEVICE__432__DEVICE__
415float remquof(float __x, float __y, int *__quo) {433float remquof(float __x, float __y, int *__quo) {
416 int __tmp;434 int __tmp;
435#ifdef __OPENMP_AMDGCN__
436#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
437#endif
417 float __r = __ocml_remquo_f32(438 float __r = __ocml_remquo_f32(
418 __x, __y, (__attribute__((address_space(5))) int *)&__tmp);439 __x, __y, (__attribute__((address_space(5))) int *)&__tmp);
419 *__quo = __tmp;440 *__quo = __tmp;
...@@ -470,6 +491,9 @@ __RETURN_TYPE __signbitf(float __x) { return __ocml_signbit_f32(__x); }...@@ -470,6 +491,9 @@ __RETURN_TYPE __signbitf(float __x) { return __ocml_signbit_f32(__x); }
470__DEVICE__491__DEVICE__
471void sincosf(float __x, float *__sinptr, float *__cosptr) {492void sincosf(float __x, float *__sinptr, float *__cosptr) {
472 float __tmp;493 float __tmp;
494#ifdef __OPENMP_AMDGCN__
495#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
496#endif
473 *__sinptr =497 *__sinptr =
474 __ocml_sincos_f32(__x, (__attribute__((address_space(5))) float *)&__tmp);498 __ocml_sincos_f32(__x, (__attribute__((address_space(5))) float *)&__tmp);
475 *__cosptr = __tmp;499 *__cosptr = __tmp;
...@@ -478,6 +502,9 @@ void sincosf(float __x, float *__sinptr, float *__cosptr) {...@@ -478,6 +502,9 @@ void sincosf(float __x, float *__sinptr, float *__cosptr) {
478__DEVICE__502__DEVICE__
479void sincospif(float __x, float *__sinptr, float *__cosptr) {503void sincospif(float __x, float *__sinptr, float *__cosptr) {
480 float __tmp;504 float __tmp;
505#ifdef __OPENMP_AMDGCN__
506#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
507#endif
481 *__sinptr = __ocml_sincospi_f32(508 *__sinptr = __ocml_sincospi_f32(
482 __x, (__attribute__((address_space(5))) float *)&__tmp);509 __x, (__attribute__((address_space(5))) float *)&__tmp);
483 *__cosptr = __tmp;510 *__cosptr = __tmp;
...@@ -790,6 +817,9 @@ double fmod(double __x, double __y) { return __ocml_fmod_f64(__x, __y); }...@@ -790,6 +817,9 @@ double fmod(double __x, double __y) { return __ocml_fmod_f64(__x, __y); }
790__DEVICE__817__DEVICE__
791double frexp(double __x, int *__nptr) {818double frexp(double __x, int *__nptr) {
792 int __tmp;819 int __tmp;
820#ifdef __OPENMP_AMDGCN__
821#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
822#endif
793 double __r =823 double __r =
794 __ocml_frexp_f64(__x, (__attribute__((address_space(5))) int *)&__tmp);824 __ocml_frexp_f64(__x, (__attribute__((address_space(5))) int *)&__tmp);
795 *__nptr = __tmp;825 *__nptr = __tmp;
...@@ -874,6 +904,9 @@ long int lround(double __x) { return __ocml_round_f64(__x); }...@@ -874,6 +904,9 @@ long int lround(double __x) { return __ocml_round_f64(__x); }
874__DEVICE__904__DEVICE__
875double modf(double __x, double *__iptr) {905double modf(double __x, double *__iptr) {
876 double __tmp;906 double __tmp;
907#ifdef __OPENMP_AMDGCN__
908#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
909#endif
877 double __r =910 double __r =
878 __ocml_modf_f64(__x, (__attribute__((address_space(5))) double *)&__tmp);911 __ocml_modf_f64(__x, (__attribute__((address_space(5))) double *)&__tmp);
879 *__iptr = __tmp;912 *__iptr = __tmp;
...@@ -962,6 +995,9 @@ double remainder(double __x, double __y) {...@@ -962,6 +995,9 @@ double remainder(double __x, double __y) {
962__DEVICE__995__DEVICE__
963double remquo(double __x, double __y, int *__quo) {996double remquo(double __x, double __y, int *__quo) {
964 int __tmp;997 int __tmp;
998#ifdef __OPENMP_AMDGCN__
999#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
1000#endif
965 double __r = __ocml_remquo_f64(1001 double __r = __ocml_remquo_f64(
966 __x, __y, (__attribute__((address_space(5))) int *)&__tmp);1002 __x, __y, (__attribute__((address_space(5))) int *)&__tmp);
967 *__quo = __tmp;1003 *__quo = __tmp;
...@@ -1020,6 +1056,9 @@ double sin(double __x) { return __ocml_sin_f64(__x); }...@@ -1020,6 +1056,9 @@ double sin(double __x) { return __ocml_sin_f64(__x); }
1020__DEVICE__1056__DEVICE__
1021void sincos(double __x, double *__sinptr, double *__cosptr) {1057void sincos(double __x, double *__sinptr, double *__cosptr) {
1022 double __tmp;1058 double __tmp;
1059#ifdef __OPENMP_AMDGCN__
1060#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
1061#endif
1023 *__sinptr = __ocml_sincos_f64(1062 *__sinptr = __ocml_sincos_f64(
1024 __x, (__attribute__((address_space(5))) double *)&__tmp);1063 __x, (__attribute__((address_space(5))) double *)&__tmp);
1025 *__cosptr = __tmp;1064 *__cosptr = __tmp;
...@@ -1028,6 +1067,9 @@ void sincos(double __x, double *__sinptr, double *__cosptr) {...@@ -1028,6 +1067,9 @@ void sincos(double __x, double *__sinptr, double *__cosptr) {
1028__DEVICE__1067__DEVICE__
1029void sincospi(double __x, double *__sinptr, double *__cosptr) {1068void sincospi(double __x, double *__sinptr, double *__cosptr) {
1030 double __tmp;1069 double __tmp;
1070#ifdef __OPENMP_AMDGCN__
1071#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc)
1072#endif
1031 *__sinptr = __ocml_sincospi_f64(1073 *__sinptr = __ocml_sincospi_f64(
1032 __x, (__attribute__((address_space(5))) double *)&__tmp);1074 __x, (__attribute__((address_space(5))) double *)&__tmp);
1033 *__cosptr = __tmp;1075 *__cosptr = __tmp;
...@@ -1262,7 +1304,7 @@ float min(float __x, float __y) { return fminf(__x, __y); }...@@ -1262,7 +1304,7 @@ float min(float __x, float __y) { return fminf(__x, __y); }
1262__DEVICE__1304__DEVICE__
1263double min(double __x, double __y) { return fmin(__x, __y); }1305double min(double __x, double __y) { return fmin(__x, __y); }
12641306
1265#if !defined(__HIPCC_RTC__)1307#if !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
1266__host__ inline static int min(int __arg1, int __arg2) {1308__host__ inline static int min(int __arg1, int __arg2) {
1267 return std::min(__arg1, __arg2);1309 return std::min(__arg1, __arg2);
1268}1310}
...@@ -1270,7 +1312,7 @@ __host__ inline static int min(int __arg1, int __arg2) {...@@ -1270,7 +1312,7 @@ __host__ inline static int min(int __arg1, int __arg2) {
1270__host__ inline static int max(int __arg1, int __arg2) {1312__host__ inline static int max(int __arg1, int __arg2) {
1271 return std::max(__arg1, __arg2);1313 return std::max(__arg1, __arg2);
1272}1314}
1273#endif // __HIPCC_RTC__1315#endif // !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__)
1274#endif1316#endif
12751317
1276#pragma pop_macro("__DEVICE__")1318#pragma pop_macro("__DEVICE__")
lib/include/intrin.h+3
...@@ -574,6 +574,9 @@ void _WriteStatusReg(int, __int64);...@@ -574,6 +574,9 @@ void _WriteStatusReg(int, __int64);
574unsigned short __cdecl _byteswap_ushort(unsigned short val);574unsigned short __cdecl _byteswap_ushort(unsigned short val);
575unsigned long __cdecl _byteswap_ulong (unsigned long val);575unsigned long __cdecl _byteswap_ulong (unsigned long val);
576unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val);576unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val);
577
578__int64 __mulh(__int64 __a, __int64 __b);
579unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
577#endif580#endif
578581
579/*----------------------------------------------------------------------------*\582/*----------------------------------------------------------------------------*\
lib/include/openmp_wrappers/__clang_openmp_device_functions.h+27-5
...@@ -14,13 +14,13 @@...@@ -14,13 +14,13 @@
14#error "This file is for OpenMP compilation only."14#error "This file is for OpenMP compilation only."
15#endif15#endif
1616
17#pragma omp begin declare variant match( \
18 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
19
20#ifdef __cplusplus17#ifdef __cplusplus
21extern "C" {18extern "C" {
22#endif19#endif
2320
21#pragma omp begin declare variant match( \
22 device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)})
23
24#define __CUDA__24#define __CUDA__
25#define __OPENMP_NVPTX__25#define __OPENMP_NVPTX__
2626
...@@ -33,11 +33,33 @@ extern "C" {...@@ -33,11 +33,33 @@ extern "C" {
33#undef __OPENMP_NVPTX__33#undef __OPENMP_NVPTX__
34#undef __CUDA__34#undef __CUDA__
3535
36#ifdef __cplusplus36#pragma omp end declare variant
37} // extern "C"37
38#ifdef __AMDGCN__
39#pragma omp begin declare variant match(device = {arch(amdgcn)})
40
41// Import types which will be used by __clang_hip_libdevice_declares.h
42#ifndef __cplusplus
43#include <stdbool.h>
44#include <stdint.h>
38#endif45#endif
3946
47#define __OPENMP_AMDGCN__
48#pragma push_macro("__device__")
49#define __device__
50
51/// Include declarations for libdevice functions.
52#include <__clang_hip_libdevice_declares.h>
53
54#pragma pop_macro("__device__")
55#undef __OPENMP_AMDGCN__
56
40#pragma omp end declare variant57#pragma omp end declare variant
58#endif
59
60#ifdef __cplusplus
61} // extern "C"
62#endif
4163
42// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the64// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the
43// need to `include <new>` in C++ mode.65// need to `include <new>` in C++ mode.
lib/include/openmp_wrappers/cmath+54
...@@ -75,4 +75,58 @@ __DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }...@@ -75,4 +75,58 @@ __DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
7575
76#pragma omp end declare variant76#pragma omp end declare variant
7777
78#ifdef __AMDGCN__
79#pragma omp begin declare variant match(device = {arch(amdgcn)})
80
81#pragma push_macro("__constant__")
82#define __constant__ __attribute__((constant))
83#define __OPENMP_AMDGCN__
84
85#include <__clang_hip_cmath.h>
86
87#pragma pop_macro("__constant__")
88#undef __OPENMP_AMDGCN__
89
90// Define overloads otherwise which are absent
91#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
92
93__DEVICE__ float acos(float __x) { return ::acosf(__x); }
94__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
95__DEVICE__ float asin(float __x) { return ::asinf(__x); }
96__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
97__DEVICE__ float atan(float __x) { return ::atanf(__x); }
98__DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); }
99__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
100__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
101__DEVICE__ float cosh(float __x) { return ::coshf(__x); }
102__DEVICE__ float erf(float __x) { return ::erff(__x); }
103__DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
104__DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
105__DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
106__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
107__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
108__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
109__DEVICE__ float ldexp(float __arg, int __exp) {
110 return ::ldexpf(__arg, __exp);
111}
112__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
113__DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
114__DEVICE__ float logb(float __x) { return ::logbf(__x); }
115__DEVICE__ float nextafter(float __x, float __y) {
116 return ::nextafterf(__x, __y);
117}
118__DEVICE__ float remainder(float __x, float __y) {
119 return ::remainderf(__x, __y);
120}
121__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
122__DEVICE__ float sinh(float __x) { return ::sinhf(__x); }
123__DEVICE__ float tan(float __x) { return ::tanf(__x); }
124__DEVICE__ float tanh(float __x) { return ::tanhf(__x); }
125__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
126
127#undef __DEVICE__
128
129#pragma omp end declare variant
130#endif // __AMDGCN__
131
78#endif132#endif
lib/include/openmp_wrappers/math.h+10
...@@ -48,4 +48,14 @@...@@ -48,4 +48,14 @@
4848
49#pragma omp end declare variant49#pragma omp end declare variant
5050
51#ifdef __AMDGCN__
52#pragma omp begin declare variant match(device = {arch(amdgcn)})
53
54#define __OPENMP_AMDGCN__
55#include <__clang_hip_math.h>
56#undef __OPENMP_AMDGCN__
57
58#pragma omp end declare variant
59#endif
60
51#endif61#endif
lib/libcxx/include/cwctype+2
...@@ -59,6 +59,7 @@ wctrans_t wctrans(const char* property);...@@ -59,6 +59,7 @@ wctrans_t wctrans(const char* property);
5959
60_LIBCPP_BEGIN_NAMESPACE_STD60_LIBCPP_BEGIN_NAMESPACE_STD
6161
62#if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)
62using ::wint_t _LIBCPP_USING_IF_EXISTS;63using ::wint_t _LIBCPP_USING_IF_EXISTS;
63using ::wctrans_t _LIBCPP_USING_IF_EXISTS;64using ::wctrans_t _LIBCPP_USING_IF_EXISTS;
64using ::wctype_t _LIBCPP_USING_IF_EXISTS;65using ::wctype_t _LIBCPP_USING_IF_EXISTS;
...@@ -80,6 +81,7 @@ using ::towlower _LIBCPP_USING_IF_EXISTS;...@@ -80,6 +81,7 @@ using ::towlower _LIBCPP_USING_IF_EXISTS;
80using ::towupper _LIBCPP_USING_IF_EXISTS;81using ::towupper _LIBCPP_USING_IF_EXISTS;
81using ::towctrans _LIBCPP_USING_IF_EXISTS;82using ::towctrans _LIBCPP_USING_IF_EXISTS;
82using ::wctrans _LIBCPP_USING_IF_EXISTS;83using ::wctrans _LIBCPP_USING_IF_EXISTS;
84#endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
8385
84_LIBCPP_END_NAMESPACE_STD86_LIBCPP_END_NAMESPACE_STD
8587
lib/libcxx/include/string+19
...@@ -522,6 +522,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1...@@ -522,6 +522,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
522#include <algorithm>522#include <algorithm>
523#include <compare>523#include <compare>
524#include <cstdio> // EOF524#include <cstdio> // EOF
525#include <cstdlib>
525#include <cstring>526#include <cstring>
526#include <cwchar>527#include <cwchar>
527#include <initializer_list>528#include <initializer_list>
...@@ -1714,6 +1715,24 @@ private:...@@ -1714,6 +1715,24 @@ private:
1714 return data() <= __p && __p <= data() + size();1715 return data() <= __p && __p <= data() + size();
1715 }1716 }
17161717
1718 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
1719 void __throw_length_error() const {
1720#ifndef _LIBCPP_NO_EXCEPTIONS
1721 __basic_string_common<true>::__throw_length_error();
1722#else
1723 _VSTD::abort();
1724#endif
1725 }
1726
1727 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
1728 void __throw_out_of_range() const {
1729#ifndef _LIBCPP_NO_EXCEPTIONS
1730 __basic_string_common<true>::__throw_out_of_range();
1731#else
1732 _VSTD::abort();
1733#endif
1734 }
1735
1717 friend basic_string operator+<>(const basic_string&, const basic_string&);1736 friend basic_string operator+<>(const basic_string&, const basic_string&);
1718 friend basic_string operator+<>(const value_type*, const basic_string&);1737 friend basic_string operator+<>(const value_type*, const basic_string&);
1719 friend basic_string operator+<>(value_type, const basic_string&);1738 friend basic_string operator+<>(value_type, const basic_string&);
lib/libcxx/include/vector+20
...@@ -281,6 +281,7 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20...@@ -281,6 +281,7 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
281#include <algorithm>281#include <algorithm>
282#include <climits>282#include <climits>
283#include <compare>283#include <compare>
284#include <cstdlib>
284#include <cstring>285#include <cstring>
285#include <initializer_list>286#include <initializer_list>
286#include <iosfwd> // for forward declaration of vector287#include <iosfwd> // for forward declaration of vector
...@@ -390,6 +391,25 @@ protected:...@@ -390,6 +391,25 @@ protected:
390 is_nothrow_move_assignable<allocator_type>::value)391 is_nothrow_move_assignable<allocator_type>::value)
391 {__move_assign_alloc(__c, integral_constant<bool,392 {__move_assign_alloc(__c, integral_constant<bool,
392 __alloc_traits::propagate_on_container_move_assignment::value>());}393 __alloc_traits::propagate_on_container_move_assignment::value>());}
394
395 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
396 void __throw_length_error() const {
397#ifndef _LIBCPP_NO_EXCEPTIONS
398 __vector_base_common<true>::__throw_length_error();
399#else
400 _VSTD::abort();
401#endif
402 }
403
404 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
405 void __throw_out_of_range() const {
406#ifndef _LIBCPP_NO_EXCEPTIONS
407 __vector_base_common<true>::__throw_out_of_range();
408#else
409 _VSTD::abort();
410#endif
411 }
412
393private:413private:
394 _LIBCPP_INLINE_VISIBILITY414 _LIBCPP_INLINE_VISIBILITY
395 void __copy_assign_alloc(const __vector_base& __c, true_type)415 void __copy_assign_alloc(const __vector_base& __c, true_type)
lib/libcxx/include/wctype.h+10
...@@ -50,8 +50,18 @@ wctrans_t wctrans(const char* property);...@@ -50,8 +50,18 @@ wctrans_t wctrans(const char* property);
50#pragma GCC system_header50#pragma GCC system_header
51#endif51#endif
5252
53// TODO:
54// In the future, we should unconditionally include_next <wctype.h> here and instead
55// have a mode under which the library does not need libc++'s <wctype.h> or <cwctype>
56// at all (i.e. a mode without wchar_t). As it stands, we need to do that to completely
57// bypass the using declarations in <cwctype> when we did not include <wctype.h>.
58// Otherwise, a using declaration like `using ::wint_t` in <cwctype> will refer to
59// nothing (with using_if_exists), and if we include another header that defines one
60// of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists
61// will fail because it does not refer to the same declaration.
53#if __has_include_next(<wctype.h>)62#if __has_include_next(<wctype.h>)
54# include_next <wctype.h>63# include_next <wctype.h>
64# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
55#endif65#endif
5666
57#ifdef __cplusplus67#ifdef __cplusplus
lib/libcxxabi/src/cxa_personality.cpp+1-1
...@@ -702,10 +702,10 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,...@@ -702,10 +702,10 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
702 return;702 return;
703 }703 }
704 landingPad = (uintptr_t)lpStart + landingPad;704 landingPad = (uintptr_t)lpStart + landingPad;
705 results.landingPad = landingPad;
706#else // __USING_SJLJ_EXCEPTIONS__705#else // __USING_SJLJ_EXCEPTIONS__
707 ++landingPad;706 ++landingPad;
708#endif // __USING_SJLJ_EXCEPTIONS__707#endif // __USING_SJLJ_EXCEPTIONS__
708 results.landingPad = landingPad;
709 if (actionEntry == 0)709 if (actionEntry == 0)
710 {710 {
711 // Found a cleanup711 // Found a cleanup