Skip to content

Commit

Permalink
UNRATIFIED RISC-V: Add 'Zicfilp' extension
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
a4lg committed Aug 15, 2023
1 parent 8d20a38 commit 95fd54a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bfd/elfxx-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
{"zicbom", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"zicbop", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"zicboz", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"zicfilp", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
{"zicfiss", ISA_SPEC_CLASS_DRAFT, 0, 1, 0 },
{"zicond", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"zicsr", ISA_SPEC_CLASS_20191213, 2, 0, 0 },
Expand Down Expand Up @@ -2395,6 +2396,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
return riscv_subset_supports (rps, "zicbop");
case INSN_CLASS_ZICBOZ:
return riscv_subset_supports (rps, "zicboz");
case INSN_CLASS_ZICFILP:
return riscv_subset_supports (rps, "zicfilp");
case INSN_CLASS_ZICFISS:
return riscv_subset_supports (rps, "zicfiss");
case INSN_CLASS_ZICOND:
Expand Down Expand Up @@ -2594,6 +2597,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
return "zicbop";
case INSN_CLASS_ZICBOZ:
return "zicboz";
case INSN_CLASS_ZICFILP:
return "zicfilp";
case INSN_CLASS_ZICFISS:
return "zicfiss";
case INSN_CLASS_ZICOND:
Expand Down
13 changes: 13 additions & 0 deletions gas/testsuite/gas/riscv/zicfilp.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#as: -march=rv32ic_zicfilp
#objdump: -d

.*:[ ]+file format .*

Disassembly of section .text:

0+000 <target>:
[ ]+[0-9a-f]+:[ ]+12345017[ ]+lpad[ ]+0x12345
[ ]+[0-9a-f]+:[ ]+12345017[ ]+lpad[ ]+0x12345
[ ]+[0-9a-f]+:[ ]+0001[ ]+nop
[ ]+[0-9a-f]+:[ ]+f0123017[ ]+lpad[ ]+0xf0123
[ ]+[0-9a-f]+:[ ]+f0123017[ ]+lpad[ ]+0xf0123
14 changes: 14 additions & 0 deletions gas/testsuite/gas/riscv/zicfilp.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
target:
# lpad LPL == auipc x0, LPL
lpad 0x12345
auipc zero, 0x12345

# Break alignment:
#
# Unaligned lpad causes illegal-instruction exception
# but must be disassembled (since alignment checking is a part of
# the lpad instruction operations).
c.nop

lpad 0xf0123
auipc zero, 0xf0123
3 changes: 3 additions & 0 deletions include/opcode/riscv-opc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,9 @@
#define MASK_MOP_RR_6 0xfe00707f
#define MATCH_MOP_RR_7 0xce004073
#define MASK_MOP_RR_7 0xfe00707f
/* Zicfilp instructions. */
#define MATCH_LPAD 0x00000017
#define MASK_LPAD 0x00000fff
/* Zicfiss instructions. */
#define MATCH_SSLOAD 0x81c04073
#define MASK_SSLOAD 0xfffff07f
Expand Down
1 change: 1 addition & 0 deletions include/opcode/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ enum riscv_insn_class
INSN_CLASS_ZICBOM,
INSN_CLASS_ZICBOP,
INSN_CLASS_ZICBOZ,
INSN_CLASS_ZICFILP,
INSN_CLASS_ZICFISS,
INSN_CLASS_H,
INSN_CLASS_XTHEADBA,
Expand Down
1 change: 1 addition & 0 deletions opcodes/riscv-opc.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ const struct riscv_opcode riscv_opcodes[] =
{"prefetch.r", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_R, MASK_PREFETCH_R, match_opcode, 0 },
{"prefetch.w", 0, INSN_CLASS_ZICBOP, "Wif(s)", MATCH_PREFETCH_W, MASK_PREFETCH_W, match_opcode, 0 },
{"pause", 0, INSN_CLASS_ZIHINTPAUSE, "", MATCH_PAUSE, MASK_PAUSE, match_opcode, 0 },
{"lpad", 0, INSN_CLASS_ZICFILP, "u", MATCH_LPAD, MASK_LPAD, match_opcode, 0 },

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

0 comments on commit 95fd54a

Please sign in to comment.