Skip to content

Assignments 15 capstone

Mugundan edited this page Nov 27, 2026 · 1 revision

Stage 14: Capstone, a Complete Toy Backend

Relevant source files

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

Tie everything together: compile C with clang and prove the backend correct on a test suite.

Purpose and Scope

A clang target (clang/lib/Basic/Targets/Toy.{h,cpp}) and a regression and execution test suite.

Read First

Tasks

  1. Add a clang TargetInfo for toy (type sizes matching the data layout, predefined __toy__).
  2. Compile 10 programs at -O0 and -O2: arithmetic, loops, recursion, arrays, structs by value, globals, switch, function pointers, long long math (libcalls), a spill-heavy function.
  3. If you write or reuse a simple Toy simulator, run them and compare with host results; otherwise check assembly by hand against the ABI.
  4. Keep everything as lit tests.

Tests

clang --target=toy-unknown-elf -O2 -c prog.c succeeds for all 10 programs; the whole llvm/test/CodeGen/Toy directory passes under llvm-lit.

Done When

Stretch

Varargs, tail calls, CFI and shrink wrapping, llvm-mca with your model, GlobalISel.

Next: stage 15. 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