╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ gen_outline_atomics.zig ──────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
241 }); 242 } else { 243 const casp = try std.fmt.allocPrint(arena, ".inst 0x48207c82 + {s}", .{o_def.m}); 244 const ldxp = try std.fmt.allocPrint(arena, "ld{s}xp", .{o_def.a}); 245 const stxp = try std.fmt.allocPrint(arena, "st{s}xp", .{o_def.l}); 246 247 return try std.fmt.allocPrint(arena, 248 \\ cbz w16, 8f 249 \\ {[casp]s} 250 \\ ret 251 \\8: 252 \\ mov x16, x0 253 \\ mov x17, x1 254 \\0: 255 \\ {[ldxp]s} x0, x1, [x4] 256 \\ cmp x0, x16 257 \\ ccmp x1, x17, #0, eq 258 \\ bne 1f 259 \\ {[stxp]s} w15, x2, x3, [x4] 260 \\ cbnz w15, 0b 261 \\1: 262 \\ ret 263 , .{ 264 .casp = casp, 265 .ldxp = ldxp, 266 .stxp = stxp, 267 }); 268 } 269 } 270 271 fn generateSwp(arena: Allocator, n: N, order: Ordering) ![]const u8 { 272 const s_def = n.defines(); 273 const o_def = order.defines(); 274 const reg = n.register(); 275 276 return try std.fmt.allocPrint(arena, 277 \\ cbz w16, 8f 278 \\ .inst 0x38208020 + {[b]s} + {[n]s} 279 \\ ret 280 \\8: 281 \\ mov {[reg]s}16, {[reg]s}0 282 \\0: 283 \\ ld{[a]s}xr{[s]s} {[reg]s}0, [x1] 284 \\ st{[l]s}xr{[s]s} w17, {[reg]s}16, [x1] 285 \\ cbnz w17, 0b 286 \\1: 287 \\ ret 288 , .{ 289 .b = s_def.b, 290 .n = o_def.n, 291 .reg = reg, 292 .s = s_def.s, 293 .a = o_def.a, 294 .l = o_def.l, 295 }); 296 } 297 298 fn generateLd(arena: Allocator, n: N, order: Ordering, ld: LdName) ![]const u8 { 299 const s_def = n.defines(); 300 const o_def = order.defines(); 301 const op = switch (ld) { 302 .ldadd => "add", 303 .ldclr => "bic", 304 .ldeor => "eor", 305 .ldset => "orr", 306 }; 307 const op_n = switch (ld) { 308 .ldadd => "0x0000", 309 .ldclr => "0x1000", 310 .ldeor => "0x2000", 311 .ldset => "0x3000", 312 }; 313 314 const reg = n.register(); 315 316 return try std.fmt.allocPrint(arena, 317 \\ cbz w16, 8f 318 \\ .inst 0x38200020 + {[op_n]s} + {[b]s} + {[n]s} 319 \\ ret 320 \\8: 321 \\ mov {[reg]s}16, {[reg]s}0 322 \\0: 323 \\ ld{[a]s}xr{[s]s} {[reg]s}0, [x1] 324 \\ {[op]s} {[reg]s}17, {[reg]s}0, {[reg]s}16 325 \\ st{[l]s}xr{[s]s} w15, {[reg]s}17, [x1] 326 \\ cbnz w15, 0b 327 \\1: 328 \\ ret 329 , .{ 330 .op_n = op_n, 331 .b = s_def.b, 332 .n = o_def.n, 333 .s = s_def.s, 334 .a = o_def.a, 335 .l = o_def.l, 336 .op = op, 337 .reg = reg, 338 }); 339 } 340