llvm

Creating parameters for a function with clang

半城伤御伤魂 提交于 2019-12-10 13:21:50
问题 I have source code which looks like this, void update(); void update() { } Iam trying to parse this code with clang and modify the code to this. typedef float v4sf attribute ((vector_size(16))); void update(v4sf& v1, v4sf& v2); void update(v4sf& v1, v4sf& v2) { } I looked at the Rewriter classes of clang. In the function which i wrote as shown below, MyRecursiveASTVisitor::VisitFunctionDecl(FunctionDecl *f) FunctionDecl has setParams() method which i could use. I would have to create params

Generate LLVM IR from Haskell code

拥有回忆 提交于 2019-12-10 13:02:00
问题 My goal is take source codes in different languages (mostly C, C++, Obj-C and Haskell) and tell every kind of statistics about them. (eg. number of variables, functions, memory allocations, complexity etc.) LLVM seemed to be a perfect tool for this, because I can generate the bitcode for these languages and with LLVM's customizable passes I can almost do anything. For the C family it works fine, take a C program ( test.c ) for example: #include <stdio.h> int main( ) { int num1, num2, sum;

Is libc++'s implementation of `std::make_heap` nonconformant

风格不统一 提交于 2019-12-10 12:31:35
问题 Edit: this is not asking how to do std::make_heap the O(n) way, but rather whether this particular implementation is indeed O(n) The textbook way of building a heap in O(n) time is to successively build the heap from bottom up. But the implementation of std::make_heap on my Mac machine in libc++ is template <class _RandomAccessIterator, class _Compare> inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { #ifdef _LIBCPP

Install numba 0.30.1 on ubuntu 16.04 lts

三世轮回 提交于 2019-12-10 11:04:28
问题 How do I install the current version (0.30.1) of numba for Python 3 on Ubuntu 16.04 LTS? My version of Python is 3.5.2, and I have a barebones install of Ubuntu (server edition I think) 回答1: Okay so after a couple of hours of figuring things out, I've decided that this is painful enough to share and not let others figure out. First, set up the basics: install Python 3, Git and g++ sudo apt install python3 git g++ Then get python3 packages PyPI (aka pip) and NumPy sudo apt python3-pip pip3

llvm每日谈之三 如何创建一个LLVM工程

[亡魂溺海] 提交于 2019-12-10 08:15:24
作者: snsn1984 阅读了文档《Creating an LLVM Project》(地址:http://llvm.org/docs/Projects.html)之后,自己照着做了一遍,记录一下自己的过程。 实际做的时候跟文档上还是有不同的。 1.首先我系统上的llvm3.1是之前已经下好,并且make过的。我打开llvm-3.1/projects目录,看到下面有一个我之前放的compiler-rt目录和另外一个本来这里就有的sample。把sample这个文件夹copy到llvm3.1的同级目录。修改文件夹名字为MyFirstLLVM。 2. 打开MyFirstLLVM/autoconf目录,打开configure.ac. 3. AC_INIT后面的括号里面有三个中括号,第一个中括号要填的是这个项目的名字,第二个是这个项目的版本号,第三个是作者的联系邮箱,可改可不改。 4. 因为现在MyFirstLLVM已经和llvm-3.1在同级目录了,所以修改接下来的LLVM_SRC_ROOT="../../llvm-3.1" LLVM_OBJ_ROOT="../../llvm-3.1/build"。llvm-3.1/build目录是我编译llvm-3.1的目录。 5. 修改AC_CONFIG_AUX_DIR后面的内容为:(["../../llvm-3.1/autoconf"])。 6.

llvm每日谈之一 llvm是什么

徘徊边缘 提交于 2019-12-10 08:03:34
作者: snsn1984 写在前面的话: 最近接触llvm比较多,在这个上面花了不少的时间。感 觉llvm要完全理解透是个很不容易的事情,需要在学习过程中好好的整理下自己的思路。刚好又阅读了开源项目Storm的作者Nathan Marz的博客《You should blog even if you have no readers》,就打开自己的blog,开始了这个llvm每日谈的系列。希望自己能坚持的久一点,多写写llvm的每个方面,多写写自己的理解。 欢迎感兴趣的人一起探讨研究。 llvm是什么? llvm是low level virtual machine的简称,其实是一个编译器框架。llvm随着这个项目的不断的发展,已经无法完全的代表这个项目了,只是这种叫法一直延续下来。 llvm是一个开源的项目。它最早的时候是Illinois的一个研究项目,主要负责人是Chris Lattner,他现在就职于Apple. Apple 目前也是llvm项目的主要赞助者之一。 llvm的主要作用是它可以作为多种语言的后端,它可以提供可编程语言无关的优化和针对很多种CPU的代码生成功能。此外llvm目前已经不仅仅是个编程框架,它目前还包含了很多的子项目,比如最具盛名的clang. llvm的优点是开源,有一个表达形式很好的IR语言,模块化作的特别好。

what is the right abstraction for compilation unit in LLVM?

橙三吉。 提交于 2019-12-10 06:54:44
问题 in LLVM we have the LLVMContext , which is the unit of storage, and we have the llvm::Module , which is where new symbols (functions and types) are built. my question is; what is the right llvm abstraction to use for compilation units? is the Module ? or is this actually meant for a bigger scope, i.e: a shared library target It seems to me that a compilation unit must satisfy an all-or-nothing result; either it compiles all its content without errors, or either there are errors and it needs

LLVM每日谈之七 Clang

血红的双手。 提交于 2019-12-10 06:36:58
作者: snsn1984 官方介绍Clang是LLVM native的一个面向C/C++/Objective-C的编译器,目标是要提供一个编译非常快的编译器。他们宣称在Debug模式下编译Objective-C比GCC快3倍。至于是否能比GCC快这么多,总有人去做对比,大家可以搜索下,好像确实快了些。 Clang一般被说是LLVM的一个前端。关于前端的定义,大家可以从LLVM每日谈之二里面看到前端在整个LLVM体系中的位置。Clang当初的定位就是要做下一个十年中一个伟大的前端,这也是苹果公司需要的。谈到苹果,现在也是LLVM最大的赞助商。苹果公司认为GCC的前端越来越不好用,并且不能给苹果的IDE提供很好的服务,所以他们转向了LLVM,Clang的定位就是替代GCC的前端。 Clang需要单独下载源码,放到LLVM Source/tools下面,然后整个编译LLVM才行。一般大家按照官方文档编译,都是已经放了Clang了。开始学习Clang文档的地址: http://clang.llvm.org/get_started.html 。这里下载源码的话使用svn下载的是最新的主干版本,大家可以从首页找到最后的发布版本的下载, 地址在: http://llvm.org/releases/ 。这里可以看到发布的各个版本,目前最新的是3.1, 马上3.2就要出来了

LLVM每日谈之十六 LLVM的学习感悟

不羁岁月 提交于 2019-12-10 06:20:24
这些总结并非我自己写的,而是摘自LLVM的版本比较老的文档中。因为老版本的文档已经鲜有人关注了,而这篇总结的非常好,到现在也很有用处,所以就把这部分内容贴出来了。这只是原文档的一部分。 原文档地址:http://llvm.org/releases/1.1/docs/Stacker.html 正文内容: Lessons I Learned About LLVM Everything's a Value! Although I knew that LLVM uses a Single Static Assignment (SSA) format, it wasn't obvious to me how prevalent this idea was in LLVM until I reallystarted using it. Reading the Programmer's Manual and Language Reference ,I noted that most of the important LLVM IR (Intermediate Representation) C++ classes were derived from the Value class. The full power of that simpledesign only became fully

LLVM每日谈之十五 LLVM自带的examples

有些话、适合烂在心里 提交于 2019-12-10 05:06:26
作者: snsn1984 在LLVM源码的目录下,有一个目录叫做examples,这个目录下边有几个LLVM的例子,初学者一般不会太关注这些例子,但是这些例子确实是精华中 的精华,在LLVM的学习过程中不可避免的要对这些例子所涉及内容要精通。所以希望大家一定要对这些例子重视起来,它们都是经典中的经典。从我个人而言, 从这些例子中学到了很多,文档说了很多都没能让人明白的东西,在这里,一个简单的例子就讲的很清楚了。 首先,要想执行这些例子,可以在cmake的时候加上参数 -DLLVM_BUILD_EXAMPLES=ON 。这样在最终编译出的bin目录下的可执行文件中,就多了这几个例子的可执行文件,运行这些文件就可以看到这些例子的输出。 接下来,我们看看这些例子到底都讲了什么东西。 llvm/examples/BrainF (Need To Do) llvm/examples/ExceptionDemo (Need To Do)从名字上来看,这个例子介绍的是LLVM的Exception模型,但是这块我目前还没有涉猎,没有进行研究,所以暂时不做介绍。 llvm/examples/Fibonacci 这个例子很像HowToUseJIT,所做的工作差不多,创建Module,创建Function,然后使用JIT,然后让函数运行。唯一的不同之处是这 个例子实现的是Fibonacci