| ... | ... | @@ -7697,6 +7697,7 @@ pub const MetadataString = enum(u32) { |
| 7697 | 7697 | |
| 7698 | 7698 | pub const Metadata = enum(u32) { |
| 7699 | 7699 | none = 0, |
| 7700 | empty_tuple = 1, |
| 7700 | 7701 | _, |
| 7701 | 7702 | |
| 7702 | 7703 | const first_forward_reference = 1 << 29; |
| ... | ... | @@ -8355,7 +8356,7 @@ pub const Metadata = enum(u32) { |
| 8355 | 8356 | }; |
| 8356 | 8357 | |
| 8357 | 8358 | pub fn init(options: Options) Allocator.Error!Builder { |
| 8358 | | var self = Builder{ |
| 8359 | var self: Builder = .{ |
| 8359 | 8360 | .gpa = options.allocator, |
| 8360 | 8361 | .strip = options.strip, |
| 8361 | 8362 | |
| ... | ... | @@ -8458,6 +8459,7 @@ pub fn init(options: Options) Allocator.Error!Builder { |
| 8458 | 8459 | |
| 8459 | 8460 | try self.metadata_string_indices.append(self.gpa, 0); |
| 8460 | 8461 | assert(try self.metadataString("") == .none); |
| 8462 | assert(try self.debugTuple(&.{}) == .empty_tuple); |
| 8461 | 8463 | |
| 8462 | 8464 | return self; |
| 8463 | 8465 | } |
| ... | ... | @@ -13759,7 +13761,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 13759 | 13761 | const MetadataKindBlock = ir.MetadataKindBlock; |
| 13760 | 13762 | var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true); |
| 13761 | 13763 | |
| 13762 | | inline for (@typeInfo(ir.MetadataKind).Enum.fields) |field| { |
| 13764 | inline for (@typeInfo(ir.FixedMetadataKind).Enum.fields) |field| { |
| 13763 | 13765 | try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{ |
| 13764 | 13766 | .id = field.value, |
| 13765 | 13767 | .name = field.name, |
| ... | ... | @@ -14046,7 +14048,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14046 | 14048 | else |
| 14047 | 14049 | -%val << 1 | 1); |
| 14048 | 14050 | } |
| 14049 | | try metadata_block.writeUnabbrev(MetadataBlock.Enumerator.id, record.items); |
| 14051 | try metadata_block.writeUnabbrev(@intFromEnum(MetadataBlock.Enumerator.id), record.items); |
| 14050 | 14052 | continue; |
| 14051 | 14053 | }; |
| 14052 | 14054 | try metadata_block.writeAbbrevAdapted(MetadataBlock.Enumerator{ |
| ... | ... | @@ -14177,7 +14179,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14177 | 14179 | |
| 14178 | 14180 | try metadata_block.writeAbbrev(MetadataBlock.GlobalDeclAttachment{ |
| 14179 | 14181 | .value = @enumFromInt(constant_adapter.getConstantIndex(global.toConst())), |
| 14180 | | .kind = ir.MetadataKind.dbg, |
| 14182 | .kind = .dbg, |
| 14181 | 14183 | .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(global_ptr.dbg) - 1), |
| 14182 | 14184 | }); |
| 14183 | 14185 | } |
| ... | ... | @@ -14220,20 +14222,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14220 | 14222 | constant_adapter: ConstantAdapter, |
| 14221 | 14223 | metadata_adapter: MetadataAdapter, |
| 14222 | 14224 | func: *const Function, |
| 14223 | | instruction_index: u32 = 0, |
| 14224 | | |
| 14225 | | pub fn init( |
| 14226 | | const_adapter: ConstantAdapter, |
| 14227 | | meta_adapter: MetadataAdapter, |
| 14228 | | func: *const Function, |
| 14229 | | ) @This() { |
| 14230 | | return .{ |
| 14231 | | .constant_adapter = const_adapter, |
| 14232 | | .metadata_adapter = meta_adapter, |
| 14233 | | .func = func, |
| 14234 | | .instruction_index = 0, |
| 14235 | | }; |
| 14236 | | } |
| 14225 | instruction_index: Function.Instruction.Index, |
| 14237 | 14226 | |
| 14238 | 14227 | pub fn get(adapter: @This(), value: anytype, comptime field_name: []const u8) @TypeOf(value) { |
| 14239 | 14228 | _ = field_name; |
| ... | ... | @@ -14282,19 +14271,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14282 | 14271 | } |
| 14283 | 14272 | |
| 14284 | 14273 | pub fn offset(adapter: @This()) u32 { |
| 14285 | | return @as( |
| 14286 | | Function.Instruction.Index, |
| 14287 | | @enumFromInt(adapter.instruction_index), |
| 14288 | | ).valueIndex(adapter.func) + adapter.firstInstr(); |
| 14274 | return adapter.instruction_index.valueIndex(adapter.func) + adapter.firstInstr(); |
| 14289 | 14275 | } |
| 14290 | 14276 | |
| 14291 | 14277 | fn firstInstr(adapter: @This()) u32 { |
| 14292 | 14278 | return adapter.constant_adapter.numConstants(); |
| 14293 | 14279 | } |
| 14294 | | |
| 14295 | | pub fn next(adapter: *@This()) void { |
| 14296 | | adapter.instruction_index += 1; |
| 14297 | | } |
| 14298 | 14280 | }; |
| 14299 | 14281 | |
| 14300 | 14282 | for (self.functions.items, 0..) |func, func_index| { |
| ... | ... | @@ -14307,7 +14289,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14307 | 14289 | |
| 14308 | 14290 | try function_block.writeAbbrev(FunctionBlock.DeclareBlocks{ .num_blocks = func.blocks.len }); |
| 14309 | 14291 | |
| 14310 | | var adapter = FunctionAdapter.init(constant_adapter, metadata_adapter, &func); |
| 14292 | var adapter: FunctionAdapter = .{ |
| 14293 | .constant_adapter = constant_adapter, |
| 14294 | .metadata_adapter = metadata_adapter, |
| 14295 | .func = &func, |
| 14296 | .instruction_index = @enumFromInt(0), |
| 14297 | }; |
| 14311 | 14298 | |
| 14312 | 14299 | // Emit function level metadata block |
| 14313 | 14300 | if (!func.strip and func.debug_values.len > 0) { |
| ... | ... | @@ -14330,21 +14317,23 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14330 | 14317 | var has_location = false; |
| 14331 | 14318 | |
| 14332 | 14319 | var block_incoming_len: u32 = undefined; |
| 14333 | | for (0..func.instructions.len) |instr_index| { |
| 14334 | | const tag = tags[instr_index]; |
| 14335 | | |
| 14320 | for (tags, datas, 0..) |tag, data, instr_index| { |
| 14321 | adapter.instruction_index = @enumFromInt(instr_index); |
| 14336 | 14322 | record.clearRetainingCapacity(); |
| 14337 | 14323 | |
| 14338 | 14324 | switch (tag) { |
| 14339 | | .block => block_incoming_len = datas[instr_index], |
| 14340 | | .arg => {}, |
| 14325 | .arg => continue, |
| 14326 | .block => { |
| 14327 | block_incoming_len = data; |
| 14328 | continue; |
| 14329 | }, |
| 14341 | 14330 | .@"unreachable" => try function_block.writeAbbrev(FunctionBlock.Unreachable{}), |
| 14342 | 14331 | .call, |
| 14343 | 14332 | .@"musttail call", |
| 14344 | 14333 | .@"notail call", |
| 14345 | 14334 | .@"tail call", |
| 14346 | 14335 | => |kind| { |
| 14347 | | var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]); |
| 14336 | var extra = func.extraDataTrail(Function.Instruction.Call, data); |
| 14348 | 14337 | |
| 14349 | 14338 | const call_conv = extra.data.info.call_conv; |
| 14350 | 14339 | const args = extra.trail.next(extra.data.args_len, Value, &func); |
| ... | ... | @@ -14367,7 +14356,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14367 | 14356 | .@"notail call fast", |
| 14368 | 14357 | .@"tail call fast", |
| 14369 | 14358 | => |kind| { |
| 14370 | | var extra = func.extraDataTrail(Function.Instruction.Call, datas[instr_index]); |
| 14359 | var extra = func.extraDataTrail(Function.Instruction.Call, data); |
| 14371 | 14360 | |
| 14372 | 14361 | const call_conv = extra.data.info.call_conv; |
| 14373 | 14362 | const args = extra.trail.next(extra.data.args_len, Value, &func); |
| ... | ... | @@ -14405,7 +14394,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14405 | 14394 | .srem, |
| 14406 | 14395 | .ashr, |
| 14407 | 14396 | => |kind| { |
| 14408 | | const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]); |
| 14397 | const extra = func.extraData(Function.Instruction.Binary, data); |
| 14409 | 14398 | try function_block.writeAbbrev(FunctionBlock.Binary{ |
| 14410 | 14399 | .opcode = kind.toBinaryOpcode(), |
| 14411 | 14400 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| ... | ... | @@ -14417,7 +14406,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14417 | 14406 | .@"lshr exact", |
| 14418 | 14407 | .@"ashr exact", |
| 14419 | 14408 | => |kind| { |
| 14420 | | const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]); |
| 14409 | const extra = func.extraData(Function.Instruction.Binary, data); |
| 14421 | 14410 | try function_block.writeAbbrev(FunctionBlock.BinaryExact{ |
| 14422 | 14411 | .opcode = kind.toBinaryOpcode(), |
| 14423 | 14412 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| ... | ... | @@ -14437,7 +14426,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14437 | 14426 | .@"shl nuw", |
| 14438 | 14427 | .@"shl nuw nsw", |
| 14439 | 14428 | => |kind| { |
| 14440 | | const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]); |
| 14429 | const extra = func.extraData(Function.Instruction.Binary, data); |
| 14441 | 14430 | try function_block.writeAbbrev(FunctionBlock.BinaryNoWrap{ |
| 14442 | 14431 | .opcode = kind.toBinaryOpcode(), |
| 14443 | 14432 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| ... | ... | @@ -14468,7 +14457,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14468 | 14457 | .@"frem fast", |
| 14469 | 14458 | .@"fsub fast", |
| 14470 | 14459 | => |kind| { |
| 14471 | | const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]); |
| 14460 | const extra = func.extraData(Function.Instruction.Binary, data); |
| 14472 | 14461 | try function_block.writeAbbrev(FunctionBlock.BinaryFast{ |
| 14473 | 14462 | .opcode = kind.toBinaryOpcode(), |
| 14474 | 14463 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| ... | ... | @@ -14479,7 +14468,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14479 | 14468 | .alloca, |
| 14480 | 14469 | .@"alloca inalloca", |
| 14481 | 14470 | => |kind| { |
| 14482 | | const extra = func.extraData(Function.Instruction.Alloca, datas[instr_index]); |
| 14471 | const extra = func.extraData(Function.Instruction.Alloca, data); |
| 14483 | 14472 | const alignment = extra.info.alignment.toLlvm(); |
| 14484 | 14473 | try function_block.writeAbbrev(FunctionBlock.Alloca{ |
| 14485 | 14474 | .inst_type = extra.type, |
| ... | ... | @@ -14508,7 +14497,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14508 | 14497 | .sext, |
| 14509 | 14498 | .zext, |
| 14510 | 14499 | => |kind| { |
| 14511 | | const extra = func.extraData(Function.Instruction.Cast, datas[instr_index]); |
| 14500 | const extra = func.extraData(Function.Instruction.Cast, data); |
| 14512 | 14501 | try function_block.writeAbbrev(FunctionBlock.Cast{ |
| 14513 | 14502 | .val = adapter.getOffsetValueIndex(extra.val), |
| 14514 | 14503 | .type_index = extra.type, |
| ... | ... | @@ -14542,7 +14531,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14542 | 14531 | .@"icmp ule", |
| 14543 | 14532 | .@"icmp ult", |
| 14544 | 14533 | => |kind| { |
| 14545 | | const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]); |
| 14534 | const extra = func.extraData(Function.Instruction.Binary, data); |
| 14546 | 14535 | try function_block.writeAbbrev(FunctionBlock.Cmp{ |
| 14547 | 14536 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| 14548 | 14537 | .rhs = adapter.getOffsetValueIndex(extra.rhs), |
| ... | ... | @@ -14566,7 +14555,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14566 | 14555 | .@"fcmp fast une", |
| 14567 | 14556 | .@"fcmp fast uno", |
| 14568 | 14557 | => |kind| { |
| 14569 | | const extra = func.extraData(Function.Instruction.Binary, datas[instr_index]); |
| 14558 | const extra = func.extraData(Function.Instruction.Binary, data); |
| 14570 | 14559 | try function_block.writeAbbrev(FunctionBlock.CmpFast{ |
| 14571 | 14560 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| 14572 | 14561 | .rhs = adapter.getOffsetValueIndex(extra.rhs), |
| ... | ... | @@ -14575,14 +14564,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14575 | 14564 | }); |
| 14576 | 14565 | }, |
| 14577 | 14566 | .fneg => try function_block.writeAbbrev(FunctionBlock.FNeg{ |
| 14578 | | .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])), |
| 14567 | .val = adapter.getOffsetValueIndex(@enumFromInt(data)), |
| 14579 | 14568 | }), |
| 14580 | 14569 | .@"fneg fast" => try function_block.writeAbbrev(FunctionBlock.FNegFast{ |
| 14581 | | .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])), |
| 14570 | .val = adapter.getOffsetValueIndex(@enumFromInt(data)), |
| 14582 | 14571 | .fast_math = FastMath.fast, |
| 14583 | 14572 | }), |
| 14584 | 14573 | .extractvalue => { |
| 14585 | | var extra = func.extraDataTrail(Function.Instruction.ExtractValue, datas[instr_index]); |
| 14574 | var extra = func.extraDataTrail(Function.Instruction.ExtractValue, data); |
| 14586 | 14575 | const indices = extra.trail.next(extra.data.indices_len, u32, &func); |
| 14587 | 14576 | try function_block.writeAbbrev(FunctionBlock.ExtractValue{ |
| 14588 | 14577 | .val = adapter.getOffsetValueIndex(extra.data.val), |
| ... | ... | @@ -14590,7 +14579,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14590 | 14579 | }); |
| 14591 | 14580 | }, |
| 14592 | 14581 | .insertvalue => { |
| 14593 | | var extra = func.extraDataTrail(Function.Instruction.InsertValue, datas[instr_index]); |
| 14582 | var extra = func.extraDataTrail(Function.Instruction.InsertValue, data); |
| 14594 | 14583 | const indices = extra.trail.next(extra.data.indices_len, u32, &func); |
| 14595 | 14584 | try function_block.writeAbbrev(FunctionBlock.InsertValue{ |
| 14596 | 14585 | .val = adapter.getOffsetValueIndex(extra.data.val), |
| ... | ... | @@ -14599,14 +14588,14 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14599 | 14588 | }); |
| 14600 | 14589 | }, |
| 14601 | 14590 | .extractelement => { |
| 14602 | | const extra = func.extraData(Function.Instruction.ExtractElement, datas[instr_index]); |
| 14591 | const extra = func.extraData(Function.Instruction.ExtractElement, data); |
| 14603 | 14592 | try function_block.writeAbbrev(FunctionBlock.ExtractElement{ |
| 14604 | 14593 | .val = adapter.getOffsetValueIndex(extra.val), |
| 14605 | 14594 | .index = adapter.getOffsetValueIndex(extra.index), |
| 14606 | 14595 | }); |
| 14607 | 14596 | }, |
| 14608 | 14597 | .insertelement => { |
| 14609 | | const extra = func.extraData(Function.Instruction.InsertElement, datas[instr_index]); |
| 14598 | const extra = func.extraData(Function.Instruction.InsertElement, data); |
| 14610 | 14599 | try function_block.writeAbbrev(FunctionBlock.InsertElement{ |
| 14611 | 14600 | .val = adapter.getOffsetValueIndex(extra.val), |
| 14612 | 14601 | .elem = adapter.getOffsetValueIndex(extra.elem), |
| ... | ... | @@ -14614,7 +14603,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14614 | 14603 | }); |
| 14615 | 14604 | }, |
| 14616 | 14605 | .select => { |
| 14617 | | const extra = func.extraData(Function.Instruction.Select, datas[instr_index]); |
| 14606 | const extra = func.extraData(Function.Instruction.Select, data); |
| 14618 | 14607 | try function_block.writeAbbrev(FunctionBlock.Select{ |
| 14619 | 14608 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| 14620 | 14609 | .rhs = adapter.getOffsetValueIndex(extra.rhs), |
| ... | ... | @@ -14622,7 +14611,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14622 | 14611 | }); |
| 14623 | 14612 | }, |
| 14624 | 14613 | .@"select fast" => { |
| 14625 | | const extra = func.extraData(Function.Instruction.Select, datas[instr_index]); |
| 14614 | const extra = func.extraData(Function.Instruction.Select, data); |
| 14626 | 14615 | try function_block.writeAbbrev(FunctionBlock.SelectFast{ |
| 14627 | 14616 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| 14628 | 14617 | .rhs = adapter.getOffsetValueIndex(extra.rhs), |
| ... | ... | @@ -14631,7 +14620,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14631 | 14620 | }); |
| 14632 | 14621 | }, |
| 14633 | 14622 | .shufflevector => { |
| 14634 | | const extra = func.extraData(Function.Instruction.ShuffleVector, datas[instr_index]); |
| 14623 | const extra = func.extraData(Function.Instruction.ShuffleVector, data); |
| 14635 | 14624 | try function_block.writeAbbrev(FunctionBlock.ShuffleVector{ |
| 14636 | 14625 | .lhs = adapter.getOffsetValueIndex(extra.lhs), |
| 14637 | 14626 | .rhs = adapter.getOffsetValueIndex(extra.rhs), |
| ... | ... | @@ -14641,7 +14630,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14641 | 14630 | .getelementptr, |
| 14642 | 14631 | .@"getelementptr inbounds", |
| 14643 | 14632 | => |kind| { |
| 14644 | | var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, datas[instr_index]); |
| 14633 | var extra = func.extraDataTrail(Function.Instruction.GetElementPtr, data); |
| 14645 | 14634 | const indices = extra.trail.next(extra.data.indices_len, Value, &func); |
| 14646 | 14635 | try function_block.writeAbbrevAdapted( |
| 14647 | 14636 | FunctionBlock.GetElementPtr{ |
| ... | ... | @@ -14654,7 +14643,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14654 | 14643 | ); |
| 14655 | 14644 | }, |
| 14656 | 14645 | .load => { |
| 14657 | | const extra = func.extraData(Function.Instruction.Load, datas[instr_index]); |
| 14646 | const extra = func.extraData(Function.Instruction.Load, data); |
| 14658 | 14647 | try function_block.writeAbbrev(FunctionBlock.Load{ |
| 14659 | 14648 | .ptr = adapter.getOffsetValueIndex(extra.ptr), |
| 14660 | 14649 | .ty = extra.type, |
| ... | ... | @@ -14663,7 +14652,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14663 | 14652 | }); |
| 14664 | 14653 | }, |
| 14665 | 14654 | .@"load atomic" => { |
| 14666 | | const extra = func.extraData(Function.Instruction.Load, datas[instr_index]); |
| 14655 | const extra = func.extraData(Function.Instruction.Load, data); |
| 14667 | 14656 | try function_block.writeAbbrev(FunctionBlock.LoadAtomic{ |
| 14668 | 14657 | .ptr = adapter.getOffsetValueIndex(extra.ptr), |
| 14669 | 14658 | .ty = extra.type, |
| ... | ... | @@ -14674,7 +14663,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14674 | 14663 | }); |
| 14675 | 14664 | }, |
| 14676 | 14665 | .store => { |
| 14677 | | const extra = func.extraData(Function.Instruction.Store, datas[instr_index]); |
| 14666 | const extra = func.extraData(Function.Instruction.Store, data); |
| 14678 | 14667 | try function_block.writeAbbrev(FunctionBlock.Store{ |
| 14679 | 14668 | .ptr = adapter.getOffsetValueIndex(extra.ptr), |
| 14680 | 14669 | .val = adapter.getOffsetValueIndex(extra.val), |
| ... | ... | @@ -14683,7 +14672,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14683 | 14672 | }); |
| 14684 | 14673 | }, |
| 14685 | 14674 | .@"store atomic" => { |
| 14686 | | const extra = func.extraData(Function.Instruction.Store, datas[instr_index]); |
| 14675 | const extra = func.extraData(Function.Instruction.Store, data); |
| 14687 | 14676 | try function_block.writeAbbrev(FunctionBlock.StoreAtomic{ |
| 14688 | 14677 | .ptr = adapter.getOffsetValueIndex(extra.ptr), |
| 14689 | 14678 | .val = adapter.getOffsetValueIndex(extra.val), |
| ... | ... | @@ -14695,11 +14684,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14695 | 14684 | }, |
| 14696 | 14685 | .br => { |
| 14697 | 14686 | try function_block.writeAbbrev(FunctionBlock.BrUnconditional{ |
| 14698 | | .block = datas[instr_index], |
| 14687 | .block = data, |
| 14699 | 14688 | }); |
| 14700 | 14689 | }, |
| 14701 | 14690 | .br_cond => { |
| 14702 | | const extra = func.extraData(Function.Instruction.BrCond, datas[instr_index]); |
| 14691 | const extra = func.extraData(Function.Instruction.BrCond, data); |
| 14703 | 14692 | try function_block.writeAbbrev(FunctionBlock.BrConditional{ |
| 14704 | 14693 | .then_block = @intFromEnum(extra.then), |
| 14705 | 14694 | .else_block = @intFromEnum(extra.@"else"), |
| ... | ... | @@ -14707,7 +14696,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14707 | 14696 | }); |
| 14708 | 14697 | }, |
| 14709 | 14698 | .@"switch" => { |
| 14710 | | var extra = func.extraDataTrail(Function.Instruction.Switch, datas[instr_index]); |
| 14699 | var extra = func.extraDataTrail(Function.Instruction.Switch, data); |
| 14711 | 14700 | |
| 14712 | 14701 | try record.ensureUnusedCapacity(self.gpa, 3 + extra.data.cases_len * 2); |
| 14713 | 14702 | |
| ... | ... | @@ -14730,7 +14719,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14730 | 14719 | try function_block.writeUnabbrev(12, record.items); |
| 14731 | 14720 | }, |
| 14732 | 14721 | .va_arg => { |
| 14733 | | const extra = func.extraData(Function.Instruction.VaArg, datas[instr_index]); |
| 14722 | const extra = func.extraData(Function.Instruction.VaArg, data); |
| 14734 | 14723 | try function_block.writeAbbrev(FunctionBlock.VaArg{ |
| 14735 | 14724 | .list_type = extra.list.typeOf(@enumFromInt(func_index), self), |
| 14736 | 14725 | .list = adapter.getOffsetValueIndex(extra.list), |
| ... | ... | @@ -14740,7 +14729,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14740 | 14729 | .phi, |
| 14741 | 14730 | .@"phi fast", |
| 14742 | 14731 | => |kind| { |
| 14743 | | var extra = func.extraDataTrail(Function.Instruction.Phi, datas[instr_index]); |
| 14732 | var extra = func.extraDataTrail(Function.Instruction.Phi, data); |
| 14744 | 14733 | const vals = extra.trail.next(block_incoming_len, Value, &func); |
| 14745 | 14734 | const blocks = extra.trail.next(block_incoming_len, Function.Block.Index, &func); |
| 14746 | 14735 | |
| ... | ... | @@ -14764,11 +14753,11 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14764 | 14753 | try function_block.writeUnabbrev(16, record.items); |
| 14765 | 14754 | }, |
| 14766 | 14755 | .ret => try function_block.writeAbbrev(FunctionBlock.Ret{ |
| 14767 | | .val = adapter.getOffsetValueIndex(@enumFromInt(datas[instr_index])), |
| 14756 | .val = adapter.getOffsetValueIndex(@enumFromInt(data)), |
| 14768 | 14757 | }), |
| 14769 | 14758 | .@"ret void" => try function_block.writeAbbrev(FunctionBlock.RetVoid{}), |
| 14770 | 14759 | .atomicrmw => { |
| 14771 | | const extra = func.extraData(Function.Instruction.AtomicRmw, datas[instr_index]); |
| 14760 | const extra = func.extraData(Function.Instruction.AtomicRmw, data); |
| 14772 | 14761 | try function_block.writeAbbrev(FunctionBlock.AtomicRmw{ |
| 14773 | 14762 | .ptr = adapter.getOffsetValueIndex(extra.ptr), |
| 14774 | 14763 | .val = adapter.getOffsetValueIndex(extra.val), |
| ... | ... | @@ -14782,7 +14771,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14782 | 14771 | .cmpxchg, |
| 14783 | 14772 | .@"cmpxchg weak", |
| 14784 | 14773 | => |kind| { |
| 14785 | | const extra = func.extraData(Function.Instruction.CmpXchg, datas[instr_index]); |
| 14774 | const extra = func.extraData(Function.Instruction.CmpXchg, data); |
| 14786 | 14775 | |
| 14787 | 14776 | try function_block.writeAbbrev(FunctionBlock.CmpXchg{ |
| 14788 | 14777 | .ptr = adapter.getOffsetValueIndex(extra.ptr), |
| ... | ... | @@ -14797,7 +14786,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14797 | 14786 | }); |
| 14798 | 14787 | }, |
| 14799 | 14788 | .fence => { |
| 14800 | | const info: MemoryAccessInfo = @bitCast(datas[instr_index]); |
| 14789 | const info: MemoryAccessInfo = @bitCast(data); |
| 14801 | 14790 | try function_block.writeAbbrev(FunctionBlock.Fence{ |
| 14802 | 14791 | .ordering = info.success_ordering, |
| 14803 | 14792 | .sync_scope = info.sync_scope, |
| ... | ... | @@ -14806,7 +14795,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14806 | 14795 | } |
| 14807 | 14796 | |
| 14808 | 14797 | if (!func.strip) { |
| 14809 | | if (func.debug_locations.get(@enumFromInt(instr_index))) |debug_location| { |
| 14798 | if (func.debug_locations.get(adapter.instruction_index)) |debug_location| { |
| 14810 | 14799 | switch (debug_location) { |
| 14811 | 14800 | .no_location => has_location = false, |
| 14812 | 14801 | .location => |location| { |
| ... | ... | @@ -14823,8 +14812,6 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14823 | 14812 | try function_block.writeAbbrev(FunctionBlock.DebugLocAgain{}); |
| 14824 | 14813 | } |
| 14825 | 14814 | } |
| 14826 | | |
| 14827 | | adapter.next(); |
| 14828 | 14815 | } |
| 14829 | 14816 | |
| 14830 | 14817 | // VALUE_SYMTAB |
| ... | ... | @@ -14850,18 +14837,32 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co |
| 14850 | 14837 | } |
| 14851 | 14838 | |
| 14852 | 14839 | // METADATA_ATTACHMENT_BLOCK |
| 14853 | | if (!func.strip) blk: { |
| 14854 | | const dbg = func.global.ptrConst(self).dbg; |
| 14855 | | |
| 14856 | | if (dbg == .none) break :blk; |
| 14857 | | |
| 14840 | const any_nosanitize = true; |
| 14841 | if (!func.strip or any_nosanitize) { |
| 14858 | 14842 | const MetadataAttachmentBlock = ir.MetadataAttachmentBlock; |
| 14859 | 14843 | var metadata_attach_block = try function_block.enterSubBlock(MetadataAttachmentBlock, false); |
| 14860 | 14844 | |
| 14861 | | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentSingle{ |
| 14862 | | .kind = ir.MetadataKind.dbg, |
| 14863 | | .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1), |
| 14864 | | }); |
| 14845 | if (!func.strip) blk: { |
| 14846 | const dbg = func.global.ptrConst(self).dbg; |
| 14847 | if (dbg == .none) break :blk; |
| 14848 | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentGlobalSingle{ |
| 14849 | .kind = .dbg, |
| 14850 | .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(dbg) - 1), |
| 14851 | }); |
| 14852 | } |
| 14853 | |
| 14854 | var instr_index: u32 = 0; |
| 14855 | for (func.instructions.items(.tag)) |instr_tag| switch (instr_tag) { |
| 14856 | .arg, .block => {}, |
| 14857 | else => { |
| 14858 | try metadata_attach_block.writeAbbrev(MetadataAttachmentBlock.AttachmentInstructionSingle{ |
| 14859 | .inst = instr_index, |
| 14860 | .kind = .nosanitize, |
| 14861 | .metadata = @enumFromInt(metadata_adapter.getMetadataIndex(.empty_tuple) - 1), |
| 14862 | }); |
| 14863 | instr_index += 1; |
| 14864 | }, |
| 14865 | }; |
| 14865 | 14866 | |
| 14866 | 14867 | try metadata_attach_block.end(); |
| 14867 | 14868 | } |