How target.md file with target.c/.cc file invoke assembly instructions

2022-05-10 Thread RICHU NORMAN
Hi,
I am new in gcc development and I am focusing on cross-compilers.I have
added a few instructions for the target machine in binutils and invoked it
using asm() from c program.Now I want to add those instructions to gcc and
define that instruction in target.md file.I have a few queries regarding
the working of gcc.
1. Do *target.md* files along with* target.cc/.c <http://target.cc/.c> *files
help to invoke assembly instructions automatically?
2.What is the input for this ?(.gimple or .cfg files)
3.How does it work internally?
4.I have defined an instruction in target.md alone.But that does not
work.How to make it work?
5.What is the use of target.c file and how cost is computed in it?
6.Which file to be examined in rtl-dump of object file for getting the
input and output to this stage in gcc?





-- 
Thanks & Regards
Richu Norman


How can I add comments to files generated in rtl dump?

2022-05-18 Thread RICHU NORMAN
Hi,
I have added the new instruction in opcode and invoked it using
asm_volatile .The new instruction is generated in the object dump.
Now I  wrote an RTL template for the same instruction in a .md file and
some cost value calculation in cfile.Then I run the sample c code that
invokes the instruction defined in .md file.
I examined the files generated in -fdump-rtl-all. But the added instruction
is not generated .
*How can I add comments to files generated in rtl dump?*
 I have added fprintf (dump_file, "Test hello world\n"); to *gcc/cfgrtl.cc *and
observed *.expand file .But I could not find the test word in that file .

-- 
Richu Norman
Research Scholar
Department of Computer Science
Cochin University of Science and Technology
Ph : (+91)-8848455627


Adding log files to gcc dump and adding testcase-rtl

2022-05-24 Thread RICHU NORMAN
Hi,
I am a beginner in gcc. I am trying to add an instruction to riscv-gcc.It
would be helpful could help with a few tips .
1.How to write comments to rtl or create a custom log file to log comments
to rtl dump?
2.How to run testsuite ?
3.Is there a way to directly run an rtl test case? Like giving rtl input
and checking the generated asm.(Like in the attachment which is posted in
bugzilla[ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82815 ])
Please suggest a way to run the gcc-testsuite with these cases. Pfa



-- 
Richu Norman
Research Scholar
Department of Computer Science
Cochin University of Science and Technology
Ph : (+91)-8848455627
/* { dg-do compile } */
/* { dg-options "-march=armv7e-m -mfloat-abi=hard -mfpu=fpv5-d16" } */

double __RTL (startwith ("mach")) foo (void)
{
(function "foo"
  (insn-chain
(cnote 1 NOTE_INSN_DELETED)
(cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
(cinsn/f 16 (parallel [
(set (mem/c:BLK (pre_modify:SI (reg/f:SI sp)
(plus:SI (reg/f:SI sp)
(const_int -8))) [1  A8])
(unspec:BLK [
(reg:SI r4)
] UNSPEC_PUSH_MULT))
(use (reg/f:SI r7))
]) "foo.c":2
 (expr_list:REG_FRAME_RELATED_EXPR (sequence [
(set/f (reg/f:SI sp)
(plus:SI (reg/f:SI sp)
(const_int -8)))
(set/f (mem/c:SI (reg/f:SI sp) [1  S4 A32])
(reg:SI r4))
(set/f (mem/c:SI (plus:SI (reg/f:SI sp)
(const_int 4)) [1  S4 A32])
(reg/f:SI r7))
])))
(cinsn/f 17 (set (reg/f:SI r7)
(plus:SI (reg/f:SI sp)
(const_int 0))) "foo.c":2)
(cnote 18 NOTE_INSN_PROLOGUE_END)
(cnote 2 NOTE_INSN_FUNCTION_BEG)
(cinsn 5 (set (reg:DF r3 [orig:110 _1 ] [110])
(const_double:DF 1.0e+0 [0x0.8p+1])) "foo.c":3)
(cinsn 8 (set (reg:DF s14 [orig:111  ] [111])
(reg:DF r3 [orig:110 _1 ] [110])) "foo.c":3)
(cinsn 12 (set (reg/i:DF s0)
(reg:DF s14 [orig:111  ] [111])) "foo.c":4)
(cinsn 13 (use (reg/i:DF s0)) "foo.c":4)
(cnote 19 NOTE_INSN_EPILOGUE_BEG)
(cinsn 20 (unspec_volatile [
(const_int 0)
] VUNSPEC_BLOCKAGE) "foo.c":4)
(cinsn/f 21 (set (reg/f:SI sp)
(reg/f:SI r7)) "foo.c":4
 (expr_list:REG_CFA_ADJUST_CFA (set (reg/f:SI sp)
(reg/f:SI r7
(cinsn 22 (unspec:SI [
(reg/f:SI sp)
] UNSPEC_REGISTER_USE) "foo.c":4)
(cinsn/f 23 (parallel [
(set/f (reg/f:SI sp)
(plus:SI (reg/f:SI sp)
(const_int 8)))
(set/f (reg:SI r4)
(mem/c:SI (reg/f:SI sp) [1  S4 A32]))
(set/f (reg/f:SI r7)
(mem/c:SI (plus:SI (reg/f:SI sp)
(const_int 4)) [1  S4 A32]))
]) "foo.c":4
 (expr_list:REG_CFA_ADJUST_CFA (set (reg/f:SI sp)
(plus:SI (reg/f:SI sp)
(const_int 8)))
(expr_list:REG_CFA_RESTORE (reg/f:SI r7)
(expr_list:REG_CFA_RESTORE (reg:SI r4)
(cjump_insn 24 (simple_return) "foo.c":4)
(cbarrier 25)
(cnote 15 NOTE_INSN_DELETED)
  ) ;; insn-chain
  (crtl
(return_rtx 
  (reg/i:DF s0)
) ;; return_rtx
  ) ;; crtl
) ;; function "foo"
}


Re: Adding log files to gcc dump and adding testcase-rtl

2022-05-25 Thread RICHU NORMAN
This is great, thank you so much!
I am also looking for support regarding adding instructions for the target
machine.



On Wed, May 25, 2022 at 4:14 PM David Malcolm  wrote:

> On Wed, 2022-05-25 at 10:25 +0530, RICHU NORMAN wrote:
> > Hi,
> > I am a beginner in gcc. I am trying to add an instruction to riscv-
> > gcc.It
> > would be helpful could help with a few tips .
>
> Hi Richu - welcome to GCC development.
>
> FWIW I've written a guide for new GCC contributors which you might find
> helpful:
>   https://gcc-newbies-guide.readthedocs.io/en/latest/index.html
>
> Caveat: I'm much more familiar with the frontends/diagnostics, rather
> than the backends/RTL, so there may be a "frontend" bias in that guide.
>
> > 1.How to write comments to rtl or create a custom log file to log
> > comments
> > to rtl dump?
> > 2.How to run testsuite ?
> > 3.Is there a way to directly run an rtl test case? Like giving rtl
> > input
> > and checking the generated asm.(Like in the attachment which is
> > posted in
> > bugzilla[ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82815 ])
> > Please suggest a way to run the gcc-testsuite with these cases. Pfa
>
> I wrote some notes on dealing with the testsuite, and on running
> individual cases here:
>
> https://gcc-newbies-guide.readthedocs.io/en/latest/working-with-the-testsuite.html
>
> Hope this is helpful; good luck
> Dave
>
>

-- 
Richu Norman
Research Scholar
Department of Computer Science
Cochin University of Science and Technology
Ph : (+91)-8848455627


RTL Pattern not working

2022-05-26 Thread RICHU NORMAN
In gcc/combine.cc


I have written a pattern to emit a complex rtl instruction which uses 'and'
'shift'  'lshiftrt' and 'or' in a single pattern.But pattern not recognised
as single pattern.I changed the cost of this instruction to 0.Still pattern
is not generated.
How can I check if the instruction works or not?
I have checked the output in files generated in fdump-rtl-all .
Wish to know how combiner.cc works.
dump_combine_total_stats (FILE *file)
{
  fprintf
(file,
 "\n;; Combiner totals: %d attempts, %d substitutions (%d requiring new
space),\n;; %d successes.\n",
 total_attempts, total_merges, total_extras, total_successes);
}
In my case the pattern is not generated as well not compared .


-- 
Richu Norman
Research Scholar
Department of Computer Science
Cochin University of Science and Technology
Ph : (+91)-8848455627