CodeGenSPIRVTest.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //===- unittests/SPIRV/CodeGenSPIRVTest.cpp ---- Run CodeGenSPIRV tests ---===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #include "FileTestFixture.h"
  10. #include "WholeFileTestFixture.h"
  11. namespace {
  12. using clang::spirv::FileTest;
  13. using clang::spirv::WholeFileTest;
  14. // === Whole output tests ===
  15. TEST_F(WholeFileTest, EmptyVoidMain) {
  16. runWholeFileTest("empty-void-main.hlsl2spv", /*generateHeader*/ true);
  17. }
  18. TEST_F(WholeFileTest, PassThruPixelShader) {
  19. runWholeFileTest("passthru-ps.hlsl2spv", /*generateHeader*/ true);
  20. }
  21. TEST_F(WholeFileTest, PassThruVertexShader) {
  22. runWholeFileTest("passthru-vs.hlsl2spv", /*generateHeader*/ true);
  23. }
  24. TEST_F(WholeFileTest, ConstantPixelShader) {
  25. runWholeFileTest("constant-ps.hlsl2spv", /*generateHeader*/ true);
  26. }
  27. // === Partial output tests ===
  28. // For types
  29. TEST_F(FileTest, ScalarTypes) { runFileTest("type.scalar.hlsl"); }
  30. TEST_F(FileTest, VectorTypes) { runFileTest("type.vector.hlsl"); }
  31. // For constants
  32. TEST_F(FileTest, ScalarConstants) { runFileTest("constant.scalar.hlsl"); }
  33. TEST_F(FileTest, VectorConstants) { runFileTest("constant.vector.hlsl"); }
  34. // For variables
  35. TEST_F(FileTest, VariableInitialier) { runFileTest("var.init.hlsl"); }
  36. // For prefix/postfix increment/decrement
  37. TEST_F(FileTest, UnaryOpPrefixIncrement) {
  38. runFileTest("unary-op.prefix-inc.hlsl");
  39. }
  40. TEST_F(FileTest, UnaryOpPrefixDecrement) {
  41. runFileTest("unary-op.prefix-dec.hlsl");
  42. }
  43. TEST_F(FileTest, UnaryOpPostfixIncrement) {
  44. runFileTest("unary-op.postfix-inc.hlsl");
  45. }
  46. TEST_F(FileTest, UnaryOpPostfixDecrement) {
  47. runFileTest("unary-op.postfix-dec.hlsl");
  48. }
  49. // For unary operators
  50. TEST_F(FileTest, UnaryOpPlus) { runFileTest("unary-op.plus.hlsl"); }
  51. TEST_F(FileTest, UnaryOpMinus) { runFileTest("unary-op.minus.hlsl"); }
  52. TEST_F(FileTest, UnaryOpLogicalNot) {
  53. runFileTest("unary-op.logical-not.hlsl");
  54. }
  55. // For assignments
  56. TEST_F(FileTest, BinaryOpAssign) { runFileTest("binary-op.assign.hlsl"); }
  57. // For arithmetic binary operators
  58. TEST_F(FileTest, BinaryOpScalarArithmetic) {
  59. runFileTest("binary-op.arithmetic.scalar.hlsl");
  60. }
  61. TEST_F(FileTest, BinaryOpVectorArithmetic) {
  62. runFileTest("binary-op.arithmetic.vector.hlsl");
  63. }
  64. TEST_F(FileTest, BinaryOpMixedArithmetic) {
  65. runFileTest("binary-op.arithmetic.mixed.hlsl");
  66. }
  67. // For arithmetic assignments
  68. TEST_F(FileTest, BinaryOpScalarArithAssign) {
  69. runFileTest("binary-op.arith-assign.scalar.hlsl");
  70. }
  71. TEST_F(FileTest, BinaryOpVectorArithAssign) {
  72. runFileTest("binary-op.arith-assign.vector.hlsl");
  73. }
  74. TEST_F(FileTest, BinaryOpMixedArithAssign) {
  75. runFileTest("binary-op.arith-assign.mixed.hlsl");
  76. }
  77. // For bitwise binary operators
  78. TEST_F(FileTest, BinaryOpScalarBitwise) {
  79. runFileTest("binary-op.bitwise.scalar.hlsl");
  80. }
  81. TEST_F(FileTest, BinaryOpVectorBitwise) {
  82. runFileTest("binary-op.bitwise.vector.hlsl");
  83. }
  84. TEST_F(FileTest, BinaryOpMixedBitwise) {
  85. runFileTest("binary-op.bitwise.mixed.hlsl");
  86. }
  87. // For bitwise assignments
  88. TEST_F(FileTest, BinaryOpScalarBitwiseAssign) {
  89. runFileTest("binary-op.bitwise-assign.scalar.hlsl");
  90. }
  91. TEST_F(FileTest, BinaryOpVectorBitwiseAssign) {
  92. runFileTest("binary-op.bitwise-assign.vector.hlsl");
  93. }
  94. TEST_F(FileTest, BinaryOpMixedBitwiseAssign) {
  95. runFileTest("binary-op.bitwise-assign.mixed.hlsl");
  96. }
  97. // For comparison operators
  98. TEST_F(FileTest, BinaryOpScalarComparison) {
  99. runFileTest("binary-op.comparison.scalar.hlsl");
  100. }
  101. TEST_F(FileTest, BinaryOpVectorComparison) {
  102. runFileTest("binary-op.comparison.vector.hlsl");
  103. }
  104. TEST_F(FileTest, BinaryOpMixedComparison) {
  105. runFileTest("binary-op.comparison.mixed.hlsl");
  106. }
  107. // For if statements
  108. TEST_F(FileTest, IfStmtPlainAssign) { runFileTest("if-stmt.plain.hlsl"); }
  109. TEST_F(FileTest, IfStmtNestedIfStmt) { runFileTest("if-stmt.nested.hlsl"); }
  110. // For for statements
  111. TEST_F(FileTest, ForStmtPlainAssign) { runFileTest("for-stmt.plain.hlsl"); }
  112. TEST_F(FileTest, ForStmtNestedForStmt) { runFileTest("for-stmt.nested.hlsl"); }
  113. // For control flows
  114. TEST_F(FileTest, ControlFlowNestedIfForStmt) { runFileTest("cf.if.for.hlsl"); }
  115. // For function calls
  116. TEST_F(FileTest, FunctionCall) { runFileTest("fn.call.hlsl"); }
  117. TEST_F(FileTest, IntrinsicsDot) { runFileTest("intrinsics.dot.hlsl"); }
  118. } // namespace