Although it's not generally needed for ARM's use of CCCustom, I return
two bools to handle the four possible outcomes to keep the mechanism
flexible:
* if CCCustomFn handled the arg or not
* if CCCustomFn wants to end processing of the arg or not
+/// CCCustomFn - This function assigns a location for Val, possibly
updating
+/// all args to reflect changes and indicates if it handled it. It
must set
+/// isCustom if it handles the arg and returns true.
+typedef bool CCCustomFn(unsigned &ValNo, MVT &ValVT,
+ MVT &LocVT, CCValAssign::LocInfo &LocInfo,
+ ISD::ArgFlagsTy &ArgFlags, CCState &State,
+ bool &result);
Is "result" what you refer to as "isCustom" in the comments?
Sorry, I am still confused. You mean it could return true but set
'result' to false? That means it has handled the argument but it would
not process any more arguments? What scenario do you envision that
this will be useful? I'd rather keep it simple.
As you note there are three actual legitimate cases (of the four combos):
1. The CCCustomFn wants the arg handling to proceed. This might be
used akin to CCPromoteToType.
2. The CCCustomFn entirely handled the arg. This might be used akin to
CCAssignToReg.
3. The CCCustomFn tried to handle the arg, but failed.
these results are conveyed the following ways:
1. The CCCustomFn returns false, &result is not used.
2. The CCCustomFn returns true, &result is false;
3. The CCCustomFn returns true, &result is true.
I tried to keep these CCCustomFns looking like TableGen generated
code. Suggestions of how to reorganize these results are welcome. 
Perhaps better comments around the typedef for CCCustomFn would
suffice?
The isCustom flag is simply a means for this machinery to convey to
the TargetLowering functions to process this arg specially. It may not
always be possible for the TargetLowering functions to determine that
the arg needs special handling after all the changes made by the
CCCustomFn or CCPromoteToType and other transformations.
I placed the "unsigned i" outside those loops because i is used after
the loop. If there's a better index search pattern, I'd be happy to
change it.
Ok.
One more nitpick:
+/// CCCustom - calls a custom arg handling function
Please capitalize "calls" and end with a period.
Once we settle on the result handling changes, I'll submit an update
with this change.