Skip to content
Open
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
37 changes: 37 additions & 0 deletions llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,43 @@ class LegalizerHelper {
LLT HalfTy,
LLT ShiftAmtTy);

/// Multi-way shift legalization: directly split wide shifts into target-sized
/// parts in a single step, avoiding recursive binary splitting.
LLVM_ABI LegalizeResult narrowScalarShiftMultiway(MachineInstr &MI,
LLT TargetTy);

/// Optimized path for constant shift amounts using static indexing.
/// Directly calculates which source parts contribute to each output part
/// without generating runtime select chains.
LLVM_ABI LegalizeResult narrowScalarShiftByConstantMultiway(MachineInstr &MI,
const APInt &Amt,
LLT TargetTy,
LLT ShiftAmtTy);

struct ShiftParams {
Register WordShift; // Number of complete words to shift
Register BitShift; // Number of bits to shift within words
Register InvBitShift; // Complement bit shift (TargetBits - BitShift)
Register Zero; // Zero constant for SHL/LSHR fill
Register SignBit; // Sign extension value for ASHR fill
};

/// Generates a single output part for constant shifts using direct indexing.
/// Calculates which source parts contribute and how they're combined.
LLVM_ABI Register buildConstantShiftPart(unsigned Opcode, unsigned PartIdx,
unsigned NumParts,
ArrayRef<Register> SrcParts,
const ShiftParams &Params,
LLT TargetTy, LLT ShiftAmtTy);

/// Generates a shift part with carry for variable shifts.
/// Combines main operand shifted by BitShift with carry bits from adjacent
/// operand.
LLVM_ABI Register buildVariableShiftPart(unsigned Opcode,
Register MainOperand,
Register ShiftAmt, LLT TargetTy,
Register CarryOperand = Register());

LLVM_ABI LegalizeResult fewerElementsVectorReductions(MachineInstr &MI,
unsigned TypeIdx,
LLT NarrowTy);
Expand Down
Loading