Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

? #2210

Closed
wants to merge 78 commits into from
Closed

? #2210

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b95143e
Here we go, this is gonna be a process
EclecticGriffin Jun 24, 2024
c4fb2f7
hoist the serialization flags
EclecticGriffin Jun 24, 2024
1544621
cleanup the serialization code
EclecticGriffin Jun 24, 2024
5418a2d
fix the error namespace
EclecticGriffin Jun 24, 2024
36cfc3b
namespace issues continue
EclecticGriffin Jun 24, 2024
3e4861c
move utils
EclecticGriffin Jun 24, 2024
947ed2c
ugh okay need this stuff back actually
EclecticGriffin Jun 24, 2024
92c25ea
yeet some tests
EclecticGriffin Jun 24, 2024
1dcd8f1
fixing stuff
EclecticGriffin Jun 24, 2024
d305eb7
purge things
EclecticGriffin Jun 24, 2024
504c6be
into the bin with all y'all
EclecticGriffin Jun 24, 2024
a79554e
I have lost all sense of what is even happening
EclecticGriffin Jun 24, 2024
2752c87
I going to go feral
EclecticGriffin Jun 24, 2024
8eebffc
nothing works aaaaaaa
EclecticGriffin Jun 24, 2024
b42334b
Fix the import
EclecticGriffin Jun 24, 2024
219c709
a checkpoint I guess, everything is still super broken. working top-d…
EclecticGriffin Jun 26, 2024
53bfd30
I am not having fun
EclecticGriffin Jun 26, 2024
6191bfa
the trashfire rages on
EclecticGriffin Jun 26, 2024
eba0247
Do some clever nonsense
EclecticGriffin Jun 27, 2024
14e16b5
watchpoint stuff
EclecticGriffin Jun 28, 2024
d5d5883
more watchpoint stuff
EclecticGriffin Jun 28, 2024
ae59c56
it compiles again
EclecticGriffin Jul 1, 2024
b5aafd5
Docs, Queues: binary heap (#2182)
polybeandip Jul 1, 2024
ecf05cc
Queues: edge case in data-gen when `num_cmds` is odd (#2190)
anshumanmohan Jul 2, 2024
ba0d5f0
Round Robin oracle and eDSL (#2177)
csziklai Jul 2, 2024
26f88e4
setup
EclecticGriffin Jul 2, 2024
ec8a4b3
oops
EclecticGriffin Jul 2, 2024
4e69a9a
Re-enable old queue tests (#2194)
polybeandip Jul 3, 2024
f59b893
Add git hooks and setup (#2188)
ethanuppal Jul 3, 2024
75c5cb8
Strict PIFO oracle and eDSL implementation (#2189)
csziklai Jul 3, 2024
4604d62
Improve LSP error reporting (#1950)
sgpthomas Jul 5, 2024
ed4ce6e
[hotfix] Fix web compilation error
sgpthomas Jul 5, 2024
ba46a1d
Can now print watchpoints & breakpoints
EclecticGriffin Jul 8, 2024
06fe5a4
Use strings instead of Id for the parsed input
EclecticGriffin Jul 8, 2024
259c2c8
[fud2] update path finding to support multi state input and output (#…
jku20 Jul 8, 2024
b60dad1
bump rhai version (#2196)
sgpthomas Jul 9, 2024
6e59cc8
my sanity is fraying
EclecticGriffin Jul 9, 2024
c92933d
Fix link formatting in language ref (#2201)
nathanielnrn Jul 10, 2024
93303f4
Duplication of dynamic fsms (#2146)
parthsarkar17 Jul 10, 2024
3448efc
much printing stuff
EclecticGriffin Jul 11, 2024
b547159
update runt tests
EclecticGriffin Jul 11, 2024
084bbaf
Merge remote-tracking branch 'origin/main' into cider2/deprecation
EclecticGriffin Jul 11, 2024
3d06ba8
try to fix fud stuff
EclecticGriffin Jul 11, 2024
136d69d
typo
EclecticGriffin Jul 11, 2024
b7ccc79
[fud2] Generate intermediate files in workdir. (#2205)
jku20 Jul 12, 2024
80f0cb6
Merge remote-tracking branch 'origin/main' into cider2/deprecation
EclecticGriffin Jul 12, 2024
f1c56ed
We're working again!!
EclecticGriffin Jul 12, 2024
836380e
fix thingy
EclecticGriffin Jul 12, 2024
346f425
fix print case for cell in main comp
EclecticGriffin Jul 12, 2024
aaf490b
converge when starting
EclecticGriffin Jul 12, 2024
40ce60c
fix breakpoint printing
EclecticGriffin Jul 12, 2024
ff98dae
fix group running check
EclecticGriffin Jul 12, 2024
64d1f0d
traversal fixes
EclecticGriffin Jul 12, 2024
5121f66
ugh we need these convergences for breakpoints to work right, very fr…
EclecticGriffin Jul 12, 2024
991becc
make exit not an error
EclecticGriffin Jul 12, 2024
0633fb7
all hail clippy
EclecticGriffin Jul 12, 2024
2d54db6
that converge was unnecessary
EclecticGriffin Jul 12, 2024
0eade0b
throw structures into the void
EclecticGriffin Jul 12, 2024
7050a31
fix the fud2 snapshots
EclecticGriffin Jul 12, 2024
c560483
cleanup the giant comment blocks
EclecticGriffin Jul 12, 2024
3583c5e
update the debugger path and remove old interp
EclecticGriffin Jul 12, 2024
3db99f5
unnecessarily fancy print at the beginning
EclecticGriffin Jul 12, 2024
da31738
migrate test suite
EclecticGriffin Jul 15, 2024
d4d607d
remove random markdown file
EclecticGriffin Jul 15, 2024
4a3f921
add a big gross runt command to the thing
EclecticGriffin Jul 15, 2024
70e6082
fix the directory
EclecticGriffin Jul 15, 2024
ed5d3f1
excise interpreter from python
EclecticGriffin Jul 15, 2024
d89f4bd
random lint in the python fud
EclecticGriffin Jul 15, 2024
520b29d
Tweak some descriptions for the help command
EclecticGriffin Jul 15, 2024
c16c112
tweak the rhai files
EclecticGriffin Jul 15, 2024
0a70ea6
update the docs and add a dummy data file
EclecticGriffin Jul 15, 2024
48806db
enable doctests and remove unused macro
EclecticGriffin Jul 15, 2024
3d620d2
remove note about features
EclecticGriffin Jul 15, 2024
ec39d7e
Add the undef primitive
EclecticGriffin Jul 15, 2024
c098ef3
fix snapshot tests again
EclecticGriffin Jul 15, 2024
ec9758b
exclude the polybench tests for the time being, even though they work
EclecticGriffin Jul 15, 2024
42d9766
unbreak the fud2 tests again
EclecticGriffin Jul 15, 2024
cff1cfc
cleanup
EclecticGriffin Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Check calyx build
run: ./target/debug/calyx --version
- name: validate playground config
run: node web/validate-data.js
run: node web/validate-data.js

# Get the hash of the Dockerfile
hash:
Expand Down Expand Up @@ -120,10 +120,10 @@ jobs:
fud c stages.interpreter.exec /home/calyx/target/debug/cider

- name: Runt tests
working-directory: /home/calyx
working-directory: /home/calyx/interp/tests
run: |
# Run the remaining tests
runt interp -x 'relay' -d -o fail
runt -x '(numeric types correctness and parsing)|(tcam testing)|(../../tests/correctness/pipelined-mac.futil)|(../../tests/correctness/std-bit-slice.futil)|(polybench)' -d -o fail

- name: Source code tests
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
working-directory: /home/calyx
run: |
runt -i 'cocotb' -d -o fail -j 1 --max-futures 1

- name: Runt tests
working-directory: /home/calyx
run: |
Expand Down
24 changes: 24 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#/bin/sh

function check {
prog=$1
shift
"$prog" "$@"
if [ $? -ne 0 ]; then
exit 1
fi
}

check cargo clippy

staged_py_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')

if [ -n "$staged_py_files" ]; then
flake8_executable=$(which flake8 || which flake)
if [ -z "$flake8_executable" ]; then
echo "flake is not installed"
exit 1
else
check "$flake8_executable" $staged_py_files
fi
fi
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions calyx-frontend/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
use super::parser;
use crate::{Attributes, PortDef, Primitive};
use atty::Stream;
use calyx_utils::{CalyxResult, Error, GPosIdx, Id};
use calyx_utils::{CalyxResult, Error, GPosIdx, Id, PosString};
use std::{num::NonZeroU64, path::PathBuf};

/// Corresponds to an individual Calyx file.
#[derive(Debug)]
pub struct NamespaceDef {
/// Path to extern files.
pub imports: Vec<String>,
pub imports: Vec<PosString>,
/// List of component definitions.
pub components: Vec<ComponentDef>,
/// Extern statements and any primitive declarations in them.
pub externs: Vec<(Option<String>, Vec<Primitive>)>,
pub externs: Vec<(Option<PosString>, Vec<Primitive>)>,
/// Optional opaque metadata
pub metadata: Option<String>,
}
Expand Down
56 changes: 29 additions & 27 deletions calyx-frontend/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::ast::{
};
use super::Attributes;
use crate::{Attribute, Direction, PortDef, Primitive, Width};
use calyx_utils::{self, CalyxResult, Id};
use calyx_utils::{self, CalyxResult, Id, PosString};
use calyx_utils::{FileIdx, GPosIdx, GlobalPositionTable};
use pest::pratt_parser::{Assoc, Op, PrattParser};
use pest_consume::{match_nodes, Error, Parser};
Expand Down Expand Up @@ -66,25 +66,16 @@ impl CalyxParser {
CalyxParser::parse_with_userdata(Rule::file, content, user_data)
.map_err(|e| e.with_path(&path.to_string_lossy()))
.map_err(|e| {
calyx_utils::Error::misc(format!(
"Failed to parse `{}`: {err}",
path.to_string_lossy(),
err = e
))
calyx_utils::Error::parse_error(e.variant.message())
.with_pos(&Self::error_span(&e, file))
})?;
let input = inputs.single().map_err(|e| {
calyx_utils::Error::misc(format!(
"Failed to parse `{}`: {err}",
path.to_string_lossy(),
err = e
))
calyx_utils::Error::parse_error(e.variant.message())
.with_pos(&Self::error_span(&e, file))
})?;
let out = CalyxParser::file(input).map_err(|e| {
calyx_utils::Error::misc(format!(
"Failed to parse `{}`: {err}",
path.to_string_lossy(),
err = e
))
calyx_utils::Error::parse_error(e.variant.message())
.with_pos(&Self::error_span(&e, file))
})?;
log::info!(
"Parsed `{}` in {}ms",
Expand All @@ -110,15 +101,16 @@ impl CalyxParser {
let inputs =
CalyxParser::parse_with_userdata(Rule::file, contents, user_data)
.map_err(|e| {
calyx_utils::Error::misc(
format!("Failed to parse buffer: {e}",),
)
calyx_utils::Error::parse_error(e.variant.message())
.with_pos(&Self::error_span(&e, file))
})?;
let input = inputs.single().map_err(|e| {
calyx_utils::Error::misc(format!("Failed to parse buffer: {e}",))
calyx_utils::Error::parse_error(e.variant.message())
.with_pos(&Self::error_span(&e, file))
})?;
let out = CalyxParser::file(input).map_err(|e| {
calyx_utils::Error::misc(format!("Failed to parse buffer: {e}",))
calyx_utils::Error::parse_error(e.variant.message())
.with_pos(&Self::error_span(&e, file))
})?;
Ok(out)
}
Expand All @@ -134,6 +126,15 @@ impl CalyxParser {
GPosIdx(pos)
}

fn error_span(error: &pest::error::Error<Rule>, file: FileIdx) -> GPosIdx {
let (start, end) = match error.location {
pest::error::InputLocation::Pos(off) => (off, off + 1),
pest::error::InputLocation::Span((start, end)) => (start, end),
};
let pos = GlobalPositionTable::as_mut().add_pos(file, start, end);
GPosIdx(pos)
}

#[allow(clippy::result_large_err)]
fn guard_expr_helper(
ud: UserData,
Expand Down Expand Up @@ -188,7 +189,7 @@ impl CalyxParser {

#[allow(clippy::large_enum_variant)]
enum ExtOrComp {
Ext((Option<String>, Vec<Primitive>)),
Ext((Option<PosString>, Vec<Primitive>)),
Comp(ComponentDef),
PrimInline(Primitive),
}
Expand Down Expand Up @@ -350,18 +351,19 @@ impl CalyxParser {
Ok(input.as_str())
}

fn string_lit(input: Node) -> ParseResult<String> {
fn string_lit(input: Node) -> ParseResult<PosString> {
let span = Self::get_span(&input);
Ok(match_nodes!(
input.into_children();
[char(c)..] => c.collect::<Vec<_>>().join("")
[char(c)..] => PosString::new(c.collect::<Vec<_>>().join(""), span)
))
}

// ================ Attributes =====================
fn attribute(input: Node) -> ParseResult<(Attribute, u64)> {
match_nodes!(
input.clone().into_children();
[string_lit(key), bitwidth(num)] => Attribute::from_str(&key).map(|attr| (attr, num)).map_err(|e| input.error(format!("{:?}", e)))
[string_lit(key), bitwidth(num)] => Attribute::from_str(key.as_ref()).map(|attr| (attr, num)).map_err(|e| input.error(format!("{:?}", e)))
)
}
fn attributes(input: Node) -> ParseResult<Attributes> {
Expand Down Expand Up @@ -1199,14 +1201,14 @@ impl CalyxParser {
)
}

fn imports(input: Node) -> ParseResult<Vec<String>> {
fn imports(input: Node) -> ParseResult<Vec<PosString>> {
Ok(match_nodes!(
input.into_children();
[string_lit(path)..] => path.collect()
))
}

fn ext(input: Node) -> ParseResult<(Option<String>, Vec<Primitive>)> {
fn ext(input: Node) -> ParseResult<(Option<PosString>, Vec<Primitive>)> {
Ok(match_nodes!(
input.into_children();
[string_lit(file), primitive(prims)..] => (Some(file), prims.collect())
Expand Down
31 changes: 17 additions & 14 deletions calyx-frontend/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::{
parser,
};
use crate::LibrarySignatures;
use calyx_utils::{CalyxResult, Error};
use calyx_utils::{CalyxResult, Error, WithPos};
use std::{
collections::HashSet,
path::{Path, PathBuf},
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Workspace {
lib_path: &Path,
) -> CalyxResult<PathBuf>
where
S: AsRef<Path> + Clone,
S: AsRef<Path> + Clone + WithPos,
{
let absolute_import = import.as_ref();
if absolute_import.is_absolute() && absolute_import.exists() {
Expand All @@ -87,7 +87,7 @@ impl Workspace {
import.as_ref().to_string_lossy(),
parent.to_string_lossy(),
lib_path.to_string_lossy()
)))
)).with_pos(&import))
}

// Get the absolute path to an extern. Extern can only exist on paths
Expand All @@ -98,17 +98,19 @@ impl Workspace {
parent: &Path,
) -> CalyxResult<PathBuf>
where
S: AsRef<Path> + Clone,
S: AsRef<Path> + Clone + WithPos,
{
let parent_path = parent.join(extern_path.clone()).canonicalize()?;
if parent_path.exists() {
return Ok(parent_path);
}
Err(Error::invalid_file(format!(
"Extern path `{}` not found in parent directory ({})",
extern_path.as_ref().to_string_lossy(),
parent.to_string_lossy(),
)))
parent
.join(extern_path.clone())
.canonicalize()
.map_err(|_| {
Error::invalid_file(format!(
"Extern path `{}` not found in parent directory ({})",
extern_path.as_ref().to_string_lossy(),
parent.to_string_lossy(),
))
.with_pos(&extern_path)
})
}

/// Construct a new workspace using the `compile.futil` library which
Expand Down Expand Up @@ -273,7 +275,8 @@ impl Workspace {
})?;

// Add original imports to workspace
ws.original_imports = ns.imports.clone();
ws.original_imports =
ns.imports.iter().map(|imp| imp.to_string()).collect();

// TODO (griffin): Probably not a great idea to clone the metadata
// string but it works for now
Expand Down
12 changes: 8 additions & 4 deletions calyx-ir/src/from_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,20 @@ pub fn ast_to_ir(mut workspace: Workspace) -> CalyxResult<Context> {
let mut all_names: HashSet<&Id> =
HashSet::with_capacity(workspace.components.len() + prims.len());

let prim_names = prims.iter().map(|p| &p.name);
let prim_names = prims.iter().map(|p| (&p.name, p.attributes.copy_span()));

let comp_names = workspace.components.iter().map(|comp| &comp.name);
let comp_names = workspace
.components
.iter()
.map(|comp| (&comp.name, comp.attributes.copy_span()));

for bound in prim_names.chain(comp_names) {
for (bound, span) in prim_names.chain(comp_names) {
if all_names.contains(bound) {
return Err(Error::already_bound(
*bound,
"component or primitive".to_string(),
));
)
.with_pos(&span));
}
all_names.insert(bound);
}
Expand Down
1 change: 1 addition & 0 deletions calyx-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ default = ["diagnostics"]
calyx-frontend.workspace = true
calyx-ir.workspace = true
calyx-utils.workspace = true
calyx-opt.workspace = true
chrono = "0.4.33"
itertools.workspace = true
regex = "1.10.3"
Expand Down
Loading
Loading