comparison lib/CodeGen/StackMaps.cpp @ 83:60c9769439b8 LLVM3.7

LLVM 3.7
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 18 Feb 2015 14:55:36 +0900
parents 54457678186b
children afa8332a0e37
comparison
equal deleted inserted replaced
78:af83660cff7b 83:60c9769439b8
82 LocationVec &Locs, LiveOutVec &LiveOuts) const { 82 LocationVec &Locs, LiveOutVec &LiveOuts) const {
83 if (MOI->isImm()) { 83 if (MOI->isImm()) {
84 switch (MOI->getImm()) { 84 switch (MOI->getImm()) {
85 default: llvm_unreachable("Unrecognized operand type."); 85 default: llvm_unreachable("Unrecognized operand type.");
86 case StackMaps::DirectMemRefOp: { 86 case StackMaps::DirectMemRefOp: {
87 unsigned Size = 87 unsigned Size = AP.TM.getDataLayout()->getPointerSizeInBits();
88 AP.TM.getSubtargetImpl()->getDataLayout()->getPointerSizeInBits();
89 assert((Size % 8) == 0 && "Need pointer size in bytes."); 88 assert((Size % 8) == 0 && "Need pointer size in bytes.");
90 Size /= 8; 89 Size /= 8;
91 unsigned Reg = (++MOI)->getReg(); 90 unsigned Reg = (++MOI)->getReg();
92 int64_t Imm = (++MOI)->getImm(); 91 int64_t Imm = (++MOI)->getImm();
93 Locs.push_back(Location(StackMaps::Location::Direct, Size, Reg, Imm)); 92 Locs.push_back(Location(StackMaps::Location::Direct, Size, Reg, Imm));
218 // Move large constants into the constant pool. 217 // Move large constants into the constant pool.
219 for (LocationVec::iterator I = Locations.begin(), E = Locations.end(); 218 for (LocationVec::iterator I = Locations.begin(), E = Locations.end();
220 I != E; ++I) { 219 I != E; ++I) {
221 // Constants are encoded as sign-extended integers. 220 // Constants are encoded as sign-extended integers.
222 // -1 is directly encoded as .long 0xFFFFFFFF with no constant pool. 221 // -1 is directly encoded as .long 0xFFFFFFFF with no constant pool.
223 if (I->LocType == Location::Constant && 222 if (I->LocType == Location::Constant && !isInt<32>(I->Offset)) {
224 ((I->Offset + (int64_t(1)<<31)) >> 32) != 0) {
225 I->LocType = Location::ConstantIndex; 223 I->LocType = Location::ConstantIndex;
224 // ConstPool is intentionally a MapVector of 'uint64_t's (as
225 // opposed to 'int64_t's). We should never be in a situation
226 // where we have to insert either the tombstone or the empty
227 // keys into a map, and for a DenseMap<uint64_t, T> these are
228 // (uint64_t)0 and (uint64_t)-1. They can be and are
229 // represented using 32 bit integers.
230
231 assert((uint64_t)I->Offset != DenseMapInfo<uint64_t>::getEmptyKey() &&
232 (uint64_t)I->Offset != DenseMapInfo<uint64_t>::getTombstoneKey() &&
233 "empty and tombstone keys should fit in 32 bits!");
226 auto Result = ConstPool.insert(std::make_pair(I->Offset, I->Offset)); 234 auto Result = ConstPool.insert(std::make_pair(I->Offset, I->Offset));
227 I->Offset = Result.first - ConstPool.begin(); 235 I->Offset = Result.first - ConstPool.begin();
228 } 236 }
229 } 237 }
230 238
231 // Create an expression to calculate the offset of the callsite from function 239 // Create an expression to calculate the offset of the callsite from function
232 // entry. 240 // entry.
233 const MCExpr *CSOffsetExpr = MCBinaryExpr::CreateSub( 241 const MCExpr *CSOffsetExpr = MCBinaryExpr::CreateSub(
234 MCSymbolRefExpr::Create(MILabel, OutContext), 242 MCSymbolRefExpr::Create(MILabel, OutContext),
235 MCSymbolRefExpr::Create(AP.CurrentFnSym, OutContext), 243 MCSymbolRefExpr::Create(AP.CurrentFnSymForSize, OutContext),
236 OutContext); 244 OutContext);
237 245
238 CSInfos.push_back(CallsiteInfo(CSOffsetExpr, ID, Locations, LiveOuts)); 246 CSInfos.emplace_back(CSOffsetExpr, ID, std::move(Locations),
247 std::move(LiveOuts));
239 248
240 // Record the stack size of the current function. 249 // Record the stack size of the current function.
241 const MachineFrameInfo *MFI = AP.MF->getFrameInfo(); 250 const MachineFrameInfo *MFI = AP.MF->getFrameInfo();
242 const TargetRegisterInfo *RegInfo = AP.MF->getSubtarget().getRegisterInfo(); 251 const TargetRegisterInfo *RegInfo = AP.MF->getSubtarget().getRegisterInfo();
243 const bool DynamicFrameSize = MFI->hasVarSizedObjects() || 252 const bool DynamicFrameSize = MFI->hasVarSizedObjects() ||
273 for (unsigned i = 0, e = (opers.hasDef() ? NArgs+1 : NArgs); i != e; ++i) 282 for (unsigned i = 0, e = (opers.hasDef() ? NArgs+1 : NArgs); i != e; ++i)
274 assert(Locations[i].LocType == Location::Register && 283 assert(Locations[i].LocType == Location::Register &&
275 "anyreg arg must be in reg."); 284 "anyreg arg must be in reg.");
276 } 285 }
277 #endif 286 #endif
287 }
288 void StackMaps::recordStatepoint(const MachineInstr &MI) {
289 assert(MI.getOpcode() == TargetOpcode::STATEPOINT &&
290 "expected statepoint");
291
292 StatepointOpers opers(&MI);
293 // Record all the deopt and gc operands (they're contiguous and run from the
294 // initial index to the end of the operand list)
295 const unsigned StartIdx = opers.getVarIdx();
296 recordStackMapOpers(MI, 0xABCDEF00,
297 MI.operands_begin() + StartIdx, MI.operands_end(),
298 false);
278 } 299 }
279 300
280 /// Emit the stackmap header. 301 /// Emit the stackmap header.
281 /// 302 ///
282 /// Header { 303 /// Header {