forked from wangliu-iscas/gcc-patch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv: thead: Add support for XTheadMac ISA extension
The XTheadMac ISA extension provides multiply-accumulate/subtract instructions: * mula/mulaw/mulah * muls/mulsw/mulsh To benefit from middle-end passes, we expand the following named patterns in riscv.md (as they are not T-Head-specific): * maddhisi4 * msubhisi4 gcc/ChangeLog: * config/riscv/riscv.md (maddhisi4): New expand. (msubhisi4): New expand. * config/riscv/thead.md (*th_mula<mode>): New pattern. (*th_mulawsi): New pattern. (*th_mulawsi2): New pattern. (*th_maddhisi4): New pattern. (*th_sextw_maddhisi4): New pattern. (*th_muls<mode>): New pattern. (*th_mulswsi): New pattern. (*th_mulswsi2): New pattern. (*th_msubhisi4): New pattern. (*th_sextw_msubhisi4): New pattern. gcc/testsuite/ChangeLog: * gcc.target/riscv/thead-mula-muls.c: New test. Co-Developed-by: Xianmiao Qu <cooper.qu@linux.alibaba.com> Signed-off-by: Xianmiao Qu <cooper.qu@linux.alibaba.com> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Changed in v2: - Add missing prefix in on INSN
- Loading branch information
1 parent
9f39242
commit cad3c7d
Showing
3 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv32gc_xtheadmac" { target { rv32 } } } */ | ||
/* { dg-options "-march=rv64gc_xtheadmac" { target { rv64 } } } */ | ||
/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Og" } } */ | ||
|
||
long f_mula(long a, long b, long c) | ||
{ | ||
return a + b * c; | ||
} | ||
|
||
long f_muls(long a, long b, long c) | ||
{ | ||
return a - b * c; | ||
} | ||
|
||
#if __riscv_xlen == 64 | ||
int f_mulaw(int a, int b, int c) | ||
{ | ||
return a + b * c; | ||
} | ||
|
||
int f_mulsw(int a, int b, int c) | ||
{ | ||
return a - b * c; | ||
} | ||
#endif | ||
|
||
long f_mulah(int a, unsigned short b, unsigned short c) | ||
{ | ||
return a + (int)(short)b * (int)(short)c; | ||
} | ||
|
||
long f_mulsh(int a, unsigned short b, unsigned short c) | ||
{ | ||
return a - (int)(short)b * (int)(short)c; | ||
} | ||
|
||
/* { dg-final { scan-assembler-times "th.mula\t" 1 } } */ | ||
/* { dg-final { scan-assembler-times "th.muls\t" 1 } } */ | ||
/* { dg-final { scan-assembler-times "th.mulaw\t" 1 { target { rv64 } } } } */ | ||
/* { dg-final { scan-assembler-times "th.mulsw\t" 1 { target { rv64 } } } } */ | ||
/* { dg-final { scan-assembler-times "th.mulah\t" 1 } } */ | ||
/* { dg-final { scan-assembler-times "th.mulsh\t" 1 } } */ |