I am having some problems defining the stack layout on ARM. It should look like Incoming vars ----------------- Saved Link Register ----------------- Local vars ----------------- The problem is that the the first local variable is being assigned to the same location as the link register. I tried to use the OffsetOfLocalArea option, but do to alignment restrictions this increased the stack size. The offset of the local vars is set in calculateFrameObjectOffsets, so I added the following hack to eliminateFrameIndex: if (Offset < 0) //local variable Offset -= 4; Is there a better way? Thanks, Rafael
On Tue, 15 Aug 2006, [UTF-8] Rafael Esp?ndola wrote:> I am having some problems defining the stack layout on ARM. It should look > like > > Incoming vars > ----------------- > Saved Link Register > ----------------- > Local vars > ----------------- > > The problem is that the the first local variable is being assigned to > the same location as the link register. I tried to use the > OffsetOfLocalArea option, but do to alignment restrictions this > increased the stack size. > > The offset of the local vars is set in calculateFrameObjectOffsets, so > I added the following hack to eliminateFrameIndex: > > if (Offset < 0) //local variable > Offset -= 4; > > Is there a better way?I'm not sure I follow the question. It sounds like you should use the standard model, where local vars are allocated using variable frame indexes and the incoming vars are fixed frame regs. The link register gets spilled to a fixed location (e.g. see the PPC backend's handling of the LR register). I'm not familiar with the ARM ISA, so I don't know the right answer. The OffsetOfLocalArea is used for ISAs (like X86) where the call sequence modifies the stack pointer (in the case of X86, the call instruction pushes a 4/8-byte return value). If ARM is like PPC, where the return address is implicitly copied into a physreg, then you should probably use OffsetOfLocalArea=0 and just ask for LR to be spilled to a specific location (e.g. see the PPC backend). I feel like I'm not really understanding the question though, can you rephrase it? -Chris -- http://nondot.org/sabre/ http://llvm.org/
> I'm not familiar with the ARM ISA, so I don't know the right answer. The > OffsetOfLocalArea is used for ISAs (like X86) where the call sequence > modifies the stack pointer (in the case of X86, the call instruction > pushes a 4/8-byte return value). If ARM is like PPC, where the return > address is implicitly copied into a physreg, then you should probably use > OffsetOfLocalArea=0 and just ask for LR to be spilled to a specific > location (e.g. see the PPC backend).The problem was that I was generating hard coded loads and stores for the link register. I was trying to shift the local variables, but this isn't the correct solution. I have now implemented getCalleeSaveSpillSlots, so that the link register is treated like any other callee save register. Thanks, Rafael
Maybe Matching Threads
- [LLVMdev] problems defining the stack layout
- [LLVMdev] problems defining the stack layout
- [LLVMdev] should PEI::calculateFrameObjectOffsets align the stack?
- [LLVMdev] should PEI::calculateFrameObjectOffsets align the stack?
- [LLVMdev] should PEI::calculateFrameObjectOffsets align the stack?