authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-01-20 00:13:08+01:00
committergravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-02-21 16:24:59+01:00
logc57b4e70b06cae022793ffe0aa025de31a0ff1c5
tree8c1f881dbe64e3ce5ea6326f5f9cd83057c22e63
parent52e843402224e43141a63e406432643b4304b507

Builder: Add function_attributes_set


1 files changed, 11 insertions(+), 1 deletions(-)

src/codegen/llvm/Builder.zig+11-1
...@@ -37,6 +37,8 @@ attributes_map: std.AutoArrayHashMapUnmanaged(void, void),...@@ -37,6 +37,8 @@ attributes_map: std.AutoArrayHashMapUnmanaged(void, void),
37attributes_indices: std.ArrayListUnmanaged(u32),37attributes_indices: std.ArrayListUnmanaged(u32),
38attributes_extra: std.ArrayListUnmanaged(u32),38attributes_extra: std.ArrayListUnmanaged(u32),
3939
40function_attributes_set: std.AutoArrayHashMapUnmanaged(FunctionAttributes, void),
41
40globals: std.AutoArrayHashMapUnmanaged(String, Global),42globals: std.AutoArrayHashMapUnmanaged(String, Global),
41next_unnamed_global: String,43next_unnamed_global: String,
42next_replaced_global: String,44next_replaced_global: String,
...@@ -8248,6 +8250,8 @@ pub fn init(options: Options) InitError!Builder {...@@ -8248,6 +8250,8 @@ pub fn init(options: Options) InitError!Builder {
8248 .attributes_indices = .{},8250 .attributes_indices = .{},
8249 .attributes_extra = .{},8251 .attributes_extra = .{},
82508252
8253 .function_attributes_set = .{},
8254
8251 .globals = .{},8255 .globals = .{},
8252 .next_unnamed_global = @enumFromInt(0),8256 .next_unnamed_global = @enumFromInt(0),
8253 .next_replaced_global = .none,8257 .next_replaced_global = .none,
...@@ -8385,6 +8389,8 @@ pub fn deinit(self: *Builder) void {...@@ -8385,6 +8389,8 @@ pub fn deinit(self: *Builder) void {
8385 self.attributes_indices.deinit(self.gpa);8389 self.attributes_indices.deinit(self.gpa);
8386 self.attributes_extra.deinit(self.gpa);8390 self.attributes_extra.deinit(self.gpa);
83878391
8392 self.function_attributes_set.deinit(self.gpa);
8393
8388 self.globals.deinit(self.gpa);8394 self.globals.deinit(self.gpa);
8389 self.next_unique_global_id.deinit(self.gpa);8395 self.next_unique_global_id.deinit(self.gpa);
8390 self.aliases.deinit(self.gpa);8396 self.aliases.deinit(self.gpa);
...@@ -8825,12 +8831,16 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr...@@ -8825,12 +8831,16 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr
8825}8831}
88268832
8827pub fn fnAttrs(self: *Builder, fn_attributes: []const Attributes) Allocator.Error!FunctionAttributes {8833pub fn fnAttrs(self: *Builder, fn_attributes: []const Attributes) Allocator.Error!FunctionAttributes {
8828 return @enumFromInt(try self.attrGeneric(@ptrCast(8834 try self.function_attributes_set.ensureUnusedCapacity(self.gpa, 1);
8835 const function_attributes: FunctionAttributes = @enumFromInt(try self.attrGeneric(@ptrCast(
8829 fn_attributes[0..if (std.mem.lastIndexOfNone(Attributes, fn_attributes, &.{.none})) |last|8836 fn_attributes[0..if (std.mem.lastIndexOfNone(Attributes, fn_attributes, &.{.none})) |last|
8830 last + 18837 last + 1
8831 else8838 else
8832 0],8839 0],
8833 )));8840 )));
8841
8842 _ = self.function_attributes_set.getOrPutAssumeCapacity(function_attributes);
8843 return function_attributes;
8834}8844}
88358845
8836pub fn addGlobal(self: *Builder, name: String, global: Global) Allocator.Error!Global.Index {8846pub fn addGlobal(self: *Builder, name: String, global: Global) Allocator.Error!Global.Index {