| ... | @@ -204,6 +204,8 @@ pub const Feature = enum { | ... | @@ -204,6 +204,8 @@ pub const Feature = enum { |
| 204 | expand_array_splat, | 204 | expand_array_splat, |
| 205 | /// Replace `array_to_vector` with an `array_elem_val` per element followed by an `aggregate_init`. | 205 | /// Replace `array_to_vector` with an `array_elem_val` per element followed by an `aggregate_init`. |
| 206 | expand_array_to_vector, | 206 | expand_array_to_vector, |
| | 207 | /// Replace `ptr_elem_val` with an `ptr_elem_ptr` followed by a `load`. |
| | 208 | expand_ptr_elem_val, |
| 207 | | 209 | |
| 208 | /// Replace all arithmetic operations on 16-bit floating-point types with calls to soft-float | 210 | /// Replace all arithmetic operations on 16-bit floating-point types with calls to soft-float |
| 209 | /// routines in compiler_rt, including `fptrunc`/`fpext`/`float_from_int`/`int_from_float` | 211 | /// routines in compiler_rt, including `fptrunc`/`fpext`/`float_from_int`/`int_from_float` |
| ... | @@ -863,10 +865,12 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { | ... | @@ -863,10 +865,12 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { |
| 863 | .array_elem_val, | 865 | .array_elem_val, |
| 864 | .slice_elem_val, | 866 | .slice_elem_val, |
| 865 | .slice_elem_ptr, | 867 | .slice_elem_ptr, |
| 866 | .ptr_elem_val, | | |
| 867 | .ptr_elem_ptr, | 868 | .ptr_elem_ptr, |
| 868 | .array_to_slice, | 869 | .array_to_slice, |
| 869 | => {}, | 870 | => {}, |
| | 871 | .ptr_elem_val => if (l.features.has(.expand_ptr_elem_val)) { |
| | 872 | continue :inst l.replaceInst(inst, .block, try l.ptrElemValBlockPayload(inst)); |
| | 873 | }, |
| 870 | .array_to_vector => if (l.features.has(.expand_array_to_vector)) { | 874 | .array_to_vector => if (l.features.has(.expand_array_to_vector)) { |
| 871 | continue :inst l.replaceInst(inst, .block, try l.arrayToVectorBlockPayload(inst)); | 875 | continue :inst l.replaceInst(inst, .block, try l.arrayToVectorBlockPayload(inst)); |
| 872 | }, | 876 | }, |
| ... | @@ -2973,6 +2977,46 @@ fn packedAggregateInitBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Erro | ... | @@ -2973,6 +2977,46 @@ fn packedAggregateInitBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Erro |
| 2973 | } }; | 2977 | } }; |
| 2974 | } | 2978 | } |
| 2975 | | 2979 | |
| | 2980 | fn ptrElemValBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.Inst.Data { |
| | 2981 | const pt = l.pt; |
| | 2982 | const zcu = pt.zcu; |
| | 2983 | const gpa = zcu.gpa; |
| | 2984 | |
| | 2985 | const orig_bin_op = l.air_instructions.items(.data)[@backingInt(orig_inst)].bin_op; |
| | 2986 | |
| | 2987 | const ptr_val = orig_bin_op.lhs; |
| | 2988 | const ptr_ty = try l.typeOf(ptr_val).elemPtrType(null, pt); |
| | 2989 | const val_ty = ptr_ty.childType(zcu); |
| | 2990 | |
| | 2991 | var inst_buf: [3]Air.Inst.Index = undefined; |
| | 2992 | var main_block: Block = .init(&inst_buf); |
| | 2993 | try l.air_instructions.ensureUnusedCapacity(gpa, inst_buf.len); |
| | 2994 | |
| | 2995 | const ptr = main_block.add(l, .{ |
| | 2996 | .tag = .ptr_elem_ptr, |
| | 2997 | .data = .{ |
| | 2998 | .ty_pl = .{ |
| | 2999 | .ty = ptr_ty, |
| | 3000 | .payload = try l.addExtra(Air.Bin, .{ |
| | 3001 | .lhs = ptr_val, |
| | 3002 | .rhs = orig_bin_op.rhs, |
| | 3003 | }), |
| | 3004 | }, |
| | 3005 | }, |
| | 3006 | }).toRef(); |
| | 3007 | |
| | 3008 | const val = main_block.addTyOp(l, .load, val_ty, ptr).toRef(); |
| | 3009 | |
| | 3010 | main_block.addBr(l, orig_inst, val); |
| | 3011 | |
| | 3012 | return .{ |
| | 3013 | .ty_pl = .{ |
| | 3014 | .ty = val_ty, |
| | 3015 | .payload = try l.addBlockBody(main_block.body()), |
| | 3016 | }, |
| | 3017 | }; |
| | 3018 | } |
| | 3019 | |
| 2976 | fn arrayToVectorBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.Inst.Data { | 3020 | fn arrayToVectorBlockPayload(l: *Legalize, orig_inst: Air.Inst.Index) Error!Air.Inst.Data { |
| 2977 | const pt = l.pt; | 3021 | const pt = l.pt; |
| 2978 | const zcu = pt.zcu; | 3022 | const zcu = pt.zcu; |