string constant of the constant pool entry..

2015-03-02 Thread Umesh Kalappa
Hi All,

I'm trying to fetch the string constant from the constant pool entry
for the symbol_ref rtx like

c sample

int i;
int main()
{
  printf("%d",i);
}

rtl is

(gdb) p debug_rtx(val)
(0xb7da4da0) (symbol_ref/f:SI ("*.LC0") [flags 0x2] )

corresponding asm

   .section.rodata,code
.align  2
.LC0:
.ascii  "%d\000"


sample code to fetch the string "%i"

tree sym = SYMBOL_REF_DECL(rtx);

if (!(sym && (TREE_CODE(sym)==STRING_CST) && STRING_CST_CHECK(sym)))
sym = 0;

const char *string = TREE_STRING_POINTER(sym);

the above sample code fails with returning null in string.

Whats wrong with the above code  ? or How do we fetch the
string_constant from the given symbol_ref ?

Any hints will be appreciated ,thank you

FYI,the  gcc code base is 4.8.3.

~Umesh


string constant of the constant pool entry..

2015-03-02 Thread Umesh Kalappa
Hi All,

I'm trying to fetch the string constant from the constant pool entry
for the symbol_ref rtx like

c sample

int i;
int main()
{
  printf("%d",i);
}

rtl is

(gdb) p debug_rtx(val)
(symbol_ref/f:SI ("*.LC0") [flags 0x2] )

corresponding asm

   .section.rodata,code
.align  2
.LC0:
.ascii  "%d\000"


sample code to fetch the string "%d"

tree sym = SYMBOL_REF_DECL(rtx);

if (!(sym && (TREE_CODE(sym)==STRING_CST) && STRING_CST_CHECK(sym)))
sym = 0;

const char *string = TREE_STRING_POINTER(sym);

the above sample code fails with returning null in string.

Whats wrong with the above code  ? or How do we fetch the
string_constant from the given symbol_ref ?

Any hints will be appreciated ,thank you

FYI,the  gcc code base is 4.8.3.

~Umesh


Is there a way to use define_subst when operands need to change modes?

2015-03-02 Thread Kyrill Tkachov

Hi all,

I'm looking at using the define_subst machinery to auto-generate 
zero-extended

versions of some patterns, for example having:
(set reg:SI
 (xor:SI a:SI b:SI))

generate a pattern of the form:
(set reg:DI
 (zero_extend:DI
   (xor:SI (a:SI b:SI

How do I go about achieving this? From the documentation, I think I need 
something like:

 (define_subst "add_z_extend"
   [(set (match_operand:SI 0 "" "")
 (match_operand:SI 1 "" ""))]
   ""
   [(set (match_dup 0)
 (zero_extend:DI (match_dup 1)))]

but in the resultant pattern I need operand 0 to be tranfsormed into DImode.
Is there a way to write that?

Thanks,
Kyrill




Re: Is there a way to use define_subst when operands need to change modes?

2015-03-02 Thread Ilya Tocar
On 02 Mar 15:22, Kyrill Tkachov wrote:
> Hi all,
> 
> I'm looking at using the define_subst machinery to auto-generate
> zero-extended
> versions of some patterns, for example having:
> (set reg:SI
>  (xor:SI a:SI b:SI))
> 
> generate a pattern of the form:
> (set reg:DI
>  (zero_extend:DI
>(xor:SI (a:SI b:SI
> 
> How do I go about achieving this? From the documentation, I think I need
> something like:
>  (define_subst "add_z_extend"
>[(set (match_operand:SI 0 "" "")
>  (match_operand:SI 1 "" ""))]
>""
>[(set (match_dup 0)
>  (zero_extend:DI (match_dup 1)))]
> 
> but in the resultant pattern I need operand 0 to be tranfsormed into DImode.
> Is there a way to write that?
>
Can't you just use  [(set (match_operand:DI 0 "" "")...  instead of
match_dup?


Re: Is there a way to use define_subst when operands need to change modes?

2015-03-02 Thread Kyrill Tkachov


On 02/03/15 17:38, Ilya Tocar wrote:

On 02 Mar 15:22, Kyrill Tkachov wrote:

Hi all,

I'm looking at using the define_subst machinery to auto-generate
zero-extended
versions of some patterns, for example having:
(set reg:SI
  (xor:SI a:SI b:SI))

generate a pattern of the form:
(set reg:DI
  (zero_extend:DI
(xor:SI (a:SI b:SI

How do I go about achieving this? From the documentation, I think I need
something like:
  (define_subst "add_z_extend"
[(set (match_operand:SI 0 "" "")
  (match_operand:SI 1 "" ""))]
""
[(set (match_dup 0)
  (zero_extend:DI (match_dup 1)))]

but in the resultant pattern I need operand 0 to be tranfsormed into DImode.
Is there a way to write that?


Can't you just use  [(set (match_operand:DI 0 "" "")...  instead of
match_dup?


So, something like:

 (define_subst "add_z_extend"
   [(set (match_operand:SI 0 "" "")
 (match_operand:SI 1 "" ""))]
   ""
   [(set (match_operand:DI 0 "" "")
 (zero_extend:DI (match_dup 1)))]


?


Are we allowed to match an operand twice?