DirectXShaderCompiler/lib/HLSL/HLMetadataPasses.cpp

78 строки
2.2 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// //
// HLMetadataPasses.cpp //
// Copyright (C) Microsoft Corporation. All rights reserved. //
// This file is distributed under the University of Illinois Open Source //
// License. See LICENSE.TXT for details. //
// //
///////////////////////////////////////////////////////////////////////////////
#include "dxc/HLSL/DxilGenerationPass.h"
#include "dxc/HLSL/HLModule.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
using namespace llvm;
using namespace hlsl;
namespace {
class HLEmitMetadata : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
explicit HLEmitMetadata() : ModulePass(ID) {}
StringRef getPassName() const override {
return "HLSL High-Level Metadata Emit";
}
bool runOnModule(Module &M) override {
if (M.HasHLModule()) {
HLModule::ClearHLMetadata(M);
M.GetHLModule().EmitHLMetadata();
return true;
}
return false;
}
};
} // namespace
char HLEmitMetadata::ID = 0;
ModulePass *llvm::createHLEmitMetadataPass() { return new HLEmitMetadata(); }
INITIALIZE_PASS(HLEmitMetadata, "hlsl-hlemit", "HLSL High-Level Metadata Emit",
false, false)
///////////////////////////////////////////////////////////////////////////////
namespace {
class HLEnsureMetadata : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
explicit HLEnsureMetadata() : ModulePass(ID) {}
StringRef getPassName() const override {
return "HLSL High-Level Metadata Ensure";
}
bool runOnModule(Module &M) override {
if (!M.HasHLModule()) {
M.GetOrCreateHLModule();
return true;
}
return false;
}
};
} // namespace
char HLEnsureMetadata::ID = 0;
ModulePass *llvm::createHLEnsureMetadataPass() {
return new HLEnsureMetadata();
}
INITIALIZE_PASS(HLEnsureMetadata, "hlsl-hlensure",
"HLSL High-Level Metadata Ensure", false, false)