linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Adding type information to instructions
@ 2008-07-04 23:43 David Given
  2008-07-07 17:42 ` Josh Triplett
  0 siblings, 1 reply; 3+ messages in thread
From: David Given @ 2008-07-04 23:43 UTC (permalink / raw)
  To: linux-sparse


[-- Attachment #1.1: Type: text/plain, Size: 1231 bytes --]

I've been having trouble finding the types of pseudos; the approach I've
been using, which is to follow the chain of pseudo's definers until I
find an instruction with enough type information to use, turns out to
fail utterly on OP_LOAD instructions; I can't find any way of getting
enough information from the opcode's arguments to determine the type of
the target.

As a result, I've had to make a minor patch to the lineariser code.
Given that the lineariser knows the information I need at the point
where it generates the instruction, it would seem to make sense to tag
the instruction with the type. This is made quite easy by the way that
the lineariser has a allocate-typed-instruction function.

Patch enclosed; it's very simple.

Does this seem like a reasonable approach? Is it something that would be
useful to have in the base builds? Are there any ramifications I should
be aware of?

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: type.patch --]
[-- Type: text/x-diff; name="type.patch", Size: 882 bytes --]

diff -rwu sparse.orig/linearize.c sparse/linearize.c
--- sparse.orig/linearize.c	2008-06-28 22:44:21.714555764 +0100
+++ sparse/linearize.c	2008-06-30 23:20:30.777932755 +0100
@@ -55,7 +55,9 @@
 
 static struct instruction *alloc_typed_instruction(int opcode, struct symbol *type)
 {
-	return alloc_instruction(opcode, type_size(type));
+	struct instruction *insn = alloc_instruction(opcode, type_size(type));
+	insn->type = type;
+	return insn;
 }
 
 static struct entrypoint *alloc_entrypoint(void)
diff -rwu sparse.orig/linearize.h sparse/linearize.h
--- sparse.orig/linearize.h	2008-06-28 22:44:21.714555764 +0100
+++ sparse/linearize.h	2008-06-30 23:20:04.425933822 +0100
@@ -71,6 +71,7 @@
 		 size:24;
 	struct basic_block *bb;
 	struct position pos;
+	struct symbol *type;
 	union {
 		pseudo_t target;
 		pseudo_t cond;		/* for branch and switch */

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding type information to instructions
  2008-07-04 23:43 Adding type information to instructions David Given
@ 2008-07-07 17:42 ` Josh Triplett
  2008-07-07 20:08   ` Chris Li
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Triplett @ 2008-07-07 17:42 UTC (permalink / raw)
  To: David Given; +Cc: linux-sparse

On Sat, 2008-07-05 at 00:43 +0100, David Given wrote:
> I've been having trouble finding the types of pseudos; the approach I've
> been using, which is to follow the chain of pseudo's definers until I
> find an instruction with enough type information to use, turns out to
> fail utterly on OP_LOAD instructions; I can't find any way of getting
> enough information from the opcode's arguments to determine the type of
> the target.
> 
> As a result, I've had to make a minor patch to the lineariser code.
> Given that the lineariser knows the information I need at the point
> where it generates the instruction, it would seem to make sense to tag
> the instruction with the type. This is made quite easy by the way that
> the lineariser has a allocate-typed-instruction function.
> 
> Patch enclosed; it's very simple.
> 
> Does this seem like a reasonable approach? Is it something that would be
> useful to have in the base builds? Are there any ramifications I should
> be aware of?

I can't think of any fundamental reason not to do this, other than the
standard reason of data structure size.  However, I'd like to hear
something from others on the list before accepting this patch.

- Josh Triplett



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding type information to instructions
  2008-07-07 17:42 ` Josh Triplett
@ 2008-07-07 20:08   ` Chris Li
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Li @ 2008-07-07 20:08 UTC (permalink / raw)
  To: Josh Triplett; +Cc: David Given, linux-sparse

On Mon, Jul 7, 2008 at 10:42 AM, Josh Triplett <josht@linux.vnet.ibm.com> wrote:
> I can't think of any fundamental reason not to do this, other than the
> standard reason of data structure size.

There is other ways to avoid the size blow up. At the linearized byte
code level,
the back end only need to know it is one of the stander C type . So we have an
array of stander ctype C type similar to ctype_declaration[].

We just need to replace the size member  with the array index in the instruction
struct..

Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-07 20:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-04 23:43 Adding type information to instructions David Given
2008-07-07 17:42 ` Josh Triplett
2008-07-07 20:08   ` Chris Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).