IG = NULL;
Size = 0;
if( DEBUG_RA) {
- cout << "Interference graph created!" << endl;
+ cerr << "Interference graph created!" << endl;
}
}
char *val;
if( DEBUG_RA > 1)
- cout << "setting intf for: [" << row << "][" << col << "]" << endl;
+ cerr << "setting intf for: [" << row << "][" << col << "]" << endl;
( row > col) ? val = &IG[row][col]: val = &IG[col][row];
assertIGNode( SrcNode );
if( DEBUG_RA > 1) {
- cout << "Merging LRs: \""; LR1->printSet();
- cout << "\" and \""; LR2->printSet();
- cout << "\"" << endl;
+ cerr << "Merging LRs: \""; LR1->printSet();
+ cerr << "\" and \""; LR2->printSet();
+ cerr << "\"" << endl;
}
unsigned SrcDegree = SrcNode->getNumOfNeighbors();
setInterference(LR1, LROfNeigh );
}
- //cout<< " #Neighs - Neigh: ["<< NeighNode->getIndex()<< "] ";
- //cout << NeighNode->getNumOfNeighbors();
- //cout << " Dest: [" << DestNode->getIndex() << "] ";
- //cout << DestNode->getNumOfNeighbors() << endl;
+ //cerr<< " #Neighs - Neigh: ["<< NeighNode->getIndex()<< "] ";
+ //cerr << NeighNode->getNumOfNeighbors();
+ //cerr << " Dest: [" << DestNode->getIndex() << "] ";
+ //cerr << DestNode->getNumOfNeighbors() << endl;
}
if( ! Node )
continue; // skip empty rows
- cout << " [" << i << "] ";
+ cerr << " [" << i << "] ";
for( unsigned int j=0; j < Size; j++) {
if( j >= i) break;
- if( IG[i][j] ) cout << "(" << i << "," << j << ") ";
+ if( IG[i][j] ) cerr << "(" << i << "," << j << ") ";
}
- cout << endl;
+ cerr << endl;
}
}
if( ! Node )
continue;
- cout << " [" << Node->getIndex() << "] ";
+ cerr << " [" << Node->getIndex() << "] ";
(Node->getParentLR())->printSet();
//int Deg = Node->getCurDegree();
- cout << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl;
+ cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl;
}
}
{
if( DEBUG_RA)
- cout << "Consturcting Live Ranges ..." << endl;
+ cerr << "Consturcting Live Ranges ..." << endl;
// first find the live ranges for all incoming args of the method since
// those LRs start from the start of the method
if( DEBUG_RA > 1) {
- cout << " adding LiveRange for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " adding LiveRange for argument ";
+ printValue( (const Value *) *ArgIt); cerr << endl;
}
}
OpI.getMachineOperand().getOperandType();
if ( OpTyp == MachineOperand::MO_CCRegister) {
- cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
+ cerr << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
printValue( OpI.getMachineOperand().getVRegValue() );
- cout << endl;
+ cerr << endl;
}
}
// Only instruction values are accepted for live ranges here
if( Def->getValueType() != Value::InstructionVal ) {
- cout << "\n**%%Error: Def is not an instruction val. Def=";
- printValue( Def ); cout << endl;
+ cerr << "\n**%%Error: Def is not an instruction val. Def=";
+ printValue( Def ); cerr << endl;
continue;
}
LiveRangeMap[ Def ] = DefRange; // update the map
if( DEBUG_RA > 1) {
- cout << " creating a LR for def: ";
- printValue(Def); cout << endl;
+ cerr << " creating a LR for def: ";
+ printValue(Def); cerr << endl;
}
// set the register class of the new live range
if(isCC && DEBUG_RA) {
- cout << "\a**created a LR for a CC reg:";
+ cerr << "\a**created a LR for a CC reg:";
printValue( OpI.getMachineOperand().getVRegValue() );
}
LiveRangeMap[ Def ] = DefRange;
if( DEBUG_RA > 1) {
- cout << " added to an existing LR for def: ";
- printValue( Def ); cout << endl;
+ cerr << " added to an existing LR for def: ";
+ printValue( Def ); cerr << endl;
}
}
suggestRegs4CallRets();
if( DEBUG_RA)
- cout << "Initial Live Ranges constructed!" << endl;
+ cerr << "Initial Live Ranges constructed!" << endl;
}
*/
if( DEBUG_RA)
- cout << endl << "Coalscing LRs ..." << endl;
+ cerr << endl << "Coalscing LRs ..." << endl;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
const MachineInstr * MInst = *MInstIterator;
if( DEBUG_RA > 1) {
- cout << " *Iterating over machine instr ";
+ cerr << " *Iterating over machine instr ";
MInst->dump();
- cout << endl;
+ cerr << endl;
}
//don't warn about labels
if (!((*UseI)->getType())->isLabelType() && DEBUG_RA) {
- cout<<" !! Warning: No LR for use "; printValue(*UseI);
- cout << endl;
+ cerr<<" !! Warning: No LR for use "; printValue(*UseI);
+ cerr << endl;
}
continue; // ignore and continue
}
} // for all BBs
if( DEBUG_RA)
- cout << endl << "Coalscing Done!" << endl;
+ cerr << endl << "Coalscing Done!" << endl;
}
void LiveRangeInfo::printLiveRanges()
{
LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator
- cout << endl << "Printing Live Ranges from Hash Map:" << endl;
+ cerr << endl << "Printing Live Ranges from Hash Map:" << endl;
for( ; HMI != LiveRangeMap.end() ; HMI ++ ) {
if( (*HMI).first && (*HMI).second ) {
- cout <<" "; printValue((*HMI).first); cout << "\t: ";
- ((*HMI).second)->printSet(); cout << endl;
+ cerr <<" "; printValue((*HMI).first); cerr << "\t: ";
+ ((*HMI).second)->printSet(); cerr << endl;
}
}
}
void PhyRegAlloc::createIGNodeListsAndIGs()
{
- if(DEBUG_RA ) cout << "Creating LR lists ..." << endl;
+ if(DEBUG_RA ) cerr << "Creating LR lists ..." << endl;
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
if( !L) {
if( DEBUG_RA) {
- cout << "\n*?!?Warning: Null liver range found for: ";
- printValue( (*HMI).first) ; cout << endl;
+ cerr << "\n*?!?Warning: Null liver range found for: ";
+ printValue( (*HMI).first) ; cerr << endl;
}
continue;
}
RegClassList[ rc ]->createInterferenceGraph();
if( DEBUG_RA)
- cout << "LRLists Created!" << endl;
+ cerr << "LRLists Created!" << endl;
}
for( ; LIt != LVSet->end(); ++LIt) {
if( DEBUG_RA > 1) {
- cout << "< Def="; printValue(Def);
- cout << ", Lvar="; printValue( *LIt); cout << "> ";
+ cerr << "< Def="; printValue(Def);
+ cerr << ", Lvar="; printValue( *LIt); cerr << "> ";
}
// get the live range corresponding to live var
else if(DEBUG_RA > 1) {
// we will not have LRs for values not explicitly allocated in the
// instruction stream (e.g., constants)
- cout << " warning: no live range for " ;
- printValue( *LIt); cout << endl; }
+ cerr << " warning: no live range for " ;
+ printValue( *LIt); cerr << endl; }
}
void PhyRegAlloc::buildInterferenceGraphs()
{
- if(DEBUG_RA) cout << "Creating interference graphs ..." << endl;
+ if(DEBUG_RA) cerr << "Creating interference graphs ..." << endl;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
addInterferencesForArgs(); // add interference for method args
if( DEBUG_RA)
- cout << "Interference graphs calculted!" << endl;
+ cerr << "Interference graphs calculted!" << endl;
}
addInterference( *ArgIt, InSet, false ); // add interferences between
// args and LVars at start
if( DEBUG_RA > 1) {
- cout << " - %% adding interference for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " - %% adding interference for argument ";
+ printValue( (const Value *) *ArgIt); cerr << endl;
}
}
}
PushedRegSet.insert( Reg );
StackOff += 4; // ****TODO: Correct ??????
- cout << "Inserted caller saving instr");
+ cerr << "Inserted caller saving instr");
} // if not already pushed
for( AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt ) {
- cout << "*ADDED instr opcode: ";
- cout << TargetInstrDescriptors[(*AdIt)->getOpCode()].opCodeString;
- cout << endl;
+ cerr << "*ADDED instr opcode: ";
+ cerr << TargetInstrDescriptors[(*AdIt)->getOpCode()].opCodeString;
+ cerr << endl;
MInstIterator = MIVec.insert( MInstIterator, *AdIt );
++MInstIterator;
// delete this condition checking later (must assert if Val is null)
if( !Val) {
if (DEBUG_RA)
- cout << "Warning: NULL Value found for operand" << endl;
+ cerr << "Warning: NULL Value found for operand" << endl;
continue;
}
assert( Val && "Value is NULL");
// nothing to worry if it's a const or a label
if (DEBUG_RA) {
- cout << "*NO LR for inst opcode: ";
- cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
+ cerr << "*NO LR for inst opcode: ";
+ cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
}
if( Op.getAllocatedRegNum() == -1)
//TM.getInstrInfo().isReturn(MInst->getOpCode())
else if(TM.getInstrInfo().isReturn(MInst->getOpCode()) ) {
- if (DEBUG_RA) cout << endl << "RETURN found" << endl;
+ if (DEBUG_RA) cerr << endl << "RETURN found" << endl;
Op.setRegForValue( MRI.getReturnAddressReg() );
}
if (Val->getValueType() == Value::InstructionVal)
{
- cout << "!Warning: No LiveRange for: ";
- printValue( Val); cout << " Type: " << Val->getValueType();
- cout << " RegVal=" << Op.getAllocatedRegNum() << endl;
+ cerr << "!Warning: No LiveRange for: ";
+ printValue( Val); cerr << " Type: " << Val->getValueType();
+ cerr << " RegVal=" << Op.getAllocatedRegNum() << endl;
}
#endif
void PhyRegAlloc::printMachineCode()
{
- cout << endl << ";************** Method ";
- cout << Meth->getName() << " *****************" << endl;
+ cerr << endl << ";************** Method ";
+ cerr << Meth->getName() << " *****************" << endl;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
for( ; BBI != Meth->end(); ++BBI) { // traverse BBs in random order
- cout << endl ; printLabel( *BBI); cout << ": ";
+ cerr << endl ; printLabel( *BBI); cerr << ": ";
// get the iterator for machine instructions
MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
MachineInstr *const MInst = *MInstIterator;
- cout << endl << "\t";
- cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
+ cerr << endl << "\t";
+ cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
//for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
const Value *const Val = Op.getVRegValue () ;
// ****this code is temporary till NULL Values are fixed
if( ! Val ) {
- cout << "\t<*NULL*>";
+ cerr << "\t<*NULL*>";
continue;
}
// if a label or a constant
if( (Val->getValueType() == Value::BasicBlockVal) ) {
- cout << "\t"; printLabel( Op.getVRegValue () );
+ cerr << "\t"; printLabel( Op.getVRegValue () );
}
else {
// else it must be a register value
//if( RegNum != 1000)
- cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
- // else cout << "\t<*NoReg*>";
+ cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
+ // else cerr << "\t<*NoReg*>";
}
}
else if(Op.getOperandType() == MachineOperand::MO_MachineRegister) {
- cout << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
+ cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
}
else
- cout << "\t" << Op; // use dump field
+ cerr << "\t" << Op; // use dump field
}
}
- cout << endl;
+ cerr << endl;
}
- cout << endl;
+ cerr << endl;
}
void PhyRegAlloc::printLabel(const Value *const Val)
{
if( Val->hasName() )
- cout << Val->getName();
+ cerr << Val->getName();
else
- cout << "Label" << Val;
+ cerr << "Label" << Val;
}
IG(this), IGNodeStack(), ReservedColorList(RCL)
{
if( DEBUG_RA)
- cout << "Created Reg Class: " << RegClassID << endl;
+ cerr << "Created Reg Class: " << RegClassID << endl;
// This constructor inits IG. The actual matrix is created by a call to
// createInterferenceGraph() above.
void RegClass::colorAllRegs()
{
- if(DEBUG_RA) cout << "Coloring IGs ..." << endl;
+ if(DEBUG_RA) cerr << "Coloring IGs ..." << endl;
//preColorIGNodes(); // pre-color IGNodes
pushAllIGNodes(); // push all IG Nodes
bool PushedAll = pushUnconstrainedIGNodes();
if( DEBUG_RA) {
- cout << " Puhsed all-unconstrained IGNodes. ";
- if( PushedAll ) cout << " No constrained nodes left.";
- cout << endl;
+ cerr << " Puhsed all-unconstrained IGNodes. ";
+ if( PushedAll ) cerr << " No constrained nodes left.";
+ cerr << endl;
}
if( PushedAll ) // if NO constrained nodes left
IGNode->pushOnStack(); // set OnStack and dec deg of neighs
if (DEBUG_RA > 1) {
- cout << " pushed un-constrained IGNode " << IGNode->getIndex() ;
- cout << " on to stack" << endl;
+ cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ;
+ cerr << " on to stack" << endl;
}
}
else pushedall = false; // we didn't push all live ranges
}
else {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " already colored with color " << Node->getColor() << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " already colored with color " << Node->getColor() << endl;
}
}
if( !Node->hasColor() ) {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " - could not find a color (needs spilling)" << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " - could not find a color (needs spilling)" << endl;
}
}
IG = NULL;
Size = 0;
if( DEBUG_RA) {
- cout << "Interference graph created!" << endl;
+ cerr << "Interference graph created!" << endl;
}
}
char *val;
if( DEBUG_RA > 1)
- cout << "setting intf for: [" << row << "][" << col << "]" << endl;
+ cerr << "setting intf for: [" << row << "][" << col << "]" << endl;
( row > col) ? val = &IG[row][col]: val = &IG[col][row];
assertIGNode( SrcNode );
if( DEBUG_RA > 1) {
- cout << "Merging LRs: \""; LR1->printSet();
- cout << "\" and \""; LR2->printSet();
- cout << "\"" << endl;
+ cerr << "Merging LRs: \""; LR1->printSet();
+ cerr << "\" and \""; LR2->printSet();
+ cerr << "\"" << endl;
}
unsigned SrcDegree = SrcNode->getNumOfNeighbors();
setInterference(LR1, LROfNeigh );
}
- //cout<< " #Neighs - Neigh: ["<< NeighNode->getIndex()<< "] ";
- //cout << NeighNode->getNumOfNeighbors();
- //cout << " Dest: [" << DestNode->getIndex() << "] ";
- //cout << DestNode->getNumOfNeighbors() << endl;
+ //cerr<< " #Neighs - Neigh: ["<< NeighNode->getIndex()<< "] ";
+ //cerr << NeighNode->getNumOfNeighbors();
+ //cerr << " Dest: [" << DestNode->getIndex() << "] ";
+ //cerr << DestNode->getNumOfNeighbors() << endl;
}
if( ! Node )
continue; // skip empty rows
- cout << " [" << i << "] ";
+ cerr << " [" << i << "] ";
for( unsigned int j=0; j < Size; j++) {
if( j >= i) break;
- if( IG[i][j] ) cout << "(" << i << "," << j << ") ";
+ if( IG[i][j] ) cerr << "(" << i << "," << j << ") ";
}
- cout << endl;
+ cerr << endl;
}
}
if( ! Node )
continue;
- cout << " [" << Node->getIndex() << "] ";
+ cerr << " [" << Node->getIndex() << "] ";
(Node->getParentLR())->printSet();
//int Deg = Node->getCurDegree();
- cout << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl;
+ cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl;
}
}
{
if( DEBUG_RA)
- cout << "Consturcting Live Ranges ..." << endl;
+ cerr << "Consturcting Live Ranges ..." << endl;
// first find the live ranges for all incoming args of the method since
// those LRs start from the start of the method
if( DEBUG_RA > 1) {
- cout << " adding LiveRange for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " adding LiveRange for argument ";
+ printValue( (const Value *) *ArgIt); cerr << endl;
}
}
OpI.getMachineOperand().getOperandType();
if ( OpTyp == MachineOperand::MO_CCRegister) {
- cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
+ cerr << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
printValue( OpI.getMachineOperand().getVRegValue() );
- cout << endl;
+ cerr << endl;
}
}
// Only instruction values are accepted for live ranges here
if( Def->getValueType() != Value::InstructionVal ) {
- cout << "\n**%%Error: Def is not an instruction val. Def=";
- printValue( Def ); cout << endl;
+ cerr << "\n**%%Error: Def is not an instruction val. Def=";
+ printValue( Def ); cerr << endl;
continue;
}
LiveRangeMap[ Def ] = DefRange; // update the map
if( DEBUG_RA > 1) {
- cout << " creating a LR for def: ";
- printValue(Def); cout << endl;
+ cerr << " creating a LR for def: ";
+ printValue(Def); cerr << endl;
}
// set the register class of the new live range
if(isCC && DEBUG_RA) {
- cout << "\a**created a LR for a CC reg:";
+ cerr << "\a**created a LR for a CC reg:";
printValue( OpI.getMachineOperand().getVRegValue() );
}
LiveRangeMap[ Def ] = DefRange;
if( DEBUG_RA > 1) {
- cout << " added to an existing LR for def: ";
- printValue( Def ); cout << endl;
+ cerr << " added to an existing LR for def: ";
+ printValue( Def ); cerr << endl;
}
}
suggestRegs4CallRets();
if( DEBUG_RA)
- cout << "Initial Live Ranges constructed!" << endl;
+ cerr << "Initial Live Ranges constructed!" << endl;
}
*/
if( DEBUG_RA)
- cout << endl << "Coalscing LRs ..." << endl;
+ cerr << endl << "Coalscing LRs ..." << endl;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
const MachineInstr * MInst = *MInstIterator;
if( DEBUG_RA > 1) {
- cout << " *Iterating over machine instr ";
+ cerr << " *Iterating over machine instr ";
MInst->dump();
- cout << endl;
+ cerr << endl;
}
//don't warn about labels
if (!((*UseI)->getType())->isLabelType() && DEBUG_RA) {
- cout<<" !! Warning: No LR for use "; printValue(*UseI);
- cout << endl;
+ cerr<<" !! Warning: No LR for use "; printValue(*UseI);
+ cerr << endl;
}
continue; // ignore and continue
}
} // for all BBs
if( DEBUG_RA)
- cout << endl << "Coalscing Done!" << endl;
+ cerr << endl << "Coalscing Done!" << endl;
}
void LiveRangeInfo::printLiveRanges()
{
LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator
- cout << endl << "Printing Live Ranges from Hash Map:" << endl;
+ cerr << endl << "Printing Live Ranges from Hash Map:" << endl;
for( ; HMI != LiveRangeMap.end() ; HMI ++ ) {
if( (*HMI).first && (*HMI).second ) {
- cout <<" "; printValue((*HMI).first); cout << "\t: ";
- ((*HMI).second)->printSet(); cout << endl;
+ cerr <<" "; printValue((*HMI).first); cerr << "\t: ";
+ ((*HMI).second)->printSet(); cerr << endl;
}
}
}
void PhyRegAlloc::createIGNodeListsAndIGs()
{
- if(DEBUG_RA ) cout << "Creating LR lists ..." << endl;
+ if(DEBUG_RA ) cerr << "Creating LR lists ..." << endl;
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
if( !L) {
if( DEBUG_RA) {
- cout << "\n*?!?Warning: Null liver range found for: ";
- printValue( (*HMI).first) ; cout << endl;
+ cerr << "\n*?!?Warning: Null liver range found for: ";
+ printValue( (*HMI).first) ; cerr << endl;
}
continue;
}
RegClassList[ rc ]->createInterferenceGraph();
if( DEBUG_RA)
- cout << "LRLists Created!" << endl;
+ cerr << "LRLists Created!" << endl;
}
for( ; LIt != LVSet->end(); ++LIt) {
if( DEBUG_RA > 1) {
- cout << "< Def="; printValue(Def);
- cout << ", Lvar="; printValue( *LIt); cout << "> ";
+ cerr << "< Def="; printValue(Def);
+ cerr << ", Lvar="; printValue( *LIt); cerr << "> ";
}
// get the live range corresponding to live var
else if(DEBUG_RA > 1) {
// we will not have LRs for values not explicitly allocated in the
// instruction stream (e.g., constants)
- cout << " warning: no live range for " ;
- printValue( *LIt); cout << endl; }
+ cerr << " warning: no live range for " ;
+ printValue( *LIt); cerr << endl; }
}
void PhyRegAlloc::buildInterferenceGraphs()
{
- if(DEBUG_RA) cout << "Creating interference graphs ..." << endl;
+ if(DEBUG_RA) cerr << "Creating interference graphs ..." << endl;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
addInterferencesForArgs(); // add interference for method args
if( DEBUG_RA)
- cout << "Interference graphs calculted!" << endl;
+ cerr << "Interference graphs calculted!" << endl;
}
addInterference( *ArgIt, InSet, false ); // add interferences between
// args and LVars at start
if( DEBUG_RA > 1) {
- cout << " - %% adding interference for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " - %% adding interference for argument ";
+ printValue( (const Value *) *ArgIt); cerr << endl;
}
}
}
PushedRegSet.insert( Reg );
StackOff += 4; // ****TODO: Correct ??????
- cout << "Inserted caller saving instr");
+ cerr << "Inserted caller saving instr");
} // if not already pushed
for( AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt ) {
- cout << "*ADDED instr opcode: ";
- cout << TargetInstrDescriptors[(*AdIt)->getOpCode()].opCodeString;
- cout << endl;
+ cerr << "*ADDED instr opcode: ";
+ cerr << TargetInstrDescriptors[(*AdIt)->getOpCode()].opCodeString;
+ cerr << endl;
MInstIterator = MIVec.insert( MInstIterator, *AdIt );
++MInstIterator;
// delete this condition checking later (must assert if Val is null)
if( !Val) {
if (DEBUG_RA)
- cout << "Warning: NULL Value found for operand" << endl;
+ cerr << "Warning: NULL Value found for operand" << endl;
continue;
}
assert( Val && "Value is NULL");
// nothing to worry if it's a const or a label
if (DEBUG_RA) {
- cout << "*NO LR for inst opcode: ";
- cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
+ cerr << "*NO LR for inst opcode: ";
+ cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
}
if( Op.getAllocatedRegNum() == -1)
//TM.getInstrInfo().isReturn(MInst->getOpCode())
else if(TM.getInstrInfo().isReturn(MInst->getOpCode()) ) {
- if (DEBUG_RA) cout << endl << "RETURN found" << endl;
+ if (DEBUG_RA) cerr << endl << "RETURN found" << endl;
Op.setRegForValue( MRI.getReturnAddressReg() );
}
if (Val->getValueType() == Value::InstructionVal)
{
- cout << "!Warning: No LiveRange for: ";
- printValue( Val); cout << " Type: " << Val->getValueType();
- cout << " RegVal=" << Op.getAllocatedRegNum() << endl;
+ cerr << "!Warning: No LiveRange for: ";
+ printValue( Val); cerr << " Type: " << Val->getValueType();
+ cerr << " RegVal=" << Op.getAllocatedRegNum() << endl;
}
#endif
void PhyRegAlloc::printMachineCode()
{
- cout << endl << ";************** Method ";
- cout << Meth->getName() << " *****************" << endl;
+ cerr << endl << ";************** Method ";
+ cerr << Meth->getName() << " *****************" << endl;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
for( ; BBI != Meth->end(); ++BBI) { // traverse BBs in random order
- cout << endl ; printLabel( *BBI); cout << ": ";
+ cerr << endl ; printLabel( *BBI); cerr << ": ";
// get the iterator for machine instructions
MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
MachineInstr *const MInst = *MInstIterator;
- cout << endl << "\t";
- cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
+ cerr << endl << "\t";
+ cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
//for(MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done();++OpI) {
const Value *const Val = Op.getVRegValue () ;
// ****this code is temporary till NULL Values are fixed
if( ! Val ) {
- cout << "\t<*NULL*>";
+ cerr << "\t<*NULL*>";
continue;
}
// if a label or a constant
if( (Val->getValueType() == Value::BasicBlockVal) ) {
- cout << "\t"; printLabel( Op.getVRegValue () );
+ cerr << "\t"; printLabel( Op.getVRegValue () );
}
else {
// else it must be a register value
//if( RegNum != 1000)
- cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
- // else cout << "\t<*NoReg*>";
+ cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
+ // else cerr << "\t<*NoReg*>";
}
}
else if(Op.getOperandType() == MachineOperand::MO_MachineRegister) {
- cout << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
+ cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
}
else
- cout << "\t" << Op; // use dump field
+ cerr << "\t" << Op; // use dump field
}
}
- cout << endl;
+ cerr << endl;
}
- cout << endl;
+ cerr << endl;
}
void PhyRegAlloc::printLabel(const Value *const Val)
{
if( Val->hasName() )
- cout << Val->getName();
+ cerr << Val->getName();
else
- cout << "Label" << Val;
+ cerr << "Label" << Val;
}
IG(this), IGNodeStack(), ReservedColorList(RCL)
{
if( DEBUG_RA)
- cout << "Created Reg Class: " << RegClassID << endl;
+ cerr << "Created Reg Class: " << RegClassID << endl;
// This constructor inits IG. The actual matrix is created by a call to
// createInterferenceGraph() above.
void RegClass::colorAllRegs()
{
- if(DEBUG_RA) cout << "Coloring IGs ..." << endl;
+ if(DEBUG_RA) cerr << "Coloring IGs ..." << endl;
//preColorIGNodes(); // pre-color IGNodes
pushAllIGNodes(); // push all IG Nodes
bool PushedAll = pushUnconstrainedIGNodes();
if( DEBUG_RA) {
- cout << " Puhsed all-unconstrained IGNodes. ";
- if( PushedAll ) cout << " No constrained nodes left.";
- cout << endl;
+ cerr << " Puhsed all-unconstrained IGNodes. ";
+ if( PushedAll ) cerr << " No constrained nodes left.";
+ cerr << endl;
}
if( PushedAll ) // if NO constrained nodes left
IGNode->pushOnStack(); // set OnStack and dec deg of neighs
if (DEBUG_RA > 1) {
- cout << " pushed un-constrained IGNode " << IGNode->getIndex() ;
- cout << " on to stack" << endl;
+ cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ;
+ cerr << " on to stack" << endl;
}
}
else pushedall = false; // we didn't push all live ranges
}
else {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " already colored with color " << Node->getColor() << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " already colored with color " << Node->getColor() << endl;
}
}
if( !Node->hasColor() ) {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " - could not find a color (needs spilling)" << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " - could not find a color (needs spilling)" << endl;
}
}
else if( ty <= Type::DoubleTyID)
res = FloatRegClassID; // sparc float reg class
else {
- cout << "TypeID: " << ty << endl;
+ cerr << "TypeID: " << ty << endl;
assert(0 && "Cannot resolve register class for type");
-
}
if(isCCReg)
return res + 2; // corresponidng condition code regiser
-
else
return res;
-
}
// returns the register tha contains always zero
return;
}
else { // can't allocate the suggested col
- cout << " Coud NOT allocate the suggested color for LR ";
- LR->printSet(); cout << endl;
+ cerr << " Could NOT allocate the suggested color for LR ";
+ LR->printSet(); cerr << endl;
}
}
return;
}
else { // can't allocate the suggested col
- cout << " Coud NOT allocate the suggested color for LR ";
- LR->printSet(); cout << endl;
+ cerr << " Could NOT allocate the suggested color for LR ";
+ LR->printSet(); cerr << endl;
}
}
else {
// Do NOTHING as this will be colored as a normal value.
- if (DEBUG_RA) cout << " Int Regr not suggested for method arg\n";
+ if (DEBUG_RA) cerr << " Int Regr not suggested for method arg\n";
}
}
// must be defined before
if( !LR ) {
if( DEBUG_RA) {
- cout << " ERROR: In call instr, no LR for arg: " ;
- printValue(CallArg); cout << endl;
+ cerr << " ERROR: In call instr, no LR for arg: " ;
+ printValue(CallArg); cerr << endl;
}
assert(0 && "NO LR for call arg");
// continue;
else if (DEBUG_RA)
// Do NOTHING as this will be colored as a normal value.
- cout << " Regr not suggested for int call arg" << endl;
+ cerr << " Regr not suggested for int call arg" << endl;
}
else if( RegType == FPSingleRegType && (argNo*2 +1)< NumOfFloatArgRegs)
LiveRange * RetValLR = LRI.getLiveRangeForValue( RetVal );
if( !RetValLR ) {
- cout << "\nNo LR for:";
+ cerr << "\nNo LR for:";
printValue( RetVal );
- cout << endl;
+ cerr << endl;
assert( RetValLR && "ERR:No LR for non-void return value");
//return;
}
// must be defined before
if( !LR ) {
if( DEBUG_RA) {
- cout << " ERROR: In call instr, no LR for arg: " ;
- printValue(CallArg); cout << endl;
+ cerr << " ERROR: In call instr, no LR for arg: " ;
+ printValue(CallArg); cerr << endl;
}
assert(0 && "NO LR for call arg");
// continue;
LiveRange *const LR = LRI.getLiveRangeForValue( RetVal );
if( !LR ) {
- cout << "\nNo LR for:";
+ cerr << "\nNo LR for:";
printValue( RetVal );
- cout << endl;
+ cerr << endl;
assert( LR && "No LR for return value of non-void method");
//return;
}
LiveRange *const LR = LRI.getLiveRangeForValue( RetVal );
if( ! LR ) {
- cout << "\nNo LR for:";
+ cerr << "\nNo LR for:";
printValue( RetVal );
- cout << endl;
+ cerr << endl;
// assert( LR && "No LR for return value of non-void method");
return;
}
break;
default:
- cout << "Value Type: " << Val->getValueType() << endl;
+ cerr << "Value Type: " << Val->getValueType() << endl;
assert(0 && "Unknown val type - Only constants/globals/labels are valid");
}
unsigned RegClassID = (LR->getRegClass())->getID();
- cout << " *Node " << (LR->getUserIGNode())->getIndex();
+ cerr << " *Node " << (LR->getUserIGNode())->getIndex();
if( ! LR->hasColor() ) {
- cout << " - could not find a color" << endl;
+ cerr << " - could not find a color" << endl;
return;
}
// if a color is found
- cout << " colored with color "<< LR->getColor();
+ cerr << " colored with color "<< LR->getColor();
if( RegClassID == IntRegClassID ) {
- cout<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) ;
- cout << "]" << endl;
+ cerr<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) ;
+ cerr << "]" << endl;
}
else if ( RegClassID == FloatRegClassID) {
- cout << "[" << SparcFloatRegOrder::getRegName(LR->getColor());
+ cerr << "[" << SparcFloatRegOrder::getRegName(LR->getColor());
if( LR->getTypeID() == Type::DoubleTyID )
- cout << "+" << SparcFloatRegOrder::getRegName(LR->getColor()+1);
- cout << "]" << endl;
+ cerr << "+" << SparcFloatRegOrder::getRegName(LR->getColor()+1);
+ cerr << "]" << endl;
}
-
-
}
-
-
-
-
-
return;
if( DEBUG_RA ) {
- cout << endl << "******************** Method "<< (M)->getName();
- cout << " ********************" <<endl;
+ cerr << endl << "******************** Method "<< (M)->getName();
+ cerr << " ********************" <<endl;
}
MethodLiveVarInfo LVI(M ); // Analyze live varaibles
PRA.allocateRegisters();
- if( DEBUG_RA ) cout << endl << "Register allocation complete!" << endl;
+ if( DEBUG_RA ) cerr << endl << "Register allocation complete!" << endl;
}