| 1 | //===- DirectXTargetTransformInfo.cpp - DirectX TTI ---------------*- C++ |
|---|---|
| 2 | //-*-===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | |
| 12 | #include "DirectXTargetTransformInfo.h" |
| 13 | #include "llvm/IR/Intrinsics.h" |
| 14 | #include "llvm/IR/IntrinsicsDirectX.h" |
| 15 | |
| 16 | using namespace llvm; |
| 17 | |
| 18 | bool DirectXTTIImpl::isTargetIntrinsicWithScalarOpAtArg( |
| 19 | Intrinsic::ID ID, unsigned ScalarOpdIdx) const { |
| 20 | switch (ID) { |
| 21 | case Intrinsic::dx_wave_readlane: |
| 22 | return ScalarOpdIdx == 1; |
| 23 | case Intrinsic::dx_wave_multi_prefix_bit_and: |
| 24 | case Intrinsic::dx_wave_multi_prefix_bit_or: |
| 25 | case Intrinsic::dx_wave_multi_prefix_bit_xor: |
| 26 | case Intrinsic::dx_wave_multi_prefix_product: |
| 27 | case Intrinsic::dx_wave_multi_prefix_uproduct: |
| 28 | case Intrinsic::dx_wave_multi_prefix_sum: |
| 29 | case Intrinsic::dx_wave_multi_prefix_usum: |
| 30 | return ScalarOpdIdx >= 1 && ScalarOpdIdx <= 4; |
| 31 | default: |
| 32 | return false; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | bool DirectXTTIImpl::isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, |
| 37 | int OpdIdx) const { |
| 38 | switch (ID) { |
| 39 | case Intrinsic::dx_asdouble: |
| 40 | case Intrinsic::dx_firstbitlow: |
| 41 | case Intrinsic::dx_firstbitshigh: |
| 42 | case Intrinsic::dx_firstbituhigh: |
| 43 | case Intrinsic::dx_isfinite: |
| 44 | case Intrinsic::dx_isinf: |
| 45 | case Intrinsic::dx_isnan: |
| 46 | case Intrinsic::dx_legacyf16tof32: |
| 47 | case Intrinsic::dx_legacyf32tof16: |
| 48 | case Intrinsic::dx_wave_all_equal: |
| 49 | return OpdIdx == 0; |
| 50 | default: |
| 51 | // All DX intrinsics are overloaded on return type unless specified |
| 52 | // otherwise |
| 53 | return OpdIdx == -1; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | unsigned DirectXTTIImpl::getMinimumLookupTableEntryBitWidth() const { |
| 58 | // DXIL does not support i8, so switch lookup tables must not be narrowed |
| 59 | // below the minimum legal integer width. When native 16-bit types are |
| 60 | // enabled (-enable-16bit-types) the minimum is i16, otherwise it is i32. |
| 61 | return HasNativeLowPrecision ? 16 : 32; |
| 62 | } |
| 63 |