ack.1.X 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. .\" $Id$
  2. .de SB
  3. .\" SuBheader
  4. .sp 1
  5. .PP
  6. .nr Sf \\n(.f
  7. .ft B
  8. \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
  9. .ft \\n(Sf
  10. .sp 1
  11. ..
  12. .TH ACK 1 "$Revision$"
  13. .ad
  14. .SH NAME
  15. ack \- Amsterdam Compiler Kit
  16. .SH SYNOPSIS
  17. \fBack\fP arguments
  18. .SH DESCRIPTION
  19. This program transforms sources in several
  20. languages to load files for a variety of machines,
  21. internally using several phases.
  22. The transformation can be stopped at any phase.
  23. Combining sources from several languages is allowed.
  24. The run-time system of the first language mentioned,
  25. either in the program call name or in the arguments,
  26. is automatically included.
  27. The libraries of all other languages mentioned,
  28. containing most of the run-time systems,
  29. are also automatically included.
  30. Two types of load files can be distinguished,
  31. \fIa.out\fP files containing machine code and \fIe.out\fP
  32. files containing virtual EM machine code.
  33. The last type is designed for interpretation; it is obtained by calling
  34. the compiler as \fIem22\fP, \fIem24\fP, or \fIem44\fP.
  35. Compilation time for interpretation is fast and gives many
  36. runtime checks,
  37. but execution with \fIem\fP(1) is about seven times slower.
  38. Execution with \fIint\fP(1) is even slower than that, but available on
  39. more machines.
  40. Which combinations of languages and machines are allowed varies
  41. in time and depends on the installation.
  42. .PP
  43. The actions of \fIack\fP are to repeatedly transform files with a
  44. particular suffix into files with another suffix,
  45. finally combining the results into a single file.
  46. .PP
  47. Different machines can use different suffices,
  48. but the following are recognized by most machines:
  49. .IP .p
  50. Pascal program.
  51. .IP .c
  52. C module.
  53. .IP .b
  54. Basic program.
  55. .IP .ocm
  56. Occam program.
  57. .IP .mod
  58. Modula-2 module.
  59. .IP .f
  60. Fortran module.
  61. .IP .e
  62. EM assembly module in human readable form.
  63. .IP .k
  64. Compact EM assembly code.
  65. .IP .m
  66. Optimized compact EM assembly code.
  67. .IP .s
  68. Machine assembly language code.
  69. .IP .o
  70. Object file.
  71. .PP
  72. .SH OPTIONS
  73. \fIAck\fP accepts the following flags:
  74. .IP \-m\fImachine\fP
  75. This flag tells \fIack\fP to generate a load file for \fImachine\fP.
  76. .IP \-o
  77. Use the next argument as the name of the resulting file.
  78. \fIAck\fP produces \fIa.out\fP or \fIe.out\fP by default.
  79. This flag can always be used when \fIack\fP produces a single output file,
  80. as in
  81. .br
  82. .ti +5
  83. \fBack -c.s main.c -o new.s\fP.
  84. .br
  85. The output is produced on \fInew.s\fP instead of \fImain.s\fP.
  86. .IP \-c\fI.suffix\fP
  87. .IP \-c
  88. \fIAck\fP tries to transform each source into a file with the \fIsuffix\fP.
  89. When no \fIsuffix\fP is specified \fIack\fP stops just
  90. before the phase where it combines all arguments into a load file,
  91. thereby transforming the sources into \fI.k\fP, \fI.s\fP,
  92. \&\fI.o\fP or \fI.m\fP files.
  93. One extra \fIsuffix\fP is recognized here, \fI.i\fP,
  94. this tells \fIack\fP to only preprocess all human readable sources,
  95. producing files with \fIsuffix\fP \fI.i\fP.
  96. .br
  97. Note: \fIack\fP refuses to overwrite argument \fI.e\fP files.
  98. .IP \-t
  99. Preserve all intermediate files.
  100. If two \fB\-t\fP are used,
  101. \fIack\fP also preserves core dumps and output of failed transformations.
  102. .IP \-w
  103. Suppress all warning messages.
  104. .IP \-v
  105. Verbose.
  106. Print information while juggling with files.
  107. .IP \-KR
  108. Tell the C-compiler to conform to "Kernighan & Ritchie" C.
  109. .IP \-ansi
  110. Tell \fIack\fP to use the ANSI C compiler instead of the old one.
  111. .IP \-fp
  112. Use the software floating point package, if present.
  113. .IP \-I\fIdir\fP
  114. \&\`#include\' files whose names do not begin with \`/\' are
  115. always sought first in the directory of the \fIfile\fP argument,
  116. then in the directories named in \fB\-I\fP options,
  117. then in directories on a standard list.
  118. .IP \-D\fIname=def\fP
  119. .IP \-D\fIname\fP
  120. Define the \fIname\fP to the preprocessor,
  121. as if by \`#define\'.
  122. If no definition is given the \fIname\fP is defined as 1.
  123. .IP \-U\fIname\fP
  124. Remove any initial definition of \fIname\fP, before
  125. preprocessing.
  126. .IP \-P
  127. Don't generate line directives.
  128. .IP \-C
  129. Leave C-comments in.
  130. .IP \-p
  131. This flag tells both the Pascal and C front ends to include
  132. code enabling the user to do some monitoring/debugging.
  133. Each time a routine is entered the routine \fBprocentry\fP
  134. is called and just before each return \fBprocexit\fP is called.
  135. These routines are supplied with one parameter, a pointer
  136. to a string containing the name of the routine.
  137. .IP \-O
  138. .IP \-O\fInum\fP
  139. .IP \-O\fIopt1,opt2,...\fP
  140. Try to use the named optimizers, or, if no optimizers are given,
  141. try to use the optimizers with optimization level <= \fInum\fP (default 1).
  142. For optimizer names, see the table at the end of this manual page.
  143. Currently, only the global optimizer has a level > 1.
  144. Higher levels will invoke more passes of the global optimizer.
  145. For the global optimizer, it is also possible to indicate explicitly which
  146. phases must be executed, using the following flags:
  147. .RS
  148. .IP \-EGO-IL
  149. Inline substitution.
  150. .IP \-EGO-CS
  151. Common subexpression elimination.
  152. .IP \-EGO-SR
  153. Strength reduction.
  154. .IP \-EGO-UD
  155. Use definition analysis.
  156. .IP \-EGO-LV
  157. Live variable analysis.
  158. .IP \-EGO-RA
  159. Register allocation.
  160. .IP \-EGO-SP
  161. Stack pollution.
  162. .IP \-EGO-BO
  163. Branch optimization.
  164. .IP \-EGO-CJ
  165. Cross jumping.
  166. .RE
  167. .IP ""
  168. Also, the following flags may be used:
  169. .RS
  170. .IP \-s<num>
  171. Give an indication to the inline substitution phase,
  172. how much bigger the program may get,
  173. in percentage. This is only used as a rough indication.
  174. The inline substitution phase will not make the program bigger when given \-s0.
  175. .IP \-a
  176. Indicate to the inline substitution phase that it is offered the whole program.
  177. This allows it to throw away routines that it has substituted inline.
  178. .IP \-Q
  179. Give some statistics.
  180. .IP \-T
  181. Optimize for time.
  182. .IP \-S
  183. Optimize for size.
  184. .RE
  185. .IP ""
  186. In principle, the optimization phases can be run in any order; a phase
  187. may even be run more than once. However, the following rules must be obeyed:
  188. .RS
  189. .IP -
  190. the Live Variable analysis phase (LV) must be run prior to the
  191. Register Allocation phase (SA), as SA uses information produced by LV.
  192. .IP -
  193. SA should be the last phase.
  194. .RE
  195. .IP ""
  196. Also, the following may be of use:
  197. .RS
  198. .IP -
  199. Inline Substitution (IL) may create new opportunities for most other phases,
  200. so it should be run as early as possible.
  201. .IP -
  202. Use Definition analysis (UD) may introduce opportunities for LV.
  203. .IP -
  204. Strength Reduction (SR) may create opportunities for UD.
  205. .RE
  206. .IP ""
  207. The global optimizer is a combiner, so it should be offered all the source
  208. files of the program. This is not strictly necessary, but it makes the
  209. global optimizer more effective.
  210. The current default optimization phases are:
  211. .RS
  212. .IP -
  213. for \-O2: CJ, BO, SP;
  214. .IP -
  215. for \-O3: CS, SR, CJ, BO, SP, UD, LV, RA;
  216. .IP -
  217. for \-O4: IL, CS, SR, CJ, BO, SP, UD, LV, RA;
  218. .IP -
  219. for higher levels: as for \-O4.
  220. .RE
  221. .IP \-L
  222. Disable the generation of code by the front ends to
  223. record line number and source file name at run-time.
  224. (This is the default for C and Fortran).
  225. .IP \-l\fIname\fP
  226. Tells \fIack\fP to insert a library module at this point.
  227. For example: the library \fImon\fP contains the
  228. routines for systems calls needed by both C and Pascal.
  229. .IP \-.\fIsuffix\fP
  230. When linking multiple \fI.o\fP or \fI.m\fP files created by
  231. separate calls of \fIack\fP together, \fIack\fP cannot deduce
  232. the run-time system needed,
  233. unless called as \fIapc\fP, \fIabc\fP, \fIocm\fP, \fIm2\fP, \fIf2c\fP, or \fIacc\fP.
  234. This flag serves to tell \fIack\fP which runtime system is
  235. needed in such a case.
  236. For example: "ack \-c x.c ; ack \-.c x.o".
  237. .IP \-r.\fIsuffix\fP
  238. Most frontends and backends use one or
  239. more run-time libraries.
  240. These flags tell \fIack\fP to include the libraries needed when
  241. a file with \fIsuffix\fP would be included in the arguments.
  242. .IP \-LIB
  243. This flag tells the peephole optimizer
  244. .RF em_opt 6
  245. to add information about the visibility of the names used
  246. to each output module.
  247. This is needed by
  248. assembler/linkers when these modules are to be inserted
  249. in libraries.
  250. .IP \-{xxx}
  251. The string starting after \`{\' and terminated by a \`}\' is passed
  252. as an option string to the Pascal compiler and supersedes corresponding
  253. options given in the source file.
  254. See the ACK reference manual [4] for a list of options.
  255. .IP "\-+xxx, \-\-xxx"
  256. When interpreting programs, these flags are used to select some
  257. options during interpretation, like test, profile, flow, extra and count.
  258. A short description of these flags follows:
  259. .RS
  260. .IP " t(est)" 12
  261. test for undefined, overflow, array bound etc.
  262. .IP " f(low)"
  263. keep track of executed source lines.
  264. .IP " c(ount)"
  265. count the number of times a source line is executed.
  266. .IP " p(rofile)"
  267. count the memory cycles executed per source line.
  268. .RE
  269. .IP "" 5
  270. Test is on by default, the others are off. Normally, these
  271. flag options are given each time the interpreter is run.
  272. The EM assembler/linker offers the opportunity to change
  273. the defaults per program.
  274. The changed options are recorded in the "e.out" header.
  275. These flags \-\- and \-+ are passed to the assembler for this purpose.
  276. So, \-\-t and \-+pfce invert the defaults.
  277. .IP \-R\fIprogram=xxx\fP
  278. Replace the \fIprogram\fP by the pathname \fIxxx\fP.
  279. The program names referred to later in this manual are allowed here.
  280. .IP \-R\fIprogram\-xxx\fP
  281. The flag argument \fI\-xxx\fP is given to \fIprogram\fP.
  282. .IP \-R\fIprogram:n\fP
  283. Set the priority of the indicated transformation to \fIn\fP.
  284. The default priority is 0, setting it to -1 makes it highly
  285. unlikely the the phase will be used, setting it to 1 makes
  286. it very likely that the phase will be used.
  287. .IP \-k
  288. Do not stop when an error occurs, but try to transform all
  289. other arguments as far as possible.
  290. .IP \-g
  291. Instruct the front-end and back-end to produce symbolic debugger information
  292. for \fIgrind\fP(1). This is currently supported by the following front-ends:
  293. C, ANSI-C, Pascal, Modula-2, and the following back-ends: Motorola M68020,
  294. Sparc, Vax, Intel 80386.
  295. .IP \-gdb
  296. Instruct the front-end and back-end to produce symbolic debugger information
  297. for \fIgdb\fP. This is currently supported by the following front-ends:
  298. C, ANSI-C, Pascal, Modula-2, and the following back-ends: Motorola M68020,
  299. Sparc, Vax, Intel 80386.
  300. .PP
  301. All arguments without a suffix or with an unrecognized suffix
  302. are passed to the loaders, as for flags.
  303. .SH PREPROCESSOR
  304. All C source programs are run through the preprocessor
  305. before they are fed to the compiler proper.
  306. On larger machines, the compiler has a built in preprocessor.
  307. Other human readable sources (Modula-2, Pascal, or Basic programs and
  308. machine assembly) are only preprocessed when they start with a \`#\'.
  309. .PP
  310. \fIAck\fP adds a few macro definitions when it calls the
  311. preprocessor.
  312. These macro\'s contain the word- and pointer-size and the sizes
  313. of some basic types used by the Pascal, Basic and/or C compiler.
  314. All sizes are in bytes.
  315. .sp 1
  316. .TS
  317. tab(:);
  318. l l l l.
  319. EM_WSIZE:wordsize:EM_PSIZE:pointer size
  320. EM_SSIZE:size of shorts (C):EM_LSIZE:size of longs (C+Pascal)
  321. EM_FSIZE:size of floats (C):EM_DSIZE:size of doubles (C+Pascal)
  322. .TE
  323. .sp 1
  324. The name of the \fImachine\fP or something like it when
  325. the machine name is numeric is also defined (as 1).
  326. As the ANSI C rules forbid this, in ANSI C, underscores are prepended to
  327. these names.
  328. .PP
  329. The default directories searched for include files differ for each machine.
  330. .SH PROGRAMS
  331. \fIAck\fP uses one or more programs in each phase of the
  332. transformation.
  333. The table below gives the names \fIack\fP uses for these
  334. programs.
  335. Internally \fIack\fP maintains a mapping of these names to pathnames
  336. for load files.
  337. The table specifies which type of files are accepted by each
  338. program as input and the file type produced as output.
  339. .sp 1
  340. .in +2
  341. .TS
  342. tab(:);
  343. l l l l.
  344. input:name:output:description
  345. \&.f:f77:.c:Fortran-to-C front end
  346. \&.c:cem:.k:C front end [4,5,6]
  347. \&.p:pc:.k:Pascal front end [2,3,6]
  348. \&.b:abc:.k:Basic front end [6,8]
  349. \&.ocm:ocm:.k:Occam front end [9]
  350. \&.mod:m2:.k:Modula-2 front end [11]
  351. \&.e:encode:.k:Compactify EM assembly language [1]
  352. \&.k:opt:.m:EM peephole optimizer
  353. \&.k .m:decode:.e:Produce human readable EM assembly
  354. \&.k .m:emass:e.out:Linker producing EM machine code [1]
  355. \&.m:ego:.gk:EM global optimizer [10]
  356. \&.gk:opt2:.g:Second EM peephole optimizer
  357. \&.m .g:be:.s:backend
  358. \&.s:asopt:.so:target optimizer
  359. \&.s .so:asld:.out:Assembler/linker, Ack object format
  360. \&.s .so:as:.o:Assembler, relocatable object
  361. \&.o:ld:a.out:Linker, machine a.out format
  362. \&.o:led:.out:Linker, Ack object format
  363. \&.o:cv:a.out:Conversion from Ack object to machine object
  364. .TE
  365. .in -2
  366. .SH "ENVIRONMENT VARIABLES"
  367. .IP ACKDIR
  368. If set, this environment variable overrides ack's idea of its home
  369. directory.
  370. .IP ACKM
  371. If set, this environment variable overrides ack's idea of the default
  372. machine it compiles for.
  373. .IP ACKFE
  374. If set, this environment variable tells ack where to get the front-end
  375. description file.
  376. .SH "SEE ALSO"
  377. .PD 0
  378. em_opt(6), em_ass(6), em_cg(6), ack.out(5)
  379. .IP [1]
  380. A.S. Tanenbaum, Hans van Staveren, Ed Keizer and Johan
  381. Stevenson, \fIDescription of a machine architecture for use with
  382. block structured languages\fP, Informatica rapport IR-81.
  383. .IP [2]
  384. K. Jensen and N. Wirth,
  385. \fIPASCAL, User manual and report\fP Springer Verlag.
  386. .IP [3]
  387. The ISO Pascal standard proposal ISO/TC97/SC5-N462.
  388. .IP [4]
  389. B.W. Kernighan and D.M. Ritchie, \fIThe C Programming
  390. language\fP, Prentice-Hall, 1978
  391. .IP [5]
  392. D.M. Ritchie, \fI C Reference Manual\fP
  393. .IP [6]
  394. Amsterdam Compiler Kit, reference manuals and UNIX manual pages.
  395. .IP [7]
  396. E.G. Keizer, Ack description file reference manual.
  397. .IP [8]
  398. M.L. Kersten a.o., \fIThe ABC compiler\fP.
  399. .IP [9]
  400. Kees Bot and Edwin Scheffer, \fIAn Occam Compiler\fP, IM-6.
  401. .IP [10]
  402. H.E. Bal, \fIThe design and implementation of the EM Global Optimizer\fP,
  403. Informatica rapport IR-99.
  404. .IP [11]
  405. C.J.H. Jacobs, \fIThe ACK Modula-2 Compiler\fP.
  406. .PD
  407. .SH DIAGNOSTICS
  408. .PD
  409. The diagnostics are intended to be self\-explanatory.
  410. .SH BUGS
  411. Not all warning messages are superseded by \fB\-w\fP.
  412. .br
  413. Argument assembly files are not preprocessed when fed into the
  414. universal assembler/loader.
  415. .SH AUTHOR
  416. Ed Keizer, Vrije Universiteit, Amsterdam