| ... | @@ -110,10 +110,19 @@ pub const Tag = enum { | ... | @@ -110,10 +110,19 @@ pub const Tag = enum { |
| 110 | Vector, | 110 | Vector, |
| 111 | }; | 111 | }; |
| 112 | | 112 | |
| | 113 | pub const MemLocRequirement = enum { |
| | 114 | /// The builtin never needs a memory location. |
| | 115 | never, |
| | 116 | /// The builtin always needs a memory location. |
| | 117 | always, |
| | 118 | /// The builtin forwards the question to argument at index 1. |
| | 119 | forward1, |
| | 120 | }; |
| | 121 | |
| 113 | tag: Tag, | 122 | tag: Tag, |
| 114 | | 123 | |
| 115 | /// `true` if the builtin call can take advantage of a result location pointer. | 124 | /// Info about the builtin call's ability to take advantage of a result location pointer. |
| 116 | needs_mem_loc: bool = false, | 125 | needs_mem_loc: MemLocRequirement = .never, |
| 117 | /// `true` if the builtin call can be the left-hand side of an expression (assigned to). | 126 | /// `true` if the builtin call can be the left-hand side of an expression (assigned to). |
| 118 | allows_lvalue: bool = false, | 127 | allows_lvalue: bool = false, |
| 119 | /// The number of parameters to this builtin function. `null` means variable number | 128 | /// The number of parameters to this builtin function. `null` means variable number |
| ... | @@ -148,7 +157,7 @@ pub const list = list: { | ... | @@ -148,7 +157,7 @@ pub const list = list: { |
| 148 | "@as", | 157 | "@as", |
| 149 | .{ | 158 | .{ |
| 150 | .tag = .as, | 159 | .tag = .as, |
| 151 | .needs_mem_loc = true, | 160 | .needs_mem_loc = .forward1, |
| 152 | .param_count = 2, | 161 | .param_count = 2, |
| 153 | }, | 162 | }, |
| 154 | }, | 163 | }, |
| ... | @@ -184,7 +193,7 @@ pub const list = list: { | ... | @@ -184,7 +193,7 @@ pub const list = list: { |
| 184 | "@bitCast", | 193 | "@bitCast", |
| 185 | .{ | 194 | .{ |
| 186 | .tag = .bit_cast, | 195 | .tag = .bit_cast, |
| 187 | .needs_mem_loc = true, | 196 | .needs_mem_loc = .forward1, |
| 188 | .param_count = 2, | 197 | .param_count = 2, |
| 189 | }, | 198 | }, |
| 190 | }, | 199 | }, |
| ... | @@ -248,7 +257,7 @@ pub const list = list: { | ... | @@ -248,7 +257,7 @@ pub const list = list: { |
| 248 | "@call", | 257 | "@call", |
| 249 | .{ | 258 | .{ |
| 250 | .tag = .call, | 259 | .tag = .call, |
| 251 | .needs_mem_loc = true, | 260 | .needs_mem_loc = .always, |
| 252 | .param_count = 3, | 261 | .param_count = 3, |
| 253 | }, | 262 | }, |
| 254 | }, | 263 | }, |
| ... | @@ -410,7 +419,7 @@ pub const list = list: { | ... | @@ -410,7 +419,7 @@ pub const list = list: { |
| 410 | "@field", | 419 | "@field", |
| 411 | .{ | 420 | .{ |
| 412 | .tag = .field, | 421 | .tag = .field, |
| 413 | .needs_mem_loc = true, | 422 | .needs_mem_loc = .always, |
| 414 | .param_count = 2, | 423 | .param_count = 2, |
| 415 | .allows_lvalue = true, | 424 | .allows_lvalue = true, |
| 416 | }, | 425 | }, |
| ... | @@ -699,7 +708,6 @@ pub const list = list: { | ... | @@ -699,7 +708,6 @@ pub const list = list: { |
| 699 | "@splat", | 708 | "@splat", |
| 700 | .{ | 709 | .{ |
| 701 | .tag = .splat, | 710 | .tag = .splat, |
| 702 | .needs_mem_loc = true, | | |
| 703 | .param_count = 2, | 711 | .param_count = 2, |
| 704 | }, | 712 | }, |
| 705 | }, | 713 | }, |
| ... | @@ -714,7 +722,7 @@ pub const list = list: { | ... | @@ -714,7 +722,7 @@ pub const list = list: { |
| 714 | "@src", | 722 | "@src", |
| 715 | .{ | 723 | .{ |
| 716 | .tag = .src, | 724 | .tag = .src, |
| 717 | .needs_mem_loc = true, | 725 | .needs_mem_loc = .always, |
| 718 | .param_count = 0, | 726 | .param_count = 0, |
| 719 | }, | 727 | }, |
| 720 | }, | 728 | }, |
| ... | @@ -869,7 +877,7 @@ pub const list = list: { | ... | @@ -869,7 +877,7 @@ pub const list = list: { |
| 869 | "@unionInit", | 877 | "@unionInit", |
| 870 | .{ | 878 | .{ |
| 871 | .tag = .union_init, | 879 | .tag = .union_init, |
| 872 | .needs_mem_loc = true, | 880 | .needs_mem_loc = .always, |
| 873 | .param_count = 3, | 881 | .param_count = 3, |
| 874 | }, | 882 | }, |
| 875 | }, | 883 | }, |