CPU Design · All levels

ABI and Calling Conventions

ISA & Programmer Model: ABI register classes, stack alignment, and parameter passing rules determine function-call overhead, spill behavior, and interop safety across compiler, runtime, and libraries.

What this topic teaches

ABI and Calling Conventions turns CPU design theory into actionable review decisions. ABI register classes, stack alignment, and parameter passing rules determine function-call overhead, spill behavior, and interop safety across compiler, runtime, and libraries. The target is evidence-backed closure, not opinion-driven tuning.

Senior-engineer framing question

When call/return overhead cycles, register spill rate, and stack bandwidth pressure shifts, can you prove first failing stage, dominant mechanism, accountable owner, and release-safe mitigation?

diagram
CPU PIPELINE VIEW - ABI and Calling Conventions

fetch -> decode -> rename -> dispatch -> execute -> retire
  |        |         |          |         |         |
icache   uop flow   map table  queueing  FU ports  ROB commit

steady-state goal:
keep every stage supplied without bubbles or flush storms

Focus: connect metric movement to the first stage loss
Metric tracked: call/return overhead cycles, register spill rate, and stack bandwidth pressure

Architecture visuals

Draw the mechanism before changing knobs. These visuals are optimized for design reviews and interview whiteboards.

Call/return critical path

diagram
CPU PIPELINE VIEW - ABI and Calling Conventions

fetch -> decode -> rename -> dispatch -> execute -> retire
  |        |         |          |         |         |
icache   uop flow   map table  queueing  FU ports  ROB commit

steady-state goal:
keep every stage supplied without bubbles or flush storms

Focus: highlight call, return, and stack traffic around hot functions
Metric tracked: call/return overhead cycles, register spill rate, and stack bandwidth pressure

ABI owner split and signoff

diagram
CPU OWNERSHIP LAYERS - ABI and Calling Conventions

artifact area     owner
----------------  ----------------------------
architecture    compiler backend owner
RTL/microarch   runtime ABI owner
software/tools  performance engineer

Rule: every regressed metric must map to an explicit owner and closure artifact.

Out-of-order control map

diagram
OOO CORE BLOCK DIAGRAM - ABI and Calling Conventions

decode -> rename -> dispatch -> reservation stations -> execute units
             |                        |                    |
       free-list / map table       wakeup-select         writeback
             \                        |                    /
              +-------- reorder buffer / retire ---------+

Focus: rename to retire dataflow

Memory hierarchy map

diagram
CPU CACHE + MEMORY HIERARCHY - ABI and Calling Conventions

                 [ L1I ]   [ L1D ]
               32-64KB, ~4 cycles
                      \     /
                       [  L2  ]
                 512KB-2MB, ~12 cycles
                           |
                         [ L3 ]
               shared LLC, 30-60 cycles
                           |
                    [ DDR/HBM memory ]
                    80-150ns effective

Optimization lens: latency vs capacity tradeoff

Speculation lens

diagram
BRANCH PREDICTOR VIEW - ABI and Calling Conventions

fetch PC -> BTB lookup -> direction predictor -> target select -> fetch redirect
               |               |                    |
          BTB miss cost     confidence         RAS / indirect path

branch resolves in execute:
correct prediction  -> pipeline keeps flowing
mispredict          -> flush + restart + refill

Focus: minimize wrong-path work

Ownership layers

diagram
CPU OWNERSHIP LAYERS - ABI and Calling Conventions

artifact area     owner
----------------  ----------------------------
architecture    compiler backend owner
RTL/microarch   runtime ABI owner
software/tools  performance engineer

Rule: every regressed metric must map to an explicit owner and closure artifact.

Evidence required

  • Primary metric: call/return overhead cycles, register spill rate, and stack bandwidth pressure.

  • Primary artifact: calling-convention compliance report, prologue/epilogue profile, and spill heatmap.

  • Owners to include: compiler backend owner, runtime ABI owner, performance engineer.

  • One reproducible failing workload and one stable comparator run.

  • One run with fully locked environment metadata for causal comparison.

Compute-memory limit lens

diagram
CPU ROOFLINE - ABI and Calling Conventions

performance
   ^
   |                 compute roof
   |                /
   |               /
   |--------------/---------------- memory roof
   +----------------------------------------------> arithmetic intensity
      memory-bound                 compute-bound

Interpretation: separate compute and memory limits

Key takeaways

  • Classify stage loss before proposing fixes.

  • Use artifacts to separate mechanism from symptoms.

  • Close with owner accountability and rollback criteria.

Common pitfalls

  • Using average IPC alone while ignoring tail behavior.

  • Comparing traces across mismatched binaries or thermal states.

  • Calling closure without workload-level validation.

CPU deep dive

ISA choices are software contracts that directly become decode, verification, and security cost in silicon.

Concept diagram

diagram
ISA CONTRACT STACK

instruction semantics -> encoding -> decode/uOP expansion -> architectural state

Metric graph

diagram
ISA HEALTH TREND

illegal encoding escapes     █
decode expansion pressure    ████
ABI mismatch incidents       ██

Reports and artifacts

  • instruction legality audit

  • decode critical-path report

  • ABI conformance summary

  • trap/CSR latency sheet

Mini case study

A late ISA extension looked harmless but increased decode expansion ratio and pushed front-end timing beyond closure margin.

Debug branches

  • Map each ISA feature to decode and retire implications

  • Separate architectural correctness from microarchitectural cost

  • Validate privileged behavior with precise-state traces

Senior review question

Ask: which CPI/latency evidence proves this topic is truly closed beyond synthetic benchmarks?

Key takeaways

  • Always connect microarchitectural counter changes to product workload outcomes.

  • Lock binary, compiler, firmware, and thermal metadata before comparing CPU traces.

Common pitfalls

  • Treating average IPC as sufficient proof while ignoring latency tails and outliers.

  • Applying predictor or prefetch tweaks without first-failing-stage attribution.

  • Declaring closure without reproducible perf, correctness, and power gates.