define target names for std libcalls.
authorSanjiv Gupta <sanjiv.gupta@microchip.com>
Fri, 31 Jul 2009 07:35:57 +0000 (07:35 +0000)
committerSanjiv Gupta <sanjiv.gupta@microchip.com>
Fri, 31 Jul 2009 07:35:57 +0000 (07:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77667 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PIC16/PIC16.h
lib/Target/PIC16/PIC16ISelLowering.cpp

index 09453fb3c612c7682cb8627ee3aa41933c1f8f8e..ec2d1f6be1095363f523472e4621a72c5a8d29b3 100644 (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;
       }
       
index 7dc96d1e1fae43758bead2dc865ffe2324fea532..811bb1eaf5bf453de8b14143c6b4bd363d126d8d 100644 (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));