[llvm] [NFC] Convert LoadExtActions to a map (PR #157627)
Sam Parker via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 9 01:37:00 PDT 2025
https://github.com/sparker-arm created https://github.com/llvm/llvm-project/pull/157627
So we can store actions per address space.
>From 55d4d05b73cbd8592aaf9c31aa7f06d73064f41d Mon Sep 17 00:00:00 2001
From: Sam Parker <sam.parker at arm.com>
Date: Tue, 9 Sep 2025 09:15:37 +0100
Subject: [PATCH 1/2] [NFC] clang-format TargetLowering.h
---
llvm/include/llvm/CodeGen/TargetLowering.h | 469 ++++++++++-----------
1 file changed, 213 insertions(+), 256 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 2ba8b29e775e0..42bdd85a1f4b9 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -200,11 +200,11 @@ class LLVM_ABI TargetLoweringBase {
/// This enum indicates whether operations are valid for a target, and if not,
/// what action should be used to make them valid.
enum LegalizeAction : uint8_t {
- Legal, // The target natively supports this operation.
- Promote, // This operation should be executed in a larger type.
- Expand, // Try to expand this to other ops, otherwise use a libcall.
- LibCall, // Don't try to expand this to other ops, always use a libcall.
- Custom // Use the LowerOperation hook to implement custom lowering.
+ Legal, // The target natively supports this operation.
+ Promote, // This operation should be executed in a larger type.
+ Expand, // Try to expand this to other ops, otherwise use a libcall.
+ LibCall, // Don't try to expand this to other ops, always use a libcall.
+ Custom // Use the LowerOperation hook to implement custom lowering.
};
/// This enum indicates whether a types are legal for a target, and if not,
@@ -220,13 +220,13 @@ class LLVM_ABI TargetLoweringBase {
TypeWidenVector, // This vector should be widened into a larger vector.
TypePromoteFloat, // Replace this float with a larger one.
TypeSoftPromoteHalf, // Soften half to i16 and use float to do arithmetic.
- TypeScalarizeScalableVector, // This action is explicitly left unimplemented.
- // While it is theoretically possible to
- // legalize operations on scalable types with a
- // loop that handles the vscale * #lanes of the
- // vector, this is non-trivial at SelectionDAG
- // level and these types are better to be
- // widened or promoted.
+ TypeScalarizeScalableVector, // This action is explicitly left
+ // unimplemented. While it is theoretically
+ // possible to legalize operations on scalable
+ // types with a loop that handles the vscale *
+ // #lanes of the vector, this is non-trivial at
+ // SelectionDAG level and these types are
+ // better to be widened or promoted.
};
/// LegalizeKind holds the legalization kind that needs to happen to EVT
@@ -235,18 +235,18 @@ class LLVM_ABI TargetLoweringBase {
/// Enum that describes how the target represents true/false values.
enum BooleanContent {
- UndefinedBooleanContent, // Only bit 0 counts, the rest can hold garbage.
- ZeroOrOneBooleanContent, // All bits zero except for bit 0.
+ UndefinedBooleanContent, // Only bit 0 counts, the rest can hold garbage.
+ ZeroOrOneBooleanContent, // All bits zero except for bit 0.
ZeroOrNegativeOneBooleanContent // All bits equal to bit 0.
};
/// Enum that describes what type of support for selects the target has.
enum SelectSupportKind {
- ScalarValSelect, // The target supports scalar selects (ex: cmov).
- ScalarCondVectorVal, // The target supports selects with a scalar condition
- // and vector values (ex: cmov).
- VectorMaskSelect // The target supports vector selects with a vector
- // mask (ex: x86 blends).
+ ScalarValSelect, // The target supports scalar selects (ex: cmov).
+ ScalarCondVectorVal, // The target supports selects with a scalar condition
+ // and vector values (ex: cmov).
+ VectorMaskSelect // The target supports vector selects with a vector
+ // mask (ex: x86 blends).
};
/// Enum that specifies what an atomic load/AtomicRMWInst is expanded
@@ -284,9 +284,9 @@ class LLVM_ABI TargetLoweringBase {
/// Enum that specifies when a float negation is beneficial.
enum class NegatibleCost {
- Cheaper = 0, // Negated expression is cheaper.
- Neutral = 1, // Negated expression has the same cost.
- Expensive = 2 // Negated expression is more expensive.
+ Cheaper = 0, // Negated expression is cheaper.
+ Neutral = 1, // Negated expression has the same cost.
+ Expensive = 2 // Negated expression is more expensive.
};
/// Enum of different potentially desirable ways to fold (and/or (setcc ...),
@@ -361,9 +361,7 @@ class LLVM_ABI TargetLoweringBase {
virtual ~TargetLoweringBase();
/// Return true if the target support strict float operation
- bool isStrictFPEnabled() const {
- return IsStrictFPEnabled;
- }
+ bool isStrictFPEnabled() const { return IsStrictFPEnabled; }
protected:
/// Initialize all of the actions to default values.
@@ -454,7 +452,8 @@ class LLVM_ABI TargetLoweringBase {
/// This callback is used to inspect load/store instructions and add
/// target-specific MachineMemOperand flags to them. The default
/// implementation does nothing.
- virtual MachineMemOperand::Flags getTargetMMOFlags(const Instruction &I) const {
+ virtual MachineMemOperand::Flags
+ getTargetMMOFlags(const Instruction &I) const {
return MachineMemOperand::MONone;
}
@@ -525,9 +524,7 @@ class LLVM_ABI TargetLoweringBase {
/// a constant pool load whose address depends on the select condition. The
/// parameter may be used to differentiate a select with FP compare from
/// integer compare.
- virtual bool reduceSelectOfFPConstantLoads(EVT CmpOpVT) const {
- return true;
- }
+ virtual bool reduceSelectOfFPConstantLoads(EVT CmpOpVT) const { return true; }
/// Does the target have multiple (allocatable) condition registers that
/// can be used to store the results of comparisons for use by selects
@@ -586,9 +583,7 @@ class LLVM_ABI TargetLoweringBase {
virtual bool isIntDivCheap(EVT VT, AttributeList Attr) const { return false; }
/// Return true if the target can handle a standalone remainder operation.
- virtual bool hasStandaloneRem(EVT VT) const {
- return true;
- }
+ virtual bool hasStandaloneRem(EVT VT) const { return true; }
/// Return true if SQRT(X) shouldn't be replaced with X*RSQRT(X).
virtual bool isFsqrtCheap(SDValue X, SelectionDAG &DAG) const {
@@ -597,11 +592,7 @@ class LLVM_ABI TargetLoweringBase {
}
/// Reciprocal estimate status values used by the functions below.
- enum ReciprocalEstimate : int {
- Unspecified = -1,
- Disabled = 0,
- Enabled = 1
- };
+ enum ReciprocalEstimate : int { Unspecified = -1, Disabled = 0, Enabled = 1 };
/// Return a ReciprocalEstimate enum value for a square root of the given type
/// based on the function's attributes. If the operation is not overridden by
@@ -720,9 +711,7 @@ class LLVM_ABI TargetLoweringBase {
/// Allow store merging for the specified type after legalization in addition
/// to before legalization. This may transform stores that do not exist
/// earlier (for example, stores created from intrinsics).
- virtual bool mergeStoresAfterLegalization(EVT MemVT) const {
- return true;
- }
+ virtual bool mergeStoresAfterLegalization(EVT MemVT) const { return true; }
/// Returns if it's reasonable to merge stores to MemVT size.
virtual bool canMergeStoresTo(unsigned AS, EVT MemVT,
@@ -731,19 +720,13 @@ class LLVM_ABI TargetLoweringBase {
}
/// Return true if it is cheap to speculate a call to intrinsic cttz.
- virtual bool isCheapToSpeculateCttz(Type *Ty) const {
- return false;
- }
+ virtual bool isCheapToSpeculateCttz(Type *Ty) const { return false; }
/// Return true if it is cheap to speculate a call to intrinsic ctlz.
- virtual bool isCheapToSpeculateCtlz(Type *Ty) const {
- return false;
- }
+ virtual bool isCheapToSpeculateCtlz(Type *Ty) const { return false; }
/// Return true if ctlz instruction is fast.
- virtual bool isCtlzFast() const {
- return false;
- }
+ virtual bool isCtlzFast() const { return false; }
/// Return true if ctpop instruction is fast.
virtual bool isCtpopFast(EVT VT) const {
@@ -796,9 +779,7 @@ class LLVM_ABI TargetLoweringBase {
/// This should be true when it takes more than one instruction to lower
/// setcc (cmp+set on x86 scalar), when bitwise ops are faster than logic on
/// condition bits (crand on PowerPC), and/or when reducing cmp+br is a win.
- virtual bool convertSetCCLogicToBitwiseLogic(EVT VT) const {
- return false;
- }
+ virtual bool convertSetCCLogicToBitwiseLogic(EVT VT) const { return false; }
/// Return the preferred operand type if the target has a quick way to compare
/// integer values of the given size. Assume that any legal integer type can
@@ -821,9 +802,7 @@ class LLVM_ABI TargetLoweringBase {
/// because a mask and compare of a single bit can be handled by inverting the
/// predicate, for example:
/// (X & 8) == 8 ---> (X & 8) != 0
- virtual bool hasAndNotCompare(SDValue Y) const {
- return false;
- }
+ virtual bool hasAndNotCompare(SDValue Y) const { return false; }
/// Return true if the target has a bitwise and-not operation:
/// X = ~A & B
@@ -952,9 +931,7 @@ class LLVM_ABI TargetLoweringBase {
// By default prefer folding (abs (sub nsw x, y)) -> abds(x, y). Some targets
// may want to avoid this to prevent loss of sub_nsw pattern.
- virtual bool preferABDSToABSWithNSW(EVT VT) const {
- return true;
- }
+ virtual bool preferABDSToABSWithNSW(EVT VT) const { return true; }
// Return true if the target wants to transform Op(Splat(X)) -> Splat(Op(X))
virtual bool preferScalarizeSplat(SDNode *N) const { return true; }
@@ -991,9 +968,7 @@ class LLVM_ABI TargetLoweringBase {
/// Return true if inserting a scalar into a variable element of an undef
/// vector is more efficiently handled by splatting the scalar instead.
- virtual bool shouldSplatInsEltVarIndex(EVT) const {
- return false;
- }
+ virtual bool shouldSplatInsEltVarIndex(EVT) const { return false; }
/// Return true if target always benefits from combining into FMA for a
/// given value type. This must typically return false on targets where FMA
@@ -1012,8 +987,7 @@ class LLVM_ABI TargetLoweringBase {
/// Return the ValueType for comparison libcalls. Comparison libcalls include
/// floating point comparison calls, and Ordered/Unordered check calls on
/// floating point numbers.
- virtual
- MVT::SimpleValueType getCmpLibcallReturnType() const;
+ virtual MVT::SimpleValueType getCmpLibcallReturnType() const;
/// For targets without i1 registers, this gives the nature of the high-bits
/// of boolean values held in types wider than i1.
@@ -1066,7 +1040,8 @@ class LLVM_ABI TargetLoweringBase {
/// Return the register class that should be used for the specified value
/// type.
- virtual const TargetRegisterClass *getRegClassFor(MVT VT, bool isDivergent = false) const {
+ virtual const TargetRegisterClass *
+ getRegClassFor(MVT VT, bool isDivergent = false) const {
(void)isDivergent;
const TargetRegisterClass *RC = RegClassForVT[VT.SimpleTy];
assert(RC && "This value type is not natively supported!");
@@ -1224,8 +1199,8 @@ class LLVM_ABI TargetLoweringBase {
}
struct IntrinsicInfo {
- unsigned opc = 0; // target opcode
- EVT memVT; // memory VT
+ unsigned opc = 0; // target opcode
+ EVT memVT; // memory VT
// value representing memory location
PointerUnion<const Value *, const PseudoSourceValue *> ptrVal;
@@ -1234,10 +1209,10 @@ class LLVM_ABI TargetLoweringBase {
// unknown address space.
std::optional<unsigned> fallbackAddressSpace;
- int offset = 0; // offset off of ptrVal
- uint64_t size = 0; // the size of the memory location
- // (taken from memVT if zero)
- MaybeAlign align = Align(1); // alignment
+ int offset = 0; // offset off of ptrVal
+ uint64_t size = 0; // the size of the memory location
+ // (taken from memVT if zero)
+ MaybeAlign align = Align(1); // alignment
MachineMemOperand::Flags flags = MachineMemOperand::MONone;
SyncScope::ID ssid = SyncScope::System;
@@ -1348,11 +1323,16 @@ class LLVM_ABI TargetLoweringBase {
LegalizeAction getStrictFPOperationAction(unsigned Op, EVT VT) const {
unsigned EqOpc;
switch (Op) {
- default: llvm_unreachable("Unexpected FP pseudo-opcode");
+ default:
+ llvm_unreachable("Unexpected FP pseudo-opcode");
#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \
- case ISD::STRICT_##DAGN: EqOpc = ISD::DAGN; break;
+ case ISD::STRICT_##DAGN: \
+ EqOpc = ISD::DAGN; \
+ break;
#define CMP_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \
- case ISD::STRICT_##DAGN: EqOpc = ISD::SETCC; break;
+ case ISD::STRICT_##DAGN: \
+ EqOpc = ISD::SETCC; \
+ break;
#include "llvm/IR/ConstrainedOps.def"
}
@@ -1369,8 +1349,8 @@ class LLVM_ABI TargetLoweringBase {
return isOperationLegal(Op, VT);
return (VT == MVT::Other || isTypeLegal(VT)) &&
- (getOperationAction(Op, VT) == Legal ||
- getOperationAction(Op, VT) == Custom);
+ (getOperationAction(Op, VT) == Legal ||
+ getOperationAction(Op, VT) == Custom);
}
/// Return true if the specified operation is legal on this target or can be
@@ -1383,8 +1363,8 @@ class LLVM_ABI TargetLoweringBase {
return isOperationLegal(Op, VT);
return (VT == MVT::Other || isTypeLegal(VT)) &&
- (getOperationAction(Op, VT) == Legal ||
- getOperationAction(Op, VT) == Promote);
+ (getOperationAction(Op, VT) == Legal ||
+ getOperationAction(Op, VT) == Promote);
}
/// Return true if the specified operation is legal on this target or can be
@@ -1397,9 +1377,9 @@ class LLVM_ABI TargetLoweringBase {
return isOperationLegal(Op, VT);
return (VT == MVT::Other || isTypeLegal(VT)) &&
- (getOperationAction(Op, VT) == Legal ||
- getOperationAction(Op, VT) == Custom ||
- getOperationAction(Op, VT) == Promote);
+ (getOperationAction(Op, VT) == Legal ||
+ getOperationAction(Op, VT) == Custom ||
+ getOperationAction(Op, VT) == Promote);
}
/// Return true if the operation uses custom lowering, regardless of whether
@@ -1481,9 +1461,10 @@ class LLVM_ABI TargetLoweringBase {
/// code sequence, or the target has a custom expander for it.
LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT,
EVT MemVT) const {
- if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
- unsigned ValI = (unsigned) ValVT.getSimpleVT().SimpleTy;
- unsigned MemI = (unsigned) MemVT.getSimpleVT().SimpleTy;
+ if (ValVT.isExtended() || MemVT.isExtended())
+ return Expand;
+ unsigned ValI = (unsigned)ValVT.getSimpleVT().SimpleTy;
+ unsigned MemI = (unsigned)MemVT.getSimpleVT().SimpleTy;
assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::VALUETYPE_SIZE &&
MemI < MVT::VALUETYPE_SIZE && "Table isn't big enough!");
unsigned Shift = 4 * ExtType;
@@ -1505,7 +1486,8 @@ class LLVM_ABI TargetLoweringBase {
/// Same as getLoadExtAction, but for atomic loads.
LegalizeAction getAtomicLoadExtAction(unsigned ExtType, EVT ValVT,
EVT MemVT) const {
- if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
+ if (ValVT.isExtended() || MemVT.isExtended())
+ return Expand;
unsigned ValI = (unsigned)ValVT.getSimpleVT().SimpleTy;
unsigned MemI = (unsigned)MemVT.getSimpleVT().SimpleTy;
assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::VALUETYPE_SIZE &&
@@ -1528,9 +1510,10 @@ class LLVM_ABI TargetLoweringBase {
/// legal, needs to be promoted to a larger size, needs to be expanded to some
/// other code sequence, or the target has a custom expander for it.
LegalizeAction getTruncStoreAction(EVT ValVT, EVT MemVT) const {
- if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
- unsigned ValI = (unsigned) ValVT.getSimpleVT().SimpleTy;
- unsigned MemI = (unsigned) MemVT.getSimpleVT().SimpleTy;
+ if (ValVT.isExtended() || MemVT.isExtended())
+ return Expand;
+ unsigned ValI = (unsigned)ValVT.getSimpleVT().SimpleTy;
+ unsigned MemI = (unsigned)MemVT.getSimpleVT().SimpleTy;
assert(ValI < MVT::VALUETYPE_SIZE && MemI < MVT::VALUETYPE_SIZE &&
"Table isn't big enough!");
return TruncStoreActions[ValI][MemI];
@@ -1545,9 +1528,8 @@ class LLVM_ABI TargetLoweringBase {
/// Return true if the specified store with truncation has solution on this
/// target.
bool isTruncStoreLegalOrCustom(EVT ValVT, EVT MemVT) const {
- return isTypeLegal(ValVT) &&
- (getTruncStoreAction(ValVT, MemVT) == Legal ||
- getTruncStoreAction(ValVT, MemVT) == Custom);
+ return isTypeLegal(ValVT) && (getTruncStoreAction(ValVT, MemVT) == Legal ||
+ getTruncStoreAction(ValVT, MemVT) == Custom);
}
virtual bool canCombineTruncStore(EVT ValVT, EVT MemVT,
@@ -1568,8 +1550,8 @@ class LLVM_ABI TargetLoweringBase {
/// Return true if the specified indexed load is legal on this target.
bool isIndexedLoadLegal(unsigned IdxMode, EVT VT) const {
return VT.isSimple() &&
- (getIndexedLoadAction(IdxMode, VT.getSimpleVT()) == Legal ||
- getIndexedLoadAction(IdxMode, VT.getSimpleVT()) == Custom);
+ (getIndexedLoadAction(IdxMode, VT.getSimpleVT()) == Legal ||
+ getIndexedLoadAction(IdxMode, VT.getSimpleVT()) == Custom);
}
/// Return how the indexed store should be treated: either it is legal, needs
@@ -1582,8 +1564,8 @@ class LLVM_ABI TargetLoweringBase {
/// Return true if the specified indexed load is legal on this target.
bool isIndexedStoreLegal(unsigned IdxMode, EVT VT) const {
return VT.isSimple() &&
- (getIndexedStoreAction(IdxMode, VT.getSimpleVT()) == Legal ||
- getIndexedStoreAction(IdxMode, VT.getSimpleVT()) == Custom);
+ (getIndexedStoreAction(IdxMode, VT.getSimpleVT()) == Legal ||
+ getIndexedStoreAction(IdxMode, VT.getSimpleVT()) == Custom);
}
/// Return how the indexed load should be treated: either it is legal, needs
@@ -1618,8 +1600,8 @@ class LLVM_ABI TargetLoweringBase {
/// extending
virtual bool shouldExtendGSIndex(EVT VT, EVT &EltTy) const { return false; }
- // Returns true if Extend can be folded into the index of a masked gathers/scatters
- // on this target.
+ // Returns true if Extend can be folded into the index of a masked
+ // gathers/scatters on this target.
virtual bool shouldRemoveExtendFromGSIndex(SDValue Extend, EVT DataVT) const {
return false;
}
@@ -1639,15 +1621,14 @@ class LLVM_ABI TargetLoweringBase {
/// Return how the condition code should be treated: either it is legal, needs
/// to be expanded to some other code sequence, or the target has a custom
/// expander for it.
- LegalizeAction
- getCondCodeAction(ISD::CondCode CC, MVT VT) const {
+ LegalizeAction getCondCodeAction(ISD::CondCode CC, MVT VT) const {
assert((unsigned)CC < std::size(CondCodeActions) &&
((unsigned)VT.SimpleTy >> 3) < std::size(CondCodeActions[0]) &&
"Table isn't big enough!");
// See setCondCodeAction for how this is encoded.
uint32_t Shift = 4 * (VT.SimpleTy & 0x7);
uint32_t Value = CondCodeActions[CC][VT.SimpleTy >> 3];
- LegalizeAction Action = (LegalizeAction) ((Value >> Shift) & 0xF);
+ LegalizeAction Action = (LegalizeAction)((Value >> Shift) & 0xF);
assert(Action != Promote && "Can't promote condition code!");
return Action;
}
@@ -1696,8 +1677,9 @@ class LLVM_ABI TargetLoweringBase {
// See if this has an explicit type specified.
std::map<std::pair<unsigned, MVT::SimpleValueType>,
MVT::SimpleValueType>::const_iterator PTTI =
- PromoteToType.find(std::make_pair(Op, VT.SimpleTy));
- if (PTTI != PromoteToType.end()) return PTTI->second;
+ PromoteToType.find(std::make_pair(Op, VT.SimpleTy));
+ if (PTTI != PromoteToType.end())
+ return PTTI->second;
assert((VT.isInteger() || VT.isFloatingPoint()) &&
"Cannot autopromote this type, add it with AddPromotedToType.");
@@ -1705,7 +1687,7 @@ class LLVM_ABI TargetLoweringBase {
uint64_t VTBits = VT.getScalarSizeInBits();
MVT NVT = VT;
do {
- NVT = (MVT::SimpleValueType)(NVT.SimpleTy+1);
+ NVT = (MVT::SimpleValueType)(NVT.SimpleTy + 1);
assert(NVT.isInteger() == VT.isInteger() &&
NVT.isFloatingPoint() == VT.isFloatingPoint() &&
"Didn't find type to promote to!");
@@ -1762,7 +1744,6 @@ class LLVM_ABI TargetLoweringBase {
return getValueType(DL, Ty, AllowUnknown);
}
-
/// Return the MVT corresponding to this LLVM type. See getValueType.
MVT getSimpleValueType(const DataLayout &DL, Type *Ty,
bool AllowUnknown = false) const {
@@ -1787,8 +1768,8 @@ class LLVM_ABI TargetLoweringBase {
EVT VT1;
MVT RegisterVT;
unsigned NumIntermediates;
- (void)getVectorTypeBreakdown(Context, VT, VT1,
- NumIntermediates, RegisterVT);
+ (void)getVectorTypeBreakdown(Context, VT, VT1, NumIntermediates,
+ RegisterVT);
return RegisterVT;
}
if (VT.isInteger()) {
@@ -1897,7 +1878,7 @@ class LLVM_ABI TargetLoweringBase {
/// perform for the specified node.
bool hasTargetDAGCombine(ISD::NodeType NT) const {
assert(unsigned(NT >> 3) < std::size(TargetDAGCombineArray));
- return TargetDAGCombineArray[NT >> 3] & (1 << (NT&7));
+ return TargetDAGCombineArray[NT >> 3] & (1 << (NT & 7));
}
unsigned getGatherAllAliasesMaxDepth() const {
@@ -2147,9 +2128,13 @@ class LLVM_ABI TargetLoweringBase {
/// Returns the name of the symbol used to emit stack probes or the empty
/// string if not applicable.
- virtual bool hasStackProbeSymbol(const MachineFunction &MF) const { return false; }
+ virtual bool hasStackProbeSymbol(const MachineFunction &MF) const {
+ return false;
+ }
- virtual bool hasInlineStackProbe(const MachineFunction &MF) const { return false; }
+ virtual bool hasInlineStackProbe(const MachineFunction &MF) const {
+ return false;
+ }
virtual StringRef getStackProbeSymbolName(const MachineFunction &MF) const {
return "";
@@ -2365,7 +2350,8 @@ class LLVM_ABI TargetLoweringBase {
// a dedicated instruction, if desired.
// E.g., on ARM, if ldrex isn't followed by strex, the exclusive monitor would
// be unnecessarily held, except if clrex, inserted by this hook, is executed.
- virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilderBase &Builder) const {}
+ virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilderBase &Builder) const {
+ }
/// Returns true if arguments should be sign-extended in lib calls.
virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const {
@@ -2373,9 +2359,7 @@ class LLVM_ABI TargetLoweringBase {
}
/// Returns true if arguments should be extended in lib calls.
- virtual bool shouldExtendTypeInLibCall(EVT Type) const {
- return true;
- }
+ virtual bool shouldExtendTypeInLibCall(EVT Type) const { return true; }
/// Returns how the given (atomic) load should be expanded by the
/// IR-level AtomicExpand pass.
@@ -2416,9 +2400,10 @@ class LLVM_ABI TargetLoweringBase {
/// Returns how the IR-level AtomicExpand pass should expand the given
/// AtomicRMW, if at all. Default is to never expand.
- virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
- return RMW->isFloatingPointOperation() ?
- AtomicExpansionKind::CmpXChg : AtomicExpansionKind::None;
+ virtual AtomicExpansionKind
+ shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
+ return RMW->isFloatingPointOperation() ? AtomicExpansionKind::CmpXChg
+ : AtomicExpansionKind::None;
}
/// Returns how the given atomic atomicrmw should be cast by the IR-level
@@ -2484,7 +2469,7 @@ class LLVM_ABI TargetLoweringBase {
// registers.
LegalizeTypeAction Action = getTypeAction(Context, VT);
return Action != TypeExpandInteger && Action != TypeExpandFloat &&
- Action != TypeSplitVector;
+ Action != TypeSplitVector;
}
virtual bool isProfitableToCombineMinNumMaxNum(EVT VT) const { return true; }
@@ -2492,17 +2477,15 @@ class LLVM_ABI TargetLoweringBase {
/// Return true if a select of constants (select Cond, C1, C2) should be
/// transformed into simple math ops with the condition value. For example:
/// select Cond, C1, C1-1 --> add (zext Cond), C1-1
- virtual bool convertSelectOfConstantsToMath(EVT VT) const {
- return false;
- }
+ virtual bool convertSelectOfConstantsToMath(EVT VT) const { return false; }
/// Return true if it is profitable to transform an integer
/// multiplication-by-constant into simpler operations like shifts and adds.
/// This may be true if the target does not directly support the
/// multiplication operation for the specified type or the sequence of simpler
/// ops is faster than the multiply.
- virtual bool decomposeMulByConstant(LLVMContext &Context,
- EVT VT, SDValue C) const {
+ virtual bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
+ SDValue C) const {
return false;
}
@@ -2898,9 +2881,9 @@ class LLVM_ABI TargetLoweringBase {
/// If ScalableOffset is zero, there is no scalable offset.
struct AddrMode {
GlobalValue *BaseGV = nullptr;
- int64_t BaseOffs = 0;
- bool HasBaseReg = false;
- int64_t Scale = 0;
+ int64_t BaseOffs = 0;
+ bool HasBaseReg = false;
+ int64_t Scale = 0;
int64_t ScalableOffset = 0;
AddrMode() = default;
};
@@ -2934,16 +2917,12 @@ class LLVM_ABI TargetLoweringBase {
/// Return true if the specified immediate is legal icmp immediate, that is
/// the target has icmp instructions which can compare a register against the
/// immediate without having to materialize the immediate into a register.
- virtual bool isLegalICmpImmediate(int64_t) const {
- return true;
- }
+ virtual bool isLegalICmpImmediate(int64_t) const { return true; }
/// Return true if the specified immediate is legal add immediate, that is the
/// target has add instructions which can add a register with the immediate
/// without having to materialize the immediate into a register.
- virtual bool isLegalAddImmediate(int64_t) const {
- return true;
- }
+ virtual bool isLegalAddImmediate(int64_t) const { return true; }
/// Return true if adding the specified scalable immediate is legal, that is
/// the target has add instructions which can add a register with the
@@ -2964,7 +2943,7 @@ class LLVM_ABI TargetLoweringBase {
/// profitable. Returns nullptr otherwise. For example under MVE float splats
/// are converted to integer to prevent the need to move from SPR to GPR
/// registers.
- virtual Type* shouldConvertSplatType(ShuffleVectorInst* SVI) const {
+ virtual Type *shouldConvertSplatType(ShuffleVectorInst *SVI) const {
return nullptr;
}
@@ -3016,7 +2995,8 @@ class LLVM_ABI TargetLoweringBase {
case ISD::ABDS:
case ISD::ABDU:
return true;
- default: return false;
+ default:
+ return false;
}
}
@@ -3052,9 +3032,7 @@ class LLVM_ABI TargetLoweringBase {
/// ToTy. e.g. On x86 it's free to truncate a i32 value in register EAX to i16
/// by referencing its sub-register AX.
/// Targets must return false when FromTy <= ToTy.
- virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const {
- return false;
- }
+ virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const { return false; }
/// Return true if a truncation from FromTy to ToTy is permitted when deciding
/// whether a call is in tail position. Typically this means that both results
@@ -3146,9 +3124,7 @@ class LLVM_ABI TargetLoweringBase {
/// explicit truncate, which is not necessarily free, but this function
/// does not deal with those cases.
/// Targets must return false when FromTy >= ToTy.
- virtual bool isZExtFree(Type *FromTy, Type *ToTy) const {
- return false;
- }
+ virtual bool isZExtFree(Type *FromTy, Type *ToTy) const { return false; }
virtual bool isZExtFree(EVT FromTy, EVT ToTy) const { return false; }
virtual bool isZExtFree(LLT FromTy, LLT ToTy, LLVMContext &Ctx) const {
@@ -3437,9 +3413,7 @@ class LLVM_ABI TargetLoweringBase {
/// Try to convert an extract element of a vector binary operation into an
/// extract element followed by a scalar operation.
- virtual bool shouldScalarizeBinop(SDValue VecOp) const {
- return false;
- }
+ virtual bool shouldScalarizeBinop(SDValue VecOp) const { return false; }
/// Return true if extraction of a scalar element from the given vector type
/// at the given index is cheap. For example, if scalar operations occur on
@@ -3633,8 +3607,8 @@ class LLVM_ABI TargetLoweringBase {
// GlobalISel Hooks
//===----------------------------------------------------------------------===//
/// Check whether or not \p MI needs to be moved close to its uses.
- virtual bool shouldLocalize(const MachineInstr &MI, const TargetTransformInfo *TTI) const;
-
+ virtual bool shouldLocalize(const MachineInstr &MI,
+ const TargetTransformInfo *TTI) const;
private:
const TargetMachine &TM;
@@ -3649,7 +3623,7 @@ class LLVM_ABI TargetLoweringBase {
/// instructions. For example, BypassSlowDivWidths[32,8] tells the code
/// generator to bypass 32-bit integer div/rem with an 8-bit unsigned integer
/// div/rem when the operands are positive and less than 256.
- DenseMap <unsigned int, unsigned int> BypassSlowDivWidths;
+ DenseMap<unsigned int, unsigned int> BypassSlowDivWidths;
/// Tells the code generator that it shouldn't generate extra flow control
/// instructions and should attempt to combine flow control instructions via
@@ -3789,7 +3763,7 @@ class LLVM_ABI TargetLoweringBase {
/// callbacks for by calling setTargetDAGCombine(), which sets a bit in this
/// array.
unsigned char
- TargetDAGCombineArray[(ISD::BUILTIN_OP_END+CHAR_BIT-1)/CHAR_BIT];
+ TargetDAGCombineArray[(ISD::BUILTIN_OP_END + CHAR_BIT - 1) / CHAR_BIT];
/// For operations that must be promoted to a specific type, this holds the
/// destination type. This map should be sparse, so don't hold it as an
@@ -3798,7 +3772,7 @@ class LLVM_ABI TargetLoweringBase {
/// Targets add entries to this map with AddPromotedToType(..), clients access
/// this with getTypeToPromoteTo(..).
std::map<std::pair<unsigned, MVT::SimpleValueType>, MVT::SimpleValueType>
- PromoteToType;
+ PromoteToType;
/// The list of libcalls that the target will use.
RTLIB::RuntimeLibcallsInfo Libcalls;
@@ -3975,17 +3949,15 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
return MRI.hasOneNonDBGUse(N0);
}
- virtual bool isSDNodeAlwaysUniform(const SDNode * N) const {
- return false;
- }
+ virtual bool isSDNodeAlwaysUniform(const SDNode *N) const { return false; }
/// Returns true by value, base pointer and offset pointer and addressing mode
/// by reference if the node's address can be legally represented as
/// pre-indexed load / store address.
- virtual bool getPreIndexedAddressParts(SDNode * /*N*/, SDValue &/*Base*/,
- SDValue &/*Offset*/,
- ISD::MemIndexedMode &/*AM*/,
- SelectionDAG &/*DAG*/) const {
+ virtual bool getPreIndexedAddressParts(SDNode * /*N*/, SDValue & /*Base*/,
+ SDValue & /*Offset*/,
+ ISD::MemIndexedMode & /*AM*/,
+ SelectionDAG & /*DAG*/) const {
return false;
}
@@ -3993,10 +3965,10 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// by reference if this node can be combined with a load / store to form a
/// post-indexed load / store.
virtual bool getPostIndexedAddressParts(SDNode * /*N*/, SDNode * /*Op*/,
- SDValue &/*Base*/,
- SDValue &/*Offset*/,
- ISD::MemIndexedMode &/*AM*/,
- SelectionDAG &/*DAG*/) const {
+ SDValue & /*Base*/,
+ SDValue & /*Offset*/,
+ ISD::MemIndexedMode & /*AM*/,
+ SelectionDAG & /*DAG*/) const {
return false;
}
@@ -4019,7 +3991,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
virtual const MCExpr *
LowerCustomJumpTableEntry(const MachineJumpTableInfo * /*MJTI*/,
const MachineBasicBlock * /*MBB*/, unsigned /*uid*/,
- MCContext &/*Ctx*/) const {
+ MCContext & /*Ctx*/) const {
llvm_unreachable("Need to implement this hook if target has custom JTIs");
}
@@ -4029,9 +4001,9 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// This returns the relocation base for the given PIC jumptable, the same as
/// getPICJumpTableRelocBase, but as an MCExpr.
- virtual const MCExpr *
- getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
- unsigned JTI, MCContext &Ctx) const;
+ virtual const MCExpr *getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
+ unsigned JTI,
+ MCContext &Ctx) const;
/// Return true if folding a constant offset with the given GlobalAddress is
/// legal. It is frequently not legal in PIC relocation models.
@@ -4090,9 +4062,9 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// registers are the same as from the calling function. This needs to be
/// checked for tail call eligibility.
bool parametersInCSRMatch(const MachineRegisterInfo &MRI,
- const uint32_t *CallerPreservedMask,
- const SmallVectorImpl<CCValAssign> &ArgLocs,
- const SmallVectorImpl<SDValue> &OutVals) const;
+ const uint32_t *CallerPreservedMask,
+ const SmallVectorImpl<CCValAssign> &ArgLocs,
+ const SmallVectorImpl<SDValue> &OutVals) const;
//===--------------------------------------------------------------------===//
// TargetLowering Optimization Methods
@@ -4108,9 +4080,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
SDValue Old;
SDValue New;
- explicit TargetLoweringOpt(SelectionDAG &InDAG,
- bool LT, bool LO) :
- DAG(InDAG), LegalTys(LT), LegalOps(LO) {}
+ explicit TargetLoweringOpt(SelectionDAG &InDAG, bool LT, bool LO)
+ : DAG(InDAG), LegalTys(LT), LegalOps(LO) {}
bool LegalTypes() const { return LegalTys; }
bool LegalOperations() const { return LegalOps; }
@@ -4122,11 +4093,11 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
}
};
- /// Determines the optimal series of memory ops to replace the memset / memcpy.
- /// Return true if the number of memory ops is below the threshold (Limit).
- /// Note that this is always the case when Limit is ~0.
- /// It returns the types of the sequence of memory ops to perform
- /// memset / memcpy by reference.
+ /// Determines the optimal series of memory ops to replace the memset /
+ /// memcpy. Return true if the number of memory ops is below the threshold
+ /// (Limit). Note that this is always the case when Limit is ~0. It returns
+ /// the types of the sequence of memory ops to perform memset / memcpy by
+ /// reference.
virtual bool
findOptimalMemOpLowering(LLVMContext &Context, std::vector<EVT> &MemOps,
unsigned Limit, const MemOp &Op, unsigned DstAS,
@@ -4256,8 +4227,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// or one and return them in the KnownZero/KnownOne bitsets. The DemandedElts
/// argument allows us to only collect the known bits that are shared by the
/// requested vector elements.
- virtual void computeKnownBitsForTargetNode(const SDValue Op,
- KnownBits &Known,
+ virtual void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
const APInt &DemandedElts,
const SelectionDAG &DAG,
unsigned Depth = 0) const;
@@ -4291,8 +4261,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// Determine which of the bits of FrameIndex \p FIOp are known to be 0.
/// Default implementation computes low bits based on alignment
/// information. This should preserve known bits passed into it.
- virtual void computeKnownBitsForFrameIndex(int FIOp,
- KnownBits &Known,
+ virtual void computeKnownBitsForFrameIndex(int FIOp, KnownBits &Known,
const MachineFunction &MF) const;
/// This method can be implemented by targets that want to expose additional
@@ -4326,12 +4295,9 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// expression and return a mask of KnownOne and KnownZero bits for the
/// expression (used to simplify the caller). The KnownZero/One bits may only
/// be accurate for those bits in the Demanded masks.
- virtual bool SimplifyDemandedBitsForTargetNode(SDValue Op,
- const APInt &DemandedBits,
- const APInt &DemandedElts,
- KnownBits &Known,
- TargetLoweringOpt &TLO,
- unsigned Depth = 0) const;
+ virtual bool SimplifyDemandedBitsForTargetNode(
+ SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts,
+ KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth = 0) const;
/// More limited version of SimplifyDemandedBits that can be used to "look
/// through" ops that don't contribute to the DemandedBits/DemandedElts -
@@ -4396,15 +4362,15 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
virtual bool isTargetCanonicalSelect(SDNode *N) const { return false; }
struct DAGCombinerInfo {
- void *DC; // The DAG Combiner object.
+ void *DC; // The DAG Combiner object.
CombineLevel Level;
bool CalledByLegalizer;
public:
SelectionDAG &DAG;
- DAGCombinerInfo(SelectionDAG &dag, CombineLevel level, bool cl, void *dc)
- : DC(dc), Level(level), CalledByLegalizer(cl), DAG(dag) {}
+ DAGCombinerInfo(SelectionDAG &dag, CombineLevel level, bool cl, void *dc)
+ : DC(dc), Level(level), CalledByLegalizer(cl), DAG(dag) {}
bool isBeforeLegalize() const { return Level == BeforeLegalizeTypes; }
bool isBeforeLegalizeOps() const { return Level < AfterLegalizeVectorOps; }
@@ -4446,8 +4412,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// Returns true (and the GlobalValue and the offset) if the node is a
/// GlobalAddress + offset.
- virtual bool
- isGAPlusOffset(SDNode *N, const GlobalValue* &GA, int64_t &Offset) const;
+ virtual bool isGAPlusOffset(SDNode *N, const GlobalValue *&GA,
+ int64_t &Offset) const;
/// This method will be invoked for all target nodes and for any
/// target-independent nodes that the target has registered with invoke it
@@ -4553,21 +4519,17 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// This method query the target whether it is beneficial for dag combiner to
/// promote the specified node. If true, it should return the desired
/// promotion type by reference.
- virtual bool IsDesirableToPromoteOp(SDValue /*Op*/, EVT &/*PVT*/) const {
+ virtual bool IsDesirableToPromoteOp(SDValue /*Op*/, EVT & /*PVT*/) const {
return false;
}
/// Return true if the target supports swifterror attribute. It optimizes
/// loads and stores to reading and writing a specific register.
- virtual bool supportSwiftError() const {
- return false;
- }
+ virtual bool supportSwiftError() const { return false; }
/// Return true if the target supports that a subset of CSRs for the given
/// machine function is handled explicitly via copies.
- virtual bool supportSplitCSR(MachineFunction *MF) const {
- return false;
- }
+ virtual bool supportSplitCSR(MachineFunction *MF) const { return false; }
/// Return true if the target supports kcfi operand bundles.
virtual bool supportKCFIBundles() const { return false; }
@@ -4643,9 +4605,10 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// Target-specific splitting of values into parts that fit a register
/// storing a legal type
- virtual bool splitValueIntoRegisterParts(
- SelectionDAG & DAG, const SDLoc &DL, SDValue Val, SDValue *Parts,
- unsigned NumParts, MVT PartVT, std::optional<CallingConv::ID> CC) const {
+ virtual bool
+ splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val,
+ SDValue *Parts, unsigned NumParts, MVT PartVT,
+ std::optional<CallingConv::ID> CC) const {
return false;
}
@@ -4714,16 +4677,16 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
Type *OrigRetTy = nullptr;
/// Same as OrigRetTy, or partially legalized for soft float libcalls.
Type *RetTy = nullptr;
- bool RetSExt : 1;
- bool RetZExt : 1;
- bool IsVarArg : 1;
- bool IsInReg : 1;
- bool DoesNotReturn : 1;
+ bool RetSExt : 1;
+ bool RetZExt : 1;
+ bool IsVarArg : 1;
+ bool IsInReg : 1;
+ bool DoesNotReturn : 1;
bool IsReturnValueUsed : 1;
- bool IsConvergent : 1;
- bool IsPatchPoint : 1;
+ bool IsConvergent : 1;
+ bool IsPatchPoint : 1;
bool IsPreallocated : 1;
- bool NoMerge : 1;
+ bool NoMerge : 1;
// IsTailCall should be modified by implementations of
// TargetLowering::LowerCall that perform tail call conversions.
@@ -4751,8 +4714,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
CallLoweringInfo(SelectionDAG &DAG)
: RetSExt(false), RetZExt(false), IsVarArg(false), IsInReg(false),
DoesNotReturn(false), IsReturnValueUsed(true), IsConvergent(false),
- IsPatchPoint(false), IsPreallocated(false), NoMerge(false),
- DAG(DAG) {}
+ IsPatchPoint(false), IsPreallocated(false), NoMerge(false), DAG(DAG) {
+ }
CallLoweringInfo &setDebugLoc(const SDLoc &dl) {
DL = dl;
@@ -4883,7 +4846,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
return *this;
}
- CallLoweringInfo &setIsPostTypeLegalization(bool Value=true) {
+ CallLoweringInfo &setIsPostTypeLegalization(bool Value = true) {
IsPostTypeLegalization = Value;
return *this;
}
@@ -4898,9 +4861,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
return *this;
}
- ArgListTy &getArgs() {
- return Args;
- }
+ ArgListTy &getArgs() { return Args; }
};
/// This structure is used to pass arguments to makeLibCall function.
@@ -4941,7 +4902,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
return *this;
}
- MakeLibCallOptions &setTypeListBeforeSoften(ArrayRef<EVT> OpsVT, EVT RetVT) {
+ MakeLibCallOptions &setTypeListBeforeSoften(ArrayRef<EVT> OpsVT,
+ EVT RetVT) {
OpsVTBeforeSoften = OpsVT;
RetVTBeforeSoften = RetVT;
IsSoften = true;
@@ -4967,9 +4929,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// and the values to be returned by the call are described by the Ins
/// array. The implementation should fill in the InVals array with legal-type
/// return values from the call, and return the resulting token chain value.
- virtual SDValue
- LowerCall(CallLoweringInfo &/*CLI*/,
- SmallVectorImpl<SDValue> &/*InVals*/) const {
+ virtual SDValue LowerCall(CallLoweringInfo & /*CLI*/,
+ SmallVectorImpl<SDValue> & /*InVals*/) const {
llvm_unreachable("Not Implemented");
}
@@ -4980,10 +4941,10 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// described by the Outs array can fit into the return registers. If false
/// is returned, an sret-demotion is performed.
virtual bool CanLowerReturn(CallingConv::ID /*CallConv*/,
- MachineFunction &/*MF*/, bool /*isVarArg*/,
- const SmallVectorImpl<ISD::OutputArg> &/*Outs*/,
- LLVMContext &/*Context*/, const Type *RetTy) const
- {
+ MachineFunction & /*MF*/, bool /*isVarArg*/,
+ const SmallVectorImpl<ISD::OutputArg> & /*Outs*/,
+ LLVMContext & /*Context*/,
+ const Type *RetTy) const {
// Return true by default to get preexisting behavior.
return true;
}
@@ -5005,21 +4966,19 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
///
/// This is used to determine whether it is possible to codegen a libcall as
/// tail call at legalization time.
- virtual bool isUsedByReturnOnly(SDNode *, SDValue &/*Chain*/) const {
+ virtual bool isUsedByReturnOnly(SDNode *, SDValue & /*Chain*/) const {
return false;
}
/// Return true if the target may be able emit the call instruction as a tail
/// call. This is used by optimization passes to determine if it's profitable
/// to duplicate return instructions to enable tailcall optimization.
- virtual bool mayBeEmittedAsTailCall(const CallInst *) const {
- return false;
- }
+ virtual bool mayBeEmittedAsTailCall(const CallInst *) const { return false; }
/// Return the register ID of the name passed in. Used by named register
/// global variables extension. There is no target-independent behaviour
/// so the default action is to bail.
- virtual Register getRegisterByName(const char* RegName, LLT Ty,
+ virtual Register getRegisterByName(const char *RegName, LLT Ty,
const MachineFunction &MF) const {
report_fatal_error("Named registers not implemented for this target");
}
@@ -5031,7 +4990,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// conventions. The frontend should handle this and include all of the
/// necessary information.
virtual EVT getTypeForExtReturn(LLVMContext &Context, EVT VT,
- ISD::NodeType /*ExtendKind*/) const {
+ ISD::NodeType /*ExtendKind*/) const {
EVT MinVT = getRegisterType(MVT::i32);
return VT.bitsLT(MinVT) ? MinVT : VT;
}
@@ -5113,8 +5072,8 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// If the target has no operations that require custom lowering, it need not
/// implement this. The default implementation aborts.
virtual void ReplaceNodeResults(SDNode * /*N*/,
- SmallVectorImpl<SDValue> &/*Results*/,
- SelectionDAG &/*DAG*/) const {
+ SmallVectorImpl<SDValue> & /*Results*/,
+ SelectionDAG & /*DAG*/) const {
llvm_unreachable("ReplaceNodeResults not implemented for this target!");
}
@@ -5133,29 +5092,29 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
//
enum ConstraintType {
- C_Register, // Constraint represents specific register(s).
- C_RegisterClass, // Constraint represents any of register(s) in class.
- C_Memory, // Memory constraint.
- C_Address, // Address constraint.
- C_Immediate, // Requires an immediate.
- C_Other, // Something else.
- C_Unknown // Unsupported constraint.
+ C_Register, // Constraint represents specific register(s).
+ C_RegisterClass, // Constraint represents any of register(s) in class.
+ C_Memory, // Memory constraint.
+ C_Address, // Address constraint.
+ C_Immediate, // Requires an immediate.
+ C_Other, // Something else.
+ C_Unknown // Unsupported constraint.
};
enum ConstraintWeight {
// Generic weights.
- CW_Invalid = -1, // No match.
- CW_Okay = 0, // Acceptable.
- CW_Good = 1, // Good weight.
- CW_Better = 2, // Better weight.
- CW_Best = 3, // Best weight.
+ CW_Invalid = -1, // No match.
+ CW_Okay = 0, // Acceptable.
+ CW_Good = 1, // Good weight.
+ CW_Better = 2, // Better weight.
+ CW_Best = 3, // Best weight.
// Well-known weights.
- CW_SpecificReg = CW_Okay, // Specific register operands.
- CW_Register = CW_Good, // Register operands.
- CW_Memory = CW_Better, // Memory operands.
- CW_Constant = CW_Best, // Constant operand.
- CW_Default = CW_Okay // Default or don't know type.
+ CW_SpecificReg = CW_Okay, // Specific register operands.
+ CW_Register = CW_Good, // Register operands.
+ CW_Memory = CW_Better, // Memory operands.
+ CW_Constant = CW_Best, // Constant operand.
+ CW_Default = CW_Okay // Default or don't know type.
};
/// This contains information for each constraint that we are lowering.
@@ -5202,20 +5161,20 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// Examine constraint type and operand type and determine a weight value.
/// The operand object must already have been set up with the operand type.
- virtual ConstraintWeight getMultipleConstraintMatchWeight(
- AsmOperandInfo &info, int maIndex) const;
+ virtual ConstraintWeight
+ getMultipleConstraintMatchWeight(AsmOperandInfo &info, int maIndex) const;
/// Examine constraint string and operand type and determine a weight value.
/// The operand object must already have been set up with the operand type.
- virtual ConstraintWeight getSingleConstraintMatchWeight(
- AsmOperandInfo &info, const char *constraint) const;
+ virtual ConstraintWeight
+ getSingleConstraintMatchWeight(AsmOperandInfo &info,
+ const char *constraint) const;
/// Determines the constraint code and constraint type to use for the specific
/// AsmOperandInfo, setting OpInfo.ConstraintCode and OpInfo.ConstraintType.
/// If the actual operand being passed in is available, it can be passed in as
/// Op, otherwise an empty SDValue can be passed.
- virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo,
- SDValue Op,
+ virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo, SDValue Op,
SelectionDAG *DAG = nullptr) const;
/// Given a constraint, return the type of constraint it is for this target.
@@ -5314,9 +5273,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// divisor. If the transform should never be done, return zero. If the
/// transform should be done, return the minimum number of divisor uses
/// that must exist.
- virtual unsigned combineRepeatedFPDivisors() const {
- return 0;
- }
+ virtual unsigned combineRepeatedFPDivisors() const { return 0; }
/// Hooks for building estimates in place of slower divisions and square
/// roots.
@@ -5669,9 +5626,9 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
/// method accepts integers as its arguments.
/// Note: This method may fail if the division could not be performed
/// within the type. Clients must retry with a wider type if this happens.
- SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl,
- SDValue LHS, SDValue RHS,
- unsigned Scale, SelectionDAG &DAG) const;
+ SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS,
+ SDValue RHS, unsigned Scale,
+ SelectionDAG &DAG) const;
/// Method for building the DAG expansion of ISD::U(ADD|SUB)O. Expansion
/// always suceeds and populates the Result and Overflow arguments.
>From 24d2f4a7893d64c11a33b084c963d1efca7dc49c Mon Sep 17 00:00:00 2001
From: Sam Parker <sam.parker at arm.com>
Date: Tue, 9 Sep 2025 09:22:13 +0100
Subject: [PATCH 2/2] [NFC][CodeGen] Convert LoadExtActions to a map
This allows us to specify actions per address space. The APIs use the
default address space, zero, if not specified.
---
llvm/include/llvm/CodeGen/TargetLowering.h | 45 ++++++++++++++--------
llvm/lib/CodeGen/TargetLoweringBase.cpp | 1 -
2 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 42bdd85a1f4b9..d295cfa043503 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -1459,8 +1459,8 @@ class LLVM_ABI TargetLoweringBase {
/// Return how this load with extension should be treated: either it is legal,
/// needs to be promoted to a larger size, needs to be expanded to some other
/// code sequence, or the target has a custom expander for it.
- LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT,
- EVT MemVT) const {
+ LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT, EVT MemVT,
+ unsigned AddrSpace = 0) const {
if (ValVT.isExtended() || MemVT.isExtended())
return Expand;
unsigned ValI = (unsigned)ValVT.getSimpleVT().SimpleTy;
@@ -1468,19 +1468,23 @@ class LLVM_ABI TargetLoweringBase {
assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::VALUETYPE_SIZE &&
MemI < MVT::VALUETYPE_SIZE && "Table isn't big enough!");
unsigned Shift = 4 * ExtType;
- return (LegalizeAction)((LoadExtActions[ValI][MemI] >> Shift) & 0xf);
+ return (
+ LegalizeAction)((LoadExtActions.at(AddrSpace)[ValI][MemI] >> Shift) &
+ 0xf);
}
/// Return true if the specified load with extension is legal on this target.
- bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const {
- return getLoadExtAction(ExtType, ValVT, MemVT) == Legal;
+ bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT,
+ unsigned AddrSpace = 0) const {
+ return getLoadExtAction(ExtType, ValVT, MemVT, AddrSpace) == Legal;
}
/// Return true if the specified load with extension is legal or custom
/// on this target.
- bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT) const {
- return getLoadExtAction(ExtType, ValVT, MemVT) == Legal ||
- getLoadExtAction(ExtType, ValVT, MemVT) == Custom;
+ bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT,
+ unsigned AddrSpace = 0) const {
+ return getLoadExtAction(ExtType, ValVT, MemVT, AddrSpace) == Legal ||
+ getLoadExtAction(ExtType, ValVT, MemVT, AddrSpace) == Custom;
}
/// Same as getLoadExtAction, but for atomic loads.
@@ -2624,23 +2628,26 @@ class LLVM_ABI TargetLoweringBase {
/// Indicate that the specified load with extension does not work with the
/// specified type and indicate what to do about it.
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT,
- LegalizeAction Action) {
+ LegalizeAction Action, unsigned AddrSpace = 0) {
assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValVT.isValid() &&
MemVT.isValid() && "Table isn't big enough!");
assert((unsigned)Action < 0x10 && "too many bits for bitfield array");
unsigned Shift = 4 * ExtType;
- LoadExtActions[ValVT.SimpleTy][MemVT.SimpleTy] &= ~((uint16_t)0xF << Shift);
- LoadExtActions[ValVT.SimpleTy][MemVT.SimpleTy] |= (uint16_t)Action << Shift;
+ LoadExtActions[AddrSpace][ValVT.SimpleTy][MemVT.SimpleTy] &=
+ ~((uint16_t)0xF << Shift);
+ LoadExtActions[AddrSpace][ValVT.SimpleTy][MemVT.SimpleTy] |=
+ (uint16_t)Action << Shift;
}
void setLoadExtAction(ArrayRef<unsigned> ExtTypes, MVT ValVT, MVT MemVT,
- LegalizeAction Action) {
+ LegalizeAction Action, unsigned AddrSpace = 0) {
for (auto ExtType : ExtTypes)
- setLoadExtAction(ExtType, ValVT, MemVT, Action);
+ setLoadExtAction(ExtType, ValVT, MemVT, Action, AddrSpace);
}
void setLoadExtAction(ArrayRef<unsigned> ExtTypes, MVT ValVT,
- ArrayRef<MVT> MemVTs, LegalizeAction Action) {
+ ArrayRef<MVT> MemVTs, LegalizeAction Action,
+ unsigned AddrSpace = 0) {
for (auto MemVT : MemVTs)
- setLoadExtAction(ExtTypes, ValVT, MemVT, Action);
+ setLoadExtAction(ExtTypes, ValVT, MemVT, Action, AddrSpace);
}
/// Let target indicate that an extending atomic load of the specified type
@@ -3722,8 +3729,12 @@ class LLVM_ABI TargetLoweringBase {
/// For each load extension type and each value type, keep a LegalizeAction
/// that indicates how instruction selection should deal with a load of a
/// specific value type and extension type. Uses 4-bits to store the action
- /// for each of the 4 load ext types.
- uint16_t LoadExtActions[MVT::VALUETYPE_SIZE][MVT::VALUETYPE_SIZE];
+ /// for each of the 4 load ext types. These actions can be specified for each
+ /// address space.
+ using LoadExtActionMap =
+ std::map<unsigned, std::array<std::array<uint16_t, MVT::VALUETYPE_SIZE>,
+ MVT::VALUETYPE_SIZE>>;
+ LoadExtActionMap LoadExtActions;
/// Similar to LoadExtActions, but for atomic loads. Only Legal or Expand
/// (default) values are supported.
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index c23281a820b2b..5432d9673deaf 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -728,7 +728,6 @@ TargetLoweringBase::~TargetLoweringBase() = default;
void TargetLoweringBase::initActions() {
// All operations default to being supported.
memset(OpActions, 0, sizeof(OpActions));
- memset(LoadExtActions, 0, sizeof(LoadExtActions));
memset(TruncStoreActions, 0, sizeof(TruncStoreActions));
memset(IndexedModeActions, 0, sizeof(IndexedModeActions));
memset(CondCodeActions, 0, sizeof(CondCodeActions));
More information about the llvm-commits
mailing list