本文整理汇总了C++中X86Compiler::setLogger方法的典型用法代码示例。如果您正苦于以下问题:C++ X86Compiler::setLogger方法的具体用法?C++ X86Compiler::setLogger怎么用?C++ X86Compiler::setLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X86Compiler
的用法示例。
在下文中一共展示了X86Compiler::setLogger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}