| ... | @@ -3094,7 +3094,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool | ... | @@ -3094,7 +3094,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool |
| 3094 | if (ty.isSlice(zcu)) return false; | 3094 | if (ty.isSlice(zcu)) return false; |
| 3095 | const child_ty = ty.childType(zcu); | 3095 | const child_ty = ty.childType(zcu); |
| 3096 | if (child_ty.zigTypeTag(zcu) == .@"fn") { | 3096 | if (child_ty.zigTypeTag(zcu) == .@"fn") { |
| 3097 | return ty.isConstPtr(zcu) and child_ty.validateExtern(.other, zcu); | 3097 | return ty.isConstPtr(zcu) and validateExternCallconv(child_ty.fnCallingConvention(zcu)); |
| 3098 | } | 3098 | } |
| 3099 | return true; | 3099 | return true; |
| 3100 | }, | 3100 | }, |
| ... | @@ -3104,12 +3104,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool | ... | @@ -3104,12 +3104,7 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool |
| 3104 | }, | 3104 | }, |
| 3105 | .@"fn" => { | 3105 | .@"fn" => { |
| 3106 | if (position != .other) return false; | 3106 | if (position != .other) return false; |
| 3107 | // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI. | 3107 | return validateExternCallconv(ty.fnCallingConvention(zcu)); |
| 3108 | // The goal is to experiment with more integrated CPU/GPU code. | | |
| 3109 | if (ty.fnCallingConvention(zcu) == .nvptx_kernel) { | | |
| 3110 | return true; | | |
| 3111 | } | | |
| 3112 | return !target_util.fnCallConvAllowsZigTypes(ty.fnCallingConvention(zcu)); | | |
| 3113 | }, | 3108 | }, |
| 3114 | .@"enum" => { | 3109 | .@"enum" => { |
| 3115 | const enum_obj = zcu.intern_pool.loadEnumType(ty.toIntern()); | 3110 | const enum_obj = zcu.intern_pool.loadEnumType(ty.toIntern()); |
| ... | @@ -3155,6 +3150,14 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool | ... | @@ -3155,6 +3150,14 @@ pub fn validateExtern(ty: Type, position: ExternPosition, zcu: *const Zcu) bool |
| 3155 | .optional => ty.isPtrLikeOptional(zcu), | 3150 | .optional => ty.isPtrLikeOptional(zcu), |
| 3156 | }; | 3151 | }; |
| 3157 | } | 3152 | } |
| | 3153 | fn validateExternCallconv(cc: std.builtin.CallingConvention) bool { |
| | 3154 | return switch (cc) { |
| | 3155 | // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI. |
| | 3156 | // The goal is to experiment with more integrated CPU/GPU code. |
| | 3157 | .nvptx_kernel => true, |
| | 3158 | else => !target_util.fnCallConvAllowsZigTypes(cc), |
| | 3159 | }; |
| | 3160 | } |
| 3158 | | 3161 | |
| 3159 | /// Asserts that `ty` has resolved layout. | 3162 | /// Asserts that `ty` has resolved layout. |
| 3160 | pub fn assertHasLayout(ty: Type, zcu: *const Zcu) void { | 3163 | pub fn assertHasLayout(ty: Type, zcu: *const Zcu) void { |