Motorola DSP56000 Family Optimizing C Compiler User’S Manual Motorola
Total Page:16
File Type:pdf, Size:1020Kb
Freescale Semiconductor, Inc. Motorola DSP56000 Family nc... Optimizing C Compiler User’s Manual, Release 6.3 DSP56KCCUM/D Document Rev. 2.0, 07/1999 Freescale Semiconductor, I For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. nc... Suite56, OnCe, and MFAX are trademarks of Motorola, Inc. Motorola reserves the right to make changes without further notice to any products herein. Motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters which may be provided in Motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. Motorola does not convey any license under its patent rights nor the rights of others. Motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support life, or for any other application in Freescale Semiconductor, I which the failure of the Motorola product could create a situation where personal injury or death may occur. Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Motorola was negligent regarding the design or manufacture of the part. Motorola and are registered trademarks of Motorola, Inc. Motorola, Inc. is an Equal Opportunity/Affirmative Action Employer. All other tradenames, trademarks, and registered trademarks are the property of their respective owners. © Copyright Motorola, Inc., 1999. All rights reserved. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Table of Contents Chapter 1 Introduction 1.1 Overview ....................................................... 1-1 1.2 Error Codes ..................................................... 1-4 1.3 Notation ........................................................ 1-4 1.4 Manual Organization .............................................. 1-5 Chapter 2 nc... Installation Guide 2.1 Introduction ..................................................... 2-1 2.2 Installation On An MS-DOS Machine (80386 or 80486) .................. 2-1 2.3 Standard Installation On A SUN ..................................... 2-3 2.4 Alternate Installation On A SUN ..................................... 2-4 2.5 Test Program .................................................... 2-4 Chapter 3 Control Program Options 3.1 Overview ....................................................... 3-1 3.2 G56k Command Line Options ....................................... 3-5 3.2.1 Preprocessor Phase Options ...................................... 3-7 3.2.2 Compile Phase Options ........................................ 3-20 3.3 Assemble Phase Options .......................................... 3-30 3.4 Link Phase Options .............................................. 3-31 Freescale Semiconductor, I Chapter 4 About g56k 4.1 Introduction ..................................................... 4-1 4.2 Identifiers ....................................................... 4-1 4.3 Predefined Preprocessor Macro Names ................................ 4-1 4.4 Data Types and Sizes .............................................. 4-1 4.4.1 Integral Data Types ............................................ 4-2 4.4.2 Floating-point Types ........................................... 4-3 4.4.2.1 Floating-point Format Description . ............................ 4-3 4.4.2.2 Comparison with IEEE STD 754-1985 Standard ................... 4-5 Motorola v For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. 4.4.3 Pointer Types . ............................................... 4-7 4.5 Register Usage ................................................... 4-8 4.6 Memory Usage................................................... 4-9 4.6.1 Activation Record ............................................ 4-10 4.6.2 Global/Static Data ............................................ 4-13 4.7 Compiler Naming Conventions ..................................... 4-13 4.8 Subroutine Call Sequence ......................................... 4-14 4.8.1 Caller Sequence .............................................. 4-14 4.8.2 Callee Sequence .............................................. 4-15 4.8.3 Return Sequence.............................................. 4-15 4.9 Software Support for Aritmetic Routines . ........................... 4-15 4.10 Run-time Safety . .............................................. 4-16 4.10.1 Memory Allocation Checks ..................................... 4-16 nc... 4.10.2 Run-time Stack Checks ........................................ 4-17 4.11 Optimization Techniques Implemented............................... 4-17 4.11.1 Register Promotion and Lifetime Analysis ......................... 4-17 4.11.2 Common Sub-expression Elimination . ........................... 4-17 4.11.3 Constant Propagation/Folding ................................... 4-18 4.11.4 Dead Code Elimination ........................................ 4-18 4.11.5 Tail Merging. .............................................. 4-18 4.11.6 Strength Reduction............................................ 4-19 4.11.7 Loop Invariant Code Motion .................................... 4-19 4.11.8 Hardware DO Loop Instruction .................................. 4-19 4.11.9 Loop Rotation. .............................................. 4-20 4.11.10 Jump Optimizations ........................................... 4-20 4.11.11 Instruction Combination........................................ 4-20 4.11.12 Leaf Routine Detection ........................................ 4-21 4.11.13 Function In-lining............................................. 4-21 4.11.14 Instruction Scheduling / Microcode Compaction .................... 4-21 Freescale Semiconductor, I Chapter 5 Mixing C and Assembly Language 5.1 Overview ....................................................... 5-1 5.2 In-line Assembly Code ............................................ 5-1 5.2.1 Instruction Template ........................................... 5-3 5.2.2 Output/Input Operands.......................................... 5-5 5.2.3 Explicit Register Saving......................................... 5-7 5.2.4 In-line Assembly Code Examples ................................. 5-8 5.2.5 Controlling Labels Generated by the Compiler ...................... 5-17 5.2.5.1 Calling Assembly Subroutines ................................ 5-17 vi Motorola DSP56000 Family Optimizing C Compiler User’s Manual Motorola For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. 5.2.5.2 Calling C Subroutines from Assembly Code ..................... 5-18 5.2.5.3 Referencing Assembly Global Variables from C .................. 5-20 5.2.5.4 Referencing Global C Variables from Assembly Language ......... 5-21 5.2.6 Specifying Registers for Variables................................ 5-22 5.2.7 Optimizer Effects on Code...................................... 5-22 5.3 #pragma Directive . .............................................. 5-22 5.4 Out-of-line Assembly Code........................................ 5-25 5.4.1 General Template ............................................. 5-26 5.4.1.1 Prologue . .............................................. 5-27 5.4.1.2 Save all registers........................................... 5-27 5.4.1.3 Main Program ............................................. 5-28 5.4.1.4 Restore all registers ........................................ 5-28 5.4.1.5 Epilogue . .............................................. 5-29 nc... 5.4.1.6 Out-of-line Assembly Code Example........................... 5-29 5.4.2 Global C and Static Variables in C ............................... 5-33 5.4.3 Using Run-time Stack for Local Data . ........................... 5-34 5.4.4 Calling C Routines ............................................ 5-35 5.4.5 Optimization Techniques ....................................... 5-36 Chapter 6 Software-Hardware Integration 6.1 Overview ....................................................... 6-1 6.2 Run-Time Environment Specification Files ............................ 6-1 6.3 crt0 File ........................................................ 6-2 6.4 Bootstrapping the C program........................................ 6-2 6.5 Memory Configuration and Management . ............................ 6-3 6.6 Interrupt Vectors . ............................................... 6-6 6.7 Miscellaneous Code............................................... 6-8 6.8 Signal File ...................................................... 6-9 Freescale Semiconductor, I 6.9 Signal() ....................................................... 6-10 6.9.1 Raise() ....................................................