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

[snippy]: Randomize rounding modes for OPERAND_FRMARG #153

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# RUN: llvm-snippy %s | FileCheck %s

include:
- ../Inputs/sections.yaml
options:
march: riscv64-unknown-elf
mcpu: generic-rv64
mattr: "+f"
num-instrs: 200
dump-mf: true
histogram:
- [FADD_S, 1.0]

# COM: RNE - 0b000
# COM: RTZ - 0b001
# COM: RDN - 0b010
# COM: RUP - 0b011
# COM: RMM - 0b100

# CHECK-DAG: [[REG:\$f[[:digit:]]+_f]] = FADD_S {{.*}}, 0
# CHECK-DAG: [[REG:\$f[[:digit:]]+_f]] = FADD_S {{.*}}, 1
# CHECK-DAG: [[REG:\$f[[:digit:]]+_f]] = FADD_S {{.*}}, 2
# CHECK-DAG: [[REG:\$f[[:digit:]]+_f]] = FADD_S {{.*}}, 3
# CHECK-DAG: [[REG:\$f[[:digit:]]+_f]] = FADD_S {{.*}}, 4
17 changes: 15 additions & 2 deletions llvm/tools/llvm-snippy/lib/Target/RISCV/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2486,8 +2486,21 @@ class SnippyRISCVTarget final : public SnippyTarget {
snippy::fatal("AVL operand generation is not supported. Probably "
"snippy still does "
"not support vector instructions generation.");
case RISCVOp::OPERAND_FRMARG:
return MachineOperand::CreateImm(0);
case RISCVOp::OPERAND_FRMARG: {
// Floating-point operations use either a static rounding mode encoded in
// the instruction, or a dynamic rounding mode held in frm.
// 000 - RNE (Round to Nearest, ties to Even)
// 001 - RTZ (Round towards Zero)
// 010 - RDN (Round Down)
// 011 - RUP (Round Up)
// 100 - RMM (Round to Nearest, ties to Max Magnitude)
// 101 - <reserved>
// 110 - <reserved>
// 111 - DYN (In instruction’s rm field, selects dynamic rounding mode)
using namespace RISCVFPRndMode;
return MachineOperand::CreateImm(
snippy::selectFrom(RNE, RTZ, RDN, RUP, RMM));
}
}
}

Expand Down
Loading