unroll.i
上传用户:ykyjsl
上传日期:2022-01-30
资源大小:145k
文件大小:2k
源码类别:

压缩解压

开发平台:

C/C++

  1. /*  unroll.i
  2.   Used for loop unrolling, duplicates the given code fragment a specified
  3.   number of times.
  4.   ---------------------------------------------------------- 
  5.   Precondition:
  6. #define UNROLL_NUM Number of repetitions
  7. #define UNROLL_CODE Code to repeat
  8.   To use:
  9. #include "unroll.i"
  10.   Result:
  11. The code UNROLL_CODE repeated UNROLL_NUM times.
  12.   ---------------------------------------------------------- 
  13.   For example:
  14.         The program fragment:
  15. ...
  16. i=0;
  17. #define UNROLL_NUM 3
  18. #define UNROLL_CODE  printf("%i",i++);
  19. #include "unroll.i"
  20. ...
  21. is equivalent to:
  22. ...
  23. i=0;
  24. printf("%i",i++);
  25. printf("%i",i++);
  26. printf("%i",i++);
  27. ...
  28.   ---------------------------------------------------------- 
  29.   If the number of times the code fragment is to be repeated is greater
  30.   than a certain number (here, 32), then a loop is added to repeat the code
  31.   fragment as required.  
  32.  */
  33. #if UNROLL_NUM > 0
  34.   UNROLL_CODE
  35. #endif
  36. #if UNROLL_NUM > 1
  37.   UNROLL_CODE
  38. #endif
  39. #if UNROLL_NUM > 2
  40.   UNROLL_CODE
  41. #endif
  42. #if UNROLL_NUM > 3
  43.   UNROLL_CODE
  44. #endif
  45. #if UNROLL_NUM > 4
  46.   UNROLL_CODE
  47. #endif
  48. #if UNROLL_NUM > 5
  49.   UNROLL_CODE
  50. #endif
  51. #if UNROLL_NUM > 6
  52.   UNROLL_CODE
  53. #endif
  54. #if UNROLL_NUM > 7
  55.   UNROLL_CODE
  56. #endif
  57. #if UNROLL_NUM > 8
  58.   UNROLL_CODE
  59. #endif
  60. #if UNROLL_NUM > 9
  61.   UNROLL_CODE
  62. #endif
  63. #if UNROLL_NUM > 10
  64.   UNROLL_CODE
  65. #endif
  66. #if UNROLL_NUM > 11
  67.   UNROLL_CODE
  68. #endif
  69. #if UNROLL_NUM > 12
  70.   UNROLL_CODE
  71. #endif
  72. #if UNROLL_NUM > 13
  73.   UNROLL_CODE
  74. #endif
  75. #if UNROLL_NUM > 14
  76.   UNROLL_CODE
  77. #endif
  78. #if UNROLL_NUM > 15
  79.   UNROLL_CODE
  80. #endif
  81. #if UNROLL_NUM > 16
  82.   UNROLL_CODE
  83. #endif
  84. #if UNROLL_NUM > 17
  85.   UNROLL_CODE
  86. #endif
  87. #if UNROLL_NUM > 18
  88.   UNROLL_CODE
  89. #endif
  90. #if UNROLL_NUM > 19
  91.   UNROLL_CODE
  92. #endif
  93. #if UNROLL_NUM > 20
  94.   UNROLL_CODE
  95. #endif
  96. #if UNROLL_NUM > 21
  97.   UNROLL_CODE
  98. #endif
  99. #if UNROLL_NUM > 22
  100.   UNROLL_CODE
  101. #endif
  102. #if UNROLL_NUM > 23
  103.   UNROLL_CODE
  104. #endif
  105. #if UNROLL_NUM > 24
  106.   UNROLL_CODE
  107. #endif
  108. #if UNROLL_NUM > 25
  109.   UNROLL_CODE
  110. #endif
  111. #if UNROLL_NUM > 26
  112.   UNROLL_CODE
  113. #endif
  114. #if UNROLL_NUM > 27
  115.   UNROLL_CODE
  116. #endif
  117. #if UNROLL_NUM > 28
  118.   UNROLL_CODE
  119. #endif
  120. #if UNROLL_NUM > 29
  121.   UNROLL_CODE
  122. #endif
  123. #if UNROLL_NUM > 30
  124.   UNROLL_CODE
  125. #endif
  126. #if UNROLL_NUM > 31
  127.   UNROLL_CODE
  128. #endif
  129. #if UNROLL_NUM > 32
  130.   {  int __i7;
  131.     for (__i7=0; __i7 < UNROLL_NUM-32; __i7++)
  132. {
  133. UNROLL_CODE
  134. }
  135.   }
  136. #endif
  137. #undef UNROLL_NUM
  138. #undef UNROLL_CODE