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

Capture variables from successful combination of submatches #493

Closed
Declan-ARM opened this issue May 15, 2024 · 5 comments
Closed

Capture variables from successful combination of submatches #493

Declan-ARM opened this issue May 15, 2024 · 5 comments

Comments

@Declan-ARM
Copy link

Hi there,

Hopefully not a silly question, but is there a way to capture the variables of a successful combination of sub-matches?

For example, if I use the following made-up SPIR-V:

    %end = OpVariable %_ptr_Function_int Function
     %15 = OpLoad %int %n
     %16 = OpLoad %int %n
           OpStore %end %16

...the following checks will return false...

const std::string check = R"(
    CHECK:    [[END:%\w+]] = OpVariable
    CHECK: [[LOADED:%\w+]] = OpLoad %int %n
    CHECK:                   OpStore [[END]] [[LOADED]]
)";

...despite OpStore %end %16 being a possibility.

Is there a better syntactical way to capture all possible versions of LOADED and return success if a match is found (instead of stopping after the first match)?

@junyer
Copy link
Contributor

junyer commented May 15, 2024

This is... LLVM's FileCheck, yeah? Doesn't that use LLVM's regular expression engine implementation?

@Declan-ARM
Copy link
Author

Apologies, this is Google's effcee (re2 is a dependency) - I was hoping there might be a way of using the likes of regex submatches to achieve the desired outcome, but wasn't sure.

If it's better to post there, then apologies - I can close this and post there instead.

@junyer
Copy link
Contributor

junyer commented May 17, 2024

Ahh. Yeah, this would be something for that project to consider supporting. It's conceivable that they could collect the multiple values of LOADED and | those values together. It's also conceivable that they could adopt a backtracking approach. It's not possible to solve the problem with a trickier regular expression.

@junyer junyer closed this as completed May 17, 2024
@Declan-ARM
Copy link
Author

Perfect.

Thanks, Paul - appreciate the quick replies 👍

@junyer
Copy link
Contributor

junyer commented May 17, 2024

You're welcome. Good luck! :)

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

No branches or pull requests

2 participants