コード例 #1
0
void PrologEpilogGenerator::saveRestorePreservedBr() {

    RegBitSet regMask = usedBrMask & opndManager->preservBrMask;
    if(regMask.any() == false) return;

    IPF_LOG << "    Preserved brs:";
    for(uint16 i=1; i<6; i++) {
        if(regMask[i] == false) continue;

        Opnd *storage  = newStorage(DATA_B, SITE_STACK);
        Opnd *offset   = opndManager->newImm(storage->getValue());
        Opnd *scratch  = opndManager->newRegOpnd(OPND_G_REG, DATA_B, SPILL_REG2);
        Opnd *preserv  = opndManager->newRegOpnd(OPND_B_REG, DATA_B, i);
        
        saveBrsInsts.push_back(new(mm) Inst(mm, INST_MOV, p0, scratch, preserv));
        saveBrsInsts.push_back(new(mm) Inst(mm, INST_ADDS, p0, stackAddr, offset, sp));
        saveBrsInsts.push_back(new(mm) Inst(mm, INST_ST, CMPLT_SZ_8, p0, stackAddr, scratch));

        restBrsInsts.push_back(new(mm) Inst(mm, INST_ADDS, p0, stackAddr, offset, sp));
        restBrsInsts.push_back(new(mm) Inst(mm, INST_LD, CMPLT_SZ_8, p0, scratch, stackAddr));
        restBrsInsts.push_back(new(mm) Inst(mm, INST_MOV, p0, preserv, scratch));
        IPF_LOG << " " << IrPrinter::toString(preserv);
    }
    IPF_LOG << endl;
    opndManager->savedBrMask = regMask.to_ulong();
}
コード例 #2
0
void PrologEpilogGenerator::saveRestorePreservedGr() {

    opndManager->initSavedBase();                // after this point mem local stack must contain preserved regs only
    IPF_LOG << "    Preserved register saved in memory stack with offset: " << opndManager->savedBase << endl;

    RegBitSet preservGrMask(string("11110000")); // work with r4-r7 only (not with automatic regs r32-r127)
    RegBitSet regMask = usedGrMask & preservGrMask;
    if(regMask.any() == false) return;

    IPF_LOG << "    Preserved grs:";
    for(uint16 i=4; i<8; i++) {
        if(regMask[i] == false) continue;

        Opnd *storage = newStorage(DATA_U64, SITE_STACK);
        Opnd *offset  = opndManager->newImm(storage->getValue());
        Opnd *preserv = opndManager->newRegOpnd(OPND_G_REG, DATA_U64, i);

        saveGrsInsts.push_back(new(mm) Inst(mm, INST_ADDS, p0, stackAddr, offset, sp));
        saveGrsInsts.push_back(new(mm) Inst(mm, INST_ST8_SPILL, p0, stackAddr, preserv));
        restGrsInsts.push_back(new(mm) Inst(mm, INST_ADDS, p0, stackAddr, offset, sp));
        restGrsInsts.push_back(new(mm) Inst(mm, INST_LD8_FILL, p0, preserv, stackAddr));

        IPF_LOG << " " << IrPrinter::toString(preserv);
    }
    IPF_LOG << endl;
    opndManager->savedGrMask = regMask.to_ulong();
}
コード例 #3
0
bool Opnd::isImm(int size) {

    if (isImm() == false) return false;
    
    Opnd* imm = (Opnd*) this;
    if (Opnd::isFoldableImm(imm->getValue(), size)) return true;
    return false;
}
コード例 #4
0
void PrologEpilogGenerator::saveRestorePreservedFr() {

    RegBitSet regMask = usedFrMask & opndManager->preservFrMask; 
    if(regMask.any() == false) return;

    IPF_LOG << "    Preserved frs:";
    for(uint16 i=2; i<32; i++) {
        if(regMask[i] == false) continue;

        Opnd *storage = newStorage(DATA_F, SITE_STACK);
        Opnd *offset  = opndManager->newImm(storage->getValue());
        Opnd *preserv = opndManager->newRegOpnd(OPND_F_REG, DATA_F, i);
        
        saveFrsInsts.push_back(new(mm) Inst(mm, INST_ADDS, p0, stackAddr, offset, sp));
        saveFrsInsts.push_back(new(mm) Inst(mm, INST_STF_SPILL, p0, stackAddr, preserv));
        restFrsInsts.push_back(new(mm) Inst(mm, INST_ADDS, p0, stackAddr, offset, sp));
        restFrsInsts.push_back(new(mm) Inst(mm, INST_LDF_FILL, p0, preserv, stackAddr));

        IPF_LOG << " " << IrPrinter::toString(preserv);
    }
    IPF_LOG << endl;
    opndManager->savedFrMask = regMask.to_ulong();
}