Repository navigation
Hexagon ISA 01 overview
Relevant source files
The following files were used as context for generating this wiki page:
- llvm/lib/Target/Hexagon/HexagonDepArch.td
- llvm/lib/Target/Hexagon/Hexagon.td
- Wikipedia: Qualcomm Hexagon
- Wikipedia: Very long instruction word
- Qualcomm: Hexagon V6x/V7x Programmer's Reference Manual and HVX Programmer's Reference Manual (Qualcomm developer network)
Hexagon is Qualcomm's digital signal processor (DSP) architecture, found in Snapdragon chips as the audio/sensor DSP and the compute DSP that Qualcomm markets as the Hexagon NPU. It is a 32-bit VLIW machine: the compiler groups up to four instructions into a packet that executes in one go, so the hardware does not need complex out-of-order logic. A wide vector unit, HVX, adds SIMD for image, audio and AI workloads.
About this wiki. Facts about registers, encodings, instruction names and architecture versions are cited from the LLVM Hexagon backend at commit
a2171756. Hardware details not visible in LLVM (cache sizes, thread counts, MMU behaviour) follow Qualcomm's public Hexagon reference manuals; they vary by chip and are marked as general. All assembly is illustrative: the local LLVM build does not include the Hexagon target, so nothing was assembled.
| # | Page | Covers |
|---|---|---|
| 1 | Overview | What Hexagon is, processor properties, versions |
| 2 | ISA Fundamentals | Packets, slots, .new, hardware loops, threads |
| 3 | Registers | General, pair, predicate, control, HVX registers; ABI |
| 4 | Encoding and Mnemonics | 32-bit words, parse bits, extenders, duplexes, assembly syntax |
| 5 | Data, Memory and Control | ALU, loads/stores, addressing, branches, loops, calls |
| 6 | FP, HVX and Alignment | Scalar floating point, HVX vectors, alignment rules |
| 7 | Caches, MMU and Glossary | Cache hierarchy and maintenance, VTCM, MMU, glossary |
Background: VLIW and multithreading are explained in the Computer Architecture wiki.
| Property | Hexagon |
|---|---|
| Word size | 32-bit (32-bit registers and addresses), 64-bit register pairs |
| Instruction size | 32 bits each; up to 4 per packet (16 bytes) |
| Issue model | VLIW: compiler-scheduled packets, in-order |
| Execution slots | 4 (slots 0-3) |
| Threads | Several hardware threads per core, interleaved (count depends on the chip) |
| Endianness | Little-endian |
| Memory accesses | Must be naturally aligned (scalar) |
| Vector extension | HVX: 32 vector registers of 64 or 128 bytes |
| Loops | Two zero-overhead hardware loops |
| Typical role | Low-power signal processing and ML inference next to the CPU |
flowchart LR
subgraph OoO["Big CPU core (e.g. Arm Cortex-X)"]
A1["Hardware finds parallelism<br/>rename, reorder, speculate"] --> A2["Fast single thread,<br/>high power"]
end
subgraph VLIW["Hexagon"]
B1["Compiler finds parallelism<br/>packs up to 4 instructions"] --> B2["Simple in-order hardware,<br/>low power, predictable timing"]
end
DSP code (filters, transforms, neural-network layers) is regular and loop-heavy, so a compiler can schedule it well ahead of time. That saves the power an out-of-order engine would spend, which matters in phones.
Sources: Wikipedia: Qualcomm Hexagon, Wikipedia: Very long instruction word
flowchart TB
subgraph SoC["Snapdragon SoC (simplified)"]
CPU["Arm CPU cores<br/>Android / Linux"]
GPU["Adreno GPU"]
subgraph DSP["Hexagon DSP / NPU"]
SC["Scalar core<br/>VLIW, hardware threads"]
HVX["HVX vector unit"]
TCM["VTCM (local memory)"]
end
CPU <-->|"FastRPC: offload calls"| DSP
MEM["Shared DRAM"]
CPU --- MEM
GPU --- MEM
DSP --- MEM
end
Applications on the Arm CPU offload work to the DSP through Qualcomm's FastRPC mechanism. The DSP runs its own real-time OS (QuRT).
LLVM knows these Hexagon versions, each enabled by a subtarget feature such as v68:
| Versions in LLVM | Notes |
|---|---|
| V5, V55 | Older scalar DSPs |
| V60, V62, V65, V66 | HVX introduced in V60 |
| V67, V68, V69 | V68+ add HVX floating point (hvx-qfloat) |
| V71, V73, V75, V79, V81 | Recent NPU-generation cores |
Matching HVX versions (hvxv60 … hvxv81), vector length (hvx-length64b, hvx-length128b) and options such as audio and hvx-ieee-fp are separate features.
clang --target=hexagon -mcpu=hexagonv73 -mhvx -mhvx-length=128B -O2 -c kernel.c (illustrative)
Sources: llvm/lib/Target/Hexagon/HexagonDepArch.td:11-37, llvm/lib/Target/Hexagon/Hexagon.td:32-96
- Hexagon is a 32-bit, in-order VLIW DSP that executes packets of up to four 32-bit instructions.
- HVX adds wide SIMD; versions V60 onward have it, V68 onward add vector floating point.
- It trades single-thread speed for low power and predictable timing.
- Computer Architecture Overview
- Fundamentals: CPU, Memory and Instructions
- Pipelining
- Branches and Remedies
- Instruction-Level Parallelism
- Memory and Ordering
- Caches and Coherence
- Multicore
- Multithreading in Hardware
- SIMD and GPUs
- Glossary and Summary
- Hexagon Overview and Processor Properties
- ISA Fundamentals: Packets, Slots and Threads
- Registers
- Instruction Encoding and Mnemonics
- Data, Memory and Control Instructions
- Floating Point, HVX and Alignment
- Caches, MMU and Glossary
- Operating Systems Overview
- Processes
- Threads
- CPU Scheduling
- Synchronization
- Deadlock
- Memory Management
- Virtual Memory
- Files, Storage and I/O
- Kernel and System Calls
- Interview Q&A and Glossary
- C++ for LLVM Development: Overview
- C++ Basics
- Classes and RAII
- Ownership and Move Semantics
- Templates and Lambdas
- LLVM Data Structures (ADT)
- LLVM-Style RTTI: isa, cast, dyn_cast
- Errors, Output and Assertions
- Iterators and Ranges
- Building, Debugging and Exercises
- LLVM IR Overview
- Structure: Modules, Functions, Blocks and Values
- Type System
- Arithmetic, Bitwise and Cast Instructions
- Compare and Select
- Memory: alloca, load, store and getelementptr
- Control Flow: br, switch, ret and call
- SSA and Phi
- Control Flow Graph and Loops
- Dominance, Dominator Tree and Dominance Frontier
- Data-flow Analysis
- Writing an IR Pass
- Common Passes
- Exercises, Tooling and Glossary
- SelectionDAG Overview
- Pipeline, Phases and Traversal Orders
- Core Data Structures
- DAG Construction
- DAG Combiner
- Legalization
- Type Legalization
- Operation and Vector Legalization
- Instruction Selection
- TableGen Pattern Language
- Matcher Interpreter and Folding
- AArch64 Instruction Selection
- Scheduling and MIR Emission
- PHI Node Resolution
- AArch64 Walkthroughs
- Arithmetic and Data Movement
- Memory Instructions
- Control Flow and Calls
- End-to-End Example
- Tooling, Debugging and Extending
- Selector Comparison and Glossary
- Assignments: Build the Toy Backend
- Stage 1: Build Setup
- Stage 2: Target Registration
- Stage 3: TableGen Skeleton
- Stage 4: MC Layer for Assembly Output
- Stage 5: TargetMachine and Subtarget
- Stage 6: TargetLowering, Arguments and Returns
- Stage 7: Instruction Selection and the First Function
- Stage 8: Registers, Copies and Spills
- Stage 9: Frame Lowering
- Stage 10: Memory, Globals and Control Flow
- Stage 11: Calls
- Stage 12: Scheduling Model
- Stage 13: Object Files
- Stage 14: Capstone, a Complete Toy Backend
- Target Bring-up Overview
- Directory Layout, CMake and Registration
- The Target .td File
- TargetMachine and Subtarget
- TargetLowering Setup
- Calling Conventions
- Instructions and Instruction Selection
- Registers and Allocation Hooks
- Frame Lowering
- AsmPrinter and the MC Layer
- Scheduling
- A Minimal Toy Target
- Bring-up Checklist and AArch64 File Map
- Tooling and Glossary
- Calling Conventions Overview
- The CallingConv.td Language
- CCState and CCValAssign
- LowerFormalArguments
- LowerCall
- LowerReturn and CanLowerReturn
- Varargs, byval, sret and swifterror
- Tail Calls and Sibling Calls
- Custom Backend Guide and Checklist
- AArch64 Walkthroughs
- Tooling and Glossary
- Frame Lowering Overview
- MachineFrameInfo
- TargetFrameLowering Hooks
- The PEI Pass
- Callee-Saved Registers and Stack Layout
- Frame Index Elimination and the Register Scavenger
- Shrink Wrapping
- CFI and Unwind Information
- Custom Backend Guide and Checklist
- AArch64 Walkthroughs
- Tooling and Glossary
- MC Layer Overview
- Core Data Structures
- Streamers
- Assembler and Layout
- Fixups and Relocations
- Writing an MC Layer for a Custom Backend
- MCAsmInfo and the Instruction Printer
- Code Emitter
- AsmBackend and Object Writer
- Assembly Parser and Disassembler
- Bring-up Checklist and Common Failures
- Tooling and Glossary
- Register Allocation Overview
- The Register Allocation Pipeline
- Registers, Virtual Registers and Register Classes
- Liveness: Slot Indexes and Live Intervals
- Preparing Code for Allocation
- PHI Elimination and Two-Address Lowering
- Register Coalescer
- Allocation Framework
- The Register Allocators
- Fast Register Allocator
- Basic Register Allocator
- Greedy Register Allocator
- PBQP Register Allocator
- Spilling and Splitting
- Spill Weights and Copy Hints
- The Inline Spiller
- Live Range Splitting
- Rewriting and Post-RA Passes
- Writing Register Allocation Support for a Custom Backend
- Register Definitions in TableGen
- TargetRegisterInfo Hooks
- TargetInstrInfo Hooks
- Pass Pipeline Hooks
- Bring-up Checklist and Common Failures
- AArch64 Walkthroughs
- Tooling and Debugging
- Glossary and Where Do I Look