This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments. On top of LLVM 3.9, an experimental backend targeting ANSI C is being implemented for the PIC16F877 in lib/Target/PIC16.
LLVM is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.
Please see the documentation provided in docs/ for further assistance with LLVM, and in particular docs/GettingStarted.rst for getting started with LLVM and docs/README.txt for an overview of LLVM's documentation setup.
If you are writing a package for LLVM, see docs/Packaging.rst for our suggestions.
A microcontroller created by MicroChip, more details can be found here: http://www.microchip.com/wwwproducts/en/PIC16F877A
This repo can be built from source. To do this, follow the offical LLVM guide to building: http://llvm.org/docs/CMake.html
Alternatively this project's binaries can be downloaded: This executable was built using Debian Jessie, although it should work for any x86 linux operating system.
wget https://github.com/loganleland/llvm/releases/download/rc1/pic16rc1.tar.gz
tar -zxvf pic16rc1.tar.gz
PATH=$PATH:$PWD/PIC16rc1
compilePIC16 source.c
postLLC can be found at llvm/lib/Target/PIC16/postLLC.sh
clang -S -emit-llvm -target pic16 source.c
llc -mcpu=generic -march=pic16 source.ll
postLLC.sh source.s
While using this compiler it would be greatly beneficial to the developers of this backend if you fill out the following survey: https://goo.gl/forms/AYxzRiEtKxIy9aBy2
This backend is a preliminary prototype undergoing active development. Pull requests are very welcome.
- Functions
- Variable scoping
- Control Structures
- Variable assignment
- Integer addition/subtraction
- Bitwise operations: &,|,^
- integer comparisons: &&, ||, ==, !=
ANSI C
toLLVM IR
clang
LLVM IR
toPre-PIC16 ISA
llc
Pre-PIC16 ISA
toPIC16 ISA
postLLC: Transforms the llc output assembly into PIC16 ISA (will be removed once assembler is implemented)
PIC16 ISA
toByte-code
mpasm
- Implement assembler
- Implement multiplication and division
- Implement more integer comparisons
- Refactor
- Create API for timing, I/O ports, etc
- Currently our implementation is confined to one out of the four available banks of general purpose registers. Using more of these banks would allow for more variables
- Implement vector support