[Lldb-commits] [PATCH] D18638: [LLDB][MIPS] Provide ABI string to compiler for appropriate code generation for MIPS

Nitesh Jain via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 31 00:04:12 PDT 2016


nitesh.jain set the repository for this revision to rL LLVM.
nitesh.jain updated this revision to Diff 52177.
nitesh.jain added a comment.

Corrected formatting issue


Repository:
  rL LLVM

http://reviews.llvm.org/D18638

Files:
  include/lldb/Core/ArchSpec.h
  source/Core/ArchSpec.cpp
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -268,6 +268,7 @@
     bool overridden_target_opts = false;
     lldb_private::LanguageRuntime *lang_rt = nullptr;
     lldb::TargetSP target_sp;
+    std::string abi;
     if (exe_scope)
         target_sp = exe_scope->CalculateTarget();
 
@@ -333,6 +334,11 @@
     // This will be empty for any CPU that doesn't really need to make a special CPU string.
     m_compiler->getTargetOpts().CPU = target_arch.GetClangTargetCPU();
 
+    // Set the target ABI
+    abi = target_arch.GetClangTargetABI();
+    if (!abi.empty())
+        m_compiler->getTargetOpts().ABI = abi;
+
     // 3. Now allow the runtime to provide custom configuration options for the target.
     // In this case, a specialized language runtime is available and we can query it for extra options.
     // For 99% of use cases, this will not be needed and should be provided when basic platform detection is not enough.
Index: source/Core/ArchSpec.cpp
===================================================================
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -505,6 +505,32 @@
 }
 
 std::string
+ArchSpec::GetClangTargetABI ()
+{
+    std::string abi;
+    const llvm::Triple::ArchType machine = GetMachine();
+
+    if (machine == llvm::Triple::mips ||
+        machine == llvm::Triple::mipsel ||
+        machine == llvm::Triple::mips64 ||
+        machine == llvm::Triple::mips64el)
+    {
+        switch (GetFlags () & eMIPSABI_mask)
+        {
+        case eMIPSABI_N64:
+             abi = "n64"; break;
+        case eMIPSABI_N32:
+             abi = "n32"; break;
+        case eMIPSABI_O32:
+             abi = "o32"; break;
+        default:
+               break;
+        }
+    }
+    return abi;
+}
+ 
+std::string
 ArchSpec::GetClangTargetCPU ()
 {
     std::string cpu;
Index: include/lldb/Core/ArchSpec.h
===================================================================
--- include/lldb/Core/ArchSpec.h
+++ include/lldb/Core/ArchSpec.h
@@ -298,6 +298,15 @@
     GetClangTargetCPU ();
 
     //------------------------------------------------------------------
+    /// Returns a string representing current ABI
+    ///
+    /// @return A string representing target ABI for the current
+    ///         architecture
+    //-----------------------------------------------------------------
+    std::string
+    GetClangTargetABI ();
+
+    //------------------------------------------------------------------
     /// Clears the object state.
     ///
     /// Clears the object state back to a default invalid state.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18638.52177.patch
Type: text/x-patch
Size: 2809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160331/89fe2d0f/attachment-0001.bin>


More information about the lldb-commits mailing list