mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-18 12:25:47 +00:00
Refactor to make helper method static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168557 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -4166,33 +4166,24 @@ static SDValue expandExp2(DebugLoc dl, SDValue Op, SelectionDAG &DAG,
|
|||||||
|
|
||||||
/// visitPow - Lower a pow intrinsic. Handles the special sequences for
|
/// visitPow - Lower a pow intrinsic. Handles the special sequences for
|
||||||
/// limited-precision mode with x == 10.0f.
|
/// limited-precision mode with x == 10.0f.
|
||||||
void
|
static SDValue expandPow(DebugLoc dl, SDValue LHS, SDValue RHS,
|
||||||
SelectionDAGBuilder::visitPow(const CallInst &I) {
|
SelectionDAG &DAG, const TargetLowering &TLI) {
|
||||||
SDValue result;
|
|
||||||
const Value *Val = I.getArgOperand(0);
|
|
||||||
DebugLoc dl = getCurDebugLoc();
|
|
||||||
bool IsExp10 = false;
|
bool IsExp10 = false;
|
||||||
|
if (LHS.getValueType() == MVT::f32 && LHS.getValueType() == MVT::f32 &&
|
||||||
if (getValue(Val).getValueType() == MVT::f32 &&
|
|
||||||
getValue(I.getArgOperand(1)).getValueType() == MVT::f32 &&
|
|
||||||
LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
|
LimitFloatPrecision > 0 && LimitFloatPrecision <= 18) {
|
||||||
if (Constant *C = const_cast<Constant*>(dyn_cast<Constant>(Val))) {
|
if (ConstantFPSDNode *LHSC = dyn_cast<ConstantFPSDNode>(LHS)) {
|
||||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
|
|
||||||
APFloat Ten(10.0f);
|
APFloat Ten(10.0f);
|
||||||
IsExp10 = CFP->getValueAPF().bitwiseIsEqual(Ten);
|
IsExp10 = LHSC->isExactlyValue(Ten);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsExp10) {
|
if (IsExp10) {
|
||||||
SDValue Op = getValue(I.getArgOperand(1));
|
|
||||||
|
|
||||||
// Put the exponent in the right bit position for later addition to the
|
// Put the exponent in the right bit position for later addition to the
|
||||||
// final result:
|
// final result:
|
||||||
//
|
//
|
||||||
// #define LOG2OF10 3.3219281f
|
// #define LOG2OF10 3.3219281f
|
||||||
// IntegerPartOfX = (int32_t)(x * LOG2OF10);
|
// IntegerPartOfX = (int32_t)(x * LOG2OF10);
|
||||||
SDValue t0 = DAG.getNode(ISD::FMUL, dl, MVT::f32, Op,
|
SDValue t0 = DAG.getNode(ISD::FMUL, dl, MVT::f32, RHS,
|
||||||
getF32Constant(DAG, 0x40549a78));
|
getF32Constant(DAG, 0x40549a78));
|
||||||
SDValue IntegerPartOfX = DAG.getNode(ISD::FP_TO_SINT, dl, MVT::i32, t0);
|
SDValue IntegerPartOfX = DAG.getNode(ISD::FP_TO_SINT, dl, MVT::i32, t0);
|
||||||
|
|
||||||
@@ -4272,18 +4263,13 @@ SelectionDAGBuilder::visitPow(const CallInst &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDValue t13 = DAG.getNode(ISD::BITCAST, dl,MVT::i32,TwoToFractionalPartOfX);
|
SDValue t13 = DAG.getNode(ISD::BITCAST, dl,MVT::i32,TwoToFractionalPartOfX);
|
||||||
result = DAG.getNode(ISD::BITCAST, dl, MVT::f32,
|
return DAG.getNode(ISD::BITCAST, dl, MVT::f32,
|
||||||
DAG.getNode(ISD::ADD, dl, MVT::i32,
|
DAG.getNode(ISD::ADD, dl, MVT::i32,
|
||||||
t13, IntegerPartOfX));
|
t13, IntegerPartOfX));
|
||||||
} else {
|
|
||||||
// No special expansion.
|
|
||||||
result = DAG.getNode(ISD::FPOW, dl,
|
|
||||||
getValue(I.getArgOperand(0)).getValueType(),
|
|
||||||
getValue(I.getArgOperand(0)),
|
|
||||||
getValue(I.getArgOperand(1)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(&I, result);
|
// No special expansion.
|
||||||
|
return DAG.getNode(ISD::FPOW, dl, LHS.getValueType(), LHS, RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4870,7 +4856,8 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
|
|||||||
setValue(&I, expandExp2(dl, getValue(I.getArgOperand(0)), DAG, TLI));
|
setValue(&I, expandExp2(dl, getValue(I.getArgOperand(0)), DAG, TLI));
|
||||||
return 0;
|
return 0;
|
||||||
case Intrinsic::pow:
|
case Intrinsic::pow:
|
||||||
visitPow(I);
|
setValue(&I, expandPow(dl, getValue(I.getArgOperand(0)),
|
||||||
|
getValue(I.getArgOperand(1)), DAG, TLI));
|
||||||
return 0;
|
return 0;
|
||||||
case Intrinsic::sqrt:
|
case Intrinsic::sqrt:
|
||||||
case Intrinsic::fabs:
|
case Intrinsic::fabs:
|
||||||
|
@@ -533,8 +533,6 @@ private:
|
|||||||
const char *visitIntrinsicCall(const CallInst &I, unsigned Intrinsic);
|
const char *visitIntrinsicCall(const CallInst &I, unsigned Intrinsic);
|
||||||
void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic);
|
void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic);
|
||||||
|
|
||||||
void visitPow(const CallInst &I);
|
|
||||||
|
|
||||||
void visitVAStart(const CallInst &I);
|
void visitVAStart(const CallInst &I);
|
||||||
void visitVAArg(const VAArgInst &I);
|
void visitVAArg(const VAArgInst &I);
|
||||||
void visitVAEnd(const CallInst &I);
|
void visitVAEnd(const CallInst &I);
|
||||||
|
Reference in New Issue
Block a user