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

[challenge] rand #14

Closed
mewmew opened this issue Nov 24, 2015 · 1 comment
Closed

[challenge] rand #14

mewmew opened this issue Nov 24, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@mewmew
Copy link
Member

mewmew commented Nov 24, 2015

"The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time."
— Tom Cargill, Bell Labs

To encourage the development of the final 10%, a set of challenges have been produced. This is a meta-issue to track the rand challenge of the parse-me repository.

Once these challenges have been beaten, lexing, parsing, and potentially type checking of LLVM IR assembly will have been implemented. At this point, the project is ready for an API overhaul and will welcome an open discussion with other members of the community interested in finding a clean, minimal API for interacting with LLVM IR.

Note: there will exist several, almost identical, challenge issues. The main reason for this is that the developer finds childish joy in closing issues once a challenge has been beaten :)

@mewmew mewmew added the meta label Nov 24, 2015
@mewmew mewmew self-assigned this Nov 24, 2015
@mewmew mewmew added this to the v0.2 milestone Nov 24, 2015
@mewmew
Copy link
Member Author

mewmew commented May 25, 2016

lparse is now capable of parsing rand.ll.

u@x1 ~/D/g/s/g/m/p/rand> lparse rand.ll 
Parsing "rand.ll"
<*>@seed = global i32 1234
define i32 @abs(i32 %x) {
0:
    %1 = icmp slt i32 %x, 0
    br i1 %1, label %2, label %4
2:
    %3 = sub i32 0, %x
    br label %5
4:
    br label %5
5:
    %.0 = phi i32 [ %3, %2 ], [ %x, %4 ]
    ret i32 %.0
}
define i32 @rand() {
0:
    %1 = load i32, i32* @seed
    %2 = mul i32 22695477, %1
    %3 = add i32 %2, 1
    store i32 %3, i32* @seed
    %4 = load i32, i32* @seed
    %5 = call i32 @abs(i32 %4)
    ret i32 %5
}

@mewmew mewmew closed this as completed May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant