mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Move some information out of LegalizeDAG into the generic Target interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19581 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
using namespace llvm;
|
||||
|
||||
TargetLowering::TargetLowering(TargetMachine &tm)
|
||||
: TM(tm), TD(TM.getTargetData()) {
|
||||
: TM(tm), TD(TM.getTargetData()), ValueTypeActions(0) {
|
||||
assert(ISD::BUILTIN_OP_END <= 128 &&
|
||||
"Fixed size array in TargetLowering is not large enough!");
|
||||
|
||||
@@ -27,9 +27,47 @@ TargetLowering::TargetLowering(TargetMachine &tm)
|
||||
memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
|
||||
}
|
||||
|
||||
/// setValueTypeAction - Set the action for a particular value type. This
|
||||
/// assumes an action has not already been set for this value type.
|
||||
static void SetValueTypeAction(MVT::ValueType VT, unsigned Action,
|
||||
TargetLowering &TLI,
|
||||
MVT::ValueType *TransformToType,
|
||||
unsigned &ValueTypeActions) {
|
||||
ValueTypeActions |= Action << (VT*2);
|
||||
if (Action == 1 /*promote*/) {
|
||||
MVT::ValueType PromoteTo;
|
||||
if (VT == MVT::f32)
|
||||
PromoteTo = MVT::f64;
|
||||
else {
|
||||
unsigned LargerReg = VT+1;
|
||||
while (!TLI.hasNativeSupportFor((MVT::ValueType)LargerReg)) {
|
||||
++LargerReg;
|
||||
assert(MVT::isInteger((MVT::ValueType)LargerReg) &&
|
||||
"Nothing to promote to??");
|
||||
}
|
||||
PromoteTo = (MVT::ValueType)LargerReg;
|
||||
}
|
||||
|
||||
assert(MVT::isInteger(VT) == MVT::isInteger(PromoteTo) &&
|
||||
MVT::isFloatingPoint(VT) == MVT::isFloatingPoint(PromoteTo) &&
|
||||
"Can only promote from int->int or fp->fp!");
|
||||
assert(VT < PromoteTo && "Must promote to a larger type!");
|
||||
TransformToType[VT] = PromoteTo;
|
||||
} else if (Action == 2) {
|
||||
assert(MVT::isInteger(VT) && VT > MVT::i8 &&
|
||||
"Cannot expand this type: target must support SOME integer reg!");
|
||||
// Expand to the next smaller integer type!
|
||||
TransformToType[VT] = (MVT::ValueType)(VT-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// computeRegisterProperties - Once all of the register classes are added,
|
||||
/// this allows us to compute derived properties we expose.
|
||||
void TargetLowering::computeRegisterProperties() {
|
||||
assert(MVT::LAST_VALUETYPE <= 16 &&
|
||||
"Too many value types for ValueTypeActions to hold!");
|
||||
|
||||
// Everything defaults to one.
|
||||
for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i)
|
||||
NumElementsForVT[i] = 1;
|
||||
@@ -44,5 +82,20 @@ void TargetLowering::computeRegisterProperties() {
|
||||
unsigned ExpandedReg = LargestIntReg; ++LargestIntReg;
|
||||
for (++ExpandedReg; MVT::isInteger((MVT::ValueType)ExpandedReg);++ExpandedReg)
|
||||
NumElementsForVT[ExpandedReg] = 2*NumElementsForVT[ExpandedReg-1];
|
||||
}
|
||||
|
||||
// Inspect all of the ValueType's possible, deciding how to process them.
|
||||
for (unsigned IntReg = MVT::i1; IntReg <= MVT::i128; ++IntReg)
|
||||
// If we are expanding this type, expand it!
|
||||
if (getNumElements((MVT::ValueType)IntReg) != 1)
|
||||
SetValueTypeAction((MVT::ValueType)IntReg, 2, *this, TransformToType,
|
||||
ValueTypeActions);
|
||||
else if (!hasNativeSupportFor((MVT::ValueType)IntReg))
|
||||
// Otherwise, if we don't have native support, we must promote to a
|
||||
// larger type.
|
||||
SetValueTypeAction((MVT::ValueType)IntReg, 1, *this, TransformToType,
|
||||
ValueTypeActions);
|
||||
|
||||
// If the target does not have native support for F32, promote it to F64.
|
||||
if (!hasNativeSupportFor(MVT::f32))
|
||||
SetValueTypeAction(MVT::f32, 1, *this, TransformToType, ValueTypeActions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user