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

simplify foreigncall handling #554

Merged
merged 1 commit into from
Dec 8, 2022
Merged

simplify foreigncall handling #554

merged 1 commit into from
Dec 8, 2022

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Dec 6, 2022

Instead of reconstructing the surface syntax we can just pass along the arguments to a Expr(:foreigncall, ...).

Fixes #552

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Merging #554 (87c7c07) into master (39d04c7) will decrease coverage by 0.53%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #554      +/-   ##
==========================================
- Coverage   86.80%   86.26%   -0.54%     
==========================================
  Files          12       12              
  Lines        2539     2505      -34     
==========================================
- Hits         2204     2161      -43     
- Misses        335      344       +9     
Impacted Files Coverage Δ
src/optimize.jl 93.93% <100.00%> (-3.65%) ⬇️
src/utils.jl 88.60% <0.00%> (+0.21%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Keno
Copy link
Member

Keno commented Dec 6, 2022

Fixes #552, hopefully

@KristofferC
Copy link
Member Author

Some of the code needs to be put back to handle e.g. the

function add1234(x::Tuple{Int32,Int32,Int32,Int32})
    Base.llvmcall("""%3 = extractvalue [4 x i32] %0, 0
      %4 = extractvalue [4 x i32] %0, 1
      %5 = extractvalue [4 x i32] %0, 2
      %6 = extractvalue [4 x i32] %0, 3
      %7 = extractvalue [4 x i32] %1, 0
      %8 = extractvalue [4 x i32] %1, 1
      %9 = extractvalue [4 x i32] %1, 2
      %10 = extractvalue [4 x i32] %1, 3
      %11 = add i32 %3, %7
      %12 = add i32 %4, %8
      %13 = add i32 %5, %9
      %14 = add i32 %6, %10
      %15 = insertvalue [4 x i32] undef, i32 %11, 0
      %16 = insertvalue [4 x i32] %15, i32 %12, 1
      %17 = insertvalue [4 x i32] %16, i32 %13, 2
      %18 = insertvalue [4 x i32] %17, i32 %14, 3
      ret [4 x i32] %18""",a,
      Tuple{Tuple{Int32,Int32,Int32,Int32},Tuple{Int32,Int32,Int32,Int32}},
        (Int32(1),Int32(2),Int32(3),Int32(4)),
        x)
end
@test @interpret(add1234(map(Int32,(2,3,4,5)))) === map(Int32,(3,5,7,9))

case

@KristofferC KristofferC marked this pull request as ready for review December 7, 2022 09:32
@KristofferC KristofferC changed the title wip: simplify foreigncall handling simplify foreigncall handling Dec 7, 2022
@KristofferC KristofferC force-pushed the foreigncall branch 2 times, most recently from f770f6b to f06c55f Compare December 7, 2022 09:53
Copy link
Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failures in nightly CI are known and unrelated. Thanks so much for working on this!

@aviatesk aviatesk merged commit be125b1 into master Dec 8, 2022
@aviatesk aviatesk deleted the foreigncall branch December 8, 2022 02:04
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

Successfully merging this pull request may close these issues.

foreigncall handling is not semantically correct
3 participants