[PATCH V8 06/10] powerpc, lib: Add new branch analysis support functions
Daniel Axtens
dja at axtens.net
Wed Jun 10 15:33:11 AEST 2015
> +static int instr_is_branch_xlform(unsigned int instr)
> +{
> + return branch_opcode(instr) == 19;
> +}
Why do these not return bool? The functions below do.
> +
> +static int is_xlform_lr(unsigned int instr)
> +{
> + return (instr & XL_FORM_LR) == XL_FORM_LR;
> +}
> +
> +static int is_bo_always(unsigned int instr)
> +{
> + return (instr & BO_ALWAYS) == BO_ALWAYS;
> +}
> +
> +static int is_branch_link_set(unsigned int instr)
> +{
> + return (instr & BRANCH_SET_LINK) == BRANCH_SET_LINK;
> +}
> +
> +bool instr_is_return_branch(unsigned int instr)
> +{
> + /*
> + * Conditional and unconditional branch to LR register
> + * without seting the link register.
setting
> + */
> + if (is_xlform_lr(instr) && !is_branch_link_set(instr))
> + return true;
> +
> + return false;
> +}
> +
> +bool instr_is_func_call(unsigned int instr)
> +{
> + /* LR should be set */
> + if (is_branch_link_set(instr))
> + return true;
> +
> + return false;
> +}
> +
> +bool instr_is_indirect_func_call(unsigned int instr)
> +{
> + /* XL-form instruction with LR set */
> + if (instr_is_branch_xlform(instr) && is_branch_link_set(instr))
> + return true;
> +
> + return false;
> +}
Both of these functions could be made into a single 'return' statement,
right?
> +
> int instr_is_relative_branch(unsigned int instr)
> {
> if (instr & BRANCH_ABSOLUTE)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 860 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20150610/77151221/attachment.sig>
More information about the Linuxppc-dev
mailing list