Skip to content

Commit

Permalink
[lldb][AIX] Updating XCOFF,PPC entry in LLDB ArchSpec (#105523)
Browse files Browse the repository at this point in the history
This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:

1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. #101657 

The complete changes for porting are present in this draft PR:
#102601 

The changes in this PR are intended to update the Architecture entry for
LLDB with XCOFF,PPC.

1. Added new ArchitectureType `eArchTypeXCOFF`
2. Added a new `ArchDefinitionEntry g_xcoff_arch_entries[]`
3. Added a new case for `XCOFF in ArchSpec::SetArchitecture(..)`
4. Updated `ArchDefinition *g_arch_definitions[]`
  • Loading branch information
DhruvSrivastavaX authored Aug 22, 2024
1 parent b4ac5c4 commit 1b664fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lldb/include/lldb/lldb-private-enumerations.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum ArchitectureType {
eArchTypeMachO,
eArchTypeELF,
eArchTypeCOFF,
eArchTypeXCOFF,
kNumArchTypes
};

Expand Down
19 changes: 18 additions & 1 deletion lldb/source/Utility/ArchSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/Support/Compiler.h"
#include "llvm/TargetParser/ARMTargetParser.h"

Expand Down Expand Up @@ -459,10 +460,23 @@ static const ArchDefinition g_coff_arch_def = {
"pe-coff",
};

static const ArchDefinitionEntry g_xcoff_arch_entries[] = {
{ArchSpec::eCore_ppc_generic, llvm::XCOFF::TCPU_COM, LLDB_INVALID_CPUTYPE,
0xFFFFFFFFu, 0xFFFFFFFFu},
{ArchSpec::eCore_ppc64_generic, llvm::XCOFF::TCPU_PPC64,
LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}};

static const ArchDefinition g_xcoff_arch_def = {
eArchTypeXCOFF,
std::size(g_xcoff_arch_entries),
g_xcoff_arch_entries,
"xcoff",
};

//===----------------------------------------------------------------------===//
// Table of all ArchDefinitions
static const ArchDefinition *g_arch_definitions[] = {
&g_macho_arch_def, &g_elf_arch_def, &g_coff_arch_def};
&g_macho_arch_def, &g_elf_arch_def, &g_coff_arch_def, &g_xcoff_arch_def};

//===----------------------------------------------------------------------===//
// Static helper functions.
Expand Down Expand Up @@ -903,6 +917,9 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
} else if (arch_type == eArchTypeCOFF && os == llvm::Triple::Win32) {
m_triple.setVendor(llvm::Triple::PC);
m_triple.setOS(llvm::Triple::Win32);
} else if (arch_type == eArchTypeXCOFF && os == llvm::Triple::AIX) {
m_triple.setVendor(llvm::Triple::IBM);
m_triple.setOS(llvm::Triple::AIX);
} else {
m_triple.setVendor(llvm::Triple::UnknownVendor);
m_triple.setOS(llvm::Triple::UnknownOS);
Expand Down

0 comments on commit 1b664fe

Please sign in to comment.