static std::unique_ptr<legacy::FunctionPassManager> g_fpm; void InitializeModuleAndPassManager(void) { // Open a new module. g_llvm_module = std::make_unique<Module>("my cool jit", g_llvm_context); // Create a new pass manager attached to it. g_fpm = std::make_unique<legacy::F...
return std::make_unique<PrototypeAST>(fn_name, std::move(arg_names)); } 解析函数:def + 函数原型 + 函数体,函数体是一个表达式。 代码语言:txt AI代码解释 /// definition ::= 'def' prototype expression static std::unique_ptr<FunctionAST> ParseDefinition() { NextToken(); // eat def. aut...
std::unique_ptr<ExprAST> cond = ParseExpression(); GetNextToken(); // eat then std::unique_ptr<ExprAST> then_expr = ParseExpression(); GetNextToken(); // eat else std::unique_ptr<ExprAST> else_expr = ParseExpression(); return std::make_unique<IfExprAST>(std::move(cond), std::...
假设我们将新后端代码存放在llvm/lib/Target/MyArch目录下。 llvm/|-- lib/||-- Target/||-- MyArch/||-- CMakeLists.txt||-- MyArch.td||-- MyArch.h||-- MyArch.cpp||-- MyArchTargetMachine.h||-- MyArchTargetMachine.cpp||-- MyArchInstrInfo.cpp||-- MyArchRegisterInfo.cpp||-- M...
this->builder = std::make_unique<llvm::IRBuilder<>>(llvmContext); } private: std::unique_ptr<llvm::Module> module; std::unique_ptr<llvm::IRBuilder<>> builder; llvm::LLVMContext llvmContext; } LLVM IR API 的另一个关键类是llvm::Value类,它是所有计算值和其他键类(如llvm::Instruction和...
autoResult=llvm::make_unique<NumberExprAST>(NumVal); getNextToken();// consume the number returnstd::move(Result); } 1. 2. 3. 4. 5. 6. 再看看函数声明的: /// prototype /// ::= id '(' id* ')' staticstd::unique_ptr<PrototypeAST>ParsePrototype() { ...
std::unique_ptr<legacy::FunctionPassManager> functionPassManager = make_unique<legacy::FunctionPassManager>(module.get()); // Promote allocas to registers. functionPassManager->add(createPromoteMemoryToRegisterPass()); // Do simple "peephole" optimizations ...
注意,要安装到默认的系统文件夹,您需要在构建完成后发出make install 命令。本文后面的内容将假设 clang 标头和库分别位于类似于 /usr/local/include 和 /usr/local/lib 的系统文件夹中。 LLVM 拥有自己的前端:名为 clang 的一种工具(恰如其分)。Clang 是一种功能强大的C/C++/Objective-C 编译器,其编译速度...
Raise minimum cmake version to 3.10 11个月前 scripts Ensure fileIndex is unique 1年前 tests Fix assert while trying to mangle a deduction guide 6年前 .clang-format Add a clang-format file and run clang-format over the repo 2年前
(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete< llvm::ToolOutputFile>>&) /builddir/build/BUILD/llvm-project-17.0.5.src/clang/lib/CodeGen/BackendUtil.cpp:1116:3 ...