Lowering formal pointer arguments

Hi,

How can I get the llvm-type of the formal argument while lowering it ?

My target needs to map pointer and non-pointer parameters to different registers. In addition, parameter lowering is address space dependent (another reason why I need such information). Looking at the DAGBuilder, I found that it is dropping it when translating llvm-types to BE types. Even if the base type is saved into the MVT structure, it's a private member. What's the reason for hiding it ? Why not to keep such information ?

Thanks in advance,

Ivan

If you need llvm::Argument, this returns the iterator pointing to the
first argument:

Function::const_arg_iterator Arg =
DAG.getMachineFunction().getFunction()->arg_begin();

If you need llvm::Argument, this returns the iterator pointing to the
first argument:

Function::const_arg_iterator Arg =
DAG.getMachineFunction().getFunction()->arg_begin();

Thanks Akira.

Ivan

Our target also use different registers for pointer and non-pointer parameters.

If you need llvm::Argument, this returns the iterator pointing to the
first argument:

DAG.getMachineFunction().getFunction() only works in LowerFormalArguments (there it returns the callee), not in LowerCall (where it returns the caller, rather than the callee). You need to pass more information about the function type to LowerCall (besides partial information such as the isVarArg parameter).

I can provide a patch if you are interested. (Unfortunately, to push this upstream has been on my to-do-list for while).

/Patrik Hägglund

Hi Patrik,

DAG.getMachineFunction().getFunction() only works in LowerFormalArguments (there it returns the callee), not in LowerCall (where it returns the caller, rather than the callee). You need to pass more information about the function type to LowerCall (besides partial information such as the isVarArg parameter).

I can provide a patch if you are interested. (Unfortunately, to push this upstream has been on my to-do-list for while).

please do! I have been facing the same problem and am very interested in
a clean solution for this.

Best regards,
Christoph

Here is a quick-and-dirty fix, done on top of trunk from Jan 25. It just adds FTy as an extra parameter. Inside LowerCall:

  ... FTy->getReturnType();

  for (FunctionType::param_iterator i = FTy->param_begin(),
         e = FTy->param_end(); i != e; ++i) {
    Type *T = *i;
    ...

However, using NULL as default value probably breaks some code, which needs to be fixed (before submitting upstream). Also, for example, the isVarArg parameter should probably be removed.

/Patrik Hägglund

lowercall_fty.diff (18.3 KB)