llvm.org GIT mirror llvm / 60a3c55
Don't worry about converting each function's reg. alloc. state into One Big Constant early on, because we can do it in doFinalization. Tighten up a comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9387 91177308-0d34-0410-b5e6-96231b3b80d8 Brian Gaeke 15 years ago
2 changed file(s) with 42 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
11751175 /// debug info").
11761176 ///
11771177 void PhyRegAlloc::saveState () {
1178 std::vector state;
1178 std::vector &state = FnAllocState[Fn];
11791179 unsigned Insn = 0;
11801180 LiveRangeMapType::const_iterator HMIEnd = LRI->getLiveRangeMap ()->end ();
11811181 for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II != IE; ++II)
12061206 state.push_back (AllocInfo (Insn, i, AllocState,
12071207 Placement).toConstant ());
12081208 }
1209 // Convert state into an LLVM ConstantArray, and put it in a
1210 // ConstantStruct (named S) along with its size.
1211 unsigned Size = state.size ();
1212 ArrayType *AT = ArrayType::get (AllocInfo::getConstantType (), Size);
1213 std::vector TV;
1214 TV.push_back (Type::UIntTy);
1215 TV.push_back (AT);
1216 StructType *ST = StructType::get (TV);
1217 std::vector CV;
1218 CV.push_back (ConstantUInt::get (Type::UIntTy, Size));
1219 CV.push_back (ConstantArray::get (AT, state));
1220 Constant *S = ConstantStruct::get (ST, CV);
1221 // Save S in the map containing register allocator state for this module.
1222 FnAllocState[Fn] = S;
12231209 }
12241210
12251211 /// Check the saved state filled in by saveState(), and abort if it looks
12471233 if (FnAllocState.find (F) == FnAllocState.end ()) {
12481234 allstate.push_back (ConstantPointerNull::get (PT));
12491235 } else {
1236 std::vector &state = FnAllocState[F];
1237
1238 // Convert state into an LLVM ConstantArray, and put it in a
1239 // ConstantStruct (named S) along with its size.
1240 unsigned Size = state.size ();
1241 ArrayType *AT = ArrayType::get (AllocInfo::getConstantType (), Size);
1242 std::vector TV;
1243 TV.push_back (Type::UIntTy);
1244 TV.push_back (AT);
1245 StructType *ST = StructType::get (TV);
1246 std::vector CV;
1247 CV.push_back (ConstantUInt::get (Type::UIntTy, Size));
1248 CV.push_back (ConstantArray::get (AT, state));
1249 Constant *S = ConstantStruct::get (ST, CV);
1250
12501251 GlobalVariable *GV =
1251 new GlobalVariable (FnAllocState[F]->getType (), true,
1252 GlobalValue::InternalLinkage, FnAllocState[F],
1252 new GlobalVariable (ST, true,
1253 GlobalValue::InternalLinkage, S,
12531254 F->getName () + ".regAllocState", &M);
1255
12541256 // Have: { uint, [Size x { uint, uint, uint, int }] } *
12551257 // Cast it to: { uint, [0 x { uint, uint, uint, int }] } *
12561258 Constant *CE = ConstantExpr::getCast (ConstantPointerRef::get (GV), PT);
13531355 verifySavedState ();
13541356 }
13551357
1356 // Now update the machine code with register names and add any
1357 // additional code inserted by the register allocator to the instruction
1358 // stream
1358 // Now update the machine code with register names and add any additional
1359 // code inserted by the register allocator to the instruction stream.
13591360 updateMachineCode();
13601361
13611362 if (DEBUG_RA) {
11751175 /// debug info").
11761176 ///
11771177 void PhyRegAlloc::saveState () {
1178 std::vector state;
1178 std::vector &state = FnAllocState[Fn];
11791179 unsigned Insn = 0;
11801180 LiveRangeMapType::const_iterator HMIEnd = LRI->getLiveRangeMap ()->end ();
11811181 for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II != IE; ++II)
12061206 state.push_back (AllocInfo (Insn, i, AllocState,
12071207 Placement).toConstant ());
12081208 }
1209 // Convert state into an LLVM ConstantArray, and put it in a
1210 // ConstantStruct (named S) along with its size.
1211 unsigned Size = state.size ();
1212 ArrayType *AT = ArrayType::get (AllocInfo::getConstantType (), Size);
1213 std::vector TV;
1214 TV.push_back (Type::UIntTy);
1215 TV.push_back (AT);
1216 StructType *ST = StructType::get (TV);
1217 std::vector CV;
1218 CV.push_back (ConstantUInt::get (Type::UIntTy, Size));
1219 CV.push_back (ConstantArray::get (AT, state));
1220 Constant *S = ConstantStruct::get (ST, CV);
1221 // Save S in the map containing register allocator state for this module.
1222 FnAllocState[Fn] = S;
12231209 }
12241210
12251211 /// Check the saved state filled in by saveState(), and abort if it looks
12471233 if (FnAllocState.find (F) == FnAllocState.end ()) {
12481234 allstate.push_back (ConstantPointerNull::get (PT));
12491235 } else {
1236 std::vector &state = FnAllocState[F];
1237
1238 // Convert state into an LLVM ConstantArray, and put it in a
1239 // ConstantStruct (named S) along with its size.
1240 unsigned Size = state.size ();
1241 ArrayType *AT = ArrayType::get (AllocInfo::getConstantType (), Size);
1242 std::vector TV;
1243 TV.push_back (Type::UIntTy);
1244 TV.push_back (AT);
1245 StructType *ST = StructType::get (TV);
1246 std::vector CV;
1247 CV.push_back (ConstantUInt::get (Type::UIntTy, Size));
1248 CV.push_back (ConstantArray::get (AT, state));
1249 Constant *S = ConstantStruct::get (ST, CV);
1250
12501251 GlobalVariable *GV =
1251 new GlobalVariable (FnAllocState[F]->getType (), true,
1252 GlobalValue::InternalLinkage, FnAllocState[F],
1252 new GlobalVariable (ST, true,
1253 GlobalValue::InternalLinkage, S,
12531254 F->getName () + ".regAllocState", &M);
1255
12541256 // Have: { uint, [Size x { uint, uint, uint, int }] } *
12551257 // Cast it to: { uint, [0 x { uint, uint, uint, int }] } *
12561258 Constant *CE = ConstantExpr::getCast (ConstantPointerRef::get (GV), PT);
13531355 verifySavedState ();
13541356 }
13551357
1356 // Now update the machine code with register names and add any
1357 // additional code inserted by the register allocator to the instruction
1358 // stream
1358 // Now update the machine code with register names and add any additional
1359 // code inserted by the register allocator to the instruction stream.
13591360 updateMachineCode();
13601361
13611362 if (DEBUG_RA) {