authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2023-08-17 16:03:40+02:00
committergravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-02-21 16:24:59+01:00
log8feae5d2d5fa8b82922f6dbb45b1aae7a4d6a93f
tree51001d4e8c65050f63cc21d4d940c2b42ec53e0d
parent955fd65cb1705d8279eb195bdbc69810df1b1d98

LLVM: Assign correct values to enum/union tags


1 files changed, 105 insertions(+), 99 deletions(-)

src/codegen/llvm/Builder.zig+105-99
...@@ -1051,7 +1051,13 @@ pub const Attribute = union(Kind) {...@@ -1051,7 +1051,13 @@ pub const Attribute = union(Kind) {
1051 .no_sanitize_hwaddress,1051 .no_sanitize_hwaddress,
1052 .sanitize_address_dyninit,1052 .sanitize_address_dyninit,
1053 => |kind| {1053 => |kind| {
1054 const field = @typeInfo(Attribute).Union.fields[@intFromEnum(kind)];1054 const field = comptime blk: {
1055 @setEvalBranchQuota(10_000);
1056 inline for (@typeInfo(Attribute).Union.fields) |field| {
1057 if (std.mem.eql(u8, field.name, @tagName(kind))) break :blk field;
1058 }
1059 unreachable;
1060 };
1055 comptime assert(std.mem.eql(u8, @tagName(kind), field.name));1061 comptime assert(std.mem.eql(u8, @tagName(kind), field.name));
1056 return @unionInit(Attribute, field.name, switch (field.type) {1062 return @unionInit(Attribute, field.name, switch (field.type) {
1057 void => {},1063 void => {},
...@@ -1255,100 +1261,100 @@ pub const Attribute = union(Kind) {...@@ -1255,100 +1261,100 @@ pub const Attribute = union(Kind) {
12551261
1256 pub const Kind = enum(u32) {1262 pub const Kind = enum(u32) {
1257 // Parameter Attributes1263 // Parameter Attributes
1258 zeroext,1264 zeroext = 34,
1259 signext,1265 signext = 24,
1260 inreg,1266 inreg = 5,
1261 byval,1267 byval = 3,
1262 byref,1268 byref = 69,
1263 preallocated,1269 preallocated = 65,
1264 inalloca,1270 inalloca = 38,
1265 sret,1271 sret = 29, // TODO: ?
1266 elementtype,1272 elementtype = 77,
1267 @"align",1273 @"align" = 1,
1268 @"noalias",1274 @"noalias" = 9,
1269 nocapture,1275 nocapture = 11,
1270 nofree,1276 nofree = 62,
1271 nest,1277 nest = 8,
1272 returned,1278 returned = 22,
1273 nonnull,1279 nonnull = 39,
1274 dereferenceable,1280 dereferenceable = 41,
1275 dereferenceable_or_null,1281 dereferenceable_or_null = 42,
1276 swiftself,1282 swiftself = 46,
1277 swiftasync,1283 swiftasync = 75,
1278 swifterror,1284 swifterror = 47,
1279 immarg,1285 immarg = 60,
1280 noundef,1286 noundef = 68,
1281 nofpclass,1287 nofpclass = 87,
1282 alignstack,1288 alignstack = 25,
1283 allocalign,1289 allocalign = 80,
1284 allocptr,1290 allocptr = 81,
1285 readnone,1291 readnone = 20,
1286 readonly,1292 readonly = 21,
1287 writeonly,1293 writeonly = 52,
12881294
1289 // Function Attributes1295 // Function Attributes
1290 //alignstack,1296 //alignstack,
1291 allockind,1297 allockind = 82,
1292 allocsize,1298 allocsize = 51,
1293 alwaysinline,1299 alwaysinline = 2,
1294 builtin,1300 builtin = 35,
1295 cold,1301 cold = 36,
1296 convergent,1302 convergent = 43,
1297 disable_sanitizer_information,1303 disable_sanitizer_information = 78,
1298 fn_ret_thunk_extern,1304 fn_ret_thunk_extern = 84,
1299 hot,1305 hot = 72,
1300 inlinehint,1306 inlinehint = 4,
1301 jumptable,1307 jumptable = 40,
1302 memory,1308 memory = 86,
1303 minsize,1309 minsize = 6,
1304 naked,1310 naked = 7,
1305 nobuiltin,1311 nobuiltin = 10,
1306 nocallback,1312 nocallback = 71,
1307 noduplicate,1313 noduplicate = 12,
1308 //nofree,1314 //nofree,
1309 noimplicitfloat,1315 noimplicitfloat = 13,
1310 @"noinline",1316 @"noinline" = 14,
1311 nomerge,1317 nomerge = 66,
1312 nonlazybind,1318 nonlazybind = 15,
1313 noprofile,1319 noprofile = 73,
1314 skipprofile,1320 skipprofile = 85,
1315 noredzone,1321 noredzone = 16,
1316 noreturn,1322 noreturn = 17,
1317 norecurse,1323 norecurse = 48,
1318 willreturn,1324 willreturn = 61,
1319 nosync,1325 nosync = 63,
1320 nounwind,1326 nounwind = 18,
1321 nosanitize_bounds,1327 nosanitize_bounds = 79,
1322 nosanitize_coverage,1328 nosanitize_coverage = 76,
1323 null_pointer_is_valid,1329 null_pointer_is_valid = 67,
1324 optforfuzzing,1330 optforfuzzing = 57,
1325 optnone,1331 optnone = 37,
1326 optsize,1332 optsize = 19,
1327 //preallocated,1333 //preallocated,
1328 returns_twice,1334 returns_twice = 23,
1329 safestack,1335 safestack = 44,
1330 sanitize_address,1336 sanitize_address = 30,
1331 sanitize_memory,1337 sanitize_memory = 32,
1332 sanitize_thread,1338 sanitize_thread = 31,
1333 sanitize_hwaddress,1339 sanitize_hwaddress = 55,
1334 sanitize_memtag,1340 sanitize_memtag = 64,
1335 speculative_load_hardening,1341 speculative_load_hardening = 59,
1336 speculatable,1342 speculatable = 53,
1337 ssp,1343 ssp = 26,
1338 sspstrong,1344 sspstrong = 28,
1339 sspreq,1345 sspreq = 27,
1340 strictfp,1346 strictfp = 54,
1341 uwtable,1347 uwtable = 33,
1342 nocf_check,1348 nocf_check = 56,
1343 shadowcallstack,1349 shadowcallstack = 58,
1344 mustprogress,1350 mustprogress = 70,
1345 vscale_range,1351 vscale_range = 74,
13461352
1347 // Global Attributes1353 // Global Attributes
1348 no_sanitize_address,1354 no_sanitize_address = 100,
1349 no_sanitize_hwaddress,1355 no_sanitize_hwaddress = 101,
1350 //sanitize_memtag,1356 //sanitize_memtag,
1351 sanitize_address_dyninit,1357 sanitize_address_dyninit = 102,
13521358
1353 string = std.math.maxInt(u31),1359 string = std.math.maxInt(u31),
1354 none = std.math.maxInt(u32),1360 none = std.math.maxInt(u32),
...@@ -1709,18 +1715,18 @@ pub const FunctionAttributes = enum(u32) {...@@ -1709,18 +1715,18 @@ pub const FunctionAttributes = enum(u32) {
1709 }1715 }
1710};1716};
17111717
1712pub const Linkage = enum {1718pub const Linkage = enum(u4) {
1713 private,1719 private = 9,
1714 internal,1720 internal = 3,
1715 weak,1721 weak = 1,
1716 weak_odr,1722 weak_odr = 10,
1717 linkonce,1723 linkonce = 4,
1718 linkonce_odr,1724 linkonce_odr = 11,
1719 available_externally,1725 available_externally = 12,
1720 appending,1726 appending = 2,
1721 common,1727 common = 8,
1722 extern_weak,1728 extern_weak = 7,
1723 external,1729 external = 0,
17241730
1725 pub fn format(1731 pub fn format(
1726 self: Linkage,1732 self: Linkage,