-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORE-V: Support Multiply Accumulate Extension #1
base: master
Are you sure you want to change the base?
Conversation
4b02595
to
fd43628
Compare
TODO: Add contributors! Not adding it now so people don't keep getting notifications :) Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html Contributos: gcc/ChangeLog: * common/config/riscv/riscv-common.cc: Added XCVmac. * config/riscv/riscv-ftypes.def: Added XCVmac builtins. * config/riscv/riscv-opts.h: Likewise. * config/riscv/riscv.md: Likewise. * config/riscv/riscv.opt: Likewise. * doc/extend.texi: Added XCVmac builtin documentation. * config/riscv/corev.def: New file. * config/riscv/corev.md: New file. gcc/testsuite/ChangeLog: * lib/target-supports.exp: * gcc.target/riscv/cv-march-xcvmac-compile.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mac.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-machhsn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-machhsrn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-machhun.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-machhurn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-macsn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-macsrn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-macun.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-macurn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-msu.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulhhsn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulhhsrn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulhhun.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulhhurn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulsn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulsrn.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulun.c: New test. * gcc.target/riscv/cv-march-xcvmac-fail-compile-mulurn.c: New test. * gcc.target/riscv/cv-march-xcvmac-test-autogeneration.c: New test. Signed-off-by: Mary Bennett <mary.bennett@embecosm.com>
fd43628
to
58eaa10
Compare
What we want the naming scheme for the testcases to be? |
The tests should also be in GCC format, right?
|
We will want the corresponding header file, too. |
@@ -1462,6 +1463,7 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] = | |||
{"xtheadmemidx", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADMEMIDX}, | |||
{"xtheadmempair", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADMEMPAIR}, | |||
{"xtheadsync", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADSYNC}, | |||
{"xcvmac", &gcc_options::x_riscv_xcv_flags, MASK_XCVMAC}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move above xtheadba
to keep in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
gcc/config/riscv/corev.md
Outdated
@@ -0,0 +1,264 @@ | |||
;; Machine description for RISC-V MAC operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;; Machine description for RISC-V MAC operations. | |
;; Machine description for CORE-V vendor extensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
;; along with GCC; see the file COPYING3. If not see | ||
;; <http://www.gnu.org/licenses/>. | ||
|
||
(define_insn "riscv_cv_mac_mac" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(define_insn "riscv_cv_mac_mac" | |
;; XCVMAC extension | |
(define_insn "riscv_cv_mac_mac" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
gcc/config/riscv/riscv-ftypes.def
Outdated
DEF_RISCV_FTYPE (3, (USI, USI, USI, UQI)) //RISCV_USI_FTYPE_USI_USI_UQI | ||
DEF_RISCV_FTYPE (3, (SI, SI, SI, UQI)) //RISCV_SI_FTYPE_SI_SI_UQI | ||
DEF_RISCV_FTYPE (4, (USI, USI, USI, USI, UQI)) //RISCV_USI_FTYPE_USI_USI_USI_UQI | ||
DEF_RISCV_FTYPE (4, (SI, SI, SI, SI, UQI)) //RISCV_SI_FTYPE_SI_SI_SI_UQI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments needed?
gcc/config/riscv/riscv-opts.h
Outdated
@@ -319,4 +319,8 @@ enum riscv_entity | |||
#define TARGET_VECTOR_VLS \ | |||
(TARGET_VECTOR && riscv_autovec_preference == RVV_SCALABLE) | |||
|
|||
#define MASK_XCVMAC (1 << 0) | |||
|
|||
#define TARGET_XCVMAC ((riscv_xcv_flags & MASK_XCVMAC) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these go alongside the existing vendor targets/masks?
gcc/config/riscv/riscv.opt
Outdated
@@ -254,6 +254,9 @@ int riscv_ztso_subext | |||
TargetVariable | |||
int riscv_xthead_subext | |||
|
|||
TargetVariable | |||
int riscv_xcv_flags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put alphabetical above riscv_xthead_subext?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
gcc/doc/extend.texi
Outdated
@@ -21614,6 +21614,82 @@ vector intrinsic specification, which is available at the following link: | |||
@uref{https://github.com/riscv-non-isa/rvv-intrinsic-doc/tree/v0.11.x}. | |||
All of these functions are declared in the include file @file{riscv_vector.h}. | |||
|
|||
These built-in functions are available for the CORE-V MAC machine | |||
architecture. For more information on CORE-V built-ins, please see | |||
@uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-hardware-loop-builtins-xcvhwlp} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go in it's own subsection e.g. CORE-V Vendor Intrinsics
.
URL mentions hardware-loop-builtins
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
/* { dg-options "-march=rv32i_xcvmac -mabi=ilp32" } */ | ||
|
||
#include <stdint.h> | ||
#include<stdio.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need stdio.h for this and the other tests.
{ | ||
asm ("cv.mac t0, t1, t2"); | ||
} | ||
} "-march=rv32ixcvmac" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be rv32i_xcvmac
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
It would make sense to have one |
What do you mean here? Not sure what header file you are referring to, sorry :( |
During the CORE-V LLVM / GCC calls, it was decided that the best way to allow the toolchain to communicate with IDEs was to add a header file of the builtins. |
List of contributors: |
This PR presents the comprehensive implementation of the MAC extension for CORE-V, in preparation for upstream.
I have thoroughly tested the implementation to ensure its correctness and compatibility with the existing codebase. However, your input, reviews, and suggestions are invaluable in making this extension even more robust.
Test results (using this toolchain):
Multilib enabled:
TODO: The failures + unsupported tests are due to...