CompilerX64 ALPHA
Der Self-Hosting x86-64 Compiler der PowerBASIC Ersetzt
Imagine a compiler so powerful it compiles its own 203,000+ line source code. A compiler where you can override any built-in function with your own assembly. Where inline ASM speaks 561+ mnemonics spanning SSE4 to AVX-512 to Intel AMX. Where a 10-pass SSA optimizer with auto-vectorization transforms your BASIC into blazing native x64 machine code. This is CompilerX64.
203,000+ lines of compiler source
7-stage compilation pipeline
x64 PE32+ native output
Self-hosting target: in progress
Why CompilerX64 Changes Everything
#OVERRIDE — Own the Compiler
Replace any built-in function with your own assembly. Not a wrapper. Not a hook. The compiler literally rewrites every call site to execute your machine code. Optimize strlen(), memcpy(), or anything else at the compiler level.
561+ Mnemonics — Future-Proof ASM
From basic MOV to AVX-512 masked operations to Intel AMX tile-based matrix math. Write inline assembly that targets the latest CPUs without external assemblers. Full encoder built-in.
SSA + Auto-Vectorization
A 10-pass optimizer converts your loops into SIMD vector code automatically. Static Single Assignment form, phi-node management, loop unrolling, function inlining, dead-code elimination, and constant folding — all built-in.
Self-Hosting — True Independence
CompilerX64 compiles itself. All 203K+ lines. No dependency on legacy 32-bit tools for the build. Own your entire toolchain from source to binary.
C Interop — Two Languages, One File
Drop C headers and C code directly into your BASIC source with #CINCLUDE and #CCODE. Mix BASIC's productivity with C's ecosystem. The preprocessor handles it all.
Variable Hooks — See Everything
#DEBUG VAR ON instruments every variable read and write with zero overhead when disabled. Build custom profilers, memory trackers, or security monitors without changing your code.
#OVERRIDE in Action
With #OVERRIDE, you replace the compiler's built-in with your own assembly — emitted inline at every call site. No function call. No stack frame. No prologue or epilogue. The compiler evaluates the arguments into registers, substitutes parameter names with those registers, and drops your raw ASM directly into the instruction stream.
Override a Built-in
The codegen replaces s with rcx and emits the instruction inline. No CALL, no RET, no stack frame.
What Happens Under the Hood
- No function is created. The ASM body is stored as text and emitted inline at each call site.
- Arguments are evaluated into Win64 registers (RCX, RDX, R8, R9) before your ASM runs.
- Parameter names are substituted with their target register names at emit time.
- Labels are uniquified per call site so multiple calls never collide.
- No CALL/RET overhead. Your code lives directly in the caller's instruction stream.
- Supports up to 8 parameters with BYVAL/BYREF.
| Param | Integer/Ptr | Float |
|---|---|---|
| 1st | RCX | XMM0 |
| 2nd | RDX | XMM1 |
| 3rd | R8 | XMM2 |
| 4th | R9 | XMM3 |
| 5th+ | Stack | |
| Return | RAX | XMM0 |
Type families: BYTE, WORD, LONG, QUAD, SINGLE, DOUBLE, STRING, PTR.
Architecture — From Source to Silicon
Quick Example
C Interop + Inline ASM
Mixed BASIC + C
Inline ASM With PB Symbols
Inline ASM blocks bind directly to PB symbols — use your variable names, not raw registers. The compiler resolves each symbol to its current stack slot or register assignment.
Preprocessor — 20+ Directives
The preprocessor is not an afterthought. It is a full macro engine with conditional compilation, code hoisting, and C-style pragma support that runs before a single token is parsed.
| Directive | What It Does |
|---|---|
#DEFINE / #UNDEF | Text macros and compile-time constants with full expression support |
#IFDEF / #IFNDEF / #ELSE / #ENDIF | Conditional compilation based on macro or equate definition |
#INCLUDE / #INCLUDE ONCE | Recursive file inclusion with circular-detection and duplicate guards |
#COMPILE EXE / #COMPILE DLL | Specify output type, filename, and entry point |
#DIM ALL / #DIM NONE | Enforce or relax explicit variable declarations |
#OPTION | Set compiler options: ANSIAPI, VERSION5 |
#REGISTER | Register allocation hints: ALL, DEFAULT, NONE (per-routine or global) |
#RESOURCE | Embed icons, manifests, version info, and custom resources into the PE |
#GLOBAL / #GLOBALHERE | Hoist code blocks to global scope from anywhere in the source tree |
#MAINHERE | Hoist initialization code directly into PBMAIN from any file |
#UNIQUE | Generate unique identifiers to avoid name collisions in generated code |
#pragma | C-style pragmas: once, pack(push/pop), comment(lib), message |
MACRO / MACROFUNCTION | Multi-line text macros and function-like macros with parameter substitution |
#OVERRIDE | Replace built-in functions with custom assembly at the compiler level |
#CCODE / #CINCLUDE | Embed C code or include C headers directly inside BASIC source |
#ASM / #ENDASM | Inline assembly blocks with full access to PB variables and symbols |
MODULE System — Industrial-Scale Organization
CompilerX64 implements a modern module system that goes far beyond simple source files. Organize large projects with explicit boundaries, initialization guarantees, and interface contracts.
MODULE / END MODULE
MODULE blocks create scoped namespaces. PRIVATE members are invisible outside; PUBLIC members are the module's API.
MODULE INIT / MODULE TERM
Guaranteed initialization and cleanup. MODULE INIT runs before your program starts. MODULE TERM runs in reverse order before exit.
| Feature | Description |
|---|---|
MODULE ... END MODULE | Scoped namespace with PRIVATE and PUBLIC visibility controls |
MODULE INIT | Automatic initialization block executed before PBMAIN |
MODULE TERM | Automatic cleanup block executed on program termination |
MODULE INTERFACE | Declare a contract (API) without implementation |
MODULE IMPLEMENTS | Provide the implementation for a declared interface |
IMPORT / EXPORT | Explicit cross-module symbol visibility |
x64 Assembler — 561+ Unique Mnemonics, 1,263+ Variants
The built-in assembler is a production-grade x64 encoder with 561 unique mnemonics and 1,263+ encoder function variants covering register-to-register, register-to-memory, immediate, RIP-relative, SIB, and masked operations. No external assembler required. Everything from basic MOV to Intel AMX tile-based matrix math is encoded directly to COFF.
| Category | Instructions | Use Case |
|---|---|---|
| Data Movement | MOV, MOVSX, MOVZX, LEA, PUSH, POP, XCHG, CMPXCHG | Registers, memory, stack operations |
| Arithmetic | ADD, ADC, SUB, SBB, INC, DEC, NEG, CMP, MUL, IMUL, DIV, IDIV | Integer math with full 64-bit precision |
| Logical / Shift | AND, OR, XOR, NOT, TEST, SHL, SHR, SAR, ROL, ROR, RCL, RCR, SHLD, SHRD | Bit manipulation and rotation |
| Control Flow | JMP, JE, JNE, JA, JAE, JB, JBE, JG, JGE, JL, JLE, CALL, RET, LOOP | Branches, loops, procedure calls |
| SSE | ADDPS, MULPS, DIVPS, SQRTPS, MINPS, MAXPS, CMPPS, ANDPS, ORPS, XORPS, MOVAPS, MOVLPS, MOVHPS, SHUFPS, UNPCKLPS | 128-bit floating-point vectors |
| SSE2 Integer | PADDB, PADDW, PADDD, PADDQ, PCMPEQB, PCMPGTB, PAND, POR, PXOR, PSLLW, PSRLD, PSHUFD | 128-bit integer vectors |
| AVX / AVX2 | VADDPS, VSUBPS, VMULPS, VDIVPS, VFMADD, VBROADCASTSS, VPERM, VSHUFPS, VPADDB, VPMULLW | 256-bit vectors with 3-operand syntax |
| AVX-512 | VADDPS (zmm), VPADDQ, VFMADD231, masked ops (k1), VBROADCASTF32x8, VPERMT2D | 512-bit vectors, mask registers, tile ops |
| AES-NI | AESENC, AESENCLAST, AESDEC, AESDECLAST, AESIMC, AESKEYGENASSIST | Hardware-accelerated encryption |
| SHA | SHA1RNDS4, SHA1NEXTE, SHA256RNDS2, SHA256MSG1, SHA256MSG2 | Hardware-accelerated hashing |
| FMA3 | VFMADD132PS, VFMADD213PS, VFMADD231PS, VFMSUB..., VFNMADD... | Fused multiply-add for high-precision math |
| CET | ENDBR64, INCSSP, RDSSP, SAVEPREVSSP | Control-flow enforcement and shadow stack |
| AMX | LDTILECFG, STTILECFG, TILELOADD, TILESTORED, TILEZERO, TDPBF16PS, TDPBSSD | Tile-based matrix multiplication (Intel AMX) |
Full 646-line assembler guide with encoding details, ModR/M/SIB byte structures, prefix reference, and CPUID feature detection tables included in the documentation.
Optimizer Passes — Ten Layers of Speed
| Phase | Pass | Description |
|---|---|---|
| Phase 1: Basic | OPT-001 | Dead Code Elimination |
| OPT-002 | Constant Propagation & Folding | |
| OPT-006 | Loop Unrolling (2x, 4x, 8x) | |
| Phase 2: Advanced | OPT-003 | LICM — Loop-Invariant Code Motion |
| OPT-004 | Memory-to-Register Promotion | |
| OPT-005 | Function Inlining | |
| Phase 3: Foundation | OPT-F1 | SSA Conversion |
| OPT-F1b | Phi Node Management | |
| OPT-F1c | SSA Destruction | |
| OPT-F2 | Auto-Vectorization (SIMD) |
Development Status
| Component | Status | Notes |
|---|---|---|
| Lexer / Parser | ~95% | Canonical Pipeline API declared; legacy parsers retired |
| Semantic Analysis | ~90% | Type checking, flow analysis, loop context validation |
| IR Generation | ~85% | Infrastructure complete, unified representation |
| Code Generation | ~85% | PRINT exact-output working, signed comparisons active |
| Optimizer | 100% | 10 passes, SSA, vectorization all implemented |
| Assembler | ~90% | x64 encoding, COFF output working |
| Linker | ~85% | PE32+ generation, imports, exports, relocations |
| Runtime | ~80% | Canonical C-based runtime, console I/O, file I/O |
| Self-Hosting | In Progress | Stage1 verification active; AST pool, loop control fixed |
Alpha Preview
CompilerX64 is currently in active development. The download package will include the compiler executable, the CX64Editor IDE, WinAPI includes, and full documentation. Stay tuned for the first public alpha release.
Business & Source Code License
For companies that need full control over their toolchain, the complete CompilerX64 source code is available for purchase. This includes the entire compiler codebase, the CX64Editor IDE, runtime libraries, and build scripts.
- Build your own custom compiler with private extensions
- Modify the language, add new directives, or tune the optimizer
- Guaranteed long-term availability — no dependency on third-party tools
- Full source access to the 203K+ line compiler, editor, and runtime
- Use your own tools, maintain your own builds, protect your IP
One-time purchase
Full source code + Editor