aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Margiolis <christos@FreeBSD.org>2023-06-03 17:04:33 +0000
committerChristos Margiolis <christos@FreeBSD.org>2023-06-03 17:04:33 +0000
commit980746e5cb264a70ad3dcbbf38ba919ad3436aa1 (patch)
tree523885df5ca83506e97fb471b91e2d6555bec2ce
parentbab7781e78fccecb7c969a63e2d5668ee1c09246 (diff)
fbt: simplify arm64 function-prologue parsing
Reviewed by: markj Approved by: markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40364
-rw-r--r--sys/cddl/dev/fbt/aarch64/fbt_isa.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/sys/cddl/dev/fbt/aarch64/fbt_isa.c b/sys/cddl/dev/fbt/aarch64/fbt_isa.c
index cc4ea42715c8..4b32d42ca0b4 100644
--- a/sys/cddl/dev/fbt/aarch64/fbt_isa.c
+++ b/sys/cddl/dev/fbt/aarch64/fbt_isa.c
@@ -130,35 +130,25 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
*/
if (*instr == NOP_INSTR)
found = true;
- if (!found) {
- for (; instr < limit; instr++) {
+ for (; !found && instr < limit; instr++) {
+ /*
+ * Functions start with "stp xt1, xt2, [xn, <const>]!" or
+ * "sub sp, sp, <const>".
+ *
+ * Sometimes the compiler will have a sub instruction that is
+ * not of the above type so don't stop if we see one.
+ */
+ if ((*instr & LDP_STP_MASK) == STP_64) {
/*
- * Some functions start with
- * "stp xt1, xt2, [xn, <const>]!"
+ * Assume any other store of this type means we are
+ * past the function prologue.
*/
- if ((*instr & LDP_STP_MASK) == STP_64) {
- /*
- * Assume any other store of this type means we
- * are past the function prolog.
- */
- if (((*instr >> ADDR_SHIFT) & ADDR_MASK) == 31)
- found = true;
- break;
- }
-
- /*
- * Some functions start with a "sub sp, sp, <const>"
- * Sometimes the compiler will have a sub instruction
- * that is not of the above type so don't stop if we
- * see one.
- */
- if ((*instr & SUB_MASK) == SUB_INSTR &&
- ((*instr >> SUB_RD_SHIFT) & SUB_R_MASK) == 31 &&
- ((*instr >> SUB_RN_SHIFT) & SUB_R_MASK) == 31) {
+ if (((*instr >> ADDR_SHIFT) & ADDR_MASK) == 31)
found = true;
- break;
- }
- }
+ } else if ((*instr & SUB_MASK) == SUB_INSTR &&
+ ((*instr >> SUB_RD_SHIFT) & SUB_R_MASK) == 31 &&
+ ((*instr >> SUB_RN_SHIFT) & SUB_R_MASK) == 31)
+ found = true;
}
if (!found)