Skip to content

Commit

Permalink
Remove entry member in Function signature
Browse files Browse the repository at this point in the history
This is being removed before any "release" as it is no longer used. All signature files before this are considered unusable.
  • Loading branch information
emesare committed Nov 11, 2024
1 parent 5b9ae5a commit bae7379
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 33 deletions.
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ panic = "abort"
lto = true
debug = "full"

[profile.bench]
lto = true

[[example]]
name = "simple"
path = "rust/examples/simple.rs"
path = "rust/examples/simple.rs"

[[bench]]
name = "void"
path = "rust/benches/void.rs"
harness = false
5 changes: 3 additions & 2 deletions rust/benches/void.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use criterion::{criterion_group, criterion_main, Criterion};
use flatbuffers::FlatBufferBuilder;
use typebuild::prelude::*;
use warp::r#type::class::TypeClass;
use warp::r#type::guid::TypeGUID;
use warp::r#type::Type;

pub fn void_benchmark(c: &mut Criterion) {
let void_type = Type::builder()
Expand Down
17 changes: 0 additions & 17 deletions rust/gen_flatbuffers/sig_bin/function_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ impl<'a> Function<'a> {
pub const VT_SYMBOL: flatbuffers::VOffsetT = 6;
pub const VT_TYPE_: flatbuffers::VOffsetT = 8;
pub const VT_CONSTRAINTS: flatbuffers::VOffsetT = 10;
pub const VT_ENTRY: flatbuffers::VOffsetT = 12;

#[inline]
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
Expand All @@ -41,7 +40,6 @@ impl<'a> Function<'a> {
args: &'args FunctionArgs<'args>
) -> flatbuffers::WIPOffset<Function<'bldr>> {
let mut builder = FunctionBuilder::new(_fbb);
if let Some(x) = args.entry { builder.add_entry(x); }
if let Some(x) = args.constraints { builder.add_constraints(x); }
if let Some(x) = args.type_ { builder.add_type_(x); }
if let Some(x) = args.symbol { builder.add_symbol(x); }
Expand Down Expand Up @@ -78,13 +76,6 @@ impl<'a> Function<'a> {
// which contains a valid value in this slot
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<FunctionConstraints>>(Function::VT_CONSTRAINTS, None)}
}
#[inline]
pub fn entry(&self) -> Option<BasicBlock<'a>> {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<BasicBlock>>(Function::VT_ENTRY, None)}
}
}

impl flatbuffers::Verifiable for Function<'_> {
Expand All @@ -98,7 +89,6 @@ impl flatbuffers::Verifiable for Function<'_> {
.visit_field::<flatbuffers::ForwardsUOffset<super::symbol_bin::Symbol>>("symbol", Self::VT_SYMBOL, false)?
.visit_field::<flatbuffers::ForwardsUOffset<super::type_bin::Type>>("type_", Self::VT_TYPE_, false)?
.visit_field::<flatbuffers::ForwardsUOffset<FunctionConstraints>>("constraints", Self::VT_CONSTRAINTS, false)?
.visit_field::<flatbuffers::ForwardsUOffset<BasicBlock>>("entry", Self::VT_ENTRY, false)?
.finish();
Ok(())
}
Expand All @@ -108,7 +98,6 @@ pub struct FunctionArgs<'a> {
pub symbol: Option<flatbuffers::WIPOffset<super::symbol_bin::Symbol<'a>>>,
pub type_: Option<flatbuffers::WIPOffset<super::type_bin::Type<'a>>>,
pub constraints: Option<flatbuffers::WIPOffset<FunctionConstraints<'a>>>,
pub entry: Option<flatbuffers::WIPOffset<BasicBlock<'a>>>,
}
impl<'a> Default for FunctionArgs<'a> {
#[inline]
Expand All @@ -118,7 +107,6 @@ impl<'a> Default for FunctionArgs<'a> {
symbol: None,
type_: None,
constraints: None,
entry: None,
}
}
}
Expand All @@ -145,10 +133,6 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FunctionBuilder<'a, 'b, A> {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<FunctionConstraints>>(Function::VT_CONSTRAINTS, constraints);
}
#[inline]
pub fn add_entry(&mut self, entry: flatbuffers::WIPOffset<BasicBlock<'b >>) {
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<BasicBlock>>(Function::VT_ENTRY, entry);
}
#[inline]
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FunctionBuilder<'a, 'b, A> {
let start = _fbb.start_table();
FunctionBuilder {
Expand All @@ -171,7 +155,6 @@ impl core::fmt::Debug for Function<'_> {
ds.field("symbol", &self.symbol());
ds.field("type_", &self.type_());
ds.field("constraints", &self.constraints());
ds.field("entry", &self.entry());
ds.finish()
}
}
3 changes: 1 addition & 2 deletions rust/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ mod tests {
guid: guid.into(),
constraints: Default::default(),
ty: rand::random(),
entry: None,
}
}

Expand Down Expand Up @@ -283,7 +282,7 @@ mod tests {
.call_sites
.insert(create_sample_function_constraint::<Uuid>("func2", None));

let mut merged_data = Data::merge(vec![first_data, second_data]);
let merged_data = Data::merge(vec![first_data, second_data]);

assert_eq!(merged_data.functions.len(), 3);
// All function constraints should be resolved.
Expand Down
7 changes: 1 addition & 6 deletions rust/signature/function.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::fb_sig as fb;
use crate::r#type::Type;
use crate::signature::basic_block::{BasicBlock, BasicBlockGUID};
use crate::signature::basic_block::BasicBlockGUID;
use crate::signature::function::constraints::FunctionConstraints;
use crate::symbol::Symbol;
use flatbuffers::{FlatBufferBuilder, WIPOffset};
Expand Down Expand Up @@ -77,7 +77,6 @@ pub struct Function {
pub symbol: Symbol,
pub ty: Type,
pub constraints: FunctionConstraints,
pub entry: Option<BasicBlock>,
}

impl Function {
Expand All @@ -102,7 +101,6 @@ impl Function {
let symbol = self.symbol.create(builder);
let ty = self.ty.create(builder);
let constraints = self.constraints.create(builder);
let entry = self.entry.as_ref().map(|e| e.create(builder));
let guid = builder.create_string(&self.guid.to_string());
fb::Function::create(
builder,
Expand All @@ -111,7 +109,6 @@ impl Function {
symbol: Some(symbol),
type_: Some(ty),
constraints: Some(constraints),
entry,
},
)
}
Expand All @@ -126,7 +123,6 @@ impl From<fb::Function<'_>> for Function {
symbol: value.symbol().unwrap().into(),
ty: ty.unwrap().into(),
constraints: value.constraints().unwrap().into(),
entry: value.entry().map(Into::into),
}
}
}
Expand Down Expand Up @@ -181,7 +177,6 @@ mod tests {
.class(TypeClass::Void)
.build(),
constraints: FunctionConstraints::default(),
entry: None,
}
}

Expand Down
7 changes: 2 additions & 5 deletions signature.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ file_extension "sbin";

table BasicBlock {
guid:string (required);
// successors:[string];
// predecessors:[string];
// TODO: successors:[string];
// TODO: predecessors:[string];
}

table FunctionConstraint {
Expand All @@ -36,9 +36,6 @@ table Function {
symbol:SymbolBin.Symbol;
type:TypeBin.Type;
constraints:FunctionConstraints;
// TODO: Remove this and just have a list of basic blocks.
// TODO: We need to support multiple entry basic blocks.
entry:BasicBlock;
}

table Data {
Expand Down

0 comments on commit bae7379

Please sign in to comment.