This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck] Add saturation support to numerical expressions.
AbandonedPublic

Authored by paulwalker-arm on May 13 2020, 9:37 AM.

Details

Reviewers
thopre
Summary

Add support for named operations to numerical expressions, which
take the form ".<name>.". This support has been used to add the
following named operations:

usat_high : Clamp LHS to be no bigger than RHS.
usat_low  : Clamp LHS to be no smaller than LHS.

Diff Detail

Event Timeline

paulwalker-arm created this revision.May 13 2020, 9:37 AM

Was this intended for upstream? I see lots of code not in upstream FileCheck (e.g. mul).

Was this intended for upstream? I see lots of code not in upstream FileCheck (e.g. mul).

My bad, saw that patch before the other one.

It was me at fault. I've just started using arc and had assumed "arc diff" would create a review for each commit. Either that or I'm just using it wrong.

I'm not a big fan of the syntax, why not introduce a functional notation instead? E.g. CHECK-NEXT: #min(VAR1,20). Also since the operation you perform is min and max why not use these instead of usat_high and usat_low?

I'll admit the syntax comes from laziness, or rather trying to implement the feature within the confines of the current design with minimal effort. Implementing real function support seemed like a considerable undertaking because then it opens up having to distinguish between function names and variable names (e.g. when parentheses are also used to define scope and precedence) plus nested function calls.

The current design suggested a simple left to right parsing structure so that's what I went with. The naming supports this because min suggests picking between multiple operands, whereas usat_high is an operation applied to a single operand.

I can investigate the function route but I cannot help but wonder if we'll just get to the point where it's better to use an existing language parser than invent a new one.

I've created D79936 as potential replacement for this patch.

I'll admit the syntax comes from laziness, or rather trying to implement the feature within the confines of the current design with minimal effort. Implementing real function support seemed like a considerable undertaking because then it opens up having to distinguish between function names and variable names (e.g. when parentheses are also used to define scope and precedence) plus nested function calls.

The current design suggested a simple left to right parsing structure so that's what I went with. The naming supports this because min suggests picking between multiple operands, whereas usat_high is an operation applied to a single operand.

I can investigate the function route but I cannot help but wonder if we'll just get to the point where it's better to use an existing language parser than invent a new one.

Yes that would be better, but I suspect it would have to be something provided by LLVM to not bring a huge dependency for a small tool. The current parsing code is my own fault and stems from my inexperience in the domain of parsing.

paulwalker-arm abandoned this revision.May 15 2020, 10:45 AM