Add uppercase and lowercase part defines in driver.
[oota-llvm.git] / tools / llvmc / example / mcc16 / plugins / PIC16Base / PluginMain.cpp
index a6d2ff6b1ae4a5c45719ae17953cd9a5e4073659..9b2f9fc5448d4d8f05afa99639bf60768747d893 100644 (file)
@@ -9,6 +9,8 @@ namespace llvmc {
   extern char *ProgramName;
 }
 
+  
+
 // Returns the platform specific directory separator via #ifdefs.
 // FIXME: This currently work on linux and windows only. It does not 
 // work on other unices. 
@@ -21,6 +23,43 @@ static std::string GetDirSeparator() {
 }
 
 namespace hooks {
+// Get preprocessor define for the part.
+// It is __partname format in lower case.
+std::string
+GetLowerCasePartDefine(void) {
+  std::string Partname;
+  if (AutoGeneratedParameter_p.empty()) {
+    Partname = "16f1xxx";
+  } else {
+    Partname = AutoGeneratedParameter_p;
+  }
+
+  std::string LowerCase;
+  for (unsigned i = 0; i <= Partname.size(); i++) {
+    LowerCase.push_back(std::tolower(Partname[i]));
+  }
+
+  return "__" + LowerCase;
+}
+
+std::string
+GetUpperCasePartDefine(void) {
+  std::string Partname;
+  if (AutoGeneratedParameter_p.empty()) {
+    Partname = "16f1xxx";
+  } else {
+    Partname = AutoGeneratedParameter_p;
+  }
+
+  std::string UpperCase;
+  for (unsigned i = 0; i <= Partname.size(); i++) {
+    UpperCase.push_back(std::toupper(Partname[i]));
+  }
+
+  return "__" +  UpperCase;
+}
+
+
 // Get the dir where c16 executables reside.
 std::string GetBinDir() {
   // Construct a Path object from the program name.