Occam-2 Compiler Library Specification

_____________________________________________________________________

INMOS Limited Confidential

Conor O’Neill and Stephen Clarke

SW-0063-5
APPROVED - 4 March, 1991

Contents

1 Change history
 1.1 Changes since issue of SW-0063-4.
 1.2 Changes since issue of SW-0063-3.
 1.3 Changes since issue of SW-0063-2 of February 1, 1990
 1.4 Changes since issue of January 24, 1990
2 Introduction
3 Operations
 3.1 INT16 operations
 3.2 INT32 operations
 3.3 INT64 operations
 3.4 REAL32 operations
 3.5 REAL64 operations
4 Type conversions
 4.1 INT16 conversions
 4.2 INT32 conversions
 4.3 INT64 conversions
 4.4 REAL32 conversions
 4.5 REAL64 conversions
5 Predefined routines
 5.1 Multiple-length integer arithmetic functions
 5.2 Floating point functions
 5.3 Full IEEE arithmetic functions
 5.4 Transputer-specific predefined routines
  5.4.1 General purpose routines
  5.4.2 Block Move routines
  5.4.3 Cyclic redundancy checking
  5.4.4 Bit manipulation routines
  5.4.5 Floating point support routines
  5.4.6 Dynamic code loading
6 Summary
7 Interactive debugger support

1 Change history

1.1 Changes since issue of SW-0063-4.

1.2 Changes since issue of SW-0063-3.

1.3 Changes since issue of SW-0063-2 of February 1, 1990

1.4 Changes since issue of January 24, 1990

2 Introduction

This document lists all the library routines which may be called implicitly by code compiled by the Inmos occam compiler, and the conditions in which they will be called. It also lists the predefined routines which must be supplied in library form.

The occam compiler can compile in HALT, STOP or UNIVERSAL error mode; therefore it may expect to find these routines in any of these error modes in the compiler libraries.

The table in section  6 details which processors each routine should be available for.

The occam compiler needs to read a compiler library when it has to compile a call into that compiler library, as it needs to know the workspace and vector space requirements of the called routine. For efficiency reasons, the compiler insists that the library routines do not use vectorspace, hence a vectorspace parameter is never needed. Theoretically, the compiler should also check that the formal parameters are of the correct types. This is not done at present.

The occam compiler assumes the following names for the compiler libraries:





Target processor




T212 T414 T800
T222 T425 T801
T225 T400 T805
Error mode M212 TA / TB




Any occam2.liboccama.liboccam8.lib




A predefined routine is a routine which is automatically defined by the compiler before the first line of user source. These may be descoped in the same way as any other identifier. Predefined routines are in some cases translated into inline code sequences and in other cases into calls into the compiler libraries. For the sake of completeness, this document lists all predefined routine names recognised by the compiler: those predefined routines which are compiled inline for particular target processors will not appear in the compiler library for that processor. Those predefined routines which are always compiled inline will not appear in any compiler library.

This document only details the entry points of the compiler libraries as required by the compiler: any routines which are internal to the compiler libraries are not listed. These are currently implemented in another library occamutl.lib which holds routines for all processor types and error modes.

3 Operations

A routine of the form

type op %CHK

performs the occam operation op upon operands of occam type type, where type is one of INT16, INT32, INT64, REAL32 or REAL64, and op is one of ADD, SUB, MUL, DIV, REM, PLUS, MINUS, TIMES, BITAND, BITOR, XOR, BITNOT, LSHIFT, RSHIFT, XOR, GT or EQ.

For example, INT32PLUS%CHK performs the occam PLUS operation upon two operands of type INT32.

The routines REAL32OPERR%CHK and REAL64OPERR%CHK implement the occam operations +, -, * and / upon REAL32 and REAL64 operands respectively. The Op parameter takes the following values:




ValueMeaning



0 Add (occam +)
1 Subtract(occam -)
2 Multiply(occam *)
3 Divide (occam /)



The routines REAL32REMERR%CHK and REAL64REMERR%CHK implement the occam remainder operation upon REAL32 and REAL64 operands respectively. They are equivalent to REAL32OP, REAL64OP, REAL32REM and REAL64REM (see “occam 2 Reference Manual”, Prentice-Hall 1988) except that they perform occam error checking for errors and overflows, rather than the IEEE method of using infinities and Not-a-Numbers.

The routines REAL32EQERR%CHK, REAL64EQERR%CHK, REAL32GTERR%CHK, and REAL64GTERR%CHK perform the occam operations = and > upon REAL32 and REAL64 operands. They are equivalent to REAL32EQ, REAL64EQ, REAL32GT and REAL64GT (see “occam 2 Reference Manual”, Prentice-Hall 1988) except that they perform occam error checking for errors and overflows, rather than the IEEE method of using infinities and Not-a-Numbers.

3.1 INT16 operations

3.2 INT32 operations

3.3 INT64 operations

3.4 REAL32 operations

3.5 REAL64 operations

4 Type conversions

A routine of the form

type1 TO type2 %CHK

performs the occam type conversion from type1 to type2, where type1 and type2 are one of INT16, INT32, INT64, REAL32 or REAL64. REAL type conversions take a rounding mode if the conversion cannot be performed exactly, which may take the values:




ModeMeaning



0 Round to zero (occam TRUNC)
1 Round to nearest(occam ROUND)



4.1 INT16 conversions

4.2 INT32 conversions

4.3 INT64 conversions

4.4 REAL32 conversions

4.5 REAL64 conversions

5 Predefined routines

The occam compiler automatically recognises a large number of predefined routines, which are in some cases translated into inline code sequences and in other cases into calls into the compiler libraries. Note that all the compiler libraries have entry point names which are formed by adding ‘%O’ to the end of the predefine name. This section lists all of these names, and describes when they will be generated inline, and when they will be calls into the compiler libraries. The actual code which is generated for the inline expansions is described in SW-0078 (“Code generated for predefined routines”).

All predefined routines named here are specified in SW-0044 (“occam 2 Language Implementation Manual”) or “occam 2 Reference Manual”, Prentice-Hall 1988.

5.1 Multiple-length integer arithmetic functions

5.2 Floating point functions

5.3 Full IEEE arithmetic functions

5.4 Transputer-specific predefined routines

5.4.1 General purpose routines

5.4.2 Block Move routines

5.4.3 Cyclic redundancy checking

5.4.4 Bit manipulation routines

5.4.5 Floating point support routines

5.4.6 Dynamic code loading

6 Summary

The following table summarizes which routines are needed on each processor type. A tick indicates that the routine is required compiled for that processor. The name of another processor (or class) also indicates that the routine is required, but that it can use the one compiled for the indicated processor type, since the code generated for that library routine would be identical. Note that technically this information is an implementation issue, not a specification (ie. it depends upon how REAL32OP etc. are implemented), but it is included here for completeness. To read this as a specification, consider any column containing a processor type simply as a tick.









Routine T212T225TATBT414T425T800








INT16ADD%CHK √TA TA TA √
INT16SUB%CHK √TA TA TA √
INT16MUL%CHK √TA TA TA √
INT16DIV%CHK √TA TA TA √
INT16REM%CHK √TA TA TA √
INT16PLUS%CHK √TA TA TA √
INT16MINUS%CHK √TA TA TA √
INT16TIMES%CHK √TA TA TA √
INT16BITAND%CHK √TA TA TA √
INT16BITOR%CHK √TA TA TA √
INT16XOR%CHK √TA TA TA √
INT16LSHIFT%CHK √TA TA TA √
INT16RSHIFT%CHK √TA TA TA √
INT16BITNOT%CHK √TA TA TA √
INT16GT%CHK √TA TA TA √
INT16EQ%CHK √TA TA TA √








INT32MUL%CHK √ T212
INT32DIV%CHK √ T212
INT32REM%CHK √ T212








INT64ADD%CHK √ T212
INT64SUB%CHK √ T212
INT64MUL%CHK √ T212 √TA TA TA √
INT64DIV%CHK √ T212 √TA TA TA √
INT64REM%CHK √ T212 √TA TA TA √
INT64PLUS%CHK √ T212
INT64MINUS%CHK √ T212
INT64TIMES%CHK √ T212
INT64BITAND%CHK √ T212
INT64BITOR%CHK √ T212
INT64XOR%CHK √ T212
INT64LSHIFT%CHK √ T212
INT64RSHIFT%CHK √ T212
INT64BITNOT%CHK √ T212
INT64GT%CHK √ T212
INT64EQ%CHK √ T212
















Routine T212T225TATBT414T425T800








REAL32OPERR%CHK √ T212 √ √ TB TB
REAL32REMERR%CHK √ T212 √TA TA TA
REAL32GTERR%CHK √ T212 √ √ TB TB
REAL32EQERR%CHK √ T212 √ √ TB TB








REAL64OPERR%CHK √ T212 √TA TA TA
REAL64REMERR%CHK √ T212 √TA TA TA
REAL64GTERR%CHK √ T212 √TA TA TA
REAL64EQERR%CHK √ T212 √TA TA TA
















Routine T212T225TATBT414T425T800








INT16TOINT64%CHK √ T212
INT16TOREAL32%CHK √ T212
INT16TOREAL64%CHK √ T212








INT32TOINT64%CHK √ T212
INT32TOREAL32%CHK √ T212 √TA TA TA
INT32TOREAL64%CHK √ T212 √TA TA TA








INT64TOINT16%CHK √ T212
INT64TOINT32%CHK √ T212
INT64TOREAL32%CHK √ T212 √TA TA TA
INT64TOREAL64%CHK √ T212 √TA TA TA
















Routine T212T225TATBT414T425T800








REAL32TOINT16%CHK √ T212
REAL32TOINT32%CHK √ T212 √TA TA TA
REAL32TOINT64%CHK √ T212 √TA TA TA
REAL32TOREAL64%CHK √ T212 √TA TA TA








REAL64TOINT16%CHK √ T212
REAL64TOINT32%CHK √ T212 √TA TA TA
REAL64TOINT64%CHK √ T212 √TA TA TA
REAL64TOREAL32%CHK √ T212 √TA TA TA
















Routine T212T225TATBT414T425T800








NOTFINITE%O √ T212
MINUSX%O √ T212
ABS%O √ T212 √ √ TB TB
ISNAN%O √ T212 √TA TA TA
ORDERED%O √ T212 √TA TA TA
MULBY2%O √ T212 √ √ TB TB
DIVBY2%O √ T212 √ √ TB TB
SQRT%O √ T212 √ √ TB TB
FPINT%O √ T212 √ √ TB TB








SCALEB%O √ T212 √ √ TB TB √
COPYSIGN%O √ T212 √TA TA TA √
NEXTAFTER%O √ T212 √TA TA TA √
LOGB%O √ T212 √TA TA TA √
FLOATING.UNPACK%O √ T212 √TA TA TA √
ARGUMENT.REDUCE%O √ T212 √ √ TB TB √
















Routine T212T225TATBT414T425T800








DNOTFINITE%O √ T212 √TA TA TA
DMINUSX%O √ T212 √TA TA TA
DABS%O √ T212 √TA TA TA
DISNAN%O √ T212 √TA TA TA
DORDERED%O √ T212 √TA TA TA
DMULBY2%O √ T212 √TA TA TA
DDIVBY2%O √ T212 √TA TA TA
DSQRT%O √ T212 √TA TA TA
DFPINT%O √ T212 √TA TA TA








DSCALEB%O √ T212 √TA TA TA √
DCOPYSIGN%O √ T212 √TA TA TA √
DNEXTAFTER%O √ T212 √TA TA TA √
DLOGB%O √ T212 √TA TA TA √
DFLOATING.UNPACK%O √ T212 √TA TA TA √
DARGUMENT.REDUCE%O √ T212 √TA TA TA √
















Routine T212T225TATBT414T425T800








REAL32OP%O √ T212 √ √ TB TB √
REAL64OP%O √ T212 √TA TA TA √
IEEE32OP%O √ T212 √TA TA TA √
IEEE64OP%O √ T212 √TA TA TA √
REAL32REM%O √ T212 √TA TA TA √
REAL64REM%O √ T212 √TA TA TA √
IEEE32REM%O √ T212 √TA TA TA √
IEEE64REM%O √ T212 √TA TA TA √
REAL32EQ%O √ T212 √TA TA TA √
REAL64EQ%O √ T212 √TA TA TA √
REAL32GT%O √ T212 √TA TA TA √
REAL64GT%O √ T212 √TA TA TA √
IEEECOMPARE%O √ T212 √TA TA TA √
DIEEECOMPARE%O √ T212 √TA TA TA √
















Routine T212T225TATBT414T425T800








MOVE2D%O √ T212 √TA TA
CLIP2D%O √ T212 √TA TA
DRAW2D%O √ T212 √TA TA
BITCOUNT%O √ √TA TA
CRCWORD%O √ √TA TA
CRCBYTE%O √ √TA TA
BITREVWORD%O √ √TA TA
BITREVNBITS%O √ √TA TA








FRACMUL%O √ T212
UNPACKSN%O - - √ √
ROUNDSN%O - - √ √








7 Interactive debugger support

If the compiler’s interactive debugging option is selected (see SW-0062 (“occam 2 Compiler specification”)) then the compiler also requires a library containing the debugging input and output routines. The compiler assumes that this library is called virtual.lib.

This library must contain the following routines for all processor types:









Routine T212T225TATBT414T425T800








VIRTUAL.OUT.WORD% √ T212 √TA TA TA √
VIRTUAL.OUT.BYTE% √ T212 √TA TA TA √
VIRTUAL.OUT% √ T212 √TA TA TA √
VIRTUAL.IN% √ T212 √TA TA TA √