This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Add the support for __builtin_setrnd()
ClosedPublic

Authored by ZhangKang on Mar 14 2019, 7:59 PM.

Details

Summary

PowerPC64/PowerPC64le supports the builtin function __builtin_setrnd to set the floating point rounding mode. This function will use the least significant two bits of integer argument to set the floating point rounding mode.

double __builtin_setrnd(int mode);

The effective values for mode are:

0 - round to nearest
1 - round to zero
2 - round to +infinity
3 - round to -infinity

Note that the mode argument will modulo 4, so if the int argument is greater than 3, it will only use the least significant two bits of the mode. Namely, builtin_setrnd(102)) is equal to builtin_setrnd(2).

Diff Detail

Repository
rL LLVM

Event Timeline

ZhangKang created this revision.Mar 14 2019, 7:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2019, 7:59 PM
ZhangKang updated this revision to Diff 190779.Mar 14 2019, 8:33 PM

Add the test file.

jsji accepted this revision.Mar 28 2019, 12:17 PM

LGTM, with some comment change please. Thanks.

llvm/include/llvm/IR/IntrinsicsPowerPC.td
1170 ↗(On Diff #190779)

this is set only? remove get in comment.

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
10996 ↗(On Diff #190779)

Typo? two G8RCRegClass here!

11022 ↗(On Diff #190779)

Load from the stack which SrcReg stored into DestReg => Load from the stack where SrcReg is stored, and save to DestReg

11037 ↗(On Diff #190779)

using the two -> use two

llvm/lib/Target/PowerPC/PPCInstrInfo.td
1313 ↗(On Diff #190779)

round mode => rounding mode

This revision is now accepted and ready to land.Mar 28 2019, 12:17 PM
ZhangKang updated this revision to Diff 192766.Mar 28 2019, 7:16 PM

Modify the comments to follow reviewer's comments..

ZhangKang marked 6 inline comments as done.Mar 28 2019, 7:18 PM
ZhangKang added inline comments.
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
10996 ↗(On Diff #190779)

Yes, it a typo, I have fixed it.

ZhangKang marked an inline comment as done.Mar 28 2019, 7:20 PM
This revision was automatically updated to reflect the committed changes.