Books I through III of The PowerPC Architecture describe the instruction set, virtual environment, and operating environment, respectively. The user manual for each processor specifies the implementation features of that processor. In this book, the term PowerPC architecture refers to the contents of Books I through III. The compiler writer is concerned principally with the contents of Book I: PowerPC User Instruction Set Architecture. 2.1 Application Environment The application environment consists of resources accessible from the problem state, which is the user mode (the PR bit in the Machine State Register is set). The PowerPC architecture is a load-store architecture that defines specifications for both 32-bit and 64-bit implementations. The instruction set is partitioned into three functional classes: branch, fixed-point and floating-point. The registers are also partitioned into groups corresponding to these classes; that is, there are condition code and branch target registers for branches, Floating-Point Registers for floating-point operations, and General-Purpose Registers for fixed-point operations. This partition benefits superscalar implementations by reducing the interlocking necessary for dependency checking. The explicit indication of all operands in the instructions, combined with the partitioning of the PowerPC architecture into functional classes, exposes dependences to the compiler. Although instructions must be word (32-bit) aligned, data can be misaligned within certain implementation-dependent constraints. The floating-point facilities support compliance to the IEEE 754 Standard for Binary Floating-Point Arithmetic (IEEE 754). 2.1.1 32-Bit and 64-Bit Implementations and Modes The PowerPC architecture includes specifications for both 32- and 64-bit implementations. In 32-bit implementations, all application registers have 32 bits, except for the 64-bit Floating-Point Registers, and effective addresses have 32 bits. In 64-bit implementations, all application registers are 64-bits longexcept for the 32-bit Condition Register, FPSCR, and XERand effective addresses have 64 bits. Figure 2-1 shows the application register sizes in 32-bit and 64-bit implementations.
Figure 2-1. Application Register Sizes Registers 32-Bit Implementation Size (Bits) 64-Bit Implementation Size (Bits) Condition Register 32 32 Link Register and Count Register 32 64 General-Purpose Registers 32 64 fixed-point Exception Register 32 32 Floating-Point Registers 64 64 Floating-Point Status and Control Register 32 32 Both 32-bit and 64-bit implementations support most of the instructions defined by the PowerPC architecture. The 64-bit implementations support all the application instructions supported 32-bit implementations as well as the following application instructions: load doubleword, store doubleword, load word algebraic, multiply doubleword, divide doubleword, rotate doubleword, shift doubleword, count leading zeros doubleword, sign extend word, and convert doubleword integer to a floating-point value. The 64-bit implementations have two modes of operation determined by the 64-bit mode (SF) bit in the Machine State Register: 64-bit mode (SF set to 1) and 32-bit mode (SF cleared to 0), for compatibility with 32-bit implementations. Application code for 32-bit implementations executes without modification on 64-bit implementations running in 32-bit mode, yielding identical results. All 64-bit implementation instructions are available in both modes. Identical instructions, however, may produce different results in 32-bit and 64-bit modes:
2.1.3.1 Memory Addressing The PowerPC architecture implements three addressing modes for instructions and three for data. The address of either an instruction or a multiple-byte data value is its lowest-numbered byte. This address points to the most-significant end in big-endian mode, and the least-significant end in little-endian mode. Instructions Branches are the only instructions that specify the address of the next instruction; all others rely on incrementing a program counter. A branch instruction indicates the effective address of the target in one of the following ways:
The non-IEEE mode implemented by some implementations may be used to obtain deterministic performance (avoiding traps and interrupts) in certain applications. See Section 3.3.7.1 on page 79 for further details.
Figure 2-2. Floating-Point Application Control Fields Register Field * Name Function FPSCR 24 VE Floating-Point Invalid Operation Exception Enable 0 Invalid operation exception handled with the IEEE 754 default response. 1 Invalid operation exception causes a Program interrupt. 25 OE Floating-Point Overflow Exception Enable 0 Overflow exception handled with the IEEE 754 default response. 1 Overflow exception causes a Program interrupt. 26 UE Floating-Point Underflow Exception Enable 0 Underflow exception handled with the IEEE 754 default response. 1 Underflow exception causes a Program interrupt. 27 ZE Floating-Point Zero-Divide Exception Enable 0 Zero divide exception handled with the IEEE 754 default response. 1 Zero divide exception causes a Program interrupt. 28 XE Floating-Point Inexact Exception Enable 0 Inexact exception handled with the IEEE 754 default response. 1 Inexact exception causes a Program interrupt. 29 NI Floating-Point Non-IEEE Mode 0 The processor executes in an IEEE 754 compatible manner. 1 The processor produces some results that do not conform with IEEE 754. 30:31 RN Floating-Point Rounding Control 00 Round to Nearest 01 Round toward 0 10 Round toward + 11 Round toward - MSR 64-bit: 52 32-bit: 20 64-bit: 55 32-bit: 23 FE0 FE1 Floating-Point Exception Modes 0 and 1 00 Ignore exceptions mode. Floating-point exceptions do not cause interrupts. 01 Imprecise nonrecoverable mode. The processor interrupts the program at some point beyond the instruction that caused the enabled exception, and the interrupt handler may not be able to identify this instruction. 10 Imprecise recoverable mode. The processor interrupts the program at some point beyond the instruction that caused the enabled exception, but the interrupt handler can identify this instruction. 11 Precise mode. The program interrupt is generated precisely at the floating-point instruction that caused the enabled exception. * 64-bit and 32-bit refer to the type of implementation. 2.2 Instruction Set All instructions are 32 bits in length. Most computational instructions specify two source register operands and a destination register operand. Only load and store instructions access memory. Furthermore, most instructions access only the registers of the same functional class. Branch instructions permit control transfers either unconditionally, or conditionally based on the test of a bit in the Condition Register. The branch targets can be immediate values given in the branches or the contents of the Link or Count Register. The fixed-point instructions include the storage access, arithmetic, compare, logical, rotate and shift, and move to/from system register instructions. The floating-point instructions include storage access, move, arithmetic, rounding and conversion, compare, and FPSCR instructions. 2.2.1 Optional Instructions The PowerPC architecture includes a set of optional instructions: