Instruction Selection
|
|
- Daniel Marshall
- 5 years ago
- Views:
Transcription
1 Compiler Design Instruction Selection Hwansoo Han
2 Structure of a Compiler O(n) O(n) O(n log n) Scanner words Parser IR Analysis & Optimization IR Instruction Selection Either fast or NP-Complete asm asm asm regs Instruction Scheduling NP-Complete regs Register Allocation NP-Complete k regs The hard stuff is mostly in code generation and optimization Conventional wisdom says that we lose little by solving these three problems independently 2
3 Big Picture of Code Generation Instruction selection Maps IR into assembly code Assumes a fixed storage mapping & code shape Assume enough registers or target important values Can make locally optimal choices, but global optimality is NP- Complete Use some form of pattern matching Combine operations & use address modes 3
4 The Problem Modern computers (still) have many ways to do anything Consider register-to-register copy Obvious operation is i2i r i r j Many others exist addi r i,0 r j subi r i,0 r j lshifti r i,0 r j multi r i,1 r j divi r i,1 r j rshifti r i,0 r j ori r i,0 r j xori r i,0 r j and others Human would ignore all of these Algorithm must look at all of them and Find low-cost encoding Take context into account (busy functional unit?) 4
5 The Goal Want to automate generation of instruction selection Front End Middle End Back End Infrastructure Machine description Back-end Generator Tables Pattern Matching Engine Description-based retargeting Need pattern matching techniques Must produce good code (some metric for good ) Must run quickly 5
6 Simple Treewalk Simple treewalk code generator runs quickly How good is the code? Tree Treewalk Code Desired Code IDENT <a,arp,4> x IDENT <b,arp,8> loadi 4 r 5 loadao r 0,r 5 r 6 loadi 8 r 7 loadao r 0,r 7 r 8 mult r 6,r 8 r 9 loadai r 0,4 r 5 loadai r 0,8 r 6 mult r 5,r 6 r 7 6
7 Example: Quality of Treewalk Code Tree Treewalk Code Desired Code IDENT <a,arp,4> x NUMBER <2> loadi 4 r 5 loadao r 0,r 5 r 6 loadi 2 r 7 mult r 6,r 7 r 8 loadai r 0,4 r 5 multi r 5,2 r 7 Must combine these This is a nonlocal problem IDENT <c,@g,4> x IDENT <d,@h,4> Common offset r 5 loadi 4 r 6 loadao r 5,r 6 r 7 r 7 loadi 4 r 8 loadao r 8,r 9 r 10 mult r 7,r 10 r 11 7 loadi 4 r 5 loadai r 5,@G r 6 loadai r 5,@H r 7 mult r 6,r 7 r 8
8 Tree-Pattern Matching Many compilers use tree-structured IRs Abstract syntax trees generated in the parser Trees or DAGs for expressions These systems might well use trees to represent target ISA Consider add operators If we can match these pattern trees against IR trees, r i + r j r i + c j Operation trees add r i,r j r k addi r i,c j r k 8
9 AST Example Low-level AST for w x - 2 * y VAL ARP + NUM 4 REF REF + - NUM 2 * REF + ARP: r arp NUM: constant LAB: ASM label w: at ARP+4 (local var) x: at ARP-26 (call-by-ref) Y: (global var) VAL ARP NUM -26 NUM 12 9
10 Notation For Operation Tree To describe these trees, we need a concise notation + +(r i,c j ) r i c j + +(r i,r j ) Linear prefix form r i r j 10
11 Notation for Tree-Pattern AST To describe these trees, we need a concise notation + GETS - -(REF(REF(+(VAL 2,NUM 2 ))), *(NUM 3,(REF(+(LAB 1,NUM 3 )))))) *(NUM 3,(REF(+(LAB 1,NUM 3 )))))) VAL ARP NUM 4 REF * +(VAL 1,NUM 1 ) REF + NUM 2 REF + REF(REF(+(VAL 2,NUM 2 ))) VAL ARP NUM -26 NUM 12 GETS(+(VAL 1,NUM 1 ), -(REF(REF(+(VAL 2,NUM 2 ))), *(NUM 3,(REF(+(LAB 1,NUM 3 )))))) 11
12 Inst. Selection via Tree-Pattern Matching Goal is to tile AST with operation trees A tiling is collection of <ast, op > pairs ast is a node in the AST op is an operation tree <ast, op > means that op could implement the subtree at ast A tiling implements an AST Cover every node (overlap is limited to a single node) Compatible trees (if two operation trees meet, expect the value in the same location) 12
13 Example: Tiling the Tree GETS Tile 6 + VAL Tile 1 NUM ARP 4 REF REF + - Tile 5 * NUM Tile 4 2 REF + Each tile corresponds to a sequence of operations Emitting those operations in an appropriate order implements the tree. - Postorder or - Bottom-up walk VAL ARP Tile 2 NUM -26 Tile 3 NUM 12 13
14 Finding Matches to Tile Compiler relates operation trees to AST subtrees Provides a set of rewrite rules Encode tree syntax, in linear form Associated with each is a code template Production Rule Cost Code Template 1 Goal Assign 0 2 Assign GETS(Reg 1,Reg 2 ) 1 store r 2 r 1 3 Assign GETS(+(Reg 1,Reg 2 ),Reg 3 ) 1 storeao r 3 r 1,r 2 4 Assign GETS(+(Reg 1,NUM 2 ),Reg 3 ) 1 storeai r 3 r 1,n 2 5 Assign GETS(+(NUM 1,Reg 2 ),Reg 3 ) 1 storeai r 3 r 2,n 1 6 Reg LAB 1 1 loadi l 1 r new 7 Reg VAL Reg NUM 1 1 loadi n 1 r new 14
15 Rewrite Rules Production Rule Cost Code Template 9 Reg REF(Reg 1 ) 1 load r 1 r new 10 Reg REF(+ (Reg 1,Reg 2 )) 1 loadao r 1,r 2 r new 11 Reg REF(+ (Reg 1,NUM 2 )) 1 loadai r 1,n 2 r new 12 Reg REF(+ (NUM 1,Reg 2 )) 1 loadai r 2,n 1 r new 13 Reg + (Reg 1,Reg 2 ) 1 add r 1,r 2 r new 14 Reg + (Reg 1,NUM 2 ) 1 addi r 1,n 2 r new 15 Reg + (NUM 1,Reg 2 ) 1 addi r 2,n 1 r new 16 Reg - (Reg 1,Reg 2 ) 1 sub r 1,r 2 r new 17 Reg - (Reg 1,NUM 2 ) 1 subi r 1,n 2 r new 18 Reg - (NUM 1,Reg 2 ) 1 rsubi r 2,n 1 r new 19 Reg x (Reg 1,Reg 2 ) 1 mult r 1,r 2 r new 20 Reg x (Reg 1,NUM 2 ) 1 multi r 1,n 2 r new 21 Reg x (NUM 1,Reg 2 ) 1 multi r 2,n 1 r new 15
16 Finding Matches (1) Multiple possible tilings Need an algorithm to associate AST subtrees with the rules REF NUM 12 What rules match? 6: Reg LAB 1 tiles the lower left node 8: Reg NUM 1 tiles the bottom right node 13: Reg + (Reg 1,Reg 2 ) tiles the + node 9: Reg REF(Reg 1 ) tiles the REF We denote this match as <6,8,13,9> Of course, it implies <8,6,13,9> Both have a cost of 4 16
17 Finding Matches (2) Many Sequences Match Our Subtree Cost Sequences REF + 2 6,11 8,12 3 6,8,10 8,6,10 6,14,9 8,15,9 4 6,8,13,9 8,6,13,9 NUM 12 In general, we want the low cost sequence Each unit of cost is an operation (1 cycle) We should favor short sequences 17
18 Finding Matches (3) Low Cost Matches REF Sequences with Cost of 2 + 6: Reg LAB 1 11: Reg REF(+(Reg 1,NUM 2 )) r i loadai r i,12 r j NUM 12 8: Reg NUM 1 12: Reg REF(+(NUM 1,Reg 2 )) loadi 12 r i loadai r i,@g r j These two are equivalent in cost 6,11 might be better, may be longer than the immediate field 18
19 Inst. Selection via Peephole Optimization Compiler can discover local improvements locally Look at a small set of adjacent operations Move a peephole over code & search for improvement Original code Improved code storeai r 1 r 0,8 storeai r 1 r 0,8 loadai r 0,8 r 15 i2i r 1 r 15 < Store-load > addi r 2,0 r 7 mult r 4,r 7 r 10 mult r 4,r 2 r 10 < identical value > jumpi L 10 L 10 : jumpi L 11 L 10 : jumpi L 11 < jump chain > 19
20 Implementation of Peephole Optimization Implementation Early systems used limited set of hand-coded patterns Window size ensured quick processing Modern peephole instruction selectors (e.g. GCC) Break problem into three tasks IR LLIR LLIR ASM Expander Simplifier Matcher IR LLIR LLIR LLIR LLIR ASM LLIR: lower-level IR 20
21 Peephole Optimization Implementation Expander Turns IR code into a low-level IR (LLIR) such as RTL Operation-by-operation, template-driven rewriting Simplifier Looks at LLIR through window and rewrites Uses forward substitution, algebraic simplification, local constant propagation, and dead-effect elimination Performs local optimization within window Matcher Compares simplified LLIR against a library of patterns Picks low-cost pattern that captures effects Must preserve LLIR effects, may add new ones (e.g., set cc) 21
22 Example : Expand (1) Original IR Code OP Arg 1 Arg 2 Result mult 2 Y t 1 sub x t 1 w Expand LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 Template-driven rewriting (e.g. TreeWalk) 22
23 Example : Simplify (2) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 Simplify MEM(r 0 r 18 LLIR Code r 13 MEM(r 0 r 14 2 x r 13 r 17 MEM(r 0 MEM(r 20 ) r 18 Local optimization within a window 23
24 Example : Match (3) MEM(r 0 r 18 LLIR Code r 13 MEM(r 0 r 14 2 x r 13 r 17 MEM(r 0 Match Final Code loadai r 0,@y r 13 multi 2 x r 13 r 14 loadai r 0,@x r 17 sub r 17 - r 14 r 18 storeai r 18 r 0,@w Compare against pattern library and find best match Turned out pretty good code 24
25 Example: Details of Simplifier (1) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r r 12 r 0 + r 11 3-operation window 25
26 Example: Details of Simplifier (2) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r r 12 r 0 + r 11 r 12 r 0 r 13 MEM(r 12 ) 26
27 Example: Details of Simplifier (3) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 12 r 0 r 13 MEM(r 12 ) r 13 MEM(r 0 r 14 r 10 x r 13 27
28 Example: Details of Simplifier (4) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 13 MEM(r 0 r 14 r 10 x r 13 r 13 MEM(r 0 r 14 2 x r 13 r 28
29 Example: Details of Simplifier (5) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 r 13 MEM(r 0 r 14 2 x r 13 r 1 st op it has rolled out of window r 14 2 x r 13 r r 16 r 0 + r 15 MEM(r 20 ) r 18 29
30 Example: Details of Simplifier (6) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 14 2 x r 13 r r 16 r 0 + r 15 r 14 2 x r 13 r 16 r 0 r 17 MEM(r 16 ) 30
31 Example: Details of Simplifier (7) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 14 2 x r 13 r 16 r 0 r 17 MEM(r 16 ) r 14 2 x r 13 r 17 MEM(r 0 +@x) 31
32 Example: Details of Simplifier (8) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 14 2 x r 13 r 17 MEM(r 0 +@x) r 17 MEM(r 0 +@x) r 32
33 Example: Details of Simplifier (9) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 17 MEM(r 0 +@x) r r r 20 r 0 + r 19 33
34 Example: Details of Simplifier (10) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r r 20 r 0 + r 19 r 20 r 0 MEM(r 20 ) r 18 34
35 Example: Details of Simplifier (11) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 20 r 0 MEM(r 20 ) r 18 MEM(r 0 r 18 35
36 Example: Details of Simplifier (12) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 MEM(r 20 ) r 18 r 20 r 0 MEM(r 20 ) r 18 MEM(r 0 r 18 36
37 Example: Details of Simplifier (13) LLIR Code r r 12 r 0 + r 11 r 13 MEM(r 12 ) r 14 r 10 x r 13 r r 16 r 0 + r 15 r 17 MEM(r 16 ) r r 20 r 0 + r 19 Simplify MEM(r 0 r 18 LLIR Code r 13 MEM(r 0 r 14 2 x r 13 r 17 MEM(r 0 MEM(r 20 ) r 18 37
38 Summary Simple treewalk Potentially poor code quality Tree-Pattern Tiling AST with operation trees Find possible tiles Match with the lowest cost tile Peephole match Expand into LLIR (such as RTL) that is machine independent Simplify using peephole optimizations (key strength of this scheme) Match with ASM Use a hand-coded pattern matcher Turn patterns into grammar & use LR parser (gcc) 38
Material Covered on the Final
Material Covered on the Final On the final exam, you are responsible for: Anything covered in class, except for stories about my good friend Ken Kennedy All lecture material after the midterm ( below the
More informationCompiling Techniques
Lecture 11: Introduction to 13 November 2015 Table of contents 1 Introduction Overview The Backend The Big Picture 2 Code Shape Overview Introduction Overview The Backend The Big Picture Source code FrontEnd
More informationCODE GENERATION REGISTER ALLOCATION. Goal. Interplay between. Translate intermediate code into target code
CODE GENERATION Goal Translate intermediate code into target code Interplay between Register Allocation Instruction Selection Instruction Scheduling 1 REGISTER ALLOCATION 1 REGISTER ALLOCATION Motivation
More informationAutomata Theory CS S-12 Turing Machine Modifications
Automata Theory CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science University of San Francisco 12-0: Extending Turing Machines When we added a stack to NFA to get a
More informationRegister Allocation. Maryam Siahbani CMPT 379 4/5/2016 1
Register Allocation Maryam Siahbani CMPT 379 4/5/2016 1 Register Allocation Intermediate code uses unlimited temporaries Simplifying code generation and optimization Complicates final translation to assembly
More informationECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University
ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University Prof. Mi Lu TA: Ehsan Rohani Laboratory Exercise #4 MIPS Assembly and Simulation
More informationOn my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work
Lab 5 : Linking Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The main objective of this lab is to experiment
More informationSpecial Nodes for Interface
fi fi Special Nodes for Interface SW on processors Chip-level HW Board-level HW fi fi C code VHDL VHDL code retargetable compilation high-level synthesis SW costs HW costs partitioning (solve ILP) cluster
More informationCompiling Techniques
Lecture 7: Abstract Syntax 13 October 2015 Table of contents Syntax Tree 1 Syntax Tree Semantic Actions Examples Abstract Grammar 2 Internal Representation AST Builder 3 Visitor Processing Semantic Actions
More informationECE 5775 (Fall 17) High-Level Digital Design Automation. Control Flow Graph
ECE 5775 (Fall 17) High-Level Digital Design Automation Control Flow Graph Announcements ECE colloquium on Monday 9/11 from 4:30pm, PHL 233 Smart Healthcare by Prof. Niraj Jha of Princeton Lab 1 is due
More informationCompilers. Lexical analysis. Yannis Smaragdakis, U. Athens (original slides by Sam
Compilers Lecture 3 Lexical analysis Yannis Smaragdakis, U. Athens (original slides by Sam Guyer@Tufts) Big picture Source code Front End IR Back End Machine code Errors Front end responsibilities Check
More informationSyntactic Analysis. Top-Down Parsing
Syntactic Analysis Top-Down Parsing Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in Compilers class at University of Southern California (USC) have explicit permission to make
More informationSyntax Analysis, VII The Canonical LR(1) Table Construction. Comp 412
COMP 412 FALL 2018 Syntax Analysis, VII The Canonical LR(1) Table Construction Comp 412 source code IR IR target Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights
More informationLAB 2 - ONE DIMENSIONAL MOTION
Name Date Partners L02-1 LAB 2 - ONE DIMENSIONAL MOTION OBJECTIVES Slow and steady wins the race. Aesop s fable: The Hare and the Tortoise To learn how to use a motion detector and gain more familiarity
More informationRegister Alloca.on. CMPT 379: Compilers Instructor: Anoop Sarkar. anoopsarkar.github.io/compilers-class
Register Alloca.on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class 1 Register Alloca.on Intermediate code uses unlimited temporaries Simplifying code genera.on and op.miza.on
More informationFunctional Big-step Semantics
Functional Big-step Semantics FM talk, 11 Mar 2015 Magnus Myréen Books Big-step semantics are defined as inductively defined relation. Functions are better! me Context: CakeML verified compiler Old compiler:
More informationPipelining. Traditional Execution. CS 365 Lecture 12 Prof. Yih Huang. add ld beq CS CS 365 2
Pipelining CS 365 Lecture 12 Prof. Yih Huang CS 365 1 Traditional Execution 1 2 3 4 1 2 3 4 5 1 2 3 add ld beq CS 365 2 1 Pipelined Execution 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
More informationLexical Analysis: DFA Minimization & Wrap Up
Lexical Analysis: DFA Minimization & Wrap Up Automating Scanner Construction PREVIOUSLY RE NFA (Thompson s construction) Build an NFA for each term Combine them with -moves NFA DFA (subset construction)
More informationCompiler Construction Lent Term 2015 Lectures (of 16)
Compiler Construction Lent Term 2015 Lectures 13 --- 16 (of 16) 1. Return to lexical analysis : application of Theory of Regular Languages and Finite Automata 2. Generating Recursive descent parsers 3.
More informationCompiler Construction Lent Term 2015 Lectures (of 16)
Compiler Construction Lent Term 2015 Lectures 13 --- 16 (of 16) 1. Return to lexical analysis : application of Theory of Regular Languages and Finite Automata 2. Generating Recursive descent parsers 3.
More informationCSE P 501 Compilers. Value Numbering & Op;miza;ons Hal Perkins Winter UW CSE P 501 Winter 2016 S-1
CSE P 501 Compilers Value Numbering & Op;miza;ons Hal Perkins Winter 2016 UW CSE P 501 Winter 2016 S-1 Agenda Op;miza;on (Review) Goals Scope: local, superlocal, regional, global (intraprocedural), interprocedural
More informationPerformance, Power & Energy. ELEC8106/ELEC6102 Spring 2010 Hayden Kwok-Hay So
Performance, Power & Energy ELEC8106/ELEC6102 Spring 2010 Hayden Kwok-Hay So Recall: Goal of this class Performance Reconfiguration Power/ Energy H. So, Sp10 Lecture 3 - ELEC8106/6102 2 PERFORMANCE EVALUATION
More informationECE 5775 (Fall 17) High-Level Digital Design Automation. Scheduling: Exact Methods
ECE 5775 (Fall 17) High-Level Digital Design Automation Scheduling: Exact Methods Announcements Sign up for the first student-led discussions today One slot remaining Presenters for the 1st session will
More informationComputer Science 160 Translation of Programming Languages
Computer Science 160 Translation of Programming Languages Instructor: Christopher Kruegel Building a Handle Recognizing Machine: [now, with a look-ahead token, which is LR(1) ] LR(k) items An LR(k) item
More informationConstruction of Static Single-Assignment Form
COMP 506 Rice University Spring 2018 Construction of Static Single-Assignment Form Part II source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all
More informationCombinatorial Aspects of Tropical Geometry and its interactions with phylogenetics
Combinatorial Aspects of Tropical Geometry and its interactions with phylogenetics María Angélica Cueto Department of Mathematics Columbia University Rabadan Lab Metting Columbia University College of
More informationLecture 10: Data Flow Analysis II
CS 515 Programming Language and Compilers I Lecture 10: Data Flow Analysis II (The lectures are based on the slides copyrighted by Keith Cooper and Linda Torczon from Rice University.) Zheng (Eddy) Zhang
More informationScheduling I. Today. Next Time. ! Introduction to scheduling! Classical algorithms. ! Advanced topics on scheduling
Scheduling I Today! Introduction to scheduling! Classical algorithms Next Time! Advanced topics on scheduling Scheduling out there! You are the manager of a supermarket (ok, things don t always turn out
More informationExploring the Potential of Instruction-Level Parallelism of Exposed Datapath Architectures with Buffered Processing Units
Exploring the Potential of Instruction-Level Parallelism of Exposed Datapath Architectures with Buffered Processing Units Anoop Bhagyanath and Klaus Schneider Embedded Systems Chair University of Kaiserslautern
More informationSyntax Analysis Part I
1 Syntax Analysis Part I Chapter 4 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2013 2 Position of a Parser in the Compiler Model Source Program Lexical Analyzer
More informationSyntax Analysis Part I
1 Syntax Analysis Part I Chapter 4 COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University, 2007-2013 2 Position of a Parser in the Compiler Model Source Program Lexical Analyzer
More informationSyntax Directed Transla1on
Syntax Directed Transla1on Syntax Directed Transla1on CMPT 379: Compilers Instructor: Anoop Sarkar anoopsarkar.github.io/compilers-class Syntax directed Translation Models for translation from parse trees
More informationTopic-I-C Dataflow Analysis
Topic-I-C Dataflow Analysis 2012/3/2 \course\cpeg421-08s\topic4-a.ppt 1 Global Dataflow Analysis Motivation We need to know variable def and use information between basic blocks for: constant folding dead-code
More informationYou Might Also Like. I look forward helping you focus your instruction while saving tons of time. Kesler Science Station Lab Activities 40%+ Savings!
Thanks Thank you for downloading my product. I truly appreciate your support and look forward to hearing your feedback. Connect You can connect with me and find many free activities and strategies over
More informationSyntax Analysis, VI Examples from LR Parsing. Comp 412
COMP 412 FALL 2017 Syntax Analysis, VI Examples from LR Parsing Comp 412 source code IR IR target code Front End Optimizer Back End Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved.
More informationTowards a formal description of models and workflows
Towards a formal description of models and workflows Heinz A Preisig Process Systems Engineering @ Chemical Engineering NTNU, Trondheim, Norway MoDeNa - FP7 ++ Computational engineering The vision that
More informationA Second Datapath Example YH16
A Second Datapath Example YH16 Lecture 09 Prof. Yih Huang S365 1 A 16-Bit Architecture: YH16 A word is 16 bit wide 32 general purpose registers, 16 bits each Like MIPS, 0 is hardwired zero. 16 bit P 16
More informationSyntax Analysis Part I. Position of a Parser in the Compiler Model. The Parser. Chapter 4
1 Syntax Analysis Part I Chapter 4 COP5621 Compiler Construction Copyright Robert van ngelen, Flora State University, 2007 Position of a Parser in the Compiler Model 2 Source Program Lexical Analyzer Lexical
More informationComputer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic
Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Digital Logic Our goal for the next few weeks is to paint a a reasonably complete picture of how we can go from transistor
More informationAnnouncements. Final exam review session tomorrow in Gates 104 from 2:15PM 4:15PM Final Friday Four Square of the quarter!
The Big Picture Problem Problem Set Set 99 due due in in the the box box up up front. front. Congrats Congrats on on finishing finishing the the last last problem problem set set of of the the quarter!
More informationCSCI-564 Advanced Computer Architecture
CSCI-564 Advanced Computer Architecture Lecture 8: Handling Exceptions and Interrupts / Superscalar Bo Wu Colorado School of Mines Branch Delay Slots (expose control hazard to software) Change the ISA
More informationNunchaku: Flexible Model Finding for Higher-Order Logic
Nunchaku: Flexible Model Finding for Higher-Order Logic Simon Cruanes, Jasmin Blanchette, Andrew Reynolds Veridis, Inria Nancy https://cedeela.fr/~simon/ April 7th, 2016 1 / 21 Summary Introduction Nunchaku
More informationLR(1) Parsers Part II. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.
LR(1) Parsers Part II Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. LR(1) Parsers A table-driven LR(1) parser looks like source code Scanner Table-driven Parser IR grammar Parser
More informationStatic Program Analysis
Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-18/spa/ Recap: Interprocedural Dataflow Analysis Outline of
More informationDSP Design Lecture 7. Unfolding cont. & Folding. Dr. Fredrik Edman.
SP esign Lecture 7 Unfolding cont. & Folding r. Fredrik Edman fredrik.edman@eit.lth.se Unfolding Unfolding creates a program with more than one iteration, J=unfolding factor Unfolding is a structured way
More informationScheduling I. Today Introduction to scheduling Classical algorithms. Next Time Advanced topics on scheduling
Scheduling I Today Introduction to scheduling Classical algorithms Next Time Advanced topics on scheduling Scheduling out there You are the manager of a supermarket (ok, things don t always turn out the
More informationArithmetic and Logic Unit First Part
Arithmetic and Logic Unit First Part Arquitectura de Computadoras Arturo Díaz D PérezP Centro de Investigación n y de Estudios Avanzados del IPN adiaz@cinvestav.mx Arquitectura de Computadoras ALU1-1 Typical
More informationFinite State Machine (FSM)
Finite State Machine (FSM) Consists of: State register Stores current state Loads next state at clock edge Combinational logic Computes the next state Computes the outputs S S Next State CLK Current State
More informationAPTAS for Bin Packing
APTAS for Bin Packing Bin Packing has an asymptotic PTAS (APTAS) [de la Vega and Leuker, 1980] For every fixed ε > 0 algorithm outputs a solution of size (1+ε)OPT + 1 in time polynomial in n APTAS for
More informationCSC 4181Compiler Construction. Context-Free Grammars Using grammars in parsers. Parsing Process. Context-Free Grammar
CSC 4181Compiler Construction Context-ree Grammars Using grammars in parsers CG 1 Parsing Process Call the scanner to get tokens Build a parse tree from the stream of tokens A parse tree shows the syntactic
More informationLexical Analysis Part II: Constructing a Scanner from Regular Expressions
Lexical Analysis Part II: Constructing a Scanner from Regular Expressions CS434 Spring 2005 Department of Computer Science University of Alabama Joel Jones Copyright 2003, Keith D. Cooper, Ken Kennedy
More informationDescription of the ED library Basic Atoms
Description of the ED library Basic Atoms Simulation Software / Description of the ED library BASIC ATOMS Enterprise Dynamics Copyright 2010 Incontrol Simulation Software B.V. All rights reserved Papendorpseweg
More informationCA Compiler Construction
CA4003 - Compiler Construction Code Generation to MIPS David Sinclair Code Generation The generation o machine code depends heavily on: the intermediate representation;and the target processor. We are
More informationUNIT-VIII COMPUTABILITY THEORY
CONTEXT SENSITIVE LANGUAGE UNIT-VIII COMPUTABILITY THEORY A Context Sensitive Grammar is a 4-tuple, G = (N, Σ P, S) where: N Set of non terminal symbols Σ Set of terminal symbols S Start symbol of the
More informationCSE 200 Lecture Notes Turing machine vs. RAM machine vs. circuits
CSE 200 Lecture Notes Turing machine vs. RAM machine vs. circuits Chris Calabro January 13, 2016 1 RAM model There are many possible, roughly equivalent RAM models. Below we will define one in the fashion
More informationCOMPUTER SCIENCE TRIPOS
CST.2016.6.1 COMPUTER SCIENCE TRIPOS Part IB Thursday 2 June 2016 1.30 to 4.30 COMPUTER SCIENCE Paper 6 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.
More informationInformatique Fondamentale IMA S8
Informatique Fondamentale IMA S8 Cours 4 : graphs, problems and algorithms on graphs, (notions of) NP completeness Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytech-lille.fr Université
More informationAccelerating Decoupled Look-ahead to Exploit Implicit Parallelism
Accelerating Decoupled Look-ahead to Exploit Implicit Parallelism Raj Parihar Advisor: Prof. Michael C. Huang March 22, 2013 Raj Parihar Accelerating Decoupled Look-ahead to Exploit Implicit Parallelism
More informationLecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation
1 Lecture Overview SSA Maximal SSA Semipruned SSA o Placing -functions o Renaming Translation out of SSA Using SSA: Sparse Simple Constant Propagation [Chapter 9] 2 SSA Revisited It is desirable to use
More informationAlgebraic Dynamic Programming
Algebraic Dynamic Programming Unit 2.b: Introduction to Bellman s GAP Robert Giegerich 1 (Lecture) Benedikt Löwes (Exercises) Faculty of Technology Bielefeld University http://www.techfak.uni-bielefeld.de/ags/pi/lehre/adp
More informationLR(1) Parsers Part III Last Parsing Lecture. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.
LR(1) Parsers Part III Last Parsing Lecture Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. LR(1) Parsers A table-driven LR(1) parser looks like source code Scanner Table-driven Parser
More informationLab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations
Lab 2 Worksheet Problems Problem : Geometry and Linear Equations Linear algebra is, first and foremost, the study of systems of linear equations. You are going to encounter linear systems frequently in
More informationMachine Learning CPSC 340. Tutorial 12
Machine Learning CPSC 340 Tutorial 12 Random Walk on Graph Page Rank Algorithm Label Propagation on Graph Assume a strongly connected graph G = (V, A) Label Propagation on Graph Assume a strongly connected
More informationParallelism and Machine Models
Parallelism and Machine Models Andrew D Smith University of New Brunswick, Fredericton Faculty of Computer Science Overview Part 1: The Parallel Computation Thesis Part 2: Parallelism of Arithmetic RAMs
More informationUsing the Prover I: Lee Pike. June 3, NASA Langley Formal Methods Group Using the Prover I:
Basic Basic NASA Langley Formal Methods Group lee.s.pike@nasa.gov June 3, 2005 Basic Sequents Basic Sequent semantics: The conjunction of the antecedents above the turnstile implies the disjunction of
More informationCMSC 330: Organization of Programming Languages. Pushdown Automata Parsing
CMSC 330: Organization of Programming Languages Pushdown Automata Parsing Chomsky Hierarchy Categorization of various languages and grammars Each is strictly more restrictive than the previous First described
More informationAutomated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving
Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving Matt Fredrikson mfredrik@cs.cmu.edu October 17, 2016 Matt Fredrikson SAT Solving 1 / 36 Review: Propositional
More informationTheory of Computation. Theory of Computation
Theory of Computation Theory of Computation What is possible to compute? We can prove that there are some problems computers cannot solve There are some problems computers can theoretically solve, but
More informationDataflow analysis. Theory and Applications. cs6463 1
Dataflow analysis Theory and Applications cs6463 1 Control-flow graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows
More informationPhysics Lab #2: Spectroscopy
Physics 10263 Lab #2: Spectroscopy Introduction This lab is meant to serve as an introduction to the science of spectroscopy. In this lab, we ll learn about how emission and absorption works, and we ll
More informationCOOKBOOK KVL AND KCL A COMPLETE GUIDE
1250 COOKBOOK KVL AND KCL A COMPLETE GUIDE Example circuit: 1) Label all source and component values with a voltage drop measurement (+,- ) and a current flow measurement (arrow): By the passive sign convention,
More informationLogical Agent & Propositional Logic
Logical Agent & Propositional Logic Berlin Chen 2005 References: 1. S. Russell and P. Norvig. Artificial Intelligence: A Modern Approach. Chapter 7 2. S. Russell s teaching materials Introduction The representation
More informationIE418 Integer Programming
IE418: Integer Programming Department of Industrial and Systems Engineering Lehigh University 2nd February 2005 Boring Stuff Extra Linux Class: 8AM 11AM, Wednesday February 9. Room??? Accounts and Passwords
More informationDataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation
-74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation
More informationCTL satisfability via tableau A C++ implementation
CTL satisfability via tableau A C++ implementation Nicola Prezza April 30, 2015 Outline 1 Introduction 2 Parsing 3 Data structures 4 Initial sets of labels and edges 5 Cull 6 Examples and benchmarks The
More informationDivisible Load Scheduling
Divisible Load Scheduling Henri Casanova 1,2 1 Associate Professor Department of Information and Computer Science University of Hawai i at Manoa, U.S.A. 2 Visiting Associate Professor National Institute
More informationCKY & Earley Parsing. Ling 571 Deep Processing Techniques for NLP January 13, 2016
CKY & Earley Parsing Ling 571 Deep Processing Techniques for NLP January 13, 2016 No Class Monday: Martin Luther King Jr. Day CKY Parsing: Finish the parse Recognizer à Parser Roadmap Earley parsing Motivation:
More informationIssues on Timing and Clocking
ECE152B TC 1 Issues on Timing and Clocking X Combinational Logic Z... clock clock clock period ECE152B TC 2 Latch and Flip-Flop L CK CK 1 L1 1 L2 2 CK CK CK ECE152B TC 3 Clocking X Combinational Logic...
More informationUniversal Turing Machine. Lecture 20
Universal Turing Machine Lecture 20 1 Turing Machine move the head left or right by one cell read write sequentially accessed infinite memory finite memory (state) next-action look-up table Variants don
More informationThe Blue Gene/P at Jülich Case Study & Optimization. W.Frings, Forschungszentrum Jülich,
The Blue Gene/P at Jülich Case Study & Optimization W.Frings, Forschungszentrum Jülich, 26.08.2008 Jugene Case-Studies: Overview Case Study: PEPC Case Study: racoon Case Study: QCD CPU0CPU3 CPU1CPU2 2
More informationParsing with Context-Free Grammars
Parsing with Context-Free Grammars Berlin Chen 2005 References: 1. Natural Language Understanding, chapter 3 (3.1~3.4, 3.6) 2. Speech and Language Processing, chapters 9, 10 NLP-Berlin Chen 1 Grammars
More informationComputer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process
Computer Architecture ESE 345 Computer Architecture Design Process 1 The Design Process "To Design Is To Represent" Design activity yields description/representation of an object -- Traditional craftsman
More informationTuring Machine Variants. Sipser pages
Turing Machine Variants Sipser pages 148-154 Marking symbols It is often convenient to have the Turing machine leave a symbol on the tape but to mark it in some way 1 1 0 2 B B B B B B B State = 1 1 1
More informationScalar Optimisation Part 2
Scalar Optimisation Part 2 Michael O Boyle January 2014 1 Course Structure L1 Introduction and Recap 4-5 lectures on classical optimisation 2 lectures on scalar optimisation Last lecture on redundant expressions
More informationChapter 9 Intermediate code generation
Chapter 9 generation Course Martin Steffen Spring 2018 Chapter 9 Learning Targets of Chapter generation. 1. intermediate code 2. three-address code and 3. translation to those forms 4. translation between
More informationReview. Earley Algorithm Chapter Left Recursion. Left-Recursion. Rule Ordering. Rule Ordering
Review Earley Algorithm Chapter 13.4 Lecture #9 October 2009 Top-Down vs. Bottom-Up Parsers Both generate too many useless trees Combine the two to avoid over-generation: Top-Down Parsing with Bottom-Up
More informationTree Parsing for Code Selection
Tree Parsing for Code Selection Reinhard Wilhelm Universität des Saarlandes wilhelm@cs.uni-sb.de 3. Januar 2010 Code Generation Real machines instead of abstract machines: Register machines, Limited resources
More informationMemory, Latches, & Registers
Memory, Latches, & Registers 1) Structured Logic Arrays 2) Memory Arrays 3) Transparent Latches 4) How to save a few bucks at toll booths 5) Edge-triggered Registers L13 Memory 1 General Table Lookup Synthesis
More informationCompiling Techniques
Lecture 3: Introduction to 22 September 2017 Reminder Action Create an account and subscribe to the course on piazza. Coursework Starts this afternoon (14.10-16.00) Coursework description is updated regularly;
More informationCMP 338: Third Class
CMP 338: Third Class HW 2 solution Conversion between bases The TINY processor Abstraction and separation of concerns Circuit design big picture Moore s law and chip fabrication cost Performance What does
More informationHoare Logic for Realistically Modelled Machine Code
Hoare Logic for Realistically Modelled Machine Code Magnus O. Myreen, Michael J. C. Gordon TACAS, March 2007 This talk Contribution: A mechanised Hoare logic for machine code with emphasis on resource
More informationGRAPHITE Two Years After First Lessons Learned From Real-World Polyhedral Compilation
GRAPHITE Two Years After First Lessons Learned From Real-World Polyhedral Compilation Konrad Trifunovic 2 Albert Cohen 2 David Edelsohn 3 Li Feng 6 Tobias Grosser 5 Harsha Jagasia 1 Razya Ladelsky 4 Sebastian
More informationExercises NP-completeness
Exercises NP-completeness Exercise 1 Knapsack problem Consider the Knapsack problem. We have n items, each with weight a j (j = 1,..., n) and value c j (j = 1,..., n) and an integer B. All a j and c j
More informationDATA SOURCES AND INPUT IN GIS. By Prof. A. Balasubramanian Centre for Advanced Studies in Earth Science, University of Mysore, Mysore
DATA SOURCES AND INPUT IN GIS By Prof. A. Balasubramanian Centre for Advanced Studies in Earth Science, University of Mysore, Mysore 1 1. GIS stands for 'Geographic Information System'. It is a computer-based
More informationOptimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem
Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur Lecture - 20 Travelling Salesman Problem Today we are going to discuss the travelling salesman problem.
More informationClass President: A Network Approach to Popularity. Due July 18, 2014
Class President: A Network Approach to Popularity Due July 8, 24 Instructions. Due Fri, July 8 at :59 PM 2. Work in groups of up to 3 3. Type up the report, and submit as a pdf on D2L 4. Attach the code
More informationEC 413 Computer Organization
EC 413 Computer Organization rithmetic Logic Unit (LU) and Register File Prof. Michel. Kinsy Computing: Computer Organization The DN of Modern Computing Computer CPU Memory System LU Register File Disks
More informationAlgorithms for quantum computers. Andrew Childs Department of Combinatorics & Optimization and Institute for Quantum Computing University of Waterloo
Algorithms for quantum computers Andrew Childs Department of Combinatorics & Optimization and Institute for Quantum Computing University of Waterloo What is a computer? A means for performing calculations
More informationA thorough derivation of back-propagation for people who really want to understand it by: Mike Gashler, September 2010
A thorough derivation of back-propagation for people who really want to understand it by: Mike Gashler, September 2010 Define the problem: Suppose we have a 5-layer feed-forward neural network. (I intentionally
More informationState and Finite State Machines
State and Finite State Machines See P&H Appendix C.7. C.8, C.10, C.11 Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University Big Picture: Building a Processor memory inst register
More information