Skip to content

Assignments 11 control memory

Mugundan edited this page Nov 27, 2026 · 1 revision

Stage 10: Memory, Globals and Control Flow

Relevant source files

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

Compile real loops: loads and stores of all widths, global addresses, compares and branches.

Purpose and Scope

Load/store patterns with an address ComplexPattern, GlobalAddress lowering, branch instructions, analyzeBranch/insertBranch/removeBranch.

Read First

Tasks

  1. SelectAddr matching (add base, simm16), frame indices and plain registers.
  2. Sign/zero-extending loads and truncating stores (lb, lbu, sb, ...).
  3. GlobalAddress custom-lowered to ToyISD::HI/LO → lui + addi with %hi/%lo operand flags printed by the instruction printer.
  4. BRCOND/SETCC patterns using beq/bne/blt/bge/slt; unconditional jmp.
  5. Branch analysis hooks so -O2 branch folding and block placement work.

Tests

Array sum loop, strlen, a switch (expanded to compares), a global counter increment.

Done When

  • Loops at -O0 and -O2
  • All load/store widths
  • -verify-machineinstrs clean after branch folding

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