Skip to content

Commit 745a694

Browse files
damyanpCopilot
andauthored
Make HLSL_COPY_GENERATED_SOURCES copy DxilCounters.cpp (#8296)
DxilCounters.cpp wasn't getting updated when HLSL_COPY_GENERATED_SOURCES was set. This change fixes that, and includes the updated DxilCounters.cpp. add_hlsl_hctgen now adds the file extension to the target it creates, which allows us to generate both DxilCounters.h and DxilCounters.cpp. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: damyanp <[email protected]>
1 parent 67a8e24 commit 745a694

4 files changed

Lines changed: 24 additions & 17 deletions

File tree

cmake/modules/HCT.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ function(add_hlsl_hctgen mode)
6767
${opcodes_json})
6868

6969
get_filename_component(output_extension ${full_output} LAST_EXT)
70+
string(SUBSTRING ${output_extension} 1 -1 output_extension_no_dot)
71+
set(target_name "${mode}_${output_extension_no_dot}")
7072

7173
if (CLANG_FORMAT_EXE AND output_extension MATCHES "\.h|\.cpp|\.inl")
7274
set(format_cmd COMMAND ${CLANG_FORMAT_EXE} -i ${temp_output})
@@ -132,8 +134,8 @@ function(add_hlsl_hctgen mode)
132134
DEPENDS ${output}
133135
COMMENT "Verifying clang-format results...")
134136

135-
add_custom_target(${mode}
137+
add_custom_target(${target_name}
136138
DEPENDS ${temp_output}.stamp)
137139

138-
add_dependencies(HCTGen ${mode})
140+
add_dependencies(HCTGen ${target_name})
139141
endfunction()

lib/DXIL/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This file is distributed under the University of Illinois Open Source License.
33
# See LICENSE.TXT for details.
44

5+
add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG)
56
add_hlsl_hctgen(DxilOperations OUTPUT DxilOperations.cpp CODE_TAG)
67
add_hlsl_hctgen(DxilShaderModel OUTPUT DxilShaderModel.cpp CODE_TAG)
78
add_hlsl_hctgen(DxilMetadata OUTPUT DxilMetadataHelper.cpp CODE_TAG)

lib/DXIL/DxilCounters.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,18 @@ bool CountDxilOp_atomic(unsigned op) {
133133
return op == 70 || (78 <= op && op <= 79);
134134
}
135135
bool CountDxilOp_barrier(unsigned op) {
136-
// Instructions: Barrier=80
137-
return op == 80;
136+
// Instructions: Barrier=80, BarrierByMemoryType=244,
137+
// BarrierByMemoryHandle=245, BarrierByNodeRecordHandle=246
138+
return op == 80 || (244 <= op && op <= 246);
138139
}
139140
bool CountDxilOp_floats(unsigned op) {
140141
// Instructions: FAbs=6, Saturate=7, IsNaN=8, IsInf=9, IsFinite=10,
141142
// IsNormal=11, Cos=12, Sin=13, Tan=14, Acos=15, Asin=16, Atan=17, Hcos=18,
142143
// Hsin=19, Htan=20, Exp=21, Frc=22, Log=23, Sqrt=24, Rsqrt=25, Round_ne=26,
143144
// Round_ni=27, Round_pi=28, Round_z=29, FMax=35, FMin=36, Fma=47, Dot2=54,
144-
// Dot3=55, Dot4=56, Dot2AddHalf=162
145+
// Dot3=55, Dot4=56, Dot2AddHalf=162, FDot=311
145146
return (6 <= op && op <= 29) || (35 <= op && op <= 36) || op == 47 ||
146-
(54 <= op && op <= 56) || op == 162;
147+
(54 <= op && op <= 56) || op == 162 || op == 311;
147148
}
148149
bool CountDxilOp_gs_cut(unsigned op) {
149150
// Instructions: CutStream=98, EmitThenCutStream=99
@@ -155,9 +156,9 @@ bool CountDxilOp_gs_emit(unsigned op) {
155156
}
156157
bool CountDxilOp_ints(unsigned op) {
157158
// Instructions: IMax=37, IMin=38, IMul=41, IMad=48, Ibfe=51,
158-
// Dot4AddI8Packed=163
159+
// Dot4AddI8Packed=163, VectorReduceAnd=309, VectorReduceOr=310
159160
return (37 <= op && op <= 38) || op == 41 || op == 48 || op == 51 ||
160-
op == 163;
161+
op == 163 || (309 <= op && op <= 310);
161162
}
162163
bool CountDxilOp_sig_ld(unsigned op) {
163164
// Instructions: LoadInput=4, LoadOutputControlPoint=103,
@@ -175,16 +176,18 @@ bool CountDxilOp_tex_bias(unsigned op) {
175176
}
176177
bool CountDxilOp_tex_cmp(unsigned op) {
177178
// Instructions: SampleCmp=64, SampleCmpLevelZero=65, TextureGatherCmp=74,
178-
// SampleCmpLevel=224
179-
return (64 <= op && op <= 65) || op == 74 || op == 224;
179+
// SampleCmpLevel=224, SampleCmpGrad=254, SampleCmpBias=255
180+
return (64 <= op && op <= 65) || op == 74 || op == 224 ||
181+
(254 <= op && op <= 255);
180182
}
181183
bool CountDxilOp_tex_grad(unsigned op) {
182184
// Instructions: SampleGrad=63
183185
return op == 63;
184186
}
185187
bool CountDxilOp_tex_load(unsigned op) {
186-
// Instructions: TextureLoad=66, BufferLoad=68, RawBufferLoad=139
187-
return op == 66 || op == 68 || op == 139;
188+
// Instructions: TextureLoad=66, BufferLoad=68, RawBufferLoad=139,
189+
// RawBufferVectorLoad=303
190+
return op == 66 || op == 68 || op == 139 || op == 303;
188191
}
189192
bool CountDxilOp_tex_norm(unsigned op) {
190193
// Instructions: Sample=60, SampleLevel=62, TextureGather=73,
@@ -195,17 +198,18 @@ bool CountDxilOp_tex_store(unsigned op) {
195198
// Instructions: TextureStore=67, BufferStore=69, RawBufferStore=140,
196199
// WriteSamplerFeedback=174, WriteSamplerFeedbackBias=175,
197200
// WriteSamplerFeedbackLevel=176, WriteSamplerFeedbackGrad=177,
198-
// TextureStoreSample=225
201+
// TextureStoreSample=225, RawBufferVectorStore=304
199202
return op == 67 || op == 69 || op == 140 || (174 <= op && op <= 177) ||
200-
op == 225;
203+
op == 225 || op == 304;
201204
}
202205
bool CountDxilOp_uints(unsigned op) {
203206
// Instructions: Bfrev=30, Countbits=31, FirstbitLo=32, FirstbitHi=33,
204207
// FirstbitSHi=34, UMax=39, UMin=40, UMul=42, UDiv=43, UAddc=44, USubb=45,
205-
// UMad=49, Msad=50, Ubfe=52, Bfi=53, Dot4AddU8Packed=164
208+
// UMad=49, Msad=50, Ubfe=52, Bfi=53, Dot4AddU8Packed=164,
209+
// VectorReduceAnd=309, VectorReduceOr=310
206210
return (30 <= op && op <= 34) || (39 <= op && op <= 40) ||
207211
(42 <= op && op <= 45) || (49 <= op && op <= 50) ||
208-
(52 <= op && op <= 53) || op == 164;
212+
(52 <= op && op <= 53) || op == 164 || (309 <= op && op <= 310);
209213
}
210214
// Counter functions for llvm ops:
211215
bool CountLlvmOp_atomic(unsigned op) {

tools/clang/lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(LLVM_LINK_COMPONENTS
66
# HLSL Change Begin
77
add_hlsl_hctgen(DxilIntrinsicTables BUILD_DIR OUTPUT gen_intrin_main_tables_15.h)
88
include_directories(${CMAKE_CURRENT_BINARY_DIR})
9-
list(APPEND LLVM_COMMON_DEPENDS DxilIntrinsicTables)
9+
list(APPEND LLVM_COMMON_DEPENDS DxilIntrinsicTables_h)
1010
# HLSL Change End
1111

1212
add_clang_library(clangSema

0 commit comments

Comments
 (0)