NVPTXUtilities.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //===-- NVPTXUtilities - Utilities -----------------------------*- C++ -*-====//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains the declaration of the NVVM specific utility functions.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
  13. #define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
  14. #include "llvm/IR/Function.h"
  15. #include "llvm/IR/GlobalVariable.h"
  16. #include "llvm/IR/IntrinsicInst.h"
  17. #include "llvm/IR/Value.h"
  18. #include <cstdarg>
  19. #include <set>
  20. #include <string>
  21. #include <vector>
  22. namespace llvm {
  23. class TargetMachine;
  24. void clearAnnotationCache(const Module *);
  25. bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
  26. unsigned &);
  27. bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
  28. std::vector<unsigned> &);
  29. bool isTexture(const Value &);
  30. bool isSurface(const Value &);
  31. bool isSampler(const Value &);
  32. bool isImage(const Value &);
  33. bool isImageReadOnly(const Value &);
  34. bool isImageWriteOnly(const Value &);
  35. bool isImageReadWrite(const Value &);
  36. bool isManaged(const Value &);
  37. std::string getTextureName(const Value &);
  38. std::string getSurfaceName(const Value &);
  39. std::string getSamplerName(const Value &);
  40. bool getMaxNTIDx(const Function &, unsigned &);
  41. bool getMaxNTIDy(const Function &, unsigned &);
  42. bool getMaxNTIDz(const Function &, unsigned &);
  43. bool getReqNTIDx(const Function &, unsigned &);
  44. bool getReqNTIDy(const Function &, unsigned &);
  45. bool getReqNTIDz(const Function &, unsigned &);
  46. bool getMinCTASm(const Function &, unsigned &);
  47. bool getMaxNReg(const Function &, unsigned &);
  48. bool isKernelFunction(const Function &);
  49. bool getAlign(const Function &, unsigned index, unsigned &);
  50. bool getAlign(const CallInst &, unsigned index, unsigned &);
  51. Function *getMaybeBitcastedCallee(const CallBase *CB);
  52. // PTX ABI requires all scalar argument/return values to have
  53. // bit-size as a power of two of at least 32 bits.
  54. inline unsigned promoteScalarArgumentSize(unsigned size) {
  55. if (size <= 32)
  56. return 32;
  57. else if (size <= 64)
  58. return 64;
  59. else
  60. return size;
  61. }
  62. bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
  63. }
  64. #endif