LLVM 24.0.0git
HLSLUtils.cpp
Go to the documentation of this file.
1//===- HLSLUtils.cpp - HLSL helper functions --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// Various helpers for working with HLSL shaders.
10///
11//===----------------------------------------------------------------------===//
12
15
16namespace llvm {
17namespace hlsl {
18
19// Parses a numthreads or wavesize attribute string in "X,Y,Z" format into three
20// unsigned integers: the thread counts in each dimension for numthreads, or the
21// minimum, maximum, and preferred wave sizes for wavesize.
22// Validates the input only through assertions.
23void parseThreadCounts(StringRef Str, unsigned &Count1, unsigned &Count2,
24 unsigned &Count3) {
26 Str.split(Counts, ',');
27 assert(Counts.size() == 3 && "expected three thread dimensions");
28
29 [[maybe_unused]] bool IsInvalid;
30 IsInvalid = Counts[0].getAsInteger(10, Count1);
31 assert(!IsInvalid && "expected an integer thread count");
32 IsInvalid = Counts[1].getAsInteger(10, Count2);
33 assert(!IsInvalid && "expected an integer thread count");
34 IsInvalid = Counts[2].getAsInteger(10, Count3);
35 assert(!IsInvalid && "expected an integer thread count");
36}
37
38} // namespace hlsl
39} // namespace llvm
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallVector class.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM_ABI void parseThreadCounts(StringRef Str, unsigned &Count1, unsigned &Count2, unsigned &Count3)
Definition HLSLUtils.cpp:23
This is an optimization pass for GlobalISel generic memory operations.