Skip to content

Assignments 07 lowering

Mugundan edited this page Nov 27, 2026 · 1 revision

Stage 6: TargetLowering, Arguments and Returns

Relevant source files

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

Tell SelectionDAG which types are legal and lower function entry and return.

Purpose and Scope

ToyTargetLowering constructor, ToyCallingConv.td (CC_Toy, RetCC_Toy, CSR_Toy), LowerFormalArguments, LowerReturn, CanLowerReturn.

Read First

Tasks

  1. addRegisterClass(MVT::i32, &Toy::GPRRegClass), computeRegisterProperties, then Expand for SDIV, SREM, UDIV, UREM, rotates, CTPOP, BR_CC, SELECT_CC.
  2. Calling convention exactly as in the overview.
  3. ToyISD::RET node and a RET pseudo or instruction with isReturn.

Tests

define void @f() { ret void } reaches instruction selection (error should now be Cannot select or succeed if RET has a pattern). Six-argument i32 function: -stop-after=finalize-isel shows two %fixed-stack loads.

Done When

  • ret void and ret i32 %a selected
  • i64 return splits into r0/r1
  • i128 return demoted to sret

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