• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ X86Compiler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中X86Compiler的典型用法代码示例。如果您正苦于以下问题:C++ X86Compiler类的具体用法?C++ X86Compiler怎么用?C++ X86Compiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了X86Compiler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: double

void CompiledExpression::generateSingleArgCall(X86Compiler& c, X86XmmVar& dest, X86XmmVar& arg, double (*function)(double)) {
    X86GpVar fn(c, kVarTypeIntPtr);
    c.mov(fn, imm_ptr((void*) function));
    X86CallNode* call = c.call(fn, kFuncConvHost, FuncBuilder1<double, double>());
    call->setArg(0, arg);
    call->setRet(0, dest);
}
开发者ID:ANKELA,项目名称:opensim-core,代码行数:7,代码来源:CompiledExpression.cpp


示例2: main

int main(int argc, char* argv[]) {
  using namespace asmjit;

  Performance perf;
  uint32_t kNumRepeats = 10;
  uint32_t kNumIterations = 10000;

  JitRuntime runtime;
  X86Assembler a(&runtime);
  X86Compiler c;

  uint32_t r, i;

  // --------------------------------------------------------------------------
  // [Bench - Opcode]
  // --------------------------------------------------------------------------

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      asmgen::opcode(a);

      void *p = a.make();
      runtime.release(p);

      a.reset();
    }
    perf.end();
  }

  printf("Opcode   | Time: %-6u [ms] | Speed: %-9u [inst/s]\n",
    perf.best, instPerMs(perf.best, kNumIterations, asmgen::kGenOpCodeInstCount));

  // --------------------------------------------------------------------------
  // [Bench - Blend]
  // --------------------------------------------------------------------------

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      c.attach(&a);
      asmgen::blend(c);
      c.finalize();

      void* p = a.make();
      runtime.release(p);
    }
    perf.end();
  }

  printf("Blend    | Time: %-6u [ms] | Speed: %-9u [inst/s]\n",
    perf.best, instPerMs(perf.best, kNumIterations, asmgen::kGenBlendInstCount));

  return 0;
}
开发者ID:kbugstar,项目名称:asmjit,代码行数:57,代码来源:asmjit_bench_x86.cpp


示例3: compile

  virtual void compile(X86Compiler& c)
  {
    c.newFunc(kX86FuncConvDefault, FuncBuilder1<int, int>());
    c.getFunc()->setHint(kFuncHintNaked, true);

    // Call a function.
    GpVar address(c.newGpVar());
    GpVar var(c.getGpArg(0));

    c.mov(address, imm((sysint_t)(void*)calledFunc));
    X86CompilerFuncCall* ctx;

    ctx = c.call(address);
    ctx->setPrototype(kX86FuncConvCompatFastCall, FuncBuilder1<int, int>());
    ctx->setArgument(0, var);
    ctx->setReturn(var);

    ctx = c.call(address);
    ctx->setPrototype(kX86FuncConvCompatFastCall, FuncBuilder1<int, int>());
    ctx->setArgument(0, var);
    ctx->setReturn(var);

    c.ret(var);
    c.endFunc();
  }
开发者ID:AmesianX,项目名称:asmjit-1,代码行数:25,代码来源:testx86.cpp


示例4: fprintf

void X86TestSuite::run()
{
  size_t i;
  size_t testCount = testList.getLength();

  for (i = 0; i < testCount; i++)
  {
    X86Compiler compiler;
    StringLogger logger;

    logger.setLogBinary(true);
    compiler.setLogger(&logger);

    X86Test* test = testList[i];
    test->compile(compiler);

    void *func = compiler.make();

    // In case that compilation fails uncomment this section to log immediately
    // after "compiler.make()".
    //
    // fprintf(stdout, "%s\n", logger.getString());
    // fflush(stdout);

    if (func != NULL)
    {
      StringBuilder output;
      StringBuilder expected;

      if (test->run(func, output, expected))
      {
        fprintf(stdout, "[Success] %s.\n", test->getName());
      }
      else
      {
        fprintf(stdout, "[Failure] %s.\n", test->getName());
        fprintf(stdout, "-------------------------------------------------------------------------------\n");
        fprintf(stdout, "%s", logger.getString());
        fprintf(stdout, "\n");
        fprintf(stdout, "Result  : %s\n", output.getData());
        fprintf(stdout, "Expected: %s\n", expected.getData());
        fprintf(stdout, "-------------------------------------------------------------------------------\n");
      }

      MemoryManager::getGlobal()->free(func);
    }
    else
    {
      fprintf(stdout, "[Failure] %s.\n", test->getName());
      fprintf(stdout, "-------------------------------------------------------------------------------\n");
      fprintf(stdout, "%s\n", logger.getString());
      fprintf(stdout, "-------------------------------------------------------------------------------\n");
    }

    fflush(stdout);
  }

  fputs("\n", stdout);
  fputs(testOutput.getData(), stdout);
  fflush(stdout);
}
开发者ID:AmesianX,项目名称:asmjit-1,代码行数:61,代码来源:testx86.cpp


示例5: benchX86

static void benchX86(uint32_t arch, uint32_t callConv) {
  using namespace asmjit;

  Performance perf;
  TestRuntime runtime(arch, callConv);

  X86Assembler a(&runtime, arch);
  X86Compiler c;

  uint32_t r, i;

  const char* archName = arch == kArchX86 ? "X86" : "X64";

  // --------------------------------------------------------------------------
  // [Bench - Opcode]
  // --------------------------------------------------------------------------

  size_t asmOutputSize = 0;
  size_t cmpOutputSize = 0;

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    asmOutputSize = 0;
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      asmgen::opcode(a);

      void *p = a.make();
      runtime.release(p);

      asmOutputSize += a.getCodeSize();
      a.reset();
    }
    perf.end();
  }

  printf("%-12s (%s) | Time: %-6u [ms] | Speed: %7.3f [MB/s]\n",
    "X86Assembler", archName, perf.best, mbps(perf.best, asmOutputSize));

  // --------------------------------------------------------------------------
  // [Bench - Blend]
  // --------------------------------------------------------------------------

  perf.reset();
  for (r = 0; r < kNumRepeats; r++) {
    cmpOutputSize = 0;
    perf.start();
    for (i = 0; i < kNumIterations; i++) {
      c.attach(&a);
      asmgen::blend(c);
      c.finalize();

      void* p = a.make();
      runtime.release(p);

      cmpOutputSize += a.getCodeSize();
      a.reset();
    }
    perf.end();
  }

  printf("%-12s (%s) | Time: %-6u [ms] | Speed: %7.3f [MB/s]\n",
    "X86Compiler", archName, perf.best, mbps(perf.best, cmpOutputSize));
}
开发者ID:AmesianX,项目名称:asmjit,代码行数:64,代码来源:asmjit_bench_x86.cpp


示例6: main

int main(int argc, char* argv[])
{
  using namespace AsmJit;

  // ==========================================================================
  // Log compiler output.
  FileLogger logger(stderr);
  logger.setLogBinary(true);

  // Create compiler.
  /*
  X86Compiler c;
  c.setLogger(&logger);

  c.newFunc(kX86FuncConvDefault, FuncBuilder0<Void>());
  c.getFunc()->setHint(kFuncHintNaked, true);

  X86CompilerFuncCall* ctx = c.call((void*)dummyFunc);
  ctx->setPrototype(kX86FuncConvDefault, FuncBuilder0<Void>());

  c.endFunc();
  */

  X86Compiler c;
  c.setLogger(&logger);

  c.newFunc(kX86FuncConvDefault, FuncBuilder0<void>());
  c.getFunc()->setHint(kFuncHintNaked, true);
  
  Label l91 = c.newLabel();
  Label l92 = c.newLabel();
  Label l93 = c.newLabel();
  Label l94 = c.newLabel();
  Label l95 = c.newLabel();
  Label l96 = c.newLabel();
  Label l97 = c.newLabel();
  c.bind(l92);

  GpVar _var91(c.newGpVar());
  GpVar _var92(c.newGpVar());
  
  c.bind(l93);
  c.jmp(l91);
  c.bind(l95);
  c.mov(_var91, imm(0));
  c.bind(l96);
  c.jmp(l93);
  c.mov(_var92, imm(1));
  c.jmp(l91);
  c.bind(l94);
  c.jmp(l92);
  c.bind(l97);
  c.add(_var91, _var92);
  c.bind(l91);
  c.ret();
  c.endFunc();
  
  typedef void (*Func9)(void);
  Func9 func9 = asmjit_cast<Func9>(c.make());
  // ==========================================================================

  // ==========================================================================
  // Make the function.
  // MyFn fn = asmjit_cast<MyFn>(c.make());

  // Call it.
  // printf("Result %llu\n", (unsigned long long)fn());

  // Free the generated function if it's not needed anymore.
  //MemoryManager::getGlobal()->free((void*)fn);
  // ==========================================================================

  return 0;
}
开发者ID:AmesianX,项目名称:asmjit-1,代码行数:74,代码来源:testdummy.cpp



注:本文中的X86Compiler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ X86TargetMachine类代码示例发布时间:2022-05-31
下一篇:
C++ X86AsmPrinter类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap