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

loop unroll for values known at compile time #123

Open
vitreo12 opened this issue Oct 1, 2020 · 1 comment
Open

loop unroll for values known at compile time #123

vitreo12 opened this issue Oct 1, 2020 · 1 comment

Comments

@vitreo12
Copy link
Owner

vitreo12 commented Oct 1, 2020

As of now, all loop with integer literals are unrolled:

loop 4 i:
    print i

In the typed section, however, it would be cool to unroll all loops where the integer is known (like coming from a const)

CONST = 4 #known at compile time
loop CONST i:
    print i
@vitreo12
Copy link
Owner Author

vitreo12 commented Oct 2, 2020

Also, this would require a new const mechanism for def arguments:

def something_unroll(AMT):
    loop AMT i: #<-- with this mechanism, this will be unrolled!
        print i

def something_normal(amt):
    loop amt i: #<-- not unrolled, amt is not a const
        print i

init:
    something_unroll 10
    something_unroll 5
    
    CONST = 10; something_unroll CONST #All good, explicit const
    CONST = in1; something_unroll CONST #<-- ERROR: CONST value not known at compile time

    a = 10; something_unroll a #<-- ERROR: a is not an int or float lit!
    a = 10; something_normal a #<-- This would still work, normal call

For implementation specifics, check explicitUnrolls/explicitUnroll.nim in omni_lang/tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant