08 2023 档案

摘要:见下文代码,方式一样的 ```c++ #include #include "llvm/IR/Module.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/raw_ostream.h" #include "llvm/IR/Funct 阅读全文
posted @ 2023-08-09 19:53 00lab 阅读(55) 评论(0) 推荐(0) 编辑
摘要:llvm::raw_ostream llvm::raw_ostream是一个抽象class,有两个重要的纯虚函数由子类实现,write_impl()保存将数据写入基础流的逻辑,current_pos()返回流中当前正在写入的位置。 llvm提供了以下输出流实现: - `outs()` for wri 阅读全文
posted @ 2023-08-02 21:19 00lab 阅读(376) 评论(0) 推荐(0) 编辑
摘要:**编译生成可执行文件** ```shell clang hello.c -o hello ``` ### 编译生成bc文件(不可读) 得到 LLVM 字节码文件.bc(不可读字节码文件) ```shell clang -O3 -emit-llvm hello.c -c -o hello.bc `` 阅读全文
posted @ 2023-08-02 21:14 00lab 阅读(238) 评论(0) 推荐(0) 编辑
摘要:## 一个ifelse源码编译 先看如下代码: ```c++ int func(int a) { int b; if (a > 5) b = 6; else b = 5; return b; } ``` 编译命令 ../output/bin/clang++ -emit-llvm llvm_if_el 阅读全文
posted @ 2023-08-02 21:10 00lab 阅读(54) 评论(0) 推荐(0) 编辑
摘要:## 四则运算指令 介绍如下: ```c++ #include #include "llvm/IR/Module.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/raw_ostream.h" #include "llvm/IR/F 阅读全文
posted @ 2023-08-02 20:07 00lab 阅读(7) 评论(0) 推荐(0) 编辑
摘要:主要分全局变量、函数参数、局部变量(常量)与返回值 ## 测试全局变量 介绍说明、代码、编译与结果如下: ```c++ #include "llvm/IR/Module.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/raw_os 阅读全文
posted @ 2023-08-02 19:59 00lab 阅读(47) 评论(0) 推荐(0) 编辑