Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8297715: RISC-V: C2: Use single-bit instructions from the Zbs extension #21

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/hotspot/cpu/riscv/assembler_riscv.hpp
Original file line number Diff line number Diff line change
@@ -1943,7 +1943,7 @@ enum Nf {

// ====================================
// RISC-V Bit-Manipulation Extension
// Currently only support Zba and Zbb.
// Currently only support Zba, Zbb and Zbs bitmanip extensions.
// ====================================
#define INSN(NAME, op, funct3, funct7) \
void NAME(Register Rd, Register Rs1, Register Rs2) { \
@@ -2018,6 +2018,7 @@ enum Nf {

INSN(rori, 0b0010011, 0b101, 0b011000);
INSN(slli_uw, 0b0011011, 0b001, 0b000010);
INSN(bexti, 0b0010011, 0b101, 0b010010);

#undef INSN

1 change: 1 addition & 0 deletions src/hotspot/cpu/riscv/globals_riscv.hpp
Original file line number Diff line number Diff line change
@@ -105,6 +105,7 @@ define_pd_global(intx, InlineSmallCode, 1000);
experimental(bool, UseRVV, false, "Use RVV instructions") \
experimental(bool, UseZba, false, "Use Zba instructions") \
experimental(bool, UseZbb, false, "Use Zbb instructions") \
experimental(bool, UseZbs, false, "Use Zbs instructions") \
experimental(bool, UseRVC, false, "Use RVC instructions")

#endif // CPU_RISCV_GLOBALS_RISCV_HPP
8 changes: 8 additions & 0 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
@@ -2682,6 +2682,14 @@ operand immI_16bits()
interface(CONST_INTER);
%}

operand immIpowerOf2() %{
predicate(is_power_of_2((juint)(n->get_int())));
match(ConI);
op_cost(0);
format %{ %}
interface(CONST_INTER);
%}

// Long Immediate: low 32-bit mask
operand immL_32bits()
%{
15 changes: 15 additions & 0 deletions src/hotspot/cpu/riscv/riscv_b.ad
Original file line number Diff line number Diff line change
@@ -447,5 +447,20 @@ instruct ornL_reg_reg_b(iRegLNoSp dst, iRegL src1, iRegL src2, immL_M1 m1) %{
as_Register($src2$$reg));
%}

ins_pipe(ialu_reg_reg);

%}

// AndI 0b0..010..0 + ConvI2B
instruct convI2Bool_andI_reg_immIpowerOf2(iRegINoSp dst, iRegIorL2I src, immIpowerOf2 mask) %{
predicate(UseZbs);
match(Set dst (Conv2B (AndI src mask)));
ins_cost(ALU_COST);

format %{ "bexti $dst, $src, $mask\t#@convI2Bool_andI_reg_immIpowerOf2" %}
ins_encode %{
__ bexti($dst$$Register, $src$$Register, exact_log2((juint)($mask$$constant)));
%}

ins_pipe(ialu_reg_reg);
%}