From fde5a3d494e5fc9942e4f9510d757c5038e2d2fd Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 1 Sep 2010 22:16:27 +0000 Subject: [PATCH] Some basic store support. llvm-svn: 112752 --- llvm/lib/Target/ARM/ARMFastISel.cpp | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp index 87af77b13e1b..9b41afb4d4ce 100644 --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -106,6 +106,7 @@ class ARMFastISel : public FastISel { // Instruction selection routines. virtual bool ARMSelectLoad(const Instruction *I); + virtual bool ARMSelectStore(const Instruction *I); // Utility routines. private: @@ -113,6 +114,7 @@ class ARMFastISel : public FastISel { bool isLoadTypeLegal(const Type *Ty, EVT &VT); bool ARMEmitLoad(EVT VT, unsigned &ResultReg, unsigned Reg, int Offset); bool ARMLoadAlloca(const Instruction *I); + bool ARMStoreAlloca(const Instruction *I); bool ARMComputeRegOffset(const Value *Obj, unsigned &Reg, int &Offset); bool DefinesOptionalPredicate(MachineInstr *MI, bool *CPSR); @@ -444,6 +446,43 @@ bool ARMFastISel::ARMEmitLoad(EVT VT, unsigned &ResultReg, return true; } +bool ARMFastISel::ARMStoreAlloca(const Instruction *I) { + Value *Op1 = I->getOperand(1); + + // Verify it's an alloca. + if (const AllocaInst *AI = dyn_cast(Op1)) { + DenseMap::iterator SI = + FuncInfo.StaticAllocaMap.find(AI); + + if (SI != FuncInfo.StaticAllocaMap.end()) { + TargetRegisterClass* RC = TLI.getRegClassFor(TLI.getPointerTy()); + unsigned Reg = getRegForValue(I->getOperand(0)); + // Make sure we can get this into a register. + if (Reg == 0) return false; + TII.storeRegToStackSlot(*FuncInfo.MBB, *FuncInfo.InsertPt, + Reg, true /*isKill*/, SI->second, RC, + TM.getRegisterInfo()); + return true; + } + } + return false; +} + +bool ARMFastISel::ARMSelectStore(const Instruction *I) { + // If we're an alloca we know we have a frame index and can emit the store + // quickly. + if (ARMStoreAlloca(I)) + return true; + + // Yay type legalization + EVT VT; + if (!isLoadTypeLegal(I->getType(), VT)) + return false; + + return false; + +} + bool ARMFastISel::ARMSelectLoad(const Instruction *I) { // If we're an alloca we know we have a frame index and can emit the load // directly in short order. @@ -496,6 +535,8 @@ bool ARMFastISel::TargetSelectInstruction(const Instruction *I) { switch (I->getOpcode()) { case Instruction::Load: return ARMSelectLoad(I); + case Instruction::Store: + return ARMSelectStore(I); default: break; } return false;