Esempio n. 1
0
bool Unboxing::genericArithmetic(llvm::Instruction::BinaryOps op) {
    llvm::Value * lhs = ins->getOperand(0);
    llvm::Value * rhs = ins->getOperand(1);
    AType * lhsType = state().get(lhs);
    AType * rhsType = state().get(rhs);
    if (lhsType->isDouble() and rhsType->isDouble()) {
        return doubleArithmetic(lhs, rhs, lhsType, rhsType, op);
    }
    return false;
}
Esempio n. 2
0
bool Unboxing::genericRelational(llvm::CmpInst::Predicate op) {
    llvm::Value * lhs = ins->getOperand(0);
    llvm::Value * rhs = ins->getOperand(1);
    AType * lhsType = state().get(lhs);
    AType * rhsType = state().get(rhs);
    if (lhsType->isDouble() and rhsType->isDouble()) {
        return doubleRelational(lhs, rhs, lhsType, rhsType, op);
    }

    return false;
}
Esempio n. 3
0
void TypeAnalysis::genericGetElement(CallInst * ci) {
    AType * from = state.get(ci->getOperand(0));
    AType * index = state.get(ci->getOperand(1));
    if (from->isDouble()) {
        if (index->isDoubleScalar()) {
            state.update(ci, AType::D1);
        } else {
            state.update(ci, AType::DV);
        }
    } else if (from->isCharacter()) {
        state.update(ci, AType::CV);
    } else {
        state.update(ci, AType::T);
    }
}
Esempio n. 4
0
bool Unboxing::genericGetElement() {
    llvm::Value * src = ins->getOperand(0);
    llvm::Value * idx = ins->getOperand(1);
    AType * srcType = state().get(src);
    AType * idxType = state().get(idx);

    if (srcType->isDouble()) {
        src = CastInst::CreatePointerCast(src, type::ptrDoubleVector, "", ins); 
        if (idxType->isDoubleScalar()) {
            llvm::Value * i = state().getMetadata(idx);
            if (i) {
                llvm::Value * res = RUNTIME_CALL(m->doubleGetSingleElement, src, i);
                updateDoubleScalar(res);
                return true;
            }
        }
    }
    return false;
}