From 4762fe621e84347b6e1ad1f2d16d2bc6cd28495e Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 18 Nov 2019 16:00:59 +0000 Subject: [PATCH] binutils/gas/riscv: Add DWARF register numbers for CSRs This commit gives DWARF register numbers to the RISC-V CSRs inline with the RISC-V ELF specification here: https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md The CSRs are defined being numbered from 4096 to 8191. This adds support to the assembler, required in order to reference CSRs in, for example .cfi directives. I have then extended dwarf.c in order to support printing CSR names in the dumped DWARF output. As the CSR name space is quite large and only sparsely populated, I have provided a new function to perform RISC-V DWARF register name lookup which uses a switch statement rather than the table base approach that other architectures use. Any CSR that does not have a known name will return a name based on 'csr%d' with the %d being replaced by the offset of the CSR from 4096. gas/ChangeLog: * config/tc-riscv.c (tc_riscv_regname_to_dw2regnum): Lookup CSR names too. * testsuite/gas/riscv/csr-dw-regnums.d: New file. * testsuite/gas/riscv/csr-dw-regnums.s: New file. binutils/ChangeLog: * dwarf.c (regname_internal_riscv): New function. (init_dwarf_regnames_riscv): Use new function. Change-Id: I3f70bc24fa8b3c75744e6775eeeb87db70c7ecfb --- binutils/ChangeLog | 5 + binutils/dwarf.c | 41 +++- gas/ChangeLog | 7 + gas/config/tc-riscv.c | 4 + gas/testsuite/gas/riscv/csr-dw-regnums.d | 265 +++++++++++++++++++++++ gas/testsuite/gas/riscv/csr-dw-regnums.s | 255 ++++++++++++++++++++++ 6 files changed, 574 insertions(+), 3 deletions(-) create mode 100644 gas/testsuite/gas/riscv/csr-dw-regnums.d create mode 100644 gas/testsuite/gas/riscv/csr-dw-regnums.s diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 9aace1337f4..d91298924cf 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2019-11-22 Andrew Burgess + + * dwarf.c (regname_internal_riscv): New function. + (init_dwarf_regnames_riscv): Use new function. + 2019-11-22 Andrew Burgess * dwarf.c (typedef dwarf_regname_lookup_ftype): New typedef. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 483d7c080bb..06ef1f7285e 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7591,12 +7591,47 @@ static const char *const dwarf_regnames_riscv[] = "ft8", "ft9", "ft10", "ft11" /* 60 - 63 */ }; +/* A RISC-V replacement for REGNAME_INTERNAL_BY_TABLE_ONLY which handles + the large number of CSRs. */ + +static const char * +regname_internal_riscv (unsigned int regno) +{ + const char *name = NULL; + + /* Lookup in the table first, this covers GPR and FPR. */ + if (regno < ARRAY_SIZE (dwarf_regnames_riscv)) + name = dwarf_regnames_riscv [regno]; + else if (regno >= 4096 && regno <= 8191) + { + /* This might be a CSR, these live in a sparse number space from 4096 + to 8191 These numbers are defined in the RISC-V ELF ABI + document. */ + switch (regno) + { +#define DECLARE_CSR(NAME,VALUE) case VALUE + 4096: name = #NAME; break; +#include "opcode/riscv-opc.h" +#undef DECLARE_CSR + + default: + { + static char csr_name[10]; + snprintf (csr_name, sizeof (csr_name), "csr%d", (regno - 4096)); + name = csr_name; + } + break; + } + } + + return name; +} + static void init_dwarf_regnames_riscv (void) { - dwarf_regnames = dwarf_regnames_riscv; - dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_riscv); - dwarf_regnames_lookup_func = regname_internal_by_table_only; + dwarf_regnames = NULL; + dwarf_regnames_count = 8192; + dwarf_regnames_lookup_func = regname_internal_riscv; } void diff --git a/gas/ChangeLog b/gas/ChangeLog index f3b8d33a308..474e5c31f8a 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2019-11-22 Andrew Burgess + + * config/tc-riscv.c (tc_riscv_regname_to_dw2regnum): Lookup CSR + names too. + * testsuite/gas/riscv/csr-dw-regnums.d: New file. + * testsuite/gas/riscv/csr-dw-regnums.s: New file. + 2019-11-22 Andrew Burgess * config/tc-riscv.c (struct regname): Delete. diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 5d95ee8eee3..dcd8405a2c1 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -3037,6 +3037,10 @@ tc_riscv_regname_to_dw2regnum (char *regname) if ((reg = reg_lookup_internal (regname, RCLASS_FPR)) >= 0) return reg + 32; + /* CSRs are numbered 4096 -> 8191. */ + if ((reg = reg_lookup_internal (regname, RCLASS_CSR)) >= 0) + return reg + 4096; + as_bad (_("unknown register `%s'"), regname); return -1; } diff --git a/gas/testsuite/gas/riscv/csr-dw-regnums.d b/gas/testsuite/gas/riscv/csr-dw-regnums.d new file mode 100644 index 00000000000..597747cf313 --- /dev/null +++ b/gas/testsuite/gas/riscv/csr-dw-regnums.d @@ -0,0 +1,265 @@ +#as: +#objdump: --dwarf=frames + + +.*: file format elf.*-.*riscv + +Contents of the .* section: + + +00000000 [a-zA-Z0-9]+ [a-zA-Z0-9]+ CIE + Version: .* + Augmentation: .* + Code alignment factor: .* + Data alignment factor: .* + Return address column: .* + Augmentation data: .* +#... +[a-zA-Z0-9]+ [a-zA-Z0-9]+ [a-zA-Z0-9]+ FDE cie=00000000 pc=[a-zA-Z0-9]+\.\.[a-zA-Z0-9]+ + DW_CFA_advance_loc: 4 to 0+0000020 + DW_CFA_offset_extended: r4096 \(ustatus\) at cfa\+0 + DW_CFA_offset_extended_sf: r4100 \(uie\) at cfa\+16 + DW_CFA_offset_extended_sf: r4101 \(utvec\) at cfa\+20 + DW_CFA_offset_extended_sf: r4160 \(uscratch\) at cfa\+256 + DW_CFA_offset_extended_sf: r4161 \(uepc\) at cfa\+260 + DW_CFA_offset_extended_sf: r4162 \(ucause\) at cfa\+264 + DW_CFA_offset_extended_sf: r4163 \(utval\) at cfa\+268 + DW_CFA_offset_extended_sf: r4164 \(uip\) at cfa\+272 + DW_CFA_offset_extended_sf: r4097 \(fflags\) at cfa\+4 + DW_CFA_offset_extended_sf: r4098 \(frm\) at cfa\+8 + DW_CFA_offset_extended_sf: r4099 \(fcsr\) at cfa\+12 + DW_CFA_offset_extended_sf: r7168 \(cycle\) at cfa\+12288 + DW_CFA_offset_extended_sf: r7169 \(time\) at cfa\+12292 + DW_CFA_offset_extended_sf: r7170 \(instret\) at cfa\+12296 + DW_CFA_offset_extended_sf: r7171 \(hpmcounter3\) at cfa\+12300 + DW_CFA_offset_extended_sf: r7172 \(hpmcounter4\) at cfa\+12304 + DW_CFA_offset_extended_sf: r7173 \(hpmcounter5\) at cfa\+12308 + DW_CFA_offset_extended_sf: r7174 \(hpmcounter6\) at cfa\+12312 + DW_CFA_offset_extended_sf: r7175 \(hpmcounter7\) at cfa\+12316 + DW_CFA_offset_extended_sf: r7176 \(hpmcounter8\) at cfa\+12320 + DW_CFA_offset_extended_sf: r7177 \(hpmcounter9\) at cfa\+12324 + DW_CFA_offset_extended_sf: r7178 \(hpmcounter10\) at cfa\+12328 + DW_CFA_offset_extended_sf: r7179 \(hpmcounter11\) at cfa\+12332 + DW_CFA_offset_extended_sf: r7180 \(hpmcounter12\) at cfa\+12336 + DW_CFA_offset_extended_sf: r7181 \(hpmcounter13\) at cfa\+12340 + DW_CFA_offset_extended_sf: r7182 \(hpmcounter14\) at cfa\+12344 + DW_CFA_offset_extended_sf: r7183 \(hpmcounter15\) at cfa\+12348 + DW_CFA_offset_extended_sf: r7184 \(hpmcounter16\) at cfa\+12352 + DW_CFA_offset_extended_sf: r7185 \(hpmcounter17\) at cfa\+12356 + DW_CFA_offset_extended_sf: r7186 \(hpmcounter18\) at cfa\+12360 + DW_CFA_offset_extended_sf: r7187 \(hpmcounter19\) at cfa\+12364 + DW_CFA_offset_extended_sf: r7188 \(hpmcounter20\) at cfa\+12368 + DW_CFA_offset_extended_sf: r7189 \(hpmcounter21\) at cfa\+12372 + DW_CFA_offset_extended_sf: r7190 \(hpmcounter22\) at cfa\+12376 + DW_CFA_offset_extended_sf: r7191 \(hpmcounter23\) at cfa\+12380 + DW_CFA_offset_extended_sf: r7192 \(hpmcounter24\) at cfa\+12384 + DW_CFA_offset_extended_sf: r7193 \(hpmcounter25\) at cfa\+12388 + DW_CFA_offset_extended_sf: r7194 \(hpmcounter26\) at cfa\+12392 + DW_CFA_offset_extended_sf: r7195 \(hpmcounter27\) at cfa\+12396 + DW_CFA_offset_extended_sf: r7196 \(hpmcounter28\) at cfa\+12400 + DW_CFA_offset_extended_sf: r7197 \(hpmcounter29\) at cfa\+12404 + DW_CFA_offset_extended_sf: r7198 \(hpmcounter30\) at cfa\+12408 + DW_CFA_offset_extended_sf: r7199 \(hpmcounter31\) at cfa\+12412 + DW_CFA_offset_extended_sf: r7296 \(cycleh\) at cfa\+12800 + DW_CFA_offset_extended_sf: r7297 \(timeh\) at cfa\+12804 + DW_CFA_offset_extended_sf: r7298 \(instreth\) at cfa\+12808 + DW_CFA_offset_extended_sf: r7299 \(hpmcounter3h\) at cfa\+12812 + DW_CFA_offset_extended_sf: r7300 \(hpmcounter4h\) at cfa\+12816 + DW_CFA_offset_extended_sf: r7301 \(hpmcounter5h\) at cfa\+12820 + DW_CFA_offset_extended_sf: r7302 \(hpmcounter6h\) at cfa\+12824 + DW_CFA_offset_extended_sf: r7303 \(hpmcounter7h\) at cfa\+12828 + DW_CFA_offset_extended_sf: r7304 \(hpmcounter8h\) at cfa\+12832 + DW_CFA_offset_extended_sf: r7305 \(hpmcounter9h\) at cfa\+12836 + DW_CFA_offset_extended_sf: r7306 \(hpmcounter10h\) at cfa\+12840 + DW_CFA_offset_extended_sf: r7307 \(hpmcounter11h\) at cfa\+12844 + DW_CFA_offset_extended_sf: r7308 \(hpmcounter12h\) at cfa\+12848 + DW_CFA_offset_extended_sf: r7309 \(hpmcounter13h\) at cfa\+12852 + DW_CFA_offset_extended_sf: r7310 \(hpmcounter14h\) at cfa\+12856 + DW_CFA_offset_extended_sf: r7311 \(hpmcounter15h\) at cfa\+12860 + DW_CFA_offset_extended_sf: r7312 \(hpmcounter16h\) at cfa\+12864 + DW_CFA_offset_extended_sf: r7313 \(hpmcounter17h\) at cfa\+12868 + DW_CFA_offset_extended_sf: r7314 \(hpmcounter18h\) at cfa\+12872 + DW_CFA_offset_extended_sf: r7315 \(hpmcounter19h\) at cfa\+12876 + DW_CFA_offset_extended_sf: r7316 \(hpmcounter20h\) at cfa\+12880 + DW_CFA_offset_extended_sf: r7317 \(hpmcounter21h\) at cfa\+12884 + DW_CFA_offset_extended_sf: r7318 \(hpmcounter22h\) at cfa\+12888 + DW_CFA_offset_extended_sf: r7319 \(hpmcounter23h\) at cfa\+12892 + DW_CFA_offset_extended_sf: r7320 \(hpmcounter24h\) at cfa\+12896 + DW_CFA_offset_extended_sf: r7321 \(hpmcounter25h\) at cfa\+12900 + DW_CFA_offset_extended_sf: r7322 \(hpmcounter26h\) at cfa\+12904 + DW_CFA_offset_extended_sf: r7323 \(hpmcounter27h\) at cfa\+12908 + DW_CFA_offset_extended_sf: r7324 \(hpmcounter28h\) at cfa\+12912 + DW_CFA_offset_extended_sf: r7325 \(hpmcounter29h\) at cfa\+12916 + DW_CFA_offset_extended_sf: r7326 \(hpmcounter30h\) at cfa\+12920 + DW_CFA_offset_extended_sf: r7327 \(hpmcounter31h\) at cfa\+12924 + DW_CFA_offset_extended_sf: r4352 \(sstatus\) at cfa\+1024 + DW_CFA_offset_extended_sf: r4354 \(sedeleg\) at cfa\+1032 + DW_CFA_offset_extended_sf: r4355 \(sideleg\) at cfa\+1036 + DW_CFA_offset_extended_sf: r4356 \(sie\) at cfa\+1040 + DW_CFA_offset_extended_sf: r4357 \(stvec\) at cfa\+1044 + DW_CFA_offset_extended_sf: r4358 \(scounteren\) at cfa\+1048 + DW_CFA_offset_extended_sf: r4416 \(sscratch\) at cfa\+1280 + DW_CFA_offset_extended_sf: r4417 \(sepc\) at cfa\+1284 + DW_CFA_offset_extended_sf: r4418 \(scause\) at cfa\+1288 + DW_CFA_offset_extended_sf: r4419 \(stval\) at cfa\+1292 + DW_CFA_offset_extended_sf: r4420 \(sip\) at cfa\+1296 + DW_CFA_offset_extended_sf: r4480 \(satp\) at cfa\+1536 + DW_CFA_offset_extended_sf: r7953 \(mvendorid\) at cfa\+15428 + DW_CFA_offset_extended_sf: r7954 \(marchid\) at cfa\+15432 + DW_CFA_offset_extended_sf: r7955 \(mimpid\) at cfa\+15436 + DW_CFA_offset_extended_sf: r7956 \(mhartid\) at cfa\+15440 + DW_CFA_offset_extended_sf: r4864 \(mstatus\) at cfa\+3072 + DW_CFA_offset_extended_sf: r4865 \(misa\) at cfa\+3076 + DW_CFA_offset_extended_sf: r4866 \(medeleg\) at cfa\+3080 + DW_CFA_offset_extended_sf: r4867 \(mideleg\) at cfa\+3084 + DW_CFA_offset_extended_sf: r4868 \(mie\) at cfa\+3088 + DW_CFA_offset_extended_sf: r4869 \(mtvec\) at cfa\+3092 + DW_CFA_offset_extended_sf: r4870 \(mcounteren\) at cfa\+3096 + DW_CFA_offset_extended_sf: r4928 \(mscratch\) at cfa\+3328 + DW_CFA_offset_extended_sf: r4929 \(mepc\) at cfa\+3332 + DW_CFA_offset_extended_sf: r4930 \(mcause\) at cfa\+3336 + DW_CFA_offset_extended_sf: r4931 \(mtval\) at cfa\+3340 + DW_CFA_offset_extended_sf: r4932 \(mip\) at cfa\+3344 + DW_CFA_offset_extended_sf: r5024 \(pmpcfg0\) at cfa\+3712 + DW_CFA_offset_extended_sf: r5025 \(pmpcfg1\) at cfa\+3716 + DW_CFA_offset_extended_sf: r5026 \(pmpcfg2\) at cfa\+3720 + DW_CFA_offset_extended_sf: r5027 \(pmpcfg3\) at cfa\+3724 + DW_CFA_offset_extended_sf: r5040 \(pmpaddr0\) at cfa\+3776 + DW_CFA_offset_extended_sf: r5041 \(pmpaddr1\) at cfa\+3780 + DW_CFA_offset_extended_sf: r5042 \(pmpaddr2\) at cfa\+3784 + DW_CFA_offset_extended_sf: r5043 \(pmpaddr3\) at cfa\+3788 + DW_CFA_offset_extended_sf: r5044 \(pmpaddr4\) at cfa\+3792 + DW_CFA_offset_extended_sf: r5045 \(pmpaddr5\) at cfa\+3796 + DW_CFA_offset_extended_sf: r5046 \(pmpaddr6\) at cfa\+3800 + DW_CFA_offset_extended_sf: r5047 \(pmpaddr7\) at cfa\+3804 + DW_CFA_offset_extended_sf: r5048 \(pmpaddr8\) at cfa\+3808 + DW_CFA_offset_extended_sf: r5049 \(pmpaddr9\) at cfa\+3812 + DW_CFA_offset_extended_sf: r5050 \(pmpaddr10\) at cfa\+3816 + DW_CFA_offset_extended_sf: r5051 \(pmpaddr11\) at cfa\+3820 + DW_CFA_offset_extended_sf: r5052 \(pmpaddr12\) at cfa\+3824 + DW_CFA_offset_extended_sf: r5053 \(pmpaddr13\) at cfa\+3828 + DW_CFA_offset_extended_sf: r5054 \(pmpaddr14\) at cfa\+3832 + DW_CFA_offset_extended_sf: r5055 \(pmpaddr15\) at cfa\+3836 + DW_CFA_offset_extended_sf: r6912 \(mcycle\) at cfa\+11264 + DW_CFA_offset_extended_sf: r6914 \(minstret\) at cfa\+11272 + DW_CFA_offset_extended_sf: r6915 \(mhpmcounter3\) at cfa\+11276 + DW_CFA_offset_extended_sf: r6916 \(mhpmcounter4\) at cfa\+11280 + DW_CFA_offset_extended_sf: r6917 \(mhpmcounter5\) at cfa\+11284 + DW_CFA_offset_extended_sf: r6918 \(mhpmcounter6\) at cfa\+11288 + DW_CFA_offset_extended_sf: r6919 \(mhpmcounter7\) at cfa\+11292 + DW_CFA_offset_extended_sf: r6920 \(mhpmcounter8\) at cfa\+11296 + DW_CFA_offset_extended_sf: r6921 \(mhpmcounter9\) at cfa\+11300 + DW_CFA_offset_extended_sf: r6922 \(mhpmcounter10\) at cfa\+11304 + DW_CFA_offset_extended_sf: r6923 \(mhpmcounter11\) at cfa\+11308 + DW_CFA_offset_extended_sf: r6924 \(mhpmcounter12\) at cfa\+11312 + DW_CFA_offset_extended_sf: r6925 \(mhpmcounter13\) at cfa\+11316 + DW_CFA_offset_extended_sf: r6926 \(mhpmcounter14\) at cfa\+11320 + DW_CFA_offset_extended_sf: r6927 \(mhpmcounter15\) at cfa\+11324 + DW_CFA_offset_extended_sf: r6928 \(mhpmcounter16\) at cfa\+11328 + DW_CFA_offset_extended_sf: r6929 \(mhpmcounter17\) at cfa\+11332 + DW_CFA_offset_extended_sf: r6930 \(mhpmcounter18\) at cfa\+11336 + DW_CFA_offset_extended_sf: r6931 \(mhpmcounter19\) at cfa\+11340 + DW_CFA_offset_extended_sf: r6932 \(mhpmcounter20\) at cfa\+11344 + DW_CFA_offset_extended_sf: r6933 \(mhpmcounter21\) at cfa\+11348 + DW_CFA_offset_extended_sf: r6934 \(mhpmcounter22\) at cfa\+11352 + DW_CFA_offset_extended_sf: r6935 \(mhpmcounter23\) at cfa\+11356 + DW_CFA_offset_extended_sf: r6936 \(mhpmcounter24\) at cfa\+11360 + DW_CFA_offset_extended_sf: r6937 \(mhpmcounter25\) at cfa\+11364 + DW_CFA_offset_extended_sf: r6938 \(mhpmcounter26\) at cfa\+11368 + DW_CFA_offset_extended_sf: r6939 \(mhpmcounter27\) at cfa\+11372 + DW_CFA_offset_extended_sf: r6940 \(mhpmcounter28\) at cfa\+11376 + DW_CFA_offset_extended_sf: r6941 \(mhpmcounter29\) at cfa\+11380 + DW_CFA_offset_extended_sf: r6942 \(mhpmcounter30\) at cfa\+11384 + DW_CFA_offset_extended_sf: r6943 \(mhpmcounter31\) at cfa\+11388 + DW_CFA_offset_extended_sf: r7040 \(mcycleh\) at cfa\+11776 + DW_CFA_offset_extended_sf: r7042 \(minstreth\) at cfa\+11784 + DW_CFA_offset_extended_sf: r7043 \(mhpmcounter3h\) at cfa\+11788 + DW_CFA_offset_extended_sf: r7044 \(mhpmcounter4h\) at cfa\+11792 + DW_CFA_offset_extended_sf: r7045 \(mhpmcounter5h\) at cfa\+11796 + DW_CFA_offset_extended_sf: r7046 \(mhpmcounter6h\) at cfa\+11800 + DW_CFA_offset_extended_sf: r7047 \(mhpmcounter7h\) at cfa\+11804 + DW_CFA_offset_extended_sf: r7048 \(mhpmcounter8h\) at cfa\+11808 + DW_CFA_offset_extended_sf: r7049 \(mhpmcounter9h\) at cfa\+11812 + DW_CFA_offset_extended_sf: r7050 \(mhpmcounter10h\) at cfa\+11816 + DW_CFA_offset_extended_sf: r7051 \(mhpmcounter11h\) at cfa\+11820 + DW_CFA_offset_extended_sf: r7052 \(mhpmcounter12h\) at cfa\+11824 + DW_CFA_offset_extended_sf: r7053 \(mhpmcounter13h\) at cfa\+11828 + DW_CFA_offset_extended_sf: r7054 \(mhpmcounter14h\) at cfa\+11832 + DW_CFA_offset_extended_sf: r7055 \(mhpmcounter15h\) at cfa\+11836 + DW_CFA_offset_extended_sf: r7056 \(mhpmcounter16h\) at cfa\+11840 + DW_CFA_offset_extended_sf: r7057 \(mhpmcounter17h\) at cfa\+11844 + DW_CFA_offset_extended_sf: r7058 \(mhpmcounter18h\) at cfa\+11848 + DW_CFA_offset_extended_sf: r7059 \(mhpmcounter19h\) at cfa\+11852 + DW_CFA_offset_extended_sf: r7060 \(mhpmcounter20h\) at cfa\+11856 + DW_CFA_offset_extended_sf: r7061 \(mhpmcounter21h\) at cfa\+11860 + DW_CFA_offset_extended_sf: r7062 \(mhpmcounter22h\) at cfa\+11864 + DW_CFA_offset_extended_sf: r7063 \(mhpmcounter23h\) at cfa\+11868 + DW_CFA_offset_extended_sf: r7064 \(mhpmcounter24h\) at cfa\+11872 + DW_CFA_offset_extended_sf: r7065 \(mhpmcounter25h\) at cfa\+11876 + DW_CFA_offset_extended_sf: r7066 \(mhpmcounter26h\) at cfa\+11880 + DW_CFA_offset_extended_sf: r7067 \(mhpmcounter27h\) at cfa\+11884 + DW_CFA_offset_extended_sf: r7068 \(mhpmcounter28h\) at cfa\+11888 + DW_CFA_offset_extended_sf: r7069 \(mhpmcounter29h\) at cfa\+11892 + DW_CFA_offset_extended_sf: r7070 \(mhpmcounter30h\) at cfa\+11896 + DW_CFA_offset_extended_sf: r7071 \(mhpmcounter31h\) at cfa\+11900 + DW_CFA_offset_extended_sf: r4899 \(mhpmevent3\) at cfa\+3212 + DW_CFA_offset_extended_sf: r4900 \(mhpmevent4\) at cfa\+3216 + DW_CFA_offset_extended_sf: r4901 \(mhpmevent5\) at cfa\+3220 + DW_CFA_offset_extended_sf: r4902 \(mhpmevent6\) at cfa\+3224 + DW_CFA_offset_extended_sf: r4903 \(mhpmevent7\) at cfa\+3228 + DW_CFA_offset_extended_sf: r4904 \(mhpmevent8\) at cfa\+3232 + DW_CFA_offset_extended_sf: r4905 \(mhpmevent9\) at cfa\+3236 + DW_CFA_offset_extended_sf: r4906 \(mhpmevent10\) at cfa\+3240 + DW_CFA_offset_extended_sf: r4907 \(mhpmevent11\) at cfa\+3244 + DW_CFA_offset_extended_sf: r4908 \(mhpmevent12\) at cfa\+3248 + DW_CFA_offset_extended_sf: r4909 \(mhpmevent13\) at cfa\+3252 + DW_CFA_offset_extended_sf: r4910 \(mhpmevent14\) at cfa\+3256 + DW_CFA_offset_extended_sf: r4911 \(mhpmevent15\) at cfa\+3260 + DW_CFA_offset_extended_sf: r4912 \(mhpmevent16\) at cfa\+3264 + DW_CFA_offset_extended_sf: r4913 \(mhpmevent17\) at cfa\+3268 + DW_CFA_offset_extended_sf: r4914 \(mhpmevent18\) at cfa\+3272 + DW_CFA_offset_extended_sf: r4915 \(mhpmevent19\) at cfa\+3276 + DW_CFA_offset_extended_sf: r4916 \(mhpmevent20\) at cfa\+3280 + DW_CFA_offset_extended_sf: r4917 \(mhpmevent21\) at cfa\+3284 + DW_CFA_offset_extended_sf: r4918 \(mhpmevent22\) at cfa\+3288 + DW_CFA_offset_extended_sf: r4919 \(mhpmevent23\) at cfa\+3292 + DW_CFA_offset_extended_sf: r4920 \(mhpmevent24\) at cfa\+3296 + DW_CFA_offset_extended_sf: r4921 \(mhpmevent25\) at cfa\+3300 + DW_CFA_offset_extended_sf: r4922 \(mhpmevent26\) at cfa\+3304 + DW_CFA_offset_extended_sf: r4923 \(mhpmevent27\) at cfa\+3308 + DW_CFA_offset_extended_sf: r4924 \(mhpmevent28\) at cfa\+3312 + DW_CFA_offset_extended_sf: r4925 \(mhpmevent29\) at cfa\+3316 + DW_CFA_offset_extended_sf: r4926 \(mhpmevent30\) at cfa\+3320 + DW_CFA_offset_extended_sf: r4927 \(mhpmevent31\) at cfa\+3324 + DW_CFA_offset_extended_sf: r6048 \(tselect\) at cfa\+7808 + DW_CFA_offset_extended_sf: r6049 \(tdata1\) at cfa\+7812 + DW_CFA_offset_extended_sf: r6050 \(tdata2\) at cfa\+7816 + DW_CFA_offset_extended_sf: r6051 \(tdata3\) at cfa\+7820 + DW_CFA_offset_extended_sf: r6064 \(dcsr\) at cfa\+7872 + DW_CFA_offset_extended_sf: r6065 \(dpc\) at cfa\+7876 + DW_CFA_offset_extended_sf: r6066 \(dscratch\) at cfa\+7880 + DW_CFA_offset_extended_sf: r4608 \(hstatus\) at cfa\+2048 + DW_CFA_offset_extended_sf: r4610 \(hedeleg\) at cfa\+2056 + DW_CFA_offset_extended_sf: r4611 \(hideleg\) at cfa\+2060 + DW_CFA_offset_extended_sf: r4612 \(hie\) at cfa\+2064 + DW_CFA_offset_extended_sf: r4613 \(htvec\) at cfa\+2068 + DW_CFA_offset_extended_sf: r4672 \(hscratch\) at cfa\+2304 + DW_CFA_offset_extended_sf: r4673 \(hepc\) at cfa\+2308 + DW_CFA_offset_extended_sf: r4674 \(hcause\) at cfa\+2312 + DW_CFA_offset_extended_sf: r4675 \(hbadaddr\) at cfa\+2316 + DW_CFA_offset_extended_sf: r4676 \(hip\) at cfa\+2320 + DW_CFA_offset_extended_sf: r4992 \(mbase\) at cfa\+3584 + DW_CFA_offset_extended_sf: r4993 \(mbound\) at cfa\+3588 + DW_CFA_offset_extended_sf: r4994 \(mibase\) at cfa\+3592 + DW_CFA_offset_extended_sf: r4995 \(mibound\) at cfa\+3596 + DW_CFA_offset_extended_sf: r4996 \(mdbase\) at cfa\+3600 + DW_CFA_offset_extended_sf: r4997 \(mdbound\) at cfa\+3604 + DW_CFA_offset_extended_sf: r4896 \(mucounteren\) at cfa\+3200 + DW_CFA_offset_extended_sf: r4897 \(mscounteren\) at cfa\+3204 + DW_CFA_offset_extended_sf: r4898 \(mhcounteren\) at cfa\+3208 + DW_CFA_offset_extended_sf: r4163 \(utval\) at cfa\+268 + DW_CFA_offset_extended_sf: r4419 \(stval\) at cfa\+1292 + DW_CFA_offset_extended_sf: r4480 \(satp\) at cfa\+1536 + DW_CFA_offset_extended_sf: r4931 \(mtval\) at cfa\+3340 + DW_CFA_nop +#... diff --git a/gas/testsuite/gas/riscv/csr-dw-regnums.s b/gas/testsuite/gas/riscv/csr-dw-regnums.s new file mode 100644 index 00000000000..b29e9da96e7 --- /dev/null +++ b/gas/testsuite/gas/riscv/csr-dw-regnums.s @@ -0,0 +1,255 @@ +# Check that CFI directives can accept all of the CSR names (including +# aliases). The results for this test also ensures that the DWARF +# register numbers for the CSRs shouldn't change. + + .text + .global _start +_start: + .cfi_startproc + nop + .cfi_offset ustatus, 0 + .cfi_offset uie, 16 + .cfi_offset utvec, 20 + .cfi_offset uscratch, 256 + .cfi_offset uepc, 260 + .cfi_offset ucause, 264 + .cfi_offset utval, 268 + .cfi_offset uip, 272 + .cfi_offset fflags, 4 + .cfi_offset frm, 8 + .cfi_offset fcsr, 12 + .cfi_offset cycle, 12288 + .cfi_offset time, 12292 + .cfi_offset instret, 12296 + .cfi_offset hpmcounter3, 12300 + .cfi_offset hpmcounter4, 12304 + .cfi_offset hpmcounter5, 12308 + .cfi_offset hpmcounter6, 12312 + .cfi_offset hpmcounter7, 12316 + .cfi_offset hpmcounter8, 12320 + .cfi_offset hpmcounter9, 12324 + .cfi_offset hpmcounter10, 12328 + .cfi_offset hpmcounter11, 12332 + .cfi_offset hpmcounter12, 12336 + .cfi_offset hpmcounter13, 12340 + .cfi_offset hpmcounter14, 12344 + .cfi_offset hpmcounter15, 12348 + .cfi_offset hpmcounter16, 12352 + .cfi_offset hpmcounter17, 12356 + .cfi_offset hpmcounter18, 12360 + .cfi_offset hpmcounter19, 12364 + .cfi_offset hpmcounter20, 12368 + .cfi_offset hpmcounter21, 12372 + .cfi_offset hpmcounter22, 12376 + .cfi_offset hpmcounter23, 12380 + .cfi_offset hpmcounter24, 12384 + .cfi_offset hpmcounter25, 12388 + .cfi_offset hpmcounter26, 12392 + .cfi_offset hpmcounter27, 12396 + .cfi_offset hpmcounter28, 12400 + .cfi_offset hpmcounter29, 12404 + .cfi_offset hpmcounter30, 12408 + .cfi_offset hpmcounter31, 12412 + .cfi_offset cycleh, 12800 + .cfi_offset timeh, 12804 + .cfi_offset instreth, 12808 + .cfi_offset hpmcounter3h, 12812 + .cfi_offset hpmcounter4h, 12816 + .cfi_offset hpmcounter5h, 12820 + .cfi_offset hpmcounter6h, 12824 + .cfi_offset hpmcounter7h, 12828 + .cfi_offset hpmcounter8h, 12832 + .cfi_offset hpmcounter9h, 12836 + .cfi_offset hpmcounter10h, 12840 + .cfi_offset hpmcounter11h, 12844 + .cfi_offset hpmcounter12h, 12848 + .cfi_offset hpmcounter13h, 12852 + .cfi_offset hpmcounter14h, 12856 + .cfi_offset hpmcounter15h, 12860 + .cfi_offset hpmcounter16h, 12864 + .cfi_offset hpmcounter17h, 12868 + .cfi_offset hpmcounter18h, 12872 + .cfi_offset hpmcounter19h, 12876 + .cfi_offset hpmcounter20h, 12880 + .cfi_offset hpmcounter21h, 12884 + .cfi_offset hpmcounter22h, 12888 + .cfi_offset hpmcounter23h, 12892 + .cfi_offset hpmcounter24h, 12896 + .cfi_offset hpmcounter25h, 12900 + .cfi_offset hpmcounter26h, 12904 + .cfi_offset hpmcounter27h, 12908 + .cfi_offset hpmcounter28h, 12912 + .cfi_offset hpmcounter29h, 12916 + .cfi_offset hpmcounter30h, 12920 + .cfi_offset hpmcounter31h, 12924 + .cfi_offset sstatus, 1024 + .cfi_offset sedeleg, 1032 + .cfi_offset sideleg, 1036 + .cfi_offset sie, 1040 + .cfi_offset stvec, 1044 + .cfi_offset scounteren, 1048 + .cfi_offset sscratch, 1280 + .cfi_offset sepc, 1284 + .cfi_offset scause, 1288 + .cfi_offset stval, 1292 + .cfi_offset sip, 1296 + .cfi_offset satp, 1536 + .cfi_offset mvendorid, 15428 + .cfi_offset marchid, 15432 + .cfi_offset mimpid, 15436 + .cfi_offset mhartid, 15440 + .cfi_offset mstatus, 3072 + .cfi_offset misa, 3076 + .cfi_offset medeleg, 3080 + .cfi_offset mideleg, 3084 + .cfi_offset mie, 3088 + .cfi_offset mtvec, 3092 + .cfi_offset mcounteren, 3096 + .cfi_offset mscratch, 3328 + .cfi_offset mepc, 3332 + .cfi_offset mcause, 3336 + .cfi_offset mtval, 3340 + .cfi_offset mip, 3344 + .cfi_offset pmpcfg0, 3712 + .cfi_offset pmpcfg1, 3716 + .cfi_offset pmpcfg2, 3720 + .cfi_offset pmpcfg3, 3724 + .cfi_offset pmpaddr0, 3776 + .cfi_offset pmpaddr1, 3780 + .cfi_offset pmpaddr2, 3784 + .cfi_offset pmpaddr3, 3788 + .cfi_offset pmpaddr4, 3792 + .cfi_offset pmpaddr5, 3796 + .cfi_offset pmpaddr6, 3800 + .cfi_offset pmpaddr7, 3804 + .cfi_offset pmpaddr8, 3808 + .cfi_offset pmpaddr9, 3812 + .cfi_offset pmpaddr10, 3816 + .cfi_offset pmpaddr11, 3820 + .cfi_offset pmpaddr12, 3824 + .cfi_offset pmpaddr13, 3828 + .cfi_offset pmpaddr14, 3832 + .cfi_offset pmpaddr15, 3836 + .cfi_offset mcycle, 11264 + .cfi_offset minstret, 11272 + .cfi_offset mhpmcounter3, 11276 + .cfi_offset mhpmcounter4, 11280 + .cfi_offset mhpmcounter5, 11284 + .cfi_offset mhpmcounter6, 11288 + .cfi_offset mhpmcounter7, 11292 + .cfi_offset mhpmcounter8, 11296 + .cfi_offset mhpmcounter9, 11300 + .cfi_offset mhpmcounter10, 11304 + .cfi_offset mhpmcounter11, 11308 + .cfi_offset mhpmcounter12, 11312 + .cfi_offset mhpmcounter13, 11316 + .cfi_offset mhpmcounter14, 11320 + .cfi_offset mhpmcounter15, 11324 + .cfi_offset mhpmcounter16, 11328 + .cfi_offset mhpmcounter17, 11332 + .cfi_offset mhpmcounter18, 11336 + .cfi_offset mhpmcounter19, 11340 + .cfi_offset mhpmcounter20, 11344 + .cfi_offset mhpmcounter21, 11348 + .cfi_offset mhpmcounter22, 11352 + .cfi_offset mhpmcounter23, 11356 + .cfi_offset mhpmcounter24, 11360 + .cfi_offset mhpmcounter25, 11364 + .cfi_offset mhpmcounter26, 11368 + .cfi_offset mhpmcounter27, 11372 + .cfi_offset mhpmcounter28, 11376 + .cfi_offset mhpmcounter29, 11380 + .cfi_offset mhpmcounter30, 11384 + .cfi_offset mhpmcounter31, 11388 + .cfi_offset mcycleh, 11776 + .cfi_offset minstreth, 11784 + .cfi_offset mhpmcounter3h, 11788 + .cfi_offset mhpmcounter4h, 11792 + .cfi_offset mhpmcounter5h, 11796 + .cfi_offset mhpmcounter6h, 11800 + .cfi_offset mhpmcounter7h, 11804 + .cfi_offset mhpmcounter8h, 11808 + .cfi_offset mhpmcounter9h, 11812 + .cfi_offset mhpmcounter10h, 11816 + .cfi_offset mhpmcounter11h, 11820 + .cfi_offset mhpmcounter12h, 11824 + .cfi_offset mhpmcounter13h, 11828 + .cfi_offset mhpmcounter14h, 11832 + .cfi_offset mhpmcounter15h, 11836 + .cfi_offset mhpmcounter16h, 11840 + .cfi_offset mhpmcounter17h, 11844 + .cfi_offset mhpmcounter18h, 11848 + .cfi_offset mhpmcounter19h, 11852 + .cfi_offset mhpmcounter20h, 11856 + .cfi_offset mhpmcounter21h, 11860 + .cfi_offset mhpmcounter22h, 11864 + .cfi_offset mhpmcounter23h, 11868 + .cfi_offset mhpmcounter24h, 11872 + .cfi_offset mhpmcounter25h, 11876 + .cfi_offset mhpmcounter26h, 11880 + .cfi_offset mhpmcounter27h, 11884 + .cfi_offset mhpmcounter28h, 11888 + .cfi_offset mhpmcounter29h, 11892 + .cfi_offset mhpmcounter30h, 11896 + .cfi_offset mhpmcounter31h, 11900 + .cfi_offset mhpmevent3, 3212 + .cfi_offset mhpmevent4, 3216 + .cfi_offset mhpmevent5, 3220 + .cfi_offset mhpmevent6, 3224 + .cfi_offset mhpmevent7, 3228 + .cfi_offset mhpmevent8, 3232 + .cfi_offset mhpmevent9, 3236 + .cfi_offset mhpmevent10, 3240 + .cfi_offset mhpmevent11, 3244 + .cfi_offset mhpmevent12, 3248 + .cfi_offset mhpmevent13, 3252 + .cfi_offset mhpmevent14, 3256 + .cfi_offset mhpmevent15, 3260 + .cfi_offset mhpmevent16, 3264 + .cfi_offset mhpmevent17, 3268 + .cfi_offset mhpmevent18, 3272 + .cfi_offset mhpmevent19, 3276 + .cfi_offset mhpmevent20, 3280 + .cfi_offset mhpmevent21, 3284 + .cfi_offset mhpmevent22, 3288 + .cfi_offset mhpmevent23, 3292 + .cfi_offset mhpmevent24, 3296 + .cfi_offset mhpmevent25, 3300 + .cfi_offset mhpmevent26, 3304 + .cfi_offset mhpmevent27, 3308 + .cfi_offset mhpmevent28, 3312 + .cfi_offset mhpmevent29, 3316 + .cfi_offset mhpmevent30, 3320 + .cfi_offset mhpmevent31, 3324 + .cfi_offset tselect, 7808 + .cfi_offset tdata1, 7812 + .cfi_offset tdata2, 7816 + .cfi_offset tdata3, 7820 + .cfi_offset dcsr, 7872 + .cfi_offset dpc, 7876 + .cfi_offset dscratch, 7880 + .cfi_offset hstatus, 2048 + .cfi_offset hedeleg, 2056 + .cfi_offset hideleg, 2060 + .cfi_offset hie, 2064 + .cfi_offset htvec, 2068 + .cfi_offset hscratch, 2304 + .cfi_offset hepc, 2308 + .cfi_offset hcause, 2312 + .cfi_offset hbadaddr, 2316 + .cfi_offset hip, 2320 + .cfi_offset mbase, 3584 + .cfi_offset mbound, 3588 + .cfi_offset mibase, 3592 + .cfi_offset mibound, 3596 + .cfi_offset mdbase, 3600 + .cfi_offset mdbound, 3604 + .cfi_offset mucounteren, 3200 + .cfi_offset mscounteren, 3204 + .cfi_offset mhcounteren, 3208 + .cfi_offset ubadaddr, 268 + .cfi_offset sbadaddr, 1292 + .cfi_offset sptbr, 1536 + .cfi_offset mbadaddr, 3340 + nop + .cfi_endproc -- 2.39.2