| 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 | default: |
| 24 | return false; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | bool DirectXTTIImpl::isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, |
| 29 | int OpdIdx) const { |
| 30 | switch (ID) { |
| 31 | case Intrinsic::dx_asdouble: |
| 32 | case Intrinsic::dx_firstbitlow: |
| 33 | case Intrinsic::dx_firstbitshigh: |
| 34 | case Intrinsic::dx_firstbituhigh: |
| 35 | case Intrinsic::dx_isinf: |
| 36 | case Intrinsic::dx_isnan: |
| 37 | case Intrinsic::dx_legacyf16tof32: |
| 38 | case Intrinsic::dx_legacyf32tof16: |
| 39 | case Intrinsic::dx_wave_all_equal: |
| 40 | return OpdIdx == 0; |
| 41 | default: |
| 42 | // All DX intrinsics are overloaded on return type unless specified |
| 43 | // otherwise |
| 44 | return OpdIdx == -1; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | unsigned DirectXTTIImpl::getMinimumLookupTableEntryBitWidth() const { |
| 49 | // DXIL does not support i8, so switch lookup tables must not be narrowed |
| 50 | // below the minimum legal integer width. When native 16-bit types are |
| 51 | // enabled (-enable-16bit-types) the minimum is i16, otherwise it is i32. |
| 52 | return HasNativeLowPrecision ? 16 : 32; |
| 53 | } |
| 54 |