Skip to content

Commit 95fd54a

Browse files
committed
UNRATIFIED RISC-V: Add 'Zicfilp' extension
[DO NOT MERGE] Until the 'Zicfilp' extension is frozen/ratified and final version number is determined, this patch should not be merged upstream. This commit uses unratified version 0.1 as in the documentation (instead of possible 1.0 after ratification). This commit adds RISC-V Landing Pads extension (Zicfilp) based on the document version 0.1 (latest git revision): <riscv/riscv-cfi@c6a8311> **Important Note** The "lpad" instruction requires 4-byte alignment to complete without exceptions but this is not currently enforced by the assembler. bfd/ChangeLog: * elfxx-riscv.c (riscv_supported_std_z_ext): Add 'Zicfilp' extension to valid 'Z' extension list. (riscv_multi_subset_supports): Support new instruction class. (riscv_multi_subset_supports_ext): Likewise. gas/ChangeLog: * testsuite/gas/riscv/zicfilp.s: New test. * testsuite/gas/riscv/zicfilp.d: Likewise. include/ChangeLog: * opcode/riscv-opc.h (MATCH_LPAD, MASK_LPAD): New. * opcode/riscv.h (enum riscv_insn_class): Add new instruction class INSN_CLASS_ZICFILP. opcodes/ChangeLog: * riscv-opc.c (riscv_opcodes): Although not strictly a hint, add "lpad" to the list of standard hints because of its encoding.
1 parent 8d20a38 commit 95fd54a

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

bfd/elfxx-riscv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12561256
{"zicbom", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12571257
{"zicbop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12581258
{"zicboz", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1259+
{"zicfilp", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
12591260
{"zicfiss", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
12601261
{"zicond", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12611262
{"zicsr", ISA_SPEC_CLASS_20191213, 2, 0, 0 },
@@ -2395,6 +2396,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
23952396
return riscv_subset_supports (rps, "zicbop");
23962397
case INSN_CLASS_ZICBOZ:
23972398
return riscv_subset_supports (rps, "zicboz");
2399+
case INSN_CLASS_ZICFILP:
2400+
return riscv_subset_supports (rps, "zicfilp");
23982401
case INSN_CLASS_ZICFISS:
23992402
return riscv_subset_supports (rps, "zicfiss");
24002403
case INSN_CLASS_ZICOND:
@@ -2594,6 +2597,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
25942597
return "zicbop";
25952598
case INSN_CLASS_ZICBOZ:
25962599
return "zicboz";
2600+
case INSN_CLASS_ZICFILP:
2601+
return "zicfilp";
25972602
case INSN_CLASS_ZICFISS:
25982603
return "zicfiss";
25992604
case INSN_CLASS_ZICOND:

gas/testsuite/gas/riscv/zicfilp.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#as: -march=rv32ic_zicfilp
2+
#objdump: -d
3+
4+
.*:[ ]+file format .*
5+
6+
Disassembly of section .text:
7+
8+
0+000 <target>:
9+
[ ]+[0-9a-f]+:[ ]+12345017[ ]+lpad[ ]+0x12345
10+
[ ]+[0-9a-f]+:[ ]+12345017[ ]+lpad[ ]+0x12345
11+
[ ]+[0-9a-f]+:[ ]+0001[ ]+nop
12+
[ ]+[0-9a-f]+:[ ]+f0123017[ ]+lpad[ ]+0xf0123
13+
[ ]+[0-9a-f]+:[ ]+f0123017[ ]+lpad[ ]+0xf0123

gas/testsuite/gas/riscv/zicfilp.s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
target:
2+
# lpad LPL == auipc x0, LPL
3+
lpad 0x12345
4+
auipc zero, 0x12345
5+
6+
# Break alignment:
7+
#
8+
# Unaligned lpad causes illegal-instruction exception
9+
# but must be disassembled (since alignment checking is a part of
10+
# the lpad instruction operations).
11+
c.nop
12+
13+
lpad 0xf0123
14+
auipc zero, 0xf0123

include/opcode/riscv-opc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,9 @@
23792379
#define MASK_MOP_RR_6 0xfe00707f
23802380
#define MATCH_MOP_RR_7 0xce004073
23812381
#define MASK_MOP_RR_7 0xfe00707f
2382+
/* Zicfilp instructions. */
2383+
#define MATCH_LPAD 0x00000017
2384+
#define MASK_LPAD 0x00000fff
23822385
/* Zicfiss instructions. */
23832386
#define MATCH_SSLOAD 0x81c04073
23842387
#define MASK_SSLOAD 0xfffff07f

include/opcode/riscv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ enum riscv_insn_class
441441
INSN_CLASS_ZICBOM,
442442
INSN_CLASS_ZICBOP,
443443
INSN_CLASS_ZICBOZ,
444+
INSN_CLASS_ZICFILP,
444445
INSN_CLASS_ZICFISS,
445446
INSN_CLASS_H,
446447
INSN_CLASS_XTHEADBA,

opcodes/riscv-opc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ const struct riscv_opcode riscv_opcodes[] =
368368
{"prefetch.r", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_R, MASK_PREFETCH_R, match_opcode, 0 },
369369
{"prefetch.w", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_W, MASK_PREFETCH_W, match_opcode, 0 },
370370
{"pause", 0, INSN_CLASS_ZIHINTPAUSE, "", MATCH_PAUSE, MASK_PAUSE, match_opcode, 0 },
371+
{"lpad", 0, INSN_CLASS_ZICFILP, "u", MATCH_LPAD, MASK_LPAD, match_opcode, 0 },
371372

372373
/* Standard "May Be Ops" (and compressed aliases). */
373374
{"ssload", 0, INSN_CLASS_ZICFISS, "d", MATCH_SSLOAD, MASK_SSLOAD, match_rd_eq_1_or_5, INSN_DREF },

0 commit comments

Comments
 (0)