[llvm-branch-commits] [lldb] r271378 - Merging r261206:
Mohit K. Bhakkad via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jun 1 03:39:47 PDT 2016
Author: mohit.bhakkad
Date: Wed Jun 1 05:36:32 2016
New Revision: 271378
URL: http://llvm.org/viewvc/llvm-project?rev=271378&view=rev
Log:
Merging r261206:
------------------------------------------------------------------------
r261206 | bhushan.attarde | 2016-02-18 17:23:28 +0530 (Thu, 18 Feb 2016) | 9 lines
[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/branches/release_38/ (props changed)
lldb/branches/release_38/include/lldb/Core/ArchSpec.h
lldb/branches/release_38/source/Core/ArchSpec.cpp
lldb/branches/release_38/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
Propchange: lldb/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 1 05:36:32 2016
@@ -1,3 +1,3 @@
/lldb/branches/apple/python-GIL:156467-162159
/lldb/branches/iohandler:198360-200250
-/lldb/trunk:257691-257692,257926,258485,258621,258684-258685,258758,258761,258919,258967,259188,260072,260362,262819,264030,265134
+/lldb/trunk:257691-257692,257926,258485,258621,258684-258685,258758,258761,258919,258967,259188,260072,260362,261206,262819,264030,265134
Modified: lldb/branches/release_38/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/include/lldb/Core/ArchSpec.h?rev=271378&r1=271377&r2=271378&view=diff
==============================================================================
--- lldb/branches/release_38/include/lldb/Core/ArchSpec.h (original)
+++ lldb/branches/release_38/include/lldb/Core/ArchSpec.h Wed Jun 1 05:36:32 2016
@@ -281,6 +281,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/branches/release_38/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Core/ArchSpec.cpp?rev=271378&r1=271377&r2=271378&view=diff
==============================================================================
--- lldb/branches/release_38/source/Core/ArchSpec.cpp (original)
+++ lldb/branches/release_38/source/Core/ArchSpec.cpp Wed Jun 1 05:36:32 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/branches/release_38/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=271378&r1=271377&r2=271378&view=diff
==============================================================================
--- lldb/branches/release_38/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)
+++ lldb/branches/release_38/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Wed Jun 1 05:36:32 2016
@@ -175,14 +175,21 @@ 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();
+
// TODO: figure out what to really do when we don't have a valid target.
// Sometimes this will be ok to just use the host target triple (when we
// evaluate say "2+3", but other expressions like breakpoint conditions
// and other things that _are_ target specific really shouldn't just be
// using the host triple. This needs to be fixed in a better way.
- 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;
}
else
@@ -190,8 +197,8 @@ ClangExpressionParser::ClangExpressionPa
m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
}
- 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");
@@ -207,6 +214,10 @@ ClangExpressionParser::ClangExpressionPa
m_compiler->createDiagnostics();
+ // 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();
+
// Create the target instance.
m_compiler->setTarget(TargetInfo::CreateTargetInfo(
m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts));
More information about the llvm-branch-commits
mailing list