Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nv50_ir_lowering_nvc0.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2011 Christoph Bumiller
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #include "codegen/nv50_ir.h"
  23. #include "codegen/nv50_ir_build_util.h"
  24. namespace nv50_ir {
  25. class NVC0LegalizeSSA : public Pass
  26. {
  27. private:
  28. virtual bool visit(BasicBlock *);
  29. virtual bool visit(Function *);
  30. // we want to insert calls to the builtin library only after optimization
  31. void handleDIV(Instruction *); // integer division, modulus
  32. void handleRCPRSQ(Instruction *); // double precision float recip/rsqrt
  33. void handleFTZ(Instruction *);
  34. private:
  35. BuildUtil bld;
  36. };
  37. class NVC0LegalizePostRA : public Pass
  38. {
  39. public:
  40. NVC0LegalizePostRA(const Program *);
  41. private:
  42. virtual bool visit(Function *);
  43. virtual bool visit(BasicBlock *);
  44. void replaceZero(Instruction *);
  45. bool tryReplaceContWithBra(BasicBlock *);
  46. void propagateJoin(BasicBlock *);
  47. struct TexUse
  48. {
  49. TexUse(Instruction *use, const Instruction *tex)
  50. : insn(use), tex(tex), level(-1) { }
  51. Instruction *insn;
  52. const Instruction *tex; // or split / mov
  53. int level;
  54. };
  55. struct Limits
  56. {
  57. Limits() { }
  58. Limits(int min, int max) : min(min), max(max) { }
  59. int min, max;
  60. };
  61. bool insertTextureBarriers(Function *);
  62. inline bool insnDominatedBy(const Instruction *, const Instruction *) const;
  63. void findFirstUses(Instruction *texi, std::list<TexUse> &uses);
  64. void findFirstUsesBB(int minGPR, int maxGPR, Instruction *start,
  65. const Instruction *texi, std::list<TexUse> &uses,
  66. unordered_set<const BasicBlock *> &visited);
  67. void addTexUse(std::list<TexUse>&, Instruction *, const Instruction *);
  68. const Instruction *recurseDef(const Instruction *);
  69. private:
  70. LValue *rZero;
  71. LValue *carry;
  72. LValue *pOne;
  73. const bool needTexBar;
  74. };
  75. class NVC0LoweringPass : public Pass
  76. {
  77. public:
  78. NVC0LoweringPass(Program *);
  79. protected:
  80. bool handleRDSV(Instruction *);
  81. bool handleWRSV(Instruction *);
  82. bool handleEXPORT(Instruction *);
  83. bool handleOUT(Instruction *);
  84. bool handleDIV(Instruction *);
  85. bool handleMOD(Instruction *);
  86. bool handleSQRT(Instruction *);
  87. bool handlePOW(Instruction *);
  88. bool handleTEX(TexInstruction *);
  89. bool handleTXD(TexInstruction *);
  90. bool handleTXQ(TexInstruction *);
  91. virtual bool handleManualTXD(TexInstruction *);
  92. bool handleTXLQ(TexInstruction *);
  93. bool handleSUQ(TexInstruction *);
  94. bool handleATOM(Instruction *);
  95. bool handleCasExch(Instruction *, bool needCctl);
  96. void handleSurfaceOpNVE4(TexInstruction *);
  97. void handleSharedATOM(Instruction *);
  98. void handleSharedATOMNVE4(Instruction *);
  99. void handleLDST(Instruction *);
  100. bool handleBUFQ(Instruction *);
  101. void checkPredicate(Instruction *);
  102. virtual bool visit(Instruction *);
  103. private:
  104. virtual bool visit(Function *);
  105. virtual bool visit(BasicBlock *);
  106. void readTessCoord(LValue *dst, int c);
  107. Value *loadResInfo32(Value *ptr, uint32_t off, uint16_t base);
  108. Value *loadResInfo64(Value *ptr, uint32_t off, uint16_t base);
  109. Value *loadResLength32(Value *ptr, uint32_t off, uint16_t base);
  110. Value *loadSuInfo32(Value *ptr, uint32_t off);
  111. Value *loadSuInfo64(Value *ptr, uint32_t off);
  112. Value *loadSuLength32(Value *ptr, uint32_t off);
  113. Value *loadBufInfo32(Value *ptr, uint32_t off);
  114. Value *loadBufInfo64(Value *ptr, uint32_t off);
  115. Value *loadBufLength32(Value *ptr, uint32_t off);
  116. Value *loadUboInfo32(Value *ptr, uint32_t off);
  117. Value *loadUboInfo64(Value *ptr, uint32_t off);
  118. Value *loadUboLength32(Value *ptr, uint32_t off);
  119. Value *loadMsInfo32(Value *ptr, uint32_t off);
  120. Value *loadTexHandle(Value *ptr, unsigned int slot);
  121. void adjustCoordinatesMS(TexInstruction *);
  122. void processSurfaceCoordsNVE4(TexInstruction *);
  123. void convertSurfaceFormat(TexInstruction *);
  124. protected:
  125. BuildUtil bld;
  126. private:
  127. const Target *const targ;
  128. Symbol *gMemBase;
  129. LValue *gpEmitAddress;
  130. };
  131. } // namespace nv50_ir