280 likes | 456 Views
Lecture 5: Instruction Set Architecture (Review). Michael B. Greenwald Computer Architecture CIS 501 Spring 1999. Administration. Policies: no extensions on homework HW #2: shorter, fewer points, less time, HW manuals on line. Design Space of ISA. Five Primary Dimensions
E N D
Lecture 5:Instruction Set Architecture(Review) Michael B. Greenwald Computer Architecture CIS 501 Spring 1999
Administration • Policies: no extensions on homework • HW #2: shorter, fewer points, less time, HW manuals on line
Design Space of ISA Five Primary Dimensions • Operand Storage Where besides memory? • Number of (explicit) operands ( 0, 1, 2, 3 ) • Effective Address How is memory location specified? • Type & Size of Operands byte, int, float, vector, . . . How is it specified? • Operations add, sub, mul, . . . How is it specifed? Other Aspects • Successor How is it specified? • Conditions How are they determined? • Encodings Fixed or variable? Wide? • Parallelism
Continuum of ISA Classes • All can have arbitrary number of registers • Accumulator: each register is special, implicit in op-code • Stack: top-of-stack register cache • GPR: no special meaning, so can keep adding. • What values are stored in each register? • Accumulator: forced by instruction • Stack: mostly order of eval • GPR: almost no restrictions
The Case Against Special Purpose Registers • Performance is derived from the existence of several fast registers, not from the way they are organized • Data does not always “surface” when needed • Constants, repeated operands, common subexpressions so TOP and Swap instructions are required • Code density is about equal to that of GPR instruction sets • Registers have short addresses • Keep things in registers and reuse them • Slightly simpler to write a poor compiler, but not an optimizing compiler
Design Space of ISA Five Primary Dimensions • Operand Storage Where besides memory? • Number of (explicit) operands ( 0, 1, 2, 3 ) • Effective Address How is memory location specified? • Type & Size of Operands byte, int, float, vector, . . . How is it specified? • Operations add, sub, mul, . . . How is it specifed? Other Aspects • Successor How is it specified? • Conditions How are they determined? • Encodings Fixed or variable? Wide? • Parallelism
General Purpose Registers • How many operands? (2 or 3) • How many operands access memory? (0 - 3)
Architecture Names • Worth hearing once • Worth forgetting • Historically questionable • Non-standard definitions • e.g. Harvard Architecture, Von Neumann architecture, etc.
Design Space of ISA Five Primary Dimensions • Operand Storage Where besides memory? • Number of (explicit) operands ( 0, 1, 2, 3 ) • Effective Address How is memory location specified? • Type & Size of Operands byte, int, float, vector, . . . How is it specified? • Operations add, sub, mul, . . . How is it specifed? Other Aspects • Successor How is it specified? • Conditions How are they determined? • Encodings Fixed or variable? Wide? • Parallelism
Data in memory • Word size: 8,16,32,36,40,70,72... • Byte/character size: 7(KL10),8,9(Multics) • Addressing (pointer format) • Bit fields • Big-Endian vs. Little-Endian (wars) • Alignment • Unaligned accesses are slow: • require alignment network • sign extend • These are not evil in themselves, unless they slow down the aligned case by (e.g.) slowing down pipeline
Computing the Effective Address • Addressing mode in instruction • Additional mode (tags) in data • Forwarding pointer (Lisp Machine) • Lookup/indirection (PDP-10)
Kinds of Addressing Modes memory • Register direct Ri • Immediate (literal) v • Direct (absolute) M[v] • Register indirect M[Ri] • Base+Displacement M[Ri + v] • Base+Index M[Ri + Rj] • Scaled Index M[Ri + Rj*d + v] • Autoincrement M[Ri++] • Autodecrement M[Ri - -] • Memory Indirect M[ M[Ri] ] • [Indirection Chains] (PDP-10, LispM) reg. file Ri Rj v
Design Space of ISA Five Primary Dimensions • Operand Storage Where besides memory? • Number of explicit operands ( 0, 1, 2, 3 ) • Effective Address How is memory location specified? • Type & Size of Operands byte, int, float, vector, . . . How is it specified? • Operations add, sub, mul, . . . How is it specifed? Other Aspects • Successor How is it specified? • Conditions How are they determined? • Encodings Fixed or variable? Wide? • Parallelism
Specifying Data Types • Implicit in operation vs. tagged data • Tagged data: • Garbage collection • Generic arithmetic (generic functions) • Mostly obsolete (although hardware support for tagged data still exists, e.g. SPARC) • Encoded in opcode • Type generally known at compile time • Genericity usually done at function call, in software.
Possible data types • Boolean • Bit String • Character, String, BCD (“Packed Decimal”) • Integer (2’s complement, n bit) • Floating Point (IEEE 754) But also ... • BitVector • Polynomial • Chess Move
Design Space of ISA Five Primary Dimensions • Operand Storage Where besides memory? • Number of explicit operands ( 0, 1, 2, 3 ) • Effective Address How is memory location specified? • Type & Size of Operands byte, int, float, vector, . . . How is it specified? • Operations add, sub, mul, . . . How is it specifed? Other Aspects • Successor How is it specified? • Conditions How are they determined? • Encodings Fixed or variable? Wide? • Parallelism
Classes of Operations • ALU + Floating Point • Load/Store • Control flow • Traps and protection • Synchronization • Cache/memory control • IO But don’t forget • EDITPC(VAX) • CRC(VAX) • BITBLT,EIEIO(PowerPC),CAS2 (68040),...
Instruction Encoding: Issues • Size of compiled code • Speed of decoding • Number of resources (registers) and access methods (addressing modes)
Instruction Encoding: Styles • Variable (VAX [1-53 bytes]) • Highest code density • Flexibility • Fixed (DLX, MIPS, SPARC, PowerPC, HP PA) • Easy to decode • Hybrid (Intel 80x86) • Multiple fixed sizes to provide better code density while still being easy to decode
Case Study: Quantitative Analysis of Constants • 3 kinds of constants • Immediate literals • Displacement addressing mode • Branch Distances • Frequency • Range/magnitude
Immediate Literals • For ALU, comparisons, MOV immediate to register for constant, & MOV immediate to register for address. • Frequency:
Immediate Literals • For ALU, comparisons, MOV immediate to register for constant, & MOV immediate to register for address. • Frequency:
Immediate Literals: Range • 0 implicit, 94% positive, on VAX, 32bits • 50-70% within 8 bits, 75-80% within 16 bits
Frequency of addressing modes • Immediate and Displacement dominate
Kinds of Addressing Modes memory • Register direct Ri • Immediate (literal) v • Direct (absolute) M[v] • Register indirect M[Ri] • Base+Displacement M[Ri + v] • Base+Index M[Ri + Rj] • Scaled Index M[Ri + Rj*d + v] • Autoincrement M[Ri++] • Autodecrement M[Ri - -] • Memory Indirect M[ M[Ri] ] • [Indirection Chains] (PDP-10, LispM) reg. file Ri Rj v
Displacement Addressing Mode: Range • Widely distributed, tested on mach. w/16 bit displacement • 1% >= 16 bits, 12 bits = 75%, 16 bits = 99%