define target names for std libcalls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjiv Gupta 2009-07-31 07:35:57 +00:00
parent b6804e9126
commit aa93917a5e
2 changed files with 34 additions and 12 deletions

View File

@ -255,14 +255,9 @@ namespace PIC16CC {
return false;
}
// FIXME: currently we track both @memcpy and memcpy, as
// the first one is generated by clang, and the second one by codegen
// while lowering intrinsics. One we fix codegen to use RTLIB, we can
// have only @memcpy here.
inline static bool isMemIntrinsic (const std::string &Name) {
if (Name.compare("@memcpy") == 0 || Name.compare("memcpy") == 0 ||
Name.compare("@memset") == 0 || Name.compare("memset") == 0 ||
Name.compare("@memmove") == 0 || Name.compare("memmove") == 0) {
if (Name.compare("@memcpy") == 0 || Name.compare("@memset") == 0 ||
Name.compare("@memmove") == 0) {
return true;
}

View File

@ -31,7 +31,7 @@ using namespace llvm;
static const char *getIntrinsicName(unsigned opcode) {
std::string Basename;
switch(opcode) {
default: assert (0 && "do not know intrinsic name");
default: llvm_unreachable("do not know intrinsic name");
// Arithmetic Right shift for integer types.
case PIC16ISD::SRA_I8: Basename = "sra.i8"; break;
case RTLIB::SRA_I16: Basename = "sra.i16"; break;
@ -115,10 +115,30 @@ static const char *getIntrinsicName(unsigned opcode) {
std::string Fullname = prefix + tagname + Basename;
// The name has to live through program life.
char *tmp = new char[Fullname.size() + 1];
strcpy (tmp, Fullname.c_str());
return tmp;
return createESName(Fullname);
}
// getStdLibCallName - Get the name for the standard library function.
static const char *getStdLibCallName(unsigned opcode) {
std::string BaseName;
switch(opcode) {
case RTLIB::COS_F32: BaseName = "cos";
break;
case RTLIB::SIN_F32: BaseName = "sin";
break;
case RTLIB::MEMCPY: BaseName = "memcpy";
break;
case RTLIB::MEMSET: BaseName = "memset";
break;
case RTLIB::MEMMOVE: BaseName = "memmove";
break;
default: llvm_unreachable("do not know std lib call name");
}
std::string prefix = PAN::getTagName(PAN::PREFIX_SYMBOL);
std::string LibCallName = prefix + BaseName;
// The name has to live through program life.
return createESName(LibCallName);
}
// PIC16TargetLowering Constructor.
@ -130,6 +150,13 @@ PIC16TargetLowering::PIC16TargetLowering(PIC16TargetMachine &TM)
addRegisterClass(MVT::i8, PIC16::GPRRegisterClass);
setShiftAmountType(MVT::i8);
// Std lib call names
setLibcallName(RTLIB::COS_F32, getStdLibCallName(RTLIB::COS_F32));
setLibcallName(RTLIB::SIN_F32, getStdLibCallName(RTLIB::SIN_F32));
setLibcallName(RTLIB::MEMCPY, getStdLibCallName(RTLIB::MEMCPY));
setLibcallName(RTLIB::MEMSET, getStdLibCallName(RTLIB::MEMSET));
setLibcallName(RTLIB::MEMMOVE, getStdLibCallName(RTLIB::MEMMOVE));
// SRA library call names
setPIC16LibcallName(PIC16ISD::SRA_I8, getIntrinsicName(PIC16ISD::SRA_I8));