Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Franck Bui-Huu <vagabon.xyz@gmail.com>
To: anemo@mba.ocn.ne.jp
Cc: ralf@linux-mips.org, linux-mips@linux-mips.org,
	Franck Bui-Huu <vagabon.xyz@gmail.com>
Subject: [PATCH 1/7] Make get_frame_info() more readable.
Date: Tue,  1 Aug 2006 11:27:11 +0200	[thread overview]
Message-ID: <11544244383201-git-send-email-vagabon.xyz@gmail.com> (raw)
In-Reply-To: <11544244373398-git-send-email-vagabon.xyz@gmail.com>

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
---
 arch/mips/kernel/process.c |   63 ++++++++++++++++++++++----------------------
 1 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 8709a46..8d0e4fa 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -281,48 +281,49 @@ static struct mips_frame_info {
 } *schedule_frame, mfinfo[64];
 static int mfinfo_num;
 
+static inline int is_ra_save_ins(union mips_instruction *pc)
+{
+	/* sw / sd $ra, offset($sp) */
+	return (pc->i_format.opcode == sw_op || pc->i_format.opcode == sd_op) &&
+		pc->i_format.rs == 29 &&
+		pc->i_format.rt == 31;
+}
+
+static inline int is_jal_jalr_jr_ins(union mips_instruction *pc)
+{
+	return pc->j_format.opcode == jal_op ||
+		(pc->r_format.opcode == spec_op &&
+			(pc->r_format.func == jalr_op || pc->r_format.func == jr_op));
+}
+
+static inline int is_sp_move_ins(union mips_instruction *pc)
+{
+	/* addiu/daddiu sp,sp,-imm */
+	return (pc->i_format.opcode == addiu_op || pc->i_format.opcode == daddiu_op) && \
+		pc->i_format.rs == 29 && \
+		pc->i_format.rt == 29;
+}
+
 static int get_frame_info(struct mips_frame_info *info)
 {
-	int i;
-	void *func = info->func;
-	union mips_instruction *ip = (union mips_instruction *)func;
+	union mips_instruction *ip = info->func;
+	int i, max_insns =
+		min(128UL, info->func_size / sizeof(union mips_instruction));
+
 	info->pc_offset = -1;
 	info->frame_size = 0;
-	for (i = 0; i < 128; i++, ip++) {
-		/* if jal, jalr, jr, stop. */
-		if (ip->j_format.opcode == jal_op ||
-		    (ip->r_format.opcode == spec_op &&
-		     (ip->r_format.func == jalr_op ||
-		      ip->r_format.func == jr_op)))
-			break;
 
-		if (info->func_size && i >= info->func_size / 4)
+	for (i = 0; i < max_insns; i++, ip++) {
+
+		if (is_jal_jalr_jr_ins(ip))
 			break;
-		if (
-#ifdef CONFIG_32BIT
-		    ip->i_format.opcode == addiu_op &&
-#endif
-#ifdef CONFIG_64BIT
-		    ip->i_format.opcode == daddiu_op &&
-#endif
-		    ip->i_format.rs == 29 &&
-		    ip->i_format.rt == 29) {
-			/* addiu/daddiu sp,sp,-imm */
+		if (is_sp_move_ins(ip)) {
 			if (info->frame_size)
 				continue;
 			info->frame_size = - ip->i_format.simmediate;
 		}
 
-		if (
-#ifdef CONFIG_32BIT
-		    ip->i_format.opcode == sw_op &&
-#endif
-#ifdef CONFIG_64BIT
-		    ip->i_format.opcode == sd_op &&
-#endif
-		    ip->i_format.rs == 29 &&
-		    ip->i_format.rt == 31) {
-			/* sw / sd $ra, offset($sp) */
+		if (is_ra_save_ins(ip)) {
 			if (info->pc_offset != -1)
 				continue;
 			info->pc_offset =
-- 
1.4.2.rc2

  reply	other threads:[~2006-08-01  9:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-01  9:27 [PATCH 0/7] Improve prologue analysis code Franck Bui-Huu
2006-08-01  9:27 ` Franck Bui-Huu [this message]
2006-08-01 15:02   ` [PATCH 1/7] Make get_frame_info() more readable Atsushi Nemoto
2006-08-01  9:27 ` [PATCH 2/7] Make get_frame_info() more robust Franck Bui-Huu
2006-08-01  9:27 ` [PATCH 3/7] Make frame_info_init() more readable Franck Bui-Huu
2006-08-01  9:27 ` [PATCH 4/7] Remove unused MODULE_RANGE macro Franck Bui-Huu
2006-08-01  9:27 ` [PATCH 5/7] Miscellaneous cleanup in prologue analysis code Franck Bui-Huu
2006-08-01  9:27 ` [PATCH 6/7] Fix dump_stack() Franck Bui-Huu
2006-08-01 15:08   ` Atsushi Nemoto
2006-08-01 15:36     ` Franck Bui-Huu
2006-08-01 16:05       ` Atsushi Nemoto
2006-08-01 17:43         ` Franck Bui-Huu
2006-08-02  1:54           ` Atsushi Nemoto
2006-08-01  9:27 ` [PATCH 7/7] Allow unwind_stack() to return ra for leaf function Franck Bui-Huu
2006-08-01 15:48   ` Atsushi Nemoto
2006-08-01 19:38     ` Franck Bui-Huu
2006-08-02  1:51       ` Atsushi Nemoto
2006-08-02 10:21         ` Franck Bui-Huu
2006-08-02 11:25           ` Atsushi Nemoto
2006-08-02 13:08             ` Franck Bui-Huu
2006-08-02 16:00               ` Atsushi Nemoto
2006-08-02 16:56                 ` Franck Bui-Huu
2006-08-03  4:52                   ` Atsushi Nemoto
  -- strict thread matches above, loose matches on Subject: below --
2006-08-03  7:29 [PATCH 0/7] Improve prologue analysis code (take #2) Franck Bui-Huu
2006-08-03  7:29 ` [PATCH 1/7] Make get_frame_info() more readable Franck Bui-Huu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11544244383201-git-send-email-vagabon.xyz@gmail.com \
    --to=vagabon.xyz@gmail.com \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox