* add a new instruction to gcc
@ 2020-04-15 3:17 郑镐东
0 siblings, 0 replies; only message in thread
From: 郑镐东 @ 2020-04-15 3:17 UTC (permalink / raw)
To: gcc-help
Greetings.
I tried to add a new assembly instruction to gcc, the new instruction is:
"checki rdi,rs1,rs2".I want gcc to insert my assembly statement before the
array's assignment statement during compilation.
For example:
> int func1()
> {
> int a[10];
> int b[10];
> a[0] = 1;
> }
> int func2()
> {
> int a[10];
> int b[10];
> ...
> ...
> a[2] = b[3];
> }
I want gcc to compile the above code to do the following:
> int fun1(){
> int a[10];
> int b[10];
> <----------- checki rdi,rs1,rs2
> // insert my custom assembly code
> a[0] = 1;
> }
> int func2()
> {
> int a[10];
> int b[10];
> ...
> ...
> <----------- checki rdi,rs1,rs2
> // insert my custom assembly code
> a[2] = b[3];
> }
I wrote some code in the gimple layer to identify arrays:
> static bool is_array(tree var){
> if(TREE_CODE(var) == VAR_DECL && TREE_TYPE(var) == ARRAY_TYPE)
> {
> return true;
> }
> return false;
> }
> static bool find_array_assignments(gimple stmt)
> {
> if(is_gimple_assign(stmt))
> {
> tree lhsop = gimple_assign_lhs(stmt);
> tree rhsop1 = gimple_assign_rhs1(stmt);
> tree rhsop2 = gimple_assign_rhs2(stmt);
> if((lhsop && is_array(lhsop)) || (rhsop1 && is_array(rhsop1)) ||
(rhsop2 && is_array(rhsop2)))
> return true;
> }
> return false;
> }
But I'm not sure in which file to add the code and I'm also not sure in
which files I need to define my assembly statement and insert it when GCC
recognizes the array.I find some gcc info at gcc.gnu.org, but I couldn't
find a specific example I could refer to.
In general, I want to know which file in GCC I should add the code that
identifies the array to for it to take effect, and I also want to know
which files I should use define_insn to declare my assembly statement to
change and what to add?
Thanks in advance,
Best regards,
wizard
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-15 3:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 3:17 add a new instruction to gcc 郑镐东
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).