Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmake/modules/HCT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ endif()
function(add_hlsl_hctgen mode)
cmake_parse_arguments(ARG
"BUILD_DIR;CODE_TAG"
"OUTPUT"
"OUTPUT;TARGET_NAME"
""
${ARGN})
if (NOT ARG_TARGET_NAME)
set(ARG_TARGET_NAME ${mode})
endif()

if (NOT ARG_OUTPUT)
message(FATAL_ERROR "add_hlsl_hctgen requires OUTPUT argument")
Expand Down Expand Up @@ -132,8 +135,8 @@ function(add_hlsl_hctgen mode)
DEPENDS ${output}
COMMENT "Verifying clang-format results...")

add_custom_target(${mode}
add_custom_target(${ARG_TARGET_NAME}
DEPENDS ${temp_output}.stamp)

add_dependencies(HCTGen ${mode})
add_dependencies(HCTGen ${ARG_TARGET_NAME})
endfunction()
1 change: 1 addition & 0 deletions lib/DXIL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This file is distributed under the University of Illinois Open Source License.
# See LICENSE.TXT for details.

add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG TARGET_NAME DxilCountersCpp)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot what is special about DxilCounters.cpp that means it needs a special TARGET_NAME parameter? None of the ones below seem to need this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument to add_hlsl_hctgen serves double duty: it's both the hctgen generation mode (passed directly to hctgen.py) and the CMake target name. DxilCounters is the only hctgen mode that generates two separate files — DxilCounters.h (in include/dxc/DXIL/CMakeLists.txt) and DxilCounters.cpp (in lib/DXIL/CMakeLists.txt). Since both calls must pass DxilCounters as the mode, but CMake target names must be unique, one of them needs a different target name.

I tried renaming the mode to DxilCountersH for the .h side, but that breaks hctgen.py which only accepts fixed mode names. TARGET_NAME is the minimal way to decouple the CMake target name from the hctgen mode.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot I'm convinced that this is truly a special case. Is the target name actually important and relied upon anywhere? If not, then how about the output file extension is always added to the target name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target names were not relied upon by name externally, with one exception: DxilIntrinsicTables in tools/clang/lib/Sema/CMakeLists.txt.

Implemented your suggestion in ddcbecf: the TARGET_NAME parameter is removed and the target name is now always auto-derived as ${mode}_${extension} (e.g. DxilCounters_h, DxilCounters_cpp). Updated the one external reference accordingly (DxilIntrinsicTablesDxilIntrinsicTables_h).

add_hlsl_hctgen(DxilOperations OUTPUT DxilOperations.cpp CODE_TAG)
add_hlsl_hctgen(DxilShaderModel OUTPUT DxilShaderModel.cpp CODE_TAG)
add_hlsl_hctgen(DxilMetadata OUTPUT DxilMetadataHelper.cpp CODE_TAG)
Expand Down
32 changes: 18 additions & 14 deletions lib/DXIL/DxilCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,18 @@ bool CountDxilOp_atomic(unsigned op) {
return op == 70 || (78 <= op && op <= 79);
}
bool CountDxilOp_barrier(unsigned op) {
// Instructions: Barrier=80
return op == 80;
// Instructions: Barrier=80, BarrierByMemoryType=244,
// BarrierByMemoryHandle=245, BarrierByNodeRecordHandle=246
return op == 80 || (244 <= op && op <= 246);
}
bool CountDxilOp_floats(unsigned op) {
// Instructions: FAbs=6, Saturate=7, IsNaN=8, IsInf=9, IsFinite=10,
// IsNormal=11, Cos=12, Sin=13, Tan=14, Acos=15, Asin=16, Atan=17, Hcos=18,
// Hsin=19, Htan=20, Exp=21, Frc=22, Log=23, Sqrt=24, Rsqrt=25, Round_ne=26,
// Round_ni=27, Round_pi=28, Round_z=29, FMax=35, FMin=36, Fma=47, Dot2=54,
// Dot3=55, Dot4=56, Dot2AddHalf=162
// Dot3=55, Dot4=56, Dot2AddHalf=162, FDot=311
return (6 <= op && op <= 29) || (35 <= op && op <= 36) || op == 47 ||
(54 <= op && op <= 56) || op == 162;
(54 <= op && op <= 56) || op == 162 || op == 311;
}
bool CountDxilOp_gs_cut(unsigned op) {
// Instructions: CutStream=98, EmitThenCutStream=99
Expand All @@ -155,9 +156,9 @@ bool CountDxilOp_gs_emit(unsigned op) {
}
bool CountDxilOp_ints(unsigned op) {
// Instructions: IMax=37, IMin=38, IMul=41, IMad=48, Ibfe=51,
// Dot4AddI8Packed=163
// Dot4AddI8Packed=163, VectorReduceAnd=309, VectorReduceOr=310
return (37 <= op && op <= 38) || op == 41 || op == 48 || op == 51 ||
op == 163;
op == 163 || (309 <= op && op <= 310);
}
bool CountDxilOp_sig_ld(unsigned op) {
// Instructions: LoadInput=4, LoadOutputControlPoint=103,
Expand All @@ -175,16 +176,18 @@ bool CountDxilOp_tex_bias(unsigned op) {
}
bool CountDxilOp_tex_cmp(unsigned op) {
// Instructions: SampleCmp=64, SampleCmpLevelZero=65, TextureGatherCmp=74,
// SampleCmpLevel=224
return (64 <= op && op <= 65) || op == 74 || op == 224;
// SampleCmpLevel=224, SampleCmpGrad=254, SampleCmpBias=255
return (64 <= op && op <= 65) || op == 74 || op == 224 ||
(254 <= op && op <= 255);
}
bool CountDxilOp_tex_grad(unsigned op) {
// Instructions: SampleGrad=63
return op == 63;
}
bool CountDxilOp_tex_load(unsigned op) {
// Instructions: TextureLoad=66, BufferLoad=68, RawBufferLoad=139
return op == 66 || op == 68 || op == 139;
// Instructions: TextureLoad=66, BufferLoad=68, RawBufferLoad=139,
// RawBufferVectorLoad=303
return op == 66 || op == 68 || op == 139 || op == 303;
}
bool CountDxilOp_tex_norm(unsigned op) {
// Instructions: Sample=60, SampleLevel=62, TextureGather=73,
Expand All @@ -195,17 +198,18 @@ bool CountDxilOp_tex_store(unsigned op) {
// Instructions: TextureStore=67, BufferStore=69, RawBufferStore=140,
// WriteSamplerFeedback=174, WriteSamplerFeedbackBias=175,
// WriteSamplerFeedbackLevel=176, WriteSamplerFeedbackGrad=177,
// TextureStoreSample=225
// TextureStoreSample=225, RawBufferVectorStore=304
return op == 67 || op == 69 || op == 140 || (174 <= op && op <= 177) ||
op == 225;
op == 225 || op == 304;
}
bool CountDxilOp_uints(unsigned op) {
// Instructions: Bfrev=30, Countbits=31, FirstbitLo=32, FirstbitHi=33,
// FirstbitSHi=34, UMax=39, UMin=40, UMul=42, UDiv=43, UAddc=44, USubb=45,
// UMad=49, Msad=50, Ubfe=52, Bfi=53, Dot4AddU8Packed=164
// UMad=49, Msad=50, Ubfe=52, Bfi=53, Dot4AddU8Packed=164,
// VectorReduceAnd=309, VectorReduceOr=310
return (30 <= op && op <= 34) || (39 <= op && op <= 40) ||
(42 <= op && op <= 45) || (49 <= op && op <= 50) ||
(52 <= op && op <= 53) || op == 164;
(52 <= op && op <= 53) || op == 164 || (309 <= op && op <= 310);
}
// Counter functions for llvm ops:
bool CountLlvmOp_atomic(unsigned op) {
Expand Down