Skip to content

Commit d2542fa

Browse files
committed
[Heavy] Define heavy::MatchVectorOp
1 parent a5ee3f4 commit d2542fa

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

heavy/include/heavy/Ops.td

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,29 @@ def heavy_MatchTailOp : HeavyOp<"match_tail", []> {
408408
];
409409
}
410410

411+
def heavy_MatchVectorOp : HeavyOp<"match_vector", []> {
412+
let description = [{
413+
Destructure a vector literal with a single, optional subpattern.
414+
The attributes $head and $tail are the number of elements before
415+
and after the subpattern P_e. If P_e does not exist then $tail is 0.
416+
The number of results are $head + $tail + 1 or $head if $tail is 0.
417+
The results are ordered (H... E_e T....) where H and T are the
418+
corresponding head and tail elements and E_e is a list of the
419+
elements to match against the subpattern.
420+
}];
421+
422+
let arguments = (ins UI32Attr:$head,
423+
UI32Attr:$tail,
424+
HeavyValue:$input);
425+
let results = (outs Variadic<HeavyValue>:$results);
426+
427+
let builders = [
428+
OpBuilder<(ins "uint32_t":$head,
429+
"uint32_t":$tail,
430+
"::mlir::Value":$input)>
431+
];
432+
}
433+
411434
def heavy_MatchArgsOp : HeavyOp<"match_args"> {
412435
let description = [{
413436
Destructure a dynamically lengthed array (ValueRefs) using the type

0 commit comments

Comments
 (0)