Skip to content

Split context manager for if-then into two new blocks #742

Open
@Zelatrix

Description

@Zelatrix

I am trying to use LLVM lite to implement a while loop construct. I know the IR for this, but I am having trouble implementing this in Python. I believe that the reason for this is because the current implementation of the if-then context manager contains the following basic blocks:

entry:
    instructions
entry.if:
    instrs
entry.endif
    instrs

I believe that in order to be able to use this context manager, unless there is another way to do it with the current implementation, it should have the entry block split in two, like so:

entry:
    instructions
entry.cond:
    instrs
entry.if:
    instrs
entry.endif
    instrs

This way, users would be able to jump specifically back into the conditional basic block and avoid reinitialising any variables defined outside of the if statement, allowing for code such as:

int main() {
    int x = 10;
    START: if(x > 0) {
    printf("%d\n", x);
    x -= 1;
    goto START;
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions