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),
3737attributes_indices: std.ArrayListUnmanaged(u32),
3838attributes_extra: std.ArrayListUnmanaged(u32),
3939
40function_attributes_set: std.AutoArrayHashMapUnmanaged(FunctionAttributes, void),
41
4042globals: std.AutoArrayHashMapUnmanaged(String, Global),
4143next_unnamed_global: String,
4244next_replaced_global: String,
......@@ -8248,6 +8250,8 @@ pub fn init(options: Options) InitError!Builder {
82488250 .attributes_indices = .{},
82498251 .attributes_extra = .{},
82508252
8253 .function_attributes_set = .{},
8254
82518255 .globals = .{},
82528256 .next_unnamed_global = @enumFromInt(0),
82538257 .next_replaced_global = .none,
......@@ -8385,6 +8389,8 @@ pub fn deinit(self: *Builder) void {
83858389 self.attributes_indices.deinit(self.gpa);
83868390 self.attributes_extra.deinit(self.gpa);
83878391
8392 self.function_attributes_set.deinit(self.gpa);
8393
83888394 self.globals.deinit(self.gpa);
83898395 self.next_unique_global_id.deinit(self.gpa);
83908396 self.aliases.deinit(self.gpa);
......@@ -8825,12 +8831,16 @@ pub fn attrs(self: *Builder, attributes: []Attribute.Index) Allocator.Error!Attr
88258831}
88268832
88278833pub 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(
88298836 fn_attributes[0..if (std.mem.lastIndexOfNone(Attributes, fn_attributes, &.{.none})) |last|
88308837 last + 1
88318838 else
88328839 0],
88338840 )));
8841
8842 _ = self.function_attributes_set.getOrPutAssumeCapacity(function_attributes);
8843 return function_attributes;
88348844}
88358845
88368846pub fn addGlobal(self: *Builder, name: String, global: Global) Allocator.Error!Global.Index {