- Timestamp:
- Apr 19, 2011, 11:12:07 PM (14 years ago)
- Location:
- clamav/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
clamav/trunk ¶
-
Property svn:mergeinfo
set to
/clamav/vendor/0.97 merged eligible
-
Property svn:mergeinfo
set to
-
TabularUnified clamav/trunk/libclamav/c++/llvm/lib/CodeGen/MachineFunction.cpp ¶
r189 r319 24 24 #include "llvm/CodeGen/MachineInstr.h" 25 25 #include "llvm/CodeGen/MachineJumpTableInfo.h" 26 #include "llvm/CodeGen/MachineModuleInfo.h" 26 27 #include "llvm/CodeGen/MachineRegisterInfo.h" 27 28 #include "llvm/CodeGen/Passes.h" … … 40 41 using namespace llvm; 41 42 42 namespace {43 struct Printer : public MachineFunctionPass {44 static char ID;45 46 raw_ostream &OS;47 const std::string Banner;48 49 Printer(raw_ostream &os, const std::string &banner)50 : MachineFunctionPass(&ID), OS(os), Banner(banner) {}51 52 const char *getPassName() const { return "MachineFunction Printer"; }53 54 virtual void getAnalysisUsage(AnalysisUsage &AU) const {55 AU.setPreservesAll();56 MachineFunctionPass::getAnalysisUsage(AU);57 }58 59 bool runOnMachineFunction(MachineFunction &MF) {60 OS << "# " << Banner << ":\n";61 MF.print(OS);62 return false;63 }64 };65 char Printer::ID = 0;66 }67 68 /// Returns a newly-created MachineFunction Printer pass. The default banner is69 /// empty.70 ///71 FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS,72 const std::string &Banner){73 return new Printer(OS, Banner);74 }75 76 43 //===----------------------------------------------------------------------===// 77 44 // MachineFunction implementation … … 85 52 } 86 53 87 MachineFunction::MachineFunction( Function *F, const TargetMachine &TM,88 unsigned FunctionNum )89 : Fn(F), Target(TM) {54 MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM, 55 unsigned FunctionNum, MachineModuleInfo &mmi) 56 : Fn(F), Target(TM), Ctx(mmi.getContext()), MMI(mmi) { 90 57 if (TM.getRegisterInfo()) 91 RegInfo = new (Allocator.Allocate<MachineRegisterInfo>()) 92 MachineRegisterInfo(*TM.getRegisterInfo()); 58 RegInfo = new (Allocator) MachineRegisterInfo(*TM.getRegisterInfo()); 93 59 else 94 60 RegInfo = 0; 95 61 MFInfo = 0; 96 FrameInfo = new (Allocator.Allocate<MachineFrameInfo>()) 97 MachineFrameInfo(*TM.getFrameInfo()); 62 FrameInfo = new (Allocator) MachineFrameInfo(*TM.getFrameInfo()); 98 63 if (Fn->hasFnAttr(Attribute::StackAlignment)) 99 64 FrameInfo->setMaxAlignment(Attribute::getStackAlignmentFromAttrs( 100 65 Fn->getAttributes().getFnAttributes())); 101 ConstantPool = new (Allocator.Allocate<MachineConstantPool>()) 102 MachineConstantPool(TM.getTargetData()); 66 ConstantPool = new (Allocator) MachineConstantPool(TM.getTargetData()); 103 67 Alignment = TM.getTargetLowering()->getFunctionAlignment(F); 104 68 FunctionNumber = FunctionNum; … … 133 97 if (JumpTableInfo) return JumpTableInfo; 134 98 135 JumpTableInfo = new (Allocator .Allocate<MachineJumpTableInfo>())99 JumpTableInfo = new (Allocator) 136 100 MachineJumpTableInfo((MachineJumpTableInfo::JTEntryKind)EntryKind); 137 101 return JumpTableInfo; … … 230 194 int64_t o, uint64_t s, 231 195 unsigned base_alignment) { 232 return new (Allocator.Allocate<MachineMemOperand>()) 233 MachineMemOperand(v, f, o, s, base_alignment); 196 return new (Allocator) MachineMemOperand(v, f, o, s, base_alignment); 234 197 } 235 198 … … 237 200 MachineFunction::getMachineMemOperand(const MachineMemOperand *MMO, 238 201 int64_t Offset, uint64_t Size) { 239 return new (Allocator .Allocate<MachineMemOperand>())202 return new (Allocator) 240 203 MachineMemOperand(MMO->getValue(), MMO->getFlags(), 241 204 int64_t(uint64_t(MMO->getOffset()) + … … 416 379 ViewGraph(this, "mf" + getFunction()->getNameStr()); 417 380 #else 418 errs() << " SelectionDAG::viewGraphis only available in debug builds on "381 errs() << "MachineFunction::viewCFG is only available in debug builds on " 419 382 << "systems with Graphviz or gv!\n"; 420 383 #endif // NDEBUG … … 426 389 ViewGraph(this, "mf" + getFunction()->getNameStr(), true); 427 390 #else 428 errs() << " SelectionDAG::viewGraphis only available in debug builds on "391 errs() << "MachineFunction::viewCFGOnly is only available in debug builds on " 429 392 << "systems with Graphviz or gv!\n"; 430 393 #endif // NDEBUG … … 435 398 unsigned MachineFunction::addLiveIn(unsigned PReg, 436 399 const TargetRegisterClass *RC) { 437 assert(RC->contains(PReg) && "Not the correct regclass!"); 438 unsigned VReg = getRegInfo().createVirtualRegister(RC); 439 getRegInfo().addLiveIn(PReg, VReg); 400 MachineRegisterInfo &MRI = getRegInfo(); 401 unsigned VReg = MRI.getLiveInVirtReg(PReg); 402 if (VReg) { 403 assert(MRI.getRegClass(VReg) == RC && "Register class mismatch!"); 404 return VReg; 405 } 406 VReg = MRI.createVirtualRegister(RC); 407 MRI.addLiveIn(PReg, VReg); 440 408 return VReg; 441 409 } 442 443 /// getDILocation - Get the DILocation for a given DebugLoc object.444 DILocation MachineFunction::getDILocation(DebugLoc DL) const {445 unsigned Idx = DL.getIndex();446 assert(Idx < DebugLocInfo.DebugLocations.size() &&447 "Invalid index into debug locations!");448 return DILocation(DebugLocInfo.DebugLocations[Idx]);449 }450 451 410 452 411 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table. … … 479 438 /// 480 439 int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset, 481 bool Immutable , bool isSS) {440 bool Immutable) { 482 441 assert(Size != 0 && "Cannot allocate zero size fixed stack objects!"); 483 Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable, 484 isSS)); 442 // The alignment of the frame index can be determined from its offset from 443 // the incoming frame position. If the frame object is at offset 32 and 444 // the stack is guaranteed to be 16-byte aligned, then we know that the 445 // object is 16-byte aligned. 446 unsigned StackAlign = TFI.getStackAlignment(); 447 unsigned Align = MinAlign(SPOffset, StackAlign); 448 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable, 449 /*isSS*/false, false)); 485 450 return -++NumFixedObjects; 486 451 } … … 573 538 case MachineJumpTableInfo::EK_Custom32: 574 539 return 4; 540 case MachineJumpTableInfo::EK_Inline: 541 return 0; 575 542 } 576 543 assert(0 && "Unknown jump table encoding!"); … … 590 557 case MachineJumpTableInfo::EK_Custom32: 591 558 return TD.getABIIntegerTypeAlignment(32); 559 case MachineJumpTableInfo::EK_Inline: 560 return 1; 592 561 } 593 562 assert(0 && "Unknown jump table encoding!"); … … 673 642 /// CanShareConstantPoolEntry - Test whether the given two constants 674 643 /// can be allocated the same constant pool entry. 675 static bool CanShareConstantPoolEntry( Constant *A,Constant *B,644 static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B, 676 645 const TargetData *TD) { 677 646 // Handle the trivial case quickly. … … 688 657 // If a floating-point value and an integer value have the same encoding, 689 658 // they can share a constant-pool entry. 690 if ( ConstantFP *AFP = dyn_cast<ConstantFP>(A))691 if ( ConstantInt *BI = dyn_cast<ConstantInt>(B))659 if (const ConstantFP *AFP = dyn_cast<ConstantFP>(A)) 660 if (const ConstantInt *BI = dyn_cast<ConstantInt>(B)) 692 661 return AFP->getValueAPF().bitcastToAPInt() == BI->getValue(); 693 if ( ConstantFP *BFP = dyn_cast<ConstantFP>(B))694 if ( ConstantInt *AI = dyn_cast<ConstantInt>(A))662 if (const ConstantFP *BFP = dyn_cast<ConstantFP>(B)) 663 if (const ConstantInt *AI = dyn_cast<ConstantInt>(A)) 695 664 return BFP->getValueAPF().bitcastToAPInt() == AI->getValue(); 696 665 697 666 // Two vectors can share an entry if each pair of corresponding 698 667 // elements could. 699 if ( ConstantVector *AV = dyn_cast<ConstantVector>(A))700 if ( ConstantVector *BV = dyn_cast<ConstantVector>(B)) {668 if (const ConstantVector *AV = dyn_cast<ConstantVector>(A)) 669 if (const ConstantVector *BV = dyn_cast<ConstantVector>(B)) { 701 670 if (AV->getType()->getNumElements() != BV->getType()->getNumElements()) 702 671 return false; … … 717 686 /// alignment for the object. 718 687 /// 719 unsigned MachineConstantPool::getConstantPoolIndex( Constant *C,688 unsigned MachineConstantPool::getConstantPoolIndex(const Constant *C, 720 689 unsigned Alignment) { 721 690 assert(Alignment && "Alignment must be specified!");
Note:
See TracChangeset
for help on using the changeset viewer.