Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • pystencils pystencils
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 6
    • Merge requests 6
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pycodegen
  • pystencilspystencils
  • Merge requests
  • !257

Bit Flag Conditional

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Frederik Hennig requested to merge da15siwa/pystencils:bit_masks into master Jul 02, 2021
  • Overview 2
  • Commits 5
  • Pipelines 3
  • Changes 3

This MR introduces a bit flag conditional that acts like a ternary operator for a single bit flag. It takes at least three arguments:

  • flag_bit specifies which bit of the mask is examined
  • mask_expression is an integer-typed expression which acts as a bit mask
  • then_expression is a SymPy expression of arbitrary type, and
  • optionally else_expression is a SymPy expression of arbitrary type

flag_cond examines the given bit of the given mask and takes the value of then_expression if the bit is set to 1. If not, it becomes either 0 or else_expression:

Three argument version:

    flag_cond(flag_bit, mask, expr) = expr if (flag_bit is set in mask) else 0

Four argument version:

    flag_cond(flag_bit, mask, expr_then, expr_else) = expr_then if (flag_bit is set in mask) else expr_else
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: bit_masks