DxilLinker.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilLinker.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Representation of HLSL Linker. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include <unordered_map>
  13. #include <unordered_set>
  14. #include "llvm/ADT/StringRef.h"
  15. #include "llvm/ADT/StringMap.h"
  16. #include <memory>
  17. #include "llvm/Support/ErrorOr.h"
  18. #include "dxc/HLSL/DxilExportMap.h"
  19. namespace llvm {
  20. class Function;
  21. class GlobalVariable;
  22. class Constant;
  23. class Module;
  24. class LLVMContext;
  25. } // namespace llvm
  26. namespace hlsl {
  27. class DxilModule;
  28. class DxilResourceBase;
  29. // Linker for DxilModule.
  30. class DxilLinker {
  31. public:
  32. virtual ~DxilLinker() {}
  33. static DxilLinker *CreateLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor);
  34. void SetValidatorVersion(unsigned valMajor, unsigned valMinor) { m_valMajor = valMajor, m_valMinor = valMinor; }
  35. virtual bool HasLibNameRegistered(llvm::StringRef name) = 0;
  36. virtual bool RegisterLib(llvm::StringRef name,
  37. std::unique_ptr<llvm::Module> pModule,
  38. std::unique_ptr<llvm::Module> pDebugModule) = 0;
  39. virtual bool AttachLib(llvm::StringRef name) = 0;
  40. virtual bool DetachLib(llvm::StringRef name) = 0;
  41. virtual void DetachAll() = 0;
  42. virtual std::unique_ptr<llvm::Module>
  43. Link(llvm::StringRef entry, llvm::StringRef profile, dxilutil::ExportMap &exportMap) = 0;
  44. protected:
  45. DxilLinker(llvm::LLVMContext &Ctx, unsigned valMajor, unsigned valMinor) : m_ctx(Ctx), m_valMajor(valMajor), m_valMinor(valMinor) {}
  46. llvm::LLVMContext &m_ctx;
  47. unsigned m_valMajor, m_valMinor;
  48. };
  49. } // namespace hlsl