DxcPixLiveVariables.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxcPixLiveVariables.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. // Implements a mapping from the instructions in the Module to the set of //
  9. // live variables available in that instruction. //
  10. // //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #pragma once
  13. #include "dxc/Support/WinIncludes.h"
  14. #include <map>
  15. #include <memory>
  16. #include <vector>
  17. #include "DxcPixDxilDebugInfo.h"
  18. namespace llvm
  19. {
  20. class DIVariable;
  21. class Instruction;
  22. class Module;
  23. class Value;
  24. } // namespace llvm
  25. namespace dxil_debug_info
  26. {
  27. // VariableInfo is the bag with the information about a particular
  28. // DIVariable in the Module.
  29. struct VariableInfo
  30. {
  31. using OffsetInBits = unsigned;
  32. // Location is the dxil alloca register where this variable lives.
  33. struct Location
  34. {
  35. llvm::Value *m_V = nullptr;
  36. unsigned m_FragmentIndex = 0;
  37. };
  38. explicit VariableInfo(
  39. llvm::DIVariable *Variable
  40. ) : m_Variable(Variable)
  41. {
  42. }
  43. llvm::DIVariable *m_Variable;
  44. std::map<OffsetInBits, Location> m_ValueLocationMap;
  45. #ifndef NDEBUG
  46. std::vector<bool> m_DbgDeclareValidation;
  47. #endif // !NDEBUG
  48. };
  49. class LiveVariables {
  50. public:
  51. LiveVariables();
  52. ~LiveVariables();
  53. HRESULT Init(DxcPixDxilDebugInfo *pDxilDebugInfo);
  54. void Clear();
  55. HRESULT GetLiveVariablesAtInstruction(
  56. llvm::Instruction *Instr,
  57. IDxcPixDxilLiveVariables **Result) const;
  58. private:
  59. struct Impl;
  60. std::unique_ptr<Impl> m_pImpl;
  61. };
  62. HRESULT CreateDxilLiveVariables(
  63. DxcPixDxilDebugInfo *pDxilDebugInfo,
  64. std::vector<const VariableInfo *> &&LiveVariables,
  65. IDxcPixDxilLiveVariables **ppResult);
  66. } // namespace dxil_debug_info