# dlang/dmd architecture

> Architecture diagram of the GitHub repository dlang/dmd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dlang/dmd
- Repository: https://github.com/dlang/dmd

## Overview

DMD is the reference compiler for the D language. The supplied tree contains compiler interface headers and a small selection of druntime support files, not the compiler’s implementation or executable entry point. The graph therefore focuses on the compiler’s language-model layers and the visible support components; it cannot establish a complete user-to-compiled-output flow. Edges reflect documented imports or explicit README statements, not inferred runtime calls.

Main entry points: [`compiler/include/dmd/dsymbol.h`](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/dsymbol.h) (Symbols and scopes), [`compiler/include/dmd/expression.h`](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/expression.h) (Expressions), [`compiler/include/dmd/mtype.h`](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/mtype.h) (Types), [`compiler/include/dmd/ast_node.h`](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/ast_node.h) (AST base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_language["Language model"]
  node_tokens["Tokens<br/>[tokens.h]"]
  node_expressions["Expressions<br/>[expression.h]"]
  node_types["Types<br/>[mtype.h]"]
  node_statements["Statements<br/>[statement.h]"]
  node_declarations["Declarations<br/>[declaration.h]"]
  node_aggregates["Aggregates<br/>[aggregate.h]"]
  node_templates["Templates<br/>[template.h]"]
end

subgraph group_frontend["Frontend structure"]
  node_dmd["DMD compiler"]
  node_symbols["Symbols and scopes<br/>[dsymbol.h]"]
  node_ast["AST base<br/>[ast_node.h]"]
  node_visitor["AST visitor<br/>[visitor.h]"]
end

subgraph group_support["Compiler support"]
  node_globals["Compiler configuration<br/>[globals.h]"]
  node_arrays["AST collections<br/>[arraytypes.h]"]
  node_portability["Portability layer<br/>[port.h]"]
  node_memory["Root arrays<br/>[array.h]"]
  node_outbuffer["Output buffer<br/>[outbuffer.h]"]
end

subgraph group_runtime["Runtime support"]
  node_valgrind["Valgrind requests<br/>[valgrind.h]"]
  node_memcheck["Valgrind checks<br/>[memcheck.h]"]
  node_valgrind_c["Valgrind C support<br/>[valgrind.c]"]
end

node_developer(("D developer"))

node_developer -->|"uses compiler"| node_dmd
node_dmd -.->|"defines tokens"| node_tokens
node_expressions -->|"derives from"| node_ast
node_expressions -->|"uses tokens"| node_tokens
node_expressions -->|"references types"| node_types
node_types -->|"references expressions"| node_expressions
node_types -->|"uses AST base"| node_ast
node_statements -->|"uses AST base"| node_ast
node_statements -->|"references symbols"| node_symbols
node_declarations -->|"uses symbols"| node_symbols
node_declarations -->|"references types"| node_types
node_symbols -->|"uses AST base"| node_ast
node_symbols -->|"uses configuration"| node_globals
node_symbols -->|"uses collections"| node_arrays
node_symbols -->|"dispatches visitor"| node_visitor
node_aggregates -->|"uses symbols"| node_symbols
node_templates -->|"uses symbols"| node_symbols
node_templates -->|"references expressions"| node_expressions
node_arrays -->|"uses arrays"| node_memory
node_globals -->|"uses buffer"| node_outbuffer
node_globals -->|"uses portability"| node_portability
node_memcheck -->|"includes requests"| node_valgrind
node_valgrind_c -->|"uses requests"| node_valgrind
node_valgrind_c -->|"uses checks"| node_memcheck

click node_dmd "https://github.com/dlang/dmd/tree/master/compiler/include/dmd"
click node_tokens "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/tokens.h"
click node_expressions "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/expression.h"
click node_types "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/mtype.h"
click node_statements "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/statement.h"
click node_declarations "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/declaration.h"
click node_symbols "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/dsymbol.h"
click node_ast "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/ast_node.h"
click node_visitor "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/visitor.h"
click node_aggregates "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/aggregate.h"
click node_templates "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/template.h"
click node_globals "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/globals.h"
click node_arrays "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/arraytypes.h"
click node_portability "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/root/port.h"
click node_memory "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/root/array.h"
click node_outbuffer "https://github.com/dlang/dmd/blob/master/compiler/include/dmd/common/outbuffer.h"
click node_valgrind "https://github.com/dlang/dmd/blob/master/druntime/src/etc/valgrind/valgrind.h"
click node_memcheck "https://github.com/dlang/dmd/blob/master/druntime/src/etc/valgrind/memcheck.h"
click node_valgrind_c "https://github.com/dlang/dmd/blob/master/druntime/src/etc/valgrind/valgrind.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tokens,node_expressions,node_types,node_statements,node_declarations,node_aggregates,node_templates toneBlue
class node_dmd,node_symbols,node_ast,node_visitor toneAmber
class node_globals,node_arrays,node_portability,node_memory,node_outbuffer toneMint
class node_valgrind,node_memcheck,node_valgrind_c toneRose
class node_developer toneIndigo
```

## Components

### Language model

- [Tokens](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/tokens.h): `compiler/include/dmd/tokens.h`
- [Expressions](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/expression.h): `compiler/include/dmd/expression.h`
- [Types](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/mtype.h): `compiler/include/dmd/mtype.h`
- [Statements](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/statement.h): `compiler/include/dmd/statement.h`
- [Declarations](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/declaration.h): `compiler/include/dmd/declaration.h`
- [Aggregates](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/aggregate.h): `compiler/include/dmd/aggregate.h`
- [Templates](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/template.h): `compiler/include/dmd/template.h`

### Frontend structure

- [DMD compiler](https://github.com/dlang/dmd/tree/master/compiler/include/dmd): `compiler/include/dmd`
- [Symbols and scopes](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/dsymbol.h): `compiler/include/dmd/dsymbol.h`
- [AST base](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/ast_node.h): `compiler/include/dmd/ast_node.h`
- [AST visitor](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/visitor.h): `compiler/include/dmd/visitor.h`

### Compiler support

- [Compiler configuration](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/globals.h): `compiler/include/dmd/globals.h`
- [AST collections](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/arraytypes.h): `compiler/include/dmd/arraytypes.h`
- [Portability layer](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/root/port.h): `compiler/include/dmd/root/port.h`
- [Root arrays](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/root/array.h): `compiler/include/dmd/root/array.h`
- [Output buffer](https://github.com/dlang/dmd/blob/master/compiler/include/dmd/common/outbuffer.h): `compiler/include/dmd/common/outbuffer.h`

### Runtime support

- [Valgrind requests](https://github.com/dlang/dmd/blob/master/druntime/src/etc/valgrind/valgrind.h): `druntime/src/etc/valgrind/valgrind.h`
- [Valgrind checks](https://github.com/dlang/dmd/blob/master/druntime/src/etc/valgrind/memcheck.h): `druntime/src/etc/valgrind/memcheck.h`
- [Valgrind C support](https://github.com/dlang/dmd/blob/master/druntime/src/etc/valgrind/valgrind.c): `druntime/src/etc/valgrind/valgrind.c`

### Other components

- **D developer**

## Connections

- D developer → DMD compiler: uses compiler
- DMD compiler → Tokens: defines tokens (evidence: `compiler/include/dmd/expression.h`)
- Expressions → AST base: derives from (evidence: `compiler/include/dmd/expression.h`)
- Expressions → Tokens: uses tokens (evidence: `compiler/include/dmd/expression.h`)
- Expressions → Types: references types (evidence: `compiler/include/dmd/expression.h`)
- Types → Expressions: references expressions (evidence: `compiler/include/dmd/mtype.h`)
- Types → AST base: uses AST base (evidence: `compiler/include/dmd/mtype.h`)
- Statements → AST base: uses AST base (evidence: `compiler/include/dmd/statement.h`)
- Statements → Symbols and scopes: references symbols (evidence: `compiler/include/dmd/statement.h`)
- Declarations → Symbols and scopes: uses symbols (evidence: `compiler/include/dmd/declaration.h`)
- Declarations → Types: references types (evidence: `compiler/include/dmd/declaration.h`)
- Symbols and scopes → AST base: uses AST base (evidence: `compiler/include/dmd/dsymbol.h`)
- Symbols and scopes → Compiler configuration: uses configuration (evidence: `compiler/include/dmd/dsymbol.h`)
- Symbols and scopes → AST collections: uses collections (evidence: `compiler/include/dmd/dsymbol.h`)
- Symbols and scopes → AST visitor: dispatches visitor (evidence: `compiler/include/dmd/dsymbol.h`)
- Aggregates → Symbols and scopes: uses symbols (evidence: `compiler/include/dmd/aggregate.h`)
- Templates → Symbols and scopes: uses symbols (evidence: `compiler/include/dmd/template.h`)
- Templates → Expressions: references expressions (evidence: `compiler/include/dmd/template.h`)
- AST collections → Root arrays: uses arrays (evidence: `compiler/include/dmd/arraytypes.h`)
- Compiler configuration → Output buffer: uses buffer (evidence: `compiler/include/dmd/globals.h`)
- Compiler configuration → Portability layer: uses portability (evidence: `compiler/include/dmd/globals.h`)
- Valgrind checks → Valgrind requests: includes requests (evidence: `druntime/src/etc/valgrind/memcheck.h`)
- Valgrind C support → Valgrind requests: uses requests (evidence: `druntime/src/etc/valgrind/valgrind.c`)
- Valgrind C support → Valgrind checks: uses checks (evidence: `druntime/src/etc/valgrind/valgrind.c`)
