specrtl: A Language for GCC Machine Descriptions

Similar documents
specrtl: A Language for GCC Machine Descriptions

Introduction to Machine Descriptions

GCC Internals: A Conceptual View Part II

An Overview of Compilation

arxiv: v1 [cs.pl] 30 Sep 2013

Retargeting GCC to Spim: A Recap

CSE 504: Compiler Design. Instruction Selection

Instruction Selection, II Tree-pattern matching

GCC Control Flow and Plugins

Incremental Machine Descriptions for GCC

Compiler Design (40-414)

The Design and Implementation of Gnu Compiler Collection

Agenda. CSE P 501 Compilers. Big Picture. Compiler Organization. Intermediate Representations. IR for Code Generation. CSE P 501 Au05 N-1

Instruction Selection: Peephole Matching. Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.

The Phasewise File Groups of GCC

Compiler Design Overview. Compiler Design 1

CS 406/534 Compiler Construction Instruction Selection and Global Register Allocation

Adding custom instructions to the Simplescalar infrastructure

First Level Gray Box Probing

Combined Object-Lambda Architectures

Intermediate Representation

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Topic 6 Basic Back-End Optimization

Group B Assignment 9. Code generation using DAG. Title of Assignment: Problem Definition: Code generation using DAG / labeled tree.

Crafting a Compiler with C (II) Compiler V. S. Interpreter

About the Authors... iii Introduction... xvii. Chapter 1: System Software... 1

A Simple Tree Pattern Matching Algorithm for Code Generator

CSE 5317 Midterm Examination 4 March Solutions

What do Compilers Produce?

CS 406/534 Compiler Construction Putting It All Together

Instruction Selection and Scheduling

Formats of Translated Programs

Plugin Mechanisms in GCC

CMPT 379 Compilers. Parse trees

Lecture 12: Compiler Backend

The Structure of a Syntax-Directed Compiler

Alternatives for semantic processing

CST-402(T): Language Processors

Instruction Selection: Preliminaries. Comp 412

CS415 Compilers. Intermediate Represeation & Code Generation

CSc 453. Code Generation I Christian Collberg. Compiler Phases. Code Generation Issues. Slide Compilers and Systems Software.

Introduction to Compiler Construction

Intermediate Representations

CS 2210 Programming Project (Part IV)

Introduction. CSc 453. Compilers and Systems Software. 19 : Code Generation I. Department of Computer Science University of Arizona.

The Structure of a Compiler

Experiences in Building a Compiler for an Object-Oriented Language

CS5363 Final Review. cs5363 1

Compilers and Code Optimization EDOARDO FUSELLA

Compiler Optimization Techniques

CSE 582 Autumn 2002 Exam 11/26/02

We can emit stack-machine-style code for expressions via recursion

Code Generation: Integrated Instruction Selection and Register Allocation Algorithms

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done

CA Compiler Construction

Front End. Hwansoo Han

Introduction to Parsing. Lecture 5

Introduction to Compiler Construction

Intermediate Code & Local Optimizations

Working of the Compilers

Low-level optimization

Control & Execution. Finite State Machines for Control. MIPS Execution. Comp 411. L14 Control & Execution 1

A Set of Tools to Teach Compiler Construction

Goals of Program Optimization (1 of 2)

Introduction to Syntax Analysis. Compiler Design Syntax Analysis s.l. dr. ing. Ciprian-Bogdan Chirila

Lecture Notes on Intermediate Representation

COMPILER CONSTRUCTION Seminar 02 TDDB44

Better Extensibility through Modular Syntax. Robert Grimm New York University

Introduction to Parsing. Lecture 5

List of Figures. About the Authors. Acknowledgments

LECTURE NOTES ON COMPILER DESIGN P a g e 2

1 Lexical Considerations

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Peephole Optimization Technique for analysis and review of Compiler Design and Construction

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

Review. Pat Morin COMP 3002

7 Translation to Intermediate Code

Introduction to Compiler

CSE 401 Midterm Exam Sample Solution 2/11/15

Discovering Machine-Specific Code Improvements. Technical Report. S. L. Graham (415)

Important Project Dates

I ve been getting this a lot lately So, what are you teaching this term? Computer Organization. Do you mean, like keeping your computer in place?

Fall Compiler Principles Lecture 6: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev

CS131: Programming Languages and Compilers. Spring 2017

Code generation and local optimization

Compilers Crash Course

Code Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline.

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

Code generation and local optimization

STEVEN R. BAGLEY THE ASSEMBLER

Formal Languages and Grammars. Chapter 2: Sections 2.1 and 2.2

Syntax Analysis Part I

Fall Compiler Principles Lecture 5: Intermediate Representation. Roman Manevich Ben-Gurion University of the Negev

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

5 The Control Structure Diagram (CSD)

Computer Software: Introduction

Compilers. Intermediate representations and code generation. Yannis Smaragdakis, U. Athens (original slides by Sam

Design of Embedded DSP Processors Unit 7: Programming toolchain. 9/26/2017 Unit 7 of TSEA H1 1

Code generation and optimization

10/18/18. Outline. Semantic Analysis. Two types of semantic rules. Syntax vs. Semantics. Static Semantics. Static Semantics.

Transcription:

specrtl: A Language for GCC Machine Descriptions GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay April 2011

GROW 2011, Chamonix specrtl: Outline 1/29 Outline Introduction and motivation Introduction to specrtl Conclusions and Future Work

GROW 2011, Chamonix specrtl: Outline 1/29 Outline Introduction and motivation Introduction to specrtl Conclusions and Future Work Disclaimer: Preliminary work that is still evolving

Part 1 Introduction

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program AST

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program AST Optimizer Target Indep. IR

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program AST Optimizer Target Indep. IR Code Generator Target Program

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program Front End AST AST Optimizer Target Indep. IR Code Generator Target Program

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program Front End AST Optimizer Target Indep. IR AST Expander Register Transfers Code Generator Target Program

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program Front End AST Optimizer Target Indep. IR Code Generator AST Expander Register Transfers Optimizer Register Transfers Target Program

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End Input Source Program Front End AST Optimizer Target Indep. IR Code Generator AST Expander Register Transfers Optimizer Register Transfers Target Program Recognizer Target Program

GROW 2011, Chamonix specrtl: Introduction 2/29 Aho Ullman Model Compilation Models Davidson Fraser Model Front End AST Optimizer Target Indep. IR Code Generator Target Program Aho Ullman: Instruction selection over optimized IR using cost based tree pattern matching Davidson Fraser: Instruction selection over AST using structural tree pattern matching naive code which is target dependent, and is optimized subsequently Front End AST Expander Register Transfers Optimizer Register Transfers Recognizer Target Program

GROW 2011, Chamonix specrtl: Introduction 3/29 Retargetability in Aho Ullman and Davidson Fraser Models Instruction Selection Aho Ullman Model Davisdon Fraser Model Machine independent IR is expressed in the form of trees Machine instructions are described in the form of trees Trees in the IR are covered using the instruction trees Optimization

GROW 2011, Chamonix specrtl: Introduction 3/29 Retargetability in Aho Ullman and Davidson Fraser Models Instruction Selection Aho Ullman Model Davisdon Fraser Model Machine independent IR is expressed in the form of trees Machine instructions are described in the form of trees Trees in the IR are covered using the instruction trees Cost based tree pattern matching Optimization

GROW 2011, Chamonix specrtl: Introduction 3/29 Retargetability in Aho Ullman and Davidson Fraser Models Instruction Selection Aho Ullman Model Davisdon Fraser Model Machine independent IR is expressed in the form of trees Machine instructions are described in the form of trees Trees in the IR are covered using the instruction trees Cost based tree pattern Structual tree pattern matching matching Optimization

GROW 2011, Chamonix specrtl: Introduction 3/29 Retargetability in Aho Ullman and Davidson Fraser Models Instruction Selection Aho Ullman Model Davisdon Fraser Model Machine independent IR is expressed in the form of trees Machine instructions are described in the form of trees Trees in the IR are covered using the instruction trees Cost based tree pattern Structual tree pattern matching matching Optimization Machine independent

GROW 2011, Chamonix specrtl: Introduction 3/29 Retargetability in Aho Ullman and Davidson Fraser Models Instruction Selection Aho Ullman Model Davisdon Fraser Model Machine independent IR is expressed in the form of trees Machine instructions are described in the form of trees Trees in the IR are covered using the instruction trees Cost based tree pattern Structual tree pattern matching matching Machine dependent Optimization Machine independent

GROW 2011, Chamonix specrtl: Introduction 3/29 Retargetability in Aho Ullman and Davidson Fraser Models Instruction Selection Aho Ullman Model Davisdon Fraser Model Machine independent IR is expressed in the form of trees Machine instructions are described in the form of trees Trees in the IR are covered using the instruction trees Cost based tree pattern Structual tree pattern matching matching Machine dependent Optimization Machine independent Key Insight: Register transfers are target specific but their form is target independent

GROW 2011, Chamonix specrtl: Introduction 4/29 GCC s Adaptation of Davidson Fraser Model toplev main front end pass manager langhook... code for chosen language GIMPLE passes... pass 1 pass 2 code for pass 1 code for pass 2 expander code generated code pass expand RTL passes... pass n 1 pass n optab table code for pass n 1 Pattern matcher insn data

GROW 2011, Chamonix specrtl: Introduction 5/29 Comparing Code Generators in Davidson Fraser Model GCC Zephyr/VPO Quick C-- Expander Recognizer Transformation Trees (TT) Nature of TT Fixing shapes of TT TT Inst method TT Inst mapping Time of devising TT Inst mapping RTL templates Target dependent MD writing Pattern matching using finite automaton Fixed manually MD writing RTL templates Expansion tiles Target dependent MD writing LR parsing (Yacc based) Discovered automatically Compilation Target independent Framework design Pattern matching Discovered automatically Compiler construction

Part 2 Motivation

GROW 2011, Chamonix specrtl: Motivation 6/29 The Need for Improving Machine Descriptions The Problems: The specification mechanism for Machine descriptions is quite adhoc Adhoc design decisions

GROW 2011, Chamonix specrtl: Motivation 6/29 The Need for Improving Machine Descriptions The Problems: The specification mechanism for Machine descriptions is quite adhoc Adhoc design decisions

GROW 2011, Chamonix specrtl: Motivation 6/29 The Need for Improving Machine Descriptions The Problems: The specification mechanism for Machine descriptions is quite adhoc Only syntax borrowed from LISP, neither semantics not spirit! Non-composable rules Mode and code iterator mechanisms are insufficient Adhoc design decisions

GROW 2011, Chamonix specrtl: Motivation 6/29 The Need for Improving Machine Descriptions The Problems: The specification mechanism for Machine descriptions is quite adhoc Only syntax borrowed from LISP, neither semantics not spirit! Non-composable rules Mode and code iterator mechanisms are insufficient Adhoc design decisions Honouring operand constraints delayed to global register allocation During GIMPLE to RTL translation, a lot of C code is required Choice of insertion of NOPs

GROW 2011, Chamonix specrtl: Motivation 7/29 Symptom of Poor Specification Mechanism Machine descriptions are large, verbose, repetitive, and contain large chunks of C code Size in terms of line counts for gcc-4.5.0 Target *.md *.c *.h Total i386 35766 28643 15694 80103 mips 12930 12572 5105 30607

GROW 2011, Chamonix specrtl: Motivation 7/29 Symptom of Poor Specification Mechanism Machine descriptions are large, verbose, repetitive, and contain large chunks of C code Size in terms of line counts for gcc-4.5.0 Target *.md *.c *.h Total i386 35766 28643 15694 80103 mips 12930 12572 5105 30607 Machine descriptions are difficult to construct, understand, debug, and enhance

GROW 2011, Chamonix specrtl: Motivation 8/29 Typical Instruction Specification in GCC (define_insn "movsi" [(set (match_operand:si 0 "register_operand" "r") (match_operand:si 1 "const_int_operand" "k") )] "" /* C boolean expression, if required */ "li %0, %1" )

GROW 2011, Chamonix specrtl: Motivation 8/29 Typical Instruction Specification in GCC Define instruction pattern Standard Pattern Name (define_insn "movsi" [(set (match_operand:si 0 "register_operand" "r") (match_operand:si 1 "const_int_operand" "k") )] "" /* C boolean expression, if required */ "li %0, %1" ) RTL Expression (RTX): Semantics of target instruction target asm inst. = Concrete syntax for RTX

GROW 2011, Chamonix specrtl: Motivation 8/29 Typical Instruction Specification in GCC RTL operator MD constructs (define_insn "movsi" [(set (match_operand:si 0 "register_operand" "r") (match_operand:si 1 "const_int_operand" "k") )] "" /* C boolean expression, if required */ "li %0, %1" ) Mode Predicates Constraints

GROW 2011, Chamonix specrtl: Motivation 9/29 Design Flaws in Machine Descriptions Multiple patterns with same structure Repetition of almost similar RTL expressions across multiple define insn an define expand patterns Some Modes, Predicates, Constraints, Boolean Condition, or RTL Expression may differ everything else may be identical One RTL expression may appears as a sub-expression of some other RTL expression Repetition of C code along with RTL expressions in these patterns.

GROW 2011, Chamonix specrtl: Motivation 10/29 Redundancy in MIPS Machine Descriptions: Example 1 [(set (match_operand:m 0 "register_operand" "c0") (plus:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "p" "c2")))] RTL Template

GROW 2011, Chamonix specrtl: Motivation 10/29 Redundancy in MIPS Machine Descriptions: Example 1 [(set (match_operand:m 0 "register_operand" "c0") (plus:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "p" "c2")))] RTL Template Structure = +

GROW 2011, Chamonix specrtl: Motivation 10/29 Redundancy in MIPS Machine Descriptions: Example 1 [(set (match_operand:m 0 "register_operand" "c0") (plus:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "p" "c2")))] RTL Template Structure = + Details Pattern name m p c0 c1 c2 define insn add<mode>3 ANYF register operand =f f f define expand add<mode>3 GPR arith operand define insn *add<mode>3 GPR arith operand =d,d d,d d,q

GROW 2011, Chamonix specrtl: Motivation 11/29 Redundancy in MIPS Machine Descriptions: Example 2 [(set (match_operand:m 0 "register_operand" "c0") (mult:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "register_operand" "c2")))] RTL Template

GROW 2011, Chamonix specrtl: Motivation 11/29 Redundancy in MIPS Machine Descriptions: Example 2 [(set (match_operand:m 0 "register_operand" "c0") (mult:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "register_operand" "c2")))] RTL Template = Structure

GROW 2011, Chamonix specrtl: Motivation 11/29 Redundancy in MIPS Machine Descriptions: Example 2 [(set (match_operand:m 0 "register_operand" "c0") (mult:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "register_operand" "c2")))] RTL Template = Structure Details Pattern name m c0 c1 c2 define insn *mul<mode>3 SCALARF =f f f define insn *mul<mode>3 r4300 SCALARF =f f f define insn mulv2sf3 V2SF =f f f define expand mul<mode>3 GPR define insn mul<mode>3 mul3 loongson GPR =d d d define insn mul<mode>3 mul3 GPR d,1 d,d d,d

GROW 2011, Chamonix specrtl: Motivation 12/29 Redundancy in MIPS Machine Descriptions: Example 3 [(set (match_operand:m 0 "register_operand" "c0") (plus:m (mult:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "register_operand" "c2")))] (match_operand:m 3 "register_operand" "c3")))] RTL Template

GROW 2011, Chamonix specrtl: Motivation 12/29 Redundancy in MIPS Machine Descriptions: Example 3 [(set (match_operand:m 0 "register_operand" "c0") (plus:m (mult:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "register_operand" "c2")))] (match_operand:m 3 "register_operand" "c3")))] RTL Template = Structure +

GROW 2011, Chamonix specrtl: Motivation 12/29 Redundancy in MIPS Machine Descriptions: Example 3 [(set (match_operand:m 0 "register_operand" "c0") (plus:m (mult:m (match_operand:m 1 "register_operand" "c1") (match_operand:m 2 "register_operand" "c2")))] (match_operand:m 3 "register_operand" "c3")))] RTL Template = Structure + Details Pattern name m c0 c1 c2 c3 *mul acc si SI =l*?*?,d? d,d d,d 0,d *mul acc si r3900 SI =l*?*?,d*?,d? d,d,d d,d,d 0,1,d *macc SI =l,d d,d d,d 0,1 *madd4<mode> ANYF =f f f f *madd3<mode> ANYF =f f f 0

GROW 2011, Chamonix specrtl: Motivation 13/29 Insufficient Iterator Mechanism Iterators cannot be used across define insn, define expand, define peephole2 and other patterns Defining iterator attribute for each varying parameter becomes tedious For same set of modes and rtx codes, change in other fields of pattern makes use of iterators impossible Mode and code attributes cannot be defined for operator or operand number, name of the pattern etc. Patterns with different RTL template share attribute value vector for which iterators can not be used

GROW 2011, Chamonix specrtl: Motivation 14/29 Many Similar Patterns Cannot be Combined (define expand iordi3 [(set (match operand:di 0 nonimmediate operand ) (ior:di (match operand:di 1 nonimmediate operand ) (match operand:di 2 x86 64 general operand ))) (clobber (reg:cc FLAGS REG))] TARGET 64BIT ix86 expand binary operator (IOR, DImode, operands); DONE; ) (define insn *iordi 1 rex64 [(set (match operand:di 0 nonimmediate operand =rm,r ) (ior:di (match operand:di 1 nonimmediate operand %0,0 ) (match operand:di 2 x86 64 general operand re,rme ))) (clobber (reg:cc FLAGS REG))] TARGET 64BIT && ix86 binary operator ok (IOR, DImode, operands) or{q}\t{%2, %0 %0, %2} [(set attr type alu ) (set attr mode DI )])

GROW 2011, Chamonix specrtl: Motivation 15/29 Measuring Redundancy in RTL Templates MD File Total number of patterns Number of primitive trees Number of times primitive trees are used to create composite trees i386.md 1303 349 4308 arm.md 534 232 1369 mips.md 337 147 921

Part 3 Introduction to specrtl

GROW 2011, Chamonix specrtl: Introduction to specrtl 16/29 Key Observation Behind specrtl Davidson Fraser insight Register transfers are target specific but their form is target independent GCC s approach Use Target independent RTL for machine specification Generate expander and recognizer by reading machine descriptions Main problems with GCC s Approach Although the shapes of RTL statements are target independent, they have to be provided in RTL templates Our key idea: Separate shapes of RTL statements from the target specific details

GROW 2011, Chamonix specrtl: Introduction to specrtl 17/29 Specification Goals of specrtl Support all of the following Separation of shapes from target specific details Creation of new shapes by composing shapes Associtiating concrete details with shapes Overriding concrete details

GROW 2011, Chamonix specrtl: Introduction to specrtl 18/29 Software Engineering Goals of specrtl Allow non-disruptive migration for existing machine descriptions Incremental changes No need to change GCC source until we are sure of the new specification GCC must remain usable after each small change made in the machine descriptions

GROW 2011, Chamonix specrtl: Introduction to specrtl 19/29 Meeting the Specification Goals: Key Idea Separation of shapes from target specific details: Shape tree structure of RTL templates Details attributes of tree nodes (eg. modes, predicates, constraints etc.)

GROW 2011, Chamonix specrtl: Introduction to specrtl 19/29 Meeting the Specification Goals: Key Idea Separation of shapes from target specific details: Shape tree structure of RTL templates Details attributes of tree nodes (eg. modes, predicates, constraints etc.) Abstract patterns and Concrete patterns Abstract patterns are shapes with holes in them that represent missing information Concrete patterns are shapes in which all holes are plugged in using target specific information

GROW 2011, Chamonix specrtl: Introduction to specrtl 19/29 Meeting the Specification Goals: Key Idea Separation of shapes from target specific details: Shape tree structure of RTL templates Details attributes of tree nodes (eg. modes, predicates, constraints etc.) Abstract patterns and Concrete patterns Abstract patterns are shapes with holes in them that represent missing information Concrete patterns are shapes in which all holes are plugged in using target specific information Abstract patterns capture shapes which can be concretized by providing details

GROW 2011, Chamonix specrtl: Introduction to specrtl 20/29 Meeting the Specification Goals: Operations Creating new shapes by composing shapes: extends

GROW 2011, Chamonix specrtl: Introduction to specrtl 20/29 Meeting the Specification Goals: Operations Creating new shapes by composing shapes: extends Associtiating concrete details with shapes: instantiates

GROW 2011, Chamonix specrtl: Introduction to specrtl 20/29 Meeting the Specification Goals: Operations Creating new shapes by composing shapes: extends Associtiating concrete details with shapes: instantiates Overriding concrete details: overrides

GROW 2011, Chamonix specrtl: Introduction to specrtl 21/29 Properties of Operations Operation Base pattern Derived pattern Nodes influenced Can change extends Abstract Abstract Leaf nodes Structure instantiates Abstract Concrete All nodes Attributes Abstract Abstract Internal nodes Attributes overrides Concrete Concrete All nodes Attributes

GROW 2011, Chamonix specrtl: Introduction to specrtl 22/29 Creating Abstract Patterns abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root + root.2 root.2.2 abstract set_macc extends set_plus { root.2.2 = mult; } = root + root.2 root.1 root.2.2 root.2.1 root.2.2.1 root.2.2.2

GROW 2011, Chamonix specrtl: Introduction to specrtl 23/29 Creating Concrete Patterns abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root concrete add<mode>3.insn instantiates set_plus { set_plus(register_operand:anyf:"=f", register_operand:anyf:"f", register_operand:anyf:"f"); root.2.mode = ANYF; } concrete add<mode>3.expand instantiates set_plus { set_plus(register_operand:gpr:"", register_operand:gpr:"", arith_operand:gpr:""); root.2.mode = GPR; } + root.2 root.2.2

GROW 2011, Chamonix specrtl: Introduction to specrtl 24/29 Generating Conventional Machine Descriptions abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root + root.2 root.2.2 concrete add<mode>3.insn instantiates set_plus { set_plus(register_operand:anyf:"=f", register_operand:anyf:"f", register_operand:anyf:"f"); root.2.mode = ANYF; } {: /* Conventional Machine Description Fragments */ :} (define_insn "add<mode>3" [(set (match_operand:anyf 0 "register_operand" "=f") (plus:anyf (match_operand:anyf 1 "register_operand" "f") (match_operand:anyf 2 "register_operand" "f")))] /* Conventional Machine Description Fragments */ )

GROW 2011, Chamonix specrtl: Introduction to specrtl 24/29 Generating Conventional Machine Descriptions abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root + root.2 root.2.2 concrete add<mode>3.insn instantiates set_plus { set_plus(register_operand:anyf:"=f", register_operand:anyf:"f", register_operand:anyf:"f"); root.2.mode = ANYF; } {: /* Conventional Machine Description Fragments */ :} (define_insn "add<mode>3" [(set (match_operand:anyf 0 "register_operand" "=f") (plus:anyf (match_operand:anyf 1 "register_operand" "f") (match_operand:anyf 2 "register_operand" "f")))] /* Conventional Machine Description Fragments */ )

GROW 2011, Chamonix specrtl: Introduction to specrtl 24/29 Generating Conventional Machine Descriptions abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root + root.2 root.2.2 concrete add<mode>3.insn instantiates set_plus { set_plus(register_operand:anyf:"=f", register_operand:anyf:"f", register_operand:anyf:"f"); root.2.mode = ANYF; } {: /* Conventional Machine Description Fragments */ :} Resulting MD Specification (define_insn "add<mode>3" [(set (match_operand:anyf 0 "register_operand" "=f") (plus:anyf (match_operand:anyf 1 "register_operand" "f") (match_operand:anyf 2 "register_operand" "f")))] /* Conventional Machine Description Fragments */ )

GROW 2011, Chamonix specrtl: Introduction to specrtl 25/29 Overriding Details abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root concrete add<mode>3.expand instantiates set_plus { set_plus(register_operand:gpr:"", register_operand:gpr:"", arith_operand:gpr:""); root.2.mode = GPR; } + root.2 root.2.2 concrete *add<mode>3.insn overrides add<mode>3.expand { allconstraints = ("=d,d", "d,d", "d,q"); }

GROW 2011, Chamonix specrtl: Introduction to specrtl 25/29 Overriding Details abstract set_plus extends set { root.2 = plus; } root.1 root.2.1 = root concrete add<mode>3.expand instantiates set_plus { set_plus(register_operand:gpr:"", register_operand:gpr:"", arith_operand:gpr:""); root.2.mode = GPR; } + root.2 root.2.2 concrete *add<mode>3.insn overrides add<mode>3.expand { allconstraints = ("=d,d", "d,d", "d,q"); }

GROW 2011, Chamonix specrtl: Introduction to specrtl 26/29 Some More Examples Omitting conventional MD fragments concrete *mul<mode>3.insn instantiates set_mult { set_mult(register_operand:scalarf:"=f", register_operand:scalarf:"f", register_operand:scalarf:"f"); root.2.mode = SCALARF; } concrete *mul<mode>3_r4300.insn overrides *mul<mode>3.insn {} concrete mulv2sf3 overrides *mul<mode>3.insn { SCALARF -> V2SF; }

GROW 2011, Chamonix specrtl: Introduction to specrtl 26/29 Some More Examples Omitting conventional MD fragments concrete *mul<mode>3.insn instantiates set_mult { set_mult(register_operand:scalarf:"=f", register_operand:scalarf:"f", register_operand:scalarf:"f"); root.2.mode = SCALARF; } concrete *mul<mode>3_r4300.insn overrides *mul<mode>3.insn {} concrete mulv2sf3 overrides *mul<mode>3.insn { SCALARF -> V2SF; }

Part 4 Conclusions

GROW 2011, Chamonix specrtl: Conclusions 27/29 Current Status and Plans for Future Work specrtl parser has been augmented with semantic checks Emitting conventional machine descriptions is pending i386 move instructions and spim add instructions have been rewritten Other instructions are being rewritten Suggestions have been received to improve the syntax

GROW 2011, Chamonix specrtl: Conclusions 28/29 Conclusions Separating shapes from concrete details is very helpful It may be possible to identify a large number of common shapes Machine descriptions may become much smaller Only the concrete details need to be specified Non-disruptive and incremental migration to new machine descriptions GCC source need not change until these machine descriptions have been found useful

GROW 2011, Chamonix specrtl: Conclusions 29/29 Last but not the least... Thank You!