Skip to content
Snippets Groups Projects
Commit e5c21393 authored by Matthew McGill's avatar Matthew McGill
Browse files

Made constructor with slot size clearer

Former-commit-id: 67c0a0c54ed8adaae295b8d815a7476473d19ffa
parent c82da996
No related branches found
No related tags found
No related merge requests found
......@@ -77,7 +77,7 @@ class ColoredInstructionNonces_t
: firp(the_firp), slot_size(1), slot_values(255) { }
ColoredInstructionNonces_t(libIRDB::FileIR_t *the_firp, int the_slot_size)
: firp(the_firp), slot_size(the_slot_size),
slot_values(~((NonceValueType_t) 0) >> (sizeof(NonceValueType_t)*8-the_slot_size*8)) { }
slot_values(MaxNonceValForSlotSize(the_slot_size)) { }
ColoredSlotValues_t GetColorsOfIBT (libIRDB::Instruction_t* i)
{ return color_assignments[i]; }
......@@ -112,6 +112,15 @@ class ColoredInstructionNonces_t
// the slot that each IB uses. ICFS_t -> slot_value
std::map<libIRDB::ICFS_t, ColoredSlotValue_t> slot_assignments;
NonceValueType_t MaxNonceValForSlotSize(int slot_size)
{
NonceValueType_t max_nonce_val = ~((NonceValueType_t) 0);
size_t max_nonce_size_bits = sizeof(NonceValueType_t)*8;
size_t slot_size_bits = slot_size*8;
return max_nonce_val >> (max_nonce_size_bits - slot_size_bits);
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment