MachineInstr* in vector are not const (and never really were)
authorVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 8 Jul 2002 23:07:26 +0000 (23:07 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 8 Jul 2002 23:07:26 +0000 (23:07 +0000)
because operands may be modified directly to set register.
Also, class MachineCodeForBasicBlock is now an annotation on BasicBlock.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2832 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp

index 4bbd36f635fcadb592285242b2ec0a8e0be3cded..6a992b1ee354ca8614070aaf798342e025d3c601 100644 (file)
@@ -1,6 +1,7 @@
 #include "llvm/CodeGen/LiveRangeInfo.h"
 #include "llvm/CodeGen/RegClass.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
@@ -107,19 +108,19 @@ void LiveRangeInfo::constructLiveRanges() {
   // Now find speical LLVM instructions (CALL, RET) and LRs in machine
   // instructions.
   //
-  for (Function::const_iterator BBI = Meth->begin(); BBI != Meth->end(); ++BBI){
+  for (Function::const_iterator BBI=Meth->begin(); BBI != Meth->end(); ++BBI){
     // Now find all LRs for machine the instructions. A new LR will be created 
     // only for defs in the machine instr since, we assume that all Values are
     // defined before they are used. However, there can be multiple defs for
     // the same Value in machine instructions.
 
     // get the iterator for machine instructions
-    const MachineCodeForBasicBlock& MIVec = BBI->getMachineInstrVec();
-
+    MachineCodeForBasicBlock& MIVec = MachineCodeForBasicBlock::get(BBI);
+    
     // iterate over all the machine instructions in BB
-    for(MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
+    for(MachineCodeForBasicBlock::iterator MInstIterator = MIVec.begin();
         MInstIterator != MIVec.end(); ++MInstIterator) {  
-      const MachineInstr *MInst = *MInstIterator; 
+      MachineInstr *MInst = *MInstIterator; 
 
       // Now if the machine instruction is a  call/return instruction,
       // add it to CallRetInstrList for processing its implicit operands
@@ -130,7 +131,7 @@ void LiveRangeInfo::constructLiveRanges() {
  
              
       // iterate over  MI operands to find defs
-      for (MachineInstr::const_val_op_iterator OpI = MInst->begin(),
+      for (MachineInstr::val_op_iterator OpI = MInst->begin(),
              OpE = MInst->end(); OpI != OpE; ++OpI) {
        if(DEBUG_RA) {
          MachineOperand::MachineOperandType OpTyp = 
@@ -220,10 +221,10 @@ void LiveRangeInfo::constructLiveRanges() {
 //---------------------------------------------------------------------------
 void LiveRangeInfo::suggestRegs4CallRets()
 {
-  CallRetInstrListType::const_iterator It =  CallRetInstrList.begin();
+  CallRetInstrListType::iterator It =  CallRetInstrList.begin();
   for( ; It !=  CallRetInstrList.end(); ++It ) {
 
-    const MachineInstr *MInst = *It;
+    MachineInstr *MInst = *It;
     MachineOpCode OpCode =  MInst->getOpCode();
 
     if( (TM.getInstrInfo()).isReturn(OpCode)  )
@@ -266,7 +267,7 @@ void LiveRangeInfo::coalesceLRs()
       BBI != BBE; ++BBI) {
 
     // get the iterator for machine instructions
-    const MachineCodeForBasicBlock& MIVec = BBI->getMachineInstrVec();
+    const MachineCodeForBasicBlock& MIVec = MachineCodeForBasicBlock::get(BBI);
     MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
 
     // iterate over all the machine instructions in BB
index 4bbd36f635fcadb592285242b2ec0a8e0be3cded..6a992b1ee354ca8614070aaf798342e025d3c601 100644 (file)
@@ -1,6 +1,7 @@
 #include "llvm/CodeGen/LiveRangeInfo.h"
 #include "llvm/CodeGen/RegClass.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
@@ -107,19 +108,19 @@ void LiveRangeInfo::constructLiveRanges() {
   // Now find speical LLVM instructions (CALL, RET) and LRs in machine
   // instructions.
   //
-  for (Function::const_iterator BBI = Meth->begin(); BBI != Meth->end(); ++BBI){
+  for (Function::const_iterator BBI=Meth->begin(); BBI != Meth->end(); ++BBI){
     // Now find all LRs for machine the instructions. A new LR will be created 
     // only for defs in the machine instr since, we assume that all Values are
     // defined before they are used. However, there can be multiple defs for
     // the same Value in machine instructions.
 
     // get the iterator for machine instructions
-    const MachineCodeForBasicBlock& MIVec = BBI->getMachineInstrVec();
-
+    MachineCodeForBasicBlock& MIVec = MachineCodeForBasicBlock::get(BBI);
+    
     // iterate over all the machine instructions in BB
-    for(MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
+    for(MachineCodeForBasicBlock::iterator MInstIterator = MIVec.begin();
         MInstIterator != MIVec.end(); ++MInstIterator) {  
-      const MachineInstr *MInst = *MInstIterator; 
+      MachineInstr *MInst = *MInstIterator; 
 
       // Now if the machine instruction is a  call/return instruction,
       // add it to CallRetInstrList for processing its implicit operands
@@ -130,7 +131,7 @@ void LiveRangeInfo::constructLiveRanges() {
  
              
       // iterate over  MI operands to find defs
-      for (MachineInstr::const_val_op_iterator OpI = MInst->begin(),
+      for (MachineInstr::val_op_iterator OpI = MInst->begin(),
              OpE = MInst->end(); OpI != OpE; ++OpI) {
        if(DEBUG_RA) {
          MachineOperand::MachineOperandType OpTyp = 
@@ -220,10 +221,10 @@ void LiveRangeInfo::constructLiveRanges() {
 //---------------------------------------------------------------------------
 void LiveRangeInfo::suggestRegs4CallRets()
 {
-  CallRetInstrListType::const_iterator It =  CallRetInstrList.begin();
+  CallRetInstrListType::iterator It =  CallRetInstrList.begin();
   for( ; It !=  CallRetInstrList.end(); ++It ) {
 
-    const MachineInstr *MInst = *It;
+    MachineInstr *MInst = *It;
     MachineOpCode OpCode =  MInst->getOpCode();
 
     if( (TM.getInstrInfo()).isReturn(OpCode)  )
@@ -266,7 +267,7 @@ void LiveRangeInfo::coalesceLRs()
       BBI != BBE; ++BBI) {
 
     // get the iterator for machine instructions
-    const MachineCodeForBasicBlock& MIVec = BBI->getMachineInstrVec();
+    const MachineCodeForBasicBlock& MIVec = MachineCodeForBasicBlock::get(BBI);
     MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
 
     // iterate over all the machine instructions in BB