LLVM 19.0.0git
DXILShaderFlags.h
Go to the documentation of this file.
1//===- DXILShaderFlags.h - DXIL Shader Flags helper objects ---------------===//
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 contains helper objects and APIs for working with DXIL
10/// Shader Flags.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TARGET_DIRECTX_DXILSHADERFLAGS_H
15#define LLVM_TARGET_DIRECTX_DXILSHADERFLAGS_H
16
17#include "llvm/IR/PassManager.h"
18#include "llvm/Pass.h"
20#include "llvm/Support/Debug.h"
22#include <cstdint>
23
24namespace llvm {
25class Module;
26class GlobalVariable;
27
28namespace dxil {
29
31#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleBit, FlagName, Str) \
32 bool FlagName : 1;
33#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) bool FlagName : 1;
34#include "llvm/BinaryFormat/DXContainerConstants.def"
35
36#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleBit, FlagName, Str) \
37 FlagName = false;
38#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) FlagName = false;
40#include "llvm/BinaryFormat/DXContainerConstants.def"
41 }
42
43 constexpr uint64_t getMask(int Bit) const {
44 return Bit != -1 ? 1ull << Bit : 0;
45 }
46 operator uint64_t() const {
47 uint64_t FlagValue = 0;
48#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleBit, FlagName, Str) \
49 FlagValue |= FlagName ? getMask(DxilModuleBit) : 0ull;
50#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) \
51 FlagValue |= FlagName ? getMask(DxilModuleBit) : 0ull;
52#include "llvm/BinaryFormat/DXContainerConstants.def"
53 return FlagValue;
54 }
56 uint64_t FeatureFlags = 0;
57#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleBit, FlagName, Str) \
58 FeatureFlags |= FlagName ? getMask(FeatureBit) : 0ull;
59#include "llvm/BinaryFormat/DXContainerConstants.def"
60 return FeatureFlags;
61 }
62
64 void print(raw_ostream &OS = dbgs()) const;
65 LLVM_DUMP_METHOD void dump() const { print(); }
66};
67
68class ShaderFlagsAnalysis : public AnalysisInfoMixin<ShaderFlagsAnalysis> {
70 static AnalysisKey Key;
71
72public:
74
76
78};
79
80/// Printer pass for ShaderFlagsAnalysis results.
82 : public PassInfoMixin<ShaderFlagsAnalysisPrinter> {
83 raw_ostream &OS;
84
85public:
88};
89
90/// Wrapper pass for the legacy pass manager.
91///
92/// This is required because the passes that will depend on this are codegen
93/// passes which run through the legacy pass manager.
96
97public:
98 static char ID;
99
101
102 const ComputedShaderFlags &getShaderFlags() { return Flags; }
103
104 bool runOnModule(Module &M) override {
106 return false;
107 }
108
109 void getAnalysisUsage(AnalysisUsage &AU) const override {
110 AU.setPreservesAll();
111 }
112};
113
114} // namespace dxil
115} // namespace llvm
116
117#endif // LLVM_TARGET_DIRECTX_DXILSHADERFLAGS_H
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:529
Machine Check Debug Module
This header defines various interfaces for pass management in LLVM.
raw_pwrite_stream & OS
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:321
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:251
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:109
Printer pass for ShaderFlagsAnalysis results.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Wrapper pass for the legacy pass manager.
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
const ComputedShaderFlags & getShaderFlags()
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
ComputedShaderFlags run(Module &M, ModuleAnalysisManager &AM)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:97
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:26
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:74
constexpr uint64_t getMask(int Bit) const
static ComputedShaderFlags computeFlags(Module &M)
LLVM_DUMP_METHOD void dump() const
void print(raw_ostream &OS=dbgs()) const