| ... | @@ -3214,7 +3214,7 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) ?u16 { | ... | @@ -3214,7 +3214,7 @@ pub fn cTypeByteSize(t: *const Target, c_type: CType) ?u16 { |
| 3214 | | 3214 | |
| 3215 | /// Returns `null` if no C ABI is defined for this target. | 3215 | /// Returns `null` if no C ABI is defined for this target. |
| 3216 | pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { | 3216 | pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { |
| 3217 | switch (target.os.tag) { | 3217 | return switch (target.os.tag) { |
| 3218 | .freestanding, | 3218 | .freestanding, |
| 3219 | .other, | 3219 | .other, |
| 3220 | .ashetos, | 3220 | .ashetos, |
| ... | @@ -3222,49 +3222,49 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { | ... | @@ -3222,49 +3222,49 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { |
| 3222 | .msp430, | 3222 | .msp430, |
| 3223 | .x86_16, | 3223 | .x86_16, |
| 3224 | => switch (c_type) { | 3224 | => switch (c_type) { |
| 3225 | .char => return 8, | 3225 | .char => 8, |
| 3226 | .short, .ushort, .int, .uint => return 16, | 3226 | .short, .ushort, .int, .uint => 16, |
| 3227 | .float, .long, .ulong => return 32, | 3227 | .float, .long, .ulong => 32, |
| 3228 | .longlong, .ulonglong, .double, .longdouble => return 64, | 3228 | .longlong, .ulonglong, .double, .longdouble => 64, |
| 3229 | }, | 3229 | }, |
| 3230 | .avr => switch (c_type) { | 3230 | .avr => switch (c_type) { |
| 3231 | .char => return 8, | 3231 | .char => 8, |
| 3232 | .short, .ushort, .int, .uint => return 16, | 3232 | .short, .ushort, .int, .uint => 16, |
| 3233 | .long, .ulong, .float, .double, .longdouble => return 32, | 3233 | .long, .ulong, .float, .double, .longdouble => 32, |
| 3234 | .longlong, .ulonglong => return 64, | 3234 | .longlong, .ulonglong => 64, |
| 3235 | }, | 3235 | }, |
| 3236 | .mips64, | 3236 | .mips64, |
| 3237 | .mips64el, | 3237 | .mips64el, |
| 3238 | => switch (c_type) { | 3238 | => switch (c_type) { |
| 3239 | .char => return 8, | 3239 | .char => 8, |
| 3240 | .short, .ushort => return 16, | 3240 | .short, .ushort => 16, |
| 3241 | .int, .uint, .float => return 32, | 3241 | .int, .uint, .float => 32, |
| 3242 | .long, .ulong => switch (target.abi) { | 3242 | .long, .ulong => switch (target.abi) { |
| 3243 | .abin32 => return 32, | 3243 | .abin32 => 32, |
| 3244 | else => return 64, | 3244 | else => 64, |
| 3245 | }, | 3245 | }, |
| 3246 | .longlong, .ulonglong, .double => return 64, | 3246 | .longlong, .ulonglong, .double => 64, |
| 3247 | .longdouble => return 128, | 3247 | .longdouble => 128, |
| 3248 | }, | 3248 | }, |
| 3249 | .x86_64 => switch (c_type) { | 3249 | .x86_64 => switch (c_type) { |
| 3250 | .char => return 8, | 3250 | .char => 8, |
| 3251 | .short, .ushort => return 16, | 3251 | .short, .ushort => 16, |
| 3252 | .int, .uint, .float => return 32, | 3252 | .int, .uint, .float => 32, |
| 3253 | .long, .ulong => switch (target.abi) { | 3253 | .long, .ulong => switch (target.abi) { |
| 3254 | .x32 => return 32, | 3254 | .x32 => 32, |
| 3255 | else => return 64, | 3255 | else => 64, |
| 3256 | }, | 3256 | }, |
| 3257 | .longlong, .ulonglong, .double => return 64, | 3257 | .longlong, .ulonglong, .double => 64, |
| 3258 | .longdouble => return 80, | 3258 | .longdouble => 80, |
| 3259 | }, | 3259 | }, |
| 3260 | else => switch (c_type) { | 3260 | else => switch (c_type) { |
| 3261 | .char => return 8, | 3261 | .char => 8, |
| 3262 | .short, .ushort => return 16, | 3262 | .short, .ushort => 16, |
| 3263 | .int, .uint, .float => return 32, | 3263 | .int, .uint, .float => 32, |
| 3264 | .long, .ulong => return target.ptrBitWidth(), | 3264 | .long, .ulong => target.ptrBitWidth(), |
| 3265 | .longlong, .ulonglong, .double => return 64, | 3265 | .longlong, .ulonglong, .double => 64, |
| 3266 | .longdouble => switch (target.cpu.arch) { | 3266 | .longdouble => switch (target.cpu.arch) { |
| 3267 | .x86 => return 80, | 3267 | .x86 => 80, |
| 3268 | | 3268 | |
| 3269 | .alpha, | 3269 | .alpha, |
| 3270 | .riscv32, | 3270 | .riscv32, |
| ... | @@ -3284,9 +3284,9 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { | ... | @@ -3284,9 +3284,9 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { |
| 3284 | .loongarch32, | 3284 | .loongarch32, |
| 3285 | .loongarch64, | 3285 | .loongarch64, |
| 3286 | .ve, | 3286 | .ve, |
| 3287 | => return 128, | 3287 | => 128, |
| 3288 | | 3288 | |
| 3289 | else => return 64, | 3289 | else => 64, |
| 3290 | }, | 3290 | }, |
| 3291 | }, | 3291 | }, |
| 3292 | }, | 3292 | }, |
| ... | @@ -3313,60 +3313,60 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { | ... | @@ -3313,60 +3313,60 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { |
| 3313 | .mips64, | 3313 | .mips64, |
| 3314 | .mips64el, | 3314 | .mips64el, |
| 3315 | => switch (c_type) { | 3315 | => switch (c_type) { |
| 3316 | .char => return 8, | 3316 | .char => 8, |
| 3317 | .short, .ushort => return 16, | 3317 | .short, .ushort => 16, |
| 3318 | .int, .uint, .float => return 32, | 3318 | .int, .uint, .float => 32, |
| 3319 | .long, .ulong => switch (target.abi) { | 3319 | .long, .ulong => switch (target.abi) { |
| 3320 | .gnuabin32, .muslabin32, .abin32 => return 32, | 3320 | .gnuabin32, .muslabin32, .abin32 => 32, |
| 3321 | else => return 64, | 3321 | else => 64, |
| 3322 | }, | 3322 | }, |
| 3323 | .longlong, .ulonglong, .double => return 64, | 3323 | .longlong, .ulonglong, .double => 64, |
| 3324 | .longdouble => return 128, | 3324 | .longdouble => 128, |
| 3325 | }, | 3325 | }, |
| 3326 | .x86_64 => switch (c_type) { | 3326 | .x86_64 => switch (c_type) { |
| 3327 | .char => return 8, | 3327 | .char => 8, |
| 3328 | .short, .ushort => return 16, | 3328 | .short, .ushort => 16, |
| 3329 | .int, .uint, .float => return 32, | 3329 | .int, .uint, .float => 32, |
| 3330 | .long, .ulong => switch (target.abi) { | 3330 | .long, .ulong => switch (target.abi) { |
| 3331 | .gnux32, .muslx32, .x32 => return 32, | 3331 | .gnux32, .muslx32, .x32 => 32, |
| 3332 | else => return 64, | 3332 | else => 64, |
| 3333 | }, | 3333 | }, |
| 3334 | .longlong, .ulonglong, .double => return 64, | 3334 | .longlong, .ulonglong, .double => 64, |
| 3335 | .longdouble => return 80, | 3335 | .longdouble => 80, |
| 3336 | }, | 3336 | }, |
| 3337 | else => switch (c_type) { | 3337 | else => switch (c_type) { |
| 3338 | .char => return 8, | 3338 | .char => 8, |
| 3339 | .short, .ushort => return 16, | 3339 | .short, .ushort => 16, |
| 3340 | .int, .uint, .float => return 32, | 3340 | .int, .uint, .float => 32, |
| 3341 | .long, .ulong => return target.ptrBitWidth(), | 3341 | .long, .ulong => target.ptrBitWidth(), |
| 3342 | .longlong, .ulonglong, .double => return 64, | 3342 | .longlong, .ulonglong, .double => 64, |
| 3343 | .longdouble => switch (target.cpu.arch) { | 3343 | .longdouble => switch (target.cpu.arch) { |
| 3344 | .x86 => switch (target.abi) { | 3344 | .x86 => switch (target.abi) { |
| 3345 | .android => return 64, | 3345 | .android => 64, |
| 3346 | else => return 80, | 3346 | else => 80, |
| 3347 | }, | 3347 | }, |
| 3348 | | 3348 | |
| 3349 | .powerpc, | 3349 | .powerpc, |
| 3350 | .powerpcle, | 3350 | .powerpcle, |
| 3351 | => switch (target.abi) { | 3351 | => switch (target.abi) { |
| 3352 | .musleabi, .musleabihf => return 64, | 3352 | .musleabi, .musleabihf => 64, |
| 3353 | else => switch (target.os.tag) { | 3353 | else => switch (target.os.tag) { |
| 3354 | .netbsd, | 3354 | .netbsd, |
| 3355 | .openbsd, | 3355 | .openbsd, |
| 3356 | => return 64, | 3356 | => 64, |
| 3357 | else => return 128, | 3357 | else => 128, |
| 3358 | }, | 3358 | }, |
| 3359 | }, | 3359 | }, |
| 3360 | | 3360 | |
| 3361 | .powerpc64, | 3361 | .powerpc64, |
| 3362 | .powerpc64le, | 3362 | .powerpc64le, |
| 3363 | => switch (target.abi) { | 3363 | => switch (target.abi) { |
| 3364 | .musl => return 64, | 3364 | .musl => 64, |
| 3365 | else => switch (target.os.tag) { | 3365 | else => switch (target.os.tag) { |
| 3366 | .freebsd, | 3366 | .freebsd, |
| 3367 | .openbsd, | 3367 | .openbsd, |
| 3368 | => return 64, | 3368 | => 64, |
| 3369 | else => return 128, | 3369 | else => 128, |
| 3370 | }, | 3370 | }, |
| 3371 | }, | 3371 | }, |
| 3372 | | 3372 | |
| ... | @@ -3386,43 +3386,43 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { | ... | @@ -3386,43 +3386,43 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { |
| 3386 | .loongarch32, | 3386 | .loongarch32, |
| 3387 | .loongarch64, | 3387 | .loongarch64, |
| 3388 | .ve, | 3388 | .ve, |
| 3389 | => return 128, | 3389 | => 128, |
| 3390 | | 3390 | |
| 3391 | else => return 64, | 3391 | else => 64, |
| 3392 | }, | 3392 | }, |
| 3393 | }, | 3393 | }, |
| 3394 | }, | 3394 | }, |
| 3395 | | 3395 | |
| 3396 | .windows, .uefi => switch (target.cpu.arch) { | 3396 | .windows, .uefi => switch (target.cpu.arch) { |
| 3397 | .x86 => switch (c_type) { | 3397 | .x86 => switch (c_type) { |
| 3398 | .char => return 8, | 3398 | .char => 8, |
| 3399 | .short, .ushort => return 16, | 3399 | .short, .ushort => 16, |
| 3400 | .int, .uint, .float => return 32, | 3400 | .int, .uint, .float => 32, |
| 3401 | .long, .ulong => return 32, | 3401 | .long, .ulong => 32, |
| 3402 | .longlong, .ulonglong, .double => return 64, | 3402 | .longlong, .ulonglong, .double => 64, |
| 3403 | .longdouble => switch (target.abi) { | 3403 | .longdouble => switch (target.abi) { |
| 3404 | .gnu => return 80, | 3404 | .gnu => 80, |
| 3405 | else => return 64, | 3405 | else => 64, |
| 3406 | }, | 3406 | }, |
| 3407 | }, | 3407 | }, |
| 3408 | .x86_64 => switch (c_type) { | 3408 | .x86_64 => switch (c_type) { |
| 3409 | .char => return 8, | 3409 | .char => 8, |
| 3410 | .short, .ushort => return 16, | 3410 | .short, .ushort => 16, |
| 3411 | .int, .uint, .float => return 32, | 3411 | .int, .uint, .float => 32, |
| 3412 | .long, .ulong => return 32, | 3412 | .long, .ulong => 32, |
| 3413 | .longlong, .ulonglong, .double => return 64, | 3413 | .longlong, .ulonglong, .double => 64, |
| 3414 | .longdouble => switch (target.abi) { | 3414 | .longdouble => switch (target.abi) { |
| 3415 | .gnu => return 80, | 3415 | .gnu => 80, |
| 3416 | else => return 64, | 3416 | else => 64, |
| 3417 | }, | 3417 | }, |
| 3418 | }, | 3418 | }, |
| 3419 | else => switch (c_type) { | 3419 | else => switch (c_type) { |
| 3420 | .char => return 8, | 3420 | .char => 8, |
| 3421 | .short, .ushort => return 16, | 3421 | .short, .ushort => 16, |
| 3422 | .int, .uint, .float => return 32, | 3422 | .int, .uint, .float => 32, |
| 3423 | .long, .ulong => return 32, | 3423 | .long, .ulong => 32, |
| 3424 | .longlong, .ulonglong, .double => return 64, | 3424 | .longlong, .ulonglong, .double => 64, |
| 3425 | .longdouble => return 64, | 3425 | .longdouble => 64, |
| 3426 | }, | 3426 | }, |
| 3427 | }, | 3427 | }, |
| 3428 | | 3428 | |
| ... | @@ -3434,113 +3434,113 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { | ... | @@ -3434,113 +3434,113 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 { |
| 3434 | .visionos, | 3434 | .visionos, |
| 3435 | .watchos, | 3435 | .watchos, |
| 3436 | => switch (c_type) { | 3436 | => switch (c_type) { |
| 3437 | .char => return 8, | 3437 | .char => 8, |
| 3438 | .short, .ushort => return 16, | 3438 | .short, .ushort => 16, |
| 3439 | .int, .uint, .float => return 32, | 3439 | .int, .uint, .float => 32, |
| 3440 | .long, .ulong => switch (target.cpu.arch) { | 3440 | .long, .ulong => switch (target.cpu.arch) { |
| 3441 | .x86_64 => return 64, | 3441 | .x86_64 => 64, |
| 3442 | else => switch (target.abi) { | 3442 | else => switch (target.abi) { |
| 3443 | .ilp32 => return 32, | 3443 | .ilp32 => 32, |
| 3444 | else => return 64, | 3444 | else => 64, |
| 3445 | }, | 3445 | }, |
| 3446 | }, | 3446 | }, |
| 3447 | .longlong, .ulonglong, .double => return 64, | 3447 | .longlong, .ulonglong, .double => 64, |
| 3448 | .longdouble => switch (target.cpu.arch) { | 3448 | .longdouble => switch (target.cpu.arch) { |
| 3449 | .x86_64 => return 80, | 3449 | .x86_64 => 80, |
| 3450 | else => return 64, | 3450 | else => 64, |
| 3451 | }, | 3451 | }, |
| 3452 | }, | 3452 | }, |
| 3453 | | 3453 | |
| 3454 | .nvcl, .cuda => switch (c_type) { | 3454 | .nvcl, .cuda => switch (c_type) { |
| 3455 | .char => return 8, | 3455 | .char => 8, |
| 3456 | .short, .ushort => return 16, | 3456 | .short, .ushort => 16, |
| 3457 | .int, .uint, .float => return 32, | 3457 | .int, .uint, .float => 32, |
| 3458 | .long, .ulong => switch (target.cpu.arch) { | 3458 | .long, .ulong => switch (target.cpu.arch) { |
| 3459 | .nvptx => return 32, | 3459 | .nvptx => 32, |
| 3460 | .nvptx64 => return 64, | 3460 | .nvptx64 => 64, |
| 3461 | else => return 64, | 3461 | else => 64, |
| 3462 | }, | 3462 | }, |
| 3463 | .longlong, .ulonglong, .double => return 64, | 3463 | .longlong, .ulonglong, .double => 64, |
| 3464 | .longdouble => return 64, | 3464 | .longdouble => 64, |
| 3465 | }, | 3465 | }, |
| 3466 | | 3466 | |
| 3467 | .amdhsa, .amdpal, .mesa3d => switch (c_type) { | 3467 | .amdhsa, .amdpal, .mesa3d => switch (c_type) { |
| 3468 | .char => return 8, | 3468 | .char => 8, |
| 3469 | .short, .ushort => return 16, | 3469 | .short, .ushort => 16, |
| 3470 | .int, .uint, .float => return 32, | 3470 | .int, .uint, .float => 32, |
| 3471 | .long, .ulong, .longlong, .ulonglong, .double => return 64, | 3471 | .long, .ulong, .longlong, .ulonglong, .double => 64, |
| 3472 | .longdouble => return 128, | 3472 | .longdouble => 128, |
| 3473 | }, | 3473 | }, |
| 3474 | | 3474 | |
| 3475 | .opencl, .vulkan => switch (c_type) { | 3475 | .opencl, .vulkan => switch (c_type) { |
| 3476 | .char => return 8, | 3476 | .char => 8, |
| 3477 | .short, .ushort => return 16, | 3477 | .short, .ushort => 16, |
| 3478 | .int, .uint, .float => return 32, | 3478 | .int, .uint, .float => 32, |
| 3479 | .long, .ulong, .double => return 64, | 3479 | .long, .ulong, .double => 64, |
| 3480 | .longlong, .ulonglong => return 128, | 3480 | .longlong, .ulonglong => 128, |
| 3481 | // Note: The OpenCL specification does not guarantee a particular size for long double, | 3481 | // Note: The OpenCL specification does not guarantee a particular size for long double, |
| 3482 | // but clang uses 128 bits. | 3482 | // but clang uses 128 bits. |
| 3483 | .longdouble => return 128, | 3483 | .longdouble => 128, |
| 3484 | }, | 3484 | }, |
| 3485 | | 3485 | |
| 3486 | .@"3ds" => switch (c_type) { | 3486 | .@"3ds" => switch (c_type) { |
| 3487 | .char => return 8, | 3487 | .char => 8, |
| 3488 | .short, .ushort => return 16, | 3488 | .short, .ushort => 16, |
| 3489 | .int, .uint, .float, .long, .ulong => return 32, | 3489 | .int, .uint, .float, .long, .ulong => 32, |
| 3490 | .longlong, .ulonglong, .double, .longdouble => return 64, | 3490 | .longlong, .ulonglong, .double, .longdouble => 64, |
| 3491 | }, | 3491 | }, |
| 3492 | | 3492 | |
| 3493 | .wiiu => switch (c_type) { | 3493 | .wiiu => switch (c_type) { |
| 3494 | .char => return 8, | 3494 | .char => 8, |
| 3495 | .short, .ushort => return 16, | 3495 | .short, .ushort => 16, |
| 3496 | .int, .uint, .float, .long, .ulong => return 32, | 3496 | .int, .uint, .float, .long, .ulong => 32, |
| 3497 | .longlong, .ulonglong, .double, .longdouble => return 64, | 3497 | .longlong, .ulonglong, .double, .longdouble => 64, |
| 3498 | }, | 3498 | }, |
| 3499 | | 3499 | |
| 3500 | .@"switch" => switch (c_type) { | 3500 | .@"switch" => switch (c_type) { |
| 3501 | .char => return 8, | 3501 | .char => 8, |
| 3502 | .short, .ushort => return 16, | 3502 | .short, .ushort => 16, |
| 3503 | .int, .uint, .float => return 32, | 3503 | .int, .uint, .float => 32, |
| 3504 | .long, .ulong, .longlong, .ulonglong, .double => return 64, | 3504 | .long, .ulong, .longlong, .ulonglong, .double => 64, |
| 3505 | .longdouble => return 128, | 3505 | .longdouble => 128, |
| 3506 | }, | 3506 | }, |
| 3507 | | 3507 | |
| 3508 | .psx => switch (c_type) { | 3508 | .psx => switch (c_type) { |
| 3509 | .char => return 8, | 3509 | .char => 8, |
| 3510 | .short, .ushort => return 16, | 3510 | .short, .ushort => 16, |
| 3511 | .int, .uint, .long, .ulong, .float => return 32, | 3511 | .int, .uint, .long, .ulong, .float => 32, |
| 3512 | .longlong, .ulonglong, .double, .longdouble => return 64, | 3512 | .longlong, .ulonglong, .double, .longdouble => 64, |
| 3513 | }, | 3513 | }, |
| 3514 | .ps4, .ps5 => switch (c_type) { | 3514 | .ps4, .ps5 => switch (c_type) { |
| 3515 | .char => return 8, | 3515 | .char => 8, |
| 3516 | .short, .ushort => return 16, | 3516 | .short, .ushort => 16, |
| 3517 | .int, .uint, .float => return 32, | 3517 | .int, .uint, .float => 32, |
| 3518 | .long, .ulong => return 64, | 3518 | .long, .ulong => 64, |
| 3519 | .longlong, .ulonglong, .double => return 64, | 3519 | .longlong, .ulonglong, .double => 64, |
| 3520 | .longdouble => return 80, | 3520 | .longdouble => 80, |
| 3521 | }, | 3521 | }, |
| 3522 | .psp, .vita => switch (c_type) { | 3522 | .psp, .vita => switch (c_type) { |
| 3523 | .char => return 8, | 3523 | .char => 8, |
| 3524 | .short, .ushort => return 16, | 3524 | .short, .ushort => 16, |
| 3525 | .int, .uint, .float => return 32, | 3525 | .int, .uint, .float => 32, |
| 3526 | .long, .ulong => return 64, | 3526 | .long, .ulong => 64, |
| 3527 | .longlong, .ulonglong, .double, .longdouble => return 64, | 3527 | .longlong, .ulonglong, .double, .longdouble => 64, |
| 3528 | }, | 3528 | }, |
| 3529 | .tios => switch (c_type) { | 3529 | .tios => switch (c_type) { |
| 3530 | .char => return 8, | 3530 | .char => 8, |
| 3531 | .short, .ushort => return 16, | 3531 | .short, .ushort => 16, |
| 3532 | .int, .uint => return 24, | 3532 | .int, .uint => 24, |
| 3533 | .long, .ulong, .float, .double => return 32, | 3533 | .long, .ulong, .float, .double => 32, |
| 3534 | .longlong, .ulonglong, .longdouble => return 64, | 3534 | .longlong, .ulonglong, .longdouble => 64, |
| 3535 | }, | 3535 | }, |
| 3536 | | 3536 | |
| 3537 | .opengl => return null, | 3537 | .opengl => null, |
| 3538 | | 3538 | |
| 3539 | .ps3, | 3539 | .ps3, |
| 3540 | .contiki, | 3540 | .contiki, |
| 3541 | .managarm, | 3541 | .managarm, |
| 3542 | => @panic("specify the C integer and float type sizes for this OS"), | 3542 | => @panic("specify the C integer and float type sizes for this OS"), |
| 3543 | } | 3543 | }; |
| 3544 | } | 3544 | } |
| 3545 | | 3545 | |
| 3546 | /// Returns `null` if no C ABI is defined for this target. | 3546 | /// Returns `null` if no C ABI is defined for this target. |