diff options
author | Artem Belevich <tra@google.com> | 2017-01-13 20:56:17 +0000 |
---|---|---|
committer | Artem Belevich <tra@google.com> | 2017-01-13 20:56:17 +0000 |
commit | 64dc9be7b48e3e3ec1f7dec270bf433d2084915a (patch) | |
tree | ca4f810515a29fb080b1341aaee69917aadc06b0 /llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp | |
parent | 836a3b416d222f0703d2e964a8e08f3892dd0278 (diff) | |
download | bcm5719-llvm-64dc9be7b48e3e3ec1f7dec270bf433d2084915a.tar.gz bcm5719-llvm-64dc9be7b48e3e3ec1f7dec270bf433d2084915a.zip |
[NVPTX] Added support for half-precision floating point.
Only scalar half-precision operations are supported at the moment.
- Adds general support for 'half' type in NVPTX.
- fp16 math operations are supported on sm_53+ GPUs only
(can be disabled with --nvptx-no-f16-math).
- Type conversions to/from fp16 are supported on all GPU variants.
- On GPU variants that do not have full fp16 support (or if it's disabled),
fp16 operations are promoted to fp32 and results are converted back
to fp16 for storage.
Differential Revision: https://reviews.llvm.org/D28540
llvm-svn: 291956
Diffstat (limited to 'llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp')
-rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp b/llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp index eab5ee80561..86a28f7d070 100644 --- a/llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp @@ -27,6 +27,13 @@ void NVPTXFloatMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const { switch (Kind) { default: llvm_unreachable("Invalid kind!"); + case VK_NVPTX_HALF_PREC_FLOAT: + // ptxas does not have a way to specify half-precision floats. + // Instead we have to print and load fp16 constants as .b16 + OS << "0x"; + NumHex = 4; + APF.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &Ignored); + break; case VK_NVPTX_SINGLE_PREC_FLOAT: OS << "0f"; NumHex = 8; |