HLMatrixLowerHelper.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // HLMatrixLowerHelper.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. // This file provides helper functions to lower high level matrix. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "llvm/IR/IRBuilder.h"
  13. namespace llvm {
  14. class Type;
  15. class Value;
  16. template<typename T>
  17. class ArrayRef;
  18. }
  19. namespace hlsl {
  20. namespace HLMatrixLower {
  21. // TODO: use type annotation.
  22. bool IsMatrixType(llvm::Type *Ty);
  23. // Translate matrix type to vector type.
  24. llvm::Type *LowerMatrixType(llvm::Type *Ty);
  25. // TODO: use type annotation.
  26. llvm::Type *GetMatrixInfo(llvm::Type *Ty, unsigned &col, unsigned &row);
  27. // TODO: use type annotation.
  28. bool IsMatrixArrayPointer(llvm::Type *Ty);
  29. // Translate matrix array pointer type to vector array pointer type.
  30. llvm::Type *LowerMatrixArrayPointer(llvm::Type *Ty);
  31. llvm::Value *BuildVector(llvm::Type *EltTy, unsigned size,
  32. llvm::ArrayRef<llvm::Value *> elts,
  33. llvm::IRBuilder<> &Builder);
  34. // For case like mat[i][j].
  35. // IdxList is [i][0], [i][1], [i][2],[i][3].
  36. // Idx is j.
  37. // return [i][j] not mat[i][j] because resource ptr and temp ptr need different
  38. // code gen.
  39. llvm::Value *
  40. LowerGEPOnMatIndexListToIndex(llvm::GetElementPtrInst *GEP,
  41. llvm::ArrayRef<llvm::Value *> IdxList);
  42. unsigned GetColMajorIdx(unsigned r, unsigned c, unsigned row);
  43. unsigned GetRowMajorIdx(unsigned r, unsigned c, unsigned col);
  44. } // namespace HLMatrixLower
  45. } // namespace hlsl