inline-asm-validate-x86.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
  2. // RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
  3. void I(int i, int j) {
  4. static const int BelowMin = -1;
  5. static const int AboveMax = 32;
  6. __asm__("xorl %0,%2"
  7. : "=r"(i)
  8. : "0"(i), "I"(j)); // expected-error{{constraint 'I' expects an integer constant expression}}
  9. __asm__("xorl %0,%2"
  10. : "=r"(i)
  11. : "0"(i), "I"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}
  12. __asm__("xorl %0,%2"
  13. : "=r"(i)
  14. : "0"(i), "I"(AboveMax)); // expected-error{{value '32' out of range for constraint 'I'}}
  15. __asm__("xorl %0,%2"
  16. : "=r"(i)
  17. : "0"(i), "I"(16)); // expected-no-error
  18. }
  19. void J(int i, int j) {
  20. static const int BelowMin = -1;
  21. static const int AboveMax = 64;
  22. __asm__("xorl %0,%2"
  23. : "=r"(i)
  24. : "0"(i), "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
  25. __asm__("xorl %0,%2"
  26. : "=r"(i)
  27. : "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
  28. __asm__("xorl %0,%2"
  29. : "=r"(i)
  30. : "0"(i), "J"(AboveMax)); // expected-error{{value '64' out of range for constraint 'J'}}
  31. __asm__("xorl %0,%2"
  32. : "=r"(i)
  33. : "0"(i), "J"(32)); // expected-no-error
  34. }
  35. void K(int i, int j) {
  36. static const int BelowMin = -129;
  37. static const int AboveMax = 128;
  38. __asm__("xorl %0,%2"
  39. : "=r"(i)
  40. : "0"(i), "K"(j)); // expected-error{{constraint 'K' expects an integer constant expression}}
  41. __asm__("xorl %0,%2"
  42. : "=r"(i)
  43. : "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}
  44. __asm__("xorl %0,%2"
  45. : "=r"(i)
  46. : "0"(i), "K"(AboveMax)); // expected-error{{value '128' out of range for constraint 'K'}}
  47. __asm__("xorl %0,%2"
  48. : "=r"(i)
  49. : "0"(i), "K"(96)); // expected-no-error
  50. }
  51. void M(int i, int j) {
  52. static const int BelowMin = -1;
  53. static const int AboveMax = 4;
  54. __asm__("xorl %0,%2"
  55. : "=r"(i)
  56. : "0"(i), "M"(j)); // expected-error{{constraint 'M' expects an integer constant expression}}
  57. __asm__("xorl %0,%2"
  58. : "=r"(i)
  59. : "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}
  60. __asm__("xorl %0,%2"
  61. : "=r"(i)
  62. : "0"(i), "M"(AboveMax)); // expected-error{{value '4' out of range for constraint 'M'}}
  63. __asm__("xorl %0,%2"
  64. : "=r"(i)
  65. : "0"(i), "M"(2)); // expected-no-error
  66. }
  67. void N(int i, int j) {
  68. static const int BelowMin = -1;
  69. static const int AboveMax = 256;
  70. __asm__("xorl %0,%2"
  71. : "=r"(i)
  72. : "0"(i), "N"(j)); // expected-error{{constraint 'N' expects an integer constant expression}}
  73. __asm__("xorl %0,%2"
  74. : "=r"(i)
  75. : "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}
  76. __asm__("xorl %0,%2"
  77. : "=r"(i)
  78. : "0"(i), "N"(AboveMax)); // expected-error{{value '256' out of range for constraint 'N'}}
  79. __asm__("xorl %0,%2"
  80. : "=r"(i)
  81. : "0"(i), "N"(128)); // expected-no-error
  82. }
  83. void O(int i, int j) {
  84. static const int BelowMin = -1;
  85. static const int AboveMax = 128;
  86. __asm__("xorl %0,%2"
  87. : "=r"(i)
  88. : "0"(i), "O"(j)); // expected-error{{constraint 'O' expects an integer constant expression}}
  89. __asm__("xorl %0,%2"
  90. : "=r"(i)
  91. : "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}
  92. __asm__("xorl %0,%2"
  93. : "=r"(i)
  94. : "0"(i), "O"(AboveMax)); // expected-error{{value '128' out of range for constraint 'O'}}
  95. __asm__("xorl %0,%2"
  96. : "=r"(i)
  97. : "0"(i), "O"(64)); // expected-no-error
  98. }