Repository navigation
Hexagon ISA 03 registers
Relevant source files
The following files were used as context for generating this wiki page:
- llvm/lib/Target/Hexagon/HexagonRegisterInfo.td
- llvm/lib/Target/Hexagon/HexagonCallingConv.td
- Qualcomm: Hexagon Application Binary Interface User Guide
Hexagon has a small, regular register model: 32 general registers that can also be used as 16 pairs, 4 predicate registers, a set of control registers, and (with HVX) 32 wide vector registers with 4 vector predicates.
This page covers each register file, register pairs, the control registers, the HVX registers, and the calling-convention roles. How instructions use them is on Data, Memory and Control.
flowchart TB
subgraph Scalar["Scalar core (per hardware thread)"]
R["R0-R31: 32 x 32-bit general<br/>(pairs R1:0 ... R31:30 = 64-bit)"]
P["P0-P3: 4 x 8-bit predicates"]
C["C0-C31: control registers<br/>loops, USR, PC, GP, CS, timers"]
end
subgraph Vec["HVX (per vector context)"]
V["V0-V31: 64 or 128 bytes each<br/>(pairs W = V1:0 ... V31:30)"]
Q["Q0-Q3: vector predicates"]
end
| File | Count | Width | LLVM register class |
|---|---|---|---|
| General | 32 (r0-r31) |
32 bits | IntRegs |
| General pairs | 16 (r1:0 … r31:30) |
64 bits |
DoubleRegs (holds i64, f64, small vectors) |
| Predicate | 4 (p0-p3) |
8 bits | PredRegs |
| Control |
c0-c31 (not all defined) |
32 bits | CtrRegs |
| HVX vector | 32 (v0-v31) |
512 or 1024 bits | HvxVR |
| HVX pairs | 16 (v1:0 …) |
2 × vector | HvxWR |
| HVX predicate | 4 (q0-q3) |
1 bit per vector byte | HvxQR |
Sources: llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:222, llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:273-276, llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:521, llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:552
Three general registers have fixed jobs, defined with these aliases in LLVM:
| Register | Alias | Role |
|---|---|---|
r29 |
sp |
Stack pointer |
r30 |
fp |
Frame pointer |
r31 |
lr |
Link register (return address, set by call) |
A pair r1:0 is two consecutive registers used as one 64-bit value, high half in the odd register. Pairs must start at an even register.
flowchart LR
PR["r1:0 (64-bit)"] --> HI["r1 = bits 63..32"]
PR --> LO["r0 = bits 31..0"]
Sources: llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:116-118
p0-p3 hold results of comparisons. They are 8 bits wide so that vector compares on 8 bytes (vcmpb) set one bit per byte; scalar compares set all bits. They drive conditional instructions, conditional jumps and .new forwarding (ISA Fundamentals). Together they are also readable as control register c4 (p3:0).
Sources: llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:141-144
| Number | Name | Purpose |
|---|---|---|
| c0, c1 |
sa0, lc0
|
Hardware loop 0: start address, loop count |
| c2, c3 |
sa1, lc1
|
Hardware loop 1 |
| c4 | p3:0 |
All four predicates together |
| c6, c7 |
m0, m1
|
Modifier registers for post-increment and circular addressing |
| c8 | usr |
User status register: overflow flags, floating-point flags and rounding mode, loop configuration |
| c9 | pc |
Program counter (read-only) |
| c10 | ugp |
User general pointer (thread-local storage base) |
| c11 | gp |
Global pointer for GP-relative small-data addressing |
| c12, c13 |
cs0, cs1
|
Circular buffer start addresses |
| c14 | upcyclelo |
Cycle counter (low; c15 high) |
| c16, c17 |
framelimit, framekey
|
Stack overflow check limit, return-address scrambling key |
| c18 | pktcountlo |
Packet counter |
| c30 | utimerlo |
User timer |
Control registers are moved with r0 = c8 style transfers (or by name, r0 = usr). Supervisor-only system registers exist in addition (see Caches, MMU).
Sources: llvm/lib/Target/Hexagon/HexagonRegisterInfo.td:152-185
Each v register is one full vector: 64 bytes in 64-byte mode or 128 bytes in 128-byte mode, chosen by the chip and -mhvx-length. The same register holds 128 bytes, 64 halfwords or 32 words (in 128-byte mode). q registers hold one bit per byte lane and act as masks. More on FP, HVX and Alignment.
In the standard Hexagon ABI (general description; see the ABI guide):
| Registers | Role |
|---|---|
r0-r5
|
First six 32-bit arguments (64-bit values in aligned pairs) |
r0 (r1:0) |
Return value |
r6-r15, r28
|
Caller-saved temporaries |
r16-r27
|
Callee-saved |
r29, r30, r31
|
sp, fp, lr
|
LLVM's calling-convention description assigns i32 and i64 (and small vector) values to registers by type in this order; values that do not fit go on the stack.
Sources: llvm/lib/Target/Hexagon/HexagonCallingConv.td:19-32
- 32 general registers (
r29/r30/r31=sp/fp/lr), usable as 64-bit even/odd pairs. - 4 predicate registers drive conditional execution; control registers hold loops,
usr,pc,gp, modifiers. - HVX adds 32 wide vector registers, vector pairs, and 4 vector predicates.
- 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