LLVM 19.0.0git
Go to the documentation of this file.
1//===- DXILUpgrade.cpp - Upgrade DXIL metadata to LLVM constructs ---------===//
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
10#include "llvm/IR/Constants.h"
11#include "llvm/IR/Metadata.h"
12#include "llvm/IR/Module.h"
13#include "llvm/Support/Debug.h"
15using namespace llvm;
17#define DEBUG_TYPE "dxil-upgrade"
20 NamedMDNode *ValVer = M.getNamedMetadata("dx.valver");
21 if (!ValVer)
22 return false;
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;
38 // We never add, remove, or change functions here.
42 bool Changed = false;
43 Changed |= handleValVerMetadata(M);
45 if (!Changed)
47 return PA;
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:47
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:321
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:631
Metadata node.
Definition: Metadata.h:1067
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:1729
void dropAllReferences()
Remove all uses and clear node vector.
Definition: Metadata.h:1794
void eraseFromParent()
Drop all references and remove the node from parent module.
Definition: Metadata.cpp:1394
MDNode * getOperand(unsigned i) const
Definition: Metadata.cpp:1381
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:109
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:115
void preserveSet()
Mark an analysis set as preserved.
Definition: Analysis.h:144
void preserve()
Mark an analysis as preserved.
Definition: Analysis.h:129
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