[meta] Introduce the InstructionGroupBuilder;

This follows the rest of the code base data structures, where we have a
mutable data structure builder; once the data structure is constructed,
it's immutable.

This also makes the definition of instructions easier, and it paves the
way for defining immediate variants.
This commit is contained in:
Benjamin Bouvier
2019-04-30 18:33:01 +02:00
parent feb90e376a
commit d9277f249b
7 changed files with 251 additions and 382 deletions

View File

@@ -404,11 +404,14 @@ impl TransformGroups {
#[should_panic]
fn test_double_custom_legalization() {
use crate::cdsl::formats::{FormatRegistry, InstructionFormatBuilder};
use crate::cdsl::instructions::InstructionBuilder;
use crate::cdsl::instructions::{InstructionBuilder, InstructionGroupBuilder};
let mut format = FormatRegistry::new();
format.insert(InstructionFormatBuilder::new("nullary"));
let dummy_inst = InstructionBuilder::new("dummy", "doc").finish(&format);
let mut inst_group = InstructionGroupBuilder::new("test", "", &format);
inst_group.push(InstructionBuilder::new("dummy", "doc"));
let inst_group = inst_group.finish();
let dummy_inst = inst_group.by_name("dummy");
let mut transform_group = TransformGroupBuilder::new("test", "doc");
transform_group.custom_legalize(&dummy_inst, "custom 1");