[PATCH 04/12] RISC-V: GAS: Add basic shared test utilities
Tsukasa OI
research_trasio@irq.a4lg.com
Sat Nov 5 12:29:10 GMT 2022
This commit adds basic shared test utilities intended for future
extension tests.
gas/ChangeLog:
* testsuite/gas/riscv/testutils.inc: New test utilities.
---
gas/testsuite/gas/riscv/testutils.inc | 113 ++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 gas/testsuite/gas/riscv/testutils.inc
diff --git a/gas/testsuite/gas/riscv/testutils.inc b/gas/testsuite/gas/riscv/testutils.inc
new file mode 100644
index 00000000000..009484eefed
--- /dev/null
+++ b/gas/testsuite/gas/riscv/testutils.inc
@@ -0,0 +1,113 @@
+# Set NOARCH symbols.
+.ifndef NOARCH
+.set NOARCH, 0
+.endif
+.ifndef NOARCH_ARCH
+.set NOARCH_ARCH, 0
+.endif
+.ifndef NOARCH_XLEN
+.set NOARCH_XLEN, 0
+.endif
+.if NOARCH
+.set NOARCH_ARCH, 1
+.set NOARCH_XLEN, 1
+.endif
+
+# Update XLEN constraint symbols.
+# For intentional error handling tests, .if SYM ... .endif block should be
+# used to test those varibales.
+.macro UPDATE_XLEN
+ .if NOARCH_XLEN
+ # When NOARCH_XLEN is set,
+ # set those variables to "invalid" 1 to generate errors.
+ .set XLEN_EQ_32, 1
+ .set XLEN_EQ_64, 1
+ .set XLEN_GE_64, 1
+ .else
+ # Set symbol values depending on the XLEN.
+ .ifdef XLEN
+ .ifeq XLEN-32
+ .set XLEN_EQ_32, 1
+ .else
+ .set XLEN_EQ_32, 0
+ .endif
+ .ifeq XLEN-64
+ .set XLEN_EQ_64, 1
+ .else
+ .set XLEN_EQ_64, 0
+ .endif
+ .ifge XLEN-64
+ .set XLEN_GE_64, 1
+ .else
+ .set XLEN_GE_64, 0
+ .endif
+ .else
+ .set XLEN_EQ_32, 0
+ .set XLEN_EQ_64, 0
+ .set XLEN_GE_64, 0
+ .endif
+ .endif
+.endm
+UPDATE_XLEN
+
+# Set the base architecture.
+.macro SET_BASE_FORCE xlen, basearch=i
+ .option arch, rv\xlen\basearch
+ .set XLEN, \xlen
+ UPDATE_XLEN
+.endm
+
+# Set the base architecture unless the symbol NOARCH_ARCH is set.
+.macro SET_BASE xlen, basearch=i
+ .if !NOARCH_ARCH
+ SET_BASE_FORCE \xlen, \basearch
+ .endif
+.endm
+
+# Begin base architecture block.
+.macro SET_BASE_START_FORCE xlen, basearch=i
+ .option push
+ SET_BASE_FORCE \xlen, \basearch
+.endm
+
+# Begin base architecture block.
+# Don't change the architecture if NOARCH_ARCH is set.
+.macro SET_BASE_START xlen, basearch=i
+ .option push
+ SET_BASE \xlen, \basearch
+.endm
+
+# End base architecture block.
+.macro SET_BASE_END
+ .option pop
+.endm
+
+# Set the architecture.
+.macro SET_ARCH_FORCE arch
+ .option arch, \arch
+.endm
+
+# Set the architecture unless the symbol NOARCH_ARCH is set.
+.macro SET_ARCH arch
+ .ifeq NOARCH_ARCH-0
+ SET_ARCH_FORCE \arch
+ .endif
+.endm
+
+# Begin architecture block.
+.macro SET_ARCH_START_FORCE arch
+ .option push
+ SET_ARCH_FORCE \arch
+.endm
+
+# Begin architecture block.
+# Don't change the architecture if NOARCH_ARCH is set.
+.macro SET_ARCH_START arch
+ .option push
+ SET_ARCH \arch
+.endm
+
+# End architecture block.
+.macro SET_ARCH_END
+ .option pop
+.endm
--
2.37.2
More information about the Binutils
mailing list