This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add frexp{f,l} libcall signatures
ClosedPublic

Authored by dschuff on Jul 6 2023, 11:45 AM.

Details

Summary

The llvm.frexp.* family of intrinsics and their corresponding libcalls were
recently added, which means we need to know their signatures.

Fixed: https://github.com/llvm/llvm-project/issues/63657

Diff Detail

Event Timeline

dschuff created this revision.Jul 6 2023, 11:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 11:45 AM
Herald added subscribers: pmatos, asb, wingo and 4 others. · View Herald Transcript
dschuff requested review of this revision.Jul 6 2023, 11:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 11:45 AM
dschuff edited the summary of this revision. (Show Details)Jul 6 2023, 11:47 AM
dschuff added reviewers: aheejin, tlively.
sunfish accepted this revision.Jul 6 2023, 11:47 AM
This revision is now accepted and ready to land.Jul 6 2023, 11:47 AM
sbc100 added inline comments.Jul 6 2023, 11:51 AM
llvm/test/CodeGen/WebAssembly/libcalls.ll
261

How is llvm.frexp.f64.i32 implemented? Is it supposed to be the name of a function compiler-rt?

dschuff added inline comments.Jul 6 2023, 12:52 PM
llvm/test/CodeGen/WebAssembly/libcalls.ll
261

it's a libm function, like the other functions in this test. IIRC some of the libcalls might be compiler-rt, I'm not sure LLVM differentiates. Also the list of intrinsics doesn't really differentiate between ones that lower directly to libcalls and ones that don't, because it depends on the architecture (e.g. if there are instructions that map directly or not). In this case wasm doesn't really have a direct equivalent for frexp.

sbc100 added inline comments.Jul 6 2023, 1:04 PM
llvm/test/CodeGen/WebAssembly/libcalls.ll
261

But how can libm implement a function called llvm.frexp.f64.i32.. wouldn't you need a name without periods in it if you want to be able to implement it in C?

261

The other callees here have names like __powidf2

dschuff updated this revision to Diff 537850.Jul 6 2023, 1:21 PM

Fix test

dschuff added inline comments.Jul 6 2023, 1:23 PM
llvm/test/CodeGen/WebAssembly/libcalls.ll
261

Sorry, the target-independent lowering code translates the intrinsic (named @llvm.frexp.f64.i32 or @llvm.frexp.f32.i32) into a call to the library function (named frexp or frexpf).

Oh, but I see the problem here, the call in the generated code in this test is wrong! It looks like there was some kind of accident with update_llc_check_tests.py, I'm not sure what happened there. I fixed that

(Also yes, I missed __powidf2. I assume that one is a compiler-rt function)

dschuff updated this revision to Diff 537858.Jul 6 2023, 1:23 PM

fix upload

sbc100 accepted this revision.Jul 6 2023, 1:25 PM
This revision was landed with ongoing or failed builds.Jul 6 2023, 1:37 PM
This revision was automatically updated to reflect the committed changes.