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


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

本文整理汇总了C++中IRBuilder::CreateICmpSLT方法的典型用法代码示例。如果您正苦于以下问题:C++ IRBuilder::CreateICmpSLT方法的具体用法?C++ IRBuilder::CreateICmpSLT怎么用?C++ IRBuilder::CreateICmpSLT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRBuilder的用法示例。


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

示例1: getValue

Value* LessThanExpression::getValue() {
    assert(leftExpression != NULL);
    assert(rightExpression != NULL);
    assert(leftExpression->getType() == rightExpression->getType());

    IRBuilder<>* builder = codegen::getBuilder();
    int c;
    if(leftExpression->getType() != COLEXPRESSION) {
        c = leftExpression->getType();
    } else {
        c = convertDTtoET(leftExpression->getDataType());
    }
    switch(c) {
        case LONGVALUEEXPRESSION:
            return builder->CreateICmpSLT(leftExpression->getValue(), rightExpression->getValue());
        case DOUBLEVALUEEXPRESSION:
            return builder->CreateFCmpOLT(leftExpression->getValue(), rightExpression->getValue());
        case STRINGVALUEEXPRESSION:
        case DATEVALUEEXPRESSION:
            return codegen::stringCmp(leftExpression->getValue(), rightExpression->getValue(), LESSTHANEXPRESSION);
        default:
            cout << "Unknown expression type!" << endl;
            exit(-1);
    }

    return NULL;
}
开发者ID:Legacy25,项目名称:ValkyrieDB,代码行数:27,代码来源: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: emitCond

		static Value* emitCond(IRBuilder<>& builder, Value* arg) {
			return builder.CreateICmpSLT(arg, builder.getInt64(0));
		}
开发者ID:xuhd,项目名称:llvmmmix,代码行数:3,代码来源:ConditionalOpcodesImpl.cpp

示例4: CreatePassManager


//.........这里部分代码省略.........
                assert(inputs->source->size >= 0);
                size = inputs->source->size;
            }
            assert(size == inputs->source->size || inputs->source->size == 1);
        }
        args++;
        argument_addresses[i] = builder->CreateAlloca(arguments[2], nullptr, argument_names[i]);
        builder->CreateStore(&*args, argument_addresses[i]);
        args++; i++;
        argument_addresses[i] = builder->CreateAlloca(arguments[3], nullptr, argument_names[i]);
        builder->CreateStore(&*args, argument_addresses[i]);
        args++; i++;
        argument_addresses[i] = builder->CreateAlloca(arguments[4], nullptr, argument_names[i]);
        builder->CreateStore(&*args, argument_addresses[i]);
        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)
开发者ID:Mytherin,项目名称:numpyllvm,代码行数:67,代码来源:compiler.cpp


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