LLVM 18.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
18#include "llvm/IR/PassManager.h"
19#include "llvm/Pass.h"
21#include "llvm/Support/Debug.h"
23#include <cstdint>
24
25namespace llvm {
26class Module;
27class GlobalVariable;
28
29namespace dxil {
30
32#define SHADER_FLAG(bit, FlagName, Str) bool FlagName : 1;
33#include "llvm/BinaryFormat/DXContainerConstants.def"
34
35#define SHADER_FLAG(bit, FlagName, Str) FlagName = false;
37#include "llvm/BinaryFormat/DXContainerConstants.def"
38 }
39
40 operator uint64_t() const {
41 uint64_t FlagValue = 0;
42#define SHADER_FLAG(bit, FlagName, Str) \
43 FlagValue |= \
44 FlagName ? static_cast<uint64_t>(dxbc::FeatureFlags::FlagName) : 0ull;
45#include "llvm/BinaryFormat/DXContainerConstants.def"
46 return FlagValue;
47 }
48
50 void print(raw_ostream &OS = dbgs()) const;
51 LLVM_DUMP_METHOD void dump() const { print(); }
52};
53
54class ShaderFlagsAnalysis : public AnalysisInfoMixin<ShaderFlagsAnalysis> {
56 static AnalysisKey Key;
57
58public:
60
62
64};
65
66/// Printer pass for ShaderFlagsAnalysis results.
68 : public PassInfoMixin<ShaderFlagsAnalysisPrinter> {
69 raw_ostream &OS;
70
71public:
74};
75
76/// Wrapper pass for the legacy pass manager.
77///
78/// This is required because the passes that will depend on this are codegen
79/// passes which run through the legacy pass manager.
82
83public:
84 static char ID;
85
87
88 const ComputedShaderFlags &getShaderFlags() { return Flags; }
89
90 bool runOnModule(Module &M) override {
92 return false;
93 }
94
95 void getAnalysisUsage(AnalysisUsage &AU) const override {
96 AU.setPreservesAll();
97 }
98};
99
100} // namespace dxil
101} // namespace llvm
102
103#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:510
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:649
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: PassManager.h:172
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:414
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:89
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:391
static ComputedShaderFlags computeFlags(Module &M)
LLVM_DUMP_METHOD void dump() const
void print(raw_ostream &OS=dbgs()) const