llvm

What is LLVM Intermediate representation?

帅比萌擦擦* 提交于 2019-12-01 03:42:48
I have tried the LLVM demo from the link http://llvm.org/demo/ What kind of IR is this? HIR, MIR or LIR? The SSA representation is usually used in MIR, I think. So, is it an MIR? But it can store the informations for dependence analysis. Hence can it be an HIR? What file extention actually represent the LLVM IR, .ll or .bc? How can I get the symbol table used in LLVM? I'm not familiar with a single, strict definition of what differentiates one level of IR from another, but from what I know it would fall under the MIR category. It has SSA form and doesn't have explicit registers, so I would

How to add a Metadata String to an LLVM module with the C++ API?

﹥>﹥吖頭↗ 提交于 2019-12-01 03:16:31
问题 I'm trying to add a metadata string to my LLVM module. The stripped down version of what I'm trying is #include <llvm/LLVMContext.h> #include <llvm/Module.h> #include <llvm/Metadata.h> using namespace llvm; int main() { Module* module = new Module("test", getGlobalContext()); MDString::get(module->getContext(), "test"); module->dump(); } I can compile and run it: Desktop% g++ llvm.cc -o llvm `llvm-config --cppflags --ldflags --libs all` Desktop% ./llvm ; ModuleID = 'test' But as one can see,

Call Python code from LLVM JIT

岁酱吖の 提交于 2019-12-01 02:09:41
问题 I write a language lexer/parser/compiler in python, that should run in the LLVM JIT-VM (using llvm-py ) later. The first two steps are quite straightforward for now, but (even if I didn't start the compile-task yet) I see a problem, when my code wants to call Python-Code (in general), or interact with the Python lexer/parser/compiler (in special) respectively. My main concern is, that the code should be able to dynamically load additional code into the VM at runtime and thus it must trigger

Does Xcode 4 have support for AVX?

爷,独闯天下 提交于 2019-12-01 02:01:09
Before I spend time and money downloading Xcode 4, can anyone tell me whether it comes with a version of gcc (or any other compiler, e.g. LLVM) which supports the AVX instruction set on Sandy Bridge CPUs (i.e. gcc -mavx on mainstream gcc builds) ? I don't seen any public release notes anywhere so it's not easy to check, and I don't really need Xcode 4 yet unless it has AVX support. I eventually cracked and downloaded Xcode 4 - it looks like clang is the only compiler that may support AVX currently, although I haven't tested it properly: $ clang -dM -E -mavx - < /dev/null | grep -i avx #define

What is LLVM Intermediate representation?

蓝咒 提交于 2019-12-01 01:29:39
问题 I have tried the LLVM demo from the link http://llvm.org/demo/ What kind of IR is this? HIR, MIR or LIR? The SSA representation is usually used in MIR, I think. So, is it an MIR? But it can store the informations for dependence analysis. Hence can it be an HIR? What file extention actually represent the LLVM IR, .ll or .bc? How can I get the symbol table used in LLVM? 回答1: I'm not familiar with a single, strict definition of what differentiates one level of IR from another, but from what I

LLVM - Run Own Pass automatically with clang

邮差的信 提交于 2019-12-01 01:19:10
问题 I wrote a few own passes for llvm, in order to use them with clang. I integrated them in llvm (not dynamically loaded). They are even listed in the Optimizations available: section when I type: opt --help-hidden I want to run one of own my passes now automatically as the last one when I call clang: clang ./hello.bc -o ./hello or even with c-code: clang ./hello.c -o ./hello When I run my pass with opt manually, the modified ByteCode is generated and written to a new .bc file: opt -my-pass < .

how to compile CUDA to llvm IR?

本秂侑毒 提交于 2019-12-01 00:05:01
I've been trying for three days to compile a CUDA kernel into llvm IR and I couldn't do it. I've changed langoptions.cpp and added CUDA=1; in the constructor , but still the clang give me Error messages for cuda syntax (like _synchthreads() call). I've done the following: downloaded llvm (including clang) modified langoptions.cpp (CUDA=1; in the constructor), and installed it. installed CUDA toolkit 4.1 and CUDA SDK. compiled a CUDA example using clang using: clang -I${CUDA_HOME}/include -I${CUDA_SDK_INC} ~/workspace/cuda_example/mis_kernel.cu -S -emit-llvm -o ~/workspace/cuda_example/a.ll and

LLVM insert intrinsic function Cos

我只是一个虾纸丫 提交于 2019-11-30 23:27:54
I am trying to insert intrinsic cos() function call to LLVM pass. My code in a FunctionPass: std::vector<Type *> arg_type; arg_type.push_back(Type::getFloatTy(getGlobalContext())); Function *fun = Intrinsic::getDeclaration(F.getParent(), Intrinsic::cos, arg_type); CallInst* callInst = CallInst::Create(fun, args, Twine("cos"), (Instruction *)&I); When I leave out last line generated IR is: define i32 @main() nounwind uwtable { entry: ... } declare float @llvm.cos.f32(float) nounwind readonly , but with CallInst included all i get is: 0 opt 0x000000000094f4bf 1 opt 0x000000000094f9c9 2

计算机的革命----编译器体系的战争<二>-----集团军的危险信号

痴心易碎 提交于 2019-11-30 20:27:53
Symantec C/C++ 已经不见踪影,Symantec现在专心做他的安全软件,诺顿杀毒软件,还有一些其他的,Boland C/C++最后还是被收购了,现在的RAD C++ Builder混的一直不愠不火,WATCOM 被Sybase败落后终于开源了,现在是Open WATCOM 1.9,Open WATCOM 2.0正在构建中,前几日我还编译了 2.0Beta1 现在呢,Microsoft C/C++也还不错,代码质量什么的也很好,在微软的内部,C/C++的压力也不小,.NET托管的还有C# Visual Basic F#这些都在争取微软的资源,微软也曾经推出过C/C++编译器的研究项目 Phoenix,现在呢,是推出Roslyn,C#,Visual Basic的编译器项目,WPF直到Visual Studio 11才在Windows 8上正式支持C/C++构建,以往,如果不是自己设置,C/C++代码不用C/CLR是无法支持的,当然就算WPF支持也要C/CLR。不过,在Windows平台上,最佳C/C++应用开发Visual C/C++是最佳选择,前提是你有足够的钱支付软件授权费用。GCC在Windows上有两个著名的移植版本一个是cygwin,也就是windows 上模拟Linux,一般而言开发基于Windows的程序不太建议,因为这样的程序还要调用cygwin库

How do I use an exisiting function pass from my LLVM - pass?

a 夏天 提交于 2019-11-30 20:15:13
I have been using LLVM and I was confused how to use a different already present pass from my own pass ? Precisely my program needs Dominance Frontier Calculation for any given instruction. LLVM already has the Dominance function Class that is implemented as a function pass. How can i invoke it/make use of it in my Module Pass ? osgx WARNING: I have no real experience and answer may be incorrect or outdated. (it is based largely on outdated LLVM sources: version 1.3 .) Add an include: #include "llvm/Analysis/DominanceFrontier.h" If your pass if Function Pass, add to your class the method (if