mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Fix lowering to work correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14134 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -69,7 +69,14 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
|
|||||||
|
|
||||||
std::string Name = CI->getName(); CI->setName("");
|
std::string Name = CI->getName(); CI->setName("");
|
||||||
if (FT->getReturnType() == Type::VoidTy) Name.clear();
|
if (FT->getReturnType() == Type::VoidTy) Name.clear();
|
||||||
return new CallInst(FCache, Operands, Name, CI);
|
CallInst *NewCI = new CallInst(FCache, Operands, Name, CI);
|
||||||
|
if (!CI->use_empty()) {
|
||||||
|
Value *V = NewCI;
|
||||||
|
if (CI->getType() != NewCI->getType())
|
||||||
|
V = new CastInst(NewCI, CI->getType(), Name, CI);
|
||||||
|
CI->replaceAllUsesWith(V);
|
||||||
|
}
|
||||||
|
return NewCI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
|
void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
|
||||||
@@ -98,7 +105,9 @@ void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
|
|||||||
EnsureFunctionExists(M, "memset", I->abegin(), --I->aend(),
|
EnsureFunctionExists(M, "memset", I->abegin(), --I->aend(),
|
||||||
I->abegin()->getType());
|
I->abegin()->getType());
|
||||||
break;
|
break;
|
||||||
|
case Intrinsic::isnan:
|
||||||
|
EnsureFunctionExists(M, "isnan", I->abegin(), I->aend(), Type::BoolTy);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -196,7 +205,7 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
|||||||
// multiple isnans for different FP arguments.
|
// multiple isnans for different FP arguments.
|
||||||
static Function *isnanFCache = 0;
|
static Function *isnanFCache = 0;
|
||||||
ReplaceCallWith("isnan", CI, CI->op_begin()+1, CI->op_end(),
|
ReplaceCallWith("isnan", CI, CI->op_begin()+1, CI->op_end(),
|
||||||
(*(CI->op_begin()+1))->getType(), isnanFCache);
|
Type::BoolTy, isnanFCache);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,14 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
|
|||||||
|
|
||||||
std::string Name = CI->getName(); CI->setName("");
|
std::string Name = CI->getName(); CI->setName("");
|
||||||
if (FT->getReturnType() == Type::VoidTy) Name.clear();
|
if (FT->getReturnType() == Type::VoidTy) Name.clear();
|
||||||
return new CallInst(FCache, Operands, Name, CI);
|
CallInst *NewCI = new CallInst(FCache, Operands, Name, CI);
|
||||||
|
if (!CI->use_empty()) {
|
||||||
|
Value *V = NewCI;
|
||||||
|
if (CI->getType() != NewCI->getType())
|
||||||
|
V = new CastInst(NewCI, CI->getType(), Name, CI);
|
||||||
|
CI->replaceAllUsesWith(V);
|
||||||
|
}
|
||||||
|
return NewCI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
|
void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
|
||||||
@@ -98,7 +105,9 @@ void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
|
|||||||
EnsureFunctionExists(M, "memset", I->abegin(), --I->aend(),
|
EnsureFunctionExists(M, "memset", I->abegin(), --I->aend(),
|
||||||
I->abegin()->getType());
|
I->abegin()->getType());
|
||||||
break;
|
break;
|
||||||
|
case Intrinsic::isnan:
|
||||||
|
EnsureFunctionExists(M, "isnan", I->abegin(), I->aend(), Type::BoolTy);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -196,7 +205,7 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
|||||||
// multiple isnans for different FP arguments.
|
// multiple isnans for different FP arguments.
|
||||||
static Function *isnanFCache = 0;
|
static Function *isnanFCache = 0;
|
||||||
ReplaceCallWith("isnan", CI, CI->op_begin()+1, CI->op_end(),
|
ReplaceCallWith("isnan", CI, CI->op_begin()+1, CI->op_end(),
|
||||||
(*(CI->op_begin()+1))->getType(), isnanFCache);
|
Type::BoolTy, isnanFCache);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user