Mincpp: Efficient, Portable Compilation of C Programs

Total Page:16

File Type:pdf, Size:1020Kb

Mincpp: Efficient, Portable Compilation of C Programs Mincpp: Efficient, Portable Compilation of C Programs George Moberly B.S., Boston University A thesis submitted to the faculty of the Oregon Graduate Institute of Science & Technology in partial fulfillment of the requirements for the degree Master of Science in Computer Science April, 1994 The thesis "Mincpp:Efficient, Port; le Compilation of C Programs" by George Moberly has been examined and approved b: the following Examination Committee: .-------------______--s---------------------- a Sheard, Ph.D. 1 sistant Professor The s Research Advisor eve Otto, Ph.D. sistant Professor Acknowledgment This thesis and supporting degree program was made possible only with the financial, intellectual, and emotional support of many corporations, institutions, and individuals. Past and present employers Digital Equipment Corporation, Mentor Graphics Corporation, and SpaceLabs Medical, Incorporated generously paid for the vast majority of the educational expenses involved, and have actively supported my work. Degree credit was transferred from Tufts University, The University of Washington, and Oregon State University. The following individuals shared generously of their time to discuss issues with me: Phil Brooks and Mike Gresham of Mentor Graphics, Bill Bregar of Oregon State University, Aki Fujimura of Pure Software, Greg Kostal, Jeff Small, and of course Tim Sheard and Steve Otto of OGI. Finally, my wife Julie deserves profound credit and thanks for not letting me give up when it would have been easier to have done so, and for unwavering belief and support of this effort. Table of Contents TABLE OF CONTENTS....................................................................................................... IV LIST OF TABLES ..............................................................................................................VIII LIST OF FIGURES ................................................................................................................M ABSTRACT ..............................................................................................................................X 1. INTRODUCTIONffROBLEM STATEMENT................................................................... 1 1.1 HELLO.WORLD ..................................................................................................................... 2 1.2 NOVA.................................................................................................................................... 4 1.3 THESISPROBLEMS ................................................................................................................. 6 1.3.1 High Compile Times...................................................................................................... 6 1.3.2 Too Many Builds ........................................................................................................... 6 1.3.3 Too Few Builds ............................................................................................................. 7 1.4 CHAPTERSUMMARIES ............................................................................................................ 7 2. RELATED WORK ...............................................................................................................9 2.1 OVERVIEW............................................................................................................................. 9 2.2 SYSTEMDESCRIPTIONS ........................................................................................................ 11 2.2.1 Standard UNIX Compilers: cc. ace and cfront ............................................................. II 2.2.2 Cfront/cback ............................................................................................................... 13 2.2.3 Centerline Objectcenter.............................................................................................. 15 2.2.4 Lucid Energize ............................................................................................................ 18 2.2.5 MicrosoJ C/C++ ........................................................................................................ 20 2.2.6 BorlandC++ ..............................................................................................................20 2.2.7 IBM Tokyo Research Compile Server ..........................................................................20 2.2.8 NeST Smart Preprocessor ...........................................................................................20 2.3 DISCUSSION......................................................................................................................... 21 3. MINCPP .............................................................................................................................22 3.1 IMPLEMENTATIONRATIONALE .............................................................................................. 22 3.2 SYMBOLTABLE BASICS ........................................................................................................ 23 3.3 SCANNER............................................................................................................................. 25 3.4 PARSERBASICS .................................................................................................................... 26 3.5 A SINGLESIMPLE DECLARATION .......................................................................................... 28 3.6 SYMBOLTABLE: PART 2 ...................................................................................................... 31 3.7 EXTERNALDECLARATIONS ................................................................................................... 32 3.7.1 Simple Declarations .................................................................................................... 33 3.7.2 Function Prototypes .................................................................................................. 35 3.7.3 Enumerations .............................................................................................................. 37 3.7.4 Structures and Unions................................................................................................. 38 3.7.5 Typedef Declarations .................................................................................................. 40 3.8 FUNCTIONDEFINITIONS ....................................................................................................... 41 3.8.1 Old-Style Parameters .................................................................................................. 41 3.8.2ANSI-Style Parameters ................................................................................................ 42 3.8.3 Local Declarations ......................................................................................................43 3.8.4 Referencing .................................................................................................................44 3.9 SAVEAND REPLAY............................................................................................................... 44 3.9.1 Save ............................................................................................................................ 45 3.9.2 Replay ......................................................................................................................... 45 3.10 USINGMINCPP ................................................................................................................... 46 3.11 IMPLEMENTATIONSUMMARY .............................................................................................. 47 4 .RESULTS ........................................................................................................................... 48 4.1 BENCHMARKDESCRIPTIONS ................................................................................................. 48 4.1.1 Small Benchmarks..................................................................................................... 49 4.1.2 Large Benchmarks ....................................................................................................... 49 4.2 DIRECTORYSTRUCTURE ....................................................................................................... 50 4.3 HEADERFILE STRUCTURES ................................................................................................... 50 4.4 Noco~............................................................................................................................... 58 4.5 MAKEFILESAND BUILDSCRIPTS ........................................................................................... 58 4.6 COLLECTIONMETHODOLOGY ANDTOOLS ............................................................................. 65 4.7 RESULT DATA...................................................................................................................... 66 4.7.1 File Sizes .....................................................................................................................66 4.7.2 Cpp and Mincpp Times................................................................................................ 69 4.7.3 Compile Times ............................................................................................................71 4.7.4 Object File Sizes ......................................................................................................... 74 4.7.5 Linker and Binary Results
Recommended publications
  • Mipspro C++ Programmer's Guide
    MIPSproTM C++ Programmer’s Guide 007–0704–150 CONTRIBUTORS Rewritten in 2002 by Jean Wilson with engineering support from John Wilkinson and editing support from Susan Wilkening. COPYRIGHT Copyright © 1995, 1999, 2002 - 2003 Silicon Graphics, Inc. All rights reserved; provided portions may be copyright in third parties, as indicated elsewhere herein. No permission is granted to copy, distribute, or create derivative works from the contents of this electronic documentation in any manner, in whole or in part, without the prior written permission of Silicon Graphics, Inc. LIMITED RIGHTS LEGEND The electronic (software) version of this document was developed at private expense; if acquired under an agreement with the USA government or any contractor thereto, it is acquired as "commercial computer software" subject to the provisions of its applicable license agreement, as specified in (a) 48 CFR 12.212 of the FAR; or, if acquired for Department of Defense units, (b) 48 CFR 227-7202 of the DoD FAR Supplement; or sections succeeding thereto. Contractor/manufacturer is Silicon Graphics, Inc., 1600 Amphitheatre Pkwy 2E, Mountain View, CA 94043-1351. TRADEMARKS AND ATTRIBUTIONS Silicon Graphics, SGI, the SGI logo, IRIX, O2, Octane, and Origin are registered trademarks and OpenMP and ProDev are trademarks of Silicon Graphics, Inc. in the United States and/or other countries worldwide. MIPS, MIPS I, MIPS II, MIPS III, MIPS IV, R2000, R3000, R4000, R4400, R4600, R5000, and R8000 are registered or unregistered trademarks and MIPSpro, R10000, R12000, R1400 are trademarks of MIPS Technologies, Inc., used under license by Silicon Graphics, Inc. Portions of this publication may have been derived from the OpenMP Language Application Program Interface Specification.
    [Show full text]
  • CRTE V11.1A Common Runtime Environment
    English FUJITSU Software BS2000 CRTE V11.1A Common Runtime Environment User Guide * Edition December 2019 Comments… Suggestions… Corrections… The User Documentation Department would like to know your opinion on this manual. Your feedback helps us to optimize our documentation to suit your individual needs. Feel free to send us your comments by e-mail to: [email protected] senden. Certified documentation according to DIN EN ISO 9001:2015 To ensure a consistently high quality standard and user-friendliness, this documentation was created to meet the regulations of a quality management system which complies with the requirements of the standard DIN EN ISO 9001:2015 . Copyright and Trademarks Copyright © 2019 Fujitsu Technology Solutions GmbH. All rights reserved. Delivery subject to availability; right of technical modifications reserved. All hardware and software names used are trademarks of their respective manufacturers. Table of Contents CRTE V11.1 . 6 1 Preface . 7 1.1 Objectives and target groups of this manual . 8 1.2 Summary of contents . 9 1.3 Changes since the last edition of the manual . 10 1.4 Notational conventions . 11 2 Selectable unit, installation and shareability of CRTE . 12 2.1 CRTE V11.1A selectable unit . 13 2.2 Installing CRTE . 16 2.2.1 CRTE libraries for installation without version specification . 17 2.2.2 Standard installation under the user ID “$.” . 18 2.2.3 Installing with IMON under a non-standard user ID . 19 2.2.4 Installing header files and POSIX link switches in the default POSIX directory . 20 2.2.5 Installing header files and POSIX link switches in any POSIX directory .
    [Show full text]
  • C++ Programmer's Guide
    C++ Programmer’s Guide Document Number 007–0704–130 St. Peter’s Basilica image courtesy of ENEL SpA and InfoByte SpA. Disk Thrower image courtesy of Xavier Berenguer, Animatica. Copyright © 1995, 1999 Silicon Graphics, Inc. All Rights Reserved. This document or parts thereof may not be reproduced in any form unless permitted by contract or by written permission of Silicon Graphics, Inc. LIMITED AND RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the Government is subject to restrictions as set forth in the Rights in Data clause at FAR 52.227-14 and/or in similar or successor clauses in the FAR, or in the DOD, DOE or NASA FAR Supplements. Unpublished rights reserved under the Copyright Laws of the United States. Contractor/manufacturer is Silicon Graphics, Inc., 1600 Amphitheatre Pkwy., Mountain View, CA 94043-1351. Autotasking, CF77, CRAY, Cray Ada, CraySoft, CRAY Y-MP, CRAY-1, CRInform, CRI/TurboKiva, HSX, LibSci, MPP Apprentice, SSD, SUPERCLUSTER, UNICOS, X-MP EA, and UNICOS/mk are federally registered trademarks and Because no workstation is an island, CCI, CCMT, CF90, CFT, CFT2, CFT77, ConCurrent Maintenance Tools, COS, Cray Animation Theater, CRAY APP, CRAY C90, CRAY C90D, Cray C++ Compiling System, CrayDoc, CRAY EL, CRAY J90, CRAY J90se, CrayLink, Cray NQS, Cray/REELlibrarian, CRAY S-MP, CRAY SSD-T90, CRAY SV1, CRAY T90, CRAY T3D, CRAY T3E, CrayTutor, CRAY X-MP, CRAY XMS, CRAY-2, CSIM, CVT, Delivering the power . ., DGauss, Docview, EMDS, GigaRing, HEXAR, IOS, ND Series Network Disk Array, Network Queuing Environment, Network Queuing Tools, OLNET, RQS, SEGLDR, SMARTE, SUPERLINK, System Maintenance and Remote Testing Environment, Trusted UNICOS, and UNICOS MAX are trademarks of Cray Research, Inc., a wholly owned subsidiary of Silicon Graphics, Inc.
    [Show full text]
  • A Customizable, Front-End Retargetablesource Code Analysis
    GENOA - A Customizable, front-end retargetable Source Code Analysis Framework Premkumar T. Devanbu [email protected] Dept. Of Computer Science, University of California, Davis, CA 95616 Code Analysis tools provide support for such software engineering tasks as program understanding, software metrics, testing and re-engineering. In this paper we describe genoa, the framework underlying application generators such as Aria [Devanbu et al. 1996] and gen++ [?] which have been used to generate a wide range of practical code analysis tools. This experience illustrates front-end retargetability of genoa; we describe the features of the genoa framework that allow it to be used with dierent front ends. While permitting arbitrary parse tree computations, the genoa specication language has special, compact iteration operators that are tuned for expressing simple, polynomial time analysis programs; in fact, there is a useful sublanguage of the genoa language that can express precisely all (and only) polynomial time (PTIME) analysis programs on parse-trees. Thus, we argue that the genoa language is a simple and convenient vehicle for implementing a range of analysis tools. We also argue that the “front-end reuse” approach of GENOA oers an important advantage for tools aimed at large software projects: the reuse of complex, expensive build procedures to run generated tools over large source bases. In this paper, we describe the genoa framework and our experiences with it. Categories and Subject Descriptors: D.2.3 [Software Engineering]: Coding Tools and Tech- niques; D.2.6 [Software Engineering]: Programming Environments General Terms: Languages Additional Key Words and Phrases: source analysis, reverse engineering, metrics, code inspection 1.
    [Show full text]
  • A History of C++: 1979− 1991
    A History of C++: 1979−1991 Bjarne Stroustrup AT&T Bell Laboratories Murray Hill, New Jersey 07974 ABSTRACT This paper outlines the history of the C++ programming language. The emphasis is on the ideas, constraints, and people that shaped the language, rather than the minutiae of language features. Key design decisions relating to language features are discussed, but the focus is on the overall design goals and practical constraints. The evolution of C++ is traced from C with Classes to the current ANSI and ISO standards work and the explosion of use, interest, commercial activity, compilers, tools, environments, and libraries. 1 Introduction C++ was designed to provide Simula’s facilities for program organization together with C’s effi- ciency and flexibility for systems programming. It was intended to deliver that to real projects within half a year of the idea. It succeeded. At the time, I realized neither the modesty nor the preposterousness of that goal. The goal was modest in that it did not involve innovation, and preposterous in both its time scale and its Draco- nian demands on efficiency and flexibility. While a modest amount of innovation did emerge over the years, efficiency and flexibility have been maintained without compromise. While the goals for C++ have been refined, elaborated, and made more explicit over the years, C++ as used today directly reflects its original aims. This paper is organized in roughly chronological order: §2 C with Classes: 1979– 1983. This section describes the fundamental design decisions for C++ as they were made for C++’s immediate predecessor. §3 From C with Classes to C++: 1982– 1985.
    [Show full text]
  • Reference Guide for Openpower Cpus
    REFERENCE GUIDE FOR OPENPOWER CPUS Version 2020 TABLE OF CONTENTS Preface............................................................................................................. ix Audience Description.......................................................................................... ix Compatibility and Conformance to Standards............................................................ ix Organization..................................................................................................... x Hardware and Software Constraints........................................................................ xi Conventions..................................................................................................... xi Terms............................................................................................................ xii Related Publications......................................................................................... xiii Chapter 1. Fortran, C, and C++ Data Types................................................................ 1 1.1. Fortran Data Types....................................................................................... 1 1.1.1. Fortran Scalars.......................................................................................1 1.1.2. FORTRAN real(2).....................................................................................3 1.1.3. FORTRAN Aggregate Data Type Extensions...................................................... 3 1.1.4. Fortran 90 Aggregate Data Types
    [Show full text]
  • (R)Evolution of C++ Aka the Hitchhiker’S Guide to C++
    C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary (R)evolution of C++ aka The Hitchhiker’s Guide to C++ Łukasz Ziobron´ [email protected] http://ziobron.net code::dive, 2016-11-15 C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary (R)evolution of JS C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author C with Classes Cfront era Standardization time C++ future (R)evolution! Language popularity Summary About the author Interests: Archery Digital photography Machine learning Image processing High tech Starcraft Blogging at ziobron.net 2 C++ is even more popular now, because of
    [Show full text]
  • HP Ac++ Online Programmer's Guide Command Line Options
    HP aC++ Online Programmer's Guide © Copyright 1996, 1997, 1998, 1999 Hewlett-Packard Company All rights reserved. Send mail to report errors or comment on the documentation. Welcome to the HP aC++ Online Programmer's Guide. The guide is divided into the following files. String search is available within each file. (Choose Edit, then Find.) Note that each file may contain links to related topics in other files. Command-Line Options What's New - including release notes for this Command Syntax and Environment version of HP aC++ Variables Diagnostic Messages Information Map - where to find more Distributing Your HP aC++ Products information about this guide and about C++ Exception Handling Getting Started Glossary LEX and YACC with HP aC++ Libraries HP C++ (cfront) to HP aC++ Migration Mixing HP aC++ with Other Languages Guide Optimizing Your Code Pragmas Rogue Wave Library Reference Manuals Precompiled Header Files Preprocessing Rogue Wave Tools.h++ Version 7.0.6 Reference Standardizing Your Code Manual Templates Introduction and Overview Rogue Wave Standard C++ Library Version 1.2.1 Detailed Information Reference Manual Threads NOTE: If you are accessing this guide from the World Wide Web URL, http://docs.hp.com, rather than from a system on which HP aC++ is installed, Rogue Wave documentation is not available. The above two links and any other such links within this guide will not succeed. Command Line Options You can specify command-line options to the aCC command. They allow you to override the default actions of the compiler. Each option begins with either a - or a + sign.
    [Show full text]
  • Cray C and C++ Reference Manual
    Cray C and C++ Reference Manual (8.7) S-2179 Contents Contents 1 About the Cray and C++ Reference Manual...........................................................................................................4 2 The Cray Compiling Environment...........................................................................................................................5 3 Invoke the C and C++ Compilers............................................................................................................................7 4 Compiler Command Line Options.........................................................................................................................12 4.1 Standard Language Conformance Options............................................................................................. 12 4.2 C Specific Language Conformance Options........................................................................................... 15 4.3 C++ Specific Language Conformance Options....................................................................................... 15 4.4 Miscellaneous C++ Specific Options....................................................................................................... 17 4.5 General Language Options..................................................................................................................... 18 4.6 General Optimization Options................................................................................................................. 21 4.7 Cache Management Options...................................................................................................................26
    [Show full text]
  • Summary of UNIX Commands Furnishing, Performance, Or the Use of These Previewers Commands Or the Associated Descriptions Available on Most UNIX Systems
    S u mmary of UNIX Commands- version 3.2 Disclaimer 8. Usnet news 9. File transfer and remote access Summary of UNIX The author and publisher make no warranty of any 10. X window kind, expressed or implied, including the warranties of 11. Graph, Plot, Image processing tools commands merchantability or fitness for a particular purpose, with regard to the use of commands contained in this 12. Information systems 1994,1995,1996 Budi Rahardjo reference card. This reference card is provided “as is”. 13. Networking programs <[email protected]> The author and publisher shall not be liable for 14. Programming tools damage in connection with, or arising out of the 15. Text processors, typesetters, and This is a summary of UNIX commands furnishing, performance, or the use of these previewers commands or the associated descriptions available on most UNIX systems. 16. Wordprocessors Depending on the configuration, some of 17. Spreadsheets the commands may be unavailable on your Conventions 18. Databases site. These commands may be a 1. Directory and file commands commercial program, freeware or public bold domain program that must be installed represents program name separately, or probably just not in your bdf search path. Check your local dirname display disk space (HP-UX). See documentation or manual pages for more represents directory name as an also df. details (e.g. man programname). argument cat filename This reference card, obviously, cannot filename display the content of file filename describe all UNIX commands in details, but represents file name as an instead I picked commands that are useful argument cd [dirname] and interesting from a user’s point of view.
    [Show full text]
  • Compiler Construction
    Compiler construction PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Sat, 10 Dec 2011 02:23:02 UTC Contents Articles Introduction 1 Compiler construction 1 Compiler 2 Interpreter 10 History of compiler writing 14 Lexical analysis 22 Lexical analysis 22 Regular expression 26 Regular expression examples 37 Finite-state machine 41 Preprocessor 51 Syntactic analysis 54 Parsing 54 Lookahead 58 Symbol table 61 Abstract syntax 63 Abstract syntax tree 64 Context-free grammar 65 Terminal and nonterminal symbols 77 Left recursion 79 Backus–Naur Form 83 Extended Backus–Naur Form 86 TBNF 91 Top-down parsing 91 Recursive descent parser 93 Tail recursive parser 98 Parsing expression grammar 100 LL parser 106 LR parser 114 Parsing table 123 Simple LR parser 125 Canonical LR parser 127 GLR parser 129 LALR parser 130 Recursive ascent parser 133 Parser combinator 140 Bottom-up parsing 143 Chomsky normal form 148 CYK algorithm 150 Simple precedence grammar 153 Simple precedence parser 154 Operator-precedence grammar 156 Operator-precedence parser 159 Shunting-yard algorithm 163 Chart parser 173 Earley parser 174 The lexer hack 178 Scannerless parsing 180 Semantic analysis 182 Attribute grammar 182 L-attributed grammar 184 LR-attributed grammar 185 S-attributed grammar 185 ECLR-attributed grammar 186 Intermediate language 186 Control flow graph 188 Basic block 190 Call graph 192 Data-flow analysis 195 Use-define chain 201 Live variable analysis 204 Reaching definition 206 Three address
    [Show full text]
  • Porting C to the IBM" Mainframe Environment Gary H. Merrill, SAS Institute Inc., Cary, NC
    Porting C to the IBM" Mainframe Environment Gary H. Merrill, SAS Institute Inc., Cary, NC ABSTRACT • Class 3 contains programs that take advantage in inessential ways of various features of the machine ThiS paper deals with issues encountered in porting existing C pro­ architecture (for example, the size of ints or size of grams to the mainframe environment Following a discussion con­ pointers). cerning what it means to say that a program is portable, this paper emphasizes program features that are likely to inhibit portability to • Class 4 contains programs that take advantage in and from the mainframe. inessential ways of various features of the host operating system and file system (for example, the format of file names, the maximum length of file names, or library THE MEANING OF PORTABILITY functions specific to that compiler or operating system). What does it mean to say that a program, or a body of source code, Potentially portable is portable? For most practical purposes (and portability is a practi­ • Class 5 contains programs that make use of certain cal concept), this means that if you have written and debugged the common, but not universally available, library interfaces (for program so that it runs correctly on one system, when you compile example. UNIX curses or XWINDOWS). and link the same code for a second system, the program will (with­ out modification) run correctly on that system as well. Thus, portabil­ • Class 6 contains programs that intentionally take advantage ity is a relation among a body of source cocle and two computer of features of the machine architecture (for example, the systems.
    [Show full text]