Skip to content

Commit 1790faf

Browse files
committed
Create structs as named types for bpf llvm ir
Signed-off-by: Sean Young <[email protected]>
1 parent d846eeb commit 1790faf

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

Diff for: TODO

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@
44
- Need ir-ctl and ir-keytable command line parsing
55
- localization of cli messages
66
- clap 4.5/4.4 and merge cir devices/config
7-
- struct definitions should be on the module rather than repeated
8-
- honour max_gap in Action::Gap { .. }
97
- implement Action::Gap/Flash { Expression::Length {} }
108
- test all the protocols
11-
- Generic decoder Options {} struct
9+
- Generic decoder Options {} struct saves NFA/DFA files
1210
- calculate maximum length for timeout
1311
- calculate minimum $extent for avoiding runtime calcs
14-
- lead in gap (or whatever irptransmogrifier calls it
12+
- lead in gap (or whatever irptransmogrifier calls it)
1513
- Formatting of ir receive is poor/broken
1614
- Test all keymaps
17-
- Need ir-ctl and ir-keytable command line parsing
18-
- localization of cli messages
1915
- scancode <=> irp mapping
2016
- lircd.conf generate -> send to lircd -> correct result?
21-
- bpf feature should not be the default
17+
- bpf feature should not be the default in irp crate
2218

2319
ir-keytable -c
2420

Diff for: irp/src/build_bpf.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ impl DFA {
5757
builder.module.print_to_file(path).unwrap();
5858
}
5959

60+
builder.module.verify().unwrap();
61+
6062
let target = Target::from_name("bpf").unwrap();
6163

6264
let target_machine = target
@@ -726,21 +728,20 @@ fn define_map_def<'ctx>(
726728
vars: &HashMap<&str, VarValue>,
727729
context: &'ctx Context,
728730
) -> (GlobalValue<'ctx>, StructType<'ctx>) {
729-
let i32 = context.i32_type().as_basic_type_enum();
730-
let i64 = context.i64_type().as_basic_type_enum();
731+
let i32 = context.i32_type();
732+
733+
let field_types = vec![i32.as_basic_type_enum(); 7];
731734

732-
let field_types = vec![i32; 7];
735+
let bpf_map_def = context.opaque_struct_type("bpf_map_def");
733736

734-
let bpf_map_def = context.struct_type(&field_types, false);
737+
bpf_map_def.set_body(&field_types, false);
735738

736739
let gv = module.add_global(
737740
bpf_map_def,
738741
Some(AddressSpace::default()),
739742
"decoder_state_map",
740743
);
741744

742-
let i32 = context.i32_type();
743-
744745
let def = bpf_map_def.const_named_struct(&[
745746
// BPF_MAP_TYPE_ARRAY
746747
i32.const_int(2, false).into(),
@@ -761,9 +762,11 @@ fn define_map_def<'ctx>(
761762
gv.set_section(Some("maps"));
762763
gv.set_alignment(4);
763764

764-
let field_types = vec![i64; vars.len()];
765+
let field_types = vec![context.i64_type().as_basic_type_enum(); vars.len()];
766+
767+
let decoder_state_ty = context.opaque_struct_type("decoder_state_ty");
765768

766-
let decoder_state_ty = context.struct_type(&field_types, false);
769+
decoder_state_ty.set_body(&field_types, false);
767770

768771
(gv, decoder_state_ty)
769772
}

0 commit comments

Comments
 (0)