Translating ETC to LLVM Assembly Carl Ritson C.G.Ritson@kent.ac.uk - - PowerPoint PPT Presentation

translating etc to llvm assembly
SMART_READER_LITE
LIVE PREVIEW

Translating ETC to LLVM Assembly Carl Ritson C.G.Ritson@kent.ac.uk - - PowerPoint PPT Presentation

Translating ETC to LLVM Assembly Carl Ritson C.G.Ritson@kent.ac.uk School of Computing, University of Kent 2009 11 3 1983-1984 INMOS Transputer released. occam is born. 2009 11 3 1989 SGS Thompson


slide-1
SLIDE 1

Translating ETC to LLVM Assembly

Carl Ritson

C.G.Ritson@kent.ac.uk School of Computing, University of Kent

2009年11月3日火曜日

slide-2
SLIDE 2

1983-1984

INMOS Transputer released.

  • ccam is born.

2009年11月3日火曜日

slide-3
SLIDE 3

1989

SGS Thompson acquires INMOS.

  • ccam reaches version 2.1 (occ21).

2009年11月3日火曜日

slide-4
SLIDE 4

1993-1994

INMOS subsumed. Transputer and occam development ends.

2009年11月3日火曜日

slide-5
SLIDE 5

1995-1997

  • ccam for All (Welch, BAE, Formal Systems, Marconi, etc)

KRoC is born (octran, tranpc).

2009年11月3日火曜日

slide-6
SLIDE 6

2000-2003

  • ccam-π (Welch, Barnes)

tranx86 (Barnes)

2009年11月3日火曜日

slide-7
SLIDE 7

2004-2007

More occam-π (Welch, Barnes) The Transterpreter (Jacobsen, Jadud, Dimmich)

2009年11月3日火曜日

slide-8
SLIDE 8

Execution

  • cc21

tranx86 System Linker ETC

  • bject

CCSP kernel Native Libraries Executable Native Object Code plinker/slinker TVM Bytecode TVM ETC Libraries

Source

2009年11月3日火曜日

slide-9
SLIDE 9

Execution

  • cc21

tranx86 System Linker ETC

  • bject

CCSP kernel Native Libraries Executable Native Object Code plinker/slinker TVM Bytecode TVM ETC Libraries

Source

LLVM Converter LLVM Assembly llc

2009年11月3日火曜日

slide-10
SLIDE 10

Extended Transputer Code

Targets 3-place stack machine, with workspace. Small set of RISC-like instructions with CISC secondaries.

2009年11月3日火曜日

slide-11
SLIDE 11

LLVM

Machine independent program representation. Generic analysis and optimisation passes.

2009年11月3日火曜日

slide-12
SLIDE 12

Why LLVM?

More control than C. Code generation for x86, x86-64, ARM, PPC, ...

2009年11月3日火曜日

slide-13
SLIDE 13

LLVM Assembly

Typed SSA-form with procedures and calling conventions. Obviates data flow and control flow graphs.

2009年11月3日火曜日

slide-14
SLIDE 14

define i32 @cube (i32 %x) { %x_0 = mul i32 %x ,%x %x_1 = mul i32 %x_0,%x ret i32 %x_1 }

2009年11月3日火曜日

slide-15
SLIDE 15

PROC foo (VAL INT x, y, CHAN INT out!) INT z: SEQ z := x + y

  • ut ! z

:

2009年11月3日火曜日

slide-16
SLIDE 16

.L0: AJW -1 -- allocate workspace LDL 2 -- load x LDL 3 -- load y ADD STL 0 -- store to z LDLP 0 -- load pointer to z LDL 4 -- load channel LDC 4 -- load size of INT OUT AJW 1 -- deallocate workspace RET

2009年11月3日火曜日

slide-17
SLIDE 17

The Transformation

Trace and numerate operand stack. Extract control flow into procedures.

2009年11月3日火曜日

slide-18
SLIDE 18

.L0: AJW -1 LDL 2 -- => %reg_0 LDL 3 -- => %reg_1 ADD -- %reg_1, %reg_0 => %reg_2 STL 0 -- %reg_2 => () LDLP 0 -- => %reg_3 LDL 4 -- => %reg_4 LDC 4 -- => %reg_5 OUT -- %reg_5, %reg_4, %reg_3 => () AJW 1 RET

2009年11月3日火曜日

slide-19
SLIDE 19

define void @O_foo (i8* %sched, i32* %wptr_0) { L0: ; AJW -1 %wptr_1 = getelementptr i32* %wptr_0, i32 -1

2009年11月3日火曜日

slide-20
SLIDE 20

; LDL 2 %tmp_0 = getelementptr i32* %wptr_1, i32 2 %reg_0 = load i32* %tmp_0 ; LDL 3 %tmp_1 = getelementptr i32* %wptr_1, i32 2 %reg_1 = load i32* %tmp_1

2009年11月3日火曜日

slide-21
SLIDE 21

; ADD { (reg_1, reg_0) => (reg_2) } %tmp_2 = call {i32, i1} @llvm.sadd.with.overflow.i32 (i32 %reg_0, i32 %reg_1) %reg_2 = extractvalue {i32, i1} %tmp_2, 0 %tmp_3 = extractvalue {i32, i1} %tmp_2, 1

2009年11月3日火曜日

slide-22
SLIDE 22

br i1 %tmp_3, label %tmp_4_overflow_error, label %tmp_4_ok tmp_4_overflow_error: %tmp_5 = load i8** @C_0 ; “foo.occ” call void @etc_error_overflow (i8* %sched, i32* %wptr_1, i8* %tmp_5, i32 5) tmp_4_ok: ; STL 0 store i32 %reg_2, i32* %wptr_1

2009年11月3日火曜日

slide-23
SLIDE 23

Control Flow

Branching and blocking, via co-operate scheduling. Functions over workspaces, e.g. P = <f1,f2,f3,...,fn>.

2009年11月3日火曜日

slide-24
SLIDE 24

f1 f2 fn g1 g2 gm

Process A Process B Kernel

2009年11月3日火曜日

slide-25
SLIDE 25

Continuation Passing Style

Collapses stack, obviates dependencies. Very appropriate for occam-like languages.

2009年11月3日火曜日

slide-26
SLIDE 26

Run-time Simplification

Kernel calls become native C calls. Run-time state more tractable.

2009年11月3日火曜日

slide-27
SLIDE 27

mandelbrot

KRoC Distribution

2009年11月3日火曜日

slide-28
SLIDE 28

2009年11月3日火曜日

slide-29
SLIDE 29

308% 249% 100%

tranx86 llvm plain llvm optimised

2009年11月3日火曜日

slide-30
SLIDE 30

spectralnorm

Language Games

2009年11月3日火曜日

slide-31
SLIDE 31

161% 150% 100%

tranx86 llvm plain llvm optimised

2009年11月3日火曜日

slide-32
SLIDE 32

agents

CCSP Comparisons

2009年11月3日火曜日

slide-33
SLIDE 33

104% 79% 100%

tranx86 llvm plain llvm optimised

2009年11月3日火曜日

slide-34
SLIDE 34

Benefits

Simplifies: run-time, floating point, corner cases. Off-the-shelf optimisations improve performance.

2009年11月3日火曜日

slide-35
SLIDE 35

Difficulties

Unclear semantics of tail-calls (for CPS). Toolchain issues.

2009年11月3日火曜日

slide-36
SLIDE 36

Future Work

Porting, refactoring, bypass ETC. Add to LLVM support for this style of compilation.

2009年11月3日火曜日

slide-37
SLIDE 37

Thanks

Questions?

EPSRC grant EP/D061822

2009年11月3日火曜日