[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
Wed Apr 6 22:24:54 PDT 2016
nitesh.jain updated this revision to Diff 52886.
nitesh.jain added a comment.
The diff is updated as per suggestion
Repository:
rL LLVM
http://reviews.llvm.org/D18638
Files:
source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -137,7 +137,19 @@
Error
RunStaticInitializers (lldb::IRExecutionUnitSP &execution_unit_sp,
ExecutionContext &exe_ctx);
-
+
+ //------------------------------------------------------------------
+ /// Returns a string representing current ABI.
+ ///
+ /// @param[in] target_arch
+ /// The target architecture.
+ ///
+ /// @return
+ /// A string representing target ABI for the current architecture.
+ //-------------------------------------------------------------------
+ std::string
+ GetClangTargetABI (const ArchSpec &target_arch);
+
private:
std::unique_ptr<llvm::LLVMContext> m_llvm_context; ///< The LLVM context to generate IR into
std::unique_ptr<clang::FileManager> m_file_manager; ///< The Clang file manager object used by the compiler
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 = GetClangTargetABI(target_arch);
+ 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.
@@ -645,6 +651,32 @@
return num_errors;
}
+std::string
+ClangExpressionParser::GetClangTargetABI (const ArchSpec &target_arch)
+{
+ std::string abi;
+ const llvm::Triple::ArchType machine = target_arch.GetMachine();
+
+ if(machine == llvm::Triple::mips ||
+ machine == llvm::Triple::mipsel ||
+ machine == llvm::Triple::mips64 ||
+ machine == llvm::Triple::mips64el)
+ {
+ switch (target_arch.GetFlags () & ArchSpec::eMIPSABI_mask)
+ {
+ case ArchSpec::eMIPSABI_N64:
+ abi = "n64"; break;
+ case ArchSpec::eMIPSABI_N32:
+ abi = "n32"; break;
+ case ArchSpec::eMIPSABI_O32:
+ abi = "o32"; break;
+ default:
+ break;
+ }
+ }
+ return abi;
+}
+
bool
ClangExpressionParser::RewriteExpression(DiagnosticManager &diagnostic_manager)
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18638.52886.patch
Type: text/x-patch
Size: 3179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160407/432db247/attachment.bin>
More information about the lldb-commits
mailing list