xref: /llvm-project/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp (revision aab25f20f6c06bab7aac6fb83d54705ec4cdfadd)
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(Intrinsic::ID ID,
19                                                         unsigned ScalarOpdIdx) {
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) {
30   switch (ID) {
31   case Intrinsic::dx_asdouble:
32     return OpdIdx == 0;
33   default:
34     return OpdIdx == -1;
35   }
36 }
37 
38 bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable(
39     Intrinsic::ID ID) const {
40   switch (ID) {
41   case Intrinsic::dx_frac:
42   case Intrinsic::dx_rsqrt:
43   case Intrinsic::dx_wave_reduce_max:
44   case Intrinsic::dx_wave_reduce_umax:
45   case Intrinsic::dx_wave_reduce_sum:
46   case Intrinsic::dx_wave_reduce_usum:
47   case Intrinsic::dx_wave_readlane:
48   case Intrinsic::dx_asdouble:
49   case Intrinsic::dx_splitdouble:
50   case Intrinsic::dx_firstbituhigh:
51   case Intrinsic::dx_firstbitshigh:
52   case Intrinsic::dx_firstbitlow:
53     return true;
54   default:
55     return false;
56   }
57 }
58