| ... | @@ -1117,9 +1117,10 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO | ... | @@ -1117,9 +1117,10 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO |
| 1117 | .float_to_int, | 1117 | .float_to_int, |
| 1118 | .fptrunc, | 1118 | .fptrunc, |
| 1119 | .fpext, | 1119 | .fpext, |
| 1120 | .ptrtoint, | | |
| 1121 | => try airSimpleCast(f, inst), | 1120 | => try airSimpleCast(f, inst), |
| 1122 | | 1121 | |
| | 1122 | .ptrtoint => try airPtrToInt(f, inst), |
| | 1123 | |
| 1123 | .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)), | 1124 | .atomic_store_unordered => try airAtomicStore(f, inst, toMemoryOrder(.Unordered)), |
| 1124 | .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)), | 1125 | .atomic_store_monotonic => try airAtomicStore(f, inst, toMemoryOrder(.Monotonic)), |
| 1125 | .atomic_store_release => try airAtomicStore(f, inst, toMemoryOrder(.Release)), | 1126 | .atomic_store_release => try airAtomicStore(f, inst, toMemoryOrder(.Release)), |
| ... | @@ -2264,15 +2265,18 @@ fn airWrapOptional(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -2264,15 +2265,18 @@ fn airWrapOptional(f: *Function, inst: Air.Inst.Index) !CValue { |
| 2264 | return local; | 2265 | return local; |
| 2265 | } | 2266 | } |
| 2266 | fn airWrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { | 2267 | fn airWrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue { |
| 2267 | if (f.liveness.isUnused(inst)) | 2268 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 2268 | return CValue.none; | | |
| 2269 | | 2269 | |
| 2270 | const writer = f.object.writer(); | 2270 | const writer = f.object.writer(); |
| 2271 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; | 2271 | const ty_op = f.air.instructions.items(.data)[inst].ty_op; |
| 2272 | const operand = try f.resolveInst(ty_op.operand); | 2272 | const operand = try f.resolveInst(ty_op.operand); |
| | 2273 | const err_un_ty = f.air.typeOfIndex(inst); |
| | 2274 | const payload_ty = err_un_ty.errorUnionPayload(); |
| | 2275 | if (!payload_ty.hasCodeGenBits()) { |
| | 2276 | return operand; |
| | 2277 | } |
| 2273 | | 2278 | |
| 2274 | const inst_ty = f.air.typeOfIndex(inst); | 2279 | const local = try f.allocLocal(err_un_ty, .Const); |
| 2275 | const local = try f.allocLocal(inst_ty, .Const); | | |
| 2276 | try writer.writeAll(" = { .error = "); | 2280 | try writer.writeAll(" = { .error = "); |
| 2277 | try f.writeCValue(writer, operand); | 2281 | try f.writeCValue(writer, operand); |
| 2278 | try writer.writeAll(" };\n"); | 2282 | try writer.writeAll(" };\n"); |
| ... | @@ -2343,8 +2347,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -2343,8 +2347,7 @@ fn airArrayToSlice(f: *Function, inst: Air.Inst.Index) !CValue { |
| 2343 | /// Emits a local variable with the result type and initializes it | 2347 | /// Emits a local variable with the result type and initializes it |
| 2344 | /// with the operand. | 2348 | /// with the operand. |
| 2345 | fn airSimpleCast(f: *Function, inst: Air.Inst.Index) !CValue { | 2349 | fn airSimpleCast(f: *Function, inst: Air.Inst.Index) !CValue { |
| 2346 | if (f.liveness.isUnused(inst)) | 2350 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 2347 | return CValue.none; | | |
| 2348 | | 2351 | |
| 2349 | const inst_ty = f.air.typeOfIndex(inst); | 2352 | const inst_ty = f.air.typeOfIndex(inst); |
| 2350 | const local = try f.allocLocal(inst_ty, .Const); | 2353 | const local = try f.allocLocal(inst_ty, .Const); |
| ... | @@ -2358,6 +2361,21 @@ fn airSimpleCast(f: *Function, inst: Air.Inst.Index) !CValue { | ... | @@ -2358,6 +2361,21 @@ fn airSimpleCast(f: *Function, inst: Air.Inst.Index) !CValue { |
| 2358 | return local; | 2361 | return local; |
| 2359 | } | 2362 | } |
| 2360 | | 2363 | |
| | 2364 | fn airPtrToInt(f: *Function, inst: Air.Inst.Index) !CValue { |
| | 2365 | if (f.liveness.isUnused(inst)) return CValue.none; |
| | 2366 | |
| | 2367 | const inst_ty = f.air.typeOfIndex(inst); |
| | 2368 | const local = try f.allocLocal(inst_ty, .Const); |
| | 2369 | const un_op = f.air.instructions.items(.data)[inst].un_op; |
| | 2370 | const writer = f.object.writer(); |
| | 2371 | const operand = try f.resolveInst(un_op); |
| | 2372 | |
| | 2373 | try writer.writeAll(" = "); |
| | 2374 | try f.writeCValue(writer, operand); |
| | 2375 | try writer.writeAll(";\n"); |
| | 2376 | return local; |
| | 2377 | } |
| | 2378 | |
| 2361 | fn airBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8) !CValue { | 2379 | fn airBuiltinCall(f: *Function, inst: Air.Inst.Index, fn_name: [*:0]const u8) !CValue { |
| 2362 | if (f.liveness.isUnused(inst)) return CValue.none; | 2380 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 2363 | | 2381 | |