mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-23 16:30:00 +00:00
Remove the API compatibility layer which converted add, sub, and mul
to fadd, fsub, and fmul, when used with a floating-point type. LLVM has supported the new instructions since 2.6, so it's time to get on board. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b98c549d13
commit
1eaac53261
@ -2351,11 +2351,28 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
|
|||||||
if (NSW)
|
if (NSW)
|
||||||
return Error(ModifierLoc, "nsw only applies to integer operations");
|
return Error(ModifierLoc, "nsw only applies to integer operations");
|
||||||
}
|
}
|
||||||
// API compatibility: Accept either integer or floating-point types with
|
// Check that the type is valid for the operator.
|
||||||
// add, sub, and mul.
|
switch (Opc) {
|
||||||
if (!Val0->getType()->isIntOrIntVectorTy() &&
|
case Instruction::Add:
|
||||||
!Val0->getType()->isFPOrFPVectorTy())
|
case Instruction::Sub:
|
||||||
return Error(ID.Loc,"constexpr requires integer, fp, or vector operands");
|
case Instruction::Mul:
|
||||||
|
case Instruction::UDiv:
|
||||||
|
case Instruction::SDiv:
|
||||||
|
case Instruction::URem:
|
||||||
|
case Instruction::SRem:
|
||||||
|
if (!Val0->getType()->isIntOrIntVectorTy())
|
||||||
|
return Error(ID.Loc, "constexpr requires integer operands");
|
||||||
|
break;
|
||||||
|
case Instruction::FAdd:
|
||||||
|
case Instruction::FSub:
|
||||||
|
case Instruction::FMul:
|
||||||
|
case Instruction::FDiv:
|
||||||
|
case Instruction::FRem:
|
||||||
|
if (!Val0->getType()->isFPOrFPVectorTy())
|
||||||
|
return Error(ID.Loc, "constexpr requires fp operands");
|
||||||
|
break;
|
||||||
|
default: llvm_unreachable("Unknown binary operator!");
|
||||||
|
}
|
||||||
unsigned Flags = 0;
|
unsigned Flags = 0;
|
||||||
if (NUW) Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
|
if (NUW) Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
|
||||||
if (NSW) Flags |= OverflowingBinaryOperator::NoSignedWrap;
|
if (NSW) Flags |= OverflowingBinaryOperator::NoSignedWrap;
|
||||||
@ -3000,8 +3017,7 @@ int LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
|
|||||||
if (EatIfPresent(lltok::kw_nuw))
|
if (EatIfPresent(lltok::kw_nuw))
|
||||||
NUW = true;
|
NUW = true;
|
||||||
}
|
}
|
||||||
// API compatibility: Accept either integer or floating-point types.
|
bool Result = ParseArithmetic(Inst, PFS, KeywordVal, 1);
|
||||||
bool Result = ParseArithmetic(Inst, PFS, KeywordVal, 0);
|
|
||||||
if (!Result) {
|
if (!Result) {
|
||||||
if (!Inst->getType()->isIntOrIntVectorTy()) {
|
if (!Inst->getType()->isIntOrIntVectorTy()) {
|
||||||
if (NUW)
|
if (NUW)
|
||||||
|
@ -1450,12 +1450,6 @@ Constant *ConstantExpr::getCompareTy(unsigned short predicate,
|
|||||||
|
|
||||||
Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2,
|
Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2,
|
||||||
unsigned Flags) {
|
unsigned Flags) {
|
||||||
// API compatibility: Adjust integer opcodes to floating-point opcodes.
|
|
||||||
if (C1->getType()->isFPOrFPVectorTy()) {
|
|
||||||
if (Opcode == Instruction::Add) Opcode = Instruction::FAdd;
|
|
||||||
else if (Opcode == Instruction::Sub) Opcode = Instruction::FSub;
|
|
||||||
else if (Opcode == Instruction::Mul) Opcode = Instruction::FMul;
|
|
||||||
}
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
@ -1840,9 +1834,6 @@ Constant *ConstantExpr::getExtractValue(Constant *Agg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Constant* ConstantExpr::getNeg(Constant* C) {
|
Constant* ConstantExpr::getNeg(Constant* C) {
|
||||||
// API compatibility: Adjust integer opcodes to floating-point opcodes.
|
|
||||||
if (C->getType()->isFPOrFPVectorTy())
|
|
||||||
return getFNeg(C);
|
|
||||||
assert(C->getType()->isIntOrIntVectorTy() &&
|
assert(C->getType()->isIntOrIntVectorTy() &&
|
||||||
"Cannot NEG a nonintegral value!");
|
"Cannot NEG a nonintegral value!");
|
||||||
return get(Instruction::Sub,
|
return get(Instruction::Sub,
|
||||||
|
@ -1562,43 +1562,29 @@ const Type* ExtractValueInst::getIndexedType(const Type *Agg,
|
|||||||
// BinaryOperator Class
|
// BinaryOperator Class
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// AdjustIType - Map Add, Sub, and Mul to FAdd, FSub, and FMul when the
|
|
||||||
/// type is floating-point, to help provide compatibility with an older API.
|
|
||||||
///
|
|
||||||
static BinaryOperator::BinaryOps AdjustIType(BinaryOperator::BinaryOps iType,
|
|
||||||
const Type *Ty) {
|
|
||||||
// API compatibility: Adjust integer opcodes to floating-point opcodes.
|
|
||||||
if (Ty->isFPOrFPVectorTy()) {
|
|
||||||
if (iType == BinaryOperator::Add) iType = BinaryOperator::FAdd;
|
|
||||||
else if (iType == BinaryOperator::Sub) iType = BinaryOperator::FSub;
|
|
||||||
else if (iType == BinaryOperator::Mul) iType = BinaryOperator::FMul;
|
|
||||||
}
|
|
||||||
return iType;
|
|
||||||
}
|
|
||||||
|
|
||||||
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
||||||
const Type *Ty, const Twine &Name,
|
const Type *Ty, const Twine &Name,
|
||||||
Instruction *InsertBefore)
|
Instruction *InsertBefore)
|
||||||
: Instruction(Ty, AdjustIType(iType, Ty),
|
: Instruction(Ty, iType,
|
||||||
OperandTraits<BinaryOperator>::op_begin(this),
|
OperandTraits<BinaryOperator>::op_begin(this),
|
||||||
OperandTraits<BinaryOperator>::operands(this),
|
OperandTraits<BinaryOperator>::operands(this),
|
||||||
InsertBefore) {
|
InsertBefore) {
|
||||||
Op<0>() = S1;
|
Op<0>() = S1;
|
||||||
Op<1>() = S2;
|
Op<1>() = S2;
|
||||||
init(AdjustIType(iType, Ty));
|
init(iType);
|
||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
||||||
const Type *Ty, const Twine &Name,
|
const Type *Ty, const Twine &Name,
|
||||||
BasicBlock *InsertAtEnd)
|
BasicBlock *InsertAtEnd)
|
||||||
: Instruction(Ty, AdjustIType(iType, Ty),
|
: Instruction(Ty, iType,
|
||||||
OperandTraits<BinaryOperator>::op_begin(this),
|
OperandTraits<BinaryOperator>::op_begin(this),
|
||||||
OperandTraits<BinaryOperator>::operands(this),
|
OperandTraits<BinaryOperator>::operands(this),
|
||||||
InsertAtEnd) {
|
InsertAtEnd) {
|
||||||
Op<0>() = S1;
|
Op<0>() = S1;
|
||||||
Op<1>() = S2;
|
Op<1>() = S2;
|
||||||
init(AdjustIType(iType, Ty));
|
init(iType);
|
||||||
setName(Name);
|
setName(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user