Skip to content

Commit f6b1ef1

Browse files
committed
[Heavy] Remove ApplyActionOp
1 parent 1e5b6dc commit f6b1ef1

File tree

3 files changed

+22
-35
lines changed

3 files changed

+22
-35
lines changed

heavy/include/nbdl_gen/Nbdl.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,6 @@ def Nbdl_VisitOp : Nbdl_Op<"visit", []> {
358358
let results = (outs Nbdl_Type:$result);
359359
}
360360

361-
def Nbdl_ApplyActionOp : Nbdl_Op<"apply_action", [Terminator]> {
362-
let description = [{
363-
Create a call to nbdl::apply_action which is dispatched
364-
by the type of the LHS in C++.
365-
}];
366-
let arguments = (ins Nbdl_Type:$lhs, Variadic<Nbdl_Type>:$args);
367-
let results = (outs);
368-
}
369-
370361
def Nbdl_ConsumerOp : Nbdl_Op<"consumer", []> {
371362
let description = [{
372363
A consumer is an object provided with an object
@@ -389,8 +380,6 @@ def Nbdl_ConstOp : Nbdl_Op<"const", []> {
389380
We don't modify the type in IR land but rely on C++
390381
to manage underlying types. This is analogous to an
391382
immutable borrow I think.
392-
We generally only allow mutation to occur to the operands
393-
of nbdl.apply_action or nbdl.resolve.
394383
}];
395384

396385
let arguments = (ins Nbdl_Type:$arg);

heavy/lib/Nbdl/NbdlWriter.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ class FuncWriter : public NbdlWriter<FuncWriter> {
359359
else if (isa<MatchIfOp>(Op)) return Visit(cast<MatchIfOp>(Op));
360360
else if (isa<FuncOp>(Op)) return Visit(cast<FuncOp>(Op));
361361
else if (isa<StoreComposeOp>(Op)) return Visit(cast<StoreComposeOp>(Op));
362-
else if (isa<ApplyActionOp>(Op)) return Visit(cast<ApplyActionOp>(Op));
363362
else if (isa<ScopeOp>(Op))
364363
return VisitRegion(cast<ScopeOp>(Op).getBody());
365364
else if (isa<ConstexprOp, LiteralOp>(Op)) return;
@@ -454,17 +453,6 @@ class FuncWriter : public NbdlWriter<FuncWriter> {
454453
// Do nothing.
455454
}
456455

457-
void Visit(ApplyActionOp Op) {
458-
OS << "::nbdl::apply_action(";
459-
WriteExpr(Op.getLhs());
460-
OS << ", ";
461-
llvm::interleave(Op.getArgs(), OS,
462-
[&](mlir::Value V) {
463-
WriteExpr(V);
464-
}, ",\n");
465-
OS << ");\n";
466-
}
467-
468456
void Visit(StoreComposeOp Op) {
469457
// Note the C++ function does (Key, Rhs, Lhs) for some reason.
470458
OS << "auto ";

heavy/test/Nbdl/apply_action.scm renamed to heavy/test/Nbdl/close_previous_scope.scm

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,24 @@
1010
(define !nbdl.store (type "!nbdl.store"))
1111
(define !nbdl.unit (type "!nbdl.unit"))
1212
(define !nbdl.symbol (type "!nbdl.symbol"))
13+
(define !nbdl.unit (type "!nbdl.unit"))
1314
(define i32 (type "i32"))
1415

16+
(define (resolve . args)
17+
(define Result
18+
(result
19+
(create-op "nbdl.visit"
20+
(loc: 0)
21+
(operands: args)
22+
(attributes:)
23+
(result-types: !nbdl.unit)
24+
)))
25+
(create-op "nbdl.discard"
26+
(loc: 0)
27+
(operands: Result)
28+
(attributes:)
29+
(result-types:)))
30+
1531
(define my_match_params
1632
(%build-match-params
1733
'my_match_params
@@ -53,11 +69,8 @@
5369
("type" (string-attr "std::string")))
5470
(result-types:)
5571
(region: "body" ((MatchedStore : !nbdl.store))
56-
(create-op "nbdl.apply_action"
57-
(loc: 0)
58-
(operands: MatchedStore Foo)
59-
(attributes:)
60-
(result-types:))))))
72+
(resolve MatchedStore Foo)
73+
))))
6174
; Foo is not allowed after this (because it could be invalidated.)
6275
(close-previous-scope)
6376
(close-previous-scope) ; Should do nothing.
@@ -68,17 +81,14 @@
6881
(attributes:
6982
("expr" (string-attr "::some_tag{}")))
7083
(result-types: !nbdl.store)))))
71-
(create-op "nbdl.apply_action"
72-
(loc: 0)
73-
(operands: Store SomeTag)
74-
(attributes:)
75-
(result-types:))))))
84+
(resolve
85+
Store SomeTag)))))
7686

7787
(unless (verify current-nbdl-module)
7888
(error "verification failed {}" my_match_params))
7989

8090
; TODO Handle perfect forwarding.
81-
; CHECK: nbdl::apply_action(arg_3, get_2)
82-
; CHECK: nbdl::apply_action(arg_0, ::some_tag{})
91+
; CHECK: arg_3(get_2);
92+
; CHECK: arg_0(::some_tag{});
8393
(translate-cpp my_match_params)
8494
(newline)

0 commit comments

Comments
 (0)