Skip to content

Assignments 12 calls

Mugundan edited this page Nov 27, 2026 · 1 revision

Stage 11: Calls

Relevant source files

The following files were used as context for generating this wiki page:

Make functions call each other, including recursion and stack arguments.

Purpose and Scope

LowerCall, ToyISD::CALL, CALL instruction (isCall, Defs = [LR]), call-frame pseudos, getCallPreservedMask.

Read First

Tasks

  1. Implement LowerCall following the Toy version on the callconv custom backend page.
  2. ADJCALLSTACKDOWN/UP registered in the ToyInstrInfo constructor; eliminateCallFramePseudoInstr.
  3. Save lr and used callee-saved registers in the prologue (default spill path).

Tests

Recursive fib(n), a call with six arguments, a call whose result is used after another call. Check lr is saved only in non-leaf functions.

Done When

  • Recursion correct
  • Stack arguments at the right offsets
  • Values live across calls are in callee-saved registers

Stretch

Sibling calls (tail calls) and varargs (special arguments).

Next: stage 12. All Toy code and expected output on this page are illustrative, not LLVM source and not tool output; your exact output may differ.

Start here

Computer Organization & Architecture

Hexagon ISA

Operating Systems

C++ for LLVM Development

LLVM IR

SelectionDAG

Backend Assignments

Target Bring-up

Calling Conventions

Frame Lowering

MC Layer

Register Allocation

Scheduling

Clone this wiki locally