mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Split the Add, Sub, and Mul instruction opcodes into separate
integer and floating-point opcodes, introducing FAdd, FSub, and FMul. For now, the AsmParser, BitcodeReader, and IRBuilder all preserve backwards compatability, and the Core LLVM APIs preserve backwards compatibility for IR producers. Most front-ends won't need to change immediately. This implements the first step of the plan outlined here: http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72897 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -842,20 +842,6 @@ void SelectionDAGLowering::visit(unsigned Opcode, User &I) {
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionDAGLowering::visitAdd(User &I) {
|
||||
if (I.getType()->isFPOrFPVector())
|
||||
visitBinary(I, ISD::FADD);
|
||||
else
|
||||
visitBinary(I, ISD::ADD);
|
||||
}
|
||||
|
||||
void SelectionDAGLowering::visitMul(User &I) {
|
||||
if (I.getType()->isFPOrFPVector())
|
||||
visitBinary(I, ISD::FMUL);
|
||||
else
|
||||
visitBinary(I, ISD::MUL);
|
||||
}
|
||||
|
||||
SDValue SelectionDAGLowering::getValue(const Value *V) {
|
||||
SDValue &N = NodeMap[V];
|
||||
if (N.getNode()) return N;
|
||||
@@ -2161,37 +2147,33 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &SI) {
|
||||
}
|
||||
|
||||
|
||||
void SelectionDAGLowering::visitSub(User &I) {
|
||||
void SelectionDAGLowering::visitFSub(User &I) {
|
||||
// -0.0 - X --> fneg
|
||||
const Type *Ty = I.getType();
|
||||
if (isa<VectorType>(Ty)) {
|
||||
if (ConstantVector *CV = dyn_cast<ConstantVector>(I.getOperand(0))) {
|
||||
const VectorType *DestTy = cast<VectorType>(I.getType());
|
||||
const Type *ElTy = DestTy->getElementType();
|
||||
if (ElTy->isFloatingPoint()) {
|
||||
unsigned VL = DestTy->getNumElements();
|
||||
std::vector<Constant*> NZ(VL, ConstantFP::getNegativeZero(ElTy));
|
||||
Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
|
||||
if (CV == CNZ) {
|
||||
SDValue Op2 = getValue(I.getOperand(1));
|
||||
setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
|
||||
Op2.getValueType(), Op2));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Ty->isFloatingPoint()) {
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0)))
|
||||
if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
|
||||
unsigned VL = DestTy->getNumElements();
|
||||
std::vector<Constant*> NZ(VL, ConstantFP::getNegativeZero(ElTy));
|
||||
Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
|
||||
if (CV == CNZ) {
|
||||
SDValue Op2 = getValue(I.getOperand(1));
|
||||
setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
|
||||
Op2.getValueType(), Op2));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0)))
|
||||
if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
|
||||
SDValue Op2 = getValue(I.getOperand(1));
|
||||
setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
|
||||
Op2.getValueType(), Op2));
|
||||
return;
|
||||
}
|
||||
|
||||
visitBinary(I, Ty->isFPOrFPVector() ? ISD::FSUB : ISD::SUB);
|
||||
visitBinary(I, ISD::FSUB);
|
||||
}
|
||||
|
||||
void SelectionDAGLowering::visitBinary(User &I, unsigned OpCode) {
|
||||
|
||||
Reference in New Issue
Block a user