diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2024-09-12 19:50:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-12 19:50:38 +0100 |
| commit | 0001f91e4e1e51cd64cdd5c0a21451c8bad67233 (patch) | |
| tree | 9c3efb262890fa76a9b1d02c694dadad11c316f4 /src/codegen | |
| parent | b95e0e09dcbe4ca948fd4098a8e3a4d90df9cb22 (diff) | |
| parent | 9271a89c65967ff0fed7011b4195abdd0f9195eb (diff) | |
| download | zig-0001f91e4e1e51cd64cdd5c0a21451c8bad67233.tar.gz zig-0001f91e4e1e51cd64cdd5c0a21451c8bad67233.zip | |
Merge pull request #21287 from linusg/deprecated-default-init
Replace deprecated default initializations with decl literals
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 8 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 18 | ||||
| -rw-r--r-- | src/codegen/llvm/Builder.zig | 12 | ||||
| -rw-r--r-- | src/codegen/spirv.zig | 20 | ||||
| -rw-r--r-- | src/codegen/spirv/Assembler.zig | 10 | ||||
| -rw-r--r-- | src/codegen/spirv/Module.zig | 20 | ||||
| -rw-r--r-- | src/codegen/spirv/Section.zig | 2 |
7 files changed, 45 insertions, 45 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 0ec5513b6f..466bdcde6a 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -304,14 +304,14 @@ pub const Function = struct { air: Air, liveness: Liveness, value_map: CValueMap, - blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .{}, + blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, BlockData) = .empty, next_arg_index: usize = 0, next_block_index: usize = 0, object: Object, lazy_fns: LazyFnMap, func_index: InternPool.Index, /// All the locals, to be emitted at the top of the function. - locals: std.ArrayListUnmanaged(Local) = .{}, + locals: std.ArrayListUnmanaged(Local) = .empty, /// Which locals are available for reuse, based on Type. free_locals_map: LocalsMap = .{}, /// Locals which will not be freed by Liveness. This is used after a @@ -320,10 +320,10 @@ pub const Function = struct { /// of variable declarations at the top of a function, sorted descending /// by type alignment. /// The value is whether the alloc needs to be emitted in the header. - allocs: std.AutoArrayHashMapUnmanaged(LocalIndex, bool) = .{}, + allocs: std.AutoArrayHashMapUnmanaged(LocalIndex, bool) = .empty, /// Maps from `loop_switch_br` instructions to the allocated local used /// for the switch cond. Dispatches should set this local to the new cond. - loop_switch_conds: std.AutoHashMapUnmanaged(Air.Inst.Index, LocalIndex) = .{}, + loop_switch_conds: std.AutoHashMapUnmanaged(Air.Inst.Index, LocalIndex) = .empty, fn resolveInst(f: *Function, ref: Air.Inst.Ref) !CValue { const gop = try f.value_map.getOrPut(ref); diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 956ed7de08..ec2ba4e4c1 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1500,7 +1500,7 @@ pub const Object = struct { // instructions. Depending on the calling convention, this list is not necessarily // a bijection with the actual LLVM parameters of the function. const gpa = o.gpa; - var args: std.ArrayListUnmanaged(Builder.Value) = .{}; + var args: std.ArrayListUnmanaged(Builder.Value) = .empty; defer args.deinit(gpa); { @@ -2497,7 +2497,7 @@ pub const Object = struct { switch (ip.indexToKey(ty.toIntern())) { .anon_struct_type => |tuple| { - var fields: std.ArrayListUnmanaged(Builder.Metadata) = .{}; + var fields: std.ArrayListUnmanaged(Builder.Metadata) = .empty; defer fields.deinit(gpa); try fields.ensureUnusedCapacity(gpa, tuple.types.len); @@ -2574,7 +2574,7 @@ pub const Object = struct { const struct_type = zcu.typeToStruct(ty).?; - var fields: std.ArrayListUnmanaged(Builder.Metadata) = .{}; + var fields: std.ArrayListUnmanaged(Builder.Metadata) = .empty; defer fields.deinit(gpa); try fields.ensureUnusedCapacity(gpa, struct_type.field_types.len); @@ -2667,7 +2667,7 @@ pub const Object = struct { return debug_union_type; } - var fields: std.ArrayListUnmanaged(Builder.Metadata) = .{}; + var fields: std.ArrayListUnmanaged(Builder.Metadata) = .empty; defer fields.deinit(gpa); try fields.ensureUnusedCapacity(gpa, union_type.loadTagType(ip).names.len); @@ -3412,7 +3412,7 @@ pub const Object = struct { return int_ty; } - var llvm_field_types = std.ArrayListUnmanaged(Builder.Type){}; + var llvm_field_types: std.ArrayListUnmanaged(Builder.Type) = .empty; defer llvm_field_types.deinit(o.gpa); // Although we can estimate how much capacity to add, these cannot be // relied upon because of the recursive calls to lowerType below. @@ -3481,7 +3481,7 @@ pub const Object = struct { return ty; }, .anon_struct_type => |anon_struct_type| { - var llvm_field_types: std.ArrayListUnmanaged(Builder.Type) = .{}; + var llvm_field_types: std.ArrayListUnmanaged(Builder.Type) = .empty; defer llvm_field_types.deinit(o.gpa); // Although we can estimate how much capacity to add, these cannot be // relied upon because of the recursive calls to lowerType below. @@ -3672,7 +3672,7 @@ pub const Object = struct { const target = zcu.getTarget(); const ret_ty = try lowerFnRetTy(o, fn_info); - var llvm_params = std.ArrayListUnmanaged(Builder.Type){}; + var llvm_params: std.ArrayListUnmanaged(Builder.Type) = .empty; defer llvm_params.deinit(o.gpa); if (firstParamSRet(fn_info, zcu, target)) { @@ -7438,7 +7438,7 @@ pub const FuncGen = struct { const inputs: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra_i..][0..extra.data.inputs_len]); extra_i += inputs.len; - var llvm_constraints: std.ArrayListUnmanaged(u8) = .{}; + var llvm_constraints: std.ArrayListUnmanaged(u8) = .empty; defer llvm_constraints.deinit(self.gpa); var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); @@ -7466,7 +7466,7 @@ pub const FuncGen = struct { var llvm_param_i: usize = 0; var total_i: u16 = 0; - var name_map: std.StringArrayHashMapUnmanaged(u16) = .{}; + var name_map: std.StringArrayHashMapUnmanaged(u16) = .empty; try name_map.ensureUnusedCapacity(arena, max_param_count); var rw_extra_i = extra_i; diff --git a/src/codegen/llvm/Builder.zig b/src/codegen/llvm/Builder.zig index f6bfcab1ad..d3aa6e34c4 100644 --- a/src/codegen/llvm/Builder.zig +++ b/src/codegen/llvm/Builder.zig @@ -3994,7 +3994,7 @@ pub const Function = struct { names: [*]const String = &[0]String{}, value_indices: [*]const u32 = &[0]u32{}, strip: bool, - debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .{}, + debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .empty, debug_values: []const Instruction.Index = &.{}, extra: []const u32 = &.{}, @@ -6166,7 +6166,7 @@ pub const WipFunction = struct { const value_indices = try gpa.alloc(u32, final_instructions_len); errdefer gpa.free(value_indices); - var debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .{}; + var debug_locations: std.AutoHashMapUnmanaged(Instruction.Index, DebugLocation) = .empty; errdefer debug_locations.deinit(gpa); try debug_locations.ensureUnusedCapacity(gpa, @intCast(self.debug_locations.count())); @@ -9557,7 +9557,7 @@ pub fn printUnbuffered( } } - var attribute_groups: std.AutoArrayHashMapUnmanaged(Attributes, void) = .{}; + var attribute_groups: std.AutoArrayHashMapUnmanaged(Attributes, void) = .empty; defer attribute_groups.deinit(self.gpa); for (0.., self.functions.items) |function_i, function| { @@ -13133,7 +13133,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co // Write LLVM IR magic try bitcode.writeBits(ir.MAGIC, 32); - var record: std.ArrayListUnmanaged(u64) = .{}; + var record: std.ArrayListUnmanaged(u64) = .empty; defer record.deinit(self.gpa); // IDENTIFICATION_BLOCK @@ -13524,7 +13524,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co try paramattr_block.end(); } - var globals: std.AutoArrayHashMapUnmanaged(Global.Index, void) = .{}; + var globals: std.AutoArrayHashMapUnmanaged(Global.Index, void) = .empty; defer globals.deinit(self.gpa); try globals.ensureUnusedCapacity( self.gpa, @@ -13587,7 +13587,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co // Globals { - var section_map: std.AutoArrayHashMapUnmanaged(String, void) = .{}; + var section_map: std.AutoArrayHashMapUnmanaged(String, void) = .empty; defer section_map.deinit(self.gpa); try section_map.ensureUnusedCapacity(self.gpa, globals.count()); diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index afc7641072..dc45b26931 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -79,7 +79,7 @@ const ControlFlow = union(enum) { selection: struct { /// In order to know which merges we still need to do, we need to keep /// a stack of those. - merge_stack: std.ArrayListUnmanaged(SelectionMerge) = .{}, + merge_stack: std.ArrayListUnmanaged(SelectionMerge) = .empty, }, /// For a `loop` type block, we can early-exit the block by /// jumping to the loop exit node, and we don't need to generate @@ -87,7 +87,7 @@ const ControlFlow = union(enum) { loop: struct { /// The next block to jump to can be determined from any number /// of conditions that jump to the loop exit. - merges: std.ArrayListUnmanaged(Incoming) = .{}, + merges: std.ArrayListUnmanaged(Incoming) = .empty, /// The label id of the loop's merge block. merge_block: IdRef, }, @@ -102,10 +102,10 @@ const ControlFlow = union(enum) { }; /// The stack of (structured) blocks that we are currently in. This determines /// how exits from the current block must be handled. - block_stack: std.ArrayListUnmanaged(*Structured.Block) = .{}, + block_stack: std.ArrayListUnmanaged(*Structured.Block) = .empty, /// Maps `block` inst indices to the variable that the block's result /// value must be written to. - block_results: std.AutoHashMapUnmanaged(Air.Inst.Index, IdRef) = .{}, + block_results: std.AutoHashMapUnmanaged(Air.Inst.Index, IdRef) = .empty, }; const Unstructured = struct { @@ -116,12 +116,12 @@ const ControlFlow = union(enum) { const Block = struct { label: ?IdRef = null, - incoming_blocks: std.ArrayListUnmanaged(Incoming) = .{}, + incoming_blocks: std.ArrayListUnmanaged(Incoming) = .empty, }; /// We need to keep track of result ids for block labels, as well as the 'incoming' /// blocks for a block. - blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, *Block) = .{}, + blocks: std.AutoHashMapUnmanaged(Air.Inst.Index, *Block) = .empty, }; structured: Structured, @@ -153,10 +153,10 @@ pub const Object = struct { /// The Zig module that this object file is generated for. /// A map of Zig decl indices to SPIR-V decl indices. - nav_link: std.AutoHashMapUnmanaged(InternPool.Nav.Index, SpvModule.Decl.Index) = .{}, + nav_link: std.AutoHashMapUnmanaged(InternPool.Nav.Index, SpvModule.Decl.Index) = .empty, /// A map of Zig InternPool indices for anonymous decls to SPIR-V decl indices. - uav_link: std.AutoHashMapUnmanaged(struct { InternPool.Index, StorageClass }, SpvModule.Decl.Index) = .{}, + uav_link: std.AutoHashMapUnmanaged(struct { InternPool.Index, StorageClass }, SpvModule.Decl.Index) = .empty, /// A map that maps AIR intern pool indices to SPIR-V result-ids. intern_map: InternMap = .{}, @@ -300,7 +300,7 @@ const NavGen = struct { /// An array of function argument result-ids. Each index corresponds with the /// function argument of the same index. - args: std.ArrayListUnmanaged(IdRef) = .{}, + args: std.ArrayListUnmanaged(IdRef) = .empty, /// A counter to keep track of how many `arg` instructions we've seen yet. next_arg_index: u32 = 0, @@ -6270,7 +6270,7 @@ const NavGen = struct { } } - var incoming_structured_blocks = std.ArrayListUnmanaged(ControlFlow.Structured.Block.Incoming){}; + var incoming_structured_blocks: std.ArrayListUnmanaged(ControlFlow.Structured.Block.Incoming) = .empty; defer incoming_structured_blocks.deinit(self.gpa); if (self.control_flow == .structured) { diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig index 2cbb873d30..9e39f2ed09 100644 --- a/src/codegen/spirv/Assembler.zig +++ b/src/codegen/spirv/Assembler.zig @@ -148,7 +148,7 @@ const AsmValueMap = std.StringArrayHashMapUnmanaged(AsmValue); gpa: Allocator, /// A list of errors that occured during processing the assembly. -errors: std.ArrayListUnmanaged(ErrorMsg) = .{}, +errors: std.ArrayListUnmanaged(ErrorMsg) = .empty, /// The source code that is being assembled. src: []const u8, @@ -161,7 +161,7 @@ spv: *SpvModule, func: *SpvModule.Fn, /// `self.src` tokenized. -tokens: std.ArrayListUnmanaged(Token) = .{}, +tokens: std.ArrayListUnmanaged(Token) = .empty, /// The token that is next during parsing. current_token: u32 = 0, @@ -172,9 +172,9 @@ inst: struct { /// The opcode of the current instruction. opcode: Opcode = undefined, /// Operands of the current instruction. - operands: std.ArrayListUnmanaged(Operand) = .{}, + operands: std.ArrayListUnmanaged(Operand) = .empty, /// This is where string data resides. Strings are zero-terminated. - string_bytes: std.ArrayListUnmanaged(u8) = .{}, + string_bytes: std.ArrayListUnmanaged(u8) = .empty, /// Return a reference to the result of this instruction, if any. fn result(self: @This()) ?AsmValue.Ref { @@ -196,7 +196,7 @@ value_map: AsmValueMap = .{}, /// This set is used to quickly transform from an opcode name to the /// index in its instruction set. The index of the key is the /// index in `spec.InstructionSet.core.instructions()`. -instruction_map: std.StringArrayHashMapUnmanaged(void) = .{}, +instruction_map: std.StringArrayHashMapUnmanaged(void) = .empty, /// Free the resources owned by this assembler. pub fn deinit(self: *Assembler) void { diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index ae30de156b..94787e06b9 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -35,7 +35,7 @@ pub const Fn = struct { /// the end of this function definition. body: Section = .{}, /// The decl dependencies that this function depends on. - decl_deps: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{}, + decl_deps: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .empty, /// Reset this function without deallocating resources, so that /// it may be used to emit code for another function. @@ -141,7 +141,7 @@ sections: struct { next_result_id: Word, /// Cache for results of OpString instructions. -strings: std.StringArrayHashMapUnmanaged(IdRef) = .{}, +strings: std.StringArrayHashMapUnmanaged(IdRef) = .empty, /// Some types shouldn't be emitted more than one time, but cannot be caught by /// the `intern_map` during codegen. Sometimes, IDs are compared to check if @@ -154,27 +154,27 @@ strings: std.StringArrayHashMapUnmanaged(IdRef) = .{}, cache: struct { bool_type: ?IdRef = null, void_type: ?IdRef = null, - int_types: std.AutoHashMapUnmanaged(std.builtin.Type.Int, IdRef) = .{}, - float_types: std.AutoHashMapUnmanaged(std.builtin.Type.Float, IdRef) = .{}, + int_types: std.AutoHashMapUnmanaged(std.builtin.Type.Int, IdRef) = .empty, + float_types: std.AutoHashMapUnmanaged(std.builtin.Type.Float, IdRef) = .empty, // This cache is required so that @Vector(X, u1) in direct representation has the // same ID as @Vector(X, bool) in indirect representation. - vector_types: std.AutoHashMapUnmanaged(struct { IdRef, u32 }, IdRef) = .{}, + vector_types: std.AutoHashMapUnmanaged(struct { IdRef, u32 }, IdRef) = .empty, - builtins: std.AutoHashMapUnmanaged(struct { IdRef, spec.BuiltIn }, Decl.Index) = .{}, + builtins: std.AutoHashMapUnmanaged(struct { IdRef, spec.BuiltIn }, Decl.Index) = .empty, } = .{}, /// Set of Decls, referred to by Decl.Index. -decls: std.ArrayListUnmanaged(Decl) = .{}, +decls: std.ArrayListUnmanaged(Decl) = .empty, /// List of dependencies, per decl. This list holds all the dependencies, sliced by the /// begin_dep and end_dep in `self.decls`. -decl_deps: std.ArrayListUnmanaged(Decl.Index) = .{}, +decl_deps: std.ArrayListUnmanaged(Decl.Index) = .empty, /// The list of entry points that should be exported from this module. -entry_points: std.ArrayListUnmanaged(EntryPoint) = .{}, +entry_points: std.ArrayListUnmanaged(EntryPoint) = .empty, /// The list of extended instruction sets that should be imported. -extended_instruction_set: std.AutoHashMapUnmanaged(spec.InstructionSet, IdRef) = .{}, +extended_instruction_set: std.AutoHashMapUnmanaged(spec.InstructionSet, IdRef) = .empty, pub fn init(gpa: Allocator) Module { return .{ diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig index 20abf8ab70..1fdf884bdb 100644 --- a/src/codegen/spirv/Section.zig +++ b/src/codegen/spirv/Section.zig @@ -15,7 +15,7 @@ const Opcode = spec.Opcode; /// The instructions in this section. Memory is owned by the Module /// externally associated to this Section. -instructions: std.ArrayListUnmanaged(Word) = .{}, +instructions: std.ArrayListUnmanaged(Word) = .empty, pub fn deinit(section: *Section, allocator: Allocator) void { section.instructions.deinit(allocator); |
