public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* How target.md file with target.c/.cc file invoke assembly instructions
@ 2022-05-11  5:45 RICHU NORMAN
  2022-05-11 19:19 ` David Edelsohn
  0 siblings, 1 reply; 2+ messages in thread
From: RICHU NORMAN @ 2022-05-11  5:45 UTC (permalink / raw)
  To: gcc

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

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

* Re: How target.md file with target.c/.cc file invoke assembly instructions
  2022-05-11  5:45 How target.md file with target.c/.cc file invoke assembly instructions RICHU NORMAN
@ 2022-05-11 19:19 ` David Edelsohn
  0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2022-05-11 19:19 UTC (permalink / raw)
  To: RICHU NORMAN; +Cc: GCC Development

On Wed, May 11, 2022 at 1:46 AM RICHU NORMAN <richunorman@cusat.ac.in> wrote:
>
> 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.

You might find the GCC introduction at the GCC Resource Center at IIT
Bombay of assistance:
https://www.cse.iitb.ac.in/grc/

Also, please see the description of the GCC Machine Description

https://gcc.gnu.org/onlinedocs/gccint/Machine-Desc.html#Machine-Desc

> 1. Do *target.md* files along with* target.cc/.c <http://target.cc/.c> *files
> help to invoke assembly instructions automatically?

The machine description (MD file, C file and headers) describe the
processor (as well as the ABI and other details for the target
platform supported by the processor).

> 2.What is the input for this ?(.gimple or .cfg files)

The machine description is not an independent program that takes input
from a file.  The GCC compiler runs the various passes, including the
ones derived from the information in the MD 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?

Please see the documentation linked above and try to understand how
the other patterns in the MD file that you modified work.  You need to
ensure that the pattern you added corresponds to valid RTL that is
generated in the port.  At a very simplistic level, GCC invokes
well-known, named patterns in the MD file to generate RTL, transforms
and optimizes the RTL both with generic optimizations and
optimizations described in the MD files, and then re-recognizes the
RTL to match patterns in the MD file to determine which assembly
language to generate.

> 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?

https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#Developer-Options

You probably want to use -fdump-rtl-all and see if the expected RTL
for your new pattern ever is generated or where it is being lost.  Or
maybe your pattern is not expecting the canonical form of the RTL into
which it is transformed.

You need to learn more about the basic internals of GCC.  The GCC
community can help answer technical questions but cannot debug your
machine description changes for you.

Thanks, David

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

end of thread, other threads:[~2022-05-11 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  5:45 How target.md file with target.c/.cc file invoke assembly instructions RICHU NORMAN
2022-05-11 19:19 ` David Edelsohn

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 read-only IMAP folder(s) and NNTP newsgroup(s).