9#include "clang/AST/DeclCXX.h"
30 return std::make_shared<RegisterTypeBuilderClang>(target);
38 uint32_t register_byte_size,
40 if (
auto maybe_compiler_type =
42 return *maybe_compiler_type;
46 register_byte_size * 8);
47 CompilerType enum_type = type_system->CreateEnumerationType(
51 type_system->StartTagDeclarationDefinition(enum_type);
55 type_system->AddEnumerationValueToEnumerationType(
56 enum_type, decl, enumerator.m_name.c_str(), enumerator.m_value,
57 register_byte_size * 8);
60 type_system->CompleteTagDeclarationDefinition(enum_type);
63 std::make_pair(enum_type_info->
GetUID(), register_byte_size), enum_type);
70 if (
auto maybe_compiler_type =
72 return *maybe_compiler_type;
79 register_byte_size * 8);
84 type_system->StartTagDeclarationDefinition(flags_type);
86 for (
auto field : flags_info->
GetFields()) {
90 if (!enum_type_info->GetEnumerators().empty())
92 BuildEnumType(enum_type_info, register_byte_size, type_system);
94 type_system->AddFieldToRecordType(flags_type, field.GetName(), field_type,
95 field.GetSizeInBits());
98 type_system->CompleteTagDeclarationDefinition(flags_type);
100 type_system->SetIsPacked(flags_type);
104 llvm::expectedToOptional(flags_type.
GetByteSize(
nullptr)).value_or(0) ==
108 std::make_pair(flags_info->
GetUID(), register_byte_size), flags_type);
143 const RegisterType *register_type, uint32_t register_byte_size) {
147 return cached->second;
#define LLDB_PLUGIN_DEFINE(PluginName)
Generic representation of a type in a programming language.
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
A class that describes the declaration location of a lldb object.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
std::optional< CompilerType > GetExistingCompilerType(const RegisterType *register_type, uint32_t register_byte_size)
CompilerType BuildEnumType(const RegisterTypeEnum *enum_type_info, uint32_t register_byte_size, lldb::TypeSystemClangSP type_system)
CompilerType BuildFlagsType(const RegisterTypeFlags *flags_info, uint32_t register_byte_size, lldb::TypeSystemClangSP type_system)
std::weak_ptr< TypeSystemClang > m_cached_type_system
CompilerType GetRegisterType(const RegisterInfo ®_info) override
Do not cache the returned CompilerType.
llvm::SmallDenseMap< std::pair< uint64_t, uint32_t >, CompilerType, 8 > m_type_cache
static llvm::StringRef GetPluginNameStatic()
RegisterTypeBuilderClang(Target &target)
static llvm::StringRef GetPluginDescriptionStatic()
static lldb::RegisterTypeBuilderSP CreateInstance(Target &target)
const Enumerators & GetEnumerators() const
const std::vector< Field > & GetFields() const
RegisterTypeKind getKind() const
uint64_t GetUID() const
Return an identifier unique among all RegisterType instances constructed during the lifetime of the L...
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::RegisterTypeBuilder > RegisterTypeBuilderSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eEncodingUint
unsigned integer
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
Every register is described in detail including its name, alternate name (optional),...
uint32_t byte_size
Size in bytes of the register.
const RegisterType * register_type
If not nullptr, a type defined by XML descriptions.