Skip to content
  • Kenneth Graunke's avatar
    glsl: Convert ir_call to be a statement rather than a value. · d884f608
    Kenneth Graunke authored
    
    
    Aside from ir_call, our IR is cleanly split into two classes:
    - Statements (typeless; used for side effects, control flow)
    - Values (deeply nestable, pure, typed expression trees)
    
    Unfortunately, ir_call confused all this:
    - For void functions, we placed ir_call directly in the instruction
      stream, treating it as an untyped statement.  Yet, it was a subclass
      of ir_rvalue, and no other ir_rvalue could be used in this way.
    - For functions with a return value, ir_call could be placed in
      arbitrary expression trees.  While this fit naturally with the source
      language, it meant that expressions might not be pure, making it
      difficult to transform and optimize them.  To combat this, we always
      emitted ir_call directly in the RHS of an ir_assignment, only using
      a temporary variable in expression trees.  Many passes relied on this
      assumption; the acos and atan built-ins violated it.
    
    This patch makes ir_call a statement (ir_instruction) rather than a
    value (ir_rvalue).  Non-void calls now take a ir_dereference of a
    variable, and store the return value there---effectively a call and
    assignment rolled into one.  They cannot be embedded in expressions.
    
    All expression trees are now pure, without exception.
    
    Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: default avatarEric Anholt <eric@anholt.net>
    Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
    d884f608