本文整理汇总了C++中IRBuilder::CreateAdd方法的典型用法代码示例。如果您正苦于以下问题:C++ IRBuilder::CreateAdd方法的具体用法?C++ IRBuilder::CreateAdd怎么用?C++ IRBuilder::CreateAdd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRBuilder
的用法示例。
在下文中一共展示了IRBuilder::CreateAdd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void MmixLlvm::Private::emitIncl(VerticeContext& vctx, IRBuilder<>& builder, MXByte xarg, MXWyde yzarg)
{
Value *xval0 = vctx.getRegister(xarg);
Value* result = builder.CreateAdd(xval0, builder.getInt64((MXOcta) yzarg));
assignRegister(vctx, builder, xarg, result);
builder.CreateBr(vctx.getOCExit());
}
示例2: getValue
Value* AdditionExpression::getValue() {
assert(leftExpression != NULL);
assert(rightExpression != NULL);
IRBuilder<>* builder = codegen::getBuilder();
return builder->CreateAdd(leftExpression->getValue(), rightExpression->getValue());
}
示例3: codeGen
Value* Op::codeGen(CodeGenContext &context) {
cout << "Creating Op " << op <<endl;
IRBuilder<> *builder = context.currentBuilder();
Value *tape_1;
Value *lshValue = lhs.codeGen(context);
Value *rshValue = rhs.codeGen(context);
switch(op) {
case T_PLUS:
tape_1 = builder->CreateAdd(lshValue,
rshValue, "addtmp");
break;
case T_MINUS:
tape_1 = builder->CreateSub(lshValue,
rshValue, "subtmp");
break;
case T_DIV:
tape_1 = builder->CreateUDiv(lshValue,
rshValue, "divtmp");
break;
case T_MUL:
tape_1 = builder->CreateMul(lshValue,
rshValue, "multmp");
break;
case T_LT:
tape_1 = builder->CreateICmpSLT(lshValue,
rshValue, "lttmp");
break;
case T_GT:
tape_1 = builder->CreateICmpSGT(lshValue,
rshValue, "gttmp");
break;
}
return tape_1;
}
示例4: Visit
void ASTCodeGenVisitor::Visit(DecrData* s) {
IRBuilder<> builder = builders_.top();
Value* ptr_val = builder.CreateLoad(ptr_);
Value* result = builder.CreateAdd(ptr_val, neg_one);
builder.CreateStore(result, ptr_);
VisitNextASTNode(s);
}
示例5: Visit
void CNodeCodeGenVisitor::Visit(CAdd* s) {
IRBuilder<> builder = builders_.top();
Value* offset_ptr = builder.CreateGEP(ptr_, GetPtrOffset(s->GetOffset()));
Value* offset_val = builder.CreateLoad(offset_ptr);
Value* add_val = GetDataOffset(s->GetAmt());
Value* result = builder.CreateAdd(offset_val, add_val);
builder.CreateStore(result, offset_ptr);
VisitNextCNode(s);
}
示例6: compile_plus
/// compile_plus - Emit code for '+'
void BrainFTraceRecorder::compile_plus(BrainFTraceNode *node,
IRBuilder<>& builder) {
Value *CellValue = builder.CreateLoad(DataPtr);
Constant *One =
ConstantInt::get(IntegerType::getInt8Ty(Header->getContext()), 1);
Value *UpdatedValue = builder.CreateAdd(CellValue, One);
builder.CreateStore(UpdatedValue, DataPtr);
if (node->left != (BrainFTraceNode*)~0ULL)
compile_opcode(node->left, builder);
else {
HeaderPHI->addIncoming(DataPtr, builder.GetInsertBlock());
builder.CreateBr(Header);
}
}
示例7: CreatePassManager
//.........这里部分代码省略.........
args++; i++;
argument_addresses[i] = builder->CreateAlloca(arguments[5], nullptr, argument_names[i]);
builder->CreateStore(&*args, argument_addresses[i]);
args++; i++;
assert(args == function->arg_end());
assert(i == arg_count);
info.index_addr = argument_addresses[start_addr];
info.thread_addr = argument_addresses[thread_nr_addr];
PerformInitialization(info, pipeline->operation);
builder->CreateBr(loop_cond);
}
// for loop condition: index < end
builder->SetInsertPoint(loop_cond);
{
LoadInst *index = builder->CreateLoad(argument_addresses[start_addr], "index");
LoadInst *end = builder->CreateLoad(argument_addresses[end_addr], "end");
Value *condition = builder->CreateICmpSLT(index, end, "index < end");
builder->CreateCondBr(condition, loop_body, loop_end);
}
// loop body: perform the computation
builder->SetInsertPoint(loop_body);
{
LoadInst *index = builder->CreateLoad(argument_addresses[start_addr], "index");
info.index = index;
info.index_addr = argument_addresses[start_addr];
// perform the computation over the given index
// we don't use the return value because the final assignment has already taken place
Value *v = PerformOperation(info, thread->builder, thread->context, pipeline->operation, pipeline->inputData, pipeline->outputData);
if (v == NULL) {
// failed to perform operation
printf("Failed to compile pipeline %s\n", pipeline->name);
return NULL;
}
builder->CreateBr(loop_inc);
}
// loop increment: index++
builder->SetInsertPoint(loop_inc);
{
LoadInst *index = builder->CreateLoad(argument_addresses[start_addr], "index");
Value *incremented_index = builder->CreateAdd(index, ConstantInt::get(int64_tpe, 1, true), "index++");
builder->CreateStore(incremented_index, argument_addresses[start_addr]);
builder->CreateBr(loop_cond);
}
// loop end: return; (nothing happens here because we have no return value)
builder->SetInsertPoint(loop_end);
{
// return the output size of each of the columns
int i = 0;
Value *result_sizes = builder->CreateLoad(argument_addresses[result_sizes_addr], "result_sizes[]");
for(auto it = pipeline->outputData->objects.begin(); it != pipeline->outputData->objects.end(); it++) {
Value* output_count;
if (it->index_addr) {
output_count = builder->CreateLoad((Value*) it->index_addr, "count");
} else {
output_count = ConstantInt::get(int64_tpe, 1, true);
}
Value *output_addr = builder->CreateGEP(int64_tpe, result_sizes, ConstantInt::get(int64_tpe, i, true));
builder->CreateStore(output_count, output_addr);
i++;
}
builder->CreateRet(ConstantInt::get(int64_tpe, 0, true));
}
#ifndef _NOTDEBUG
verifyFunction(*function);
verifyModule(*module);
#endif
//printf("LLVM for pipeline %s\n", pipeline->name);
module->dump();
passmanager->run(*function);
// dump generated LLVM code
//module->dump();
auto handle = thread->jit->addModule(std::move(owner));
jit_function compiled_function = (jit_function) thread->jit->findSymbol(fname).getAddress();
if (!compiled_function) {
printf("Error creating function.\n");
return NULL;
}
JITFunction *jf = CreateJITFunction(thread, pipeline);
jf->size = size;
jf->function = compiled_function;
jf->jit = thread->jit.get();
jf->handle = handle;
assert(jf->function);
return jf;
}