Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTL] Add pattern matching to rtl tests #59

Merged
merged 2 commits into from
Jul 29, 2020
Merged

Conversation

amaleewilson
Copy link
Contributor

@amaleewilson amaleewilson commented Jul 29, 2020

Updates the RTL tests to use pattern matching instead of hardcoded ssa values. Addresses #24

@amaleewilson amaleewilson changed the title Add pattern matching to rtl tests Add pattern matching to rtl tests, addresses #24 Jul 29, 2020
@amaleewilson amaleewilson changed the title Add pattern matching to rtl tests, addresses #24 Add pattern matching to rtl tests Jul 29, 2020
@amaleewilson amaleewilson changed the title Add pattern matching to rtl tests [RTL] Add pattern matching to rtl tests Jul 29, 2020
Copy link
Collaborator

@lattner lattner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

test/rtl/basic.mlir Show resolved Hide resolved
@amaleewilson amaleewilson merged commit 3368e44 into master Jul 29, 2020
@lattner
Copy link
Collaborator

lattner commented Jul 29, 2020

Thanks!

// CHECK-NEXT: %0 = rtl.add %c42_i12, %c42_i12 : i12
// CHECK-NEXT: %1 = rtl.mul %c42_i12, %0 : i12
// CHECK-NEXT: %[[RES0:.*]] = rtl.add %c42_i12, %c42_i12 : i12
// CHECK-NEXT: %[[RES1:.*]] = rtl.mul %c42_i12, %[[RES0:.*]] : i12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[[RES0:.*]] is a capture expression. To use the captured value as a pattern, you need to use [[RES0]].
Since the test only uses capture expressions, this is equivalent to just use wildcards as in:

// CHECK-NEXT:    %{{.*}} = rtl.mul %c42_i12, %{{.*}} : i12

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch I should have noticed that. Thank you!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if you expect a number, you can be more specific and use [[RES0:[0-9]+]]. As a question of style, I would probably also include the % to the pattern: [[RES0:%[0-9]+]].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jprotze!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally just write .* because it is unambiguous and the pattern is simpler, but we're now so far down the line of personal preference that anything is fine :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants