opt_var.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. NASM Optimizer Usage of
  2. Certain Variables to Control Assembly
  3. prepared by: John R Coffman
  4. date: 07-Mar-2005
  5. GLOBAL variables:
  6. optimizing optimization meta data (with level and flag info)
  7. .level -1 flags nasm 0.98 compatible operation;
  8. offsets usually are explicit (short/near)
  9. no optimization passes
  10. 0 flags non-optimized assembly; forward
  11. references generate long offsets; always
  12. assembles
  13. no optimization passes
  14. 2 or more specifies optmization passes. 5 is
  15. the actual recommended minimum setting
  16. optimization passes (2 or more, plus
  17. passes 1 and 2 will be required)
  18. .flag 0 allow all optimizations
  19. 1 disallow jump match optimization
  20. pass0 0 flags an optimizer pass (multiple passes)
  21. 1 flags pass1 (define labels)
  22. 2 flags pass2 (spit out code)
  23. LOCAL variables: local to 'assemble_file' (nasm.c)
  24. pass_max 2 for non-optimized assembly
  25. 4 or more for optimized assembly
  26. pass index of the FOR loop (1..pass_max)
  27. with optimized assembly, this variable is
  28. advanced to 'pass_max - 1' in the logic
  29. at the end of the loop to terminate
  30. an optimized assembly before all passes
  31. are used; i.e., when convergence has
  32. occurred
  33. pass1 flag for making parts of the assembler do
  34. pass 1 behaviors on optimizer passes
  35. pass2 flag for making parts of the assembler do
  36. pass 2 behaviors on optimizer passes
  37. pass_cnt benign counter for counting the actual
  38. number of passes taken. Since 'pass'
  39. may be jerked upward early on optimized
  40. assembly, it does not accurately reflect
  41. the number of passes taken.
  42. always ends at 2 for non-optimized assembly
  43. How the variables sequence:
  44. NON-OPTIMIZED assembly:
  45. pass0 1 2 all indicate, pass 1 and pass 2
  46. pass1 1 2
  47. pass2 1 2
  48. pass 1 2
  49. ----------------------------------------
  50. pass_max pre-set to 2
  51. pass_cnt ends at 2
  52. OPTIMIZED assembly:
  53. optimizing set to 2 or greater
  54. pass0 0 0 0 0 0 ... 0 0 1 2
  55. pass1 1 1 1 1 1 ... 1 1 1 2
  56. pass2 1 2 2 2 2 ... 2 2 2 2
  57. pass 1 2 3 4 5 ... 7 8 9 12
  58. pass_max pre-set to, say, 12
  59. pass_cnt ends at 10 for this assembly
  60. >From pass_cnt, the reported number of passes will be 1+8+1, meaning
  61. 8 optimization passes, plus pass 1, plus pass 2.
  62. Subroutines may check 'pass0' to see if an optimizer pass is in
  63. progress (pass0==0). Many have arguments to tell what pass is in
  64. progress. But these variables are passed in as 'pass1' or 'pass2'.
  65. >From the sequences above, 'pass' bears no relation to the desired
  66. pass 1 or pass 2 behavior of the assembler. 'pass1' is used to tell
  67. parts of the assembler, on multiple occasions, that pass 1 is in
  68. progress, and only once that pass 2 is being performed. Other parts
  69. of the assembler need to be told only once that pass 1 is being
  70. performed, but may be told multiple times that pass 2 is being done.
  71. For instance, the preprocessor reset operation looks at pass1, and it
  72. thinks many pass 1 resets are being done, but only one pass 2 reset
  73. is done. Also, certain errors are non-fatal on pass 1, but fatal on
  74. pass 2; hence, they are tied to the 'pass1' variable to determine the
  75. assembler pass number.
  76. Further, segment definitions look at the 'pass2' variable, since they
  77. do some initialization on pass 1, but are pretty much no-ops on pass
  78. 2. Hence, they should see pass 1 only once, but may see pass 2
  79. multiple times.
  80. [end]