diff options
| author | Artem Belevich <tra@google.com> | 2018-04-06 22:25:08 +0000 |
|---|---|---|
| committer | Artem Belevich <tra@google.com> | 2018-04-06 22:25:08 +0000 |
| commit | f256decdc4d68b3803af92db58edbbc98891c54f (patch) | |
| tree | f3eb4b8311e389a45b0fbab6d6b932e5603a4e67 /llvm/lib/Target | |
| parent | 4c1112612caa8fad5aab686ddfdef809abcfe841 (diff) | |
| download | bcm5719-llvm-f256decdc4d68b3803af92db58edbbc98891c54f.tar.gz bcm5719-llvm-f256decdc4d68b3803af92db58edbbc98891c54f.zip | |
[NVPTX] add support for initializing fp16 arrays.
Previously HalfTy was not handled which would either trigger an assertion,
or result in array initialized with garbage.
Differential Revision: https://reviews.llvm.org/D45391
llvm-svn: 329463
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 357e24136a5..2fd0689b1aa 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1945,11 +1945,17 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes, llvm_unreachable("unsupported integer const type"); break; } + case Type::HalfTyID: case Type::FloatTyID: case Type::DoubleTyID: { const ConstantFP *CFP = dyn_cast<ConstantFP>(CPV); Type *Ty = CFP->getType(); - if (Ty == Type::getFloatTy(CPV->getContext())) { + if (Ty == Type::getHalfTy(CPV->getContext())) { + APInt API = CFP->getValueAPF().bitcastToAPInt(); + uint16_t float16 = API.getLoBits(16).getZExtValue(); + ConvertIntToBytes<>(ptr, float16); + aggBuffer->addBytes(ptr, 2, Bytes); + } else if (Ty == Type::getFloatTy(CPV->getContext())) { float float32 = (float) CFP->getValueAPF().convertToFloat(); ConvertFloatToBytes(ptr, float32); aggBuffer->addBytes(ptr, 4, Bytes); |

