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

Think about removal of custom TypeTraits #659

Open
1 task done
Jezurko opened this issue Jul 9, 2024 · 0 comments
Open
1 task done

Think about removal of custom TypeTraits #659

Jezurko opened this issue Jul 9, 2024 · 0 comments

Comments

@Jezurko
Copy link
Collaborator

Jezurko commented Jul 9, 2024

Prerequisites

  • I have read the documentation and the proposed feature is not implemented.

Description

Currently, we have several custom type traits (in include/vast/Dialect/Core/Utils.td and include/vast/Dialect/Core/TypeTraits.hpp) to generate traits for Operation verifiers.
E.g.

class IsPointer< string arg > : PredOpTrait< "value is of a pointer type",
    CPred< "$" # arg # ".getType().hasTrait< mlir::TypeTrait::PointerTypeTrait >()" >
>;

and(CORE_TRAIT is our own macro):

CORE_TRAIT(PointerTypeTrait);

and adding the trait to the relevant types (in this case PointerType and DecayedType).

Instead, we could have (in include/vast/Dialect/Highlevel/HighlevelTypes.td):

class IsPointer< string arg > : PredOpTrait< "IsTypedef",
  SubstLeaves< "$_self", "$" # arg #".getType()", Or< [PointerType.predicate, DecayedType.predicate] > >
>;

without any additional code.

Advantages:

  • Reduced amount of code
  • It can be defined within the related dialect
  • To me it seems a bit more uniform with how the rest of the verification is done
  • I vaguely remember, that having to write the C++ code (in TypeTraits.hpp) might be problematic for dynamic dialects or something like that (@xlauko might remember more?)

Disadvantages:

  • TypeTraits are a bit more flexible (anyone can pass their type into our operations by adding the trait to it)
  • TypeTraits can be used by multiple dialects in VAST (although I don't believe that's the case right now)
  • The information about the predicate is further from the type itself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants