OS PL/I Version 2 GC26-4313-3

General Information

Release 2

r\ which case the programmer explicitly controls the storage (independently of the invocation of blocks) with ALLOCATE and FREE statements. Programmers can also declare storage as BASED. BASED storage gives programmers an even higher degree of control than does CONTROLLED storage.

Storage classes let programmers determine the speed, storage space, or program ming economy of each application. External procedures can be maintained in aux iliary storage for dynamic loading into (and deletion from) real storage during program processing. It is usually true that the more dynamic the method of storage allocation, the greater the run time.

Machine Independence PL/I is much less machine dependent than most commonly used programming lan guages. Machine independence causes some restrictions in the language. The most obvious example is that data with different characteristics cannot, in general, share the same storage. To equate a floating-point number with a certain number of alphabetic characters makes assumptions about the representation of those data Items that might not be true for all machines.

The price entailed by machine independence may sometimes be too high in terms of run time. In the interest of efficiency, certain features such as the UNSPEC built-in function and record-oriented data transmission are machine dependent.

Expressions Programmers specify calculations in PL/l by using expressions. An expression has a meaning in PL/I that is similar to that of elementary algebra. An example of an algebraic, PL/I expression is:

A + B *

The PL/I expression above multiplies the value of B by the value of C and adds the value of A to the result. PL/I places few restrictions on the kinds of data that can be used in an expression. PL/I expressions can include arrays or mixed element structures.

When programmers specify such mixed expressions, PL/I converts the operands in order to meaningfully evaluate the operation.

However, note the following considerations:

• Programmers must carefully consider the rules for conversion because con verted data might not have the same value as the original data. The rules for conversion can be overridden by using built-in functions (such as ADD, MUL TIPLY, and SUBSTR).

• Conversions may increase run time.

Expressions can be used in many PL/I statements. An example appears in the fol lowing assignment and GALL statements; X = A + B * C;

This assignment means: Evaluate the expression on the right and store the result In X. If the attributes of X differ from the attributes of the result of the expression, conversion will be performed.

Chapter 2. Major Features of PL/I 15 CALL SUB(0,E * F);

This CALL statement means: Call the named SUB, passing D as the first argument. Pass the result of evaluating E * F as the second argument. If D or E * F does not match the attributes of the parameters of SUB (an Internal proce dure), conversion does take place.

Data Aggregates In PL/1, data Items may be single data elements or they may be grouped together to form data aggregates (that Is, as groups of data items that can be referred to either collectively or Individually). Data aggregates can be either arrays, struc tures, or arrays of structures.

A variable that represents a single element within an aggregate Is called an element variable, or scalar variable. A variable that represents an aggregate of data elements is called an array variable, or a structure variable.

Any type of problem data or program control data can be grouped Into a data aggregate. Elements of an aggregate are program variables that can be used as If they had been Individually declared.

Arrays

An array Is an n-dlmensional collection of elements with the same attributes. Arrays are defined by the number of elements in the array (the extent), a base attri bute, a scale attribute, and a precision attribute. For example: DECLARE TEMPERATURES (365) FIXED DECIMAL (4,1);

In the DECLARE statement, TEMPERATURES Is the name of the array. Its four attributes are: 1. (365) is the high bound of the array and Is also the size or extent of the array because the default low bound Is 1.

2. FIXED Is the scale attribute of its elements.

3. DECIMAL is the base attribute of all Its elements.

4. (4,1) Is the precision attribute of Its elements.

Structures

A structure is a collection of items whose locations relative to one another are crit ical, and whose elements need not have Identical attributes. Like an array, the entire structure Is given a name that can be used for the entire aggregate of data elements. Unlike an array, each element of the structure also has a unique name.

The data Items that appear in a structure usually have a logical relationship to each other. A structure has different levels which are specified as Integers in a DECLARE statement. At the first level Is the structure name (the major structure name); at a deeper level are the names of substructures (the minor structure names); and at the lowest level are the individual element names (the elementary names). An elementary name In a structure can represent an array.

Structures can be used to describe Input data and to format output data. Names selected for any unused space within a structure must be unique.

16 OS PL/I General Information For example, payroll data could be declared with a major structure name PAYROLL, three minor structure names NAME, HOURS, and RATE, and several elementary names: DECLARE 1 PAYROLL, 2 NAME, 3 LAST CHAR(20), 3 FIRST CHAR(15), 2 HOURS, 3 REGULAR FIXED DEC(5,2), 3 OVERTIME FIXED 0EC(5,2), 2 RATE, 3 REGULAR FIXED DEC(5,2), 3 OVERTIME FIXED DEC(5.2);

Arrays of Structures

To declare an array of structures, programmers can use a DECLARE statement to give a dimension attribute to a major or minor structure. This results in an array whose elements are structures having identical names, levels, and subelements. For example, if a structure called WEATHER were used to process meteorological data for each month of the year, it might be declared as follows: DECLARE 1 WEATHER(12), 2 TEMPERATURE, 3 HIGH DECIMAL FIXED{4,1), 3 LOW DECIMAL FIXED(4,1), 2 WIND_VELOCITY, 3 HIGH DECIMAL FIXED{3). 3 LOW DECIMAL FIXE0(3), 2 PRECIPITATION, 3 TOTAL DECIMAL FIXED(3.1), 3 AVERAGE DECIMAL FIXED(3,1);

Weather data for the month of July is contained in WEATHER(7). Portions of the July weather data can be referred to by TEMPERATURE(7) or PRECIPITATI0N(7).

Run-Time Control PL/I gives programmers a number of run-time options and features for controlling programs as they run. These include options that control storage, error-handling, debugging and testing, and run-time exits.

Run-Time Options Options that control storage:

ISASIZE Controls the size of the initial storage area (ISA), the number of sub- tasks in a multitasking environment, and the size of the ISA for each subtask.

iSAINC Controls the size of subsequent ISA segments, if required.

HEAP Specifies storage for CONTROLLED and dynamically-allocated BASED variables and how the system should handle that storage.

In a multitasking environment, HEAP applies only to the major task; TASKHEAP governs the storage allocated by each subtask.

REPORT Generates reports on storage use.

Chapter 2. Major Features of PL/I 17 Options that control testing and debugging:

COUNT Counts the number of times each statement executes.

FLOW Traces the flow of branches and procedure calls.

TEST Establishes the initial state of PLITEST.

LANGUAGE Selects national language for messages.

Options that control error-handling: SPIE Determines whether program checks are handled by PL/I or by the system. STAE Determines whether PL/I or the system handles any abnormal system terminations (abends).

Interrupt Handling PL/I provides facilities to handle a variety of conditions that arise during PL/I program processing. It lets programmers specify, by means of a condition prefix, that an interrupt is to occur if the specified condition arises. Using an ON state ment, the programmer can specify the action to be taken when an interrupt does occur. In interactive processing with PLITEST, the programmer can deal imme diately with any exception.

These conditions fall into seven general condition categories:

Computational Input/Output Program checkout ' ^ List processing System action Programmer-defined Conversational checkout.

Assembler Run-Time User Exit PL/I lets programmers write an exit routine supported through a user exit, IBMBXITA. The IBM-supplied user exit incorporates functions previously provided by IBMBEER and DMSIBM. Under CICS, PL/I provides the same support through the user exit IBMFXITA.

High-Level Language Run-Time User Exit PL/I lets programmers write an exit routine in PL/I or C, that will get control when initialization is complete, but, before control is passed to the main procedure. The IBM-supplied user exit routine (IBMBINT) is a null procedure.

18 OS PL/I General Information ^ Access to Facilities PL/I gives programmers access to operating system facilities for sorting, data base management, and checkpoint/restart.

Sorting PL/I contains an interface routine that lets programmers use the sort/merge program DFSORT.

PL/I statements can call a sorting program to:

• Pass records to be sorted • Receive sorted records • Both pass and receive records.

Checkpoint/Restart When a PL/I batch processing program compiled by the Optimizing Compiler must run for an extended period, programmers can employ the operating system checkpoint/restart facility to minimize losses caused by machine or system failure. The programmer selects checkpoints in the program at which processing is to be restarted following a failure. Only the processing carried out between the check point and the failure may be lost. Results obtained up to the checkpoint are pre served on auxiliary storage, together with data (including a copy of the program and its associated storage) required to restart the program from the checkpoint.

Data Base Facilities Programmers can use the STAE and/or SPIE options when running programs under IMS as long as they use PLITDLI or ASMTDLI.

The names PLITDLI and ASMTDLI are interpreted to mean IMS interfaces. If they are being used in any other way in a program, they must be changed.

Whether or not the SPIE option is used, IMS is to be instructed that SPIE is not being used.

PL/I routes calls to (and returns from) PLITDLI and ASMTDLI through a PL/I routine and keeps track of transfers of control between the PL/I program and IMS. Thus, if an abend or program check occurs and the PL/I error handler gains control, it can tell if the problem arose on the IMS side of the interface or on the PL/I side.

If a program check or abend occurs in IMS, and the PL/I exception handler gains control, it immediately passes the error back to IMS. No PL/I condition is raised, no PL/I ON-unit gains control, no PL/I message is produced, and IBMBXITA (the user exit) does not gain control.

If a program check occurs in the PL/I program rather than in IMS, then all the facili ties of PL/I error handling apply.

IMS requires that all parameters passed to IMS in a call to PLITDLI or ASMTDLI, r except the parameter count, must be located below 16 megabytes. All storage areas referred to in the parameter list must reside in virtual storage below 16 megabytes.

Chapter 2. Major Features of PL/I 19 The PL/I program can meet this condition by using the following techniques in any combination for the parameters passed to IMS: • Placing IMS parameters in AUTOMATIC storage. All AUTOMATIC storage is below 16 megabytes on MVS/XA, regardless of the RMODE or AMODE of the program. • Placing IMS parameters in CONTROLLED storage or in BASED storage allo cated by PL/I ALLOCATE statements, provided that HEAP is below 16 mega bytes. • Placing IMS parameters in STATIC storage and using a load module attribute of RMODE(24) to force the load module (and thus STATIC storage) to be placed below the 16-megabyte line.

PL/I programs can be placed in the (extended) link pack area of MVS/XA, provided the rules for parameter storage are met. This can eliminate program loading time, speed up IMS initialization and restart, and provide the additional integrity that results from having application programs reside in protected storage.

Input and Output PL/I provides extensive facilities for input and output that let programmers choose between factors such as simplicity, machine independence, and efficiency. There are two types of input/output in PL/I: stream-oriented and record-oriented.

Stream-oriented input/output is almost completely machine independent. During input, data items are selected one by one from an assumed continuous stream of characters that PL/I converts to internal form and assigns to variables specified in a list. Similarly, during output PL/I converts data items one by one to external character form and adds them to a conceptually continuous stream of characters. Within the class of stream input and output, the programmer can choose different levels of control over the way PL/I edits data items and selects them from (or adds them to) the stream.

For printing, the output stream may be considered to be divided into lines and pages. An output stream file may be declared to be a print file with a specified line size and page size. The programmer has facilities to detect the end of a page, and to specify the beginning of a line or a page. These facilities may be used in proce dures that can be developed into a report-generating system suitable for a partic ular site or application.

In a system employing the IBM Conversational Monitor System (CMS) or the IBM Time Sharing Option (TSO), data may be fed into, and output may be obtained from, a PL/I program using a terminal that is remote from the machine.

Record-oriented input/output is machine dependent. It deals with aggregates of data (called records), and transmits records one at a time without data conversion. The external representation Is generally an exact copy of the internal represen tation. The aggregate is treated as a whole, and no conversion is performed.

20 OS PL/I General Information PL/I provides language support for the data set organizations listed below. All types of organization can be used for record-oriented input/output. Only the con secutive type of organization can be used for stream-oriented input and output.

Consecutive: Records are passed sequentially in input, output, or update modes.

REGIONAL: Records are organized into regions which contain one or more records. A key identifies the region number and permits direct and sequential record processing in input, output, or update modes.

Indexed: An index or indexes maintained by the operating system gives the location of certain principal records. This permits direct retrieval, replacement, addition, and deletion of records, as well as sequential processing.

Virtual Storage Access Method (VSAM): This type of organization provides three types of data sets: (1) key-sequenced data sets (KSDS),(2) entry-sequenced data sets (ESDS), and (3) relative-record data sets (RRDS). These data sets correspond to PL/I indexed, consecutive, and REGIONAL data set organizations, respectively. They are all ordered, and can have keys associated with their records. Both sequential and keyed access are therefore possible with all three types of data sets.

Teleprocessing: PL/I supports teleprocessing by record-oriented data trans mission using the telecommunications access method (TCAM). A teleprocessing data set is a queue of messages originating from (or destined for) remote terminals or application programs.

Stream-oriented input and output usually sacrifice efficiency for ease of handling. Each data item transmits separately and is examined to determine if data conver sion is required. Record-oriented input and output, on the other hand, provide faster transmission but generally require a greater programming effort.

Input and output operations for data bases involving a number of interrelated data sets are simplified by the use of file variables. All input/output statements can use file variables with file values established and modified while the program is proc essing.

Input/output operations may be conducted asynchronously.

Chapter 2. Major Features of PL/I 21 Chapter 3. External Characteristics of the Optimizing Compiier

The PL/l Optimizing Compiler gives programmers the choice of either fast compila tion of the source program or fast processing of the resulting object program. By selecting a compiler option programmers choose the type of optimization required. PL/I programmers can use other options to specify particular information or to request optional compiler facilities.

The Compiler also provides debugging aids to reduce the time and effort required for program checkout.

Program Compile Time Compilation speed varies with the machine configuration employed, the version of the operating system, data set disposition, region size, the complexity of the program, and the language features and Compiler options employed. In general, programs compile faster when using larger regions, and fewer compiler output options.

For programs that use the MACRO option only to include text from a source state ment library, the INCLUDE option may be used instead, thereby decreasing compi lation time.

Program Run Time The time that a program takes to run depends on the type of optimization specified. The amount of time a particular program requires depends on factors such as over head for initialization, input/output, and the nature of the internal processing of the program. Programs are most likely to show improvement in running speed when optimized if they contain the features mentioned in Chapter 4, "Optimization" on page 27.

Testing and Diagnostic Facilities In addition to PLITEST (see Chapter 2), the Compiler provides the following debug ging aids to minimize program checkout time and effort.

Diagnostics: PL/I provides comprehensive diagnostic messages during both com pilation and running. In processing an erroneous statement, the Compiler may attempt to correct the error by making an assumption about the intention of the statement. Error messages produced during compilation are categorized as unre coverable, severe, error, warning, or informational. The messages are listed in category groups in ascending statement number order. Each message indicates the number of the erroneous statement and nature of the error.

Diagnostics produced, when program calls are made to that are not link-edited (and are therefore missing), indicate the point-of-call (when possible) rather than a wild point of failure.

Chapters. External Characteristics of the Optimizing Compiler 23 Flow Trace: A programmer can use the flow trace facility to produce a record of the changes in sequential flow prior to an interrupt. The SNAP option of the ON statement and the PLIDUMP built-in subroutine include trace as part of their diag nostic output. The trace output contains a list of branch-out/branch-in pairs of statement numbers. The trace output also gives the PL/I block name (up to 8 char acters) for each pair of statements. Programmers indicate the number of program statements to trace when requesting the option. This feature is not related to the optional inclusion of the statement number in diagnostic messages produced at run time.

PL/I, when running under CICS/VS, produces FLOW information as part of EXEC GIGS RETURN.

Statement Frequency Counting: Programmers use this facility to identify those parts of a program that are most frequently executed and those statements that are never executed. The PLIDUMP file lists the statement count at program termi nation. If the PLIDUMP file does not exist, the statement count appears in SYSPRINT.

PL/I, when running under GIGS/VS, produces COUNT information as part of EXEC GIGS RETURN.

ON-Units: PL/I facilitates program condition handling by providing ON-Units for all PL/I conditions. ON-Units permit either programmer-defined or system-defined action to take place when a particular interrupt occurs during processing. The range of conditions covers all arithmetic interrupts, attention interrupts, input/output errors, and special program-checkout conditions such as CHECK, SUBSGRIPTRANGE, STRINGRANGE, SIZE, and STRINGSIZE.

Compatibility between Releases PL/I Version 2 Release 2 provides source, object, and load module compatibility with programs processed by PL/I Version 2 Release 1.

PL/I Version 2 provides source and object compatibility with programs processed by PL/I Version 1 Release 5.1. Where the program is using new features that necessitate some incompatibilities, a compiler option (GMPAT) allows programmer control over the level of incompatibility.

If any procedure in the program (including a FETGHed module) is recompiled, then all load modules in the program must be link-edited again using the PL/I Version 2, Release 1 or Release 2, Library.

With the above exceptions, different release levels of PL/I are compatible at run time, provided that the release number of the PL/I Library is equal to or greater than the release number of the PL/I Compiler.

In general, to use a Version 2 Release 2 feature, programmers must modify a pro cedure and recompile using the PL/I Version 2 Release 2 Compiler. The following new language features may be incompatible:

• Arrays

• AREAS and aggregates

24 OS PL/I General Information IgM OS PL/I Version 2 gc26-4313-3

^ General information

Release 2 Fourth Edition (October 1988)

This edition replaces and makes obsolete the previous edition, GC26-4313-2.

This edition applies to Version 2 Release 2 of the following licensed programs: • OS PL/I Optimizing Compiler, Library, and Interactive Test Facility, Program Number 5668-909 • OS PL/I Optimizing Compiler and Library, Program Number 5668-910 • OS PL/I Library Only, Program Number 5668-911 and to any subsequent releases until otherwise indicated in new editions or technical newsletters.

The changes for this edition are summarized under "What Is New in Version 2" located in the preface. Spe cific changes are indicated by a vertical bar to the left of the change. These bars will be deleted at any republication of the page affected. Editorial changes that have no technical significance are not indicated.

Changes are made periodicaliy to this publication; before using this publication in connection with the operation of IBM systems, consult the latest IBM Systeml370, 30xx, 4300, and 9370 Processors Bibliography, GC20-0001, for the editions that are applicable and current.

References in this publication to IBM products, programs, or services do not imply that IBM intends to make these available in all countries in which IBM operates. Any reference to an IBM licensed program in this publication is not intended to state or imply that only IBM's program may be used. Any functionally equivalent program may be used instead.

Requests for IBM publications should be made to your IBM representative or to the IBM branch office serving your locality. If you request publications from the address given below, your order will be delayed because publications are not stocked there.

A Reader's Comment Form is provided at the back of this publication. If the form has been removed, com ments may be addressed to IBM Corporation, Programming Publishing, P. O. Box 49023, San Jose, California, U.S.A. 95161-9023. IBM may use or distribute whatever information you supply in any way it believes appropriate without incurring any obligation to you.

©Copyright International Business Machines Corporation 1987, 1988 ^ About This Book

This book discusses the major features of OS PL/I Version 2 Release 2 (PL/I).

Who Might Use This Book This book introduces the PL/I Optimizing Compiler to data processing managers, systems anaiysts and programmers. For readers familiar with the PL/I Optimizing Compiler, it points out and explains the Improvements and enhancements in Version 2 Release 2.

How This Book Is Organized

This book helps you decide whether PL/I can meet your data processing needs. The first chapter introduces the PL/I product and presents a brief description of its features. The next three chapters describe PL/I In greater technical detail, including hardware and software requirements.

Chapter 1, "Introduction to PL/I" on page 1 gives an overview of the main fea tures of the Optimizing Compiler and what It Is designed to do. It also describes the functions of the PL/I Library, a related licensed program.

Chapter 2, "Major Features of PL/I" on page 3 gives an overview of the PL/I lan- ^ guage Implemented by the PL/I Optimizing Compiler. This chapter describes the Interactive Test facility, multitasking, and national language support (NLS). It also contains discussions of PL/I language features, including machine independence, program structure, data types, storage allocation, data collections, and Input and output.

Chapter 3, "External Characteristics of the Optimizing Compiler" on page 23 describes the Optimizing Compiler, the debugging aids designed to Increase pro grammer productivity, and the compatibility between releases.

Chapter 4, "Optimization" on page 27 describes the optimization process, including expression simplification, substituting In-line code for calls to Library subroutines, and other optimization features.

Chapter 5, "System Considerations" on page 35 describes operating systems and environments under which PL/I runs, as well as machine and operating system requirements. It also lists products that the Optimizing Compiler can use.

Appendix A, "Summary of PL/I Version 2 Features" on page 41 discusses the functional enhancements provided with PL/I Version 2 Release 1 and Release 2.

Appendix B. "Migrating to PL/I Version 2 Release 2" on page 45 explains PL/I migration requirements.

4bout This Book ill other OS PL/I Version 2 Books Available OS PUI Version 2 General Information is only one book from a library of books for OS PL/I Version 2. Figure 1 names the books in the library and shows what tasks, such as evaluating OS PL/I Version 2, each book is designed to help you with.

In addition to this General Information manual, the PL/I Version 2 Release 2 publi cations, shown in figure 1, will be available when the program is available. Descriptions of the publications follow figure 1.

Task OS PL/I Version 2 Publications Order Number

Evaluation General Information GC26-4313 Licensed Program Specifications GC26-4314

Installation and Installation and Customization under MVS SC26-4311 Customization Installation and Customization under CMS SC26-4312

Application Programming Guide SC26-4307 and System Language Reference SC26-4308 Programming Reference Summary SX26-3759 Using PLITEST SC26-4310 Messages and Codes SC26-4309

Diagnosis Problem Determination LY27-9528

Figure 1. The OS PL/I Version 2 Library

OS PL/1 Version 2 Licensed Program Specifications, GG26-4314, briefly describes PL/I and serves as the PL/I warranty.

OS PL/I Version 2 Installation and Customization under MVS, SC26-4311, lists the steps to install and customize PL/I under MVS/SP and MVS/XA.

OS PL/I Version 2 Installation and Customization under CMS, S026-4312, lists the steps to install and customize PL/I under the CMS component of VM/SP.

OS PL/I Version 2 Programming Guide, SC26-4307, describes how to code, compile, test, and run OS PL/I programs. Information appearing in OS PL/I Opti mizing Compiler: CMS User's Guide, SC33-0037, and in OS PL/I Optimizing Com piler: TSC User's Guide, SC33-0029 is now contained in this book.

OS PL/I Version 2 Programming: Language Reference, SC26-4308, presents rules for writing OS PL/I source programs to be compiled by the PL/I compiler.

OS PL/I Version 2: Reference Summary, SX26-3759, summarizes the OS PL/I lan guage keywords, options, language syntax, and PLITEST command syntax.

OS PL/I Version 2 Programming: Using PLITEST, SC26-4310, provides both guid ance and reference information on using the PL/I Interactive Test Facility (PLITEST) to test programs in a PL/I environment.

OS PL/I Version 2 Programming: Messages and Codes, SC26-4309, lists error mes sages and codes that may be issued when PL/I programs are compiled, link-edited, and run. It also includes messages and codes issued by PLITEST. This book lists both the long and short forms of each message where applicable, and gives expla nations of messages, codes, and suggested programmer responses.

IV OS PL/I General Information OS PUI Version 2 Problem Determination, LY27-9528, provides aids in problem determination and in the formulation of search arguments. It also helps users determine if a problem resulted from a user error or from an error in PL/I.

What Is New in Version 2

OS PL/i Version 2 Release 2 OS PL/I Version 2 Release 2 provides the following functional enhancements:

• Interlanguage communication with C

• Improved error handling

• CICS return code checking

• Support for user exits written in PL/I and/or C

• PLITEST enhancements

- Ability to list structures

- Ability to use mathematical and storage built-in functions

• SYSTEM(IMS) compile-time option enhancement

• Support for IBM INSPECT for 0 and PL/I. IBM INSPECT provides: - Functional compatibility with PLITEST - Capability to test C and/or PL/I programs

For more information, see IBM INSPECT for 0 and PUI: General Information, GC26-4526.

OS PL/l Version 2 Release 1 OS PL/I Version 2 Release 1 provides the following functional enhancements:

PLITEST, an interactive test facility^ Improved diagnostics Preinitializable programs Reentrant object code under CMS Write validity checking made optional Fullword array subscripts support Large AREAs and aggregates support^ Enhanced FETCH in MVS Increased block size for SYSLIB National language support Enhanced double-byte character set(DBCS) support BX bit string constant X character string constant DELAY statement implementation in CMS Enhanced MAIN procedure parameter interface^ Enhanced subsystem interface REPORT output routed to SYSPRINT

See Chapter 2, "Major Features of PL/I" on page 3 for details.

About This Book • Compressed PLIDUMP output for duplicate lines • Run-time user exit^ .

Appendix A, "Summary of PL/I Version 2 Features" on page 41 provides a general description of the enhancements made in Version 2.

VI OS PL/I General Information Contents

Chapter 1. Introduction to PL/I 1

Chapter 2. Major Features of PL/I 3 Interactive Test Facility - PLITEST 3 Compile-Time TEST option 5 Run-Time TEST option 6 Multitasking 6 Interlanguage Communication 7 Facilities at Compile-Time 8 Cross Compilation 8 Compiler Options 8 Preprocessor 10 Large System Support 10 Fullword Array Subscripts 10 Large AREAS and Aggregates 10 Large Block Size for SYSLIB Data Sets 11 Programming Features and Facilities 11 MAIN Procedure Parameter Interface 11 Accessing Load Modules in the Link Pack Area (LPA) 12 National Language Support 12 Double-Byte Character Set (DBCS) Support 12 Program Structure 12 Data Types and Data Description 13 Default Assumptions 14 Storage Allocation 14 Machine Independence 15 Expressions 15 Data Aggregates 16 Run-Time Control 17 Run-Time Options 17 Interrupt Handling 18 Assembler Run-Time User Exit 18 High-Levei Language Run-Time User Exit 18 Access to Operating System Facilities 19 Sorting 19 Checkpoint/Restart 19 Data Base Facilities 19 Input and Output 20

Chapters. External Characteristics of the Optimizing Compiler 23 Program Compile Time 23 Program Run Time 23 Testing and Diagnostic Facilities 23 Compatibility between Releases 24 Compatibility between OS and DOS 25

Chapter 4. Optimization 27 Expressions 28 Common Expression Elimination 28 Redundant Expression Elimination 29 Simplification of Expressions 29 Modification of Loop Control Variables 29

Contents vil Defactorization 30 Replacement of Constant Expressions 30 Replacement of Constant Multipliers and Exponents 30 Elimination of Common Constants 30 Code for Program Branches 30 Loops 31 Transfer of Expressions from Loops 31 Programming Considerations 31 Special Case Code for DO Statements 32 Arrays and Structures 32 Initialization of Arrays and Structures 32 Structure and Array Assignments 32 Elimination of Common Control Data 32 In-line Code 33 In-Line Code for Conversions 33 In-Line Code for Record I/O 33 In-Line Code for String Manipulation 33 In-Line Code for Built-in Functions 33 Key Handling for REGIONAL Data Sets 33 Matching Format Lists with Data Lists 34 Library Subroutines 34 Use of Registers 34

Chapter 5. System Considerations 35 Operating Systems 35 Compiling under MVS 36 Running PL/I Programs under MVS 37 Running PL/I Programs under IMS/VS 37 Running PL/I Programs under CICS/VS 37 Compiling under VM/CMS 38 Running PL/I Programs under VM/CMS 38 Related Products and Publications 39

Appendix A. Summary of PL/i Version 2 Features 41 PL/I Version 2 Release 2 41 PL/I Version 2 Release 1 41 Productivity Enhancements 41 Performance Enhancements 42 Extended Architecture (XA) Enhancements 43 Usability Enhancements 43

Appendix B. Migrating to PL/I Version 2 Release 2 45 Coexisting with the PL/I Checkout Compiler 45

Index 47

VIM OS PL/I General Information Chapter 1. Introduction to PL/1

The PL/I Optimizing Compiler compiles programs written in PL/I into efficient object programs. It should meet the requirements of PL/I users in medium or large sites. The main features include:

• Extensive Testing and Debugging Aids: Minimize time and effort required for program checkout by using:

- The Interactive Testing Facility (PLITEST) that operates in both interactive and batch mode

- Extensive implementation of ON-units

- Clear and precise compile-time and run-time diagnostic messages

- Statement number tracing facility

- Statement frequency counting facility

- Check condition support

- Data-directed input/output.

• Multitasking: In PL/I, many procedures can be active concurrently. Any PL/I procedure can call another PL/I procedure, which becomes a subtask of the calling procedure. As a result, PL/1 allows concurrent processor operations or concurrent processor and input/output operations.

• Compile-time facilities: The PL/I Optimizing Compiler gives programmers many compiler facilities. For example, programmers can use:

- The preprocessor for many useful tasks, including symbolic replacement, generating code, creating reusable procedures,and conditionally including code

- Optimization options to choose the degree to which PL/I optimizes their source code into efficient object code

- Compiler options to request information or optional compiler facilities, setting these options as defaults at installation time and setting or resetting them at compile time

- The %INCLUDE statement to include code from external libraries.

• Interlanguage Communication: PL/I programs can call and be called by FORTRAN, COBOL, C, or Assembler programs. • Large System Support: PL/I supports array subscripts in the range -2^' through AREAs and aggregates to a maximum size of 2^'-1.

• Programming Support: PL/I's system and subsystem support gives program mers a variety of useful tools, including an interface to the PL/I MAIN proce dure and interfaces to other subsystems through the SYSTEM option. Using PL/I improves programmer productivity through extensive storage allocation facilities, many data types and descriptions, modular structure, machine inde pendence, and use of expressions.

• Run-Time Control: PL/I contains a number of run-time options to help pro n grammers control storage and to aid in testing and error-handling. PL/I also supports run-time user exits.

Chapter 1. introduction to PL/I 1 • Access To Operating System Facilities: PL/I gives programmers access to sort, data base, and checkpoint/restart facilities of the operating system.

• Input and Output Facilities: PL/I's input/output facilities allow programmers to choose among such factors as simplicity, machine independence, and effi ciency. For example, a programmer can choose between stream-oriented and record-oriented input/output.

The PL/I Optimizing Compiler compiles PL/I source statements into machine instructions. In some cases it inserts references to subroutines that are stored in the Library. During link-editing, the PL/I subroutines are included from the Library to form a load module. These subroutines can contain references to other subrou tines stored in the Library. During program processing, PL/I loads, processes, and deletes Library subroutines as required.

The PL/I Library provides the following functions:

— Mathematical subroutines - Data type conversions - Record- and stream-oriented transmission — Edit-, list-, and data-directed I/O (stream-oriented transmission) - Program initialization/termination — Storage management - Tasking facilities — Error handling — Run-time message handling facilities - File opening and closing.

2 OS PL/I General Information Chapter 2. Major Features of PL/I

This chapter discusses the major features of PL/I and provides an overall description of the language. It explains the interactive Test Facility (PLITEST), multitasking, interlanguage communication, large system support, language fea tures, and run-time facilities.

PL/I is a modular language with a wide variety of features. By examining the fea tures of PL/I, you can see how easy it is to select subsets to meet a wide range of needs. Modularity is one of the most useful characteristics of PL/I.

interactive Test Faclllty - PLITEST The Interactive Test Facility, PLITEST, is a flexible tool for examining, monitoring, and controlling PL/I programs. PLITEST uses commands that are similar to PL/I statements to help programmers test and debug their programs. Figure 2 displays the PLITEST command set.

Functions PLITEST Commands

Information ANALYZE QUERY

Condition Management AT CLEAR ON

Variable Management Assignment DECLARE LIST

Run Control GO SET STEP USE VTRACE

Program Control BEGIN/END GOTO QUIT CALL/PROCEDURE IF/THEN/ELSE SELECT/WHEN/OTHERWISE DO/END QUALIFY SIGNAL

Figure 2 (Part lot 2). Functional Summary of PLITEST Commands

O

Chapter 2. Major Features of PL/I 3 Functions PLITEST Commands rs System CMS HELP TSO

Full-Screen Display Control CLOSE MOVECURS RETRIEVE COLORS OPEN RIGHT DOWN POSITION SEARCH LEFT PREVDISP SIZE LISTINGS PROFILE UP MONITOR RESTORE WINDOWS

Full-Screen Prefix AT CLEAR PEEK

Figure 2 (Part 2 of 2). Functional Summary of PLITEST Commands

Using the AT, ON, STEP, and VTRACE commands, the programmer can monitor and Interrupt the flow of a program:

• Before conditions are processed by the program

• When the values of selected variables change

• Before each statement is executed

• After each program block has been initialized O • Before each program block is terminated

• When the flow of control in the program changes:

— Before the first statement enclosed by an iterative DO statement

— Before the first statement of the true part of an IF statement

— Before the ELSE unit of an IF statement

— Before the first statement following a user label

— At every CALL or function reference -- both before and after control is transferred to the routine

— Before the true WHEN statements of a select-group

— Before the OTHERWISE statement of a select-group

• When CONTROLLED variables are ALLOCATEd

• When load modules are FETCHed

Using the GOTO command, the programmer can alter the flow of the program by redirecting it to a specified statement or label.

The programmer can display and analyze PL/I expressions containing constants and program variables via the LIST and ANALYZE commands. All PL/I operators and a wide range of PL/I built-in functions are ailowed in these expressions, and PLITEST evaluates all expressions according to PL/I rules for conversion and oper ator precedence. During expression evaluation, PLITEST alerts the user if it detects significant errors such as SUBSCRIPTRANGE, STRINGRANGE, ZERODIVIDE, or bad FIXED DECIMAL data.

OS PL/I General Information The programmer using PLITEST can also change program variables, registers, and selected storage locations via the assignment command. The assignment command allows the use of the ONCHAR, ONSOURCE, SUBSTR, UNSPEC, IMAG, and REAL pseudovariables and follows PL/I rules for assignments.

PLITEST also enables the programmer to conditionally execute any PLITEST command via the use of IF-THEN-ELSE commands, SELECT-WHEN-OTHERWISE commands, and all the PL/I varieties of DO-loop commands.

When PLITEST runs under the Interactive System Productivity Facility (ISPF) Version 2 (under CMS or TSO), it runs in full-screen mode using ISPF panels and services. A programmer, using PLITEST in full-screen mode, can view simultane ously a source window displaying the program listing, a monitor window displaying values of selected program variables, and a log window listing interactions with PLITEST. The programmer can color and configure these three windows to suit testing needs and can use ISPF to split the physical screen into two logical screens. Figure 3 illustrates a PLITEST session in full-screen.

PLITEST WHERE: KNIGHT : 52 COMMAND ===> SCROLL ===> PAGE

SOURCE 0 + 1 + 2 + 3 + 4 + 5— LINE: 220 OF 245 48 INITIALIZE_RANKINGS: PROC;

49 DCL (R.C.K) FIXED BIN(15):

50 DO R = -1 TO 2+SIZE; 51 DO C = -1 TO 2+SIZE; AT IF R < 1 I R > SIZE I C < 1 I C > SIZE THEN RANK(R,C) = 0; 53 ELSE RANK(R.C) = 8; 54 END; 55 END; log 0 + 1 + 2— LINE: 1 OF 6 MONITOR —+ 1 +— LINE: 1 OF 3 **************'* TOP OF LOG ************** ********** jQp Qp: monitor ********** 0001 AT 52 ; 0001 1 SIZE' 8 0002 GO ; 0002 2 R = -1 0003 MONITOR 0003 C = -1 0004 LIST TITLED ( SIZE ) ; ******** bottom of monitor ********* 0005 MONITOR 0006 LIST TITLED ( R . C ) ; ************* 0OTTOM OF LOG *************

Figure 3. Sample PLITEST Session

Compile-Time TEST option The Compiler supports PLITEST using the TEST/NOTEST option.

The ability to use program variables in PLITEST commands is contingent upon the SYM/NOSYM suboption. If the program is compiled with TEST(SYM), PLITEST can access almost all program variables. If the program is complied with TEST(NOSYM), PLITEST cannot access program variables, although it can still use registers, ON built-in functions, and pseudovariables.

Chapter 2. Major Features of PL/1 5 The ability to stop the program at statements, block entries, and the other locations Indicated above Is contingent upon the other suboptlon of the TEST complle-tlme option. The program can stop only where "hooks" have been Inserted by the Com piler Into the program. The following TEST suboptlons specify hook locations: NONE specifies that no hooks are to be Inserted Into the program

BLOCK specifies that hooks are Inserted at all block entries and block exits STMT specifies that hooks are Inserted additionally at all statement boundaries PATH specifies that hooks are Inserted at all points where the flow of control In the program can change ALL specifies that hooks are Inserted at all BLOCK, STMT, and PATH locations.

Run-Time TEST option The run-time environment supports PLITEST using the TEST/NOTEST option. Three suboptlons can appear with TEST. They specify:

• PL/I conditions for which PLITEST should be Invoked before program proc essing

• A DDNAME of a file to be used as the source of commands

• A command string of one or more commands to be processed during Initializa tion.

Multitasking MVS contains facilities for multiprogramming. That Is, MVS allows a number of tasks to be active concurrently. In the same way, PL/I contains facilities that allow some procedures within a PL/I program to be concurrently active.

Any PL/I procedure can call another PL/I procedure. The programmer may specify that the procedures are to be tasks, which means, they may be active concurrently. The called procedure Is a sub-task of the calling procedure, and Is attached by the calling procedure.

As soon as the processor (or Input/output) operations In one task complete, PL/I searches the active tasks for another task that requires the same resource. If PL/I finds more than one such task. It assigns the resource to the task having the highest priority. The PL/I programmer can allow the system to allocate relative priorities, or can assign the priorities as the tasks are attached.

A number of tasks can depend on each other at various points during processing. For example, one task can require results obtained in another task before it can complete. In PL/I, the programmer can synchronize tasks at various points during processing. A programmer can require an operation In one task to await the com pletion of an operation in another task before proceeding.

PLITEST can be used with multitasking programs.

When there are more tasks than one, any or all of them might call PLITEST. Because there could be conflicting use of the terminal and log file if PLITEST is operating on multiple tasks, its use is single-threaded through the PL/I Control Task. Thus, If a program runs as two tasks and the first task calls PLITEST,

6 OS PL/I General Information PLITEST accepts the request and begins operating on behalf of that task. If, during r-i that period, the second task calls PLITEST, the second task request is held until the ^ first request completes. (Note: The //rsf request is the request for PLITEST ser vices and is satisfied by more than one command and more than one programmer interaction; it can include a great deal of Input/Output and associated wait time.)

When the requests from a first task complete, PLITEST is free to accept any pending requests.

It is possible for programmers to get into situations where many tasks request PLITEST services at one time. For example, if each monitor statement hooks four running tasks, a programmer might see the progress of four independent programs as they step from statement to statement.

Interlanguage Communication Procedures compiled by the PL/I Optimizing Compiler can communicate at run time with:

• Assembler programs • Programs compiled by any of the following FORTRAN, COBOL, or C compilers

Program Name Program Number

VS FORTRAN Compiler and Library 5748-F03 VS FORTRAN Library only 5748-LM3 VS FORTRAN Version 2 Compiler and Library 5668-806 VS FORTRAN Version 2 Library only 5668-805 VS COBOL II Compiler and Library 5668-958 VS COBOL II Library only 5668-940 OS/VS COBOL Compiler and Library 5740-CB1, LM1 I IBM C Compiler 5668-039 I IBM C Library 5668-040

I A PL/I procedure can invoke COBOL, FORTRAN, C, and Assembler routines, and I can be invoked by COBOL, FORTRAN, and C programs or routines. In addition, a I PL/I program can access data sets created by COBOL, FORTRAN, and C programs.

Communication between PL/I programs and programs written in different lan- I guages is specified by a CALL statement. A FORTRAN or C program can also be I invoked by a function reference. This support also lets PL/I programs pass data to I and receive data from FORTRAN, COBOL, and C programs.

The interlanguage communication facilities are obtained by specifying COBOL or FORTRAN as an option in an ENTRY, DECLARE, or PROCEDURE statement, or j specifying ASSEMBLER as an option in a DECLARE statement. C is not an option i for ENTRY, DECLARE, or PROCEDURE statements. For C programs, interlanguage I communication is obtained automatically.

Chapter 2. Major Features of PL/I 7 Facilities at Compiie-Time PL/I provides facilities at compile-time that include cross-compilation, interlan- guage communication options, and preprocessor facilities.

Cross Compilation All PL/I Version 1 programs assume there exists only a single interface to the MAIN procedure. (For example, the only parameter that the MAIN procedure can receive is the VARYING CHARACTER string.) For other interfaces (IMS/VS, for example), the programmer had to take overt action.

In Version 2, the compiler option, SYSTEM, allows a programmer to indicate under which system or subsystem the object code is to run. This option:

• Provides cross-system compilation capability. For example, programs com piled on a CMS system can be run on an MVS system.

• Accommodates special MAIN procedure interfaces prescribed by the various (sub)systems. For example. IMS/VS application programs will be assumed to receive pointers to program specification blocks (PSB) as parameters to the MAIN procedure rather than receiving a VARYING CHARACTER string.

• Eliminates the need for special link-editing considerations. For example, the PLICALLA ENTRY for IMS/VS application program link-edits is no longer needed.

The SYSTEM option supports MVS, TSO, CICS, IMS/VS, and CMS (with extended — and tokenized parameter list format). f T

It is still possible to run a program compiled for one system on another system, as long as the invoking program conforms to the parameter protocol that is expected by the PL/I program, as defined by the SYSTEM option used during compilation. For example, under CMS, the programmer can compile a program with SYSTEM(MVS) and run it under CMS using the LKED and OSRUN commands.

For compatibility on CMS, the OSDECK compiler invocation option will be accepted and translated to SYSTEM(MVS).

Compiler Options A number of options are available for controlling the compilation process. These options (shown below) are grouped into several categories according to function.

• Options that let programmers specify the form and content of Input records: Programmers can specify the form of input records through options that indi cate the source statement margins and sequence number (if any). The content includes graphic characters and compatibility with Version 1 code.

These options are: MARGINS, SEQUENCE, GRAPHIC, and CMPAT.

• An option that lets programmers specify compiler use of storage: Program mers can limit the amount of storage in a region that is available to the com piler.

This option is: SIZE.

• Options that specify the extent of compiler processing: Programmers can direct the Compiler to invoke the preprocessor, to stop processing after the

8 OS PL/I General Information preprocessor stage or after syntax checking, and to Invoke phases which produce highly efficient object code.

These options are:

- Preprocessor - MACRO and INCLUDE

- Prevent unnecessary processing - SYNTAX and COMPILE

- Global optimization - OPTIMIZE.

Options that specify the listings to be produced: Programmers have many options that control the types of output listings from the Compiler.

Programmers can specify that source program listings are to be suppressed, or if listed, the number of lines to list per page, whether to include the pre processor source, and how much to print at the terminal. Programmers can specify that a character be used as a source statement margin indicator, that the block level and do-group level list with each source statement, that the Compiler is to identify PL/I source statements by number, and to use that number in listings.

These source listing options are: SOURCE, LINECOUNT, INSOURCE, MARGINI, NEST, STMT, and NUMBER.

Programmers can direct the Compiler to produce other listings which give cross reference information about the source program and storage use. Pro grammers can indicate the level of messages they want listed and their format (including long form or short form, statement number or line number). They can request a listing of the generated object program and static storage. They can also control printing of the selected options.

These options are: - Cross reference and storage use listings - ATTRIBUTES, XREF, AGGRE GATE, ESD, and STORAGE - Message listings - FLAG and LMESSAGE

- Generated code listings - LIST and MAP - Option listing - OPTIONS.

Options that specify the type and content of modules produced: The Compiler optionally produces object modules. Programmers can indicate the target system or subsystem under which the object code will be running. Program mers can direct the Compiler to produce object listings in the form of 80-column card images from the preprocessor as well as from the Compiler, and to produce a NAME statement. Programmers can also direct the output of the preprocessor to a data set. These options are: OBJECT. SYSTEM, DECK, NAME, and MDECK.

Programmers can direct the Compiler to include code in an object module which, when processed, produces listings of statement frequency counts and flow-of-control information. In addition, they can direct the Compiler to insert program hooks and other information that enable monitoring of program proc essing. These options are: COUNT, FLOW, GOSTMT, GONUMBER and TEST. Programmers can also direct the compiler to generate code for processing run time attention interrupts, and for localizing imprecise interrupts. These options are: INTERRUPT and IMPRECISE.

Chapter 2. Major Features of PL/I 9 Preprocessor PL/I includes a preprocessor that allows programmers to include preprocessor statements in their code. The preprocessor responds to these statements and produces source code for the Compiler. The MACRO compile-time option calls the preprocessor. Some preprocessor functions are: Symbolic Replacement. Programmers can write code using abbreviations. The preprocessor replaces the abbreviations with new identifier names. Including External Code. The %INCLUDE statement can be used to retrieve code from external libraries. %INCLUDE can be used with or without the pre processor.

Generating Code. Programmers can write complicated computations with pre processor statements. The preprocessor translates the statements into code. Conditionally Including Code. A programmer might include specific code during development and testing, and exclude it from a production system.

Creating Reusable Procedures. Preprocessor statements can be used to write procedures to be included during subsequent preprocessor runs.

Large System Support To exploit the large storage capacity of MVS/XA, PL/I supports larger sizes for arrays, AREAS, and aggregates, and supports a larger block size for SYSLIB.

Fullword Array Subscripts In PL/I, arrays (including arrays of structures) can have bounds that are in the ' ^ range of -2^' (-2,147,483,648) thru 2^*-1 (2,147,483,647). The corresponding bounds under Version 1 were in the range -2^^ (-32,768) thru 2^®-1 (32,767).

Fullword array subscripts can be used to exploit the large amounts of storage available on MVS/XA.

This function necessitates some incompatibilities with PL/I Version 1 Release 5.1 object code. A compiler option, CMPAT, lets programmers maintain compatibility with Version 1 Release 5.1 or use new functions.

Large AREAs and Aggregates An AREA may now have a maximum size of 2,147,483,647 (2^'-1) bytes. In Version 1, the size was restricted to 16,777,200.

An aggregate (the sum of lengths of all member elements of an array or a struc ture) can now have a maximum size of 2,147,483,647 (2^^-1) bytes. For unaligned BIT arrays and aggregates that contain any unaligned BIT data (arrays or non- arrays), the maximum size is 268,435,455 (2^®-1) bytes.

The above numbers include any control information bytes that may be needed thus reducing the actual maximum allowable size.

This function can be used to exploit the large amount of storage available on MVS/XA.

This support also relaxes the restriction for aggregate descriptor size. (There was a restriction of 4K bytes.)

10 OS PL/I General Information Note: Such very large objects must be declared CONTROLLED or BASED and allo- cated in HEAP specified to be ANYWHERE (that is, above the 16-megabyte line).

This function necessitates some incompatibilities with PL/I Version 1 Release 5.1 object code. A compiler option, OMPAT, lets programmers maintain compatibility with Version 1 Release 5.1 or use new functions.

Large Block Size for SYSLIB Data Sets Programmers can block the partitioned data sets (PDS) used by the Compiler (for INCLUDE and MACRO)to a maximum size of 32,760 bytes. In Version 1, the maximum block size was 4,051 bytes.

The %INCLUDE statement identifies these data sets by specifying a DDNAME or a member name with a default DDNAME of SYSLIB.

Programming Features and Facilities PL/I gives programmers more control when creating applications. Its modular structure, variety of data types, and use of expression make programmers more productive. PL/I can support languages other than English, including languages that require DBCS.

MAIN Procedure Parameter Interface When PL/I programs are run, a parameter string can be passed from the PARM of the invoking command or JCL EXEC statement to the MAIN procedure. This parameter string consists of a run-time options string followed by a slash (/), fol lowed by a parameter string for the use of the MAIN procedure. The run-time options string and the parameter string are both optional. When a programmer did not wish to specify a run-time options string but did want to specify parameters to pass to the MAIN procedure in Version 1, the programmer had to specify the slash (/) as a delimiter to indicate the absence of run-time options. In Version 2, this is no longer necessary.

In addition, if a Version 1 MAIN procedure expected parameters other than a VARYING CHARACTER string, the programmer had to specify PLICALLA as the ENTRY point when link-editing such procedures. In Version 2, this is no longer necessary.

Version 2 provides a new option, NOEXECOPS, to remove the slash (/) and PLICALLA requirements. Programmers specify NOEXECOPS as one of the OPTIONS on the PROCEDURE statement. This option is valid only for MAIN proce dures and signifies that a run-time option string is not being specified and that any string being passed is strictly a parameter string for the use of the MAIN proce dure.

When specifying NOEXECOPS, the MAIN procedure can have one of the following as parameters: • A single parameter that is a VARYING CHARACTER string. In this case, PL/I accepts the parameter string as parameters for the MAIN procedure. PL/I sets up a descriptor for the VARYING string. If a slash (/) is specified as part of the string, PL/I interprets it as part of the parameter string being passed to the MAIN procedure and not as a delimiter.

Chapter 2. Major Features of PL/I 11 • One or more parameters that are not VARYING CHARACTER strings. In this case, PL/I accepts the parameters (passed by the calling system or program). No descriptors are set up.

The PLIXOPT string declaration allows the specification of run-time options even when using NOEXECOPS.

Accessing Load Modules In the Link Pack Area (LPA) When an application program uses the FETCH statement, the PL/I Library loads the requested module using the MVS LOAD macro. The MVS LOAD macro allows access to modules residing in system link pack areas (LPA and ELPA).

The search order for the load module is defined by MVS.

National Language Support PL/I supports American-English (uppercase-only character set and mixed-case character set) and Japanese.

The following features are translatable to other languages:

• Almost all run-time messages (those with the IBM and AQA prefixes)

• Panels and commands provided by the Interactive Test Facility (PLITEST).

The compile-time messages are not included in this support.

Double-Byte Character Set(DECS) Support PL/I enhancements facilitate processing of DECS (GRAPHIC) and mixed-character data as well as allow PL/I source programs to be in DECS and/or the Single-Eyte Character Set (SECS), rather than only in SECS.

Program Structure A PL/I program consists of one or more blocks of statements. The PL/I block struc ture lets programmers produce modular programs, because blocks can contain declarations that define variable names and control storage allocation. Thus, pro grammers can restrict the scope of a variable to a single block or a group of blocks, or can cause it to be known throughout the program.

Ey giving programmers freedom to determine the degree to which a block is self- contained, PL/I makes it possible to produce blocks that programs running in other environments can use freely, but still allows interaction in blocks where interaction is desirable.

There are two kinds of blocks: PROCEDURE blocks and BEGIN blocks. See Figure 4 for an overview of the PL/I block structure. A PROCEDURE block can nest within other blocks (and Is then called an internal procedure) or not nest (and is then an external procedure). Procedures are either subroutines or functions. External procedures can exist in auxiliary storage for dynamic loading into (and deletion from) real storage during program processing. BEGIN blocks are always within another block (and are always internal).

12 OS PL/I General Information BLOCK

PROCEDURE BEGIN

EXTERNAL SUBROUTINE INTERNAL INTERNAL FUNCTION

Figure 4. The PL/I Block Structure

Procedures (or BEGIN blocks) can invoke other procedures, and these procedures may either be compiled separately, or nested within the calling procedure and compiled with it. A procedure can be recursive, which means that it can be reacti vated from within itself or from within another active procedure.

PL/I provides a useful set of functions, called built-in functions (examples are ADD. MULTIPLY, and SUBSTR) and external subroutines (for example, the sort routines).

Data Types and Data Description A characteristic of PL/I that contributes to the range of applications for which it can r> be used is the variety of data types that can be represented and manipulated. These data types fall into two categories: problem data and program control data.

Problem data consists of the following data types:

Coded arithmetic data Numeric data, including DECIMAL FLOAT, DECIMAL FIXED, BINARY FLOAT. BINARY FIXED, REAL, COMPLEX, and PICTURE.

String data Bit or character-string data, including BIT, CHAR ACTER. and GRAPHIC.

Program control data consists of the following types:

Area data Reserves a specific area for BASED variables, whose locations may change within this area as the program

runs.

Entry data Declares symbolic entry points which are names of procedures within a PL/I program, or names of math ematical built-in functions.

Event data Allows overlap, for example, between a record- oriented input/output operation and processing of other statements in the procedure that initiated the operation.

File data Identifies files to a PL/I program to define how input and output statements access and process the data.

Label data Allows branching to symbolic label names (label data contains the addresses of statement labels).

Chapter 2. Major Features of PL/I 13 Locator data Points either to addresses in storage, or to locations relative to the start of an area variable.

Task data Controls the relative priorities of tasks.

Using these data types, PL/I provides features to perform the following:

• Assignments, with automatic conversion, if necessary, between data variables

• Element, array, and structure expressions

• Arithmetic, comparison, logical (Boolean), and string-manipulation operations

PL/I also provides:

• Built-in functions for mathematical and arithmetic computation, string manipu lation, manipulation of based and controlled storage, manipulation of arrays, multitasking, and error-handling

• Pseudovariables for computation, string manipulation, multitasking, and error- handling

• Facilities for creating programmer-defined functions.

The Compiler must be able to determine, for every name used in a program, the complete set of attributes associated with that name. The programmer can specify these attributes explicitly by means of a DECLARE statement. The Compiler may determine all or some of the attributes by context, or a partial or complete set of attributes may be defaulted. The programmer can specify which attributes are to be applied by default, or the Compiler can be allowed to determine them.

Default Assumptions If the programmer does not specify all attributes associated with a name or all options permitted in a statement, the Compiler assigns attributes or options. This default action has two main consequences. First, it reduces the amount of declara tions and other program writing required. Secondly, it makes it possible to teach and use subsets of the language for which the programmer does not know all pos sible alternatives, or even that alternatives exist.

The programmer can use the DEFAULT statement to specify the defaults.

As an option, the Compiler produces an attribute listing that contains the identifiers used in a PL/I source program, plus a complete list of attributes specified either by explicit, contextual, or implicit declarations, or by application of default rules. The programmer can use this listing to check the attributes.

Storage Allocation PL/I goes beyond most other languages in flexibility of storage allocation. There are four different storage classes: AUTOMATIC, STATIC, CONTROLLED, and BASED. Programmers can use these classes to determine when storage is allo cated. In general, the default storage class in PL/I is AUTOMATIC. PL/I allocates this class of storage whenever it activates the block in which the variables are declared. At that time, PL/I calculates the bounds of arrays and the lengths of strings. PL/I frees AUTOMATIC storage for reuse whenever control leaves the block that allocated the storage.

Programmers can declare STATIC storage. PL/I allocates STATIC storage when the program is compiled. Programmers can declare storage as CONTROLLED, in

14 OS PL/I General Information Chapter 5. System Considerations

This chapter describes the operating systems under which PL/I Version 2 runs.

Operating Systems Unless otherwise stated, the PL/I Optimizing Compiler operates under the oper ating systems, and with the subsystems, listed below. The Compiler also operates under any subsequent versions, releases, and modification levels of these systems:

• MVS/System Product Version 3 Release 1

• MVS/System Product Version 2 Release 2

• MVS/System Product Version 1 Releases

• VM/XA System Product Release 1 with bi-modal CMS

• VM/System Product Version 1 Release 5

• VM/System Product Systems Facility Release 2 with CMS Release 4

• TSO/E

The PL/I Version 2 Library and the generated object code run under the systems mentioned above, as well as under the following systems and subsystems:

• IBM DATABASE 2 Version 1 Release 3

• IMS/VS Version 1 Release 3

• CICS/VS Version 1 Release 7

• ISPF Version 2 Release 1. Version 2 Release 2 is required for DBCS only.

PLITEST runs in all of the above environments except:

• CICS/VS • IMS/VS.

In addition, your site can use the Compiler with the following licensed IBM pro grams:

Program Name Program Number

VS FORTRAN Version 1 Release 4.1 Compiler and Library 5748-F03 VS FORTRAN Version 1 Release 4.1 Library only 5748-LM3 VS FORTRAN Version 2 Release 3 Compiler and Library 5668-806 VS FORTRAN Version 2 Release 3 Library only 5668-805 VS COBOL II Version 1 Release 2 Compiler and Library 5668-958 VS COBOL II Version 1 Release 2 Library only 5668-940 OS/VS COBOL Version 2 Release 4 Compiler and Library 5740-CB1, LM1 DFSORT Release 10 5740-SM1 DFSORT/CMS Release 1 5664-325 IBM C Compiler 5668-039 IBM C Library 5668-040 Batch Terminal Simulator (BTS) 5668-948

Chapter 5. System Considerations 35 When programs containing DBCS identifiers are compiled under MVS, the DBCS Ordering Support product (5665-360) is required.

Compiling under MVS The minimum space that the Compiler requires is 256K bytes of virtual storage.

The processor must have the timer feature, which a programmer must specify at the time of system generation.

At compile time and during subsequent link-editing, PL/I requires appropriate devices for the following types of input and output:

• Source program input

• Printed listings

• Object module in relocatable format

• Object module in relocatable card-image format.

Figure 5 shows the DDNAME and permitted device types associated with a partic ular class of compiler input or output.

Function DDNAME Device Type When Required

Input SYSIN DASD Always Magnetic Tape Card reader

Print SYSPRINT DASD Always Magnetic tape Printer

Output to Linkage SYSLIN DASD When link-editing Editor Magnetic tape follows compilation in the same job.

Output to Linkage SYSPUNCH DASD When link-editing Editor (card deck) Magnetic tape takes place in a sub Card Punch sequent job.

Spill SYSUT1 DASD When adequate main storage is not avail able.

Source SYSLIB DASD When either the Statement MACRO or INCLUDE Library option is used.

Figure 5. Compiler Input/Output Devices (MVS)

Working storage requires direct-access storage space only when adequate main storage is not available. The required amount depends upon the size of the source program and the amount of main storage available to the Compiler. This auxiliary storage uses the data set identified by SYSUT1. The preprocessor uses this data set as does the %INCLUDE option, when used in a source program.

36 OS PL/I General Information ^ Running PL/I Programs under MVS The storage requirements, either real or virtual, for processing a PL/I program compiled by the Compiler depend on the size and content of the source program. Programmers can reduce real storage requirements either by using the MVS control program or by using overlay facilities for handling segmented object pro grams.

The machine must use the decimal instruction set. If object programs explicitly use extended floating point calculations, the OS Extended Precision Simulator automatically simulates the extended floating point instruction set (if not present on the machine).

Some programs require facilities that a programmer must specify when generating the system. If your programs require timing information, a programmer must specify use of the timer feature when generating the system. To use the DELAY statement, a programmer must specify the ability to handle the interval timer from the application program when generating the system. To use the DATE built-in function, a programmer must specify the inclusion of date facilities into the oper ating system control program when generating the system.

The Optimizing Compiler creates object code that makes use of the operating system data management facilities. These facilities depend on the type of I/O statements used, and can include the following:

• Basic Sequential Access Method (BSAM) • Queued Sequential Access Method (QSAM) • Basic Indexed Sequential Access Method (BISAM) • Queued Indexed Sequential Access Method (QISAM) • Basic Direct Access Method (BDAM) • Telecommunication Access Method (TOAM) • Virtuai Storage Access Method (VSAM).

Running PL/i Programs under IMS/VS The PLITDLI and ASMTDLI calls to IMS/VS generate a call to a PL/I Library routine. If a programmer specifies the PL/I options SPIE or STAE, PL/I provides for appro priate error handling. If a programmer specifies PL/I options NOSPIE and/or NOSTAE, the PL/I error handling is disabled.

IMS/VS runs as a job step task. Consequently, attaching the region controller to a program is the responsibility of the programmer. Whenever PL/I multitasking is used, all tasks, even the apparent main task, operate as subtasks to a PL/I control task. PL/I tasking is, therefore, not allowed in an IMS/VS program.

Running PL/i Programs under CiCS/VS Programmers can use PL/I in conjunction with CICS/VS to write application pro grams for CICS/VS. In this case, CICS/VS provides facilities to the PL/I program that are normally provided by the operating system. These facilities include most ^ data management facilities and all job and task management facilities.

Chapter 5. System Considerations 37 Compiling under VM/OMS The Compiler operates under the Conversational Monitor System (CMS) of the Virtual Machine Facility/System Product (VM/SP) and needs 512K bytes of virtual storage.

For operation under CMS, the Compiler requires the same features that are required under the operating system. The Compiler can reside on any disk storage device that is supported by CMS. Devices are required at compilation time for the data sets listed in Figure 6.

Function File Type Device Type When Required

Input PLIOPT DASD Always Magnetic tape Card reader

Print LISTING DASD Always Magnetic tape Printer

Load TEXT DASD When object module Text Deck Magnetic tape is to be created.

Spill SYSUT1 DASD When adequate main storage is not avail able.

Preprocessor MACLIB DASD When %INCLUDE is %INCLUDE used from CMS disk.

Figure 6. Device Requirements for Compiler Data Sets(CMS)

Running PL/i Programs under VM/GMS PL/I object programs to be run under CMS cannot use the following facilities:

• Multitasking • Teleprocessing (including TCAM data management facility and the TRANSIENT file attribute)

• INDEXED files (except for use with VSAM)

• The PL/I sort facility (PLISORT)

• The PL/I checkpoint/restart facility (PLICKPT)

• ASCII data sets

• The BACKWARDS attribute for magnetic tape files

• Spanned (VS-format or VBS-format) records

• Some features of REGIONAL files (BDAM)

• The PL/I FETCH and RELEASE statements.

These restrictions do not apply to programs compiled under CMS and run under MVS.

38 OS PL/I General information For further information, see the OS PUI Version 2 Programming Guide.

CMS uses DOS/VS VSAM and access method services to support VSAM. However, OS/VS VSAM users can access their VSAM data sets; CMS maps OS/VSAM macros, in a PL/I program compiled under OS or CMS, into DOS/VS format at run time to provide the requested VSAM function. For further details, see OS PUI Version 2 Installation and Customization under CMS. For details of the use of VSAM under CMS,see VM/SP CMS for Systems Programming, SC24-5286.

Related Products and Publications Following are some of the publications for related licensed programs that program mers can use with the Compiler:

• DB/DC Data Dictionary General Information. Program Products 5740-XXF(CS/VS) and 5746-XXC(DCS/VS), GH20-9104: DB/DC Dictionary is an IMS/VS application for data base design, maintenance, and administration. Through Data Dictionary programs, the programmer can create a central, organized collection of definitions of data resources.

• CS/VS Graphic Subroutine Package (GSP) for FORTRAN IV, COBOL, and PL/I, GC27-6973: With this product, PL/I programmers can write graphics programs for display units under control of OS/VS.

• SIMPL/I (Simulation Language Based on PL/I) Program Reference (Licensed Program 5734-XXB), SH19-5060: SIMPL/I is an extension of PL/I in the form of a discrete simulation language containing PL/l-like statements and other fea tures. SIMPL/I lets programmers implement the PL/I language to design, test, and run simulation models. Applications for discrete simulation occur in such areas as manufacturing, finance, engineering, and management.

• Procedure Library-Mathematics (PL-MATH) General Information (Licensed Program 5734-XM3), GH20-0854: PL-MATH is a set of basic computational pro cedures to help the programmer develop a PL/I procedure library. It evolved from the mathematics portion of the Scientific Subroutine Package PL/I (SSP-PL/I).

• Mathematical Programming System Extended/370 (MPSX/370): General Infor mation (Licensed Program 5740-XM3)(CS/VS) and 5746-XM2(DCS/VS), GH19-1090: This mathematical programming system includes Extended Control Language (ECL), which is based on PL/I, and permits processing of advanced mathematical programming applications and integrated management science applications. EGL requires a PL/I compiler.

• PL/I in the CICS/VS Environment, G320-6022: Describes in detail the enhanced interface to CICS/VS supplied by OS PL/I Optimizing Compiler and libraries, Release 3.0. It also addresses issues related to the high level language inter face for OS/VS versions of CICS/VS, Release 1.3.

Three CICS manuals describe the use of PL/I for application programming. They

are:

• Customer Information Control System/Virtual Storage (CICS/VS) Application Programmer's Reference (Command Level), SC33-0077

• Customer Information Control System/Virtual Storage (CICS/VS) Application Programmer's Reference (Macro Level), SC33-0079

Chapter 5. System Considerations 39 • Customer Information Control System/Virtual Storage (CICS/VS) System Pro grammer's Guide, SC33-0070.

Five IMS/VS manuals describe the use of PL/I for application programming. They

are:

IMS/VS Version 1 General Information, GH20-1260

IMS/VS Version 1 Primer, SH20-9145

IMS/VS Version 1 Application Programming, SH20-9026

IMS/VS Version 2 General Information, GC26-4180

IMS/VS Version 2 Application Programming, SC26-4178.

Four IBM DATABASE 2(DB2) manuals describe the use of PL/I for application pro gramming. They are:

• IBM DATABASE 2 Application Programming Guide for CICS/OS/VS Users, SC26-4080

• IBM DATABASE 2 Application Programming Guide for IMS/VS Users, SC26-4079

• IBM DATABASE 2 Application Programming Guide for TSO Users, SC26-4081

• IBM DATABASE 2 Version 2 Application Programming Guide, 8026-4377.

The following books describe the 0 programming language:

• IBM C Language /Reference Manual, 8009-1128

• Systems Application Architecture C Reference, 8026-4353

• IBM C/370 Reference Summary, 8X09-1088

• IBM C/370 General Information, GO09-1281

• IBM C/370 Diagnosis Guide and Reference, LY09-1802

• IBM C/370 User's Guide, 8009-1263.

40 OS PL/I General Information Appendix A. Summary of PL/I Version 2 Features

OS PL/I Version 2 contains enhancements that can make PL/I programmers more productive, PL/I programs perform more efficiently, and PL/i easier to use.

PL/I Version 2 Release 2

The following are the improvements to PL/I for Version 2 Release 2.

• PL/I now provides transparent interlanguage communication with IBM C. PL/I programmers can call C programs in the same manner that they call PL/I pro cedures, and vice versa.

• Improved ERROR handling. The Error on-unit will now get control for out of storage (80A/878) ABENDS and out of space (B37,D37) ABENDS.

• GIGS return code checking is enhanced.

• A new user exit allows programmers to write user exits in PL/I and G.

• PLITEST enhancements

— Ability to list structures

— Ability to use mathematical and storage built-in functions

• SYSTEM(IMS) compile-time option enhancement. The definition of valid parameters when compiling under the SYSTEM(IMS) compile-time option has been enhanced so that only POINTER type parameters are accepted.

• Support for IBM INSPEGT for C and PL/i. IBM INSPECT provides:

— Functional compatibility with PLITEST

— Capability to test G and/or PL/I programs

For more information, see IBM INSPECT for C and PUI: General Informa tion. GG26-4526.

PL/I Version 2 Release 1

Productivity Enhancements The following enhancements improve the productivity of programmers who develop PL/I applications. These enhancements let programmers develop more reliable applications in less time.

Interactive Test Facility — PLITEST: The Interactive Test Facility, PLITEST, extends PL/I testing capabilities. PLITEST:

• Presents a command interface that is consistent with PL/I and that requires programmers to learn only a few new principles

• Enables the programmer to examine, monitor, and control program processing

Appendix A. Summary of PL/I Version 2 Features 41 • Provides significant function with little advance planning and with little increase in object program size

• Provides online help for PLITEST commands.

The Interactive Test Facility allows interactive testing in TSO and CMS. It allows batch testing in MVS and CMS. Testing in IMS is allowed via the Batch Terminal Simulator (BTS).

The programmer can control the level of services that PLITEST can perform via: • A compile-time option, TEST, to specify the extent of program information and the frequency of hooks to be generated in the object program. • A run-time option, TEST, to select the source of commands and to specify con ditions for which PLITEST should be invoked before program processing.

Improved Diagnostics: Diagnostics produced when programs call subroutines that are not link-edited (and are therefore missing), indicate (when possible) the point of call rather than a wild point of failure.

Performance Enhancements These enhancements provide performance improvements during the processing of PL/I programs.

Preinitializable Programs: This feature allows a calling program or subsystem to preinitialize the PL/I environment, incurring initialization and termination overhead only once, and not at every invocation of the PL/I program.

The calling program can control initialization and termination, providing:

• An easier way of initializing and maintaining the PL/I environment without special programming. It also provides a reliable interface between PL/I and the assembler language programs.

• Continuity between invocations of the same program, thus allowing program mers to write exits in PL/I. • Reduced processing time for repetitive calls of the same program, because it avoids initialization and termination overhead for such calls. This can show a significant reduction in response time in on-line systems and programs.

Reentrant Object Code under CMS: The function of the DMSIBM module is reim- plemented to let PL/I programs be reentrant, which allows sharing of PL/I pro grams by multiple users.

While this may not provide any performance improvement for a single user, it can increase overall system throughput.

Write Validity Checking Made Optionai: The write validity checking feature, which was standard in OS PL/I Version 1 Release 5.1, is now optional. If a programmer still requires this checking, the programmer must specify it in a JOL parameter.

42 OS PL/I General Information Extended Architecture (XA) Enhancements These enhancements exploit the large amounts of storage available in MVS/XA, and allow for easier programming.

Fuliword Array Subscripts: Array bounds may now be in the range -2^^ (-2,147,483,648) through +2^^-1 (+ 2,147,483,647). The associated built-in functions (such as LBOUND) now return FIXED BIN(31) values.

AREA and Aggregate Sizes: An AREA may now have a maximum size of 2,147,483,647 (23^-1) bytes.

An aggregate may now have a maximum size of 2,147,483,647 (2^'-1) bytes. For unaligned BIT arrays and aggregates that contain any unaligned BIT data (arrays or non-arrays), the maximum size is 268,435,455 (2^®-1) bytes.

The above numbers include any control information bytes that may be needed, thus reducing the allowable maximum size.

Accessing Load Modules In the Link Pack Area (LPA): PL/I FETCH and other dynamic LOADs done by the PL/I Library no longer use BLDL, thus allowing the system to search the system link pack areas for the load modules. This provides performance Improvements for both individual programs and for the system.

Large Block Size for SYSLIB: The partitioned data sets (PDS) that the Compiler uses (for either MACRO or INCLUDE statement processing) can be blocked to a maximum size of 32,760 bytes. In Version 1, the maximum block size was 4,051 bytes.

Usability Enhancements These enhancements make PL/I Version 2 easier to use:

National Language Support: PL/I supports American-English (uppercase-only character set and mixed-case character set) and Japanese.

Enhanced Double-Byte Character Set(DBOS) Support: This support introduces many enhancements that facilitate processing of GRAPHIC and mixed-character data and allows the source of the PL/I program to be In DBCS and/or the Single- Byte Character Set (SBCS), rather than only in SBCS.

BX Bit String Constant: This function allows the writing of bit string constants in hexadecimal format, such that each character (0-9 and A-F) represents 4 bits.

X Character String Constant: This function allows the writing of character string constants in hexadecimal format, such that each pair of characters (0-9 and A-F) represents one character of data.

Implementation of the DELAY Statement In VM/CMS: This function removes the need to use an assembler language module to suspend the processing of an appli cation for a specific time.

Enhanced MAIN Procedure Parameter Interface: This function allows passing string parameters to the MAIN procedure without specifying (or Indicating absence of) PL/I run-time options.

Appendix A. Summary of PL/I Version 2 Features 43 Interface improvements for All (Sub)Systems: A new compiler option, SYSTEM, lets the programmer specify the target operating environment (of the generated object code) and the interface parameters for the MAIN procedure. It also supports cross-compilation.

REPORT Output: REPORT output now automatically routes to the SYSPRINT file when the PLIDUMP file is not present.

PLIDUMP Output: PLIDUMP output is now compressed, removing identical consec utive lines (as occurs in MVS dumps).

Run-Time User Exit: PL/I Version 2 lets programmers write exit routines supported through a user exit and/or use an IBM-supplied user-exit routine.

44 OS PL/I General Information Appendix B. Migrating to PL/I Version 2 Release 2

PL/I Version 2 Release 2 provides source, object, and load module compatibility with programs processed by PL/t Version 2 Release 1.

Both releases of PL/l Version 2 provide source and object compatibility with pro grams processed by PL/I Version 1 Release 5.1. \ft/here the program is using new features that are incompatible, the compiler option, CMPAT, lets the programmer control the level of incompatibility.

To use an PL/I Version 2 function, the programmer can modify and recompile an existing procedure with Version 2. Some cases may require that the MAIN proce dure be recompiled.

If a programmer recompiles any procedure in any load module (MAIN or FETCHed), then all load modules must be link-edited again, using the PL/I Library Version 2, Release 1 or Release 2, to include new library modules.

With the above exceptions, different release levels of PL/I are compatible at run time, provided that the release number of the PL/I Library is equal to or greater than the release number of the PL/I Optimizing Compiler.

Coexisting with the PL/I Checkout Compiler The object code produced by the PL/I Version 2 Optimizing Compiler cannot coexist with the object code produced by the PL/I Checkout Compiler (Checker).

PL/I programs that do not use the features offered by the PL/I Version 2 Optimizing Compiler can be compiled and tested with the PL/I Checker.

A programmer can compile PL/I source code on either the Version 2 Optimizing Compiler or on the Checkout Compiler. Each compiler checks syntax on all the code and generates syntax messages where necessary. During compilation, however, the Checkout Compiler creates object code only for the source code it supports. Simiiarly, the PL/l Version 2 Optimizing Compiler creates object code only for the source code it supports.

With Version 1 of the Optimizing Compiler, programmers can link-edit checker object code together with object code compiled by the Optimizing Compiler in the same load module. This cannot be done with Version 2; all object modules in a load module must have been created by the Optimizing Compiler. The PL/l Version 2 Library does not accept load modules containing mixed Checkout Com piler and Optimizing Compiler object code, as did Version 1.

Appendix B. Migrating to PL/l Version 2 Release 2 45 Index

COBOL communication 1,7 Preprocessor Statements commercial programs %INCLUDE 10, 11 effects of optimization 23 common constants elimination of 30 common control data access method services 39 elimination of 32 access methods required 37 common expression accessing load modules 12 definition 28 overview of enhancements 43 elimination of 28 aggregate size 10 communicating with other languages 1, 7 overview of enhancements 43 compatibility 10 aggregates 10, 16, 20, 43 between OS and DOS 25 allocating storage 1, 14,36,37,38 between releases of PL/I 24 AREA size 10 compilation overview of enhancements 43 IMS/VS 37 array 16,30,32 input/output devices required 36 assignment optimized 32 machine requirements (MVS) 36 overview of enhancements 43 complle-tlme facilities 1,8 assembler communication 1,7 compile-tlme options 1,5,8 assignment cross compilation 8 array and structure, optimized 32 interlanguage communication option 1, 8 attributes 14 optimizing compiler 1,23,27,32,37 AUTOMATIC storage 11,14, 20 preprocessor 1, 8, 10, 36, 38 compile-tlme messages 1, 9 B compile-tlme options 1,5,8 %INCLUDE 10, 11 BASED Storage 11. 14, 17, 20 AGGREGATE 8 basic direct access method (EDAM) 37 basic indexed sequential access method (BISAM) 37 ATTRIBUTES 8 block size of PDS 11 basic sequential access method (BSAM) 37 CMPAT 8, 10 block size 11 COMPILE 8 block structure 12 COUNT 8 books, OS PL/I Version 2 iv DECK 8 branch instructions ESD 8 base register allocation 30 FLAG 8 built-in functions FLOW 8 In-line code 33 fullword array subscripts 10,43 BX bit string constant GONUMBER 8 overview of enhancements 43 GRAPHIC 8 IMPRECISE 8 INCLUDE 8 C communication 1,7,41 INSOURCE 0 user exit 18 INTERRUPT CALL statement 7 LINECOUNT checkpoint/restart 19 LIST 8 CICS/VS LMESSAGE facilities provided 37 MACRO 8 publications 40 MAP 8 running PL/I programs 37 MARGINI 8 using COUNT 24 MARGINS 8 using FLOW 24 MDECK 8 CMPAT 10 NAME 8 NEST 8

Index 47 compile-time options (continued) data types (continued) OBJECT 8 program control data (continued) OPTIMIZE 8 task 13 OPTIONS 8 data-directed I/O 1,20 SEQUENCE 8 DATABASE 2 SIZE 8 publications 40 SOURCE 8 DATE built-in function 37 STMT 8 machine requirements 37 STORAGE 8 debugging 1,23 SYNTAX 8 counting PL/i statement use 8, 9, 17,18 SYSTEM 1,8, 11,38 data-directed stream i/0 1, 20 TEST 5. 8, 41 diagnostics 23 XREF 8 interactive test facility (PLITEST) Compiler ON-units 24 main features 23 tracing program flow 1,18 optimization 23 DECLARE statement 7, 14 speed 23 defactorization 30 use with CMS 38 DEFAULT data attributes 14 concurrent active procedures 1, 6 DELAY 37 condition-handiing 24 overview of enhancements 43 conditionaiiy including code 1, 8. 11 devices constant exponents required for compilation 37 replacement of 30 required for link-editing 37 constant expressions diagnostics 1,9,23 replacement of 30 overview of enhancements 42 constant multipliers severity levels 23 replacement of 30 DO statement CONTROLLED storage 11,14,18,20 special case code 32 controlling compatibility 10 documentation, OS PL/I Version 2 iv conversational monitor system (CMS) double-byte character set 12 compilation requirements 38 overview of enhancements 43 Optimizing Compiler restrictions 38 dumps storage devices 38 specifying 23 conversions in-line code 33 count of statements 23 aids 23 edit-directed transmission counting PL/i statement use 1, 17, 23 match format list with data list 34 cross compilation 1, 8, 11, 38 efficient object code 1, 23, 27, 32, 37 loops 29, 31 elimination of common constants 30 D elimination of common control data 32 data 14 enhanced parameter interface, MAIN 1, 8,11 data aggregates 10, 16, 20, 43 NOEXECOPS 11 data list overview of enhancements 43 matched with format list 34 enhancements, OS PL/I Version 2 v data management facilities 37 ENTRY statement 7 data set organization 20 execution-time options 17, 18,41 data types 1 BASED 17 problem data CONTROLLED 17 coded arithmetic data 13 COUNT 17 string data 13 FLOW 17 program control data HEAP 17 area 13 iSAINC 17 entry 13 ISASIZE 17 event 13 REPORT 17 file 13 SPIE 17 label 13 STAE 17 locator 13

48 OS PL/I General Information execution-time options (continued) TASKHEAP 17 I/O facilities 2 TEST 17,41 IBMBINT user exit 18 expression IBMBXITA user exit 18 transfer out of loop 31 IF statement expressions 1, 15,28 branching optimized 30 extended architecture 1, 10 improving efficiency by compound expression 29 extended architecture enhancements IMS/VS overview of enhancements 43 processor time 37 accessing ioad modules in LPA 43 publications 40 AREA and aggregate sizes 43 system requirements 37 fuilword array subscripts 43 IMS/VS, running PL/I programs 37 large block size for SYSLIB 43 in-line code built-in functions 33 conversions 33 facilities at compite-time 1,8 record I/O 33 string manipulation 33 compile-time options 1,5,8 including code 1. 8, 11 cross compilation 8 initialization of arrays and structures 32 Interlanguage communication option 1, 8 input/output 20 optimizing compiler 1,23,27,32,37 devices required for compilation 37 preprocessor 1, 8, 10, 36, 38 devices required for link-editing 37 facilities at run-time input/output, stream 1,20 options 17, 18 installation and customization under CMS manual, OS facilities, input and output 2 facilities, operating system 2 PL/I Version 2 iv installation and customization under MVS manual, OS features, summary 41 PL/I Version 2 iv FETCH 12 Interactive System Productivity Facility (ISPF) FLOW 18 interactive test facility 1, 3, 5, 6, 36, 41 flow tracing 1,18,23,24 batch testing facilities 41 format list compile-time test option 5 matched with data list 34 interactive test facility 3 FORTRAN communication 1, 7 operating system requirements 36 frequency count of statements used 1. 17, 23 overview of enhancements 41 fullword array subscripts run-time test option 6 overview of enhancements 43 interface improvement for subsystem function modularity 1,3 overview of enhancements 44 functional enhancements, OS PL/I Version 2 v interface to subsystems 1,8, 11,38 interianguage communication option 1, 7 interrupts graphic character data 12 processing code generation 18 introduction to OS PL/I ISAINC 18 H ISASIZE 18 handling PL/l conditions from programs 1, 24* HEAP 18 high-level language 1, 36, 37, 38 K high-level language user exit 18 key handling for REGIONAL data sets 33 hooks

language reference manual, OS PL/I Version 2 IV language statements 8 GALL 7 DECLARE 14 DEFAULT 14 ENTRY 7 FETCH 12

index 49 language statements (continued) multiplication operations PROCEDURE 7, 11 optimization by repeated addition 29 language support 20 multitasking 1,6 large block size MVS 36, 37 overview of enhancements 43 large block size for SYSLIB overview of enhancements 43 N large system support 1, 10 national language support 12 library subroutines overview of enhancements 43 compatibility 24 NOEXECOPS 11 initialization routines 34 logically grouped for efficiency 34 library, PL/I 2 0 overview of library routines 2 ON-units 1,24 licensed program specifications iv operating system link pack area 12 checkpoint/restart 19, 38 overview of enhancements 43 data base 19 link-editing data management 37 input/output devices required 36 environments 35 load modules, accessing 12 sorting 19 overview of enhancements 43 operating system facilities 2 loops optimized, format list with data list 34 modification of control variable 29 optimizing compiler 1, 23, 27, 32, 37 recognition of optimization purposes 31 loops 29, 31 special case code 32 options at compile-time 1 transfer of expressions 31 %INCLUDE 10, 11 undesired effect of optimization 31 block size of PDS 11 use of registers for modified values 34 CMPAT 10 LPA 12 fuliword array subscripts 10, 43 overview of enhancements 43 SYSTEM 1,8,11,38 TEST 41 n options at run-time 17, 18 M TEST 41 machine independence 1, 36, 37, 38 options of PROCEDURE 11 MACRO 10, 11 ORDER option MAIN, enhanced parm interface 1, 8. 11 inhibits loop optimization 31 NOEXECOPS 11 optimization and register allocation 34 overview of enhancements 43 OS PL/I Version 2 manuals, OS PL/I Version 2 iv publications iv messages 1,9,23 overview of OS PL/I length of 23 severity levels 23 statement numbers 23 messages and codes book, OS PL/I Version 2 iv parameter interface of MAIN, enhanced 1 migrating to PL/I version 2 PDS block size enhancement for INCLUDE and CMPAT 45 MACRO 11 controlling incompatibility 45 performance enhancements modifying existing procedures 45 overview 42 PL/I checkout compiler 45 preinitializable programs 42 recompiling an existing procedure 45 reentrant object code under CMS 42 release level numbers 45 write validity checking made optional 42 service level numbers 45 PL/I block structure 12 mixed character data 12 PL/I checkout compiler, migration considerations modifying loop control variables 29 checking syntax 45 modularity of PL/I functions 1,3 compiling and testing 45 moving expressions out of loops language supported 45 undeslred effect 31 load modules 45 PL/I language statements 8 CALL 7

50 OS PL/I General Information PL/I language statements (continued) programming support (continued) DECLARE 14 overview (continued) DEFAULT 14 interactive test facility 41 ENTRY 7 storage allocation 1,14,36,37,38 FETCH 12 use of expressions 1, 16, 28 PROCEDURE 7,11 publications 40 PL/I library 2 publications, OS PL/I Version 2 iv overview of library routines 2 publications, related products and 39 PL/I user exit 18 PLICALLA 11 PLIDUMP 23 Q overview of enhancements 44 queued indexed sequential access method (QISAM) 37 PLIDUMP built-in function queued sequential access method (QSAM) 37 flow trace 23 statement frequency counting 23 PLITEST 1,3.5.6,36,41 R batch testing facilities 41 record I/O compile-time test option 5 in-line code 33 interactive test facility 3 record-oriented input/output 20 operating system requirements 36 redundant expression overview of enhancements 41 definition 29 run-time test option 6 elimination 29 PLITEST guidance and reference manual, OS PL/I reentrant object code under CMS Version 2 iv overview of enhancements 42 PLIXOPT 11 reference summary manual, OS PL/I Version 2 iv preinitiaiizable programs REGIONAL data sets overview of enhancements 42 key handling optimized 33 preprocessor 1,8, 10.36,38 register usage for loops 34 MACRO 10,11 related products and publications 39 problem determination guide, OS PL/I Version 2 v related products publications 40 PROCEDURE OPTIONS 11 REORDER option PROCEDURE statement 7 effect on register allocation 34 processing for loop optimization 31 machine requirements (MVS) 37 REPEAT option processor time (IMS/VS) 37 in-line code for 33 restrictions under CMS 38 replacement 1, 10, 30 productivity enhancements 1,41 REPORT 18 datatypes 13 overview of enhancements 44 interface to subsystems 1,8,11,38 run-time machine independence 1,36,37,38 speed 23 MAIN, enhanced parameter interface 1,11 run-time facilities modularity of PL/I functions 1 options 17, 18 overview 41 run-time messages 1,9,23 improved diagnostics 42 severity levels 23 interactive test facility 41 run-time options 17, 18 storage allocation 1, 14,36,37,38 BASED 17 use of expressions 1, 16,28 CONTROLLED 17 program branch code 30 COUNT 17 Program Development Facility (PDF) FLOW 17 program structure 12 HEAP 17 programmer's guide, OS PL/I Version 2 iv ISAINC 17 programming support 1, 41 ISASIZE 17 datatypes 13 REPORT 17 interface to subsystems 1. 8. 11, 38 SPIE 17 machine independence 1, 36, 37, 38 STAE 17 MAIN, enhanced parameter interface 1,11 TASKHEAP 17 modularity of PL/I functions 1 TEST 6,17,41 overview 41 improved diagnostics 42

Index 51 run-time user exit 17, 18, 19 SYSUT1 data set use 36 overview of enhancements 44 running PL/I with no run-time options 11 T TASKHEAP 18 S telecommunication access method (TCAM) 37 SNAP option TEST 18 flow trace 24 testing aids 1 specifying limits 24 counting PL/I statement use 8, 9, 17, 18 space requirements data-directed stream I/O 1, 20 under MVS 36 diagnostics 23 under VM/CMS 38 interactive test facility (PLITEST) special case for DO statement 32 ON-units 24 specifying data attributes 7. 14 tracing program flow 1, 18 speed tracing program flow 1, 18, 23, 24 ccmpiiation 23 types of data 1 SPIE 18,37 problem data STAE 18,37 coded arithmetic data 13 statement frequency counting 24 string data 13 statement tracing 1, 18, 23, 24 program control data statements 8 area 13 CALL 7 entry 13 DECLARE 14 event 13 DEFAULT 14 file 13 ENTRY 7 label 13 FETCH 12 locator 13 PROCEDURE 7, 11 task 13 STATIC storage 11, 14, 20 types of optimization 27 storage 1,14.36,37,38 storage allocation 14 storage, AUTOMATIC 11, 14, 20 u storage, BASED 11, 14, 17, 20 UNSPEC built-in function storage, CONTROLLED 11, 14, 18, 20 machine independence 15 storage, STATIC 11, 14,20 usability enhancements structure overview of enhancements 43 assignment optimized 32 BX bit string constant 43 initialization optimized 32 DELAY (VM/CMS) 43 structure and array assignments 32 double-byte character set 43 structure, block 12 enhanced parameter interface for MAIN proce structures 16 dure 43 subroutine library 2 GRAPHIC characters 43 overview of library routines 2 interface improvements for subsystems 44 subscript Japanese 43 common expressions 28 mixed-character data 43 subsystems interface national language support 43 overview of enhancements 44 PLIDUMP, alternate output file 44 summary of features 41 PLIDUMP, compression 44 symbol table REPORT output 44 symbolic replacement 1, 10, 30 run-time user exit 44 SYSLIB 11 SYSPRiNT output of REPORT 44 SYSTEM 1,8,11,38 use of expressions 1, 15,28 system requirements user exits 17, 18. 19 for IMS/VS processing 37 overview of enhancements 44 for MVS compilation 36 for MVS processing 37 for VM/CMS compilation 38 systems and subsystems interface 44

52 OS PL/I General Information VARYING CHARACTER string 11 virtual storage access method (VSAM) 37 object programs 37 supported under CMS 39 VM/CMS 38 compiling PL/I programs 38

W write validity checking, optional overview of enhancements 42

X XA enhancements overview of enhancements 43 accessing load modules in LPA 43 AREA and aggregate sizes 43 fullword array subscripts 43 large block size for SYSLIB 43 XA support 1, 10

Index 53 OS PL/I Version 2 Reader's General Information Comment Form GC26-4313-3

This manual Is part of a library that serves as a reference source for system analysts, programmers, and operators of IBM systems. You may use this form to communicate your comments about this publication, its organization, or subject matter, with the under standing that IBM may use or distribute whatever information you supply in any way it believes appropriate without incurring any obligation to you. Your comments will be sent to the author's department for whatever review and action, if any, are deemed appro priate.

Note: Do not use this form to request IBM publications. If you do, your order will be delayed because publications are not stocked at the address printed on the reverse side. Instead, you should direct any requests for copies of publications, or for assistance in using your IBM system, to your IBM representative or to the IBM branch office serving your locality.

If you have applied any technical newsletters (TNLs) to this book, please list them here:

Chapter/Section

Page No.

Comments:

If you want a reply, please complete the following Information.

Name Phone No. {.

Company.

Address

Thank you for your cooperation. No postage is necessary If mailed In the U.S.A. (Elsewhere, an IBM office or representative will be happy to forward your comments or you may mail them directly to the address In the Edition Notice on the back of the title page.) GC26-4313-3

Reader's Comment Form

Fold and tape Please do not staple Fold and tape

NO POSTAGE NECESSARY IF MAILED IN THE UNITED STATES

BUSINESS REPLY MAIL FIRST CLASS MAIL PERMIT NO. 40 ARMONK, NY

POSTAGE WILL BE PAID BY ADDRESSEE

IBM Corporation Programming Publishing P.O. Box 49023 San Jose, OA 95161-9023

iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Fold and tape Please do not staple Fold and tape • Expressions using values returned by the following built-in functions;

- HBOUND - LBOUND - DIM - ALLOCATION.

The format and content of some messages and some compiler listings has changed slightly. If any programs process these messages or listings, the pro grams might require modification.

Compatibility between OS and DOS Because the OS Optimizing Compiler implements more of the PL/I language than does the DOS Optimizing Compiler, most source programs compiled on the DOS Optimizing Compiler can be compiled on the OS Optimizing Compiler, thereby aiding the conversion from DOS to OS.

Chapter 3. External Characteristics of the Optimizing Compiler 25 Chapter 4. Optimization

The Optimizing Compiler attempts to generate object programs that run rapidly and occupy little space during processing. In many cases, the compiler generates efficient code for statements in the sequence written by the programmer. In other cases, however, the compiler may alter the sequence of statements or operations to improve the performance, while producing the same result.

The Compiler carries out the following types of optimization:

• Expressions:

— Common expression elimination — Redundant expression elimination — Simplification of expressions.

• Loops:

— Transfer of expressions from loops — Special-case code for DO statements.

• Arrays and Structures:

— Initialization — Assignments — Elimination of common control data.

• In-line Code for:

— Conversions — RECORD I/O — String manipulation — Built-in functions.

• Input/Output:

~ Key handling for REGIONAL data sets — Matching format lists with data lists.

• Other:

— Library subroutines — Use of registers — Analyzing run-time options during compile time (the PLIXOPT variable),

PL/I performs some of these types of optimization even when the NOOPTIMIZE option is specified. PL/I attempts full optimization, however, only when a pro grammer specifies the OPTIMIZE (TIME) compile-time option.

Chapter 4. Optimization 27 Expressions The following sections describe optimization of expressions.

Common Expression Elimination A common expression is an expression that occurs more than once in a program, but is intended to result in the same value each time it is evaluated. A common expression is also an expression that is identical to another expression, with no intervening modification to any operand in the expression. The compiler elimi nates a common expression by saving the value of the first occurrence of the expression either in a temporary (compiler generated) variable, or in the program variable to which the result of the expression is assigned. For example:

XI = A1 * Bl;

Y1 = A1 * Bl;

Provided that the values of A1, Bl, and X1 do not change between the processing of these statements, the statements can be optimized to the equivalent of the fol lowing PL/I statements: XI = A1 * Bl;

Y1 = XI;

Sometimes the first occurrence of a common expression involves the assignment of a value to a variable that is modified before It occurs In a later expression. In this case, the Compiler assigns the value to a temporary variable. The example given above becomes: Temp = A1 * Bl; XI = Temp;

XI = XI + 2;

Y1 = Temp;

If the common expression occurs as a subexpression within a larger expression, the Compiler creates a temporary variable to hold the value of the common subex pression. For example, in the expression C1 -t- A1 * 81. a temporary variable con tains the value of A1 * 81, if this were a common subexpression.

An Important application of this technique occurs In statements containing sub scripted variables that use the same subscript value for each variable. For example; PAYTAX(MNO)=PAYCODE(MNO)*WKPMNT(MNO); The Compiler computes the value of the subscript MNO only once, when the state ment processes. The computation involves the conversion of a value from decimal to binary, if MNO is declared to be a decimal variable.

28 OS PL/I General information Redundant Expression Elimination A redundant expression is an expression that need not be evaluated for a program to run correctly. For example, the logical expression: (A=D)I(C=0) contains the subexpressions (A = D) and (C = D). The second expression need not be evaluated if the first one is true. This optimization makes using a compound logical expression in a single IF statement more efficient than using an equivalent series of nested IF statements.

Simplification of Expressions There are six types of expression simplification processes explained below.

Modification of Loop Control Variables Where possible, the expression-simplification process modifies both the control variable and the iteration specification of a do-loop for more efficient processing when using the control variable as a subscript. The Compiler calculates addresses of array elements faster by replacing multiplication operations with addition oper ations. For example, the loop: Do I = 1 To N By 1; A(I) = B(I); End; assigns N element values from array B to corresponding elements in array A. Assuming that each element is 4 bytes long, the address calculations used for each iteration of the loop are:

Base(A)+ (4*1) for array A, and Base{B)+ (4*l) for array B,

where "Base" represents the base address of the array in storage. The Compiler can convert repeated multiplication of the control variable by a constant (that represents the length of an element) to faster addition operations. It converts the optimized DO statement above into object code equivalent to the following state ment:

Do Temp = 4 By 4 To 4*N;

The Compiler converts the element address calculations to the equivalent of: Base(A) + Temp for array A, and Base(B) + Temp for array B.

This optimization of a loop control variable and its iteration can occur only when the control variable (used as a subscript) increases by a constant value. Programs should not use the value of the control variable outside the loop in which it controls iteration.

Chapter 4. Optimization 29 Defactorization Where possible, a constant In an array subscript expression is an offset in the address calculation. For example, PL/I calculates the address of a 4-byte element: A(I+1Q)

as: (Base(A)+4*10)+I*4

Replacement of Constant Expressions Expression simplification replaces constant expressions of the form A + B or A*B, where A and B are integer constants, with the equivalent constant. For example, the Compiler replaces the expression 2+ 5 with 7.

Replacement of Constant Multipliers and Exponents The expression-simplification process replaces certain constant multipliers and exponents. For example: A*2 becomes A+A,

and

A*'*2 becomes A*A.

Elimination of Common Constants If a constant occurs more than once in a program, the Compiler stores only a single copy of that constant. For example, in the following statements: Week_No = Week_No + 1; Record_Count = Record_Count + 1;

the Compiler stores the 1 only once, provided that Week_No and Record_Count have the same attributes.

Code for Program Branches The Compiler allocates base registers for branch instructions in the object program in accordance with the logical structure of the program. This minimizes the occur rence of program-addressing load instructions in the middle of deeply nested loops.

Also, the Compiler arranges the branch instructions generated for IF statements as efficiently as possible. For example, a statement such as: IF condition THEN GOTO label;

is defined by the PL/I language as being a test of condition followed by a branch on false to the statement following the THEN clause. However, when the THEN clause consists only of a GOTO statement, the statement compiles as a branch on true to the label specified in the THEN clause.

30 OS PL/I General Information Loops In addition to the optimization described in "Modification of Loop Control Variables" on page 29, PL/I provides optimization features for loops as described in the following sections.

Transfer of Expressions from Loops Where it is possible to produce an error-free run without affecting program results, optimization moves invariant expressions or statements from inside a loop to a point that immediately precedes the loop. An expression or statement occurring within a loop is said to be invariant if the Compiler can detect that the value of the expression or the action of the statement would be identical for each iteration of the loop. A loop can be either a do-loop or a loop in a program detectable by ana lyzing the flow of control within the program. For example: Do I = 1 To N; B(I) = C(I) * SQRT(N); P = N * J; End;

This loop can be optimized to produce object code corresponding to the following statements: Temp = SQRT(N); P = N * J; DO I = 1 TO N; B(I) = C(I) * Temp; End;

If programmers want to use this type of optimization, they must specify REORDER for a BEGIN or PROCEDURE block that contains the loop. If a programmer does not specify the option, the Compiler assumes the default option, ORDER, which inhibits optimization.

Programming Considerations The Compiler transfers expressions from inside to outside a loop on the assump tion that every expression in the loop runs more frequently than expressions imme diately outside the loop. Occasionally this assumption fails, and the Compiler moves expressions out of loops to positions in which they run more frequently than if they had remained inside the loop. For example: Do I = J To K While(X(I)=0); X(I) = Y(I) * SQRT(N); End;

The Compiler might move the expression SQRT(N) out of the loop to a position in which it is possibie for the expression to be processed more frequently than in its original position inside the loop. This undesired effect of optimization is prevented by using the ORDER option for the block in which the loop occurs.

The Compiler detects loops by analyzing the flow of control. The Compiler can fail to recognize a loop if programmers use label variables because of flowpaths that they know are seldom or never used. Using label variables can inadvertently inhibit optimization by making a loop undetectable.

Chapter 4. Optimization 31 Special Case Code for DO Statements Where possible for a do-loop, the Compiler generates code in which the value of the control variable, and the values of the iteration specification, are contained in registers throughout loop execution. For example, the Compiler attempts to main tain in registers the values of the variables I, K, and L in the following statement: Do I = A To K By L; This optimization uses the most efficient loop control instructions.

Arrays and Structures PL/I provides optimization for array and structure variables as described in the fol lowing sections.

Initialization of Arrays and Structures When arrays and some structures that have the BASED, AUTOMATIC, or CON TROLLED storage class are to be initialized by a constant specified in the INITIAL attribute, the Compiler initializes the first element of the variable by the constant. The remainder of the initiaiization is a single move that propagates the value through all the elements of the variable. For example, for the following declara tion: DCL A(20,20) Fixed Binary Init{(400)0); the Compiler initializes array A using this method.

Structure and Array Assignments The Compiler implements structure and array assignment statements by single move instructions whenever possible. Otherwise, the Compiler assigns values by the simplest loop possible for the operands in the declaration. For example: DCL A(10),B(10), 1 SClO), 2 T, 2 U; A=B; A=T;

The Compiler implements the first assignment statement by a single move instruc tion, and the second by a loop. This occurs because array T is interleaved with array U, thereby making a single move impossible.

Elimination of Common Control Data The Compiler generates control information to describe certain program elements such as arrays. If there are two or more similar arrays, the Compiler generates this descriptive information only once.

32 OS PL/I General Information In-line Code To Increase efficiency, the PL/I Compiler produces in-line code (code that it incor porates within programs) as a substitute for calls to generalized subroutines.

In-Line Code for Conversions The Compiler performs most conversions by in-line code, rather than by calls to the Library. The exceptions are:

• Conversions between character and arithmetic data

• Conversions from numeric character (PICTURE) data, where the picture includes characters other than 9, V, Z, or a single sign or currency character

• Conversions to numeric character (PICTURE) data, where the picture includes scale factors or floating point picture characters.

For example, the Compiler converts data to PICTURE 'ZZ9V99' with in-line code.

In-Line Code for Record I/O For consecutive buffered files under certain conditions, in-line code implements the input and output transmission statements READ, WRITE, and LOCATE rather than calls to the Library.

In-Line Code for String Manipulation In-line code performs operations on many character strings (such as concatenation and assignment of adjustable, varying-length, and fixed-length strings). In-line code performs similar operations on many aligned bit strings that have a length that is a multiple of 8.

In-Line Code for Built-in Functions The Compiler uses in-line code to implement many built-in functions. INDEX and SUBSTR are examples of functions for which the Compiler usually generates in-line code. TRANSLATE, VERIFY, and REPEAT are examples where the Com piler generates in-line code for simple cases.

Key Handling for REGIONAL Data Sets In certain circumstances, avoiding unnecessary conversions between fixed binary and character-string data types simplifies key handling for REGIONAL data sets, as follows:

REGI0NAL(1): If the key is a fixed binary integer with precision (12,0) through (23,0), there is no conversion from fixed binary to character-string and back again.

REGI0NAL(2) and REGiONAL(3): If the key is in the form Kjll, where K is a char acter string and I is fixed binary with precision (12,0) through (23,0), the rightmost eight (8) characters of the resultant string do not reconvert to fixed binary. (This conversion would otherwise be necessary to obtain the region number.)

Chapter 4. Optimization 33 Matching Format Lists with Data Lists Where possible, the Compiler matches format and data lists of edit-directed input/output statements at compile time. This is possible only when neither list contains repetition factors at compile time that are expressions with unknown values. This permits in-line code to convert to or from the data list item. Also, on input, PL/I can take the item directly from the buffer or, on output, place it directly into the buffer. This eliminates Library calls, except when necessary to transmit a block of data between the input or output device and the buffer. For example: DCL (A,B,X,Y,Z) CHAR(25); Get File(SYSIN) Edit(X,Y,Z) (A(25)); Put File(SYSPRINT) Edit(A,B) (A(25));

In this example, format list matching occurs at compile time; at run time. Library calls are required only when PL/I transmits the buffer contents to or from the input or output device.

Library Subroutines The Library is a set of subroutines containing logically related functions. These functions occur within the Library subroutines in such a manner that a link-edited object program contains only the specific code likely to be necessary for the func tions used in that program.

Selecting Library procedures in this way minimizes program main storage require ments. It can also reduce the time required for loading the program into main storage.

The groups of functions particularly concerned with this efficient structuring include record-oriented input and output, stream-oriented input and output, conversion, and error-handling functions.

Use of Registers The Compiler achieves more efficient loop processing by maintaining in registers the values of loop variables that are subject to frequent modification. Keeping values of variables in registers, as the flow of program control permits, results in considerable efficiency. This efficiency is a result of dispensing with time- consuming load-and-store operations that reset the values of variables in their storage locations. When, after loop processing, the latest value of a variable is not required, the Compiler does not assign the value to the storage location of the vari able as control passes out of the loop.

Specifying REORDER for the block significantly optimizes the allocation of regis ters. However, because the latest value of a variable can exist in a register but not in the storage location of that variable, the values of variables reset in the block might not be the latest assigned values when a computational interrupt occurs, Specifying ORDER impedes optimizing the allocation of registers but guarantees that all values of variables are reset in the block, thereby immediately assigning values to their storage locations.

34 OS PL/I General Information Progra 5668-91 5668-9 5668-9