Skip to content

Commit

Permalink
Merge #59
Browse files Browse the repository at this point in the history
59: extend llvm-ir parser to handle libstd's IR r=japaric a=japaric

fixes #58 

Co-authored-by: Jorge Aparicio <[email protected]>
  • Loading branch information
bors[bot] and japaric authored Jun 22, 2022
2 parents f03feb6 + 8c6d14a commit 6e43fe7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
override: true
profile: minimal
target: thumbv7m-none-eabi
toolchain: nightly
toolchain: nightly-2022-06-18
- run: cargo install --path . --debug
- name: Can analyze example firmware
run: cargo test
Expand Down
4 changes: 4 additions & 0 deletions src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ mod tests {
assert_eq!(super::local("%."), Ok(("", Local)));

assert_eq!(super::local("%.9"), Ok(("", Local)));

assert_eq!(super::local("%f"), Ok(("", Local)));

assert_eq!(super::local("%_17.0.i.i.i.i.i"), Ok(("", Local)));
}

#[test]
Expand Down
19 changes: 15 additions & 4 deletions src/ir/define.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ fn indirect_call(i: &str) -> IResult<&str, Stmt> {
.0;
let (i, output) = alt((map(super::type_, Some), map(tag("void"), |_| None)))(i)?;
let i = space1(i)?.0;
let i = char('%')(i)?.0;
let i = opt(char('_'))(i)?.0;
let i = digit1(i)?.0;
let i = many0(|i| tag(".i")(i))(i)?.0;
let i = super::local(i)?.0;
let (i, inputs) = delimited(
char('('),
separated_list(
Expand Down Expand Up @@ -517,6 +514,20 @@ mod tests {
);
}

#[test]
fn call_gh58() {
assert_eq!(
super::indirect_call("tail call void %f()"),
Ok((
"",
Stmt::IndirectCall(FnSig {
inputs: vec![],
output: None,
})
))
);
}

#[test]
fn label() {
assert_eq!(
Expand Down

0 comments on commit 6e43fe7

Please sign in to comment.