mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 08:31:11 +00:00
Makes value8_high/low and value16 branchless.
This commit is contained in:
parent
08f2877382
commit
cf16f41939
@ -53,7 +53,9 @@ struct Microcycle {
|
||||
/// which by inspecting the low bit of the provided address. The RW line indicates a read.
|
||||
static const int SelectByte = 1 << 0;
|
||||
// Maintenance note: this is bit 0 to reduce the cost of getting a host-endian
|
||||
// bytewise address. See implementation of host_endian_byte_address().
|
||||
// bytewise address. The assumption that it is bit 0 is also used for branchless
|
||||
// selection in a few places. See implementation of host_endian_byte_address(),
|
||||
// value8_high(), value8_low() and value16().
|
||||
|
||||
/// Indicates that the address and both data select strobes are active.
|
||||
static const int SelectWord = 1 << 1;
|
||||
@ -223,8 +225,8 @@ struct Microcycle {
|
||||
this is a write cycle.
|
||||
*/
|
||||
forceinline uint16_t value16() const {
|
||||
if(operation & SelectWord) return value->full;
|
||||
return uint16_t((value->halves.low << 8) | value->halves.low);
|
||||
const uint16_t values[] = { value->full, uint16_t((value->halves.low << 8) | value->halves.low) };
|
||||
return values[operation & SelectByte];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -232,11 +234,8 @@ struct Microcycle {
|
||||
@c 0xff otherwise. Assumes this is a write cycle.
|
||||
*/
|
||||
forceinline uint8_t value8_high() const {
|
||||
if(operation & SelectWord) {
|
||||
return uint8_t(value->full >> 8);
|
||||
}
|
||||
|
||||
return value->halves.low;
|
||||
const uint8_t values[] = { uint8_t(value->full >> 8), value->halves.low};
|
||||
return values[operation & SelectByte];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -244,11 +243,8 @@ struct Microcycle {
|
||||
@c 0xff otherwise. Assumes this is a write cycle.
|
||||
*/
|
||||
forceinline uint8_t value8_low() const {
|
||||
if(operation & SelectWord) {
|
||||
return uint8_t(value->full);
|
||||
}
|
||||
|
||||
return value->halves.low;
|
||||
const uint8_t values[] = { uint8_t(value->full), value->halves.low};
|
||||
return values[operation & SelectByte];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user