GDC: The GNU D Compiler Iain Bucaw @ibuclaw GHM 2013 Iain Bucaw - - PowerPoint PPT Presentation

gdc
SMART_READER_LITE
LIVE PREVIEW

GDC: The GNU D Compiler Iain Bucaw @ibuclaw GHM 2013 Iain Bucaw - - PowerPoint PPT Presentation

GDC: The GNU D Compiler Iain Bucaw @ibuclaw GHM 2013 Iain Bucaw (@ibuclaw) (slide 1) GHM 2013 1 / 69 Outline History of Porting D Front End (DFE) 1 GDC Current Status 2 The Anatomy of a GCC Front End 3 GDC Extensions 4 Future


slide-1
SLIDE 1

GDC:

The GNU D Compiler Iain Bucław

@ibuclaw

GHM 2013

Iain Bucław (@ibuclaw) (slide 1) GHM 2013 1 / 69

slide-2
SLIDE 2

Outline

1

History of Porting D Front End (DFE)

2

GDC Current Status

3

The Anatomy of a GCC Front End

4

GDC Extensions

5

Future Plans

Iain Bucław (@ibuclaw) (slide 2) GHM 2013 2 / 69

slide-3
SLIDE 3

What is D?

D is a language with C-like syntax and static typing. Pragmatically combines convenience, power, and efficiency.

High efficiency Systems level access Modeling power Simplicity High productivity Code correctness

Iain Bucław (@ibuclaw) (slide 3) GHM 2013 3 / 69

slide-4
SLIDE 4

Features Inherited from C/C++

General look and feel of C/C++. Object Oriented. Template Metaprogramming. Exception Handling. Runtime Type Identification. Operator Overloading.

Iain Bucław (@ibuclaw) (slide 4) GHM 2013 4 / 69

slide-5
SLIDE 5

Features Dropped from C/C++

C source compatibility. C Preprocessor and Macros. Multiple Inheritance. Forward Declarations. Support for 16-bit architectures. Implementation Specific Types.

Iain Bucław (@ibuclaw) (slide 5) GHM 2013 5 / 69

slide-6
SLIDE 6

A Short History of Porting the D Front End.

Iain Bucław (@ibuclaw) (slide 6) GHM 2013 6 / 69

slide-7
SLIDE 7

History

Late/1999: Work began on D. August/2001: First public announcement and draft specification. December/2001: D v0.01 Alpha released.

Iain Bucław (@ibuclaw) (slide 7) GHM 2013 7 / 69

slide-8
SLIDE 8

History

January/2002: Early discussions of wanting to port D to GNU/Linux began. April/2002: Walter Bright releases D Front End sources. May/2002: Birth of D.gnu Mailing List and BrightD Compiler Project. June/2002: OpenD Compiler Project announced.

Iain Bucław (@ibuclaw) (slide 8) GHM 2013 8 / 69

slide-9
SLIDE 9

History

August/2002: D Linux (DLI) released. May/2003: Walter Ports DMD to GNU/Linux. February/2004: GDMD Compiler Released. March/2004: DGCC Compiler Released.

Iain Bucław (@ibuclaw) (slide 9) GHM 2013 9 / 69

slide-10
SLIDE 10

History

September/2007: New Development of an LLVM D Compiler. June/2008: DGCC Development Abandoned. September/2009: GDC Revival Project Kicks Off. December/2009: Enter Your Humble Speaker.

Iain Bucław (@ibuclaw) (slide 10) GHM 2013 10 / 69

slide-11
SLIDE 11

Current State of D2 Compiler

Three main compilers based off the D2 Front End. Platform support for Linux, FreeBSD, OSX, Solaris, and Windows. Target support for ARM, PowerPC, x86, x86_64. D Runtime gaining support for more targets. Phobos becoming platform agnostic.

Iain Bucław (@ibuclaw) (slide 11) GHM 2013 11 / 69

slide-12
SLIDE 12

Current GDC Support Status.

Iain Bucław (@ibuclaw) (slide 12) GHM 2013 12 / 69

slide-13
SLIDE 13

GDC: Language Support

D Front End 2.063.2. Passes 100% on D2 Testsuite on x86 and x86_64. Passes all unittests in Druntime and Phobos.

Iain Bucław (@ibuclaw) (slide 13) GHM 2013 13 / 69

slide-14
SLIDE 14

GDC: Target Support

x86/x86_64: Solid support. ARM: Partial support. MIPS: Partial support. Others: Untested / No runtime support.

Iain Bucław (@ibuclaw) (slide 14) GHM 2013 14 / 69

slide-15
SLIDE 15

GDC: Platform Support

GNU/Linux: Main support platform. FreeBSD/OpenBSD: Support should be there. OSX: Lacks TLS Support. Windows/MinGW: Alpha quality release available.

Iain Bucław (@ibuclaw) (slide 15) GHM 2013 15 / 69

slide-16
SLIDE 16

GDC: Incompatibilities with DMD.

GDC follows the D calling convention as per the spec. Except for Win32, which defines the D calling convention. No D Inline Assembly implemented. No naked function support.

Iain Bucław (@ibuclaw) (slide 16) GHM 2013 16 / 69

slide-17
SLIDE 17

GDC: Incompatibilities with DMD.

Type va_list matches C ABI. No __simd support.

Allow __vector sizes of 8, 16 or 32 bytes. No current restrictions on what targets can use __vector.

gcov and gprof replace -cov and -profile. gdmd script maintained separately.

Iain Bucław (@ibuclaw) (slide 17) GHM 2013 17 / 69

slide-18
SLIDE 18

The Anatomy of a GCC Front End.

Iain Bucław (@ibuclaw) (slide 18) GHM 2013 18 / 69

slide-19
SLIDE 19

Why GCC?

GCC is developed to be 100% free software. The entry barrier to GCC development has gotten considerably lower during the last few years. With work on documentation and separation of internal modules, writing your own front end for GCC has become accessible to a wider community of developers.

Iain Bucław (@ibuclaw) (slide 19) GHM 2013 19 / 69

slide-20
SLIDE 20

Introduction to GCC

Able to translate from a variety of source languages to assembly. Encapsulated into one command. Front end is made up of two main components.

Iain Bucław (@ibuclaw) (slide 20) GHM 2013 20 / 69

slide-21
SLIDE 21

Compilation Driver

User interfacing application. Knows about all supported languages. Able to determine source language. Passes output between compiler and assembler.

Iain Bucław (@ibuclaw) (slide 21) GHM 2013 21 / 69

slide-22
SLIDE 22

Compilation Driver

void lang_specific_driver (struct cl_decoded_option **in_decoded_options, unsigned int *in_decoded_options_count, int *in_added_libraries) { } int lang_specific_pre_link (void) { return 0; } int lang_specific_extra_outfiles = 0; const struct spec_function lang_specific_spec_functions[] = { { 0, 0 } };

Iain Bucław (@ibuclaw) (slide 22) GHM 2013 22 / 69

slide-23
SLIDE 23

Compiler Proper

One compiler proper for each language. Composed from three components.

Iain Bucław (@ibuclaw) (slide 23) GHM 2013 23 / 69

slide-24
SLIDE 24

Front End, Middle End and Back End

The Front End contains all the language processing logic. The Middle End is the platform independent part of the compiler. The Back End is then the platform dependent part.

Iain Bucław (@ibuclaw) (slide 24) GHM 2013 24 / 69

slide-25
SLIDE 25

GENERIC

GENERIC is a tree language. Mechanism to define own node types. Supports everything there is to represent in a typical C function. During the course of compilation, it is lowered into an intermediate code called GIMPLE.

Iain Bucław (@ibuclaw) (slide 25) GHM 2013 25 / 69

slide-26
SLIDE 26

GIMPLE

GIMPLE is a subset of GENERIC. Breaks down all expressions, using temporaries to store intermediate results. Further transforms all blocks into gotos and labels. Lowered down to RTL, or Register Transfer Language.

Iain Bucław (@ibuclaw) (slide 26) GHM 2013 26 / 69

slide-27
SLIDE 27

Interfacing with D Front-End

GDC initialises the D Front-End, sets up all global parameters. D Front-End parses and runs semantic on the code.

void Import::semantic(Scope *sc); void Module::semantic(); void Declaration::semantic(Scope *sc); void Dsymbol::semantic(Scope *sc); Type *Type::semantic(Loc loc, Scope *sc); Expression *Expression::semantic(Scope *sc); Statement *Statement::semantic(Scope *sc); Initializer *Initializer::semantic(Scope *sc, Type *t);

Iain Bucław (@ibuclaw) (slide 27) GHM 2013 27 / 69

slide-28
SLIDE 28

Interfacing with D Front-End

GDC generates GENERIC to be sent to backend.

void Module::genmoduleinfo (void); void Declaration::toDt (dt_t **pdt); void Declaration::toObjFile (int); void Declaration::toSymbol (void); void Dsymbol::toObjFile (int); void Dsymbol::toSymbol (void); type* Type::toCtype (void); dt_t** Type::toDt (dt_t **pdt); elem* Expression::toElem (IRState *irs); void Statement::toIR (IRState *irs); dt_t* Initializer::toDt (void);

Iain Bucław (@ibuclaw) (slide 28) GHM 2013 28 / 69

slide-29
SLIDE 29

Interfacing with D Front-End

GCC backend compiles down to RTL.

static void d_write_global_declarations (void) { tree *vec = (tree *) globalDeclarations.data; // Complete all generated thunks. cgraph_process_same_body_aliases (); // Process all file scopes in this compilation, and the external_scope, // through wrapup_global_declarations. wrapup_global_declarations (vec, globalDeclarations.dim); // We’re done parsing; proceed to optimize and emit assembly. if (!global.errors && !errorcount) finalize_compilation_unit (); // Now, issue warnings about static, but not defined, functions. check_global_declarations (vec, globalDeclarations.dim); // After cgraph has had a chance to emit everything that’s going to // be emitted, output debug information for globals. emit_debug_global_declarations (vec, globalDeclarations.dim); }

Iain Bucław (@ibuclaw) (slide 29) GHM 2013 29 / 69

slide-30
SLIDE 30

Interfacing with GCC

#define LANG_HOOKS_NAME "GNU D" #define LANG_HOOKS_INIT d_init #define LANG_HOOKS_INIT_OPTIONS d_init_options #define LANG_HOOKS_OPTION_LANG_MASK d_option_lang_mask #define LANG_HOOKS_HANDLE_OPTION d_handle_option #define LANG_HOOKS_POST_OPTIONS d_post_options #define LANG_HOOKS_PARSE_FILE d_parse_file #define LANG_HOOKS_TYPES_COMPATIBLE_P d_types_compatible_p #define LANG_HOOKS_BUILTIN_FUNCTION d_builtin_function #define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE d_builtin_function #define LANG_HOOKS_REGISTER_BUILTIN_TYPE d_register_builtin_type #define LANG_HOOKS_FINISH_INCOMPLETE_DECL d_finish_incomplete_decl #define LANG_HOOKS_GIMPLIFY_EXPR d_gimplify_expr #define LANG_HOOKS_EH_PERSONALITY d_eh_personality #define LANG_HOOKS_EH_RUNTIME_TYPE d_build_eh_type_type #define LANG_HOOKS_WRITE_GLOBALS d_write_global_declarations #define LANG_HOOKS_TYPE_FOR_MODE d_type_for_mode #define LANG_HOOKS_TYPE_FOR_SIZE d_type_for_size #define LANG_HOOKS_TYPE_PROMOTES_TO d_type_promotes_to struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;

Iain Bucław (@ibuclaw) (slide 30) GHM 2013 30 / 69

slide-31
SLIDE 31

Interfacing with GCC

enum built_in_attribute { #include "builtin-attrs.def" ATTR_LAST }; static tree built_in_attributes[(int) ATTR_LAST]; static void d_init_attributes (void) { #include "builtin-attrs.def" }

Iain Bucław (@ibuclaw) (slide 31) GHM 2013 31 / 69

slide-32
SLIDE 32

Interfacing with GCC

enum d_builtin_type { #include "builtin-types.def" BT_LAST }; static tree builtin_types[(int) BT_LAST + 1]; void d_init_builtins (void) { #include "builtin-types.def" d_init_attributes (); #include "builtins.def" targetm.init_builtins (); build_common_builtin_nodes (); }

Iain Bucław (@ibuclaw) (slide 32) GHM 2013 32 / 69

slide-33
SLIDE 33

Interfacing with GCC

void d_backend_init (void) { init_global_binding_level (); // Parameters are (signed_char = false, short_double = false). build_common_tree_nodes (false, false); d_init_builtins (); if (flag_exceptions) d_init_exceptions (); main_identifier_node = get_identifier ("main"); }

Iain Bucław (@ibuclaw) (slide 33) GHM 2013 33 / 69

slide-34
SLIDE 34

A Simple D Program

module demo; int add(int a, int b) { return a + b; }

Iain Bucław (@ibuclaw) (slide 34) GHM 2013 34 / 69

slide-35
SLIDE 35

Code Generated by Front-End

Module (demo); FuncDeclaration (demo.add) CompoundStatement { ReturnStatement { AddExp (SymbolExp (a) + SymbolExp (b)); } }

Iain Bucław (@ibuclaw) (slide 35) GHM 2013 35 / 69

slide-36
SLIDE 36

Code Generated in GENERIC

demo.add (int a, int b) { return <retval> = a + b; } demo.add (int a, int b) bind_expr ( return_expr ( init_expr (<retval>, plus_expr (a, b)) ) )

Iain Bucław (@ibuclaw) (slide 36) GHM 2013 36 / 69

slide-37
SLIDE 37

Representation after Gimplification

demo.add (int a, int b) { int vartmp0; vartmp0 = a + b; return vartmp0; } demo.add (int a, int b) gimple_bind ( int vartmp0; gimple_assign (plus_expr, vartmp0, a, b) gimple_return (vartmp0) )

Iain Bucław (@ibuclaw) (slide 37) GHM 2013 37 / 69

slide-38
SLIDE 38

A More Interesting D Program

module demo; long fib (uint m) { return (m < 2) ? m : fib (m - 1) + fib (m - 2); }

Iain Bucław (@ibuclaw) (slide 38) GHM 2013 38 / 69

slide-39
SLIDE 39

Code Generated by Front-End

Module (demo); FuncDeclaration (demo.fib) CompoundStatement { ReturnStatement { CondExp { CmpExp (SymbolExp (m) < IntegerExp (2)) ? SymbolExp (m) : AddExp (CallExp (fib, (MinExp (SymbolExp (m), IntegerExp (1)))), CallExp (fib, (MinExp (SymbolExp (m), IntegerExp (2))))); } } }

Iain Bucław (@ibuclaw) (slide 39) GHM 2013 39 / 69

slide-40
SLIDE 40

Code Generated in GENERIC

demo.fib(uint m) { return <retval> = m <= 1 ? (long) m : demo.fib (m - 1) + demo.fib (m - 2); } demo.fib(uint m) bind_expr ( return_expr ( init_expr (<retval>, cond_expr (le_expr, m, 1, nop_expr (m), plus_expr (call_expr (demo.fib, minus_expr (m, 1)), call_expr (demo.fib, minus_expr (m, 2))) ) ) ) )

Iain Bucław (@ibuclaw) (slide 40) GHM 2013 40 / 69

slide-41
SLIDE 41

Representation after Gimplification

demo.fib (uint m) { long vartmp0; long iftmp0; uint vartmp1; long vartmp2; uint vartmp3; long vartmp4; if (m <= 1) goto L1; else goto L2; L1: iftmp0 = (long) m; goto L3; L2: vartmp1 = m + 4294967295; vartmp2 = demo.fib (vartmp1); vartmp3 = m + 4294967294; vartmp4 = demo.fib (vartmp3); iftmp0 = vartmp2 + vartmp4; L3: vartmp0 = iftmp0; return vartmp0; }

Iain Bucław (@ibuclaw) (slide 41) GHM 2013 41 / 69

slide-42
SLIDE 42

Representation after Gimplification

demo.fib (uint m) gimple_bind ( long vartmp0; uint vartmp1; long vartmp2; uint vartmp3; long vartmp4; long iftmp0; gimple_cond (le_expr, m, 1, (L1), (L2)) gimple_label (L1) gimple_assign (nop_expr, iftmp0, m) gimple_goto (L3) gimple_label (L2) gimple_assign (plus_expr, vartmp1, m, 4294967295) gimple_call (demo.fib, vartmp2, vartmp1) gimple_assign (plus_expr, vartmp3, m, 4294967294) gimple_call (demo.fib, vartmp4, vartmp3) gimple_assign (plus_expr, iftmp0, vartmp2, vartmp4) gimple_label (L3) gimple_assign (var_decl, vartmp0, iftmp0) gimple_return (vartmp0) )

Iain Bucław (@ibuclaw) (slide 42) GHM 2013 42 / 69

slide-43
SLIDE 43

GDC Extensions

Iain Bucław (@ibuclaw) (slide 43) GHM 2013 43 / 69

slide-44
SLIDE 44

Custom Static Chains

Generated for all nested functions Generated for toplevel functions with nested references.

int delegate() foo() { int x = 7; int bar() { int baz() { return x + 3; } return baz(); } return &bar; }

Iain Bucław (@ibuclaw) (slide 44) GHM 2013 44 / 69

slide-45
SLIDE 45

Generated GENERIC Code

closure.foo.bar.baz (void *this) { return <retval> = ((CLOSURE.closure.foo *) this)->x + 3; } closure.foo.bar (void *this) { return <retval> = closure.foo.bar.baz ((CLOSURE.closure.foo *) this); } closure.foo (void *this) { int x [value-expr: (__closptr)->x]; struct CLOSURE.closure.foo *__closptr; __closptr = (CLOSURE.closure.foo *) _d_allocmemory (8); __closptr->__chain = 0B; __closptr->x = 7; return <retval> = {.object=__closptr, .func=closure.foo.bar}; }

Iain Bucław (@ibuclaw) (slide 45) GHM 2013 45 / 69

slide-46
SLIDE 46

Function Frames

Where a closure is not required, a frame is instead generated.

void bar() { int add = 2; scope dg = (int a) => a + add; assert(dg(5) == 7); }

Iain Bucław (@ibuclaw) (slide 46) GHM 2013 46 / 69

slide-47
SLIDE 47

Generated GENERIC Code

frame.bar.__lambda1 (void *this) { return <retval> = a + ((FRAME.frame.bar *) this)->add; } frame.bar () { struct dg; int add [value-expr: (&__frame)->add]; struct FRAME.frame.bar __frame; __frame.__chain = 0B; (&__frame)->add = 2; dg = {.object=&__frame, .func=frame.bar.__lambda1}; if (dg.func (dg.object, 5) == 7) { } else { _d_assert ({.length=6, .ptr="test.d"}, 7); } }

Iain Bucław (@ibuclaw) (slide 47) GHM 2013 47 / 69

slide-48
SLIDE 48

GCC Built-in Functions and Types

gcc.builtins gives access to built-ins provided by the GCC backend.

import gcc.builtins; void test() { real r = 0.5 * __builtin_sqrtl(real.min_normal); __builtin_printf("Hello World!\n"); }

Iain Bucław (@ibuclaw) (slide 48) GHM 2013 48 / 69

slide-49
SLIDE 49

Generated GENERIC Code

Allows many C library calls to be optimised in certain cases.

builtins.test () { real r; r = 9.16801933777423582810706196024241582978182485679283618642e-2467; __builtin_puts ("Hello World!"); }

Iain Bucław (@ibuclaw) (slide 49) GHM 2013 49 / 69

slide-50
SLIDE 50

Built-in Types

Defines aliases to internal types.

__builtin_va_list; // Target C va_list type. __builtin_clong; // Target C long int type. __builtin_culong; // Target C long unsigned int type. __builtin_machine_byte; // Signed type whose size is equal to sizeof(unit). __builtin_machine_ubyte; // Unsigned variant. __builtin_machine_int; // Signed type whose size is equal to sizeof(word). __builtin_machine_uint; // Unsigned variant. __builtin_pointer_int; // Signed type whose size is equal to sizeof(pointer). __builtin_pointer_uint; // Unsigned variant. __builtin_unwind_int; // Target C _Unwind_Sword type, for EH. __builtin_unwind_uint; // Target C _Unwind_Word type, for EH.

Iain Bucław (@ibuclaw) (slide 50) GHM 2013 50 / 69

slide-51
SLIDE 51

Implementing D Intrinsics

DMD has several intrinsics to the compiler.

import core.bitop; import core.math; void main() { long l; l = rndtol (4.5); size_t[2] a = [2, 256]; btc(a.ptr, 35); }

Iain Bucław (@ibuclaw) (slide 51) GHM 2013 51 / 69

slide-52
SLIDE 52

Generated GENERIC Code

core.math intrinsics are mapped to GCC builtin-ins. core.bitop instrinsics are expanded with inlined generated code.

int D main() { int D.2001; ulong a[2]; long l; l = 0; l = (long) __builtin_llroundl (4.5e+0); a[0] = 2; a[1] = 256; D.2001 = (*(ulong *) &a & 34359738368) != 0 ? -1 : 0; *(ulong *) &a = *(ulong *) &a ^ 34359738368; return <retval> = 0; }

Iain Bucław (@ibuclaw) (slide 52) GHM 2013 52 / 69

slide-53
SLIDE 53

Extending D Intrinsics

Many functions defined in core.stdc are mapped to GCC built-ins. Functions recognised as a GCC built-in can be optimised. Can be turned off with -fno-builtin switch.

Iain Bucław (@ibuclaw) (slide 53) GHM 2013 53 / 69

slide-54
SLIDE 54

import core.stdc.stdio; import core.stdc.math; void test() { real r = powl(3, 3); if (r == 27.0) printf("Match!\n"); } intrinsic.test() { real r; r = 2.7e+1; { if (r == 2.7e+1) { __builtin_puts ("Match!"); } } }

Iain Bucław (@ibuclaw) (slide 54) GHM 2013 54 / 69

slide-55
SLIDE 55

Variadic Functions

The va_list type has an exclusive meaning in the compiler. Matches the C ABI, type is not a void*. Defined in gcc.builtins, then an alias to the type in core.stdc.stdarg. Special va functions expanded at compile-time.

Iain Bucław (@ibuclaw) (slide 55) GHM 2013 55 / 69

slide-56
SLIDE 56

Variadic Functions

import core.stdc.stdarg; void variadic(...) { auto a1 = va_arg!(int)(_argptr); auto a2 = va_arg!(double)(_argptr); auto a3 = va_arg!(int[2])(_argptr); auto a4 = va_arg!(string)(_argptr); }

Iain Bucław (@ibuclaw) (slide 56) GHM 2013 56 / 69

slide-57
SLIDE 57

Generated GENERIC Code

valist.variadic (struct TypeInfo_Tuple & _arguments_typeinfo) { struct _argptr[1]; struct a4; int a3[2]; double a2; int a1; struct _arguments; __builtin_va_start (&_argptr, _arguments_typeinfo); try { _arguments = _arguments_typeinfo->elements; a1 = VA_ARG_EXPR <_argptr>; a2 = VA_ARG_EXPR <_argptr>; a3 = VA_ARG_EXPR <_argptr>; a4 = VA_ARG_EXPR <_argptr>; } finally { __builtin_va_end (&_argptr); } }

Iain Bucław (@ibuclaw) (slide 57) GHM 2013 57 / 69

slide-58
SLIDE 58

GCC Attributes

Used to be accessible via pragmas in the language. Now uses UDA syntax that gets handled by gcc.attributes.

import gcc.attributes; import gcc.builtins; @attribute("noreturn") void die() { __builtin_unreachable(); } @attribute("forceinline") int multiply(int a, int b) { return a * b; }

Iain Bucław (@ibuclaw) (slide 58) GHM 2013 58 / 69

slide-59
SLIDE 59

GCC Type Attributes

Attributes can also be applied to types.

import gcc.attributes; @attribute("aligned") struct A { char c; int i; } @attribute("unused") int unused_var;

As of writing, none of these type attributes are implemented in GDC.

Iain Bucław (@ibuclaw) (slide 59) GHM 2013 59 / 69

slide-60
SLIDE 60

GCC Extended Assembly

GDC implements a variant of GCC Extended Assembly. Extended assembly allows you to optionally specify the operands.

asm { "rdtsc" : /* output operands */ : /* input operands */ : /* list of clobbered registers */ ; }

Iain Bucław (@ibuclaw) (slide 60) GHM 2013 60 / 69

slide-61
SLIDE 61

GCC Extended Assembly

static uint getIeeeFlags() { asm { fstsw AX; and EAX, 0x03D; } uint result; asm { "fstsw %%ax; andl $0x03D, %%eax" : "=a" result; } return result; }

Iain Bucław (@ibuclaw) (slide 61) GHM 2013 61 / 69

slide-62
SLIDE 62

Benefits of Extended Assembly

It is available on nearly all targets. Instruction templates can be generated through CTFE string constants. Does not prevent a function from being inlined. Can have some common optimisations applied to them, such as DCE.

Iain Bucław (@ibuclaw) (slide 62) GHM 2013 62 / 69

slide-63
SLIDE 63

Future Plans

Iain Bucław (@ibuclaw) (slide 63) GHM 2013 63 / 69

slide-64
SLIDE 64

Compiler: Short Term

Find a workable solution for TLS support. Better support for LTO. Correct generation of D Thunks.

Iain Bucław (@ibuclaw) (slide 64) GHM 2013 64 / 69

slide-65
SLIDE 65

Compiler: Long Term

Implement D Front-End in D. Integration of DFE into GCC garbage collector.

Iain Bucław (@ibuclaw) (slide 65) GHM 2013 65 / 69

slide-66
SLIDE 66

Compiler: Wishlist

Add support for label operands in Extended Assembly.

int frob(int x) { int y; asm { "frob %%r5, %1; jc %l[Lerror]; mov (%2), %%r5" : : "r"(x), "r"(&y) : "r5", "memory" : Lerror; } return y; Lerror: return -1; }

Iain Bucław (@ibuclaw) (slide 66) GHM 2013 66 / 69

slide-67
SLIDE 67

Library

Implement Exception Chaining. Conversion of D IASM to Extended Assembly. Finish off port of ARM. Fix D GC runtime for TLS support.

Iain Bucław (@ibuclaw) (slide 67) GHM 2013 67 / 69

slide-68
SLIDE 68

http://gdcproject.org http://bugzilla.gdcproject.org https://github.com/D-Programming-GDC/GDC ibuclaw@gdcproject.org

Iain Bucław (@ibuclaw) (slide 68) GHM 2013 68 / 69

slide-69
SLIDE 69

Questions?

Iain Bucław (@ibuclaw) (slide 69) GHM 2013 69 / 69