authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-02-21 15:05:41-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-02-21 15:46:34-05:00
log248fb40dcc5eb50cf19e711197c5d1b210abf1b3
tree1ab5f7d2749f8a884d0d067d95faf17818d60c22
parent434c6f42cad5aef9112b576c685521a9763bef9b

CBE: fix windows test failures


4 files changed, 129 insertions(+), 102 deletions(-)

lib/zig.h+68-63
......@@ -316,7 +316,7 @@ zig_extern void *memset (void *, int, size_t);
316316
317317/* ===================== 8/16/32/64-bit Integer Support ===================== */
318318
319#if __STDC_VERSION__ >= 199901L
319#if __STDC_VERSION__ >= 199901L || _MSC_VER
320320#include <stdint.h>
321321#else
322322
......@@ -1923,6 +1923,7 @@ typedef double zig_f16;
19231923#define zig_make_f16(fp, repr) fp
19241924#elif LDBL_MANT_DIG == 11
19251925#define zig_bitSizeOf_c_longdouble 16
1926typedef uint16_t zig_repr_c_longdouble;
19261927typedef long double zig_f16;
19271928#define zig_make_f16(fp, repr) fp##l
19281929#elif FLT16_MANT_DIG == 11 && (zig_has_builtin(inff16) || defined(zig_gnuc))
......@@ -1959,6 +1960,7 @@ typedef double zig_f32;
19591960#define zig_make_f32(fp, repr) fp
19601961#elif LDBL_MANT_DIG == 24
19611962#define zig_bitSizeOf_c_longdouble 32
1963typedef uint32_t zig_repr_c_longdouble;
19621964typedef long double zig_f32;
19631965#define zig_make_f32(fp, repr) fp##l
19641966#elif FLT32_MANT_DIG == 24
......@@ -1982,6 +1984,7 @@ typedef int32_t zig_f32;
19821984#if _MSC_VER
19831985#ifdef ZIG_TARGET_ABI_MSVC
19841986#define zig_bitSizeOf_c_longdouble 64
1987typedef uint64_t zig_repr_c_longdouble;
19851988#endif
19861989#define zig_make_special_constant_f64(sign, name, arg, repr) sign zig_make_f64(zig_msvc_flt_##name, )
19871990#else /* _MSC_VER */
......@@ -1995,6 +1998,7 @@ typedef double zig_f64;
19951998#define zig_make_f64(fp, repr) fp
19961999#elif LDBL_MANT_DIG == 53
19972000#define zig_bitSizeOf_c_longdouble 64
2001typedef uint64_t zig_repr_c_longdouble;
19982002typedef long double zig_f64;
19992003#define zig_make_f64(fp, repr) fp##l
20002004#elif FLT64_MANT_DIG == 53
......@@ -2027,6 +2031,7 @@ typedef double zig_f80;
20272031#define zig_make_f80(fp, repr) fp
20282032#elif LDBL_MANT_DIG == 64
20292033#define zig_bitSizeOf_c_longdouble 80
2034typedef zig_u128 zig_repr_c_longdouble;
20302035typedef long double zig_f80;
20312036#define zig_make_f80(fp, repr) fp##l
20322037#elif FLT80_MANT_DIG == 64
......@@ -2062,6 +2067,7 @@ typedef double zig_f128;
20622067#define zig_make_f128(fp, repr) fp
20632068#elif LDBL_MANT_DIG == 113
20642069#define zig_bitSizeOf_c_longdouble 128
2070typedef zig_u128 zig_repr_c_longdouble;
20652071typedef long double zig_f128;
20662072#define zig_make_f128(fp, repr) fp##l
20672073#elif FLT128_MANT_DIG == 113
......@@ -2099,9 +2105,10 @@ typedef zig_i128 zig_f128;
20992105#ifdef zig_bitSizeOf_c_longdouble
21002106
21012107#ifdef ZIG_TARGET_ABI_MSVC
2102typedef double zig_c_longdouble;
21032108#undef zig_bitSizeOf_c_longdouble
21042109#define zig_bitSizeOf_c_longdouble 64
2110typedef uint64_t zig_repr_c_longdouble;
2111typedef zig_f64 zig_c_longdouble;
21052112#define zig_make_c_longdouble(fp, repr) fp
21062113#else
21072114typedef long double zig_c_longdouble;
......@@ -2113,6 +2120,7 @@ typedef long double zig_c_longdouble;
21132120#undef zig_has_c_longdouble
21142121#define zig_has_c_longdouble 0
21152122#define zig_bitSizeOf_c_longdouble 80
2123typedef zig_u128 zig_repr_c_longdouble;
21162124#define zig_compiler_rt_abbrev_c_longdouble zig_compiler_rt_abbrev_f80
21172125#define zig_bitSizeOf_repr_c_longdouble 128
21182126typedef zig_i128 zig_c_longdouble;
......@@ -2126,21 +2134,18 @@ typedef zig_i128 zig_c_longdouble;
21262134
21272135#if !zig_has_float_builtins
21282136#define zig_float_from_repr(Type, ReprType) \
2129 static inline zig_##Type zig_float_from_repr_##Type(zig_##ReprType repr) { \
2130 return *((zig_##Type*)&repr); \
2137 static inline zig_##Type zig_float_from_repr_##Type(ReprType repr) { \
2138 zig_##Type result; \
2139 memcpy(&result, &repr, sizeof(result)); \
2140 return result; \
21312141 }
21322142
2133zig_float_from_repr(f16, u16)
2134zig_float_from_repr(f32, u32)
2135zig_float_from_repr(f64, u64)
2136zig_float_from_repr(f80, u128)
2137zig_float_from_repr(f128, u128)
2138#if zig_bitSizeOf_c_longdouble == 80
2139zig_float_from_repr(c_longdouble, u128)
2140#else
2141#define zig_expand_float_from_repr(Type, ReprType) zig_float_from_repr(Type, ReprType)
2142zig_expand_float_from_repr(c_longdouble, zig_expand_concat(u, zig_bitSizeOf_c_longdouble))
2143#endif
2143zig_float_from_repr(f16, uint16_t)
2144zig_float_from_repr(f32, uint32_t)
2145zig_float_from_repr(f64, uint64_t)
2146zig_float_from_repr(f80, zig_u128)
2147zig_float_from_repr(f128, zig_u128)
2148zig_float_from_repr(c_longdouble, zig_repr_c_longdouble)
21442149#endif
21452150
21462151#define zig_cast_f16 (zig_f16)
......@@ -2288,98 +2293,98 @@ zig_float_builtins(c_longdouble)
22882293
22892294// TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64
22902295
2291#define zig_msvc_atomics(Type, suffix) \
2292 static inline bool zig_msvc_cmpxchg_##Type(zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \
2293 zig_##Type comparand = *expected; \
2294 zig_##Type initial = _InterlockedCompareExchange##suffix(obj, desired, comparand); \
2296#define zig_msvc_atomics(ZigType, Type, suffix) \
2297 static inline bool zig_msvc_cmpxchg_##ZigType(Type volatile* obj, Type* expected, Type desired) { \
2298 Type comparand = *expected; \
2299 Type initial = _InterlockedCompareExchange##suffix(obj, desired, comparand); \
22952300 bool exchanged = initial == comparand; \
22962301 if (!exchanged) { \
22972302 *expected = initial; \
22982303 } \
22992304 return exchanged; \
23002305 } \
2301 static inline zig_##Type zig_msvc_atomicrmw_xchg_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2306 static inline Type zig_msvc_atomicrmw_xchg_##ZigType(Type volatile* obj, Type value) { \
23022307 return _InterlockedExchange##suffix(obj, value); \
23032308 } \
2304 static inline zig_##Type zig_msvc_atomicrmw_add_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2309 static inline Type zig_msvc_atomicrmw_add_##ZigType(Type volatile* obj, Type value) { \
23052310 return _InterlockedExchangeAdd##suffix(obj, value); \
23062311 } \
2307 static inline zig_##Type zig_msvc_atomicrmw_sub_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2312 static inline Type zig_msvc_atomicrmw_sub_##ZigType(Type volatile* obj, Type value) { \
23082313 bool success = false; \
2309 zig_##Type new; \
2310 zig_##Type prev; \
2314 Type new; \
2315 Type prev; \
23112316 while (!success) { \
23122317 prev = *obj; \
23132318 new = prev - value; \
2314 success = zig_msvc_cmpxchg_##Type(obj, &prev, new); \
2319 success = zig_msvc_cmpxchg_##ZigType(obj, &prev, new); \
23152320 } \
23162321 return prev; \
23172322 } \
2318 static inline zig_##Type zig_msvc_atomicrmw_or_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2323 static inline Type zig_msvc_atomicrmw_or_##ZigType(Type volatile* obj, Type value) { \
23192324 return _InterlockedOr##suffix(obj, value); \
23202325 } \
2321 static inline zig_##Type zig_msvc_atomicrmw_xor_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2326 static inline Type zig_msvc_atomicrmw_xor_##ZigType(Type volatile* obj, Type value) { \
23222327 return _InterlockedXor##suffix(obj, value); \
23232328 } \
2324 static inline zig_##Type zig_msvc_atomicrmw_and_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2329 static inline Type zig_msvc_atomicrmw_and_##ZigType(Type volatile* obj, Type value) { \
23252330 return _InterlockedAnd##suffix(obj, value); \
23262331 } \
2327 static inline zig_##Type zig_msvc_atomicrmw_nand_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2332 static inline Type zig_msvc_atomicrmw_nand_##ZigType(Type volatile* obj, Type value) { \
23282333 bool success = false; \
2329 zig_##Type new; \
2330 zig_##Type prev; \
2334 Type new; \
2335 Type prev; \
23312336 while (!success) { \
23322337 prev = *obj; \
23332338 new = ~(prev & value); \
2334 success = zig_msvc_cmpxchg_##Type(obj, &prev, new); \
2339 success = zig_msvc_cmpxchg_##ZigType(obj, &prev, new); \
23352340 } \
23362341 return prev; \
23372342 } \
2338 static inline zig_##Type zig_msvc_atomicrmw_min_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2343 static inline Type zig_msvc_atomicrmw_min_##ZigType(Type volatile* obj, Type value) { \
23392344 bool success = false; \
2340 zig_##Type new; \
2341 zig_##Type prev; \
2345 Type new; \
2346 Type prev; \
23422347 while (!success) { \
23432348 prev = *obj; \
23442349 new = value < prev ? value : prev; \
2345 success = zig_msvc_cmpxchg_##Type(obj, &prev, new); \
2350 success = zig_msvc_cmpxchg_##ZigType(obj, &prev, new); \
23462351 } \
23472352 return prev; \
23482353 } \
2349 static inline zig_##Type zig_msvc_atomicrmw_max_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2354 static inline Type zig_msvc_atomicrmw_max_##ZigType(Type volatile* obj, Type value) { \
23502355 bool success = false; \
2351 zig_##Type new; \
2352 zig_##Type prev; \
2356 Type new; \
2357 Type prev; \
23532358 while (!success) { \
23542359 prev = *obj; \
23552360 new = value > prev ? value : prev; \
2356 success = zig_msvc_cmpxchg_##Type(obj, &prev, new); \
2361 success = zig_msvc_cmpxchg_##ZigType(obj, &prev, new); \
23572362 } \
23582363 return prev; \
23592364 } \
2360 static inline void zig_msvc_atomic_store_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2365 static inline void zig_msvc_atomic_store_##ZigType(Type volatile* obj, Type value) { \
23612366 _InterlockedExchange##suffix(obj, value); \
23622367 } \
2363 static inline zig_##Type zig_msvc_atomic_load_##Type(zig_##Type volatile* obj) { \
2368 static inline Type zig_msvc_atomic_load_##ZigType(Type volatile* obj) { \
23642369 return _InterlockedOr##suffix(obj, 0); \
23652370 }
23662371
2367zig_msvc_atomics(u8, 8)
2368zig_msvc_atomics(i8, 8)
2369zig_msvc_atomics(u16, 16)
2370zig_msvc_atomics(i16, 16)
2371zig_msvc_atomics(u32, )
2372zig_msvc_atomics(i32, )
2372zig_msvc_atomics( u8, uint8_t, 8)
2373zig_msvc_atomics( i8, int8_t, 8)
2374zig_msvc_atomics(u16, uint16_t, 16)
2375zig_msvc_atomics(i16, int16_t, 16)
2376zig_msvc_atomics(u32, uint32_t, )
2377zig_msvc_atomics(i32, int32_t, )
23732378
23742379#if _M_X64
2375zig_msvc_atomics(u64, 64)
2376zig_msvc_atomics(i64, 64)
2380zig_msvc_atomics(u64, uint64_t, 64)
2381zig_msvc_atomics(i64, int64_t, 64)
23772382#endif
23782383
23792384#define zig_msvc_flt_atomics(Type, ReprType, suffix) \
23802385 static inline bool zig_msvc_cmpxchg_##Type(zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \
2381 zig_##ReprType comparand = *((zig_##ReprType*)expected); \
2382 zig_##ReprType initial = _InterlockedCompareExchange##suffix((zig_##ReprType volatile*)obj, *((zig_##ReprType*)&desired), comparand); \
2386 ReprType comparand = *((ReprType*)expected); \
2387 ReprType initial = _InterlockedCompareExchange##suffix((ReprType volatile*)obj, *((ReprType*)&desired), comparand); \
23832388 bool exchanged = initial == comparand; \
23842389 if (!exchanged) { \
23852390 *expected = *((zig_##Type*)&initial); \
......@@ -2387,35 +2392,35 @@ zig_msvc_atomics(i64, 64)
23872392 return exchanged; \
23882393 } \
23892394 static inline zig_##Type zig_msvc_atomicrmw_xchg_##Type(zig_##Type volatile* obj, zig_##Type value) { \
2390 zig_##ReprType initial = _InterlockedExchange##suffix((zig_##ReprType volatile*)obj, *((zig_##ReprType*)&value)); \
2395 ReprType initial = _InterlockedExchange##suffix((ReprType volatile*)obj, *((ReprType*)&value)); \
23912396 return *((zig_##Type*)&initial); \
23922397 } \
23932398 static inline zig_##Type zig_msvc_atomicrmw_add_##Type(zig_##Type volatile* obj, zig_##Type value) { \
23942399 bool success = false; \
2395 zig_##ReprType new; \
2400 ReprType new; \
23962401 zig_##Type prev; \
23972402 while (!success) { \
23982403 prev = *obj; \
23992404 new = prev + value; \
2400 success = zig_msvc_cmpxchg_##Type(obj, &prev, *((zig_##ReprType*)&new)); \
2405 success = zig_msvc_cmpxchg_##Type(obj, &prev, *((ReprType*)&new)); \
24012406 } \
24022407 return prev; \
24032408 } \
24042409 static inline zig_##Type zig_msvc_atomicrmw_sub_##Type(zig_##Type volatile* obj, zig_##Type value) { \
24052410 bool success = false; \
2406 zig_##ReprType new; \
2411 ReprType new; \
24072412 zig_##Type prev; \
24082413 while (!success) { \
24092414 prev = *obj; \
24102415 new = prev - value; \
2411 success = zig_msvc_cmpxchg_##Type(obj, &prev, *((zig_##ReprType*)&new)); \
2416 success = zig_msvc_cmpxchg_##Type(obj, &prev, *((ReprType*)&new)); \
24122417 } \
24132418 return prev; \
24142419 }
24152420
2416zig_msvc_flt_atomics(f32, u32, )
2421zig_msvc_flt_atomics(f32, uint32_t, )
24172422#if _M_X64
2418zig_msvc_flt_atomics(f64, u64, 64)
2423zig_msvc_flt_atomics(f64, uint64_t, 64)
24192424#endif
24202425
24212426#if _M_IX86
......@@ -2426,11 +2431,11 @@ static inline void zig_msvc_atomic_barrier() {
24262431 }
24272432}
24282433
2429static inline void* zig_msvc_atomicrmw_xchg_p32(void** obj, uint32_t* arg) {
2434static inline void* zig_msvc_atomicrmw_xchg_p32(void** obj, void* arg) {
24302435 return _InterlockedExchangePointer(obj, arg);
24312436}
24322437
2433static inline void zig_msvc_atomic_store_p32(void** obj, uint32_t* arg) {
2438static inline void zig_msvc_atomic_store_p32(void** obj, void* arg) {
24342439 _InterlockedExchangePointer(obj, arg);
24352440}
24362441
......@@ -2448,11 +2453,11 @@ static inline bool zig_msvc_cmpxchg_p32(void** obj, void** expected, void* desir
24482453 return exchanged;
24492454}
24502455#else /* _M_IX86 */
2451static inline void* zig_msvc_atomicrmw_xchg_p64(void** obj, uint64_t* arg) {
2456static inline void* zig_msvc_atomicrmw_xchg_p64(void** obj, void* arg) {
24522457 return _InterlockedExchangePointer(obj, arg);
24532458}
24542459
2455static inline void zig_msvc_atomic_store_p64(void** obj, uint64_t* arg) {
2460static inline void zig_msvc_atomic_store_p64(void** obj, void* arg) {
24562461 _InterlockedExchangePointer(obj, arg);
24572462}
24582463
src/codegen/c.zig+41-37
......@@ -2058,6 +2058,7 @@ fn renderTypePrefix(
20582058 .zig_f64,
20592059 .zig_f80,
20602060 .zig_f128,
2061 .zig_c_longdouble,
20612062 => |tag| try w.writeAll(@tagName(tag)),
20622063
20632064 .pointer,
......@@ -2225,6 +2226,7 @@ fn renderTypeSuffix(
22252226 .zig_f64,
22262227 .zig_f80,
22272228 .zig_f128,
2229 .zig_c_longdouble,
22282230 => {},
22292231
22302232 .pointer,
......@@ -3062,6 +3064,7 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
30623064 return CValue.none;
30633065 }
30643066
3067 const inst_ty = f.air.typeOfIndex(inst);
30653068 const ptr_ty = f.air.typeOf(bin_op.lhs);
30663069 const child_ty = ptr_ty.childType();
30673070
......@@ -3076,7 +3079,9 @@ fn airPtrElemPtr(f: *Function, inst: Air.Inst.Index) !CValue {
30763079 const writer = f.object.writer();
30773080 const local = try f.allocLocal(inst, f.air.typeOfIndex(inst));
30783081 try f.writeCValue(writer, local, .Other);
3079 try writer.writeAll(" = &(");
3082 try writer.writeAll(" = (");
3083 try f.renderTypecast(writer, inst_ty);
3084 try writer.writeAll(")&(");
30803085 if (ptr_ty.ptrSize() == .One) {
30813086 // It's a pointer to an array, so we need to de-reference.
30823087 try f.writeCValueDeref(writer, ptr);
......@@ -3902,32 +3907,31 @@ fn airPtrAddSub(f: *Function, inst: Air.Inst.Index, operator: u8) !CValue {
39023907 try reap(f, inst, &.{ bin_op.lhs, bin_op.rhs });
39033908
39043909 const inst_ty = f.air.typeOfIndex(inst);
3905 const elem_ty = switch (inst_ty.ptrSize()) {
3906 .One => blk: {
3907 const array_ty = inst_ty.childType();
3908 break :blk array_ty.childType();
3909 },
3910 else => inst_ty.childType(),
3911 };
3910 const elem_ty = inst_ty.elemType2();
39123911
3913 // We must convert to and from integer types to prevent UB if the operation
3914 // results in a NULL pointer, or if LHS is NULL. The operation is only UB
3915 // if the result is NULL and then dereferenced.
39163912 const local = try f.allocLocal(inst, inst_ty);
39173913 const writer = f.object.writer();
39183914 try f.writeCValue(writer, local, .Other);
3919 try writer.writeAll(" = (");
3920 try f.renderTypecast(writer, inst_ty);
3921 try writer.writeAll(")(((uintptr_t)");
3922 try f.writeCValue(writer, lhs, .Other);
3923 try writer.writeAll(") ");
3924 try writer.writeByte(operator);
3925 try writer.writeAll(" (");
3926 try f.writeCValue(writer, rhs, .Other);
3927 try writer.writeAll("*sizeof(");
3928 try f.renderTypecast(writer, elem_ty);
3929 try writer.writeAll(")));\n");
3915 try writer.writeAll(" = ");
3916
3917 if (elem_ty.hasRuntimeBitsIgnoreComptime()) {
3918 // We must convert to and from integer types to prevent UB if the operation
3919 // results in a NULL pointer, or if LHS is NULL. The operation is only UB
3920 // if the result is NULL and then dereferenced.
3921 try writer.writeByte('(');
3922 try f.renderTypecast(writer, inst_ty);
3923 try writer.writeAll(")(((uintptr_t)");
3924 try f.writeCValue(writer, lhs, .Other);
3925 try writer.writeAll(") ");
3926 try writer.writeByte(operator);
3927 try writer.writeAll(" (");
3928 try f.writeCValue(writer, rhs, .Other);
3929 try writer.writeAll("*sizeof(");
3930 try f.renderTypecast(writer, elem_ty);
3931 try writer.writeAll(")))");
3932 } else try f.writeCValue(writer, lhs, .Initializer);
39303933
3934 try writer.writeAll(";\n");
39313935 return local;
39323936}
39333937
......@@ -5264,21 +5268,21 @@ fn structFieldPtr(f: *Function, inst: Air.Inst.Index, struct_ptr_ty: Type, struc
52645268 else => unreachable,
52655269 };
52665270
5267 try writer.writeByte('&');
5268 switch (field_loc) {
5269 .begin, .end => {
5270 try writer.writeByte('(');
5271 try f.writeCValue(writer, struct_ptr, .Other);
5272 try writer.print(")[{}]", .{
5273 @boolToInt(field_loc == .end and struct_ty.hasRuntimeBitsIgnoreComptime()),
5274 });
5275 },
5276 .field => |field| if (extra_name != .none) {
5277 try f.writeCValueDerefMember(writer, struct_ptr, extra_name);
5278 try writer.writeByte('.');
5279 try f.writeCValue(writer, field, .Other);
5280 } else try f.writeCValueDerefMember(writer, struct_ptr, field),
5281 }
5271 if (struct_ty.hasRuntimeBitsIgnoreComptime()) {
5272 try writer.writeByte('&');
5273 switch (field_loc) {
5274 .begin, .end => {
5275 try writer.writeByte('(');
5276 try f.writeCValue(writer, struct_ptr, .Other);
5277 try writer.print(")[{}]", .{@boolToInt(field_loc == .end)});
5278 },
5279 .field => |field| if (extra_name != .none) {
5280 try f.writeCValueDerefMember(writer, struct_ptr, extra_name);
5281 try writer.writeByte('.');
5282 try f.writeCValue(writer, field, .Other);
5283 } else try f.writeCValueDerefMember(writer, struct_ptr, field),
5284 }
5285 } else try f.writeCValue(writer, struct_ptr, .Other);
52825286 try writer.writeAll(";\n");
52835287 return local;
52845288}
src/codegen/c/type.zig+7-2
......@@ -102,6 +102,7 @@ pub const CType = extern union {
102102 zig_f64,
103103 zig_f80,
104104 zig_f128,
105 zig_c_longdouble, // Keep last_no_payload_tag updated!
105106
106107 // After this, the tag requires a payload.
107108 pointer,
......@@ -127,7 +128,7 @@ pub const CType = extern union {
127128 function,
128129 varargs_function,
129130
130 pub const last_no_payload_tag = Tag.zig_f128;
131 pub const last_no_payload_tag = Tag.zig_c_longdouble;
131132 pub const no_payload_count = @enumToInt(last_no_payload_tag) + 1;
132133
133134 pub fn hasPayload(self: Tag) bool {
......@@ -177,6 +178,7 @@ pub const CType = extern union {
177178 .zig_f64,
178179 .zig_f80,
179180 .zig_f128,
181 .zig_c_longdouble,
180182 => @compileError("Type Tag " ++ @tagName(self) ++ " has no payload"),
181183
182184 .pointer,
......@@ -557,6 +559,7 @@ pub const CType = extern union {
557559 .zig_f64,
558560 .zig_f80,
559561 .zig_f128,
562 .zig_c_longdouble,
560563 => false,
561564
562565 .pointer,
......@@ -674,6 +677,7 @@ pub const CType = extern union {
674677 .zig_f64,
675678 .zig_f80,
676679 .zig_f128,
680 .zig_c_longdouble,
677681 => {},
678682
679683 .pointer,
......@@ -980,7 +984,7 @@ pub const CType = extern union {
980984 .f64 => .zig_f64,
981985 .f80 => .zig_f80,
982986 .f128 => .zig_f128,
983 .c_longdouble => .@"long double",
987 .c_longdouble => .zig_c_longdouble,
984988 else => unreachable,
985989 }),
986990
......@@ -1374,6 +1378,7 @@ pub const CType = extern union {
13741378 .zig_f64,
13751379 .zig_f80,
13761380 .zig_f128,
1381 .zig_c_longdouble,
13771382 => return self,
13781383
13791384 .pointer,
test/behavior/asm.zig+13
......@@ -7,6 +7,7 @@ const is_x86_64_linux = builtin.cpu.arch == .x86_64 and builtin.os.tag == .linux
77comptime {
88 if (builtin.zig_backend != .stage2_arm and
99 builtin.zig_backend != .stage2_aarch64 and
10 !(builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) and // MSVC doesn't support inline assembly
1011 is_x86_64_linux)
1112 {
1213 asm (
......@@ -24,6 +25,8 @@ test "module level assembly" {
2425 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
2526 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
2627
28 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly
29
2730 if (is_x86_64_linux) {
2831 try expect(this_is_my_alias() == 1234);
2932 }
......@@ -36,6 +39,8 @@ test "output constraint modifiers" {
3639 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
3740 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
3841
42 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly
43
3944 // This is only testing compilation.
4045 var a: u32 = 3;
4146 asm volatile (""
......@@ -57,6 +62,8 @@ test "alternative constraints" {
5762 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
5863 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
5964
65 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly
66
6067 // Make sure we allow commas as a separator for alternative constraints.
6168 var a: u32 = 3;
6269 asm volatile (""
......@@ -73,6 +80,8 @@ test "sized integer/float in asm input" {
7380 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
7481 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
7582
83 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly
84
7685 asm volatile (""
7786 :
7887 : [_] "m" (@as(usize, 3)),
......@@ -122,6 +131,8 @@ test "struct/array/union types as input values" {
122131 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
123132 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
124133
134 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly
135
125136 asm volatile (""
126137 :
127138 : [_] "m" (@as([1]u32, undefined)),
......@@ -146,6 +157,8 @@ test "asm modifiers (AArch64)" {
146157 if (builtin.target.cpu.arch != .aarch64) return error.SkipZigTest;
147158 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
148159
160 if (builtin.zig_backend == .stage2_c and builtin.os.tag == .windows) return error.SkipZigTest; // MSVC doesn't support inline assembly
161
149162 var x: u32 = 15;
150163 const double = asm ("add %[ret:w], %[in:w], %[in:w]"
151164 : [ret] "=r" (-> u32),