Code Monkey home page Code Monkey logo

p2tree / llvm_for_cpu0 Goto Github PK

View Code? Open in Web Editor NEW
186.0 9.0 72.0 78.55 MB

This is a tutorial to learn LLVM, I realize a backend to compiler machine code for cpu0 which is a simple RISC cpu.

CMake 0.30% C++ 41.52% Shell 0.04% Go 0.03% OCaml 0.11% Python 0.51% CSS 0.01% Roff 0.01% Batchfile 0.01% C 12.59% NASL 0.01% LLVM 31.67% Assembly 11.66% Objective-C 0.87% HTML 0.38% Swift 0.01% C# 0.02% TypeScript 0.01% Emacs Lisp 0.01% Objective-C++ 0.24%

llvm_for_cpu0's Introduction

Introduction

前言

项目路径:https://github.com/P2Tree/LLVM_for_cpu0

介绍

这个项目是一个学习 LLVM 的教程,我实现了一个 LLVM 框架下的后端,用来编译能够在 Cpu0 上执行的可执行代码,Cpu0 是一个简单易学的 RISC 处理器。另外,我还编写了一份详细的中文文档作为 LLVM 初学者的指南,它们放在 tutorial 路径下。

这个目录和其子目录下包含着完整的 LLVM 的源代码,目前是 8.0.0 版本,以及用于构建优化编译器、优化器和运行时环境的工具包。

大多数代码都放到 src/lib/Target/Cpu0 这个路径下,不过也有少量代码在其他位置,配合修改了公共代码。

使用方法

你可以把文档的每个章节作为指南来阅读和学习,并把工程中的代码作为参考。 我把每个章节修改过的文件都放到了 shortcut/ch_x 的各个路径下,如果在编码时有困惑,可以辅助查看。 我知道,目前代码和文档里依然会有问题,如果你有任何疑问,欢迎告知我。

感谢

正如我在文档中写到的,教程文档高度参考了一本教程,这个教程叫 Tutorial: Creating an LLVM Backend for Cpu0 Architecture,其作者叫 Chen Chung-Shu,他的教程对我学习 LLVM 非常有帮助。不过,因为完成较早,教程依赖的 LLVM 版本比较旧,大概是 3.0 版本,所以我重新用新版本实现了一遍。 所以,我诚挚的感谢 Chen Chung-Shu,感谢他的细致工作。

Preface

Project path: https://github.com/P2Tree/LLVM_for_cpu0

Introduction

This is a tutorial to learn LLVM, I realize a backend in LLVM infrastructure to compiler execute code for Cpu0 which is a simple RISC cpu. And I also write a detailed tutorial document by Chinese as a guidance for Chinese LLVM beginner. You can find it in the toturial.

This directory and its subdirectories contain source code for LLVM ( LLVM 8.0.0 currently ), a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.

Most of the code about Cpu0 backend is located in the src/lib/Target/Cpu0 but some are in other path to change public code.

Usage

You can read and learn each chapter in the document for a guide and use code of this project as a reference. I put every changed file into the shortcut/ch_x and you can check it if you have some trouble with coding. I think there are also have some bugs and drawbacks in the document and the code, please feel free to tell me if you have any problem.

Grateful

As I told you in the document, this tutorial document is reference extensively to a guide with Chen Chung-Shu which name is Tutorial: Creating an LLVM Backend for Cpu0 Architecture, this guide is very helpful for me to learn LLVM. As the guidence is so old with LLVM ( LLVM 3.0 probably ), I achieved again with a new version of LLVM. So I express heartfelt thanks to Chen Chung-Shu and his careful work.

llvm_for_cpu0's People

Contributors

gwdx avatar p2tree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.