Skip to content

Commit f13b6a7

Browse files
author
Jessica Paquette
committed
[GlobalISel] Add a G_FNEARBYINT opcode
For eventually selecting llvm.nearbyint. Equivalent to the SelectionDAG nearbyint node. Update legalizer-info-validation.mir. Differential Revision: https://reviews.llvm.org/D60921 llvm-svn: 359201
1 parent 2f9ef33 commit f13b6a7

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

llvm/include/llvm/Support/TargetOpcodes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ HANDLE_TARGET_OPCODE(G_FFLOOR)
539539
/// Floating point round to next integer.
540540
HANDLE_TARGET_OPCODE(G_FRINT)
541541

542+
/// Floating point round to nearest integer.
543+
HANDLE_TARGET_OPCODE(G_FNEARBYINT)
544+
542545
/// Generic AddressSpaceCast.
543546
HANDLE_TARGET_OPCODE(G_ADDRSPACE_CAST)
544547

llvm/include/llvm/Target/GenericOpcodes.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,13 @@ def G_FRINT : GenericInstruction {
599599
let hasSideEffects = 0;
600600
}
601601

602+
// Floating point round to the nearest integer.
603+
def G_FNEARBYINT : GenericInstruction {
604+
let OutOperandList = (outs type0:$dst);
605+
let InOperandList = (ins type0:$src1);
606+
let hasSideEffects = 0;
607+
}
608+
602609
//------------------------------------------------------------------------------
603610
// Opcodes for LLVM Intrinsics
604611
//------------------------------------------------------------------------------

llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def : GINodeEquiv<G_FABS, fabs>;
9696
def : GINodeEquiv<G_FSQRT, fsqrt>;
9797
def : GINodeEquiv<G_FFLOOR, ffloor>;
9898
def : GINodeEquiv<G_FRINT, frint>;
99+
def : GINodeEquiv<G_FNEARBYINT, fnearbyint>;
99100

100101
// Broadly speaking G_LOAD is equivalent to ISD::LOAD but there are some
101102
// complications that tablegen must take care of. For example, Predicates such

llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@
350350
#
351351
# DEBUG-NEXT: G_FRINT (opcode {{[0-9]+}}): 1 type index
352352
# DEBUG: .. type index coverage check SKIPPED: user-defined predicate detected
353+
#
354+
# DEBUG-NEXT: G_FNEARBYINT (opcode {{[0-9]+}}): 1 type index
355+
# DEBUG: .. type index coverage check SKIPPED: no rules defined
353356

354357
# CHECK-NOT: ill-defined
355358

0 commit comments

Comments
 (0)