Skip to content

Commit

Permalink
Create structs as named types for bpf llvm ir
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Young <[email protected]>
  • Loading branch information
seanyoung committed Apr 7, 2024
1 parent d846eeb commit 1790faf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
10 changes: 3 additions & 7 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
- Need ir-ctl and ir-keytable command line parsing
- localization of cli messages
- clap 4.5/4.4 and merge cir devices/config
- struct definitions should be on the module rather than repeated
- honour max_gap in Action::Gap { .. }
- implement Action::Gap/Flash { Expression::Length {} }
- test all the protocols
- Generic decoder Options {} struct
- Generic decoder Options {} struct saves NFA/DFA files
- calculate maximum length for timeout
- calculate minimum $extent for avoiding runtime calcs
- lead in gap (or whatever irptransmogrifier calls it
- lead in gap (or whatever irptransmogrifier calls it)
- Formatting of ir receive is poor/broken
- Test all keymaps
- Need ir-ctl and ir-keytable command line parsing
- localization of cli messages
- scancode <=> irp mapping
- lircd.conf generate -> send to lircd -> correct result?
- bpf feature should not be the default
- bpf feature should not be the default in irp crate

ir-keytable -c

Expand Down
19 changes: 11 additions & 8 deletions irp/src/build_bpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ impl DFA {
builder.module.print_to_file(path).unwrap();
}

builder.module.verify().unwrap();

let target = Target::from_name("bpf").unwrap();

let target_machine = target
Expand Down Expand Up @@ -726,21 +728,20 @@ fn define_map_def<'ctx>(
vars: &HashMap<&str, VarValue>,
context: &'ctx Context,
) -> (GlobalValue<'ctx>, StructType<'ctx>) {
let i32 = context.i32_type().as_basic_type_enum();
let i64 = context.i64_type().as_basic_type_enum();
let i32 = context.i32_type();

let field_types = vec![i32.as_basic_type_enum(); 7];

let field_types = vec![i32; 7];
let bpf_map_def = context.opaque_struct_type("bpf_map_def");

let bpf_map_def = context.struct_type(&field_types, false);
bpf_map_def.set_body(&field_types, false);

let gv = module.add_global(
bpf_map_def,
Some(AddressSpace::default()),
"decoder_state_map",
);

let i32 = context.i32_type();

let def = bpf_map_def.const_named_struct(&[
// BPF_MAP_TYPE_ARRAY
i32.const_int(2, false).into(),
Expand All @@ -761,9 +762,11 @@ fn define_map_def<'ctx>(
gv.set_section(Some("maps"));
gv.set_alignment(4);

let field_types = vec![i64; vars.len()];
let field_types = vec![context.i64_type().as_basic_type_enum(); vars.len()];

let decoder_state_ty = context.opaque_struct_type("decoder_state_ty");

let decoder_state_ty = context.struct_type(&field_types, false);
decoder_state_ty.set_body(&field_types, false);

(gv, decoder_state_ty)
}
Expand Down

0 comments on commit 1790faf

Please sign in to comment.