Skip to content

Assignments 06 targetmachine

Mugundan edited this page Nov 27, 2026 · 1 revision

Stage 5: TargetMachine and Subtarget

Relevant source files

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

Create the per-compilation and per-CPU objects and the pass pipeline.

Purpose and Scope

ToyTargetMachine, ToySubtarget, ToyPassConfig, empty ToyInstrInfo, ToyRegisterInfo, ToyFrameLowering stubs.

Read First

Tasks

  1. Constructor calls CodeGenTargetMachineImpl(...) with TT.computeDataLayout(), then initAsmInfo().
  2. Subtarget owns instr info, frame lowering and lowering; calls ParseSubtargetFeatures.
  3. ToyPassConfig::addInstSelector adds your selector (stub for now).
  4. ToyRegisterInfo: getCalleeSavedRegs, getReservedRegs (SP), getFrameRegister (stubs are fine).

Tests

llc -mtriple=toy-unknown-elf empty.ll -o - (a module with no functions) prints a file header and exits 0.

Done When

  • Empty module compiles
  • -mcpu=generic accepted

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