forked from OSchip/llvm-project
[LLDB][MIPS] Provide ABI string to compiler for appropriate code generation for MIPS
Patch by Nitesh Jain. Summary: These patch will set clang::TargetOptions::ABI and accordingly code will be generated for MIPS target. Reviewers: ovyalov, clayborg Subscribers: lldb-commits, mohit.bhakkad, sagar, jaydeep, bhushan Differential: D18638 llvm-svn: 269407
This commit is contained in:
parent
6ec636d21e
commit
adc1abe77e
|
@ -286,7 +286,8 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
|
||||||
lldb::LanguageType frame_lang = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
|
lldb::LanguageType frame_lang = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
|
||||||
bool overridden_target_opts = false;
|
bool overridden_target_opts = false;
|
||||||
lldb_private::LanguageRuntime *lang_rt = nullptr;
|
lldb_private::LanguageRuntime *lang_rt = nullptr;
|
||||||
|
|
||||||
|
std::string abi;
|
||||||
ArchSpec target_arch;
|
ArchSpec target_arch;
|
||||||
target_arch = target_sp->GetArchitecture();
|
target_arch = target_sp->GetArchitecture();
|
||||||
|
|
||||||
|
@ -350,6 +351,11 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
|
||||||
// This will be empty for any CPU that doesn't really need to make a special CPU string.
|
// 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();
|
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.
|
// 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.
|
// 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.
|
// For 99% of use cases, this will not be needed and should be provided when basic platform detection is not enough.
|
||||||
|
@ -658,6 +664,29 @@ ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager)
|
||||||
return num_errors;
|
return num_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
ClangExpressionParser::GetClangTargetABI (const ArchSpec &target_arch)
|
||||||
|
{
|
||||||
|
std::string abi;
|
||||||
|
const llvm::Triple::ArchType machine = target_arch.GetMachine();
|
||||||
|
|
||||||
|
if(target_arch.IsMIPS())
|
||||||
|
{
|
||||||
|
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
|
bool
|
||||||
ClangExpressionParser::RewriteExpression(DiagnosticManager &diagnostic_manager)
|
ClangExpressionParser::RewriteExpression(DiagnosticManager &diagnostic_manager)
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,7 +137,19 @@ public:
|
||||||
Error
|
Error
|
||||||
RunStaticInitializers (lldb::IRExecutionUnitSP &execution_unit_sp,
|
RunStaticInitializers (lldb::IRExecutionUnitSP &execution_unit_sp,
|
||||||
ExecutionContext &exe_ctx);
|
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:
|
private:
|
||||||
std::unique_ptr<llvm::LLVMContext> m_llvm_context; ///< The LLVM context to generate IR into
|
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
|
std::unique_ptr<clang::FileManager> m_file_manager; ///< The Clang file manager object used by the compiler
|
||||||
|
|
Loading…
Reference in New Issue