Skip to content

Commit 8708968

Browse files
authored
[NFC][DirectX] Moving IsValidXYZ Functions to cpp file (#161896)
Originally, DXContainer `isValid...` functions were defined din the header. That cause a problem, that made this specific file huge, since every function also includes a `def` file. To fix this problem, this PR moves the function to the cpp equivalent file. Closes: [158162](#158162)
1 parent fea9ef3 commit 8708968

File tree

2 files changed

+71
-57
lines changed

2 files changed

+71
-57
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 7 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,9 @@ enum class RootParameterType : uint32_t {
201201

202202
LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
203203

204-
#define ROOT_PARAMETER(Val, Enum) \
205-
case Val: \
206-
return true;
207-
inline bool isValidParameterType(uint32_t V) {
208-
switch (V) {
209-
#include "DXContainerConstants.def"
210-
}
211-
return false;
212-
}
204+
bool isValidParameterType(uint32_t V);
213205

214-
inline bool isValidRangeType(uint32_t V) {
215-
return V <= llvm::to_underlying(dxil::ResourceClass::LastEntry);
216-
}
206+
bool isValidRangeType(uint32_t V);
217207

218208
#define SHADER_VISIBILITY(Val, Enum) Enum = Val,
219209
enum class ShaderVisibility : uint32_t {
@@ -222,30 +212,14 @@ enum class ShaderVisibility : uint32_t {
222212

223213
LLVM_ABI ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
224214

225-
#define SHADER_VISIBILITY(Val, Enum) \
226-
case Val: \
227-
return true;
228-
inline bool isValidShaderVisibility(uint32_t V) {
229-
switch (V) {
230-
#include "DXContainerConstants.def"
231-
}
232-
return false;
233-
}
215+
bool isValidShaderVisibility(uint32_t V);
234216

235217
#define FILTER(Val, Enum) Enum = Val,
236218
enum class SamplerFilter : uint32_t {
237219
#include "DXContainerConstants.def"
238220
};
239221

240-
#define FILTER(Val, Enum) \
241-
case Val: \
242-
return true;
243-
inline bool isValidSamplerFilter(uint32_t V) {
244-
switch (V) {
245-
#include "DXContainerConstants.def"
246-
}
247-
return false;
248-
}
222+
bool isValidSamplerFilter(uint32_t V);
249223

250224
LLVM_ABI ArrayRef<EnumEntry<SamplerFilter>> getSamplerFilters();
251225

@@ -256,15 +230,7 @@ enum class TextureAddressMode : uint32_t {
256230

257231
LLVM_ABI ArrayRef<EnumEntry<TextureAddressMode>> getTextureAddressModes();
258232

259-
#define TEXTURE_ADDRESS_MODE(Val, Enum) \
260-
case Val: \
261-
return true;
262-
inline bool isValidAddress(uint32_t V) {
263-
switch (V) {
264-
#include "DXContainerConstants.def"
265-
}
266-
return false;
267-
}
233+
bool isValidAddress(uint32_t V);
268234

269235
#define COMPARISON_FUNC(Val, Enum) Enum = Val,
270236
enum class ComparisonFunc : uint32_t {
@@ -273,30 +239,14 @@ enum class ComparisonFunc : uint32_t {
273239

274240
LLVM_ABI ArrayRef<EnumEntry<ComparisonFunc>> getComparisonFuncs();
275241

276-
#define COMPARISON_FUNC(Val, Enum) \
277-
case Val: \
278-
return true;
279-
inline bool isValidComparisonFunc(uint32_t V) {
280-
switch (V) {
281-
#include "DXContainerConstants.def"
282-
}
283-
return false;
284-
}
242+
bool isValidComparisonFunc(uint32_t V);
285243

286244
#define STATIC_BORDER_COLOR(Val, Enum) Enum = Val,
287245
enum class StaticBorderColor : uint32_t {
288246
#include "DXContainerConstants.def"
289247
};
290248

291-
#define STATIC_BORDER_COLOR(Val, Enum) \
292-
case Val: \
293-
return true;
294-
inline bool isValidBorderColor(uint32_t V) {
295-
switch (V) {
296-
#include "DXContainerConstants.def"
297-
}
298-
return false;
299-
}
249+
bool isValidBorderColor(uint32_t V);
300250

301251
LLVM_ABI ArrayRef<EnumEntry<StaticBorderColor>> getStaticBorderColors();
302252

llvm/lib/BinaryFormat/DXContainer.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,70 @@
1818
using namespace llvm;
1919
using namespace llvm::dxbc;
2020

21+
#define ROOT_PARAMETER(Val, Enum) \
22+
case Val: \
23+
return true;
24+
bool llvm::dxbc::isValidParameterType(uint32_t V) {
25+
switch (V) {
26+
#include "llvm/BinaryFormat/DXContainerConstants.def"
27+
}
28+
return false;
29+
}
30+
31+
bool llvm::dxbc::isValidRangeType(uint32_t V) {
32+
return V <= llvm::to_underlying(dxil::ResourceClass::LastEntry);
33+
}
34+
35+
#define SHADER_VISIBILITY(Val, Enum) \
36+
case Val: \
37+
return true;
38+
bool llvm::dxbc::isValidShaderVisibility(uint32_t V) {
39+
switch (V) {
40+
#include "llvm/BinaryFormat/DXContainerConstants.def"
41+
}
42+
return false;
43+
}
44+
45+
#define FILTER(Val, Enum) \
46+
case Val: \
47+
return true;
48+
bool llvm::dxbc::isValidSamplerFilter(uint32_t V) {
49+
switch (V) {
50+
#include "llvm/BinaryFormat/DXContainerConstants.def"
51+
}
52+
return false;
53+
}
54+
55+
#define TEXTURE_ADDRESS_MODE(Val, Enum) \
56+
case Val: \
57+
return true;
58+
bool llvm::dxbc::isValidAddress(uint32_t V) {
59+
switch (V) {
60+
#include "llvm/BinaryFormat/DXContainerConstants.def"
61+
}
62+
return false;
63+
}
64+
65+
#define COMPARISON_FUNC(Val, Enum) \
66+
case Val: \
67+
return true;
68+
bool llvm::dxbc::isValidComparisonFunc(uint32_t V) {
69+
switch (V) {
70+
#include "llvm/BinaryFormat/DXContainerConstants.def"
71+
}
72+
return false;
73+
}
74+
75+
#define STATIC_BORDER_COLOR(Val, Enum) \
76+
case Val: \
77+
return true;
78+
bool llvm::dxbc::isValidBorderColor(uint32_t V) {
79+
switch (V) {
80+
#include "llvm/BinaryFormat/DXContainerConstants.def"
81+
}
82+
return false;
83+
}
84+
2185
dxbc::PartType dxbc::parsePartType(StringRef S) {
2286
#define CONTAINER_PART(PartName) .Case(#PartName, PartType::PartName)
2387
return StringSwitch<dxbc::PartType>(S)

0 commit comments

Comments
 (0)