HLMatrixLowerHelper.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. class DxilFieldAnnotation;
  21. class DxilTypeSystem;
  22. namespace HLMatrixLower {
  23. // TODO: use type annotation.
  24. bool IsMatrixType(llvm::Type *Ty);
  25. DxilFieldAnnotation *FindAnnotationFromMatUser(llvm::Value *Mat,
  26. DxilTypeSystem &typeSys);
  27. // Translate matrix type to vector type.
  28. llvm::Type *LowerMatrixType(llvm::Type *Ty);
  29. // TODO: use type annotation.
  30. llvm::Type *GetMatrixInfo(llvm::Type *Ty, unsigned &col, unsigned &row);
  31. // TODO: use type annotation.
  32. bool IsMatrixArrayPointer(llvm::Type *Ty);
  33. // Translate matrix array pointer type to vector array pointer type.
  34. llvm::Type *LowerMatrixArrayPointer(llvm::Type *Ty);
  35. llvm::Value *BuildVector(llvm::Type *EltTy, unsigned size,
  36. llvm::ArrayRef<llvm::Value *> elts,
  37. llvm::IRBuilder<> &Builder);
  38. // For case like mat[i][j].
  39. // IdxList is [i][0], [i][1], [i][2],[i][3].
  40. // Idx is j.
  41. // return [i][j] not mat[i][j] because resource ptr and temp ptr need different
  42. // code gen.
  43. llvm::Value *
  44. LowerGEPOnMatIndexListToIndex(llvm::GetElementPtrInst *GEP,
  45. llvm::ArrayRef<llvm::Value *> IdxList);
  46. unsigned GetColMajorIdx(unsigned r, unsigned c, unsigned row);
  47. unsigned GetRowMajorIdx(unsigned r, unsigned c, unsigned col);
  48. } // namespace HLMatrixLower
  49. } // namespace hlsl