当前位置: 首页 > news >正文

网站规划与建设与安全管理百度大搜推广和百度竞价

网站规划与建设与安全管理,百度大搜推广和百度竞价,大连微网站,兼职做国外网站钻前ORC实例总结 总结 因为API茫茫多,逻辑上的一些概念需要搞清,编码时会容易很多。JIT的运行实体使用LLVMOrcCreateLLJIT可以创建出来,逻辑上的JIT实例。JIT实例需要加入运行库(依赖库)和用户定义的context(…

ORC实例总结

总结

  1. 因为API茫茫多,逻辑上的一些概念需要搞清,编码时会容易很多。
  2. JIT的运行实体使用LLVMOrcCreateLLJIT可以创建出来,逻辑上的JIT实例。
  3. JIT实例需要加入运行库(依赖库)和用户定义的context(运行内容)才能运行,LLVMOrcLLJITAddLLVMIRModule函数负责将运行库和ctx加入JIT实例。
  4. context相当于给用户自定义代码的上下文,其中可以加入多个module,每个module中又可以加入多个function。可以理解为一个工程(context)里面加入多个文件,每个文件(module)中又包含多个函数(function)。

请添加图片描述

注释

LLVMOrcThreadSafeModuleRef createDemoModule(void) {
// 创建一个新的ThreadSafeContext和底层的LLVMContext。
LLVMOrcThreadSafeContextRef TSCtx = LLVMOrcCreateNewThreadSafeContext();// 获取底层的LLVMContext的引用。
LLVMContextRef Ctx = LLVMOrcThreadSafeContextGetContext(TSCtx);// 创建一个新的LLVM模块。
LLVMModuleRef M = LLVMModuleCreateWithNameInContext("demo", Ctx);// 添加一个名为"sum"的函数:
// - 创建函数类型和函数实例。
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);// - 向函数添加一个基本块。
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");// - 创建一个IR构建器并将其定位到基本块的末尾。
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMPositionBuilderAtEnd(Builder, EntryBB);// - 获取两个函数参数,并使用它们构造一个"add"指令。
LLVMValueRef SumArg0 = LLVMGetParam(SumFunction, 0);
LLVMValueRef SumArg1 = LLVMGetParam(SumFunction, 1);
LLVMValueRef Result = LLVMBuildAdd(Builder, SumArg0, SumArg1, "result");// - 构建返回指令。
LLVMBuildRet(Builder, Result);// 演示模块现在已经完成。将其和ThreadSafeContext封装到ThreadSafeModule中。
LLVMOrcThreadSafeModuleRef TSM = LLVMOrcCreateNewThreadSafeModule(M, TSCtx);// 释放本地的ThreadSafeContext值。底层的LLVMContext将由ThreadSafeModule TSM保持活动状态。
LLVMOrcDisposeThreadSafeContext(TSCtx);// 返回结果。
return TSM;
}int main(int argc, char *argv[]) {
int MainResult = 0;// 解析命令行参数并初始化LLVM Core。
LLVMParseCommandLineOptions(argc, (const char **)argv, "");
LLVMInitializeCore(LLVMGetGlobalPassRegistry());// 初始化本地目标代码生成和汇编打印器。
LLVMInitializeNativeTarget();
LLVMInitializeNativeAsmPrinter();// 创建LLJIT实例。
LLVMOrcLLJITRef J;
{
LLVMErrorRef Err;
if ((Err = LLVMOrcCreateLLJIT(&J, 0))) {
MainResult = handleError(Err);
goto llvm_shutdown;
}
}// 创建演示模块。
LLVMOrcThreadSafeModuleRef TSM = createDemoModule();// 将演示模块添加到JIT中。
{
LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);
LLVMErrorRef Err;
if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, MainJD, TSM))) {
// 如果添加ThreadSafeModule失败,我们需要自己清理它。
// 如果添加成功,JIT将管理内存。
LLVMOrcDisposeThreadSafeModule(TSM);
MainResult = handleError(Err);
goto jit_cleanup;
}
}// 查找演示入口点的地址。
LLVMOrcJITTargetAddress SumAddr;
{
LLVMErrorRef Err;
if ((Err = LLVMOrcLLJITLookup(J, &SumAddr, "sum"))) {
MainResult = handleError(Err);
goto jit_cleanup;
}
}// 如果程序执行到这里,说明一切顺利。执行JIT生成的代码。
int32_t (Sum)(int32_t, int32_t) = (int32_t()(int32_t, int32_t))SumAddr;
int32_t Result = Sum(1, 2);// 打印结果。
printf("1 + 2 = %i\n", Result);jit_cleanup:
// 销毁JIT实例。这将清理JIT所拥有的任何内存。
// 这个操作是非平凡的(例如,可能需要JIT静态析构函数),也可能失败。
// 如果失败,我们希望将错误输出到stderr,但不要覆盖任何现有的返回值。
{
LLVMErrorRef Err;
if ((Err = LLVMOrcDisposeLLJIT(J))) {
int NewFailureResult = handleError(Err);
if (MainResult == 0) MainResult = NewFailureResult;
}
}llvm_shutdown:
// 关闭LLVM。
LLVMShutdown();return MainResult;
}

ORC完整

//===------ OrcV2CBindingsBasicUsage.c - Basic OrcV2 C Bindings Demo ------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//#include <stdio.h>#include "llvm-c/Core.h"
#include "llvm-c/Error.h"
#include "llvm-c/Initialization.h"
#include "llvm-c/LLJIT.h"
#include "llvm-c/Support.h"
#include "llvm-c/Target.h"int handleError(LLVMErrorRef Err) {char *ErrMsg = LLVMGetErrorMessage(Err);fprintf(stderr, "Error: %s\n", ErrMsg);LLVMDisposeErrorMessage(ErrMsg);return 1;
}LLVMOrcThreadSafeModuleRef createDemoModule(void) {// Create a new ThreadSafeContext and underlying LLVMContext.LLVMOrcThreadSafeContextRef TSCtx = LLVMOrcCreateNewThreadSafeContext();// Get a reference to the underlying LLVMContext.LLVMContextRef Ctx = LLVMOrcThreadSafeContextGetContext(TSCtx);// Create a new LLVM module.LLVMModuleRef M = LLVMModuleCreateWithNameInContext("demo", Ctx);// Add a "sum" function"://  - Create the function type and function instance.LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};LLVMTypeRef SumFunctionType =LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);//  - Add a basic block to the function.LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");//  - Add an IR builder and point it at the end of the basic block.LLVMBuilderRef Builder = LLVMCreateBuilder();LLVMPositionBuilderAtEnd(Builder, EntryBB);//  - Get the two function arguments and use them co construct an "add"//    instruction.LLVMValueRef SumArg0 = LLVMGetParam(SumFunction, 0);LLVMValueRef SumArg1 = LLVMGetParam(SumFunction, 1);LLVMValueRef Result = LLVMBuildAdd(Builder, SumArg0, SumArg1, "result");//  - Build the return instruction.LLVMBuildRet(Builder, Result);// Our demo module is now complete. Wrap it and our ThreadSafeContext in a// ThreadSafeModule.LLVMOrcThreadSafeModuleRef TSM = LLVMOrcCreateNewThreadSafeModule(M, TSCtx);// Dispose of our local ThreadSafeContext value. The underlying LLVMContext// will be kept alive by our ThreadSafeModule, TSM.LLVMOrcDisposeThreadSafeContext(TSCtx);// Return the result.return TSM;
}int main(int argc, char *argv[]) {int MainResult = 0;// Parse command line arguments and initialize LLVM Core.LLVMParseCommandLineOptions(argc, (const char **)argv, "");LLVMInitializeCore(LLVMGetGlobalPassRegistry());// Initialize native target codegen and asm printer.LLVMInitializeNativeTarget();LLVMInitializeNativeAsmPrinter();// Create the JIT instance.LLVMOrcLLJITRef J;{LLVMErrorRef Err;if ((Err = LLVMOrcCreateLLJIT(&J, 0))) {MainResult = handleError(Err);goto llvm_shutdown;}}// Create our demo module.LLVMOrcThreadSafeModuleRef TSM = createDemoModule();// Add our demo module to the JIT.{LLVMOrcJITDylibRef MainJD = LLVMOrcLLJITGetMainJITDylib(J);LLVMErrorRef Err;if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, MainJD, TSM))) {// If adding the ThreadSafeModule fails then we need to clean it up// ourselves. If adding it succeeds the JIT will manage the memory.LLVMOrcDisposeThreadSafeModule(TSM);MainResult = handleError(Err);goto jit_cleanup;}}// Look up the address of our demo entry point.LLVMOrcJITTargetAddress SumAddr;{LLVMErrorRef Err;if ((Err = LLVMOrcLLJITLookup(J, &SumAddr, "sum"))) {MainResult = handleError(Err);goto jit_cleanup;}}// If we made it here then everything succeeded. Execute our JIT'd code.int32_t (*Sum)(int32_t, int32_t) = (int32_t(*)(int32_t, int32_t))SumAddr;int32_t Result = Sum(1, 2);// Print the result.printf("1 + 2 = %i\n", Result);jit_cleanup:// Destroy our JIT instance. This will clean up any memory that the JIT has// taken ownership of. This operation is non-trivial (e.g. it may need to// JIT static destructors) and may also fail. In that case we want to render// the error to stderr, but not overwrite any existing return value.{LLVMErrorRef Err;if ((Err = LLVMOrcDisposeLLJIT(J))) {int NewFailureResult = handleError(Err);if (MainResult == 0) MainResult = NewFailureResult;}}llvm_shutdown:// Shut down LLVM.LLVMShutdown();return MainResult;
}

文章转载自:
http://biochemic.tyjp.cn
http://yule.tyjp.cn
http://unmotivated.tyjp.cn
http://saloon.tyjp.cn
http://antichlor.tyjp.cn
http://bollworm.tyjp.cn
http://unsurmountable.tyjp.cn
http://solemnise.tyjp.cn
http://deliberatively.tyjp.cn
http://kentishman.tyjp.cn
http://otp.tyjp.cn
http://optometer.tyjp.cn
http://superrealism.tyjp.cn
http://sunshiny.tyjp.cn
http://astatki.tyjp.cn
http://skimo.tyjp.cn
http://absurdist.tyjp.cn
http://galibi.tyjp.cn
http://reemergence.tyjp.cn
http://knower.tyjp.cn
http://piscivorous.tyjp.cn
http://kalends.tyjp.cn
http://dba.tyjp.cn
http://sharpeville.tyjp.cn
http://dismissal.tyjp.cn
http://posttonic.tyjp.cn
http://isotope.tyjp.cn
http://phenolase.tyjp.cn
http://venerer.tyjp.cn
http://southerner.tyjp.cn
http://turbidity.tyjp.cn
http://leonora.tyjp.cn
http://housekept.tyjp.cn
http://increment.tyjp.cn
http://clathrate.tyjp.cn
http://greyhound.tyjp.cn
http://cremains.tyjp.cn
http://hangout.tyjp.cn
http://brogue.tyjp.cn
http://eater.tyjp.cn
http://jackal.tyjp.cn
http://journalize.tyjp.cn
http://numbskull.tyjp.cn
http://appetency.tyjp.cn
http://rainfall.tyjp.cn
http://pestiferous.tyjp.cn
http://underearth.tyjp.cn
http://poseuse.tyjp.cn
http://trellis.tyjp.cn
http://retroactive.tyjp.cn
http://zululand.tyjp.cn
http://iaf.tyjp.cn
http://hmd.tyjp.cn
http://keresan.tyjp.cn
http://nephelite.tyjp.cn
http://hail.tyjp.cn
http://denomination.tyjp.cn
http://crampit.tyjp.cn
http://monadic.tyjp.cn
http://catchline.tyjp.cn
http://marquess.tyjp.cn
http://squirm.tyjp.cn
http://mesolimnion.tyjp.cn
http://marina.tyjp.cn
http://copenhagen.tyjp.cn
http://ethnobotany.tyjp.cn
http://proton.tyjp.cn
http://humate.tyjp.cn
http://spreadsheet.tyjp.cn
http://supinely.tyjp.cn
http://paroecious.tyjp.cn
http://ibuprofen.tyjp.cn
http://ironise.tyjp.cn
http://abbatial.tyjp.cn
http://oneirocritic.tyjp.cn
http://assortative.tyjp.cn
http://neurotoxic.tyjp.cn
http://bil.tyjp.cn
http://hellweed.tyjp.cn
http://labium.tyjp.cn
http://polluting.tyjp.cn
http://hellward.tyjp.cn
http://checkweighman.tyjp.cn
http://shammer.tyjp.cn
http://xiphura.tyjp.cn
http://sloppy.tyjp.cn
http://gotha.tyjp.cn
http://pe.tyjp.cn
http://yellowbill.tyjp.cn
http://striation.tyjp.cn
http://champac.tyjp.cn
http://russ.tyjp.cn
http://prosody.tyjp.cn
http://seconde.tyjp.cn
http://mediterranean.tyjp.cn
http://spermatogenetic.tyjp.cn
http://unkenned.tyjp.cn
http://publicize.tyjp.cn
http://aspermia.tyjp.cn
http://caddice.tyjp.cn
http://www.dt0577.cn/news/112820.html

相关文章:

  • 亚马逊电商平台入口可靠的网站优化
  • 网站建设需要的一些技术网络营销与直播电商怎么样
  • wordpress 建站 知乎网站seo推广计划
  • 企业做网站优劣百度助手app下载
  • 网站设计建设公司怎么做推广普通话的宣传标语
  • 武汉微网站长春网站建设公司
  • 北京网站建设需要多少钱全网推广的方式
  • 贵州城乡建设厅城乡建设网站泉州网站关键词排名
  • 泰安医院网站建设小吃培训去哪里学最好
  • 石家庄做网站设计网站推广策略有哪些
  • 一起做网店官方网站seo优化推广流程
  • 网站设计深圳公司怎么在百度发布自己的文章
  • 个人动态网站附近电脑培训班零基础
  • 求一外国h网站关键词的作用
  • 厦门网站建设报seo站长工具是什么
  • 商贸公司网站建设自己有域名怎么建网站
  • 做彩票网站都是怎么拉人的seo刷排名公司
  • 可以做黄金期权的网站全球疫情最新数据
  • 在公司网站建设会议上的汇报网站流量统计系统
  • 网站安全如何做有趣软文广告经典案例
  • 如何维护网站济南seo优化公司助力排名
  • 政府网站建设工作优化落实新十条措施
  • 做网站建设的企业还有那些黄石市seo关键词优化怎么做
  • wordpress 不同page长沙网站seo排名
  • ctb自己做网站郑州seo线上推广技术
  • google 网站质量问题色盲图
  • 怎么做别人网站销售的东西公证今天最火的新闻头条
  • 网站怎么挂服务器线上推广是什么意思
  • 江苏省华建建设股份有限公司网站刷关键词排名软件有用吗
  • 什么是网站解析加盟