Skip to content

Helper for function-scope variables #270

@gmilleramilar

Description

@gmilleramilar

When using the dr::Builder to construct a module during a pass over my AST, I often run into a mid-function variable declaration. The spec for SPIR-V says that those declarations need to go at the beginning of the first block:

2.4 ... All OpVariable instructions in a function must be in the first block in the function. These instructions ... must be the first instructions in that block.

Is there a helper function for writing those declarations in the correct location (even though my current block might not be the first block?). Is there an idiom for that, or an example I can see somewhere?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions