Adds the WaveActiveMin intrinsic from #99169. I think I did all of the required things on the checklist: - [x] Implement `WaveActiveMin` clang builtin, - [x] Link `WaveActiveMin` clang builtin with `hlsl_intrinsics.h` - [x] Add sema checks for `WaveActiveMin` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp` - [x] Add codegen for `WaveActiveMin` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp` - [x] Add codegen tests to `clang/test/CodeGenHLSL/builtins/WaveActiveMin.hlsl` - [x] Add sema tests to `clang/test/SemaHLSL/BuiltIns/WaveActiveMin-errors.hlsl` - [x] Create the `int_dx_WaveActiveMin` intrinsic in `IntrinsicsDirectX.td` - [x] Create the `DXILOpMapping` of `int_dx_WaveActiveMin` to `119` in `DXIL.td` - [x] Create the `WaveActiveMin.ll` and `WaveActiveMin_errors.ll` tests in `llvm/test/CodeGen/DirectX/` - [x] Create the `int_spv_WaveActiveMin` intrinsic in `IntrinsicsSPIRV.td` - [x] In SPIRVInstructionSelector.cpp create the `WaveActiveMin` lowering and map it to `int_spv_WaveActiveMin` in `SPIRVInstructionSelector::selectIntrinsic`. - [x] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveActiveMin.ll But as some of the code has changed and was moved around (E.G. `CGBuiltin.cpp` -> `CGHLSLBuiltins.cpp`) I mostly followed how `WaveActiveMax()` is implemented. I have not been able to run the tests myself as I am unsure which project runs the correct test. Any guidance on how I can test myself would be helpful. Also added some tests to the offload-test-suite https://github.com/llvm/offload-test-suite/pull/478
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
//===- DirectXTargetTransformInfo.cpp - DirectX TTI ---------------*- C++
|
|
//-*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "DirectXTargetTransformInfo.h"
|
|
#include "llvm/IR/Intrinsics.h"
|
|
#include "llvm/IR/IntrinsicsDirectX.h"
|
|
|
|
using namespace llvm;
|
|
|
|
bool DirectXTTIImpl::isTargetIntrinsicWithScalarOpAtArg(
|
|
Intrinsic::ID ID, unsigned ScalarOpdIdx) const {
|
|
switch (ID) {
|
|
case Intrinsic::dx_wave_readlane:
|
|
return ScalarOpdIdx == 1;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool DirectXTTIImpl::isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
|
|
int OpdIdx) const {
|
|
switch (ID) {
|
|
case Intrinsic::dx_asdouble:
|
|
case Intrinsic::dx_isinf:
|
|
case Intrinsic::dx_isnan:
|
|
case Intrinsic::dx_firstbitlow:
|
|
case Intrinsic::dx_firstbituhigh:
|
|
case Intrinsic::dx_firstbitshigh:
|
|
return OpdIdx == 0;
|
|
default:
|
|
return OpdIdx == -1;
|
|
}
|
|
}
|
|
|
|
bool DirectXTTIImpl::isTargetIntrinsicTriviallyScalarizable(
|
|
Intrinsic::ID ID) const {
|
|
switch (ID) {
|
|
case Intrinsic::dx_asdouble:
|
|
case Intrinsic::dx_firstbitlow:
|
|
case Intrinsic::dx_firstbitshigh:
|
|
case Intrinsic::dx_firstbituhigh:
|
|
case Intrinsic::dx_frac:
|
|
case Intrinsic::dx_isinf:
|
|
case Intrinsic::dx_isnan:
|
|
case Intrinsic::dx_rsqrt:
|
|
case Intrinsic::dx_saturate:
|
|
case Intrinsic::dx_splitdouble:
|
|
case Intrinsic::dx_wave_readlane:
|
|
case Intrinsic::dx_wave_reduce_max:
|
|
case Intrinsic::dx_wave_reduce_min:
|
|
case Intrinsic::dx_wave_reduce_sum:
|
|
case Intrinsic::dx_wave_reduce_umax:
|
|
case Intrinsic::dx_wave_reduce_umin:
|
|
case Intrinsic::dx_wave_reduce_usum:
|
|
case Intrinsic::dx_imad:
|
|
case Intrinsic::dx_umad:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|