COINS a COmpiler INfra Structure COINS helps you

  • Slides: 7
Download presentation
COINS‥ a COmpiler INfra. Structure COINS helps you to make a new compiler n

COINS‥ a COmpiler INfra. Structure COINS helps you to make a new compiler n n n for new language for new processor with new optimization method COINS assists n n n compiler designers educators computer architects

Introduction to COINS written in Java. n Slow compilation⇔ easy BUG tracking about 176

Introduction to COINS written in Java. n Slow compilation⇔ easy BUG tracking about 176 k lines or 710 source files easy to understand ‥high modularity C and FORTRAN ‥‥ input (Java ‥‥ in progress) SPARC and x 86 ‥‥ target (ARM, MIPS, SH 4, Power. PC ‥ in progress)

Structure of COINS Language specific analyzer HIR (High-level Intermediate Representation) n n n represents

Structure of COINS Language specific analyzer HIR (High-level Intermediate Representation) n n n represents an abstract language keeps source code level info. and suitable for high-level opt. (parallelization , alias analysis) two output paths‥‥LIR and C LIR (Low-level Intermediate Representation) n n n represents an abstract machine has a strictly defined denotational semantics suitable for low-level opt. (SSA, branch, inst. scheduling, SIMD) Re-targetable code generator based on TMD

a = b + 1; a = b + 1 = a + b

a = b + 1; a = b + 1 = a + b (assign int <var int a> or (add int <var int b> <const int 1>)) 1

(SET I 32 (MEM I 32 (FRAME I 32 "a. 1")) (SET I 32

(SET I 32 (MEM I 32 (FRAME I 32 "a. 1")) (SET I 32 (MEM I 32 (STATIC (ADD I 32 "a")) (MEM I 32 (FRAME I 32 "b. 2")) (ADD“a” I 32 (MEM I 32 : (STATIC I 32 "b")) I 32 1))) & “b” local (INTCONST “a” & “b” : global(INT CONST I 32 1))) Visualization = a + b (assign int <var int a> or (add int <var int b> <const int 1>)) 1

TMD (Target Machine Description) Correspondence between LIR pattern and target machine code pattern LIR→LIR

TMD (Target Machine Description) Correspondence between LIR pattern and target machine code pattern LIR→LIR re-writing rules Tmd 2 Java : iburg-like tree parser generator performing DP matching (for cost). Retargeting costs (lines): SPARC 1100 x 86 1404 ARM 1408~ MIPS 1603 Power. PC 2807~ SH 4 1744~

Examples from a TMD (SPARC) ; ; Register decl. ; ; Two versions of

Examples from a TMD (SPARC) ; ; Register decl. ; ; Two versions of signed MUL. (def *real-reg-symtab* (SYMTAB (foreach @n (01 23 45 67) ("%l@n" REG I 64 4 0)) (foreach @p (i o) (foreach @n (01 23 45) ("%@p@n" REG I 64 4 0))) (foreach @gl (g l) (foreach @n (0 1 2 3 4 5 6 7) ("%@gl@n" REG I 32 4 0))) (foreach @oi (o i) (foreach @n (0 1 2 3 4 5) ("%@oi@n" REG I 32 4 0))) (foreach @n (0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30) ("%f@n" REG F 64 8 0)) ("%sp" REG I 32 4 0) ("%fp" REG I 32 4 0))) (foreach (@op @lib) ((MUL. mul) (DIVS. div) (DIVU. udiv) (MODS. rem) (MODU. urem)) (defrule regl (@op I 32 regl) (cond "!machine. Opt. V 8") (regset ($0 *reg-o 0 -I 32*) ($1 *reg-o 0 -I 32*) ($2 *reg-o 1 -I 32*)) (code (call "@lib") (nop)) (clobber (REG I 32 "%o 1") (REG I 32 "%o 2")(REG I 32 "%o 3") (REG I 32 "%o 4")(REG I 32 "%o 5")) (cost 10))) ; ; V 8 MUL instruction (defrule regl (MUL I 32 regl rc) (cond "machine. Opt. V 8") (code (smul $1 $2 $0)) (cost 1))