mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 18:33:22 +00:00
adjust to constant folding api changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cd2492e6ff
commit
72d88ae544
@ -85,23 +85,24 @@ llvm::canConstantFoldCallTo(Function *F) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *
|
static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
|
||||||
llvm::ConstantFoldFP(double (*NativeFP)(double), double V, const Type *Ty) {
|
const Type *Ty) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
V = NativeFP(V);
|
V = NativeFP(V);
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
return ConstantFP::get(Ty, V);
|
return ConstantFP::get(Ty, V);
|
||||||
|
errno = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
||||||
/// with the specified arguments, returning null if unsuccessful.
|
/// with the specified arguments, returning null if unsuccessful.
|
||||||
Constant *
|
Constant *
|
||||||
llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
|
llvm::ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands) {
|
||||||
const std::string &Name = F->getName();
|
const std::string &Name = F->getName();
|
||||||
const Type *Ty = F->getReturnType();
|
const Type *Ty = F->getReturnType();
|
||||||
|
|
||||||
if (Operands.size() == 1) {
|
if (NumOperands == 1) {
|
||||||
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
double V = Op->getValue();
|
double V = Op->getValue();
|
||||||
switch (Name[0])
|
switch (Name[0])
|
||||||
@ -172,7 +173,7 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
|
|||||||
else if (Name == "llvm.bswap.i64")
|
else if (Name == "llvm.bswap.i64")
|
||||||
return ConstantInt::get(Ty, ByteSwap_64(V));
|
return ConstantInt::get(Ty, ByteSwap_64(V));
|
||||||
}
|
}
|
||||||
} else if (Operands.size() == 2) {
|
} else if (NumOperands == 2) {
|
||||||
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
double Op1V = Op1->getValue();
|
double Op1V = Op1->getValue();
|
||||||
if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
|
if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
|
||||||
|
@ -1761,8 +1761,8 @@ static Constant *ConstantFold(const Instruction *I,
|
|||||||
return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
|
return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
|
||||||
case Instruction::Call:
|
case Instruction::Call:
|
||||||
if (Function *GV = dyn_cast<Function>(Operands[0])) {
|
if (Function *GV = dyn_cast<Function>(Operands[0])) {
|
||||||
Operands.erase(Operands.begin());
|
return ConstantFoldCall(cast<Function>(GV), &Operands[1],
|
||||||
return ConstantFoldCall(cast<Function>(GV), Operands);
|
Operands.size()-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case Instruction::GetElementPtr: {
|
case Instruction::GetElementPtr: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user