LLVM 22.0.0git
DXILUpgrade.cpp
Go to the documentation of this file.
1//===- DXILUpgrade.cpp - Upgrade DXIL metadata to LLVM constructs ---------===//
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
10#include "llvm/IR/Constants.h"
11#include "llvm/IR/Metadata.h"
12#include "llvm/IR/Module.h"
13#include "llvm/Support/Debug.h"
14
15using namespace llvm;
16
17#define DEBUG_TYPE "dxil-upgrade"
18
20 NamedMDNode *ValVer = M.getNamedMetadata("dx.valver");
21 if (!ValVer)
22 return false;
23
25 MDNode *N = ValVer->getOperand(0);
26 auto X = mdconst::extract<ConstantInt>(N->getOperand(0))->getZExtValue();
27 auto Y = mdconst::extract<ConstantInt>(N->getOperand(1))->getZExtValue();
28 dbgs() << "DXIL: validation version: " << X << "." << Y << "\n";
29 });
30 // We don't need the validation version internally, so we drop it.
31 ValVer->dropAllReferences();
32 ValVer->eraseFromParent();
33 return true;
34}
35
38 // We never add, remove, or change functions here.
41
42 bool Changed = false;
44
45 if (!Changed)
47 return PA;
48}
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool handleValVerMetadata(Module &M)
Module.h This file contains the declarations for the Module class.
This file contains the declarations for metadata subclasses.
#define LLVM_DEBUG(...)
Definition Debug.h:114
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
Definition Analysis.h:50
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Metadata node.
Definition Metadata.h:1077
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A tuple of MDNodes.
Definition Metadata.h:1753
void dropAllReferences()
Remove all uses and clear node vector.
Definition Metadata.h:1818
LLVM_ABI void eraseFromParent()
Drop all references and remove the node from parent module.
LLVM_ABI MDNode * getOperand(unsigned i) const
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
PreservedAnalyses & preserve()
Mark an analysis as preserved.
Definition Analysis.h:132
Changed
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition Metadata.h:666
This is an optimization pass for GlobalISel generic memory operations.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
#define N