[PATCH] powerpc: Add helper functions for synthesising instructions at runtime
Paul Mackerras
paulus at samba.org
Thu Oct 20 08:53:11 EST 2005
Michael Ellerman writes:
> +typedef enum {
> + BRANCH_RELATIVE,
> + BRANCH_RELATIVE_LINK,
> + BRANCH_ABSOLUTE,
> + BRANCH_ABSOLUTE_LINK
> +} branch_t;
Just to pursue this thread a bit further...
I think your branch_t is folding together two things that are really
orthogonal, and this is causing your code to get longer and more
confusing than necessary.
I would just have defined two separate flags, say BRANCH_ABSOLUTE and
BRANCH_LINK (either with #define or enum), and then declared the
"type" argument to create_branch as "bitwise". Then you can simply OR
the type argument into the instruction word, and you can do tests like
if (!(type & BRANCH_ABSOLUTE)) quite naturally.
This ends up being almost exactly what Segher suggested, but maybe
a little less obfuscated.
Paul.
More information about the Linuxppc64-dev
mailing list