Repository navigation
Category LLVM Backend
Home › All Categories › LLVM Backend
tiko compiles each module to textual LLVM IR and runs clang -c on it to make an object. clang then drives the link. There is no other code generator and no fallback. So there is no -gen option, and tiko -gen llvm hello.tiko is refused:
tiko-lang: error TKO0100: unknown option '-gen'
The IR comes from tiko's own pipeline:
- the frontend builds a typed AST;
- lowering turns it into MIR, a typed IR over basic blocks with its own verifier;
- an ABI pass rewrites procedure signatures and calls for the target's C calling convention, one classifier each for Win64, SysV AMD64 and Apple's AAPCS64;
- the emitter writes the LLVM IR.
--emit-ir writes that IR and stops: to standard output, or with -o x.ll to that file. --emit-asm runs clang -S on it and stops, writing x.s, or <source>.s with no -o. With several modules and one -o, each is <name>.<n>.ll (or .s). -v echoes every clang invocation, and --keep-temps keeps the .ll files.
Each target has its own triple:
| Target | clang triple |
|---|---|
windows-x86_64 (default on Windows) |
x86_64-pc-windows-msvc |
linux-x86_64 (default on Linux) |
x86_64-pc-linux-gnu |
macos-arm64 (default on macOS) |
arm64-apple-macosx13.0 |
clang 18 or newer, installed by you. Nothing is bundled.
tiko runs whatever TIKO_CLANG names. Without it, tiko runs C:\Program Files\LLVM\bin\clang.exe on Windows, /usr/bin/clang on Linux and Homebrew's /opt/homebrew/opt/llvm/bin/clang on macOS, and searches PATH only when that file is absent. It takes llvm-ar and llvm-rc from the same directory. The link uses lld; on Linux it falls back to the system ld when there is no ld.lld beside clang or in /usr/bin. On macOS the link uses Apple's linker and the macOS SDK from Xcode's Command Line Tools, and it searches Homebrew's /opt/homebrew/lib after your own library paths.
If clang is not there, tiko says so and stops:
tiko-lang: error TKO0111: no usable toolchain: clang not found at 'C:/nope/clang.exe' -- set TIKO_CLANG to the clang to use
Inline ASM is refused:
error TKO0407: inline assembly is not supported; compile that module with fbc
An ASM block is raw assembler text with direct symbol references. LLVM wants constraint strings and operands, and anything short of refusing it produces plausible-but-wrong code.
-
-O0to-O3(written joined:-O2) are passed through to clang. The corpus programs give the same output at all four levels. -
-gemits DWARF line tables. gdb breaks, steps and unwinds on both Windows targets and on Linux. Variables are not described yet.
-
Self-hosting. tiko compiles itself to a byte-identical fixpoint on windows-x86_64 and linux-x86_64, at
-O0and-O2, and on macos-arm64 at-O0(build/bootstrap.sh). -
Codegen coverage.
build/icescan.shcompiles all 2,709 corpus files to objects and reports anything the emitter or clang refuses: 21 failures in 12 files at the last run.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing