LLVM 20.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;
43 Changed |= handleValVerMetadata(M);
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)
Definition: DXILUpgrade.cpp:19
#define LLVM_DEBUG(X)
Definition: Debug.h:101
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file contains the declarations for metadata subclasses.
Module.h This file contains the declarations for the Module class.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Definition: Analysis.h:49
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: DXILUpgrade.cpp:36
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:563
Metadata node.
Definition: Metadata.h:1069
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A tuple of MDNodes.
Definition: Metadata.h:1730
void dropAllReferences()
Remove all uses and clear node vector.
Definition: Metadata.h:1795
void eraseFromParent()
Drop all references and remove the node from parent module.
Definition: Metadata.cpp:1401
MDNode * getOperand(unsigned i) const
Definition: Metadata.cpp:1388
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
void preserveSet()
Mark an analysis set as preserved.
Definition: Analysis.h:146
void preserve()
Mark an analysis as preserved.
Definition: Analysis.h:131
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
#define N