mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-03 17:24:24 +00:00
Make this work with renamed intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26482 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
01ac91e2fd
commit
aecb0627fa
@ -283,8 +283,11 @@ public:
|
|||||||
Function* get_memcpy() {
|
Function* get_memcpy() {
|
||||||
if (!memcpy_func) {
|
if (!memcpy_func) {
|
||||||
const Type *SBP = PointerType::get(Type::SByteTy);
|
const Type *SBP = PointerType::get(Type::SByteTy);
|
||||||
memcpy_func = M->getOrInsertFunction("llvm.memcpy", Type::VoidTy,SBP, SBP,
|
const char *N = TD->getIntPtrType() == Type::UIntTy ?
|
||||||
TD->getIntPtrType(), Type::UIntTy, NULL);
|
"llvm.memcpy.i32" : "llvm.memcpy.i64";
|
||||||
|
memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
|
||||||
|
TD->getIntPtrType(), Type::UIntTy,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
return memcpy_func;
|
return memcpy_func;
|
||||||
}
|
}
|
||||||
@ -1018,16 +1021,9 @@ struct memcmpOptimization : public LibCallOptimization {
|
|||||||
/// bytes depending on the length of the string and the alignment. Additional
|
/// bytes depending on the length of the string and the alignment. Additional
|
||||||
/// optimizations are possible in code generation (sequence of immediate store)
|
/// optimizations are possible in code generation (sequence of immediate store)
|
||||||
/// @brief Simplify the memcpy library function.
|
/// @brief Simplify the memcpy library function.
|
||||||
struct LLVMMemCpyOptimization : public LibCallOptimization {
|
struct LLVMMemCpyMoveOptzn : public LibCallOptimization {
|
||||||
/// @brief Default Constructor
|
LLVMMemCpyMoveOptzn(const char* fname, const char* desc)
|
||||||
LLVMMemCpyOptimization() : LibCallOptimization("llvm.memcpy",
|
|
||||||
"Number of 'llvm.memcpy' calls simplified") {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// @brief Subclass Constructor
|
|
||||||
LLVMMemCpyOptimization(const char* fname, const char* desc)
|
|
||||||
: LibCallOptimization(fname, desc) {}
|
: LibCallOptimization(fname, desc) {}
|
||||||
public:
|
|
||||||
|
|
||||||
/// @brief Make sure that the "memcpy" function has the right prototype
|
/// @brief Make sure that the "memcpy" function has the right prototype
|
||||||
virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& TD) {
|
virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& TD) {
|
||||||
@ -1086,27 +1082,26 @@ public:
|
|||||||
ci->eraseFromParent();
|
ci->eraseFromParent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} LLVMMemCpyOptimizer;
|
};
|
||||||
|
|
||||||
/// This LibCallOptimization will simplify a call to the memmove library
|
/// This LibCallOptimization will simplify a call to the memcpy/memmove library
|
||||||
/// function. It is identical to MemCopyOptimization except for the name of
|
/// functions.
|
||||||
/// the intrinsic.
|
LLVMMemCpyMoveOptzn LLVMMemCpyOptimizer32("llvm.memcpy.i32",
|
||||||
/// @brief Simplify the memmove library function.
|
"Number of 'llvm.memcpy' calls simplified");
|
||||||
struct LLVMMemMoveOptimization : public LLVMMemCpyOptimization {
|
LLVMMemCpyMoveOptzn LLVMMemCpyOptimizer64("llvm.memcpy.i64",
|
||||||
/// @brief Default Constructor
|
"Number of 'llvm.memcpy' calls simplified");
|
||||||
LLVMMemMoveOptimization() : LLVMMemCpyOptimization("llvm.memmove",
|
LLVMMemCpyMoveOptzn LLVMMemMoveOptimizer32("llvm.memmove.i32",
|
||||||
"Number of 'llvm.memmove' calls simplified") {}
|
"Number of 'llvm.memmove' calls simplified");
|
||||||
|
LLVMMemCpyMoveOptzn LLVMMemMoveOptimizer64("llvm.memmove.i64",
|
||||||
} LLVMMemMoveOptimizer;
|
"Number of 'llvm.memmove' calls simplified");
|
||||||
|
|
||||||
/// This LibCallOptimization will simplify a call to the memset library
|
/// This LibCallOptimization will simplify a call to the memset library
|
||||||
/// function by expanding it out to a single store of size 0, 1, 2, 4, or 8
|
/// function by expanding it out to a single store of size 0, 1, 2, 4, or 8
|
||||||
/// bytes depending on the length argument.
|
/// bytes depending on the length argument.
|
||||||
struct LLVMMemSetOptimization : public LibCallOptimization {
|
struct LLVMMemSetOptimization : public LibCallOptimization {
|
||||||
/// @brief Default Constructor
|
/// @brief Default Constructor
|
||||||
LLVMMemSetOptimization() : LibCallOptimization("llvm.memset",
|
LLVMMemSetOptimization(const char *Name) : LibCallOptimization(Name,
|
||||||
"Number of 'llvm.memset' calls simplified") {}
|
"Number of 'llvm.memset' calls simplified") {}
|
||||||
public:
|
|
||||||
|
|
||||||
/// @brief Make sure that the "memset" function has the right prototype
|
/// @brief Make sure that the "memset" function has the right prototype
|
||||||
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &TD) {
|
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &TD) {
|
||||||
@ -1196,7 +1191,11 @@ public:
|
|||||||
ci->eraseFromParent();
|
ci->eraseFromParent();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} LLVMMemSetOptimizer;
|
};
|
||||||
|
|
||||||
|
LLVMMemSetOptimization MemSet32Optimizer("llvm.memset.i32");
|
||||||
|
LLVMMemSetOptimization MemSet64Optimizer("llvm.memset.i64");
|
||||||
|
|
||||||
|
|
||||||
/// This LibCallOptimization will simplify calls to the "pow" library
|
/// This LibCallOptimization will simplify calls to the "pow" library
|
||||||
/// function. It looks for cases where the result of pow is well known and
|
/// function. It looks for cases where the result of pow is well known and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user