Skip to content

Commit 3232a4a

Browse files
committed
Remove legacy asm clobbers syntax handling
1 parent 3ab87a3 commit 3232a4a

File tree

10 files changed

+13
-433
lines changed

10 files changed

+13
-433
lines changed

lib/compiler/reduce/Walk.zig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
501501
.@"asm",
502502
=> return walkAsm(w, ast.fullAsm(node).?),
503503

504-
.asm_legacy => {
505-
return walkAsmLegacy(w, ast.legacyAsm(node).?);
506-
},
507-
508504
.enum_literal => {
509505
return walkIdentifier(w, ast.nodeMainToken(node)); // name
510506
},
@@ -881,11 +877,6 @@ fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void {
881877
try walkExpressions(w, asm_node.ast.items);
882878
}
883879

884-
fn walkAsmLegacy(w: *Walk, asm_node: Ast.full.AsmLegacy) Error!void {
885-
try walkExpression(w, asm_node.ast.template);
886-
try walkExpressions(w, asm_node.ast.items);
887-
}
888-
889880
/// Check if it is already gutted (i.e. its body replaced with `@trap()`).
890881
fn isFnBodyGutted(ast: *const Ast, body_node: Ast.Node.Index) bool {
891882
// skip over discards

lib/docs/wasm/Walk.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
791791
try expr(w, scope, parent_decl, full.ast.template);
792792
},
793793

794-
.asm_legacy => {},
795-
796794
.builtin_call_two,
797795
.builtin_call_two_comma,
798796
.builtin_call,

lib/std/testing.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,12 @@ fn failEqualSlices(
402402
var differ = if (T == u8) BytesDiffer{
403403
.expected = expected_window,
404404
.actual = actual_window,
405-
.ttyconf = tty_config,
405+
.ttyconf = ttyconf,
406406
} else SliceDiffer(T){
407407
.start_index = window_start,
408408
.expected = expected_window,
409409
.actual = actual_window,
410-
.ttyconf = tty_config,
410+
.ttyconf = ttyconf,
411411
};
412412

413413
// Print indexes as hex for slices of u8 since it's more likely to be binary data where

lib/std/zig/Ast.zig

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
636636
.@"nosuspend",
637637
.asm_simple,
638638
.@"asm",
639-
.asm_legacy,
640639
.array_type,
641640
.array_type_sentinel,
642641
.error_value,
@@ -1050,11 +1049,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
10501049
n = @enumFromInt(tree.extra_data[@intFromEnum(members.end) - 1]); // last parameter
10511050
}
10521051
},
1053-
.asm_legacy => {
1054-
_, const extra_index = tree.nodeData(n).node_and_extra;
1055-
const extra = tree.extraData(extra_index, Node.AsmLegacy);
1056-
return extra.rparen + end_offset;
1057-
},
10581052
.@"asm" => {
10591053
_, const extra_index = tree.nodeData(n).node_and_extra;
10601054
const extra = tree.extraData(extra_index, Node.Asm);
@@ -1897,18 +1891,6 @@ pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm {
18971891
});
18981892
}
18991893

1900-
pub fn asmLegacy(tree: Ast, node: Node.Index) full.AsmLegacy {
1901-
const template, const extra_index = tree.nodeData(node).node_and_extra;
1902-
const extra = tree.extraData(extra_index, Node.AsmLegacy);
1903-
const items = tree.extraDataSlice(.{ .start = extra.items_start, .end = extra.items_end }, Node.Index);
1904-
return tree.legacyAsmComponents(.{
1905-
.asm_token = tree.nodeMainToken(node),
1906-
.template = template,
1907-
.items = items,
1908-
.rparen = extra.rparen,
1909-
});
1910-
}
1911-
19121894
pub fn asmFull(tree: Ast, node: Node.Index) full.Asm {
19131895
const template, const extra_index = tree.nodeData(node).node_and_extra;
19141896
const extra = tree.extraData(extra_index, Node.Asm);
@@ -2214,67 +2196,6 @@ fn fullSwitchCaseComponents(tree: Ast, info: full.SwitchCase.Components, node: N
22142196
return result;
22152197
}
22162198

2217-
fn legacyAsmComponents(tree: Ast, info: full.AsmLegacy.Components) full.AsmLegacy {
2218-
var result: full.AsmLegacy = .{
2219-
.ast = info,
2220-
.volatile_token = null,
2221-
.inputs = &.{},
2222-
.outputs = &.{},
2223-
.first_clobber = null,
2224-
};
2225-
if (tree.tokenTag(info.asm_token + 1) == .keyword_volatile) {
2226-
result.volatile_token = info.asm_token + 1;
2227-
}
2228-
const outputs_end: usize = for (info.items, 0..) |item, i| {
2229-
switch (tree.nodeTag(item)) {
2230-
.asm_output => continue,
2231-
else => break i,
2232-
}
2233-
} else info.items.len;
2234-
2235-
result.outputs = info.items[0..outputs_end];
2236-
result.inputs = info.items[outputs_end..];
2237-
2238-
if (info.items.len == 0) {
2239-
// asm ("foo" ::: "a", "b");
2240-
const template_token = tree.lastToken(info.template);
2241-
if (tree.tokenTag(template_token + 1) == .colon and
2242-
tree.tokenTag(template_token + 2) == .colon and
2243-
tree.tokenTag(template_token + 3) == .colon and
2244-
tree.tokenTag(template_token + 4) == .string_literal)
2245-
{
2246-
result.first_clobber = template_token + 4;
2247-
}
2248-
} else if (result.inputs.len != 0) {
2249-
// asm ("foo" :: [_] "" (y) : "a", "b");
2250-
const last_input = result.inputs[result.inputs.len - 1];
2251-
const rparen = tree.lastToken(last_input);
2252-
var i = rparen + 1;
2253-
// Allow a (useless) comma right after the closing parenthesis.
2254-
if (tree.tokenTag(i) == .comma) i = i + 1;
2255-
if (tree.tokenTag(i) == .colon and
2256-
tree.tokenTag(i + 1) == .string_literal)
2257-
{
2258-
result.first_clobber = i + 1;
2259-
}
2260-
} else {
2261-
// asm ("foo" : [_] "" (x) :: "a", "b");
2262-
const last_output = result.outputs[result.outputs.len - 1];
2263-
const rparen = tree.lastToken(last_output);
2264-
var i = rparen + 1;
2265-
// Allow a (useless) comma right after the closing parenthesis.
2266-
if (tree.tokenTag(i) == .comma) i = i + 1;
2267-
if (tree.tokenTag(i) == .colon and
2268-
tree.tokenTag(i + 1) == .colon and
2269-
tree.tokenTag(i + 2) == .string_literal)
2270-
{
2271-
result.first_clobber = i + 2;
2272-
}
2273-
}
2274-
2275-
return result;
2276-
}
2277-
22782199
fn fullAsmComponents(tree: Ast, info: full.Asm.Components) full.Asm {
22792200
var result: full.Asm = .{
22802201
.ast = info,
@@ -2492,14 +2413,6 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm {
24922413
};
24932414
}
24942415

2495-
/// To be deleted after 0.15.0 is tagged
2496-
pub fn legacyAsm(tree: Ast, node: Node.Index) ?full.AsmLegacy {
2497-
return switch (tree.nodeTag(node)) {
2498-
.asm_legacy => tree.asmLegacy(node),
2499-
else => null,
2500-
};
2501-
}
2502-
25032416
pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call {
25042417
return switch (tree.nodeTag(node)) {
25052418
.call, .call_comma => tree.callFull(node),
@@ -2894,21 +2807,6 @@ pub const full = struct {
28942807
};
28952808
};
28962809

2897-
pub const AsmLegacy = struct {
2898-
ast: Components,
2899-
volatile_token: ?TokenIndex,
2900-
first_clobber: ?TokenIndex,
2901-
outputs: []const Node.Index,
2902-
inputs: []const Node.Index,
2903-
2904-
pub const Components = struct {
2905-
asm_token: TokenIndex,
2906-
template: Node.Index,
2907-
items: []const Node.Index,
2908-
rparen: TokenIndex,
2909-
};
2910-
};
2911-
29122810
pub const Call = struct {
29132811
ast: Components,
29142812

@@ -3905,14 +3803,6 @@ pub const Node = struct {
39053803
///
39063804
/// The `main_token` field is the `asm` token.
39073805
asm_simple,
3908-
/// `asm(lhs, a)`.
3909-
///
3910-
/// The `data` field is a `.node_and_extra`:
3911-
/// 1. a `Node.Index` to lhs.
3912-
/// 2. a `ExtraIndex` to `AsmLegacy`.
3913-
///
3914-
/// The `main_token` field is the `asm` token.
3915-
asm_legacy,
39163806
/// `asm(a, b)`.
39173807
///
39183808
/// The `data` field is a `.node_and_extra`:
@@ -4089,14 +3979,6 @@ pub const Node = struct {
40893979
callconv_expr: OptionalIndex,
40903980
};
40913981

4092-
/// To be removed after 0.15.0 is tagged
4093-
pub const AsmLegacy = struct {
4094-
items_start: ExtraIndex,
4095-
items_end: ExtraIndex,
4096-
/// Needed to make lastToken() work.
4097-
rparen: TokenIndex,
4098-
};
4099-
41003982
pub const Asm = struct {
41013983
items_start: ExtraIndex,
41023984
items_end: ExtraIndex,

0 commit comments

Comments
 (0)