예제 #1
0
Value* GreaterThanExpression::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->CreateICmpSGT(leftExpression->getValue(), rightExpression->getValue());
        case DOUBLEVALUEEXPRESSION:
            return builder->CreateFCmpOGT(leftExpression->getValue(), rightExpression->getValue());
        case STRINGVALUEEXPRESSION:
        case DATEVALUEEXPRESSION:
            return codegen::stringCmp(leftExpression->getValue(), rightExpression->getValue(), GREATERTHANEXPRESSION);
        default:
            cout << "Unknown expression type!" << endl;
            exit(-1);
    }

    return NULL;
}
예제 #2
0
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
0
		static Value* emitCond(IRBuilder<>& builder, Value* arg) {
			return builder.CreateICmpSGT(arg, builder.getInt64(0));
		}