xref: /llvm-project/llvm/lib/Target/DirectX/DirectXTargetTransformInfo.cpp (revision 8663b8777e8108f74f91a2a33115b3a00d57c043)
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::isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
29                                                             int ScalarOpdIdx) {
30   switch (ID) {
31   default:
32     return ScalarOpdIdx == -1;
33   }
34 }
35 
36 bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable(
37     Intrinsic::ID ID) const {
38   switch (ID) {
39   case Intrinsic::dx_frac:
40   case Intrinsic::dx_rsqrt:
41   case Intrinsic::dx_wave_readlane:
42   case Intrinsic::dx_splitdouble:
43   case Intrinsic::dx_firstbituhigh:
44   case Intrinsic::dx_firstbitshigh:
45     return true;
46   default:
47     return false;
48   }
49 }
50