本文整理汇总了C++中IRBuilder::CreateMul方法的典型用法代码示例。如果您正苦于以下问题:C++ IRBuilder::CreateMul方法的具体用法?C++ IRBuilder::CreateMul怎么用?C++ IRBuilder::CreateMul使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRBuilder
的用法示例。
在下文中一共展示了IRBuilder::CreateMul方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getValue
Value* MultiplicationExpression::getValue() {
assert(leftExpression != NULL);
assert(rightExpression != NULL);
IRBuilder<>* builder = codegen::getBuilder();
return builder->CreateMul(leftExpression->getValue(), rightExpression->getValue());
}
示例2: 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;
}
示例3: make_pair
static std::pair<Value*, Value*> getMul64(IRBuilder<> &Builder,
Value *LHS, Value *RHS) {
Type *I32Ty = Builder.getInt32Ty();
Type *I64Ty = Builder.getInt64Ty();
Value *LHS_EXT64 = Builder.CreateZExt(LHS, I64Ty);
Value *RHS_EXT64 = Builder.CreateZExt(RHS, I64Ty);
Value *MUL64 = Builder.CreateMul(LHS_EXT64, RHS_EXT64);
Value *Lo = Builder.CreateTrunc(MUL64, I32Ty);
Value *Hi = Builder.CreateLShr(MUL64, Builder.getInt64(32));
Hi = Builder.CreateTrunc(Hi, I32Ty);
return std::make_pair(Lo, Hi);
}
示例4: Visit
void CNodeCodeGenVisitor::Visit(CMul* s) {
IRBuilder<> builder = builders_.top();
int op_offset = s->GetOpOffset();
int target_offset = s->GetTargetOffset();
int amt = s->GetAmt();
Value* op_offset_ptr = builder.CreateGEP(ptr_, GetPtrOffset(op_offset));
Value* target_offset_ptr =
builder.CreateGEP(ptr_, GetPtrOffset(target_offset));
Value* mul_val = GetDataOffset(amt);
Value* op_val = builder.CreateLoad(op_offset_ptr);
Value* target_val = builder.CreateLoad(target_offset_ptr);
Value* mul_result = builder.CreateMul(op_val, mul_val);
Value* add_result = builder.CreateAdd(target_val, mul_result);
builder.CreateStore(add_result, target_offset_ptr);
VisitNextCNode(s);
}