Skip to content

Commit b3a0d70

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 54183e9 commit b3a0d70

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 },
@@ -2396,6 +2397,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
23962397
return riscv_subset_supports (rps, "zicbop");
23972398
case INSN_CLASS_ZICBOZ:
23982399
return riscv_subset_supports (rps, "zicboz");
2400+
case INSN_CLASS_ZICFILP:
2401+
return riscv_subset_supports (rps, "zicfilp");
23992402
case INSN_CLASS_ZICFISS:
24002403
return riscv_subset_supports (rps, "zicfiss");
24012404
case INSN_CLASS_ZICOND:
@@ -2605,6 +2608,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
26052608
return "zicbop";
26062609
case INSN_CLASS_ZICBOZ:
26072610
return "zicboz";
2611+
case INSN_CLASS_ZICFILP:
2612+
return "zicfilp";
26082613
case INSN_CLASS_ZICFISS:
26092614
return "zicfiss";
26102615
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
@@ -2396,6 +2396,9 @@
23962396
#define MASK_MOP_RR_6 0xfe00707f
23972397
#define MATCH_MOP_RR_7 0xce004073
23982398
#define MASK_MOP_RR_7 0xfe00707f
2399+
/* Zicfilp instructions. */
2400+
#define MATCH_LPAD 0x00000017
2401+
#define MASK_LPAD 0x00000fff
23992402
/* Zicfiss instructions. */
24002403
#define MATCH_SSLOAD 0x81c04073
24012404
#define MASK_SSLOAD 0xfffff07f

include/opcode/riscv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ enum riscv_insn_class
444444
INSN_CLASS_ZICBOM,
445445
INSN_CLASS_ZICBOP,
446446
INSN_CLASS_ZICBOZ,
447+
INSN_CLASS_ZICFILP,
447448
INSN_CLASS_ZICFISS,
448449
INSN_CLASS_H,
449450
INSN_CLASS_XTHEADBA,

opcodes/riscv-opc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ const struct riscv_opcode riscv_opcodes[] =
380380
{"c.ntl.s1", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_S1, MASK_C_NTL_S1, match_opcode, 0 },
381381
{"c.ntl.all", 0, INSN_CLASS_ZIHINTNTL_AND_C, "", MATCH_C_NTL_ALL, MASK_C_NTL_ALL, match_opcode, 0 },
382382
{"pause", 0, INSN_CLASS_ZIHINTPAUSE, "", MATCH_PAUSE, MASK_PAUSE, match_opcode, 0 },
383+
{"lpad", 0, INSN_CLASS_ZICFILP, "u", MATCH_LPAD, MASK_LPAD, match_opcode, 0 },
383384

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

0 commit comments

Comments
 (0)