[llvm] [GlobalISel] Add Saturated Truncate Instructions (PR #147526)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 08:26:41 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.
+ /// ///
----------------
arsenm wrote:
The leading ones are doxygen, the second one in from that I'm not sure
https://github.com/llvm/llvm-project/pull/147526
More information about the llvm-commits
mailing list