[Lldb-commits] [lldb] r261206 - [LLDB][MIPS] Provide CPU string to compiler for appropriate code generation for MIPS

Hans Wennborg via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 22 10:55:09 PST 2016


Hi Bhushan,

This looks more like new functionality than a regression fix from 3.7.
As such, I'd rather not merge it to 3.8 this late in the process.

Thanks,
Hans

On Sun, Feb 21, 2016 at 9:08 PM, Bhushan Attarde
<Bhushan.Attarde at imgtec.com> wrote:
> Hi Hans,
>
> Could you please add this (r261206) to the release branch?
>
> Thanks,
> Bhushan
>
>
> -----Original Message-----
> From: lldb-commits [mailto:lldb-commits-bounces at lists.llvm.org] On Behalf Of Bhushan D. Attarde via lldb-commits
> Sent: 18 February 2016 17:23
> To: lldb-commits at lists.llvm.org
> Subject: [Lldb-commits] [lldb] r261206 - [LLDB][MIPS] Provide CPU string to compiler for appropriate code generation for MIPS
>
> Author: bhushan.attarde
> Date: Thu Feb 18 05:53:28 2016
> New Revision: 261206
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261206&view=rev
> Log:
> [LLDB][MIPS] Provide CPU string to compiler for appropriate code generation for MIPS
>
>     SUMMARY:
>     This patch implements ArchSpec::GetClangTargetCPU() that provides string representing current architecture as a target CPU.
>     This string is then passed to tools like clang so that they generate correct code for that target.
>
>     Reviewers: clayborg, zturner
>     Subscribers: mohit.bhakkad, sagar, jaydeep, lldb-commits
>     Differential Revision: http://reviews.llvm.org/D17022
>
> Modified:
>     lldb/trunk/include/lldb/Core/ArchSpec.h
>     lldb/trunk/source/Core/ArchSpec.cpp
>     lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
>
> Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=261206&r1=261205&r2=261206&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
> +++ lldb/trunk/include/lldb/Core/ArchSpec.h Thu Feb 18 05:53:28 2016
> @@ -288,6 +288,16 @@ public:
>      GetArchitectureName () const;
>
>      //------------------------------------------------------------------
> +    /// Returns a string representing current architecture as a target CPU
> +    /// for tools like compiler, disassembler etc.
> +    ///
> +    /// @return A string representing target CPU for the current
> +    ///         architecture.
> +    //------------------------------------------------------------------
> +    std::string
> +    GetClangTargetCPU ();
> +
> +
> + //------------------------------------------------------------------
>      /// Clears the object state.
>      ///
>      /// Clears the object state back to a default invalid state.
>
> Modified: lldb/trunk/source/Core/ArchSpec.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=261206&r1=261205&r2=261206&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/ArchSpec.cpp (original)
> +++ lldb/trunk/source/Core/ArchSpec.cpp Thu Feb 18 05:53:28 2016
> @@ -511,6 +511,56 @@ ArchSpec::GetArchitectureName () const
>      return "unknown";
>  }
>
> +std::string
> +ArchSpec::GetClangTargetCPU ()
> +{
> +    std::string cpu;
> +    const llvm::Triple::ArchType machine = GetMachine();
> +
> +    if (machine == llvm::Triple::mips ||
> +        machine == llvm::Triple::mipsel ||
> +        machine == llvm::Triple::mips64 ||
> +        machine == llvm::Triple::mips64el)
> +    {
> +        switch (m_core)
> +        {
> +        case ArchSpec::eCore_mips32:
> +        case ArchSpec::eCore_mips32el:
> +            cpu = "mips32"; break;
> +        case ArchSpec::eCore_mips32r2:
> +        case ArchSpec::eCore_mips32r2el:
> +            cpu = "mips32r2"; break;
> +        case ArchSpec::eCore_mips32r3:
> +        case ArchSpec::eCore_mips32r3el:
> +            cpu = "mips32r3"; break;
> +        case ArchSpec::eCore_mips32r5:
> +        case ArchSpec::eCore_mips32r5el:
> +            cpu = "mips32r5"; break;
> +        case ArchSpec::eCore_mips32r6:
> +        case ArchSpec::eCore_mips32r6el:
> +            cpu = "mips32r6"; break;
> +        case ArchSpec::eCore_mips64:
> +        case ArchSpec::eCore_mips64el:
> +            cpu = "mips64"; break;
> +        case ArchSpec::eCore_mips64r2:
> +        case ArchSpec::eCore_mips64r2el:
> +            cpu = "mips64r2"; break;
> +        case ArchSpec::eCore_mips64r3:
> +        case ArchSpec::eCore_mips64r3el:
> +            cpu = "mips64r3"; break;
> +        case ArchSpec::eCore_mips64r5:
> +        case ArchSpec::eCore_mips64r5el:
> +            cpu = "mips64r5"; break;
> +        case ArchSpec::eCore_mips64r6:
> +        case ArchSpec::eCore_mips64r6el:
> +            cpu = "mips64r6"; break;
> +        default:
> +            break;
> +        }
> +    }
> +    return cpu;
> +}
> +
>  uint32_t
>  ArchSpec::GetMachOCPUType () const
>  {
>
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=261206&r1=261205&r2=261206&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionPars
> +++ er.cpp Thu Feb 18 05:53:28 2016
> @@ -179,6 +179,12 @@ ClangExpressionParser::ClangExpressionPa
>      if (exe_scope)
>          target_sp = exe_scope->CalculateTarget();
>
> +    ArchSpec target_arch;
> +    if (target_sp)
> +        target_arch = target_sp->GetArchitecture();
> +
> +    const auto target_machine = target_arch.GetMachine();
> +
>      // If the expression is being evaluated in the context of an existing
>      // stack frame, we introspect to see if the language runtime is available.
>      auto frame = exe_scope->CalculateStackFrame(); @@ -197,9 +203,9 @@ ClangExpressionParser::ClangExpressionPa
>
>      // 2. Configure the compiler with a set of default options that are appropriate
>      // for most situations.
> -    if (target_sp && target_sp->GetArchitecture().IsValid())
> +    if (target_sp && target_arch.IsValid())
>      {
> -        std::string triple = target_sp->GetArchitecture().GetTriple().str();
> +        std::string triple = target_arch.GetTriple().str();
>          m_compiler->getTargetOpts().Triple = triple;
>          if (log)
>              log->Printf("Using %s as the target triple", m_compiler->getTargetOpts().Triple.c_str());
> @@ -224,13 +230,17 @@ ClangExpressionParser::ClangExpressionPa
>          m_compiler->getTargetOpts().ABI = "apcs-gnu";
>      }
>      // Supported subsets of x86
> -    if (target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86 ||
> -        target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64)
> +    if (target_machine == llvm::Triple::x86 ||
> +        target_machine == llvm::Triple::x86_64)
>      {
>          m_compiler->getTargetOpts().Features.push_back("+sse");
>          m_compiler->getTargetOpts().Features.push_back("+sse2");
>      }
>
> +    // Set the target CPU to generate code for.
> +    // 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();
> +
>      // 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.
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


More information about the lldb-commits mailing list