sketch out new location representation

This commit is contained in:
Ryan Fleury
2026-04-20 09:57:30 -07:00
parent eff693244b
commit 424549b562
3 changed files with 83 additions and 27 deletions
+27 -4
View File
@@ -1058,13 +1058,11 @@ RDI_SymbolMemberTable:
{
{name_string_idx RDI_U32 ""}
{symbol_flags RDI_SymbolFlags ""}
{location_kind RDI_LocationKind ""}
{container_flags RDI_ContainerFlags ""}
{reserved_0 RDI_U8 ""}
{reserved_1 RDI_U32 ""}
{reserved_0 RDI_U16 ""}
{location RDI_Location ""}
{container_idx RDI_U32 ""}
{type_idx RDI_U32 ""}
{location_idx RDI_U32 ""}
{root_scope_idx RDI_U32 ""}
{link_name_string_idx RDI_U32 ""}
}
@@ -1231,6 +1229,31 @@ RDI_LocationSetElementMemberTable:
@expand(RDI_LocationKindTable a) `$(a.name .. =>20) = $(a.value)`
}
@gen(enums)
{
`typedef RDI_U64 RDI_Location;`;
`#define RDI_Location_KindMask 0xff00000000000000ull`;
`#define RDI_Location_KindShift 56`;
`#define RDI_Location_OffMask 0x00ffffffffffffffull`;
`#define RDI_Location_OffShift 0`;
`#define RDI_Location_SetFirstIndexMask 0x00000000ffffffffull`;
`#define RDI_Location_SetFirstIndexShift 0`;
`#define RDI_Location_SetCountMask 0x00ffffff00000000ull`;
`#define RDI_Location_SetCountShift 32`;
`#define RDI_Location_RegCodeMask 0x00ff000000000000ull`;
`#define RDI_Location_RegCodeShift 48`;
`#define RDI_Location_RegOffMask 0x0000ffff00000000ull`;
`#define RDI_Location_RegOffShift 32`;
`#define rdi_kind_from_location(l) ((((l) & RDI_Location_KindMask) >> RDI_Location_KindShift))`;
`#define rdi_voff_from_location(l) (rdi_kind_from_location(l) == RDI_LocationKind_ModuleOff ? (((l) & RDI_Location_OffMask) >> RDI_Location_OffShift) : 0)`;
`#define rdi_toff_from_location(l) (rdi_kind_from_location(l) == RDI_LocationKind_TLSOff ? (((l) & RDI_Location_OffMask) >> RDI_Location_OffShift) : 0)`;
`#define rdi_constant_data_off_from_location(l) (rdi_kind_from_location(l) == RDI_LocationKind_ConstantDataOff ? (((l) & RDI_Location_OffMask) >> RDI_Location_OffShift) : 0)`;
`#define rdi_set_first_index_from_location(l) (rdi_kind_from_location(l) == RDI_LocationKind_Set ? (((l) & RDI_Location_SetFirstIndexMask) >> RDI_Location_SetFirstIndexShift) : 0)`;
`#define rdi_set_count_from_location(l) (rdi_kind_from_location(l) == RDI_LocationKind_Set ? (((l) & RDI_Location_SetCountMask) >> RDI_Location_SetCountShift) : 0)`;
`#define rdi_regcode_from_location(l) ((((l) & RDI_Location_RegCodeMask) >> RDI_Location_RegCodeShift))`;
`#define rdi_regoff_from_location(l) ((((l) & RDI_Location_RegOffMask) >> RDI_Location_RegOffShift))`;
}
//- rjf: xlists
@xlist RDI_LinkFlags_XList: