```
#pragma pack
typedef union {
+ uint8_t actual_bytes[8];
+ // all of these are very deliberately unbounded arrays
+ // that intentionally "wrap" into subsequent actual_bytes...
uint8_t bytes[]; // elwidth 8
uint16_t hwords[]; // elwidth 16
uint32_t words[]; // elwidth 32
uint64_t dwords[]; // elwidth 64
- uint8_t actual_bytes[8];
+
} el_reg_t;
+ // ... here, as packed statically-defined GPRs.
elreg_t int_regfile[128];
+ // use element 0 as the destination
void get_register_element(el_reg_t* el, int gpr, int element, int width) {
switch (width) {
case 64: el->dwords[0] = int_regfile[gpr].dwords[element];
case 8 : el->bytes[0] = int_regfile[gpr].bytes[element];
}
}
+
+ // use element 0 as the source
void set_register_element(el_reg_t* el, int gpr, int element, int width) {
switch (width) {
case 64: int_regfile[gpr].dwords[element] = el->dwords[0];