Weekly Progress Report: Building an LLVM Backend for PRU

This is the weekly report for my GSoC project - Building an LLVM Backend for PRU.

1 Like

Hello Everyone! Here’s my Week 0 progress and the targets set for Week 1.

Tasks done in the Community Bonding Period - Week 0

  • Understood how to build a backend for a custom target in LLVM thoroughly.
  • Went through the PRU documentation, understood more about the hardware and it’s setup.
  • Submitted the Introductory Video.

Tasks for Week 1 - Conding Period Begins

  • Go through the PRU Assembly, compile some examples using pru-gcc.
  • Refer the Cpu0 backend, going through the codebase and implementation.
  • Read the PRU section of the reference manual, and understand more about it.

Suggestion given : Look for a way to take care of the special functions in the language, like gpio pins configuration, debugging functionality and so on

Final goal : Upstreaming the backend

Week 1

Tasks done in Week 1:

  • Setting up BeagleBone Black
  • Implementing basic examples, pru-gcc examples on BBB
  • Read about PRU Assembly Instruction


  • Do not use “Flasher” Debian image.
  • LLVM version 12 not supported by the Cpu0 backend.

Week 2 target:

  • Get the Cpu0 Backend Running
  • Implement examples on the Cpu0 backend
  • Understand it’s codebase

Week 2

Tasks done in Week 2:

  • Built the Cpu0 Backend using LLVM version 8
  • Implemented few examples
  • Understood the codebase, went through the tutorial

Invoke the llc built and do not use the system llc

Week 3 target:

  • Modify code for existing implementation of PRU backend
  • Write the registerinfo.td
  • Go through the PRU instructions thoroughly
1 Like

Week 3

Tasks done in Week 3:

  • Wrote the registerinfo.td (Tablegen file) for PRU
  • Went through the PRU Instruction set
  • Started working on the instrinfo.td for PRU
  • Started modifying the existing pru backend for lastest version of LLVM

Week 4 target:

  • Get done with instrinfo.td
  • Build the existing pru backend on LLVM version 16

Week 4

Tasks done in Week 4:

  • Wrote the Instrinfo.td (Tablegen file) for PRU
  • Wrote the Instrformat.td (Tablegen file) for PRU

Instruction formats of few pru instructions like sbbo, lbbo
Existing pru backend files need to be changed completely according to new LLVM version format

Week 5 target:

  • Test the tablegen files
  • Graft the Registerinfo.td file into Cpu0 backend and test

Week 5

Tasks done in Week 5:

  • Modified the registerinfo.td
  • Added type profiles and SD nodes to instrinfo.td
  • Worked on testing registerinfo.td by grafting in Cpu0 backend


Building the registerinfo.td by grafting in the Cpu0 backend, throws a lot of errors due to difference of the naming convention

Week 6

Tasks done in Week 6:

  • Worked on building a basic framework for the PRU target in LLVM

  • Registering PRU as a target

  • Writing all the target files, register, instructions files for PRU


Facing some compilation errors while building the code, working on resolving them

Week 7 target:

Register PRU as a target successfully

Week 7
Tasks done in Week 7:

  • Successfully registered PRU as a target in LLVM
  • Basic framework for PRU ready in the llvm source code

Week 8 target:
Work on all the files of PRU to be able to produce output for basic codes.

Week 8:
Tasks done in Week 8:

  • Working on the Instruction files and IselLowering files
  • Completed chp1 and chp2.1 of the Cpu0 repo being referred

No resource for the instruction formats of PRU, so contacted a TI person through LLVM forum

Week 9 target:
Complete chp 2.2 and chp2.3 of the Cpu0 reference repo

Week 9
Tasks done in Week 9:

  • Working on the framelowering, targetmachine and machinefunction info files
  • Completed chp2.2 and chp2.3 of the Cpu0 repo being referred

Instruction formats for PRU, discussing with the mentors

Week 10 target:
Complete chp 2.4 and chp2.5 of the Cpu0 reference repo

Week 10
Tasks done in Week 10:

  • Working on the DagtoDagfiles, AsmInfo, Instruction Format files
  • Completed chp2.4 and chp2.5 of the Cpu0 repo being referred

Compilation issues while building

Unfortunately a lot of valuable information was lost when TI shutdown their Wiki. But I managed to backup the information about PRU instruction format. See processors.wiki.ti.com Programmable_Realtime_Unit · dinuxbg/gnupru Wiki · GitHub

This is really helpful, thank you so much! @dinux