当前位置: 首页>>代码示例>>C++>>正文


C++ IRBuilder::CreateMul方法代码示例

本文整理汇总了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());
}
开发者ID:Legacy25,项目名称:ValkyrieDB,代码行数:7,代码来源:Expression.cpp

示例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;
}
开发者ID:raincoat,项目名称:toy-llvm-frondend,代码行数:35,代码来源:codegen.cpp

示例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);
}
开发者ID:bkaradzic,项目名称:SwiftShader,代码行数:13,代码来源:AMDGPUCodeGenPrepare.cpp

示例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);
}
开发者ID:dtwitty,项目名称:brainfuck-llvm,代码行数:20,代码来源:codegen_canon.cpp


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