| author | |
| committer | |
| log | 7da9fa6fe2e982d10ebc9c3844d1249a4eb1d514 |
| tree | 73599545ff9e5a93799c33ad5e7ac04f99718a2a |
| parent | ccc7f9987debd2112d1432f7aa58a81a0814e81d |
Adds AST generation for address spaces on pointers, function prototypes,
function declarations and variable declarations. In the latter two cases,
declaration properties were already stored more efficiently in a declaration
structure. To accomodate these for address spaces, the bit indicating presence
of a linksection attribute has been extended to include either linksection,
address space, or both.7 files changed, 137 insertions(+), 25 deletions(-)
lib/std/builtin.zig+6| ... | @@ -166,6 +166,12 @@ pub const CallingConvention = enum { | ... | @@ -166,6 +166,12 @@ pub const CallingConvention = enum { |
| 166 | SysV, | 166 | SysV, |
| 167 | }; | 167 | }; |
| 168 | 168 | ||
| 169 | /// This data structure is used by the Zig language code generation and | ||
| 170 | /// therefore must be kept in sync with the compiler implementation. | ||
| 171 | pub const AddressSpace = enum { | ||
| 172 | generic, | ||
| 173 | }; | ||
| 174 | |||
| 169 | /// This data structure is used by the Zig language code generation and | 175 | /// This data structure is used by the Zig language code generation and |
| 170 | /// therefore must be kept in sync with the compiler implementation. | 176 | /// therefore must be kept in sync with the compiler implementation. |
| 171 | pub const SourceLocation = struct { | 177 | pub const SourceLocation = struct { |
src/AstGen.zig+43-7| ... | @@ -1116,6 +1116,11 @@ fn fnProtoExpr( | ... | @@ -1116,6 +1116,11 @@ fn fnProtoExpr( |
| 1116 | const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: { | 1116 | const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: { |
| 1117 | break :inst try expr(gz, scope, align_rl, fn_proto.ast.align_expr); | 1117 | break :inst try expr(gz, scope, align_rl, fn_proto.ast.align_expr); |
| 1118 | }; | 1118 | }; |
| 1119 | |||
| 1120 | const addrspace_inst: Zir.Inst.Ref = if (fn_proto.ast.addrspace_expr == 0) .none else inst: { | ||
| 1121 | break :inst try expr(gz, scope, .{ .ty = .address_space_type }, fn_proto.ast.addrspace_expr); | ||
| 1122 | }; | ||
| 1123 | |||
| 1119 | if (fn_proto.ast.section_expr != 0) { | 1124 | if (fn_proto.ast.section_expr != 0) { |
| 1120 | return astgen.failNode(fn_proto.ast.section_expr, "linksection not allowed on function prototypes", .{}); | 1125 | return astgen.failNode(fn_proto.ast.section_expr, "linksection not allowed on function prototypes", .{}); |
| 1121 | } | 1126 | } |
| ... | @@ -1148,6 +1153,7 @@ fn fnProtoExpr( | ... | @@ -1148,6 +1153,7 @@ fn fnProtoExpr( |
| 1148 | .body = &[0]Zir.Inst.Index{}, | 1153 | .body = &[0]Zir.Inst.Index{}, |
| 1149 | .cc = cc, | 1154 | .cc = cc, |
| 1150 | .align_inst = align_inst, | 1155 | .align_inst = align_inst, |
| 1156 | .addrspace_inst = addrspace_inst, | ||
| 1151 | .lib_name = 0, | 1157 | .lib_name = 0, |
| 1152 | .is_var_args = is_var_args, | 1158 | .is_var_args = is_var_args, |
| 1153 | .is_inferred_error = false, | 1159 | .is_inferred_error = false, |
| ... | @@ -2714,6 +2720,7 @@ fn ptrType( | ... | @@ -2714,6 +2720,7 @@ fn ptrType( |
| 2714 | const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type); | 2720 | const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type); |
| 2715 | 2721 | ||
| 2716 | const simple = ptr_info.ast.align_node == 0 and | 2722 | const simple = ptr_info.ast.align_node == 0 and |
| 2723 | ptr_info.ast.addrspace_node == 0 and | ||
| 2717 | ptr_info.ast.sentinel == 0 and | 2724 | ptr_info.ast.sentinel == 0 and |
| 2718 | ptr_info.ast.bit_range_start == 0; | 2725 | ptr_info.ast.bit_range_start == 0; |
| 2719 | 2726 | ||
| ... | @@ -2732,6 +2739,7 @@ fn ptrType( | ... | @@ -2732,6 +2739,7 @@ fn ptrType( |
| 2732 | 2739 | ||
| 2733 | var sentinel_ref: Zir.Inst.Ref = .none; | 2740 | var sentinel_ref: Zir.Inst.Ref = .none; |
| 2734 | var align_ref: Zir.Inst.Ref = .none; | 2741 | var align_ref: Zir.Inst.Ref = .none; |
| 2742 | var addrspace_ref: Zir.Inst.Ref = .none; | ||
| 2735 | var bit_start_ref: Zir.Inst.Ref = .none; | 2743 | var bit_start_ref: Zir.Inst.Ref = .none; |
| 2736 | var bit_end_ref: Zir.Inst.Ref = .none; | 2744 | var bit_end_ref: Zir.Inst.Ref = .none; |
| 2737 | var trailing_count: u32 = 0; | 2745 | var trailing_count: u32 = 0; |
| ... | @@ -2744,6 +2752,10 @@ fn ptrType( | ... | @@ -2744,6 +2752,10 @@ fn ptrType( |
| 2744 | align_ref = try expr(gz, scope, align_rl, ptr_info.ast.align_node); | 2752 | align_ref = try expr(gz, scope, align_rl, ptr_info.ast.align_node); |
| 2745 | trailing_count += 1; | 2753 | trailing_count += 1; |
| 2746 | } | 2754 | } |
| 2755 | if (ptr_info.ast.addrspace_node != 0) { | ||
| 2756 | addrspace_ref = try expr(gz, scope, .{ .ty = .address_space_type }, ptr_info.ast.addrspace_node); | ||
| 2757 | trailing_count += 1; | ||
| 2758 | } | ||
| 2747 | if (ptr_info.ast.bit_range_start != 0) { | 2759 | if (ptr_info.ast.bit_range_start != 0) { |
| 2748 | assert(ptr_info.ast.bit_range_end != 0); | 2760 | assert(ptr_info.ast.bit_range_end != 0); |
| 2749 | bit_start_ref = try expr(gz, scope, .none, ptr_info.ast.bit_range_start); | 2761 | bit_start_ref = try expr(gz, scope, .none, ptr_info.ast.bit_range_start); |
| ... | @@ -2764,6 +2776,9 @@ fn ptrType( | ... | @@ -2764,6 +2776,9 @@ fn ptrType( |
| 2764 | if (align_ref != .none) { | 2776 | if (align_ref != .none) { |
| 2765 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(align_ref)); | 2777 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(align_ref)); |
| 2766 | } | 2778 | } |
| 2779 | if (addrspace_ref != .none) { | ||
| 2780 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(addrspace_ref)); | ||
| 2781 | } | ||
| 2767 | if (bit_start_ref != .none) { | 2782 | if (bit_start_ref != .none) { |
| 2768 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_start_ref)); | 2783 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_start_ref)); |
| 2769 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_end_ref)); | 2784 | gz.astgen.extra.appendAssumeCapacity(@enumToInt(bit_end_ref)); |
| ... | @@ -2779,6 +2794,7 @@ fn ptrType( | ... | @@ -2779,6 +2794,7 @@ fn ptrType( |
| 2779 | .is_volatile = ptr_info.volatile_token != null, | 2794 | .is_volatile = ptr_info.volatile_token != null, |
| 2780 | .has_sentinel = sentinel_ref != .none, | 2795 | .has_sentinel = sentinel_ref != .none, |
| 2781 | .has_align = align_ref != .none, | 2796 | .has_align = align_ref != .none, |
| 2797 | .has_addrspace = addrspace_ref != .none, | ||
| 2782 | .has_bit_range = bit_start_ref != .none, | 2798 | .has_bit_range = bit_start_ref != .none, |
| 2783 | }, | 2799 | }, |
| 2784 | .size = ptr_info.size, | 2800 | .size = ptr_info.size, |
| ... | @@ -2847,7 +2863,7 @@ const WipDecls = struct { | ... | @@ -2847,7 +2863,7 @@ const WipDecls = struct { |
| 2847 | is_pub: bool, | 2863 | is_pub: bool, |
| 2848 | is_export: bool, | 2864 | is_export: bool, |
| 2849 | has_align: bool, | 2865 | has_align: bool, |
| 2850 | has_section: bool, | 2866 | has_section_or_addrspace: bool, |
| 2851 | ) Allocator.Error!void { | 2867 | ) Allocator.Error!void { |
| 2852 | if (wip_decls.decl_index % fields_per_u32 == 0 and wip_decls.decl_index != 0) { | 2868 | if (wip_decls.decl_index % fields_per_u32 == 0 and wip_decls.decl_index != 0) { |
| 2853 | try wip_decls.bit_bag.append(gpa, wip_decls.cur_bit_bag); | 2869 | try wip_decls.bit_bag.append(gpa, wip_decls.cur_bit_bag); |
| ... | @@ -2857,7 +2873,7 @@ const WipDecls = struct { | ... | @@ -2857,7 +2873,7 @@ const WipDecls = struct { |
| 2857 | (@as(u32, @boolToInt(is_pub)) << 28) | | 2873 | (@as(u32, @boolToInt(is_pub)) << 28) | |
| 2858 | (@as(u32, @boolToInt(is_export)) << 29) | | 2874 | (@as(u32, @boolToInt(is_export)) << 29) | |
| 2859 | (@as(u32, @boolToInt(has_align)) << 30) | | 2875 | (@as(u32, @boolToInt(has_align)) << 30) | |
| 2860 | (@as(u32, @boolToInt(has_section)) << 31); | 2876 | (@as(u32, @boolToInt(has_section_or_addrspace)) << 31); |
| 2861 | wip_decls.decl_index += 1; | 2877 | wip_decls.decl_index += 1; |
| 2862 | } | 2878 | } |
| 2863 | 2879 | ||
| ... | @@ -2922,7 +2938,8 @@ fn fnDecl( | ... | @@ -2922,7 +2938,8 @@ fn fnDecl( |
| 2922 | const maybe_inline_token = fn_proto.extern_export_inline_token orelse break :blk false; | 2938 | const maybe_inline_token = fn_proto.extern_export_inline_token orelse break :blk false; |
| 2923 | break :blk token_tags[maybe_inline_token] == .keyword_inline; | 2939 | break :blk token_tags[maybe_inline_token] == .keyword_inline; |
| 2924 | }; | 2940 | }; |
| 2925 | try wip_decls.next(gpa, is_pub, is_export, fn_proto.ast.align_expr != 0, fn_proto.ast.section_expr != 0); | 2941 | const has_section_or_addrspace = fn_proto.ast.section_expr != 0 or fn_proto.ast.addrspace_expr != 0; |
| 2942 | try wip_decls.next(gpa, is_pub, is_export, fn_proto.ast.align_expr != 0, has_section_or_addrspace); | ||
| 2926 | 2943 | ||
| 2927 | var params_scope = &fn_gz.base; | 2944 | var params_scope = &fn_gz.base; |
| 2928 | const is_var_args = is_var_args: { | 2945 | const is_var_args = is_var_args: { |
| ... | @@ -3011,6 +3028,9 @@ fn fnDecl( | ... | @@ -3011,6 +3028,9 @@ fn fnDecl( |
| 3011 | const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: { | 3028 | const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: { |
| 3012 | break :inst try expr(&decl_gz, params_scope, align_rl, fn_proto.ast.align_expr); | 3029 | break :inst try expr(&decl_gz, params_scope, align_rl, fn_proto.ast.align_expr); |
| 3013 | }; | 3030 | }; |
| 3031 | const addrspace_inst: Zir.Inst.Ref = if (fn_proto.ast.addrspace_expr == 0) .none else inst: { | ||
| 3032 | break :inst try expr(&decl_gz, params_scope, .{ .ty = .address_space_type }, fn_proto.ast.addrspace_expr); | ||
| 3033 | }; | ||
| 3014 | const section_inst: Zir.Inst.Ref = if (fn_proto.ast.section_expr == 0) .none else inst: { | 3034 | const section_inst: Zir.Inst.Ref = if (fn_proto.ast.section_expr == 0) .none else inst: { |
| 3015 | break :inst try comptimeExpr(&decl_gz, params_scope, .{ .ty = .const_slice_u8_type }, fn_proto.ast.section_expr); | 3035 | break :inst try comptimeExpr(&decl_gz, params_scope, .{ .ty = .const_slice_u8_type }, fn_proto.ast.section_expr); |
| 3016 | }; | 3036 | }; |
| ... | @@ -3060,6 +3080,7 @@ fn fnDecl( | ... | @@ -3060,6 +3080,7 @@ fn fnDecl( |
| 3060 | .body = &[0]Zir.Inst.Index{}, | 3080 | .body = &[0]Zir.Inst.Index{}, |
| 3061 | .cc = cc, | 3081 | .cc = cc, |
| 3062 | .align_inst = .none, // passed in the per-decl data | 3082 | .align_inst = .none, // passed in the per-decl data |
| 3083 | .addrspace_inst = .none, // passed in the per-decl data | ||
| 3063 | .lib_name = lib_name, | 3084 | .lib_name = lib_name, |
| 3064 | .is_var_args = is_var_args, | 3085 | .is_var_args = is_var_args, |
| 3065 | .is_inferred_error = false, | 3086 | .is_inferred_error = false, |
| ... | @@ -3099,6 +3120,7 @@ fn fnDecl( | ... | @@ -3099,6 +3120,7 @@ fn fnDecl( |
| 3099 | .body = fn_gz.instructions.items, | 3120 | .body = fn_gz.instructions.items, |
| 3100 | .cc = cc, | 3121 | .cc = cc, |
| 3101 | .align_inst = .none, // passed in the per-decl data | 3122 | .align_inst = .none, // passed in the per-decl data |
| 3123 | .addrspace_inst = .none, // passed in the per-decl data | ||
| 3102 | .lib_name = lib_name, | 3124 | .lib_name = lib_name, |
| 3103 | .is_var_args = is_var_args, | 3125 | .is_var_args = is_var_args, |
| 3104 | .is_inferred_error = is_inferred_error, | 3126 | .is_inferred_error = is_inferred_error, |
| ... | @@ -3127,8 +3149,10 @@ fn fnDecl( | ... | @@ -3127,8 +3149,10 @@ fn fnDecl( |
| 3127 | if (align_inst != .none) { | 3149 | if (align_inst != .none) { |
| 3128 | wip_decls.payload.appendAssumeCapacity(@enumToInt(align_inst)); | 3150 | wip_decls.payload.appendAssumeCapacity(@enumToInt(align_inst)); |
| 3129 | } | 3151 | } |
| 3130 | if (section_inst != .none) { | 3152 | |
| 3153 | if (has_section_or_addrspace) { | ||
| 3131 | wip_decls.payload.appendAssumeCapacity(@enumToInt(section_inst)); | 3154 | wip_decls.payload.appendAssumeCapacity(@enumToInt(section_inst)); |
| 3155 | wip_decls.payload.appendAssumeCapacity(@enumToInt(addrspace_inst)); | ||
| 3132 | } | 3156 | } |
| 3133 | } | 3157 | } |
| 3134 | 3158 | ||
| ... | @@ -3175,10 +3199,14 @@ fn globalVarDecl( | ... | @@ -3175,10 +3199,14 @@ fn globalVarDecl( |
| 3175 | const align_inst: Zir.Inst.Ref = if (var_decl.ast.align_node == 0) .none else inst: { | 3199 | const align_inst: Zir.Inst.Ref = if (var_decl.ast.align_node == 0) .none else inst: { |
| 3176 | break :inst try expr(&block_scope, &block_scope.base, align_rl, var_decl.ast.align_node); | 3200 | break :inst try expr(&block_scope, &block_scope.base, align_rl, var_decl.ast.align_node); |
| 3177 | }; | 3201 | }; |
| 3202 | const addrspace_inst: Zir.Inst.Ref = if (var_decl.ast.addrspace_node == 0) .none else inst: { | ||
| 3203 | break :inst try expr(&block_scope, &block_scope.base, .{ .ty = .address_space_type }, var_decl.ast.addrspace_node); | ||
| 3204 | }; | ||
| 3178 | const section_inst: Zir.Inst.Ref = if (var_decl.ast.section_node == 0) .none else inst: { | 3205 | const section_inst: Zir.Inst.Ref = if (var_decl.ast.section_node == 0) .none else inst: { |
| 3179 | break :inst try comptimeExpr(&block_scope, &block_scope.base, .{ .ty = .const_slice_u8_type }, var_decl.ast.section_node); | 3206 | break :inst try comptimeExpr(&block_scope, &block_scope.base, .{ .ty = .const_slice_u8_type }, var_decl.ast.section_node); |
| 3180 | }; | 3207 | }; |
| 3181 | try wip_decls.next(gpa, is_pub, is_export, align_inst != .none, section_inst != .none); | 3208 | const has_section_or_addrspace = section_inst != .none or addrspace_inst != .none; |
| 3209 | try wip_decls.next(gpa, is_pub, is_export, align_inst != .none, has_section_or_addrspace); | ||
| 3182 | 3210 | ||
| 3183 | const is_threadlocal = if (var_decl.threadlocal_token) |tok| blk: { | 3211 | const is_threadlocal = if (var_decl.threadlocal_token) |tok| blk: { |
| 3184 | if (!is_mutable) { | 3212 | if (!is_mutable) { |
| ... | @@ -3271,8 +3299,9 @@ fn globalVarDecl( | ... | @@ -3271,8 +3299,9 @@ fn globalVarDecl( |
| 3271 | if (align_inst != .none) { | 3299 | if (align_inst != .none) { |
| 3272 | wip_decls.payload.appendAssumeCapacity(@enumToInt(align_inst)); | 3300 | wip_decls.payload.appendAssumeCapacity(@enumToInt(align_inst)); |
| 3273 | } | 3301 | } |
| 3274 | if (section_inst != .none) { | 3302 | if (has_section_or_addrspace) { |
| 3275 | wip_decls.payload.appendAssumeCapacity(@enumToInt(section_inst)); | 3303 | wip_decls.payload.appendAssumeCapacity(@enumToInt(section_inst)); |
| 3304 | wip_decls.payload.appendAssumeCapacity(@enumToInt(addrspace_inst)); | ||
| 3276 | } | 3305 | } |
| 3277 | } | 3306 | } |
| 3278 | 3307 | ||
| ... | @@ -3443,6 +3472,7 @@ fn testDecl( | ... | @@ -3443,6 +3472,7 @@ fn testDecl( |
| 3443 | .body = fn_block.instructions.items, | 3472 | .body = fn_block.instructions.items, |
| 3444 | .cc = .none, | 3473 | .cc = .none, |
| 3445 | .align_inst = .none, | 3474 | .align_inst = .none, |
| 3475 | .addrspace_inst = .none, | ||
| 3446 | .lib_name = 0, | 3476 | .lib_name = 0, |
| 3447 | .is_var_args = false, | 3477 | .is_var_args = false, |
| 3448 | .is_inferred_error = true, | 3478 | .is_inferred_error = true, |
| ... | @@ -9178,6 +9208,7 @@ const GenZir = struct { | ... | @@ -9178,6 +9208,7 @@ const GenZir = struct { |
| 9178 | ret_br: Zir.Inst.Index, | 9208 | ret_br: Zir.Inst.Index, |
| 9179 | cc: Zir.Inst.Ref, | 9209 | cc: Zir.Inst.Ref, |
| 9180 | align_inst: Zir.Inst.Ref, | 9210 | align_inst: Zir.Inst.Ref, |
| 9211 | addrspace_inst: Zir.Inst.Ref, | ||
| 9181 | lib_name: u32, | 9212 | lib_name: u32, |
| 9182 | is_var_args: bool, | 9213 | is_var_args: bool, |
| 9183 | is_inferred_error: bool, | 9214 | is_inferred_error: bool, |
| ... | @@ -9221,7 +9252,7 @@ const GenZir = struct { | ... | @@ -9221,7 +9252,7 @@ const GenZir = struct { |
| 9221 | 9252 | ||
| 9222 | if (args.cc != .none or args.lib_name != 0 or | 9253 | if (args.cc != .none or args.lib_name != 0 or |
| 9223 | args.is_var_args or args.is_test or args.align_inst != .none or | 9254 | args.is_var_args or args.is_test or args.align_inst != .none or |
| 9224 | args.is_extern) | 9255 | args.addrspace_inst != .none or args.is_extern) |
| 9225 | { | 9256 | { |
| 9226 | try astgen.extra.ensureUnusedCapacity( | 9257 | try astgen.extra.ensureUnusedCapacity( |
| 9227 | gpa, | 9258 | gpa, |
| ... | @@ -9229,6 +9260,7 @@ const GenZir = struct { | ... | @@ -9229,6 +9260,7 @@ const GenZir = struct { |
| 9229 | args.ret_ty.len + args.body.len + src_locs.len + | 9260 | args.ret_ty.len + args.body.len + src_locs.len + |
| 9230 | @boolToInt(args.lib_name != 0) + | 9261 | @boolToInt(args.lib_name != 0) + |
| 9231 | @boolToInt(args.align_inst != .none) + | 9262 | @boolToInt(args.align_inst != .none) + |
| 9263 | @boolToInt(args.addrspace_inst != .none) + | ||
| 9232 | @boolToInt(args.cc != .none), | 9264 | @boolToInt(args.cc != .none), |
| 9233 | ); | 9265 | ); |
| 9234 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedFunc{ | 9266 | const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.ExtendedFunc{ |
| ... | @@ -9246,6 +9278,9 @@ const GenZir = struct { | ... | @@ -9246,6 +9278,9 @@ const GenZir = struct { |
| 9246 | if (args.align_inst != .none) { | 9278 | if (args.align_inst != .none) { |
| 9247 | astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst)); | 9279 | astgen.extra.appendAssumeCapacity(@enumToInt(args.align_inst)); |
| 9248 | } | 9280 | } |
| 9281 | if (args.addrspace_inst != .none) { | ||
| 9282 | astgen.extra.appendAssumeCapacity(@enumToInt(args.addrspace_inst)); | ||
| 9283 | } | ||
| 9249 | astgen.extra.appendSliceAssumeCapacity(args.ret_ty); | 9284 | astgen.extra.appendSliceAssumeCapacity(args.ret_ty); |
| 9250 | astgen.extra.appendSliceAssumeCapacity(args.body); | 9285 | astgen.extra.appendSliceAssumeCapacity(args.body); |
| 9251 | astgen.extra.appendSliceAssumeCapacity(src_locs); | 9286 | astgen.extra.appendSliceAssumeCapacity(src_locs); |
| ... | @@ -9264,6 +9299,7 @@ const GenZir = struct { | ... | @@ -9264,6 +9299,7 @@ const GenZir = struct { |
| 9264 | .has_lib_name = args.lib_name != 0, | 9299 | .has_lib_name = args.lib_name != 0, |
| 9265 | .has_cc = args.cc != .none, | 9300 | .has_cc = args.cc != .none, |
| 9266 | .has_align = args.align_inst != .none, | 9301 | .has_align = args.align_inst != .none, |
| 9302 | .has_addrspace = args.addrspace_inst != .none, | ||
| 9267 | .is_test = args.is_test, | 9303 | .is_test = args.is_test, |
| 9268 | .is_extern = args.is_extern, | 9304 | .is_extern = args.is_extern, |
| 9269 | }), | 9305 | }), |
src/Sema.zig+3| ... | @@ -10200,6 +10200,7 @@ fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type | ... | @@ -10200,6 +10200,7 @@ fn resolveTypeFields(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, ty: Type |
| 10200 | .atomic_order => return sema.resolveBuiltinTypeFields(block, src, "AtomicOrder"), | 10200 | .atomic_order => return sema.resolveBuiltinTypeFields(block, src, "AtomicOrder"), |
| 10201 | .atomic_rmw_op => return sema.resolveBuiltinTypeFields(block, src, "AtomicRmwOp"), | 10201 | .atomic_rmw_op => return sema.resolveBuiltinTypeFields(block, src, "AtomicRmwOp"), |
| 10202 | .calling_convention => return sema.resolveBuiltinTypeFields(block, src, "CallingConvention"), | 10202 | .calling_convention => return sema.resolveBuiltinTypeFields(block, src, "CallingConvention"), |
| 10203 | .address_space => return sema.resolveBuiltinTypeFields(block, src, "AddressSpace"), | ||
| 10203 | .float_mode => return sema.resolveBuiltinTypeFields(block, src, "FloatMode"), | 10204 | .float_mode => return sema.resolveBuiltinTypeFields(block, src, "FloatMode"), |
| 10204 | .reduce_op => return sema.resolveBuiltinTypeFields(block, src, "ReduceOp"), | 10205 | .reduce_op => return sema.resolveBuiltinTypeFields(block, src, "ReduceOp"), |
| 10205 | .call_options => return sema.resolveBuiltinTypeFields(block, src, "CallOptions"), | 10206 | .call_options => return sema.resolveBuiltinTypeFields(block, src, "CallOptions"), |
| ... | @@ -10594,6 +10595,7 @@ fn typeHasOnePossibleValue( | ... | @@ -10594,6 +10595,7 @@ fn typeHasOnePossibleValue( |
| 10594 | .atomic_order, | 10595 | .atomic_order, |
| 10595 | .atomic_rmw_op, | 10596 | .atomic_rmw_op, |
| 10596 | .calling_convention, | 10597 | .calling_convention, |
| 10598 | .address_space, | ||
| 10597 | .float_mode, | 10599 | .float_mode, |
| 10598 | .reduce_op, | 10600 | .reduce_op, |
| 10599 | .call_options, | 10601 | .call_options, |
| ... | @@ -10779,6 +10781,7 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref { | ... | @@ -10779,6 +10781,7 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref { |
| 10779 | .atomic_order => return .atomic_order_type, | 10781 | .atomic_order => return .atomic_order_type, |
| 10780 | .atomic_rmw_op => return .atomic_rmw_op_type, | 10782 | .atomic_rmw_op => return .atomic_rmw_op_type, |
| 10781 | .calling_convention => return .calling_convention_type, | 10783 | .calling_convention => return .calling_convention_type, |
| 10784 | .address_space => return .address_space_type, | ||
| 10782 | .float_mode => return .float_mode_type, | 10785 | .float_mode => return .float_mode_type, |
| 10783 | .reduce_op => return .reduce_op_type, | 10786 | .reduce_op => return .reduce_op_type, |
| 10784 | .call_options => return .call_options_type, | 10787 | .call_options => return .call_options_type, |
src/Zir.zig+59-18| ... | @@ -488,10 +488,10 @@ pub const Inst = struct { | ... | @@ -488,10 +488,10 @@ pub const Inst = struct { |
| 488 | /// this instruction; a following 'ret' instruction will do the diversion. | 488 | /// this instruction; a following 'ret' instruction will do the diversion. |
| 489 | /// Uses the `str_tok` union field. | 489 | /// Uses the `str_tok` union field. |
| 490 | ret_err_value_code, | 490 | ret_err_value_code, |
| 491 | /// Create a pointer type that does not have a sentinel, alignment, or bit range specified. | 491 | /// Create a pointer type that does not have a sentinel, alignment, address space, or bit range specified. |
| 492 | /// Uses the `ptr_type_simple` union field. | 492 | /// Uses the `ptr_type_simple` union field. |
| 493 | ptr_type_simple, | 493 | ptr_type_simple, |
| 494 | /// Create a pointer type which can have a sentinel, alignment, and/or bit range. | 494 | /// Create a pointer type which can have a sentinel, alignment, address space, and/or bit range. |
| 495 | /// Uses the `ptr_type` union field. | 495 | /// Uses the `ptr_type` union field. |
| 496 | ptr_type, | 496 | ptr_type, |
| 497 | /// Slice operation `lhs[rhs..]`. No sentinel and no end offset. | 497 | /// Slice operation `lhs[rhs..]`. No sentinel and no end offset. |
| ... | @@ -1717,6 +1717,7 @@ pub const Inst = struct { | ... | @@ -1717,6 +1717,7 @@ pub const Inst = struct { |
| 1717 | atomic_order_type, | 1717 | atomic_order_type, |
| 1718 | atomic_rmw_op_type, | 1718 | atomic_rmw_op_type, |
| 1719 | calling_convention_type, | 1719 | calling_convention_type, |
| 1720 | address_space_type, | ||
| 1720 | float_mode_type, | 1721 | float_mode_type, |
| 1721 | reduce_op_type, | 1722 | reduce_op_type, |
| 1722 | call_options_type, | 1723 | call_options_type, |
| ... | @@ -1973,6 +1974,10 @@ pub const Inst = struct { | ... | @@ -1973,6 +1974,10 @@ pub const Inst = struct { |
| 1973 | .ty = Type.initTag(.type), | 1974 | .ty = Type.initTag(.type), |
| 1974 | .val = Value.initTag(.calling_convention_type), | 1975 | .val = Value.initTag(.calling_convention_type), |
| 1975 | }, | 1976 | }, |
| 1977 | .address_space_type = .{ | ||
| 1978 | .ty = Type.initTag(.type), | ||
| 1979 | .val = Value.initTag(.address_space_type), | ||
| 1980 | }, | ||
| 1976 | .float_mode_type = .{ | 1981 | .float_mode_type = .{ |
| 1977 | .ty = Type.initTag(.type), | 1982 | .ty = Type.initTag(.type), |
| 1978 | .val = Value.initTag(.float_mode_type), | 1983 | .val = Value.initTag(.float_mode_type), |
| ... | @@ -2174,8 +2179,9 @@ pub const Inst = struct { | ... | @@ -2174,8 +2179,9 @@ pub const Inst = struct { |
| 2174 | is_volatile: bool, | 2179 | is_volatile: bool, |
| 2175 | has_sentinel: bool, | 2180 | has_sentinel: bool, |
| 2176 | has_align: bool, | 2181 | has_align: bool, |
| 2182 | has_addrspace: bool, | ||
| 2177 | has_bit_range: bool, | 2183 | has_bit_range: bool, |
| 2178 | _: u2 = undefined, | 2184 | _: u1 = undefined, |
| 2179 | }, | 2185 | }, |
| 2180 | size: std.builtin.TypeInfo.Pointer.Size, | 2186 | size: std.builtin.TypeInfo.Pointer.Size, |
| 2181 | /// Index into extra. See `PtrType`. | 2187 | /// Index into extra. See `PtrType`. |
| ... | @@ -2303,6 +2309,7 @@ pub const Inst = struct { | ... | @@ -2303,6 +2309,7 @@ pub const Inst = struct { |
| 2303 | /// 0. lib_name: u32, // null terminated string index, if has_lib_name is set | 2309 | /// 0. lib_name: u32, // null terminated string index, if has_lib_name is set |
| 2304 | /// 1. cc: Ref, // if has_cc is set | 2310 | /// 1. cc: Ref, // if has_cc is set |
| 2305 | /// 2. align: Ref, // if has_align is set | 2311 | /// 2. align: Ref, // if has_align is set |
| 2312 | /// 3. addrspace: Ref, // if has_addrspace is set | ||
| 2306 | /// 3. return_type: Index // for each ret_body_len | 2313 | /// 3. return_type: Index // for each ret_body_len |
| 2307 | /// 4. body: Index // for each body_len | 2314 | /// 4. body: Index // for each body_len |
| 2308 | /// 5. src_locs: Func.SrcLocs // if body_len != 0 | 2315 | /// 5. src_locs: Func.SrcLocs // if body_len != 0 |
| ... | @@ -2320,9 +2327,10 @@ pub const Inst = struct { | ... | @@ -2320,9 +2327,10 @@ pub const Inst = struct { |
| 2320 | has_lib_name: bool, | 2327 | has_lib_name: bool, |
| 2321 | has_cc: bool, | 2328 | has_cc: bool, |
| 2322 | has_align: bool, | 2329 | has_align: bool, |
| 2330 | has_addrspace: bool, | ||
| 2323 | is_test: bool, | 2331 | is_test: bool, |
| 2324 | is_extern: bool, | 2332 | is_extern: bool, |
| 2325 | _: u9 = undefined, | 2333 | _: u8 = undefined, |
| 2326 | }; | 2334 | }; |
| 2327 | }; | 2335 | }; |
| 2328 | 2336 | ||
| ... | @@ -2405,12 +2413,13 @@ pub const Inst = struct { | ... | @@ -2405,12 +2413,13 @@ pub const Inst = struct { |
| 2405 | else_body_len: u32, | 2413 | else_body_len: u32, |
| 2406 | }; | 2414 | }; |
| 2407 | 2415 | ||
| 2408 | /// Stored in extra. Depending on the flags in Data, there will be up to 4 | 2416 | /// Stored in extra. Depending on the flags in Data, there will be up to 5 |
| 2409 | /// trailing Ref fields: | 2417 | /// trailing Ref fields: |
| 2410 | /// 0. sentinel: Ref // if `has_sentinel` flag is set | 2418 | /// 0. sentinel: Ref // if `has_sentinel` flag is set |
| 2411 | /// 1. align: Ref // if `has_align` flag is set | 2419 | /// 1. align: Ref // if `has_align` flag is set |
| 2412 | /// 2. bit_start: Ref // if `has_bit_range` flag is set | 2420 | /// 2. address_space: Ref // if `has_addrspace` flag is set |
| 2413 | /// 3. bit_end: Ref // if `has_bit_range` flag is set | 2421 | /// 3. bit_start: Ref // if `has_bit_range` flag is set |
| 2422 | /// 4. bit_end: Ref // if `has_bit_range` flag is set | ||
| 2414 | pub const PtrType = struct { | 2423 | pub const PtrType = struct { |
| 2415 | elem_type: Ref, | 2424 | elem_type: Ref, |
| 2416 | }; | 2425 | }; |
| ... | @@ -2528,7 +2537,7 @@ pub const Inst = struct { | ... | @@ -2528,7 +2537,7 @@ pub const Inst = struct { |
| 2528 | /// 0b000X: whether corresponding decl is pub | 2537 | /// 0b000X: whether corresponding decl is pub |
| 2529 | /// 0b00X0: whether corresponding decl is exported | 2538 | /// 0b00X0: whether corresponding decl is exported |
| 2530 | /// 0b0X00: whether corresponding decl has an align expression | 2539 | /// 0b0X00: whether corresponding decl has an align expression |
| 2531 | /// 0bX000: whether corresponding decl has a linksection expression | 2540 | /// 0bX000: whether corresponding decl has a linksection or an address space expression |
| 2532 | /// 5. decl: { // for every decls_len | 2541 | /// 5. decl: { // for every decls_len |
| 2533 | /// src_hash: [4]u32, // hash of source bytes | 2542 | /// src_hash: [4]u32, // hash of source bytes |
| 2534 | /// line: u32, // line number of decl, relative to parent | 2543 | /// line: u32, // line number of decl, relative to parent |
| ... | @@ -2540,7 +2549,10 @@ pub const Inst = struct { | ... | @@ -2540,7 +2549,10 @@ pub const Inst = struct { |
| 2540 | /// this is a test decl, and the name starts at `name+1`. | 2549 | /// this is a test decl, and the name starts at `name+1`. |
| 2541 | /// value: Index, | 2550 | /// value: Index, |
| 2542 | /// align: Ref, // if corresponding bit is set | 2551 | /// align: Ref, // if corresponding bit is set |
| 2543 | /// link_section: Ref, // if corresponding bit is set | 2552 | /// link_section_or_address_space: { // if corresponding bit is set. |
| 2553 | /// link_section: Ref, | ||
| 2554 | /// address_space: Ref, | ||
| 2555 | /// } | ||
| 2544 | /// } | 2556 | /// } |
| 2545 | /// 6. inst: Index // for every body_len | 2557 | /// 6. inst: Index // for every body_len |
| 2546 | /// 7. flags: u32 // for every 8 fields | 2558 | /// 7. flags: u32 // for every 8 fields |
| ... | @@ -2592,7 +2604,7 @@ pub const Inst = struct { | ... | @@ -2592,7 +2604,7 @@ pub const Inst = struct { |
| 2592 | /// 0b000X: whether corresponding decl is pub | 2604 | /// 0b000X: whether corresponding decl is pub |
| 2593 | /// 0b00X0: whether corresponding decl is exported | 2605 | /// 0b00X0: whether corresponding decl is exported |
| 2594 | /// 0b0X00: whether corresponding decl has an align expression | 2606 | /// 0b0X00: whether corresponding decl has an align expression |
| 2595 | /// 0bX000: whether corresponding decl has a linksection expression | 2607 | /// 0bX000: whether corresponding decl has a linksection or an address space expression |
| 2596 | /// 6. decl: { // for every decls_len | 2608 | /// 6. decl: { // for every decls_len |
| 2597 | /// src_hash: [4]u32, // hash of source bytes | 2609 | /// src_hash: [4]u32, // hash of source bytes |
| 2598 | /// line: u32, // line number of decl, relative to parent | 2610 | /// line: u32, // line number of decl, relative to parent |
| ... | @@ -2604,7 +2616,10 @@ pub const Inst = struct { | ... | @@ -2604,7 +2616,10 @@ pub const Inst = struct { |
| 2604 | /// this is a test decl, and the name starts at `name+1`. | 2616 | /// this is a test decl, and the name starts at `name+1`. |
| 2605 | /// value: Index, | 2617 | /// value: Index, |
| 2606 | /// align: Ref, // if corresponding bit is set | 2618 | /// align: Ref, // if corresponding bit is set |
| 2607 | /// link_section: Ref, // if corresponding bit is set | 2619 | /// link_section_or_address_space: { // if corresponding bit is set. |
| 2620 | /// link_section: Ref, | ||
| 2621 | /// address_space: Ref, | ||
| 2622 | /// } | ||
| 2608 | /// } | 2623 | /// } |
| 2609 | /// 7. inst: Index // for every body_len | 2624 | /// 7. inst: Index // for every body_len |
| 2610 | /// 8. has_bits: u32 // for every 32 fields | 2625 | /// 8. has_bits: u32 // for every 32 fields |
| ... | @@ -2637,7 +2652,7 @@ pub const Inst = struct { | ... | @@ -2637,7 +2652,7 @@ pub const Inst = struct { |
| 2637 | /// 0b000X: whether corresponding decl is pub | 2652 | /// 0b000X: whether corresponding decl is pub |
| 2638 | /// 0b00X0: whether corresponding decl is exported | 2653 | /// 0b00X0: whether corresponding decl is exported |
| 2639 | /// 0b0X00: whether corresponding decl has an align expression | 2654 | /// 0b0X00: whether corresponding decl has an align expression |
| 2640 | /// 0bX000: whether corresponding decl has a linksection expression | 2655 | /// 0bX000: whether corresponding decl has a linksection or an address space expression |
| 2641 | /// 6. decl: { // for every decls_len | 2656 | /// 6. decl: { // for every decls_len |
| 2642 | /// src_hash: [4]u32, // hash of source bytes | 2657 | /// src_hash: [4]u32, // hash of source bytes |
| 2643 | /// line: u32, // line number of decl, relative to parent | 2658 | /// line: u32, // line number of decl, relative to parent |
| ... | @@ -2649,7 +2664,10 @@ pub const Inst = struct { | ... | @@ -2649,7 +2664,10 @@ pub const Inst = struct { |
| 2649 | /// this is a test decl, and the name starts at `name+1`. | 2664 | /// this is a test decl, and the name starts at `name+1`. |
| 2650 | /// value: Index, | 2665 | /// value: Index, |
| 2651 | /// align: Ref, // if corresponding bit is set | 2666 | /// align: Ref, // if corresponding bit is set |
| 2652 | /// link_section: Ref, // if corresponding bit is set | 2667 | /// link_section_or_address_space: { // if corresponding bit is set. |
| 2668 | /// link_section: Ref, | ||
| 2669 | /// address_space: Ref, | ||
| 2670 | /// } | ||
| 2653 | /// } | 2671 | /// } |
| 2654 | /// 7. inst: Index // for every body_len | 2672 | /// 7. inst: Index // for every body_len |
| 2655 | /// 8. has_bits: u32 // for every 8 fields | 2673 | /// 8. has_bits: u32 // for every 8 fields |
| ... | @@ -2686,7 +2704,7 @@ pub const Inst = struct { | ... | @@ -2686,7 +2704,7 @@ pub const Inst = struct { |
| 2686 | /// 0b000X: whether corresponding decl is pub | 2704 | /// 0b000X: whether corresponding decl is pub |
| 2687 | /// 0b00X0: whether corresponding decl is exported | 2705 | /// 0b00X0: whether corresponding decl is exported |
| 2688 | /// 0b0X00: whether corresponding decl has an align expression | 2706 | /// 0b0X00: whether corresponding decl has an align expression |
| 2689 | /// 0bX000: whether corresponding decl has a linksection expression | 2707 | /// 0bX000: whether corresponding decl has a linksection or an address space expression |
| 2690 | /// 1. decl: { // for every decls_len | 2708 | /// 1. decl: { // for every decls_len |
| 2691 | /// src_hash: [4]u32, // hash of source bytes | 2709 | /// src_hash: [4]u32, // hash of source bytes |
| 2692 | /// line: u32, // line number of decl, relative to parent | 2710 | /// line: u32, // line number of decl, relative to parent |
| ... | @@ -2698,7 +2716,10 @@ pub const Inst = struct { | ... | @@ -2698,7 +2716,10 @@ pub const Inst = struct { |
| 2698 | /// this is a test decl, and the name starts at `name+1`. | 2716 | /// this is a test decl, and the name starts at `name+1`. |
| 2699 | /// value: Index, | 2717 | /// value: Index, |
| 2700 | /// align: Ref, // if corresponding bit is set | 2718 | /// align: Ref, // if corresponding bit is set |
| 2701 | /// link_section: Ref, // if corresponding bit is set | 2719 | /// link_section_or_address_space: { // if corresponding bit is set. |
| 2720 | /// link_section: Ref, | ||
| 2721 | /// address_space: Ref, | ||
| 2722 | /// } | ||
| 2702 | /// } | 2723 | /// } |
| 2703 | pub const OpaqueDecl = struct { | 2724 | pub const OpaqueDecl = struct { |
| 2704 | decls_len: u32, | 2725 | decls_len: u32, |
| ... | @@ -3983,7 +4004,7 @@ const Writer = struct { | ... | @@ -3983,7 +4004,7 @@ const Writer = struct { |
| 3983 | cur_bit_bag >>= 1; | 4004 | cur_bit_bag >>= 1; |
| 3984 | const has_align = @truncate(u1, cur_bit_bag) != 0; | 4005 | const has_align = @truncate(u1, cur_bit_bag) != 0; |
| 3985 | cur_bit_bag >>= 1; | 4006 | cur_bit_bag >>= 1; |
| 3986 | const has_section = @truncate(u1, cur_bit_bag) != 0; | 4007 | const has_section_or_addrspace = @truncate(u1, cur_bit_bag) != 0; |
| 3987 | cur_bit_bag >>= 1; | 4008 | cur_bit_bag >>= 1; |
| 3988 | 4009 | ||
| 3989 | const sub_index = extra_index; | 4010 | const sub_index = extra_index; |
| ... | @@ -4001,12 +4022,16 @@ const Writer = struct { | ... | @@ -4001,12 +4022,16 @@ const Writer = struct { |
| 4001 | extra_index += 1; | 4022 | extra_index += 1; |
| 4002 | break :inst inst; | 4023 | break :inst inst; |
| 4003 | }; | 4024 | }; |
| 4004 | const section_inst: Inst.Ref = if (!has_section) .none else inst: { | 4025 | const section_inst: Inst.Ref = if (!has_section_or_addrspace) .none else inst: { |
| 4005 | const inst = @intToEnum(Inst.Ref, self.code.extra[extra_index]); | 4026 | const inst = @intToEnum(Inst.Ref, self.code.extra[extra_index]); |
| 4006 | extra_index += 1; | 4027 | extra_index += 1; |
| 4007 | break :inst inst; | 4028 | break :inst inst; |
| 4008 | }; | 4029 | }; |
| 4009 | 4030 | const addrspace_inst: Inst.Ref = if (!has_section_or_addrspace) .none else inst: { | |
| 4031 | const inst = @intToEnum(Inst.Ref, self.code.extra[extra_index]); | ||
| 4032 | extra_index +=1; | ||
| 4033 | break :inst inst; | ||
| 4034 | }; | ||
| 4010 | const pub_str = if (is_pub) "pub " else ""; | 4035 | const pub_str = if (is_pub) "pub " else ""; |
| 4011 | const hash_bytes = @bitCast([16]u8, hash_u32s.*); | 4036 | const hash_bytes = @bitCast([16]u8, hash_u32s.*); |
| 4012 | try stream.writeByteNTimes(' ', self.indent); | 4037 | try stream.writeByteNTimes(' ', self.indent); |
| ... | @@ -4032,6 +4057,11 @@ const Writer = struct { | ... | @@ -4032,6 +4057,11 @@ const Writer = struct { |
| 4032 | try self.writeInstRef(stream, align_inst); | 4057 | try self.writeInstRef(stream, align_inst); |
| 4033 | try stream.writeAll(")"); | 4058 | try stream.writeAll(")"); |
| 4034 | } | 4059 | } |
| 4060 | if (addrspace_inst != .none) { | ||
| 4061 | try stream.writeAll(" addrspace("); | ||
| 4062 | try self.writeInstRef(stream, addrspace_inst); | ||
| 4063 | try stream.writeAll(")"); | ||
| 4064 | } | ||
| 4035 | if (section_inst != .none) { | 4065 | if (section_inst != .none) { |
| 4036 | try stream.writeAll(" linksection("); | 4066 | try stream.writeAll(" linksection("); |
| 4037 | try self.writeInstRef(stream, section_inst); | 4067 | try self.writeInstRef(stream, section_inst); |
| ... | @@ -4453,6 +4483,7 @@ const Writer = struct { | ... | @@ -4453,6 +4483,7 @@ const Writer = struct { |
| 4453 | false, | 4483 | false, |
| 4454 | .none, | 4484 | .none, |
| 4455 | .none, | 4485 | .none, |
| 4486 | .none, | ||
| 4456 | body, | 4487 | body, |
| 4457 | src, | 4488 | src, |
| 4458 | src_locs, | 4489 | src_locs, |
| ... | @@ -4481,6 +4512,11 @@ const Writer = struct { | ... | @@ -4481,6 +4512,11 @@ const Writer = struct { |
| 4481 | extra_index += 1; | 4512 | extra_index += 1; |
| 4482 | break :blk align_inst; | 4513 | break :blk align_inst; |
| 4483 | }; | 4514 | }; |
| 4515 | const addrspace_inst: Inst.Ref = if (!small.has_addrspace) .none else blk: { | ||
| 4516 | const addrspace_inst = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); | ||
| 4517 | extra_index += 1; | ||
| 4518 | break :blk addrspace_inst; | ||
| 4519 | }; | ||
| 4484 | 4520 | ||
| 4485 | const ret_ty_body = self.code.extra[extra_index..][0..extra.data.ret_body_len]; | 4521 | const ret_ty_body = self.code.extra[extra_index..][0..extra.data.ret_body_len]; |
| 4486 | extra_index += ret_ty_body.len; | 4522 | extra_index += ret_ty_body.len; |
| ... | @@ -4500,6 +4536,7 @@ const Writer = struct { | ... | @@ -4500,6 +4536,7 @@ const Writer = struct { |
| 4500 | small.is_extern, | 4536 | small.is_extern, |
| 4501 | cc, | 4537 | cc, |
| 4502 | align_inst, | 4538 | align_inst, |
| 4539 | addrspace_inst, | ||
| 4503 | body, | 4540 | body, |
| 4504 | src, | 4541 | src, |
| 4505 | src_locs, | 4542 | src_locs, |
| ... | @@ -4582,6 +4619,7 @@ const Writer = struct { | ... | @@ -4582,6 +4619,7 @@ const Writer = struct { |
| 4582 | is_extern: bool, | 4619 | is_extern: bool, |
| 4583 | cc: Inst.Ref, | 4620 | cc: Inst.Ref, |
| 4584 | align_inst: Inst.Ref, | 4621 | align_inst: Inst.Ref, |
| 4622 | addrspace_inst: Inst.Ref, | ||
| 4585 | body: []const Inst.Index, | 4623 | body: []const Inst.Index, |
| 4586 | src: LazySrcLoc, | 4624 | src: LazySrcLoc, |
| 4587 | src_locs: Zir.Inst.Func.SrcLocs, | 4625 | src_locs: Zir.Inst.Func.SrcLocs, |
| ... | @@ -4599,6 +4637,7 @@ const Writer = struct { | ... | @@ -4599,6 +4637,7 @@ const Writer = struct { |
| 4599 | 4637 | ||
| 4600 | try self.writeOptionalInstRef(stream, ", cc=", cc); | 4638 | try self.writeOptionalInstRef(stream, ", cc=", cc); |
| 4601 | try self.writeOptionalInstRef(stream, ", align=", align_inst); | 4639 | try self.writeOptionalInstRef(stream, ", align=", align_inst); |
| 4640 | try self.writeOptionalInstRef(stream, ", addrspace=", addrspace_inst); | ||
| 4602 | try self.writeFlag(stream, ", vargs", var_args); | 4641 | try self.writeFlag(stream, ", vargs", var_args); |
| 4603 | try self.writeFlag(stream, ", extern", is_extern); | 4642 | try self.writeFlag(stream, ", extern", is_extern); |
| 4604 | try self.writeFlag(stream, ", inferror", inferred_error_set); | 4643 | try self.writeFlag(stream, ", inferror", inferred_error_set); |
| ... | @@ -4876,6 +4915,7 @@ fn findDeclsInner( | ... | @@ -4876,6 +4915,7 @@ fn findDeclsInner( |
| 4876 | extra_index += @boolToInt(small.has_lib_name); | 4915 | extra_index += @boolToInt(small.has_lib_name); |
| 4877 | extra_index += @boolToInt(small.has_cc); | 4916 | extra_index += @boolToInt(small.has_cc); |
| 4878 | extra_index += @boolToInt(small.has_align); | 4917 | extra_index += @boolToInt(small.has_align); |
| 4918 | extra_index += @boolToInt(small.has_addrspace); | ||
| 4879 | const body = zir.extra[extra_index..][0..extra.data.body_len]; | 4919 | const body = zir.extra[extra_index..][0..extra.data.body_len]; |
| 4880 | return zir.findDeclsBody(list, body); | 4920 | return zir.findDeclsBody(list, body); |
| 4881 | }, | 4921 | }, |
| ... | @@ -5079,6 +5119,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { | ... | @@ -5079,6 +5119,7 @@ pub fn getFnInfo(zir: Zir, fn_inst: Inst.Index) FnInfo { |
| 5079 | extra_index += @boolToInt(small.has_lib_name); | 5119 | extra_index += @boolToInt(small.has_lib_name); |
| 5080 | extra_index += @boolToInt(small.has_cc); | 5120 | extra_index += @boolToInt(small.has_cc); |
| 5081 | extra_index += @boolToInt(small.has_align); | 5121 | extra_index += @boolToInt(small.has_align); |
| 5122 | extra_index += @boolToInt(small.has_addrspace); | ||
| 5082 | const ret_ty_body = zir.extra[extra_index..][0..extra.data.ret_body_len]; | 5123 | const ret_ty_body = zir.extra[extra_index..][0..extra.data.ret_body_len]; |
| 5083 | extra_index += ret_ty_body.len; | 5124 | extra_index += ret_ty_body.len; |
| 5084 | const body = zir.extra[extra_index..][0..extra.data.body_len]; | 5125 | const body = zir.extra[extra_index..][0..extra.data.body_len]; |
src/translate_c/ast.zig+2| ... | @@ -2706,6 +2706,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { | ... | @@ -2706,6 +2706,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { |
| 2706 | .lhs = try c.addExtra(std.zig.Ast.Node.FnProtoOne{ | 2706 | .lhs = try c.addExtra(std.zig.Ast.Node.FnProtoOne{ |
| 2707 | .param = params.items[0], | 2707 | .param = params.items[0], |
| 2708 | .align_expr = align_expr, | 2708 | .align_expr = align_expr, |
| 2709 | .addrspace_expr = 0, // TODO | ||
| 2709 | .section_expr = section_expr, | 2710 | .section_expr = section_expr, |
| 2710 | .callconv_expr = callconv_expr, | 2711 | .callconv_expr = callconv_expr, |
| 2711 | }), | 2712 | }), |
| ... | @@ -2721,6 +2722,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { | ... | @@ -2721,6 +2722,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { |
| 2721 | .params_start = span.start, | 2722 | .params_start = span.start, |
| 2722 | .params_end = span.end, | 2723 | .params_end = span.end, |
| 2723 | .align_expr = align_expr, | 2724 | .align_expr = align_expr, |
| 2725 | .addrspace_expr = 0, // TODO | ||
| 2724 | .section_expr = section_expr, | 2726 | .section_expr = section_expr, |
| 2725 | .callconv_expr = callconv_expr, | 2727 | .callconv_expr = callconv_expr, |
| 2726 | }), | 2728 | }), |
src/type.zig+19| ... | @@ -127,6 +127,7 @@ pub const Type = extern union { | ... | @@ -127,6 +127,7 @@ pub const Type = extern union { |
| 127 | .atomic_order, | 127 | .atomic_order, |
| 128 | .atomic_rmw_op, | 128 | .atomic_rmw_op, |
| 129 | .calling_convention, | 129 | .calling_convention, |
| 130 | .address_space, | ||
| 130 | .float_mode, | 131 | .float_mode, |
| 131 | .reduce_op, | 132 | .reduce_op, |
| 132 | => return .Enum, | 133 | => return .Enum, |
| ... | @@ -746,6 +747,7 @@ pub const Type = extern union { | ... | @@ -746,6 +747,7 @@ pub const Type = extern union { |
| 746 | .atomic_order, | 747 | .atomic_order, |
| 747 | .atomic_rmw_op, | 748 | .atomic_rmw_op, |
| 748 | .calling_convention, | 749 | .calling_convention, |
| 750 | .address_space, | ||
| 749 | .float_mode, | 751 | .float_mode, |
| 750 | .reduce_op, | 752 | .reduce_op, |
| 751 | .call_options, | 753 | .call_options, |
| ... | @@ -958,6 +960,7 @@ pub const Type = extern union { | ... | @@ -958,6 +960,7 @@ pub const Type = extern union { |
| 958 | .atomic_order => return writer.writeAll("std.builtin.AtomicOrder"), | 960 | .atomic_order => return writer.writeAll("std.builtin.AtomicOrder"), |
| 959 | .atomic_rmw_op => return writer.writeAll("std.builtin.AtomicRmwOp"), | 961 | .atomic_rmw_op => return writer.writeAll("std.builtin.AtomicRmwOp"), |
| 960 | .calling_convention => return writer.writeAll("std.builtin.CallingConvention"), | 962 | .calling_convention => return writer.writeAll("std.builtin.CallingConvention"), |
| 963 | .address_space => return writer.writeAll("std.builtin.AddressSpace"), | ||
| 961 | .float_mode => return writer.writeAll("std.builtin.FloatMode"), | 964 | .float_mode => return writer.writeAll("std.builtin.FloatMode"), |
| 962 | .reduce_op => return writer.writeAll("std.builtin.ReduceOp"), | 965 | .reduce_op => return writer.writeAll("std.builtin.ReduceOp"), |
| 963 | .call_options => return writer.writeAll("std.builtin.CallOptions"), | 966 | .call_options => return writer.writeAll("std.builtin.CallOptions"), |
| ... | @@ -1186,6 +1189,7 @@ pub const Type = extern union { | ... | @@ -1186,6 +1189,7 @@ pub const Type = extern union { |
| 1186 | .atomic_order, | 1189 | .atomic_order, |
| 1187 | .atomic_rmw_op, | 1190 | .atomic_rmw_op, |
| 1188 | .calling_convention, | 1191 | .calling_convention, |
| 1192 | .address_space, | ||
| 1189 | .float_mode, | 1193 | .float_mode, |
| 1190 | .reduce_op, | 1194 | .reduce_op, |
| 1191 | .call_options, | 1195 | .call_options, |
| ... | @@ -1301,6 +1305,7 @@ pub const Type = extern union { | ... | @@ -1301,6 +1305,7 @@ pub const Type = extern union { |
| 1301 | .atomic_order => return Value.initTag(.atomic_order_type), | 1305 | .atomic_order => return Value.initTag(.atomic_order_type), |
| 1302 | .atomic_rmw_op => return Value.initTag(.atomic_rmw_op_type), | 1306 | .atomic_rmw_op => return Value.initTag(.atomic_rmw_op_type), |
| 1303 | .calling_convention => return Value.initTag(.calling_convention_type), | 1307 | .calling_convention => return Value.initTag(.calling_convention_type), |
| 1308 | .address_space => return Value.initTag(.address_space_type), | ||
| 1304 | .float_mode => return Value.initTag(.float_mode_type), | 1309 | .float_mode => return Value.initTag(.float_mode_type), |
| 1305 | .reduce_op => return Value.initTag(.reduce_op_type), | 1310 | .reduce_op => return Value.initTag(.reduce_op_type), |
| 1306 | .call_options => return Value.initTag(.call_options_type), | 1311 | .call_options => return Value.initTag(.call_options_type), |
| ... | @@ -1362,6 +1367,7 @@ pub const Type = extern union { | ... | @@ -1362,6 +1367,7 @@ pub const Type = extern union { |
| 1362 | .atomic_order, | 1367 | .atomic_order, |
| 1363 | .atomic_rmw_op, | 1368 | .atomic_rmw_op, |
| 1364 | .calling_convention, | 1369 | .calling_convention, |
| 1370 | .address_space, | ||
| 1365 | .float_mode, | 1371 | .float_mode, |
| 1366 | .reduce_op, | 1372 | .reduce_op, |
| 1367 | .call_options, | 1373 | .call_options, |
| ... | @@ -1508,6 +1514,7 @@ pub const Type = extern union { | ... | @@ -1508,6 +1514,7 @@ pub const Type = extern union { |
| 1508 | .atomic_order, | 1514 | .atomic_order, |
| 1509 | .atomic_rmw_op, | 1515 | .atomic_rmw_op, |
| 1510 | .calling_convention, | 1516 | .calling_convention, |
| 1517 | .address_space, | ||
| 1511 | .float_mode, | 1518 | .float_mode, |
| 1512 | .reduce_op, | 1519 | .reduce_op, |
| 1513 | .call_options, | 1520 | .call_options, |
| ... | @@ -1734,6 +1741,7 @@ pub const Type = extern union { | ... | @@ -1734,6 +1741,7 @@ pub const Type = extern union { |
| 1734 | .atomic_order, | 1741 | .atomic_order, |
| 1735 | .atomic_rmw_op, | 1742 | .atomic_rmw_op, |
| 1736 | .calling_convention, | 1743 | .calling_convention, |
| 1744 | .address_space, | ||
| 1737 | .float_mode, | 1745 | .float_mode, |
| 1738 | .reduce_op, | 1746 | .reduce_op, |
| 1739 | .call_options, | 1747 | .call_options, |
| ... | @@ -2018,6 +2026,7 @@ pub const Type = extern union { | ... | @@ -2018,6 +2026,7 @@ pub const Type = extern union { |
| 2018 | .atomic_order, | 2026 | .atomic_order, |
| 2019 | .atomic_rmw_op, | 2027 | .atomic_rmw_op, |
| 2020 | .calling_convention, | 2028 | .calling_convention, |
| 2029 | .address_space, | ||
| 2021 | .float_mode, | 2030 | .float_mode, |
| 2022 | .reduce_op, | 2031 | .reduce_op, |
| 2023 | .call_options, | 2032 | .call_options, |
| ... | @@ -2775,6 +2784,7 @@ pub const Type = extern union { | ... | @@ -2775,6 +2784,7 @@ pub const Type = extern union { |
| 2775 | .atomic_order, | 2784 | .atomic_order, |
| 2776 | .atomic_rmw_op, | 2785 | .atomic_rmw_op, |
| 2777 | .calling_convention, | 2786 | .calling_convention, |
| 2787 | .address_space, | ||
| 2778 | .float_mode, | 2788 | .float_mode, |
| 2779 | .reduce_op, | 2789 | .reduce_op, |
| 2780 | .call_options, | 2790 | .call_options, |
| ... | @@ -2982,6 +2992,7 @@ pub const Type = extern union { | ... | @@ -2982,6 +2992,7 @@ pub const Type = extern union { |
| 2982 | .atomic_order, | 2992 | .atomic_order, |
| 2983 | .atomic_rmw_op, | 2993 | .atomic_rmw_op, |
| 2984 | .calling_convention, | 2994 | .calling_convention, |
| 2995 | .address_space, | ||
| 2985 | .float_mode, | 2996 | .float_mode, |
| 2986 | .reduce_op, | 2997 | .reduce_op, |
| 2987 | .call_options, | 2998 | .call_options, |
| ... | @@ -3006,6 +3017,7 @@ pub const Type = extern union { | ... | @@ -3006,6 +3017,7 @@ pub const Type = extern union { |
| 3006 | .atomic_order, | 3017 | .atomic_order, |
| 3007 | .atomic_rmw_op, | 3018 | .atomic_rmw_op, |
| 3008 | .calling_convention, | 3019 | .calling_convention, |
| 3020 | .address_space, | ||
| 3009 | .float_mode, | 3021 | .float_mode, |
| 3010 | .reduce_op, | 3022 | .reduce_op, |
| 3011 | .call_options, | 3023 | .call_options, |
| ... | @@ -3029,6 +3041,7 @@ pub const Type = extern union { | ... | @@ -3029,6 +3041,7 @@ pub const Type = extern union { |
| 3029 | .atomic_order, | 3041 | .atomic_order, |
| 3030 | .atomic_rmw_op, | 3042 | .atomic_rmw_op, |
| 3031 | .calling_convention, | 3043 | .calling_convention, |
| 3044 | .address_space, | ||
| 3032 | .float_mode, | 3045 | .float_mode, |
| 3033 | .reduce_op, | 3046 | .reduce_op, |
| 3034 | .call_options, | 3047 | .call_options, |
| ... | @@ -3082,6 +3095,7 @@ pub const Type = extern union { | ... | @@ -3082,6 +3095,7 @@ pub const Type = extern union { |
| 3082 | .atomic_order, | 3095 | .atomic_order, |
| 3083 | .atomic_rmw_op, | 3096 | .atomic_rmw_op, |
| 3084 | .calling_convention, | 3097 | .calling_convention, |
| 3098 | .address_space, | ||
| 3085 | .float_mode, | 3099 | .float_mode, |
| 3086 | .reduce_op, | 3100 | .reduce_op, |
| 3087 | .call_options, | 3101 | .call_options, |
| ... | @@ -3137,6 +3151,7 @@ pub const Type = extern union { | ... | @@ -3137,6 +3151,7 @@ pub const Type = extern union { |
| 3137 | .atomic_order, | 3151 | .atomic_order, |
| 3138 | .atomic_rmw_op, | 3152 | .atomic_rmw_op, |
| 3139 | .calling_convention, | 3153 | .calling_convention, |
| 3154 | .address_space, | ||
| 3140 | .float_mode, | 3155 | .float_mode, |
| 3141 | .reduce_op, | 3156 | .reduce_op, |
| 3142 | .call_options, | 3157 | .call_options, |
| ... | @@ -3174,6 +3189,7 @@ pub const Type = extern union { | ... | @@ -3174,6 +3189,7 @@ pub const Type = extern union { |
| 3174 | .atomic_order, | 3189 | .atomic_order, |
| 3175 | .atomic_rmw_op, | 3190 | .atomic_rmw_op, |
| 3176 | .calling_convention, | 3191 | .calling_convention, |
| 3192 | .address_space, | ||
| 3177 | .float_mode, | 3193 | .float_mode, |
| 3178 | .reduce_op, | 3194 | .reduce_op, |
| 3179 | .call_options, | 3195 | .call_options, |
| ... | @@ -3224,6 +3240,7 @@ pub const Type = extern union { | ... | @@ -3224,6 +3240,7 @@ pub const Type = extern union { |
| 3224 | .atomic_order, | 3240 | .atomic_order, |
| 3225 | .atomic_rmw_op, | 3241 | .atomic_rmw_op, |
| 3226 | .calling_convention, | 3242 | .calling_convention, |
| 3243 | .address_space, | ||
| 3227 | .float_mode, | 3244 | .float_mode, |
| 3228 | .reduce_op, | 3245 | .reduce_op, |
| 3229 | .call_options, | 3246 | .call_options, |
| ... | @@ -3284,6 +3301,7 @@ pub const Type = extern union { | ... | @@ -3284,6 +3301,7 @@ pub const Type = extern union { |
| 3284 | atomic_order, | 3301 | atomic_order, |
| 3285 | atomic_rmw_op, | 3302 | atomic_rmw_op, |
| 3286 | calling_convention, | 3303 | calling_convention, |
| 3304 | address_space, | ||
| 3287 | float_mode, | 3305 | float_mode, |
| 3288 | reduce_op, | 3306 | reduce_op, |
| 3289 | call_options, | 3307 | call_options, |
| ... | @@ -3407,6 +3425,7 @@ pub const Type = extern union { | ... | @@ -3407,6 +3425,7 @@ pub const Type = extern union { |
| 3407 | .atomic_order, | 3425 | .atomic_order, |
| 3408 | .atomic_rmw_op, | 3426 | .atomic_rmw_op, |
| 3409 | .calling_convention, | 3427 | .calling_convention, |
| 3428 | .address_space, | ||
| 3410 | .float_mode, | 3429 | .float_mode, |
| 3411 | .reduce_op, | 3430 | .reduce_op, |
| 3412 | .call_options, | 3431 | .call_options, |
src/value.zig+5| ... | @@ -63,6 +63,7 @@ pub const Value = extern union { | ... | @@ -63,6 +63,7 @@ pub const Value = extern union { |
| 63 | atomic_order_type, | 63 | atomic_order_type, |
| 64 | atomic_rmw_op_type, | 64 | atomic_rmw_op_type, |
| 65 | calling_convention_type, | 65 | calling_convention_type, |
| 66 | address_space_type, | ||
| 66 | float_mode_type, | 67 | float_mode_type, |
| 67 | reduce_op_type, | 68 | reduce_op_type, |
| 68 | call_options_type, | 69 | call_options_type, |
| ... | @@ -226,6 +227,7 @@ pub const Value = extern union { | ... | @@ -226,6 +227,7 @@ pub const Value = extern union { |
| 226 | .atomic_order_type, | 227 | .atomic_order_type, |
| 227 | .atomic_rmw_op_type, | 228 | .atomic_rmw_op_type, |
| 228 | .calling_convention_type, | 229 | .calling_convention_type, |
| 230 | .address_space_type, | ||
| 229 | .float_mode_type, | 231 | .float_mode_type, |
| 230 | .reduce_op_type, | 232 | .reduce_op_type, |
| 231 | .call_options_type, | 233 | .call_options_type, |
| ... | @@ -412,6 +414,7 @@ pub const Value = extern union { | ... | @@ -412,6 +414,7 @@ pub const Value = extern union { |
| 412 | .atomic_order_type, | 414 | .atomic_order_type, |
| 413 | .atomic_rmw_op_type, | 415 | .atomic_rmw_op_type, |
| 414 | .calling_convention_type, | 416 | .calling_convention_type, |
| 417 | .address_space_type, | ||
| 415 | .float_mode_type, | 418 | .float_mode_type, |
| 416 | .reduce_op_type, | 419 | .reduce_op_type, |
| 417 | .call_options_type, | 420 | .call_options_type, |
| ... | @@ -625,6 +628,7 @@ pub const Value = extern union { | ... | @@ -625,6 +628,7 @@ pub const Value = extern union { |
| 625 | .atomic_order_type => return out_stream.writeAll("std.builtin.AtomicOrder"), | 628 | .atomic_order_type => return out_stream.writeAll("std.builtin.AtomicOrder"), |
| 626 | .atomic_rmw_op_type => return out_stream.writeAll("std.builtin.AtomicRmwOp"), | 629 | .atomic_rmw_op_type => return out_stream.writeAll("std.builtin.AtomicRmwOp"), |
| 627 | .calling_convention_type => return out_stream.writeAll("std.builtin.CallingConvention"), | 630 | .calling_convention_type => return out_stream.writeAll("std.builtin.CallingConvention"), |
| 631 | .address_space_type => return out_stream.writeAll("std.builtin.AddressSpace"), | ||
| 628 | .float_mode_type => return out_stream.writeAll("std.builtin.FloatMode"), | 632 | .float_mode_type => return out_stream.writeAll("std.builtin.FloatMode"), |
| 629 | .reduce_op_type => return out_stream.writeAll("std.builtin.ReduceOp"), | 633 | .reduce_op_type => return out_stream.writeAll("std.builtin.ReduceOp"), |
| 630 | .call_options_type => return out_stream.writeAll("std.builtin.CallOptions"), | 634 | .call_options_type => return out_stream.writeAll("std.builtin.CallOptions"), |
| ... | @@ -792,6 +796,7 @@ pub const Value = extern union { | ... | @@ -792,6 +796,7 @@ pub const Value = extern union { |
| 792 | .atomic_order_type => Type.initTag(.atomic_order), | 796 | .atomic_order_type => Type.initTag(.atomic_order), |
| 793 | .atomic_rmw_op_type => Type.initTag(.atomic_rmw_op), | 797 | .atomic_rmw_op_type => Type.initTag(.atomic_rmw_op), |
| 794 | .calling_convention_type => Type.initTag(.calling_convention), | 798 | .calling_convention_type => Type.initTag(.calling_convention), |
| 799 | .address_space_type => Type.initTag(.address_space), | ||
| 795 | .float_mode_type => Type.initTag(.float_mode), | 800 | .float_mode_type => Type.initTag(.float_mode), |
| 796 | .reduce_op_type => Type.initTag(.reduce_op), | 801 | .reduce_op_type => Type.initTag(.reduce_op), |
| 797 | .call_options_type => Type.initTag(.call_options), | 802 | .call_options_type => Type.initTag(.call_options), |