[llvm-commits] [llvm] r110759 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/lto.cpp

Rafael Espindola rafael.espindola at gmail.com
Tue Aug 10 17:15:14 PDT 2010


Author: rafael
Date: Tue Aug 10 19:15:13 2010
New Revision: 110759

URL: http://llvm.org/viewvc/llvm-project?rev=110759&view=rev
Log:
Make it possible to set the cpu used for codegen.

Modified:
    llvm/trunk/include/llvm-c/lto.h
    llvm/trunk/tools/gold/gold-plugin.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.h
    llvm/trunk/tools/lto/lto.cpp

Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=110759&r1=110758&r2=110759&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Tue Aug 10 19:15:13 2010
@@ -206,6 +206,13 @@
 
 
 /**
+ * Sets the cpu to generate code for.
+ */
+extern void
+lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu);
+
+
+/**
  * Sets the location of the "gcc" to run. If not set, libLTO will search for
  * "gcc" on the path.
  */

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=110759&r1=110758&r2=110759&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Aug 10 19:15:13 2010
@@ -70,6 +70,7 @@
   static std::vector<std::string> pass_through;
   static std::string extra_library_path;
   static std::string triple;
+  static std::string mcpu;
   // Additional options to pass into the code generator.
   // Note: This array will contain all plugin options which are not claimed
   // as plugin exclusive to pass to the code generator.
@@ -85,6 +86,8 @@
 
     if (opt == "generate-api-file") {
       generate_api_file = true;
+    } else if (opt.startswith("mcpu=")) {
+      mcpu = opt.substr(strlen("mcpu="));
     } else if (opt.startswith("as=")) {
       if (!as_path.empty()) {
         (*message)(LDPL_WARNING, "Path to as specified twice. "
@@ -413,6 +416,9 @@
     }
     lto_codegen_set_assembler_args(cg, &as_args_p[0], as_args_p.size());
   }
+  if (!options::mcpu.empty())
+    lto_codegen_set_cpu(cg, options::mcpu.c_str());
+
   // Pass through extra options to the code generator.
   if (!options::extra.empty()) {
     for (std::vector<std::string>::iterator it = options::extra.begin();

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=110759&r1=110758&r2=110759&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Aug 10 19:15:13 2010
@@ -119,6 +119,11 @@
     return true;
 }
 
+void LTOCodeGenerator::setCpu(const char* mCpu)
+{
+  _mCpu = mCpu;
+}
+
 void LTOCodeGenerator::setAssemblerPath(const char* path)
 {
     if ( _assemblerPath )
@@ -314,7 +319,7 @@
 
         // construct LTModule, hand over ownership of module and target
         SubtargetFeatures Features;
-        Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple));
+        Features.getDefaultSubtargetFeatures(_mCpu, llvm::Triple(Triple));
         std::string FeatureStr = Features.getString();
         _target = march->createTargetMachine(Triple, FeatureStr);
     }

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=110759&r1=110758&r2=110759&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.h (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.h Tue Aug 10 19:15:13 2010
@@ -36,6 +36,7 @@
     bool                addModule(struct LTOModule*, std::string& errMsg);
     bool                setDebugInfo(lto_debug_model, std::string& errMsg);
     bool                setCodePICModel(lto_codegen_model, std::string& errMsg);
+    void                setCpu(const char *cpu);
     void                setAssemblerPath(const char* path);
     void                setAssemblerArgs(const char** args, int nargs);
     void                addMustPreserveSymbol(const char* sym);
@@ -63,6 +64,7 @@
     llvm::MemoryBuffer*         _nativeObjectFile;
     std::vector<const char*>    _codegenOptions;
     llvm::sys::Path*            _assemblerPath;
+    std::string                 _mCpu;
     std::vector<std::string>    _assemblerArgs;
 };
 

Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=110759&r1=110758&r2=110759&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Tue Aug 10 19:15:13 2010
@@ -211,6 +211,14 @@
 }
 
 //
+// sets the cpu to generate code for
+//
+void lto_codegen_set_cpu(lto_code_gen_t cg, const char* cpu)
+{
+  return cg->setCpu(cpu);
+}
+
+//
 // sets the path to the assembler tool
 //
 void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path)





More information about the llvm-commits mailing list