4 COMPILER USE

This chapter contains the following sections:

Control Program
Detailed Description of the Control Program Options
Environment Variables
Compiler
Detailed Description of the Compiler Options
Include Files
Pragmas
Compiler Limits

4.1 Control Program

The control program ccxa facilitates the invocation of the various components of the XA tool chain, from a single command line. The control program accepts source files and options on the command line in random order.

The invocation syntax of the control program is:

Options are preceded by a '-' (minus sign). The input file can have one of the extensions explained below.

When you use a UNIX shell (Bourne shell, C-shell), arguments containing special characters (such as '( )' and '?') must be enclosed with "" or escaped. The -? option (in the C-shell) becomes: "-?" or -\?.

The control program recognizes the following argument types:

Normally, a control program tries to compile and assemble all source files to object files, followed by a link and locate phase which produces an absolute output file. There are however, options to suppress the assembler, linker or locator stage. The control program produces unique filenames for intermediate steps in the compilation process, which are removed afterwards. If the compiler and assembler are called subsequently, the control program prevents preprocessing of the compiler generated assembly file. Normally, assembly input files are preprocessed first.

The following options are interpreted by the control program:

Option Description
-? or none Display invocation syntax
-Ccpu Use special function register definitions for cpu
-Mc Compact memory model
-Mh Huge memory model
-Ml Large memory model
-Mm Medium memory model
-Mt Tiny memory model
-Ms Small memory model
-V Display version header only
-Waarg Pass argument directly to the assembler
-Wcarg Pass argument directly to the C compiler
-Wlkarg Pass argument directly to the linker
-Wlcarg Pass argument directly to the locator
-Wmarg Pass argument directly to the macro preprocessor
-al Create absolute list file
-c Do not link: stop at .obj
-cl Do not locate: stop at .out
-cs Do not assemble: compile C files to .src and stop
-f file Read arguments from file ("-" denotes standard input)
-fptrap Use floating point library with trap handling
-g[f|l|n]... Enable symbolic debug information (unless -gn is used)
-ieee Set locator output file format to IEEE-695 (default)
-ihex Set locator output file format to Intel Hex
-nolib Do not link with the standard libraries
-o file Specify the output file
-srec Set locator output file format to Motorola S-records
-tiof Set locator output file format to TIOF-695
-tmp Keep intermediate files
-v Show command invocations
-v0 Show command invocations, but do not start them

Table 4-1: Control program options

4.1.1 Detailed Description of the Control Program Options

-? Display a short explanation of options at stdout.

-Ccpu Use special function register definitions for cpu.

-M{t|s|c|m|l|h}
Specify the memory model to be used:

-V The copyright header containing the version number is displayed, after which the control program terminates.

-Wa arg
-Wcarg
-Wcparg
-Wlkarg
-Wlcarg
-Wmarg

-Wplarg With these options you can pass a command line argument directly to the macro preprocessor (-Wm), assembler (-Wa), C compiler (-Wc), C++ compiler (-Wcp), C++ pre-linker (-Wpl), linker (-Wlk) or locator (-Wlc). These options may be used to pass some options that are not recognized by the control program, to the appropriate program. The argument may be either directly appended to the option, or follow the option as a separate argument of the control program.

-al Generate an absolute list file for each module in the application.

-c++ Specify that files with the extension .c are considered to be C++ files instead of C files. So, the C++ compiler is called prior to the C compiler. This option also forces the linker to link C++ libraries.

-c
-cc
-cl

-cs Normally, the control program invokes all stages to build an absolute file from the given input files. With these options it is possible to skip the C compiler, assembler, linker or locator stage. With the -cc option the control program stops after compilation of the C++ files and retains the resulting .c files. With the -cs option the control program stops after the compilation of the C source files (.c) and after preprocessing the assembly source files (.asm), and retains the resulting .src files. With the -c option the control program stops after the assembler, with as output one or more object files (.obj). With the -cl option the control program stops after the link stage, with as output a linker object file (.out).

-f file Read command line arguments from file. The filename "-" may be used to denote standard input. To get around the limits on the size of the command line, it is possible to use command files. These command files contain the options that could not be part of the real command line. Command files can also be generated on the fly, for example by the make utility.

1. It is possible to have multiple arguments on the same line in the command file.

2. To include whitespace in the argument, surround the argument with either single or double quotes.

3. If single or double quotes are to be used inside a quoted argument, we have to go by the following rules:

a. If the embedded quotes are only single or double quotes, use the opposite quote around the argument. Thus, if a argument should contain a double quote, surround the argument with single quotes.

b. If both types of quotes are used, we have to split the argument in such a way that each embedded quote is surrounded by the opposite type of quote.

Example:

or

or

4. Some operating systems impose limits on the length of lines within a text file. To circumvent this limitation it is possible to use continuation lines. These lines end with a backslash and newline. In a quoted argument, continuation lines will be appended without stripping any whitespace on the next line. For non-quoted arguments, all whitespace on the next line will be stripped.

Example:

5. It is possible to nest command line files up to 25 levels.

-fptrap Use floating point library with trap handling (libfptt.a, libfpst.a, libfpmt.a or libfplt.a). Without this option a floating point library is selected which uses no trapping.

-g[f|l|n]... Enable symbolic debug information (unless -gn used). With -gn you disable all debug, including type checking. With -gl you disable lifetime information for all types. If you use -gf, high level language type information is also emitted for types which are not referenced by variables. Therefore, this sub-option is not recommended.

-ieee
-ihex
-srec

-tiof With these options you can specify the locator output format of the absolute file. The output file can be an IEEE-695 file (.abs), Intel Hex file (.hex), Motorola S-record file (.sre) or TIOF-695 file (.abs). The default output is IEEE-695 (.abs).

-nolib With this option the control program does not supply the standard libraries to the linker. Normally the control program supplies the default C and run time libraries to the linker. Which libraries are needed is derived from the compiler options.

-o file Normally, this option is passed to the locator to specify the output file name. When you use the -cl option to suppress the locating phase, the -o option is passed to the linker. When you use the -c option to suppress the linking phase, the -o option is passed to the assembler, provided that only one source file is specified. When you use the -cs option to suppress the assembly phase, the -o option is passed to the compiler. The argument may be either directly appended to the option, or follow the option as a separate argument of the control program.

-tmp With this option the control program creates intermediate files in the current directory. They are not removed automatically. Normally, the control program generates temporary files for intermediate translation results, such as compiler generated assembly files, object files and the linker output file. If the next phase in the translation process completes successfully, these intermediate files will be removed.

-v When you use the -v option, the invocations of the individual programs are displayed on standard output, preceded by a '+' character.

-v0 This option has the same effect as the -v option, with the exception that only the invocations are displayed, but the programs are not started.

-wc++ Enable C and assembler warnings for C++ files. The assembler and C compiler may generate warnings on C output of the C++ compiler. By default these warnings are suppressed.

4.1.2 Environment Variables

The control program uses the following environment variables:

TMPDIR This variable may be used to specify a directory, which the control program should use to create temporary files. When this environment variable is not set, temporary files are created in the directory "/tmp" on UNIX systems, and in the current directory on other operating systems.

CCXAOPT This environment variable may be used to pass extra options and/or arguments to each invocation of the control program ccxa. The control program processes the arguments from this variable before the command line arguments.

CCXABIN When this variable is set, the control program prepends the directory specified by this variable to the names of the tools invoked.

4.2 Compiler

The invocation syntax of the C compiler is:

When you use a UNIX shell (Bourne shell, C-shell), arguments containing special characters (such as '( )' and '?') must be enclosed with "" or escaped. The -? option (in the C-shell) becomes: "-?" or -\?.

The C compiler accepts C source file names and command line options in random order. Source files are processed in the same order as they appear on the command line (left-to-right). Options are indicated by a leading '-' character. Each C source file is compiled separately and the compiler generates an output file with suffix .src per C source module, containing assembly source code.

The priority of the options is left-to-right: when two options conflict, the first (most left) one takes effect. The -D and -U options are not considered conflicting options, so they are processed left-to-right for each source file. You can overrule the default output file name with the -o option. The compiler uses each -o option only once, so it is possible to specify multiple -o options for multiple source files.

When you invoke cxa without any argument, the invocation syntax is displayed (same as -? option).

A summary of the options is given below. The next section describes the options in more detail.

Option Description
-? Display invocation syntax
-A[flag...] Control language extensions
-Ccpu Use special function register definitions for cpu
-Dmacro[=def] Define preprocessor macro
-E[m|l] Preprocess only or emit dependencies or enable multi-line macros
-F[c] Control floating point
-Hfile Include file before starting compilation
-Idirectory Look in directory for include files
-M{t|s|m|c|l|h} Select memory model: tiny, small, medium, compact, large or huge
-Oflag... Control optimization
-Rmem=name Change section name
-Sflag String and const allocation
-Tflag Control storage allocation
-Umacro Remove preprocessor macro
-V Display version header only
-e Remove output file if compiler errors occur
-err Send diagnostics to error list file (.err)
-f file Read options from file
-g[f|l|n]... Enable symbolic debug information (unless -gn is used)
-ivo=value Specify base address for interrupt vectors
-m{s|u|m} Select application CPU mode: system mode only, user mode only, mixed mode
-n Send output to standard output
-o file Specify name of output file
-s Merge C source code with assembly output
-safern,n,... Enable individual safer C checks
-t Display lines/min
-u Treat all 'char' variables as unsigned
-v Do not generate interrupt vectors
-w[num] Suppress one or all warning messages
-wstrict Suppress warning messages 196 and 303

Table 4-2: Compiler options (alphabetical)

Description Options
Include options
Read options from file -f file
Include file before starting compilation -Hfile
Look in directory for include files -Idirectory
Preprocess options
Preprocess only or emit dependencies or enable multi-line macros -E[m|l]
Define preprocessor macro -Dmacro[=def]
Remove preprocessor macro -Umacro
Allocation control options
Change section name -Rmem=name
String and const allocation -Sflag
Control storage allocation -Tflag
Code generation options
Use special function register definitions for cpu -Ccpu
Select memory model: tiny, small, medium, compact, large or huge -M{t|s|m|c|l|h}
Select application CPU mode: system mode only, user mode only, mixed mode -m{s|u|m}
Control optimization -Oflag...
Specify base address for interrupt vectors -ivo=value
Do not generate interrupt vectors -v
Language control options
Enable/disable specific language extensions -A[flag...]
Treat 'double' as 'float' -F
Enable 'float' constants -Fc
Treat all 'char' variables as unsigned -u
Output file options
Remove output file if compiler errors occur -e
Send output to standard output -n
Specify name of output file -o file
Merge C source code with assembly output -s
Diagnostic options
Display invocation syntax -?
Display version header only -V
Send diagnostics to error list file (.err) -err
Enable symbolic debug information (unless -gn is used) -g[f|l|n]...
Enable individual safer C checks -safern,n,...
Display lines/min -t
Suppress one or all warning messages -w[num]
Suppress warning messages 196 and 303 -wstrict

Table 4-3: Compiler options (functional)

4.2.1 Detailed Description of the Compiler Options

Option letters are listed below. Each option (except -o; see description of the -o option ) is applied to every source file. If the same option is used more than once, the first (most left) occurrence is used. The placement of command line options is of no importance except for the -I and -o options. For the -o option, the filename may not start immediately after the option. There must be a tab or space in between. All other option arguments must start immediately after the option. Source files are processed in the same order as they appear on the command line (left-to-right).

Some options have an equivalent pragma.

With options that can be set from within EDE, you will find a mouse icon that describes the corresponding action.

-?

Option:

-?

Description:

Display an explanation of options at stdout.

Example:

cxa  -?

-A

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Set or disable the Language Extensions in the Language tab.

-A[flags]

Arguments:

Optionally one or more language extension flags.

Default:

-A1

Description:

Control language extensions. -A without any flags, specifies strict ANSI mode; all language extensions are disabled. This is equivalent to -ACDKLPSTUVX and -A0.

Flags which are controlled by a letter, can be switched on with the lower case letter and switched off with the uppercase letter. Note that the usage of these options might have effect on code density and code execution performance. The following flags are allowed:

c Default. Perform character arithmetic. cxa generates code using 8-bit character arithmetic as long as the result of the expression is exactly the same as if it was evaluated using integer arithmetic. See also section Character Arithmetic.

C Disable character arithmetic.

k Default. Allow keyword language extensions such as _far, _huge and _bit.

K Keyword extensions are not allowed.

l Default. 500 significant characters are allowed in an identifier instead of the minimum ANSI-C translation limit of 31 significant characters. Note: more significant characters are truncated without any notice.

L Conform to the minimum ANSI-C translation limit of 31 significant characters. This makes it possible to translate your code with any ANSI-C conforming C-compiler. Note: more significant characters are truncated without any notice.

p Default. Allow C++ style comments in C source code. For example:

P Do not allow C++ style comments in C source code, to conform to strict ANSI-C.

s Default. __STDC__ is defined as '0'. The decimal constant '0', intended to indicate a non-conforming implementation. When one of the language extensions are enabled __STDC__ should be defined as '0'.

S __STDC__ is defined as '1'. In strict ANSI-C mode (-A) __STDC__ is defined as '1'.

t Default. Do not promote old-style function parameters when prototype checking.

T Perform default argument promotions on old-style function parameters for a strict ANSI-C implementation. char type arguments are promoted to int type and float type arguments are then promoted to double type.

v Default. Allow type cast of an lvalue object with incomplete type void and lvalue cast which does not change the type and memory of an lvalue object.

Example:

V A cast may not yield an lvalue, to conform strict ANSI-C mode.

x Default. Do not check for assignments of a constant string to a non-constant string pointer. With this option the following example produces no warning:

X Conform to ANSI-C by checking for assignments of a constant string to a non-constant string pointer. The example above produces warning W130: "operands of '=' are pointers to different types".

0 - same as -ACDKLPSTUVX (disable all, strict ANSI-C)

1 - same as -Acdklpstuvx (default, enable all)

Example:

To disable character arithmetic and C++ comments enter:

-C

Option:

Choose a cpu from the EDE | Processor Options... | Processor menu item.

-Ccpu

Arguments:

The cpu name which identifies your XA derivative.

Description:

Use special function register definitions for cpu. The filename looked for is "regcpu.sfr" in the same way include files whose names are enclosed in "" are searched.

Example:

To specify to the compiler to look for a file named regxa.sfr, and to use this file as a special function register definition file, enter:

Section Special Function Registers in the previous chapters.

-D

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Define a macro (syntax: macro[=def]) in the Define user macros field in the Preprocessing tab. You can define more macros by separating them with commas.

-Dmacro[=def]

Arguments:

The macro you want to define and optionally its definition.

Description:

Define macro to the preprocessor, as in #define. If def is not given ('=' is absent), '1' is assumed. Any number of symbols can be defined. The definition can be tested by the preprocessor with #if, #ifdef and #ifndef, for conditional compilations. If the command line is getting longer than the limit of the operating system used, the -f option is needed.

Example:

The following command defines the symbol NORAM as 1 and defines the symbol PI as 3.1416.

-U

-E / -Em / -El

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable the Preprocess only and capture output check box in the Preprocessing tab.

-E[m|l]

Description:

Run the preprocessor of the compiler only and send the output to stdout. When you use the -E option, use the -o option to separate the output from the header produced by the compiler.

When you use the -Em option, the compiler generates dependency rules which can be used by a 'make' utility.

When you use the -El option, you can use multi-line macros. A backslash used to continue a macro on the next source line will be expanded as a new line instead of a concatenation of the lines.

Examples:

The following command preprocesses the file test.c and sends the output to the file preout.

The following command preprocesses the file test.c which may contain multi-line macros, and sends the output to the file multi.

The following command generates dependency rules for the file test.c which can be used by mkxa (the XA 'make' utility).

-e

Option:

EDE always removes the output file on errors.

-e

Description:

Remove the output file when an error has occurred. With this option the 'make' utility always does the proper productions.

Example:

cxa -e test.c

-err

Option:

In EDE this option is not so useful. If you would use this option you would not see the error messages in the Build tab.

-err

Description:

Write errors to the file source.err instead of stderr.

Example:

To write errors to the test.err instead of stderr, enter:

-F / -Fc

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable one of the Use single precision floating point only or Treat floating point constants as 'float' check boxes in the Misc tab.

-F[c]

Description:

-F forces using single precision floating point only, even when double or long double is used. In fact double and long double are treated as float and default argument promotion from float to double is suppressed. When you use this option, you must use the single precision version of the C library.

See the chapter Libraries for the naming conventions of the standard libraries.

-Fc enables the use of 'float' constants. In ANSI C floating point constants are treated having type double, unless the constant has the suffix 'f'. So '3.0' is a double precision constant, while '3.0f' is a single precision constant. This option tells the compiler to treat all floating point constants as single precision float types (unless they have an explicit 'l' suffix).

Example:

To force double to be treated as float, enter:

-f

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Add the option to the Additional options field in the Misc tab.

-f file

Arguments:

A filename for command line processing. The filename "-" may be used to denote standard input.

Description:

Use file for command line processing. To get around the limits on the size of the command line, it is possible to use command files. These command files contain the options that could not be part of the real command line. Command files can also be generated on the fly, for example by the make utility.

More than one -f option is allowed.

Some simple rules apply to the format of the command file:

1. It is possible to have multiple arguments on the same line in the command file.

2. To include whitespace in the argument, surround the argument with either single or double quotes.

3. If single or double quotes are to be used inside a quoted argument, we have to go by the following rules:

a. If the embedded quotes are only single or double quotes, use the opposite quote around the argument. Thus, if a argument should contain a double quote, surround the argument with single quotes.

b. If both types of quotes are used, we have to split the argument in such a way that each embedded quote is surrounded by the opposite type of quote.

Example:

     "This has a single quote ' embedded"

or

     'This has a double quote " embedded'

or

     'This has a double quote " and \
     a single quote '"' embedded"

4. Some operating systems impose limits on the length of lines within a text file. To circumvent this limitation it is possible to use continuation lines. These lines end with a backslash and newline. In a quoted argument, continuation lines will be appended without stripping any whitespace on the next line. For non-quoted arguments, all whitespace on the next line will be stripped.

Example:

     "This is a continuation \
     line"
          -> "This is a continuation line"

     control(file1(mode,type),\
          file2(type))
          -> 
     control(file1(mode,type),file2(type))

5. It is possible to nest command line files up to 25 levels.

Example:

Suppose the file mycmds contains the following line:

The command line can now be:

-g

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable the Generate symbolic debug information check box in the Debug tab. Optionally enable the Include debug information for non referenced types and/or Disable lifetime info for all types check box.

-g[f|l|n]...

Description:

Add directives to the output files, incorporating symbolic information to facilitate high level debugging.

With -gn you disable all debug, including type checking.

With -gl you disable lifetime information for all types.

If you use -gf, high level language type information is also emitted for types which are not referenced by variables. Therefore, this sub-option is not recommended.

When the compiler is set to a high optimization level the debug comfort may decrease.

Examples:

To add symbolic debug information to the output files, enter:

To add symbolic debug information to the output files but disable lifetime information for all types, enter:

To disable all symbolic debug information including type checking, enter:

-H

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enter a filename in the First #include this file field in the Preprocessing tab.

-Hfile

Arguments:

The name of an include file.

Description:

Include file before compiling the C source. This is the same as specifying #include "file" at the first line of your C source.

Example:

cxa -Hstdio.h test.c

-I

-I

Option:

Select the EDE | Directories... menu item. Add one or more directory paths to the Include Files Path field.

-Idirectory

Arguments:

The name of the directory to search for include file(s).

Description:

Change the algorithm for searching #include files whose names do not have an absolute pathname to look in directory. Thus, #include files whose names are enclosed in "" are searched for first in the directory of the file containing the #include line, then in directories named in -I options in left-to-right order. If the include file is still not found, the compiler searches in a directory specified with the environment variable CXAINC. CXAINC may contain more than one directory. Finally, the directory ../include relative to the directory where the compiler binary is located is searched. This is the standard include directory supplied with the compiler package.

For #include files whose names are in <>, the directory of the file containing the #include line is not searched. However, the directories named in -I options (and the one in CXAINC and the relative path) are still searched.

Example:

cxa -I/proj/include test.c

Section Include Files.

-ivo

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enter a vector offset value in the Interrupt vector offset (0-0xFFFFFF) field in the Allocation tab.

-ivo=value

Arguments:

A 16-bit base address for the interrupt vector table.

Description:

This option specifies a 16-bit base address for the interrupt vector table. This option is useful when running the application on an evaluation board using the RISM ROM monitor. RISM claims non-used interrupts to user RAM.

Example:

To specify 0x4000 as the base address of the interrupt vector table, enter:

-v

-M

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Choose a Memory Model in the Memory Model tab.

-Mmodel

Arguments:

The memory model to be used, where model is one of:

Default:

-Mt

Description:

Select memory model to be used.

Example:

cxa -Ms test.c

Section Memory Models.

-m

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Choose an Application CPU mode in the Memory Model tab.

-mcpumode

Arguments:

The application CPU mode to be used, where cpumode is one of:

Default:

-ms

Description:

For optimal code generation it is required to define if an application runs in System mode or User mode. Code generation for Mode independent supports both execution modes, but increases code size. This increase is caused by insertions of a run-time check on the mode the application is running in at that moment. This option only affects the code generation for 24-bit access in the Large Memory model. The Large Memory model libraries are compiled for Mode independent.

When user mode is selected, interrupt functions are not allowed in any of the memory models.

Example:

To specify user mode, enter:

-n

Option:

-n

Description:

Do not create output files; instead, the output is sent to stdout.

Example:

cxa -n test.c

-O

Option:

Select the EDE | C Compiler Options | Project Options... menu item. You can control optimizations in the Optimization and Adv. Optim. tabs.

-Oflags

Pragma:

optimize flags

Arguments:

One or more optimization flags.

Default:

-O1

Description:

Control optimization. If you do not use this option, the default optimization of cxa is -O1, which is an optimization level to let cxa generate the smallest code.

Flags which are controlled by a letter, can be switched on with the lowercase letter and switched off with the uppercase letter. These options are described together.

All optimization flags can also be given in the source file after a #pragma optimize. However, depending on the optimization some optimize pragmas affect the entire module (module level), whereas other optimize pragmas can be used on a function scope only (function level) or on each source line (flow level). 'On function level' means that if a pragma optimize is found within a function, it is interpreted as if it was found just before the function. The optimization level of each optimize pragma is described for each -O option.

An overview of the flags is given below.

a - relax alias checking (needs -Oc) (function)
c - common subexpression elimination (function)
d - data flow, constant/copy propagation (function)
e - expression propagation (needs -Oc) (function)
f - code flow, order rearranging (function)
h - peephole optimization (flow)
i - move invariant code outside loop (needs -Oc) (function)
j - tail branch peephole optimizations (function)
l - fast loops (increases code size) (function)
s - small code size (flow)
t - force jump table for switch statement (flow)
u - loop unrolling (function)
v - subscript strength reduction (function)
w - smart switch statement, table or chain (flow)

0 - same as -OABCDEFHIJLSTUVW (no optim)
1 - same as -OaBcdefhijLstUvw (default, size))
2 - same as -OaBcdefhijlSTUvw (speed)

Example:

cxa -OACdEfhILUvw test.c

Pragma optimize in section Pragmas.

-Onumber

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Choose an Optimization Level in the Optimization tab.

-Onumber

Arguments:

A number in the range 0 - 2.

Default:

-O1

Description:

Control optimization. You can specify a single number in the range 0 - 2, to enable or disable optimization. The options are a combination of the other optimization flags:

-O0 - same as -OABCDEFHIJLSTUVW
Switchable optimizations switched off

-O1 - same as -OaBcdefhijLstUvw
Default. Set optimization to let cxa generate the smallest code.

-O2 - same as -OaBcdefhijlSTUvw
Set optimization flags to let cxa generate the fastest code.

The flags 0 to 2 cannot be concatenated with other flags. For example, -Oa2c is not allowd, -OacF is allowed.

Example:

To optimize for code size, enter:

-Oa / -OA

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Relax alias checking check box.

-Oa / -OA

Pragma:

optimize a / optimize A (on function level)

Default:

-OA

Description:

By default the compiler assumes that each pointer may point to any object created in the program, so when any pointer is dereferenced, all register contents are assumed to be invalid afterwards.

With -Oa you relax alias checking. If you specify this option, cxa will not erase remembered register contents of user variables if a write operation is done via an indirect (calculated) address. You must be sure this is not done in your C code (check pointers!) before turning on this option.

The option -Oc must be on to use this option.

With -OA you specify strict alias checking. If you specify this option, the compiler erases all register contents of user variables when a write operation is done via an indirect (calculated) address.

Example 1:

int i;

void
func( )
{
   char     * p;
   char     c;
   char     d;

   if( i )
      p = &c;
   else
      p = &d;

   c = 2;
   d = 3;

   *p = 4;  /* may write to 'c' or 'd'          */
            /* --> aliasing object 'c' or 'd'   */

   i = c;   /* '*p' might have changed the value of 'c',    */
            /* so 'c' may not be used from register         */
            /* contents, but MUST be read from memory       */
            /* --> alias checking MUST be ON in this case   */
}

Example 2:

int i;

void
func( char *p )
{
   char     c;
   char     d;

   c = 2;
   d = 3;

   *p = 4;  /* cannot write to 'c' or 'd', but to some other 
               object */

   i = c;   /* '*p' cannot have changed the value of 'c',   */
            /* so 'c' may be used from register contents    */
            /* --> alias checking may be OFF in this case   */
}

Example 3:

int array[2];

main()
{
   array[0] = 1;
   array[1] = -1;

   array[0] = array[0] + array[1];
            /* an interrupt might have changed the value    */
            /* of 'array', so 'array' may not be used       */
            /* from register contents, but MUST be read     */
            /* from memory                                  */
            /* --> alias checking MUST be ON in this case   */
}

-Oc
Pragma optimize in section Pragmas.

-Oc / -OC

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Common subexpression elimination (CSE) check box.

-Oc / -OC

Pragma:

optimize c / optimize C (on function level)

Default:

-Oc

Description:

With -Oc you enable CSE (common subexpression elimination). With this option specified, the compiler tries to detect common subexpressions within the C code. The common expressions are evaluated only once, and their result is temporarily held in registers.

The -Oc option must be on to enable the relax alias checking (-Oa), expression propagation (-Oe) and moving invariant code outside a loop (-Oi).

With -OC you disable CSE (common subexpression elimination). With this option specified, the compiler will not try to search for common expressions. Also relax alias checking, expression propagation and moving invariant code outside a loop will be disabled.

Example:

/*
 * Compile with -OC -O0,
 * Compile with -Oc -O0, common subexpressions are found
 *    and temporarily saved.
 */

char x, y, a, b, c, d;

void
main( void )
{
     x = (a * b) - (c * d);

     y = (a * b) + (c * d);/*(a*b) and (c*d) are common */
}

Pragma optimize in section Pragmas.

-Od / -OD

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Constant and copy propagation (data flow) check box.

-Od / -OD

Pragma:

optimize d / optimize D (on function level)

Default:

-Od

Description:

With -Od you enable constant and copy propagation. With this option, the compiler tries to find assignments of constant values to a variable, a subsequent assignment of the variable to another variable can be replaced by the constant value.

With -OD you disable constant and copy propagation.

Example:

/*
 * Compile with -OD -O0, 'i' is actually assigned to 'j'
 * Compile with -Od -O0, 15 is assigned to 'j', 'i' was
 * propagated
 */

int i;
int j;

void
main( void )
{
      i = 10;
      j = i + 5;
}

Pragma optimize in section Pragmas.

-Oe / -OE

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Expression propagation check box in the Adv. Optim. tab.

-Oe / -OE

Pragma:

optimize e / optimize E (on function level)

Default:

-Oe

Description:

With -Oe you enable expression propagation. With this option, the compiler tries to find assignments of expressions to a variable, a subsequent assignment of the variable to another variable can be replaced by the expression itself. Note that the option -Oc must be on to use this option.

With -OE you disable expression propagation.

Example:

/*
 * Compile with -OE -Oc -O0, normal cse is done
 * Compile with -Oe -Oc -O0, 'i+j' is propagated.
 */

unsigned i, j;

int
main( void )
{
      static int a;
      a = i + j;
      return (a);
}

-Oc
Pragma optimize in section Pragmas.

-Of / -OF

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Code order rearranging in flow optimization check box in the Adv. Optim. tab.

-Of / -OF

Pragma:

optimize f / optimize F (on function level)

Default:

-Of

Description:

With -Of you enable control flow optimizations and code order rearranging on the intermediate code representation, such as jump chaining and conditional jump reversal.

With -OF you disable control flow optimizations.

Examples:

The following example shows a control optimization:

The following example shows a conditional jump reversal:

Pragma optimize in section Pragmas.

-Oh / -OH

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Peephole optimizer (remove redundant code) check box.

-Oh / -OH

Pragma:

optimize h / optimize H (on flow level)

Default:

-Oh

Description:

With -Oh you enable peephole optimization. Remove redundant code. The peephole optimizer searches for redundent instructions or for instruction sequences which can be combined to minimize the number of instructions.

With -OH you disable peephole optimization.

Pragma optimize in section Pragmas.

-Oi / -OI

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Move invariant code outside loop check box.

-Oi / -OI

Pragma:

optimize i / optimize I (on function level)

Default:

-Oi

Description:

With -Oi you move invariant code outside a loop. With -OI you disable moving invariant code outside a loop.

The option -Oc must be on to use the -Oi option.

Example:

/*
 * Compile with -OI -Oc -O0, normal cse is done
 * Compile with -Oi -Oc -O0, invariant code is found in
 *    the loop, code is moved outside the loop.
 */
void
main( void )
{
      char x, y, a, b;
      int i;

      for( i=0; i<20; i++ )
      {
            x = a + b;
            y = a + b;
      }
}

-Oc
Pragma optimize in section Pragmas.

-Oj / -OJ

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Tail branch peephole optimizations check box.

-Oj / -OJ

Pragma:

optimize j / optimize J (on function level)

Default:

-Oj

Description:

With -Oj you can enable the peephole optimizations for tail branching. (e.g. instruction CALL RET replacement with JMP/BR). With -OJ you can disable the peephole optimizations for tail branching.

The option -Oh must be on to use the -Oj option.

Example:

/*
 * Compile with -Oh -Oj
 */
void
main( void )
{
      end();
}

-Oh
Pragma optimize in section Pragmas.

-Ol / -OL

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Fast loops (increases code size) check box.

-Ol / -OL

Pragma:

optimize l / optimize L (on function level)

Default:

-OL

Description:

With -Ol you enable fast loops. Duplicate the loop condition. Evaluate the loop condition one time outside the loop, just before entering the loop, and at the bottom of the loop. This saves one unconditional jump and gives less code inside a loop.

With -OL you disable fast loops.

Example:

/*
 * Compile with -OL -O0
 * Compile with -Ol -O0, compiler duplicates the loop
 * condition, the unconditional jump is removed.
 */
int i;

void
main( void )
{
      for( ; i<10; i++ )
      {
            do_something();
      }
}

Pragma optimize in section Pragmas.

-Os / -OS

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Produce small code (favor code size above execution speed) check box.

-Os / -OS

Pragma:

optimize s / optimize S (on flow level)

Default:

-Os

Description:

With -Os you tell the compiler to generate smaller code. Whenever possible less instructions are used.

This may result in more instruction cycles.

With -OS you disable the smaller code optimization.

Pragma optimize in section Pragmas.

-Ot / -OT

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Force jump table for switch statements check box in the Adv. Optim. tab.

-Ot / -OT

Pragma:

optimize t / optimize T (on flow level)

Default:

-OT

Description:

With -Ot you force the compiler to generate jump tables for switch statements.

With -OT it depends on the -Ow/-OW option which switch method is used. With -OT and -OW the compiler generates a jump chain for switch statements. With -OT and -Ow the compiler chooses the best switch method possible, jump chain or jump table. So, with -OT a jump table can still be generated.

Example:

/*
 * Compile with -OT -OW, generate jump chain.
 * Compile with -Ot -OW, generate jump table.
 */
int i;

void
main( void )
{
      switch (i)
      {
            case 1:      i = 0;
            case 2:      i = 1;
            case 3:      i = 2;
            default:     i = 3;
      }
}

Section Switch Statement.
Pragma optimize in section Pragmas.

-Ou / -OU

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Loop unrolling check box in the Adv. Optim. tab.

-Ou / -OU

Pragma:

optimize u / optimize U (on function level)

Default:

-OU

Description:

With -Ou you enable loop unrolling. With this option specified, the compiler tries to eliminate short loops by duplicating a loop body 2, 4 or 8 times. This reduces the number of branches and creates a longer linear code part.

With -OU you disable loop unrolling.

Example:

/*
 * Compile with -OU, normal loop handling
 * Compile with -Ou, loop is eliminated, 
 * body is duplicated
 */
int i, j;

void
main( void )
{
      for( i=0; i<2; i++ )      /* short loop */
      {
            j = 2 * i;
      }
}

Pragma optimize in section Pragmas.

-Ov / -OV

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Subscript strength reduction check box in the Adv. Optim. tab.

-Ov / -OV

Pragma:

optimize v / optimize V (on function level)

Default:

-Ov

Description:

With -Ov you enable subscript strength reduction. With this option specified, the compiler tries to reduce expressions involving an index variable in strength.

With -OV you disable subscript strength reduction.

Example:

/*
 * Compile with -OV -O0, disable subscript strength reduction
 * Compile with -Ov -O0, begin and end address of 'a' are
 * determined before the loop and temporarily put in registers
 * instead of determining the address each time inside the loop
 */
int i;
int a[4];

void
main( void )
{
      for( i=0; i<4; i++ )
      {
            a[i] = i;
      }
}

Pragma optimize in section Pragmas.

-Ow / -OW

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select the Advanced optimization optimization level in the Optimization tab. Enable or disable the Smart switch code selection (table or chain) check box in the Adv. Optim. tab.

-Ow / -OW

Pragma:

optimize w / optimize W (on flow level)

Default:

-Ow

Description:

With -Ow the compiler chooses the best switch method possible, jump chain or jump table, unless -Ot is used. -Ot forces the generation of a jump table.

With -OW the compiler generates a jump chain for switch statements, unless -Ot is used. -Ot forces the generation of a jump table.

Example:

/*
 * Compile with -OW -OT, always generate jump chain.
 * Compile with -Ow -OT, choose best switch method, in this
 * case this is also a jump chain.
 */
int i;

void
main( void )
{
      switch (i)
      {
            case 1:     i = 0;
            case 2:     i = 1;
            case 3:     i = 2;
            default:    i = 3;
      }
}

Section Switch Statement.
Pragma optimize in section Pragmas.

-o

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Add the option to the Additional options field in the Misc tab.

-o file

Arguments:

An output filename. The filename may not start immediately after the option. There must be a tab or space in between.

Default:

Module name with .src suffix.

Description:

Use file as output filename, instead of the module name with .src suffix. Special care must be taken when using this option, the first -o option found acts on the first file to compile, the second -o option acts on the second file to compile, etc.

Example:

When specified:

two files will be created, file3.src for the compiled file file1.c and file2.src for the compiled file file2.c.

-R

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Add the option to the Additional options field in the Misc tab.

-Rmem= name

Pragma:

renamesec

Arguments:

A memory space, followed by a section name. mem can be one of:

mem Description
bi _bit
id _idat (51 compatible)
xs _xdat
ir constant (switch tables)
ro constant (_rom)
rc constant (_rom_cs)
ro0 constant (_rom_pc0)
ro1 constant (_rom_pc1)
ba bitaddressable (_bdat)
pr program
pr0 program in group pc0
pr1 program in group pc1
ne _near / _data (51 compatible)
fa _far
fe _far_es
hu _huge
ed _edata (EEPROM data memory, SmartXA system mode)

Table 4-4: Memory spaces

Description:

The compiler defaults to a section naming convention, using the module name and a two letter memory type abbreviation: name_PR for executable code, name_NE for direct RAM etc. In case a module must be loaded at a fixed address or a data section needs a special place in memory, the -R option enables the user to generate a unique section name. In this way the order lcxa allocates these sections can be specified in a locator description file.

You can exclude modules from a rename action by specifying a #pragma defaultsec at the beginning of the source. This pragma overrules the -R option.

Example:

To create a new section name (NEW_NE) for _near sections, enter:

So, in fact you only specify a new module name part of a section name.

Pragma renamesec and defaultsec in section Pragmas.

-S

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select one of the String and const allocation options in the Allocation tab.

-S{o|d|c[r|s|0|1]}

Arguments:

o String and const allocation in ROM and copy to RAM (default)

d String and const allocation in ROM data space only.

c Strings in ROM code space only, const in ROM and copy to RAM
cr - strings in _rom (default)
cs - strings in _rom_cs (compact only)
c0 - strings in _rom_pc0 (medium/compact only)
c1 - strings in _rom_pc1 (medium/compact only)

Default:

-So

Description:

Default string literals and const declared objects are allocated in ROM code space and copied to RAM data space, which allows run-time string modification. Option -So is the default.

With the -Sd option string literals and const declared objects can be allocated in ROM data space only. An (EP)ROM containing this data need to be connected to the data bus. This option is proposed for applications which use an unified bus. String and const data pointers or code pointers need no different code generation. This is the most efficient allocation and code generation concept for string literals and const declared objects on the XA.

With option -Sc or -Scr string literals can also be allocated in ROM code space only. String data and code pointers cannot be mixed, because accessing it needs MOVC generation. String pointers need code space qualification with the _rom keyword. For example, char const _rom *string.

With -Scs string literals are allocated in the default ROM code segment indentified by code segment register CS. String pointers need code space qualification with the _rom_cs keyword. For example, char const _rom_cs *string;. This suboption is only available in the compact memory model.

With -Sc0/-Sc1 string literals are allocated in the default ROM code segment indentified segment of ROM data group PC0/PC1. String pointers need code space qualification with the _rom_pc0 or _rom_pc1 keyword. For example, char const _rom_cs *string;. This suboption is only available in the compact and medium memory model

Example:

cxa -Sd test.c

Section Strings in chapter Language Implementation and section const Qualifier in section Storage Types of chapter Language Implementation.

-s

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable the Merge C source code with assembly output check box in the Output tab.

-s

Pragma:

source

Description:

Merge C source code with generated assembly code in output file.

Example:

cxa -s test.c
; test.c       4 main()
; test.c       5 {
         PUBLIC  _main
TEST_PR  SEGMENT CODE
         RSEG    TEST_PR
_main:

Pragmas source and nosource in section Pragmas.

-safer

Option:

Select EDE | Expert Mode. Select the EDE | Safer C Compiler Options | Project Options... menu item. Enable Safer C in the Safer C tab.

-safern,n,....

Arguments:

The Safer C rules to be checked.

Description:

With this option, the Safer C rules to be checked can be specified. Refer to Appendix B Safer C for a list of supported and unsupported Safer C rules.

Example:

cxa -safer9 test.c

Will generate an error in case 'test.c' contains nested comments.

-T

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Set or disable one or more allocation options in the Allocation tab.

-Tflags

Arguments:

One or more allocation flags.

Default:

-TbCdEP

Description:

Control allocation. Flags that are controlled by a letter, can be switched on with the lover case letter and switched off with the uppercase letter.

An overview of the flags is given below:

b - treat small bitfields as 'char' instead of 'int'
c - no clearing of non-initialized static and public variables
d - define storage for uninitialized constant rom data, instead of implicit
zero initialization
e - treat small enumerates as 'char' instead of 'int'
p - pack char type structures

Default: -TbCdEP

Example:

cxa -Tbcdep

-Tb / -TB

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable or disable the treat bitfields as 'char' instead of 'int' checkbox in the Allocation tab.

-Tb / -TB

Default:

-Tb

Description:

With -Tb you treat small bitfield as 'char' instead of 'int'. Bitfields which can be represented by 8-bits are treated as if they are of type 'char'. This option reduces the amount of data space allocated for bitfield structures. The code size may increase when char type bitfields need to be promoted to 'int' types for expression evaluation. With this option enabled it is also allowed to declare bitfields of type 'char'.

With -TB the option is disabled. All bitfields are treated as 'int' types. In this case it is not allowed to declare bitfields of type 'char'.

Example:

Default behavior -TB:

struct bitfield
{
     int c:8;       /* int type */
     int i:9;       /* always int type */
} b;

With -Tb enabled:

struct bitfield
{
     int c:8;       /* char type */
     int i:9;       /* always int type */
} b;

or:

struct bitfield
{
     char c:8;      /* char type */
     int i:9;       /* always int type */
} b;

-Tc / -TC

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable or disable the clear non-initialized static and public variables checkbox in the Allocation tab.

-Tc / -TC

Default:

-TC

Description:

With -Tc the compiler performs no 'clearing' of non-initialized static and public variables.

With -TC the compiler performs 'clearing' of non-initialized static and public variables.

-Td / -TD

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable or disable the define storage for uninitialized constant rom data checkbox in the Allocation tab.

-Td / -TD

Default:

-Td

Description:

With -Td the compiler defines storage for uninitialized constant rom data, instead of implicit zero initialization. The compiler generates a 'DS 1' for 'const char i[1];'.

With -TD uninitialized constant rom data is implicitly zero. The compiler generates a 'DB 1' for 'const char i[1];'.

-Te / -TE

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable or disable the treat small enumerates as 'char' instead of 'int' checkbox in the Allocation tab.

-Te / -TE

Default:

-TE

Description:

With -Te you treat small enums as 'char' instead of 'int'. Enums which can be represented by 8-bits are treated as if they are of type 'char'.

With -TE the option is disabled. All bitfields are treated as 'int' types.

Example:

Default behavior -TE:

enum values
{
     VAL1,         /* int type */
     VAL2 = 256    /* always an int type */
};

With -Te enabled:

enum values
{
     VAL1,         /* char type */
     VAL2 = 256    /* always an int type */
};

-Tp / -TP

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable or disable the pack 'char' type structures checkbox in the Allocation tab.

-Tp / -TP

Default:

-TP

Pragma:

packchar / endpackchar

Description:

With the -Tp option structures and nested structures that only contain character type members are packed. Character type structures can have odd size and odd alignment. Non character type structures need alignment, because the XA architecture does not support unaligned word access. Packing structures optimizes the data allocation, but may decrease the code speed because byte copies are required for initialization and copying packed character type data structures.

With the -TP option structures and nested structures are always aligned on a word boundary and padded to an even size. Word aligning structures optimizes code speed, because only word copies are required for initialization and copying of structures.

Example:

struct
{
     char c1;
     struct
     {
          char c2;
     } onebyte;
} twobytes;

Without packing (-TP) the size of structure twobytes is equal to 4 bytes and the structure is aligned in memory. With packing enabled (-Tp) the size of structure twobytes is equal to 2 bytes and is not aligned in memory. The twobytes structure can be located either on an odd or an even address.

Pragma optimize in section Pragmas.

-t

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable the Display lines/min check box in the Output tab.

-t

Description:

Display the number of lines processed and the compilation speed in lines per minute.

Example:

cxa -t test.c
processed 25 lines at 7075 lines/min

-U

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Undefine one or more of the predefined symbols _MODEL, _CXA or _SINGLE_FP by disabling the corresponding check box in the Preprocessing tab.

-Uname

Arguments:

The name macro you want to undefine.

Description:

Remove any initial definition of identifier name as in #undef, unless it is a predefined ANSI standard macro. ANSI specifies the following predefined symbols to exist, which cannot be removed:

__FILE__ "current source filename"

__LINE__ current source line number (int type)

__TIME__ "hh:mm:ss"

__DATE__ "Mmm dd yyyy"

__STDC__ level of ANSI standard. This macro is set to 1 when the option to disable language extensions (-A) is effective. Whenever language extensions are excepted, __STDC__ is set to 0 (zero).

When cxa is invoked, also the following predefined symbols exist:

_CXA predefined symbol to identify the compiler. This symbol can be used to flag parts of the source which must be recognized by the cxa compiler only. It expands to the version number of the compiler.

_MODEL identifies for which memory model the module is compiled. It expands to a single character ('t' for tiny, 's' for small, 'm' for medium or 'l' for large) that can be tested by the preprocessor. See section Memory Models for details.

_SINGLE_FP
predefined symbol that is defined if single precision floating point is used (double is treated as float).

_DOUBLE_FP
predefined symbol that is defined if double precision floating point is used.

These symbols can be turned off with the -U option.

Example:

cxa -U_MODEL test.c

-D

-u

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Enable the Treat 'char' variables as unsigned check box in the Language tab.

-u

Description:

Treat 'character' type variables as 'unsigned character' variables. By default char is the same as specifying signed char. With -u char is the same as unsigned char.

Example:

With the following command char is treated as unsigned char:

-V

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Add the option to the Additional options field in the Misc tab.

-V

Description:

Display version information.

Example:

cxa -V
XA C compiler vx.y rz        SN000000-015 (c) year TASKING, Inc.

-v

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Disable the Generate code for interrupt vector check box in the Allocation tab.

-v

Pragma:

novector

Description:

Do not generate code for interrupt vector and reference to interrupt handler in the run-time library.

Example:

cxa -v test.c

Pragmas vector and novector in section Pragmas.

-w

Option:

Select the EDE | C Compiler Options | Project Options... menu item. Select one of the Diagnostics options in the Output tab and optionally fill in specific message numbers to suppress.

-w[num]
-wstrict

Arguments:

Optionally the warning number to suppress.

Description:

-w suppress all warning messages. -wnum only suppresses the given warning. -wstrict suppresses extensive warnings 196 and 303.

Example:

To suppress warning 135, enter:

4.3 Include Files

You may specify include files in two ways: enclosed in <> or enclosed in "". When an #include directive is seen, cxa used the following algorithm trying to open the include file:

1. If the filename is enclosed in "", and it is not an absolute pathname (does not begin with a '\' for PC, or a '/' for UNIX), the include file is searched for in the directory of the file containing the #include line. For example, in:

PC:

UNIX:

cxa first searches in the directory ..\..\source (../../source for UNIX) for include files.

If you compile a source file in the directory where the file is located (cxa test.c), the compiler searches for include files in the current directory.

Note that this first step is not done for include files enclosed in <>.

2. Use the directories specified with the -I options, in a left-to-right order. For example:

Select the EDE | Directories... menu item. Add one or more directory paths to the Include Files Path field.

PC:

UNIX:

3. Check if the environment variable CXAINC exists. If it does exist, use the contents as a directory specifier for include files. You can specify more than one directory in the environment variable CXAINC by using a separator character. Instead of using -I as in the example above, you can specify the same directory using CXAINC:

PC:

UNIX:

      CXAINC=../../include
      export CXAINC
      cxa demo.c
      setenv CXAINC ../../include
      cxa demo.c

4. When an include file is not found with the rules mentioned above, the compiler tries the subdirectory include, one directory higher than the directory containing the cxa binary. For example:

PC:

UNIX:

The compiler determines run-time which directory the binary is executed from to find this include directory.

A directory name specified with the -I option or in CXAINC may or may not be terminated with a directory separator, because cxa inserts this separator, if omitted.

When you specify more than one directory to the environment variable CXAINC, you have to use one of the following separator characters:

PC:

UNIX:

4.4 Pragmas

According to ANSI (3.8.6) a preprocessing directive of the form:

causes the compiler to behave in an implementation-defined manner. The compiler ignores pragmas which are not mentioned in the list below. Pragmas give directions to the code generator of the compiler. Besides the pragmas there are two other possibilities to steer the code generation process: command line options and keywords (e.g., _bit type variables) in the C application itself. The compiler acknowledges these three groups using the following rules:

Command line options can be overruled by keywords and pragmas. Keywords can be overruled by pragmas. Hence, pragmas have the highest priority.

This approach makes it possible to set a default optimization level for a source module, which can be overridden temporarily within the source by a pragma.

The C compiler cxa supports the following pragmas:

asm

Insert the following (non preprocessor lines) as assembly language source code into the output file. The inserted lines are not checked for their syntax. The code buffer of the peephole optimizer is flushed. Thus the compiler will stop optimizations like peephole pattern replacement and resumes these optimizations after the endasm pragma as if it starts at the beginning of a function.

For advanced assembly in-lining, intrinsic functions can be used. The defined set of intrinsic functions cover most of the specific XA features which could otherwise not be accessed by the C language. For more information on intrinsic functions see section 3.14 Intrinsic Functions.

asm_noflush

Same as pragma asm, except that the peephole optimizer does not flush the code buffer and assumes register contents remain valid.

endasm

Switch back to the C language. The section Inline Assembly in the chapter Language Implementation contains more information.

listinc

Expand include files in generated list file.

nolistinc

Default. Do not expand include files in list file.

optimize flags

Controls the amount of optimization. The remainder of the source line is scanned for option characters, which are processed like the flags of the -O command line option. Please refer to the -O option for the list of available flags.

Depending on the optimization some optimize pragmas can be used on a function scope only (function level), whereas other optimize pragmas can be used on each source line (flow level). 'On function level' means that if a pragma optimize is found within a function, it is interpreted as if it was found just before the function. The optimization level of each optimize pragma is described for each flag of the -O option.

endoptimize

End a region that was optimized with a #pragma optimize. The pragma endoptimize restores the situation as it was before the corresponding pragma optimize. #pragma optimize/endoptimize pairs can be nested.

Example:

packchar

Enable packing of char type structures. Structures and nested structures that only contain character type members are packed. Character type structures can have odd size and odd alignment. Non character type structures need alignment, because the XA architecture does not support unaligned word access. Packing structures optimizes the data allocation, but decreases the code speed because byte copies are required for initialization and copying packed character type data structures.

endpackchar

Default. Disable packing of char type structures.

Example:

renamesec mem=new

Rename a section. This pragma is used to create unique section names. Section renaming is used in combination with locator description files to assign specific locator attributes to pieces of C code. You must specify this pragma at the beginning of the source. Same as the -R option. See the -R option for more information.

defaultsec

Use default section naming convention. You can exclude modules from a rename action by specifying a #pragma defaultsec at the beginning of the source. This pragma overrules the -R option.

source-s option

Same as the -s option. Enable mixing C source with assembly code.

nosource

Default. Disable generation of C source within assembly code.

vector [value]

Default. Restore generationof interrupt vector after a novector pragma. With the value, this pragma is the same as the -ivo option.

novector

Same as the -v option. Do not emit interrupt vector and reference to interrupt handler in run-time library.

4.5 Compiler Limits

The ANSI C standard [1-2.2.4] defines a number of translation limits, which a C compiler must support to conform to the standard. The standard states that a compiler implementation should be able to translate and execute a program that contains at least one instance of every one of the limits listed below. cxa's actual limits are given within parentheses.

Most of the actual compiler limits are determined by the amount of free memory in the host system. In this case a 'D' (Dynamic) is given between parentheses. Some limits are determined by the size of the internal compiler parser stack. These limits are marked with a 'P'. Although the size of this stack is 200, the actual limit can be lower and depends on the structure of the translated program.


Copyright © 2000 TASKING, Inc.