[llvm] [DXIL][Analysis] Add DXILMetadataAnalysis pass (PR #102079)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 8 22:59:06 PDT 2024
================
@@ -0,0 +1,106 @@
+//=- DXILMetadataAnalysis.cpp - Representation of Module metadata -*- C++ -*=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/DXILMetadataAnalysis.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Module.h"
+#include "llvm/InitializePasses.h"
+
+#define DEBUG_TYPE "dxil-metadata-analysis"
+
+using namespace llvm;
+using namespace dxil;
+
+void ModuleMetadataInfo::print(raw_ostream &OS) const {
+ OS << "Shader Model Version : " << ShaderModelVersion.getAsString() << "\n";
+ OS << "DXIL Version : " << DXILVersion.getAsString() << "\n";
+ OS << "Shader Stage : " << Triple::getEnvironmentTypeName(ShaderStage)
+ << "\n";
+ OS << "Validator Version : " << ValidatorVersion.getAsString() << "\n";
+}
+
+ModuleMetadataInfo::ModuleMetadataInfo(Module &M) {
+ Triple TT(Triple(M.getTargetTriple()));
+ DXILVersion = TT.getDXILVersion();
+ ShaderModelVersion = TT.getOSVersion();
+ ShaderStage = TT.getEnvironment();
+ NamedMDNode *Entry = M.getOrInsertNamedMetadata("dx.valver");
----------------
bogner wrote:
Analysis passes must not modify the module, so creating metadata here isn’t allowed. In any case, we should be creating the `dx.valver` metadata node based on the results of this pass, so getting the value from there is circular and doesn’t make sense.
https://github.com/llvm/llvm-project/pull/102079
More information about the llvm-commits
mailing list