Give register classes a name.

This is just for better error messages etc.
This commit is contained in:
Jakob Stoklund Olesen
2017-02-16 13:56:58 -08:00
parent e182bfa9ad
commit 3072728d37
3 changed files with 6 additions and 1 deletions

View File

@@ -33,8 +33,8 @@ def gen_regclass(rc, fmt):
"""
Emit a static data definition for a register class.
"""
fmt.comment(rc.name)
with fmt.indented('RegClassData {', '},'):
fmt.line('name: "{}",'.format(rc.name))
fmt.line('index: {},'.format(rc.index))
fmt.line('width: {},'.format(rc.width))
fmt.line('subclasses: 0x{:x},'.format(rc.subclass_mask()))

View File

@@ -99,6 +99,9 @@ pub type RegClass = &'static RegClassData;
/// A register class can be a subset of another register class. The top-level register classes are
/// disjoint.
pub struct RegClassData {
/// The name of the register class.
pub name: &'static str,
/// The index of this class in the ISA's RegInfo description.
pub index: u8,

View File

@@ -118,12 +118,14 @@ mod tests {
// Register classes for testing.
const GPR: RegClass = &RegClassData {
name: "GPR",
index: 0,
width: 1,
subclasses: 0,
mask: [0xf0000000, 0x0000000f, 0],
};
const DPR: RegClass = &RegClassData {
name: "DPR",
index: 0,
width: 2,
subclasses: 0,