new location info baking layout computation - symbol-inlined locations in most cases, + indirected to set elements / bytecode / constant data as needed

This commit is contained in:
Ryan Fleury
2026-04-20 09:57:30 -07:00
parent 424549b562
commit 911e8c135e
5 changed files with 124 additions and 113 deletions
+2 -7
View File
@@ -10,7 +10,7 @@
#ifndef RDI_C #ifndef RDI_C
#define RDI_C #define RDI_C
RDI_U16 rdi_section_element_size_table[58] = RDI_U16 rdi_section_element_size_table[53] =
{ {
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_TopLevelInfo), sizeof(RDI_TopLevelInfo),
@@ -53,12 +53,7 @@ sizeof(RDI_Symbol),
sizeof(RDI_Symbol), sizeof(RDI_Symbol),
sizeof(RDI_Symbol), sizeof(RDI_Symbol),
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_RegAndOffsetU16), sizeof(RDI_U8),
sizeof(RDI_RegCode),
sizeof(RDI_U64),
sizeof(RDI_U32),
sizeof(RDI_U64),
sizeof(RDI_LocationSet),
sizeof(RDI_LocationSetElement), sizeof(RDI_LocationSetElement),
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_U32), sizeof(RDI_U32),
+21 -63
View File
@@ -116,23 +116,18 @@ RDI_SectionKind_ConstantSymbols = 0x0025,
RDI_SectionKind_ProcedureSymbols = 0x0026, RDI_SectionKind_ProcedureSymbols = 0x0026,
RDI_SectionKind_LocalSymbols = 0x0027, RDI_SectionKind_LocalSymbols = 0x0027,
RDI_SectionKind_LocationsBytecodeData = 0x0028, RDI_SectionKind_LocationsBytecodeData = 0x0028,
RDI_SectionKind_LocationsRegPlusU16 = 0x0029, RDI_SectionKind_LocationsConstantData = 0x0029,
RDI_SectionKind_LocationsReg = 0x002A, RDI_SectionKind_LocationsSetElements = 0x002A,
RDI_SectionKind_LocationsModuleOff = 0x002B, RDI_SectionKind_ConstantValueData = 0x002B,
RDI_SectionKind_LocationsTLSOff = 0x002C, RDI_SectionKind_ConstantValueTable = 0x002C,
RDI_SectionKind_LocationsConstantDataOff = 0x002D, RDI_SectionKind_MD5Checksums = 0x002D,
RDI_SectionKind_LocationsSet = 0x002E, RDI_SectionKind_SHA1Checksums = 0x002E,
RDI_SectionKind_LocationsSetElements = 0x002F, RDI_SectionKind_SHA256Checksums = 0x002F,
RDI_SectionKind_ConstantValueData = 0x0030, RDI_SectionKind_Timestamps = 0x0030,
RDI_SectionKind_ConstantValueTable = 0x0031, RDI_SectionKind_NameMaps = 0x0031,
RDI_SectionKind_MD5Checksums = 0x0032, RDI_SectionKind_NameMapBuckets = 0x0032,
RDI_SectionKind_SHA1Checksums = 0x0033, RDI_SectionKind_NameMapNodes = 0x0033,
RDI_SectionKind_SHA256Checksums = 0x0034, RDI_SectionKind_COUNT = 0x0034,
RDI_SectionKind_Timestamps = 0x0035,
RDI_SectionKind_NameMaps = 0x0036,
RDI_SectionKind_NameMapBuckets = 0x0037,
RDI_SectionKind_NameMapNodes = 0x0038,
RDI_SectionKind_COUNT = 0x0039,
} RDI_SectionKindEnum; } RDI_SectionKindEnum;
typedef RDI_U32 RDI_SectionEncoding; typedef RDI_U32 RDI_SectionEncoding;
@@ -586,12 +581,7 @@ X(ConstantSymbols, constant_symbols, RDI_Symbol)\
X(ProcedureSymbols, procedure_symbols, RDI_Symbol)\ X(ProcedureSymbols, procedure_symbols, RDI_Symbol)\
X(LocalSymbols, local_symbols, RDI_Symbol)\ X(LocalSymbols, local_symbols, RDI_Symbol)\
X(LocationsBytecodeData, locations_bytecode_data, RDI_U8)\ X(LocationsBytecodeData, locations_bytecode_data, RDI_U8)\
X(LocationsRegPlusU16, locations_reg_plus_u16, RDI_RegAndOffsetU16)\ X(LocationsConstantData, locations_constant_data, RDI_U8)\
X(LocationsReg, locations_reg, RDI_RegCode)\
X(LocationsModuleOff, locations_module_off, RDI_U64)\
X(LocationsTLSOff, locations_tls_off, RDI_U32)\
X(LocationsConstantDataOff, locations_constant_data_off, RDI_U64)\
X(LocationsSet, locations_set, RDI_LocationSet)\
X(LocationsSetElements, locations_set_elements, RDI_LocationSetElement)\ X(LocationsSetElements, locations_set_elements, RDI_LocationSetElement)\
X(ConstantValueData, constant_value_data, RDI_U8)\ X(ConstantValueData, constant_value_data, RDI_U8)\
X(ConstantValueTable, constant_value_table, RDI_U32)\ X(ConstantValueTable, constant_value_table, RDI_U32)\
@@ -1018,17 +1008,10 @@ X(RDI_RegCode, reg_code)\
X(RDI_RegCode, reg_code)\ X(RDI_RegCode, reg_code)\
X(RDI_U16, offset)\ X(RDI_U16, offset)\
#define RDI_LocationSet_XList \
X(RDI_U32, set_element_idx_first)\
X(RDI_U32, set_element_idx_opl)\
#define RDI_LocationSetElement_XList \ #define RDI_LocationSetElement_XList \
X(RDI_LocationKind, kind)\
X(RDI_U8, reserved_0)\
X(RDI_U16, reserved_1)\
X(RDI_U32, idx)\
X(RDI_U32, scope_off_first)\ X(RDI_U32, scope_off_first)\
X(RDI_U32, scope_off_opl)\ X(RDI_U32, scope_off_opl)\
X(RDI_Location, location)\
#define RDI_EvalOp_XList \ #define RDI_EvalOp_XList \
X(Stop)\ X(Stop)\
@@ -1162,12 +1145,7 @@ typedef struct RDI_U32_ConstantSymbols { RDI_U32 v; } RDI_U32_Consta
typedef struct RDI_U32_ProcedureSymbols { RDI_U32 v; } RDI_U32_ProcedureSymbols; typedef struct RDI_U32_ProcedureSymbols { RDI_U32 v; } RDI_U32_ProcedureSymbols;
typedef struct RDI_U32_LocalSymbols { RDI_U32 v; } RDI_U32_LocalSymbols; typedef struct RDI_U32_LocalSymbols { RDI_U32 v; } RDI_U32_LocalSymbols;
typedef struct RDI_U32_LocationsBytecodeData { RDI_U32 v; } RDI_U32_LocationsBytecodeData; typedef struct RDI_U32_LocationsBytecodeData { RDI_U32 v; } RDI_U32_LocationsBytecodeData;
typedef struct RDI_U32_LocationsRegPlusU16 { RDI_U32 v; } RDI_U32_LocationsRegPlusU16; typedef struct RDI_U32_LocationsConstantData { RDI_U32 v; } RDI_U32_LocationsConstantData;
typedef struct RDI_U32_LocationsReg { RDI_U32 v; } RDI_U32_LocationsReg;
typedef struct RDI_U32_LocationsModuleOff { RDI_U32 v; } RDI_U32_LocationsModuleOff;
typedef struct RDI_U32_LocationsTLSOff { RDI_U32 v; } RDI_U32_LocationsTLSOff;
typedef struct RDI_U32_LocationsConstantDataOff { RDI_U32 v; } RDI_U32_LocationsConstantDataOff;
typedef struct RDI_U32_LocationsSet { RDI_U32 v; } RDI_U32_LocationsSet;
typedef struct RDI_U32_LocationsSetElements { RDI_U32 v; } RDI_U32_LocationsSetElements; typedef struct RDI_U32_LocationsSetElements { RDI_U32 v; } RDI_U32_LocationsSetElements;
typedef struct RDI_U32_ConstantValueData { RDI_U32 v; } RDI_U32_ConstantValueData; typedef struct RDI_U32_ConstantValueData { RDI_U32 v; } RDI_U32_ConstantValueData;
typedef struct RDI_U32_ConstantValueTable { RDI_U32 v; } RDI_U32_ConstantValueTable; typedef struct RDI_U32_ConstantValueTable { RDI_U32 v; } RDI_U32_ConstantValueTable;
@@ -1216,12 +1194,7 @@ typedef RDI_U32_Table RDI_U32_ConstantSymbols;
typedef RDI_U32_Table RDI_U32_ProcedureSymbols; typedef RDI_U32_Table RDI_U32_ProcedureSymbols;
typedef RDI_U32_Table RDI_U32_LocalSymbols; typedef RDI_U32_Table RDI_U32_LocalSymbols;
typedef RDI_U32_Table RDI_U32_LocationsBytecodeData; typedef RDI_U32_Table RDI_U32_LocationsBytecodeData;
typedef RDI_U32_Table RDI_U32_LocationsRegPlusU16; typedef RDI_U32_Table RDI_U32_LocationsConstantData;
typedef RDI_U32_Table RDI_U32_LocationsReg;
typedef RDI_U32_Table RDI_U32_LocationsModuleOff;
typedef RDI_U32_Table RDI_U32_LocationsTLSOff;
typedef RDI_U32_Table RDI_U32_LocationsConstantDataOff;
typedef RDI_U32_Table RDI_U32_LocationsSet;
typedef RDI_U32_Table RDI_U32_LocationsSetElements; typedef RDI_U32_Table RDI_U32_LocationsSetElements;
typedef RDI_U32_Table RDI_U32_ConstantValueData; typedef RDI_U32_Table RDI_U32_ConstantValueData;
typedef RDI_U32_Table RDI_U32_ConstantValueTable; typedef RDI_U32_Table RDI_U32_ConstantValueTable;
@@ -1253,8 +1226,8 @@ typedef RDI_U64 RDI_Location;
#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_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_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_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_regcode_from_location(l) ((rdi_kind_from_location(l) == RDI_LocationKind_AddrRegPlusU16 || rdi_kind_from_location(l) == RDI_LocationKind_AddrAddrRegPlusU16 || rdi_kind_from_location(l) == RDI_LocationKind_ValReg) ? (((l) & RDI_Location_RegCodeMask) >> RDI_Location_RegCodeShift) : 0)
#define rdi_regoff_from_location(l) ((((l) & RDI_Location_RegOffMask) >> RDI_Location_RegOffShift)) #define rdi_regoff_from_location(l) ((rdi_kind_from_location(l) == RDI_LocationKind_AddrRegPlusU16 || rdi_kind_from_location(l) == RDI_LocationKind_AddrAddrRegPlusU16) ? (((l) & RDI_Location_RegOffMask) >> RDI_Location_RegOffShift) : 0)
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) (((decodeN) << 8) | ((popN) << 4) | ((pushN) << 0)) #define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) (((decodeN) << 8) | ((popN) << 4) | ((pushN) << 0))
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 8) & 0xff) #define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 8) & 0xff)
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0xf) #define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0xf)
@@ -1590,22 +1563,12 @@ RDI_RegCode reg_code;
RDI_U16 offset; RDI_U16 offset;
}; };
typedef struct RDI_LocationSet RDI_LocationSet;
struct RDI_LocationSet
{
RDI_U32 set_element_idx_first;
RDI_U32 set_element_idx_opl;
};
typedef struct RDI_LocationSetElement RDI_LocationSetElement; typedef struct RDI_LocationSetElement RDI_LocationSetElement;
struct RDI_LocationSetElement struct RDI_LocationSetElement
{ {
RDI_LocationKind kind;
RDI_U8 reserved_0;
RDI_U16 reserved_1;
RDI_U32 idx;
RDI_U32 scope_off_first; RDI_U32 scope_off_first;
RDI_U32 scope_off_opl; RDI_U32 scope_off_opl;
RDI_Location location;
}; };
typedef struct RDI_NameMap RDI_NameMap; typedef struct RDI_NameMap RDI_NameMap;
@@ -1672,12 +1635,7 @@ typedef RDI_Symbol RDI_SectionElementType_ConstantSymbols;
typedef RDI_Symbol RDI_SectionElementType_ProcedureSymbols; typedef RDI_Symbol RDI_SectionElementType_ProcedureSymbols;
typedef RDI_Symbol RDI_SectionElementType_LocalSymbols; typedef RDI_Symbol RDI_SectionElementType_LocalSymbols;
typedef RDI_U8 RDI_SectionElementType_LocationsBytecodeData; typedef RDI_U8 RDI_SectionElementType_LocationsBytecodeData;
typedef RDI_RegAndOffsetU16 RDI_SectionElementType_LocationsRegPlusU16; typedef RDI_U8 RDI_SectionElementType_LocationsConstantData;
typedef RDI_RegCode RDI_SectionElementType_LocationsReg;
typedef RDI_U64 RDI_SectionElementType_LocationsModuleOff;
typedef RDI_U32 RDI_SectionElementType_LocationsTLSOff;
typedef RDI_U64 RDI_SectionElementType_LocationsConstantDataOff;
typedef RDI_LocationSet RDI_SectionElementType_LocationsSet;
typedef RDI_LocationSetElement RDI_SectionElementType_LocationsSetElements; typedef RDI_LocationSetElement RDI_SectionElementType_LocationsSetElements;
typedef RDI_U8 RDI_SectionElementType_ConstantValueData; typedef RDI_U8 RDI_SectionElementType_ConstantValueData;
typedef RDI_U32 RDI_SectionElementType_ConstantValueTable; typedef RDI_U32 RDI_SectionElementType_ConstantValueTable;
@@ -1697,7 +1655,7 @@ RDI_PROC RDI_EvalConversionKind rdi_eval_conversion_kind_from_typegroups(RDI_Eva
RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTypeGroup group); RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTypeGroup group);
RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out); RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out);
extern RDI_U16 rdi_section_element_size_table[58]; extern RDI_U16 rdi_section_element_size_table[53];
extern RDI_U16 rdi_eval_op_ctrlbits_table[54]; extern RDI_U16 rdi_eval_op_ctrlbits_table[54];
#endif // RDI_H #endif // RDI_H
+15 -40
View File
@@ -206,29 +206,24 @@ RDI_SectionTable:
//- NOTE(rjf): vvv new story for locations //- NOTE(rjf): vvv new story for locations
{LocationsBytecodeData locations_bytecode_data RDI_U8 0x0028 U32 ""} {LocationsBytecodeData locations_bytecode_data RDI_U8 0x0028 U32 ""}
{LocationsRegPlusU16 locations_reg_plus_u16 RDI_RegAndOffsetU16 0x0029 U32 ""} {LocationsConstantData locations_constant_data RDI_U8 0x0029 U32 ""}
{LocationsReg locations_reg RDI_RegCode 0x002A U32 ""} {LocationsSetElements locations_set_elements RDI_LocationSetElement 0x002A U32 ""}
{LocationsModuleOff locations_module_off RDI_U64 0x002B U32 ""}
{LocationsTLSOff locations_tls_off RDI_U32 0x002C U32 ""}
{LocationsConstantDataOff locations_constant_data_off RDI_U64 0x002D U32 ""}
{LocationsSet locations_set RDI_LocationSet 0x002E U32 ""}
{LocationsSetElements locations_set_elements RDI_LocationSetElement 0x002F U32 ""}
//- TODO(rjf): vvv old story for locations (constants) //- TODO(rjf): vvv old story for locations (constants)
{ConstantValueData constant_value_data RDI_U8 0x0030 U32 ""} {ConstantValueData constant_value_data RDI_U8 0x002B U32 ""}
{ConstantValueTable constant_value_table RDI_U32 0x0031 U32 ""} {ConstantValueTable constant_value_table RDI_U32 0x002C U32 ""}
//- rjf: checksums / timestamps //- rjf: checksums / timestamps
{MD5Checksums md5_checksums RDI_MD5 0x0032 U32 ""} {MD5Checksums md5_checksums RDI_MD5 0x002D U32 ""}
{SHA1Checksums sha1_checksums RDI_SHA1 0x0033 U32 ""} {SHA1Checksums sha1_checksums RDI_SHA1 0x002E U32 ""}
{SHA256Checksums sha256_checksums RDI_SHA256 0x0034 U32 ""} {SHA256Checksums sha256_checksums RDI_SHA256 0x002F U32 ""}
{Timestamps timestamps RDI_U64 0x0035 U32 ""} {Timestamps timestamps RDI_U64 0x0030 U32 ""}
//- rjf: name maps //- rjf: name maps
{NameMaps name_maps RDI_NameMap 0x0036 U32 ""} {NameMaps name_maps RDI_NameMap 0x0031 U32 ""}
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0037 U32 ""} {NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0032 U32 ""}
{NameMapNodes name_map_nodes RDI_NameMapNode 0x0038 U32 ""} {NameMapNodes name_map_nodes RDI_NameMapNode 0x0033 U32 ""}
{COUNT count RDI_U8 0x0039 - ""} {COUNT count RDI_U8 0x0034 - ""}
} }
@table(name value) @table(name value)
@@ -1179,22 +1174,12 @@ RDI_RegAndOffsetU16MemberTable:
{offset RDI_U16 } {offset RDI_U16 }
} }
@table(name type desc)
RDI_LocationSetMemberTable:
{
{set_element_idx_first RDI_U32 ""}
{set_element_idx_opl RDI_U32 ""}
}
@table(name type desc) @table(name type desc)
RDI_LocationSetElementMemberTable: RDI_LocationSetElementMemberTable:
{ {
{kind RDI_LocationKind ""}
{reserved_0 RDI_U8 ""}
{reserved_1 RDI_U16 ""}
{idx RDI_U32 ""}
{scope_off_first RDI_U32 ""} {scope_off_first RDI_U32 ""}
{scope_off_opl RDI_U32 ""} {scope_off_opl RDI_U32 ""}
{location RDI_Location ""}
} }
//- rjf: enums //- rjf: enums
@@ -1250,8 +1235,8 @@ RDI_LocationSetElementMemberTable:
`#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_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_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_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_regcode_from_location(l) ((rdi_kind_from_location(l) == RDI_LocationKind_AddrRegPlusU16 || rdi_kind_from_location(l) == RDI_LocationKind_AddrAddrRegPlusU16 || rdi_kind_from_location(l) == RDI_LocationKind_ValReg) ? (((l) & RDI_Location_RegCodeMask) >> RDI_Location_RegCodeShift) : 0)`;
`#define rdi_regoff_from_location(l) ((((l) & RDI_Location_RegOffMask) >> RDI_Location_RegOffShift))`; `#define rdi_regoff_from_location(l) ((rdi_kind_from_location(l) == RDI_LocationKind_AddrRegPlusU16 || rdi_kind_from_location(l) == RDI_LocationKind_AddrAddrRegPlusU16) ? (((l) & RDI_Location_RegOffMask) >> RDI_Location_RegOffShift) : 0)`;
} }
//- rjf: xlists //- rjf: xlists
@@ -1336,11 +1321,6 @@ RDI_LocationSetElementMemberTable:
@expand(RDI_RegAndOffsetU16MemberTable a) `$(a.type), $(a.name)` @expand(RDI_RegAndOffsetU16MemberTable a) `$(a.type), $(a.name)`
} }
@xlist RDI_LocationSet_XList:
{
@expand(RDI_LocationSetMemberTable a) `$(a.type), $(a.name)`
}
@xlist RDI_LocationSetElement_XList: @xlist RDI_LocationSetElement_XList:
{ {
@expand(RDI_LocationSetElementMemberTable a) `$(a.type), $(a.name)` @expand(RDI_LocationSetElementMemberTable a) `$(a.type), $(a.name)`
@@ -1418,11 +1398,6 @@ RDI_LocationSetElementMemberTable:
@expand(RDI_RegAndOffsetU16MemberTable a) `$(a.type) $(a.name)` @expand(RDI_RegAndOffsetU16MemberTable a) `$(a.type) $(a.name)`
} }
@struct RDI_LocationSet:
{
@expand(RDI_LocationSetMemberTable a) `$(a.type) $(a.name)`
}
@struct RDI_LocationSetElement: @struct RDI_LocationSetElement:
{ {
@expand(RDI_LocationSetElementMemberTable a) `$(a.type) $(a.name)` @expand(RDI_LocationSetElementMemberTable a) `$(a.type) $(a.name)`
+3 -3
View File
@@ -69,8 +69,8 @@ p2r_rdi_arch_from_cv_arch(CV_Arch cv_arch)
RDI_Arch result = 0; RDI_Arch result = 0;
switch(cv_arch) switch(cv_arch)
{ {
case CV_Arch_8086: NotImplemented; break; case CV_Arch_8086:{}break;
case CV_Arch_X64: result = RDI_Arch_X64; break; case CV_Arch_X64:{result = RDI_Arch_X64;}break;
//case CV_Arch_8080: break; //case CV_Arch_8080: break;
//case CV_Arch_80286: break; //case CV_Arch_80286: break;
//case CV_Arch_80386: break; //case CV_Arch_80386: break;
@@ -130,7 +130,7 @@ p2r_rdi_arch_from_cv_arch(CV_Arch cv_arch)
//case CV_Arch_ARM64: break; //case CV_Arch_ARM64: break;
//case CV_Arch_D3D11_SHADER: break; //case CV_Arch_D3D11_SHADER: break;
} }
return(result); return result;
} }
internal RDI_RegCode internal RDI_RegCode
+83
View File
@@ -3383,6 +3383,89 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
// //
ProfScope("bake symbols") ProfScope("bake symbols")
{ {
////////////////////////////
//- rjf: count chunks
//
U64 chunk_count = 0;
for EachElement(symbol_table_list_idx, symbol_table_lists)
{
chunk_count += symbol_table_lists[symbol_table_list_idx].symbols->chunk_count;
}
////////////////////////////
//- rjf: count indirected location data - bytecode, constants, set elements
//
U64 *lane_chunk_bytecode_data_counts = 0;
U64 *lane_chunk_constant_data_counts = 0;
U64 *lane_chunk_set_element_counts = 0;
if(lane_idx() == 0)
{
lane_chunk_bytecode_data_counts = push_array(scratch.arena, U64, lane_count() * chunk_count);
lane_chunk_constant_data_counts = push_array(scratch.arena, U64, lane_count() * chunk_count);
lane_chunk_set_element_counts = push_array(scratch.arena, U64, lane_count() * chunk_count);
}
lane_sync_u64(&lane_chunk_bytecode_data_counts, 0);
lane_sync_u64(&lane_chunk_constant_data_counts, 0);
lane_sync_u64(&lane_chunk_set_element_counts, 0);
{
U64 chunk_idx = 0;
for EachElement(symbol_table_list_idx, symbol_table_lists)
{
RDIM_SymbolChunkList *src_symbols = symbol_table_lists[symbol_table_list_idx].symbols;
for EachNode(n, RDIM_SymbolChunkNode, src_symbols->first)
{
U64 slot_idx = lane_idx()*chunk_count + chunk_idx;
Rng1U64 range = lane_range(n->count);
for EachInRange(n_idx, range)
{
RDIM_Symbol *s = &n->v[n_idx];
if(s->location_cases.count > 1)
{
lane_chunk_set_element_counts[slot_idx] += s->location_cases.count;
}
lane_chunk_constant_data_counts[slot_idx] += s->value_data.size;
for EachNode(case_n, RDIM_LocationCase, s->location_cases.first)
{
lane_chunk_bytecode_data_counts[slot_idx] += case_n->location->info.bytecode.encoded_size;
}
}
chunk_idx += 1;
}
}
}
////////////////////////////
//- rjf: lay out indirected location data
//
U64 *lane_chunk_bytecode_data_offs = 0;
U64 *lane_chunk_constant_data_offs = 0;
U64 *lane_chunk_set_element_offs = 0;
if(lane_idx() == 0)
{
U64 bytecode_data_off = 0;
U64 constant_data_off = 0;
U64 set_element_off = 0;
lane_chunk_bytecode_data_offs = push_array(scratch.arena, U64, lane_count() * chunk_count);
lane_chunk_constant_data_offs = push_array(scratch.arena, U64, lane_count() * chunk_count);
lane_chunk_set_element_offs = push_array(scratch.arena, U64, lane_count() * chunk_count);
for EachIndex(chunk_idx, chunk_count)
{
for EachIndex(l_idx, lane_count())
{
U64 slot_idx = l_idx*chunk_count + chunk_idx;
lane_chunk_bytecode_data_offs[slot_idx] = bytecode_data_off;
lane_chunk_constant_data_offs[slot_idx] = constant_data_off;
lane_chunk_set_element_offs[slot_idx] = set_element_off;
bytecode_data_off += lane_chunk_bytecode_data_counts[slot_idx];
constant_data_off += lane_chunk_constant_data_counts[slot_idx];
set_element_off += lane_chunk_set_element_counts[slot_idx];
}
}
}
lane_sync_u64(&lane_chunk_bytecode_data_offs, 0);
lane_sync_u64(&lane_chunk_constant_data_offs, 0);
lane_sync_u64(&lane_chunk_set_element_offs, 0);
//////////////////////////// ////////////////////////////
//- rjf: bake flat symbol tables //- rjf: bake flat symbol tables
// //