Skip to content

Commit

Permalink
Better name for inout / out argument placeholder variables
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Korobeynikov <[email protected]>
  • Loading branch information
asl committed Feb 10, 2025
1 parent 3c52506 commit db53ecb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/Translate/Ops/calls.p4
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ action bazz(in int<16> arg1) {
// CHECK: p4hir.call @bar() : () -> ()
bar();
// CHECK: p4hir.scope
// CHECK: %[[VAR_A:.*]] = p4hir.variable ["a_out"] : <!i16i>
// CHECK: %[[VAR_A:.*]] = p4hir.variable ["a_out_arg"] : <!i16i>
// CHECK: p4hir.call @quuz(%[[VAR_A]]) : (!p4hir.ref<!i16i>) -> ()
// CHECK: p4hir.read %[[VAR_A]] : <!i16i>
int<16> val;
quuz(val);
// CHECK: p4hir.scope
// CHECK: %[[VAR_X:.*]] = p4hir.variable ["x_inout", init] : <!i16i>
// CHECK: %[[VAR_X:.*]] = p4hir.variable ["x_inout_arg", init] : <!i16i>
// CHECK: %[[VAL_X:.*]] = p4hir.read %[[VAL:.*]] : <!i16i>
// CHECK: p4hir.assign %[[VAL_X]], %[[VAR_X]] : <!i16i>
// CHECK: p4hir.call @baz(%[[VAR_X]])
Expand Down
4 changes: 2 additions & 2 deletions test/Translate/Ops/function.p4
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ action test_param() {
// CHECK-LABEL: p4hir.func action @test_param() {
// CHECK: %[[A:.*]] = p4hir.variable ["a"] : <!b1i>
// CHECK: p4hir.scope {
// CHECK: %[[X_INOUT:.*]] = p4hir.variable ["x_inout", init] : <!b1i>
// CHECK: %[[X_INOUT:.*]] = p4hir.variable ["x_inout_arg", init] : <!b1i>
// CHECK: %[[A_VAL:.*]] = p4hir.read %[[A]] : <!b1i>
// CHECK: p4hir.assign %[[A_VAL]], %[[X_INOUT]] : <!b1i>
// CHECK: %[[G_VAL:.*]] = p4hir.scope {
// CHECK: %[[Z_INOUT:.*]] = p4hir.variable ["z_inout", init] : <!b1i>
// CHECK: %[[Z_INOUT:.*]] = p4hir.variable ["z_inout_arg", init] : <!b1i>
// CHECK: %[[A_VAL2:.*]] = p4hir.read %[[A]] : <!b1i>
// CHECK: p4hir.assign %[[A_VAL2]], %[[Z_INOUT]] : <!b1i>
// CHECK: %[[G_RES:.*]] = p4hir.call @g(%[[Z_INOUT]]) : (!p4hir.ref<!b1i>) -> !b1i
Expand Down
5 changes: 3 additions & 2 deletions tools/p4mlir-translate/translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,9 @@ bool P4HIRConverter::preorder(const P4::IR::MethodCallExpression *mce) {
auto copyIn = b.create<P4HIR::VariableOp>(
loc, ref,
mlir::StringAttr::get(
context(), llvm::Twine(params[idx]->name.string_view()) +
(dir == P4::IR::Direction::InOut ? "_inout" : "_out")));
context(),
llvm::Twine(params[idx]->name.string_view()) +
(dir == P4::IR::Direction::InOut ? "_inout_arg" : "_out_arg")));

if (dir == P4::IR::Direction::InOut) {
copyIn.setInit(true);
Expand Down

0 comments on commit db53ecb

Please sign in to comment.