Seperate stack location for outgoing parameters and local variables for custom target?

I’m working on a target for the intermediate language of another compiler (so it can benifit from LLVM’s optimization stages). I’m working on LLVM 3.1 for now. I started the translater as a copy of the MIPS target so that I can just modify it to produce the correct output.

I basically want to replace all of the local variables and incoming parameters with values that look like this: LOC[i] (where i is the number of the parameter). This can be done pretty easily if I want it to apply to everything. However, outgoing parameters shouldn’t be replaced by the LOC[i] notation. I’ve seen that stack locations that are used for parameters are sometimes also used for local variables.

So here’s my question: Is there a way for me to modify my target to ensure that no location on the stack will be used for both outgoing parameters and other stack objects within a single function, and make it easy to differentiate between outgoing parameters and other local variables?

I see that in the LowerCall function in ISelLowering.cpp, there’s this code (From the MIPS target):

// Create the frame index object for this incoming parameter
LastFI = MFI->CreateFixedObject(ValVT.getSizeInBits()/8,
VA.getLocMemOffset(), true);
SDValue PtrOff = DAG.getFrameIndex(LastFI, getPointerTy());

This looks like what I might want to change, but I’m not sure what’s the right thing to do. Here’s what I tried to change it to:

LastFI = MFI->CreateStackObject(ValVT.getSizeInBits()/8,
VA.getLocMemOffset(), false);
SDValue PtrOff = DAG.getFrameIndex(LastFI, getPointerTy());

If I did this, the parameters didn’t collide with other local variables anymore, but it ruined the original calculated offset and allignment (it started at $sp+0 instead of 16 and the arguments ended up aligned at 8 instead of 4).

Is there a way to do something like this without the stack object being put in a different place, and perhaps leave a way for me to find out from the MachineFrameInfo later that this offset is for outgoing parameters?