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

Experiment to improve code readability in CodegenXtensa #7471

Draft
wants to merge 2 commits into
base: xtensa-codegen
Choose a base branch
from

Commits on Apr 1, 2023

  1. Experiment to improve code readability in CodegenXtensa

    This is just a draft because (1) it's not complete, and (2) I'm not 100% sure this is the best improvement to make.
    
    The problem I wanted to solve here was that CodeGenXtensa currently has a pervasive pattern of repeated-if-else code to choose the right type, and repeated (redundant) code inside each else clause.
    
    I was hoping that something enabling a more `switch`-like chunk of code would be smaller, easier to read and reason about, and have less redundant chunks (e.g. calls to `print_assignment()` for every type clause which are identical except for the instruction name).
    
    This takes the approach that we can use a map to make `halide_type_t` -> a bespoke enum; if the type is in the map, it means it's equivalent to `is_native_xtensa_vector<>()` returning true. This allows us to use `switch` statements in many places with only a slight overhead, but (maybe?) simpler-to-read code; when combined with judicious use of lambdas, we (hopefully?) get less redundant code.
    
    That said... this still isn't quite as elegant / easy to read as I'd like; whether or not this is enough of an improvement to be worth finishing is a matter I'd like some other folks thoughts on.
    
    Alternately, if someone has an even-better idea for handling all this, I'd love to hear anout it :-)
    steven-johnson committed Apr 1, 2023
    Configuration menu
    Copy the full SHA
    23e6d93 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2c8c363 View commit details
    Browse the repository at this point in the history