Clone of mesa.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

instructionssoa.h 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**************************************************************************
  2. *
  3. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifndef INSTRUCTIONSSOA_H
  28. #define INSTRUCTIONSSOA_H
  29. #include <pipe/p_shader_tokens.h>
  30. #include <llvm/Support/IRBuilder.h>
  31. #include <map>
  32. #include <vector>
  33. namespace llvm {
  34. class Module;
  35. class Function;
  36. class BasicBlock;
  37. class Value;
  38. }
  39. class StorageSoa;
  40. class InstructionsSoa
  41. {
  42. public:
  43. InstructionsSoa(llvm::Module *mod, llvm::Function *func,
  44. llvm::BasicBlock *block, StorageSoa *storage);
  45. std::vector<llvm::Value*> abs(const std::vector<llvm::Value*> in1);
  46. std::vector<llvm::Value*> arl(const std::vector<llvm::Value*> in);
  47. std::vector<llvm::Value*> add(const std::vector<llvm::Value*> in1,
  48. const std::vector<llvm::Value*> in2);
  49. std::vector<llvm::Value*> dp3(const std::vector<llvm::Value*> in1,
  50. const std::vector<llvm::Value*> in2);
  51. std::vector<llvm::Value*> dp4(const std::vector<llvm::Value*> in1,
  52. const std::vector<llvm::Value*> in2);
  53. std::vector<llvm::Value*> lit(const std::vector<llvm::Value*> in);
  54. std::vector<llvm::Value*> madd(const std::vector<llvm::Value*> in1,
  55. const std::vector<llvm::Value*> in2,
  56. const std::vector<llvm::Value*> in3);
  57. std::vector<llvm::Value*> max(const std::vector<llvm::Value*> in1,
  58. const std::vector<llvm::Value*> in2);
  59. std::vector<llvm::Value*> min(const std::vector<llvm::Value*> in1,
  60. const std::vector<llvm::Value*> in2);
  61. std::vector<llvm::Value*> mul(const std::vector<llvm::Value*> in1,
  62. const std::vector<llvm::Value*> in2);
  63. std::vector<llvm::Value*> pow(const std::vector<llvm::Value*> in1,
  64. const std::vector<llvm::Value*> in2);
  65. std::vector<llvm::Value*> rsq(const std::vector<llvm::Value*> in1);
  66. std::vector<llvm::Value*> slt(const std::vector<llvm::Value*> in1,
  67. const std::vector<llvm::Value*> in2);
  68. std::vector<llvm::Value*> sub(const std::vector<llvm::Value*> in1,
  69. const std::vector<llvm::Value*> in2);
  70. void end();
  71. std::vector<llvm::Value*> extractVector(llvm::Value *vector);
  72. private:
  73. const char * name(const char *prefix) const;
  74. llvm::Value *vectorFromVals(llvm::Value *x, llvm::Value *y,
  75. llvm::Value *z, llvm::Value *w);
  76. void createFunctionMap();
  77. void createBuiltins();
  78. void createDependencies();
  79. llvm::Function *function(int);
  80. llvm::Module *currentModule() const;
  81. llvm::Value *allocaTemp();
  82. std::vector<llvm::Value*> allocaToResult(llvm::Value *allocaPtr);
  83. std::vector<llvm::Value*> callBuiltin(llvm::Function *func,
  84. const std::vector<llvm::Value*> in1);
  85. std::vector<llvm::Value*> callBuiltin(llvm::Function *func,
  86. const std::vector<llvm::Value*> in1,
  87. const std::vector<llvm::Value*> in2);
  88. std::vector<llvm::Value*> callBuiltin(llvm::Function *func,
  89. const std::vector<llvm::Value*> in1,
  90. const std::vector<llvm::Value*> in2,
  91. const std::vector<llvm::Value*> in3);
  92. void injectFunction(llvm::Function *originalFunc, int op = TGSI_OPCODE_LAST);
  93. private:
  94. llvm::IRBuilder<> m_builder;
  95. StorageSoa *m_storage;
  96. std::map<int, std::string> m_functionsMap;
  97. std::map<int, llvm::Function*> m_functions;
  98. llvm::Module *m_builtins;
  99. std::map<std::string, std::vector<std::string> > m_builtinDependencies;
  100. private:
  101. mutable int m_idx;
  102. mutable char m_name[32];
  103. };
  104. #endif