[PowerPC] Add the support for __builtin_setrnd()
authorKang Zhang <shkzhang@cn.ibm.com>
Fri, 29 Mar 2019 08:45:24 +0000 (08:45 +0000)
committerKang Zhang <shkzhang@cn.ibm.com>
Fri, 29 Mar 2019 08:45:24 +0000 (08:45 +0000)
commit05f78b35ae82e371bfa478d02c482c6825c5fd80
tree636b34e45539f366eab7ccb9cf6e3c7d9cdffd14
parent711bea9dedd81cffa4d04dc6bb9edee933e04aaf
[PowerPC] Add the support for __builtin_setrnd()

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).

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D59405

llvm-svn: 357241
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrInfo.td
llvm/test/CodeGen/PowerPC/setrnd.ll [new file with mode: 0644]