Allow target to handle STRICT floating-point nodes
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 5 Jun 2019 22:33:10 +0000 (22:33 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 5 Jun 2019 22:33:10 +0000 (22:33 +0000)
commit6c5d5ce5517b12420f2717ae660a8929a41dda26
tree27bc52a7bc1a93a6faea035d91da35d41186069c
parent2f94203e23dee0e1a2ffb18030ea32cd44e3b25f
Allow target to handle STRICT floating-point nodes

The ISD::STRICT_ nodes used to implement the constrained floating-point
intrinsics are currently never passed to the target back-end, which makes
it impossible to handle them correctly (e.g. mark instructions are depending
on a floating-point status and control register, or mark instructions as
possibly trapping).

This patch allows the target to use setOperationAction to switch the action
on ISD::STRICT_ nodes to Legal. If this is done, the SelectionDAG common code
will stop converting the STRICT nodes to regular floating-point nodes, but
instead pass the STRICT nodes to the target using normal SelectionDAG
matching rules.

To avoid having the back-end duplicate all the floating-point instruction
patterns to handle both strict and non-strict variants, we make the MI
codegen explicitly aware of the floating-point exceptions by introducing
two new concepts:

- A new MCID flag "mayRaiseFPException" that the target should set on any
  instruction that possibly can raise FP exception according to the
  architecture definition.
- A new MI flag FPExcept that CodeGen/SelectionDAG will set on any MI
  instruction resulting from expansion of any constrained FP intrinsic.

Any MI instruction that is *both* marked as mayRaiseFPException *and*
FPExcept then needs to be considered as raising exceptions by MI-level
codegen (e.g. scheduling).

Setting those two new flags is straightforward. The mayRaiseFPException
flag is simply set via TableGen by marking all relevant instruction
patterns in the .td files.

The FPExcept flag is set in SDNodeFlags when creating the STRICT_ nodes
in the SelectionDAG, and gets inherited in the MachineSDNode nodes created
from it during instruction selection. The flag is then transfered to an
MIFlag when creating the MI from the MachineSDNode. This is handled just
like fast-math flags like no-nans are handled today.

This patch includes both common code changes required to implement the
new features, and the SystemZ implementation.

Reviewed By: andrew.w.kaylor

Differential Revision: https://reviews.llvm.org/D55506

llvm-svn: 362663
82 files changed:
llvm/include/llvm/CodeGen/MachineInstr.h
llvm/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/include/llvm/MC/MCInstrDesc.h
llvm/include/llvm/Target/Target.td
llvm/include/llvm/Target/TargetSelectionDAG.td
llvm/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/lib/CodeGen/ImplicitNullChecks.cpp
llvm/lib/CodeGen/MIRParser/MILexer.cpp
llvm/lib/CodeGen/MIRParser/MILexer.h
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/CodeGen/MIRPrinter.cpp
llvm/lib/CodeGen/MachineCSE.cpp
llvm/lib/CodeGen/MachineInstr.cpp
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/lib/CodeGen/PeepholeOptimizer.cpp
llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/lib/CodeGen/TargetInstrInfo.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZInstrFP.td
llvm/lib/Target/SystemZ/SystemZInstrVector.td
llvm/lib/Target/SystemZ/SystemZOperators.td
llvm/test/CodeGen/SystemZ/fp-strict-add-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-add-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-add-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-add-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-alias.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-conv-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-conv-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-conv-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-conv-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-conv-15.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-div-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-div-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-div-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-div-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-05.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-06.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-07.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-08.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-09.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-10.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-mul-11.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-round-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-round-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-round-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sqrt-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sqrt-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sqrt-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sqrt-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sub-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sub-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sub-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/fp-strict-sub-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-add-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-add-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-div-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-div-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-max-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-min-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-mul-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-mul-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-mul-03.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-mul-04.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-mul-05.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-round-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-round-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-sqrt-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-sqrt-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-sub-01.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vec-strict-sub-02.ll [new file with mode: 0644]
llvm/test/CodeGen/SystemZ/vector-constrained-fp-intrinsics.ll
llvm/utils/TableGen/CodeGenInstruction.cpp
llvm/utils/TableGen/CodeGenInstruction.h
llvm/utils/TableGen/InstrInfoEmitter.cpp