[llvm] [GlobalISel] Add Saturated Truncate Instructions (PR #147526)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 08:30:45 PDT 2025
================
@@ -809,6 +809,48 @@ class LLVM_ABI MachineIRBuilder {
MachineInstrBuilder buildZExtInReg(const DstOp &Res, const SrcOp &Op,
int64_t ImmOp);
+ /// Build and insert \p Res = \p G_TRUNC_SSAT_S \p Op
+ ///
+ /// G_TRUNC_SSAT_S truncates the saturated signed input, \p Op, to a signed
+ /// result.
+ /// ///
+ /// \pre setBasicBlock or setMI must have been called.
+ /// \pre \p Res must be a generic virtual register with scalar or vector type.
+ /// \pre \p Op must be a generic virtual register with scalar or vector type.
+ ///
+ /// \return The newly created instruction.
+ MachineInstrBuilder buildTruncSSatS(const DstOp &Res, const SrcOp &Op) {
+ return buildInstr(TargetOpcode::G_TRUNC_SSAT_S, {Res}, {Op});
+ }
+
+ /// Build and insert \p Res = \p G_TRUNC_SSAT_U \p Op
+ ///
+ /// G_TRUNC_SSAT_U truncates the saturated signed input, \p Op, to a unsigned
+ /// result.
+ /// ///
+ /// \pre setBasicBlock or setMI must have been called.
+ /// \pre \p Res must be a generic virtual register with scalar or vector type.
+ /// \pre \p Op must be a generic virtual register with scalar or vector type.
+ ///
+ /// \return The newly created instruction.
+ MachineInstrBuilder buildTruncSSatU(const DstOp &Res, const SrcOp &Op) {
+ return buildInstr(TargetOpcode::G_TRUNC_SSAT_U, {Res}, {Op});
+ }
+
+ /// Build and insert \p Res = \p G_TRUNC_USAT_U \p Op
+ ///
+ /// G_TRUNC_SSAT_S truncates the saturated unsigned input, \p Op, to a
+ /// unsigned result.
+ /// ///
----------------
davemgreen wrote:
Yeah it was the second ones in that I wasn't sure of, it might have meant something special to the output doxygen. As they are not on all the other functions we could remove them and see if anyone complains. It looks like a mistaken formatting gone awry.
https://github.com/llvm/llvm-project/pull/147526
More information about the llvm-commits
mailing list