LLVM 24.0.0git
SemanticSignaturePacking.h
Go to the documentation of this file.
1//===- SemanticSignaturePacking.h - HLSL signature packing helpers -------===//
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/// \file This file declares helpers for packing HLSL semantic signatures.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
14#define LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
15
16#include "llvm/ADT/ArrayRef.h"
19#include "llvm/Support/Error.h"
21
22namespace llvm::hlsl {
23
24static constexpr unsigned MaxSignatureRows = 32;
25static constexpr unsigned MaxSignatureCols = 4;
26
27/// Denotes the element that could not be packed and why.
28class LLVM_ABI SignaturePackingError : public ErrorInfo<SignaturePackingError> {
29public:
33
34 static char ID;
35
36 SignaturePackingError(ErrorKind Kind, unsigned ElementIndex)
37 : Kind(Kind), ElementIndex(ElementIndex) {}
38
39 ErrorKind getErrorKind() const { return Kind; }
40 unsigned getElementIndex() const { return ElementIndex; }
41
42 void log(raw_ostream &OS) const override;
43
44 std::error_code convertToErrorCode() const override {
46 }
47
48private:
49 ErrorKind Kind;
50 unsigned ElementIndex;
51};
52
53/// Packs eligible signature elements into consecutive rows.
54///
55/// See llvm/docs/DirectX/SemanticSignatures.md#stacked-packing for details.
56///
57/// On failure, Elements is left partially packed: the elements preceding the
58/// one reported by the returned SignaturePackingError keep the locations
59/// they were assigned, while that element and the ones following it retain the
60/// unallocated row and column sentinels.
63 Triple::EnvironmentType ShaderStage, IOType IOTy);
64
65} // namespace llvm::hlsl
66
67#endif // LLVM_FRONTEND_HLSL_SEMANTICSIGNATUREPACKING_H
#define LLVM_ABI
Definition Compiler.h:215
Base class for user error types.
Definition Error.h:354
Tagged union holding either a T or a Error.
Definition Error.h:485
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
SignaturePackingError(ErrorKind Kind, unsigned ElementIndex)
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI Expected< unsigned > packSignatureStacked(MutableArrayRef< SemanticSignatureElement > Elements, Triple::EnvironmentType ShaderStage, IOType IOTy)
Packs eligible signature elements into consecutive rows.
static constexpr unsigned MaxSignatureRows
static constexpr unsigned MaxSignatureCols
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94