mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Change APFloat::convertFromInteger to take the incoming
bit width instead of number of words allocated, which makes it actually work for int->APF conversions. Adjust callers. Add const to one of the APInt constructors to prevent surprising match when called with const argument. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42210 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f65f02d25
commit
910993e8dc
@ -172,7 +172,7 @@ public:
|
|||||||
/// @param numWords the number of words in bigVal
|
/// @param numWords the number of words in bigVal
|
||||||
/// @param bigVal a sequence of words to form the initial value of the APInt
|
/// @param bigVal a sequence of words to form the initial value of the APInt
|
||||||
/// @brief Construct an APInt of numBits width, initialized as bigVal[].
|
/// @brief Construct an APInt of numBits width, initialized as bigVal[].
|
||||||
APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[]);
|
APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[]);
|
||||||
|
|
||||||
/// This constructor interprets Val as a string in the given radix. The
|
/// This constructor interprets Val as a string in the given radix. The
|
||||||
/// interpretation stops when the first charater that is not suitable for the
|
/// interpretation stops when the first charater that is not suitable for the
|
||||||
|
@ -3215,7 +3215,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
|
|||||||
const uint64_t zero[] = {0, 0};
|
const uint64_t zero[] = {0, 0};
|
||||||
APFloat apf = APFloat(APInt(MVT::getSizeInBits(VT), 2, zero));
|
APFloat apf = APFloat(APInt(MVT::getSizeInBits(VT), 2, zero));
|
||||||
uint64_t x = 1ULL << ShiftAmt;
|
uint64_t x = 1ULL << ShiftAmt;
|
||||||
(void)apf.convertFromInteger(&x, 1, false, APFloat::rmTowardZero);
|
(void)apf.convertFromInteger(&x, MVT::getSizeInBits(NVT), false,
|
||||||
|
APFloat::rmTowardZero);
|
||||||
Tmp2 = DAG.getConstantFP(apf, VT);
|
Tmp2 = DAG.getConstantFP(apf, VT);
|
||||||
Tmp3 = DAG.getSetCC(TLI.getSetCCResultTy(),
|
Tmp3 = DAG.getSetCC(TLI.getSetCCResultTy(),
|
||||||
Node->getOperand(0), Tmp2, ISD::SETLT);
|
Node->getOperand(0), Tmp2, ISD::SETLT);
|
||||||
|
@ -1595,8 +1595,10 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
|
|||||||
case ISD::SINT_TO_FP: {
|
case ISD::SINT_TO_FP: {
|
||||||
const uint64_t zero[] = {0, 0};
|
const uint64_t zero[] = {0, 0};
|
||||||
APFloat apf = APFloat(APInt(MVT::getSizeInBits(VT), 2, zero));
|
APFloat apf = APFloat(APInt(MVT::getSizeInBits(VT), 2, zero));
|
||||||
(void)apf.convertFromInteger(&Val, 1, Opcode==ISD::SINT_TO_FP,
|
(void)apf.convertFromInteger(&Val,
|
||||||
APFloat::rmTowardZero);
|
MVT::getSizeInBits(Operand.getValueType()),
|
||||||
|
Opcode==ISD::SINT_TO_FP,
|
||||||
|
APFloat::rmTowardZero);
|
||||||
return getConstantFP(apf, VT);
|
return getConstantFP(apf, VT);
|
||||||
}
|
}
|
||||||
case ISD::BIT_CONVERT:
|
case ISD::BIT_CONVERT:
|
||||||
|
@ -393,10 +393,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
|
|||||||
GV.FloatVal = float(GV.IntVal.roundToDouble());
|
GV.FloatVal = float(GV.IntVal.roundToDouble());
|
||||||
else if (CE->getType() == Type::DoubleTy)
|
else if (CE->getType() == Type::DoubleTy)
|
||||||
GV.DoubleVal = GV.IntVal.roundToDouble();
|
GV.DoubleVal = GV.IntVal.roundToDouble();
|
||||||
else if (CE->getType() == Type::X86_FP80Ty) {
|
else if (CE->getType() == Type::X86_FP80Ty) {
|
||||||
const uint64_t zero[] = {0, 0};
|
const uint64_t zero[] = {0, 0};
|
||||||
APFloat apf = APFloat(APInt(80, 2, zero));
|
APFloat apf = APFloat(APInt(80, 2, zero));
|
||||||
(void)apf.convertFromInteger(GV.IntVal.getRawData(), 2, false,
|
(void)apf.convertFromInteger(GV.IntVal.getRawData(),
|
||||||
|
GV.IntVal.getBitWidth(), false,
|
||||||
APFloat::rmTowardZero);
|
APFloat::rmTowardZero);
|
||||||
GV.IntVal = apf.convertToAPInt();
|
GV.IntVal = apf.convertToAPInt();
|
||||||
}
|
}
|
||||||
@ -411,7 +412,8 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
|
|||||||
else if (CE->getType() == Type::X86_FP80Ty) {
|
else if (CE->getType() == Type::X86_FP80Ty) {
|
||||||
const uint64_t zero[] = { 0, 0};
|
const uint64_t zero[] = { 0, 0};
|
||||||
APFloat apf = APFloat(APInt(80, 2, zero));
|
APFloat apf = APFloat(APInt(80, 2, zero));
|
||||||
(void)apf.convertFromInteger(GV.IntVal.getRawData(), 2, true,
|
(void)apf.convertFromInteger(GV.IntVal.getRawData(),
|
||||||
|
GV.IntVal.getBitWidth(), true,
|
||||||
APFloat::rmTowardZero);
|
APFloat::rmTowardZero);
|
||||||
GV.IntVal = apf.convertToAPInt();
|
GV.IntVal = apf.convertToAPInt();
|
||||||
}
|
}
|
||||||
|
@ -1180,7 +1180,8 @@ APFloat::mod(const APFloat &rhs, roundingMode rounding_mode)
|
|||||||
if (fs==opInvalidOp)
|
if (fs==opInvalidOp)
|
||||||
return fs;
|
return fs;
|
||||||
|
|
||||||
fs = V.convertFromInteger(x, parts, true, rmNearestTiesToEven);
|
fs = V.convertFromInteger(x, parts * integerPartWidth, true,
|
||||||
|
rmNearestTiesToEven);
|
||||||
assert(fs==opOK); // should always work
|
assert(fs==opOK); // should always work
|
||||||
|
|
||||||
fs = V.multiply(rhs, rounding_mode);
|
fs = V.multiply(rhs, rounding_mode);
|
||||||
@ -1459,28 +1460,30 @@ APFloat::convertFromUnsignedInteger(integerPart *parts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
APFloat::opStatus
|
APFloat::opStatus
|
||||||
APFloat::convertFromInteger(const integerPart *parts,
|
APFloat::convertFromInteger(const integerPart *parts, unsigned int width,
|
||||||
unsigned int partCount, bool isSigned,
|
bool isSigned, roundingMode rounding_mode)
|
||||||
roundingMode rounding_mode)
|
|
||||||
{
|
{
|
||||||
unsigned int width;
|
unsigned int partCount = partCountForBits(width);
|
||||||
opStatus status;
|
opStatus status;
|
||||||
integerPart *copy;
|
APInt api = APInt(width, partCount, parts);
|
||||||
|
integerPart *copy = new integerPart[partCount];
|
||||||
copy = new integerPart[partCount];
|
|
||||||
APInt::tcAssign(copy, parts, partCount);
|
|
||||||
|
|
||||||
width = partCount * integerPartWidth;
|
|
||||||
|
|
||||||
sign = false;
|
sign = false;
|
||||||
if(isSigned && APInt::tcExtractBit(parts, width - 1)) {
|
if(isSigned) {
|
||||||
sign = true;
|
if (APInt::tcExtractBit(parts, width - 1)) {
|
||||||
APInt::tcNegate(copy, partCount);
|
sign = true;
|
||||||
|
if (width < partCount * integerPartWidth)
|
||||||
|
api = api.sext(partCount * integerPartWidth);
|
||||||
|
}
|
||||||
|
else if (width < partCount * integerPartWidth)
|
||||||
|
api = api.zext(partCount * integerPartWidth);
|
||||||
|
} else {
|
||||||
|
if (width < partCount * integerPartWidth)
|
||||||
|
api = api.zext(partCount * integerPartWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APInt::tcAssign(copy, api.getRawData(), partCount);
|
||||||
status = convertFromUnsignedInteger(copy, partCount, rounding_mode);
|
status = convertFromUnsignedInteger(copy, partCount, rounding_mode);
|
||||||
delete [] copy;
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ APInt::APInt(uint32_t numBits, uint64_t val, bool isSigned)
|
|||||||
clearUnusedBits();
|
clearUnusedBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
APInt::APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[])
|
APInt::APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[])
|
||||||
: BitWidth(numBits), VAL(0) {
|
: BitWidth(numBits), VAL(0) {
|
||||||
assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small");
|
assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small");
|
||||||
assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large");
|
assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large");
|
||||||
|
Loading…
Reference in New Issue
Block a user