google / google/xls

ir_convert doesn't support `impl` functions

Open
#2,082 2 comments 0 reactions 1 assignee Claimed by @erinzmoore View on GitHub
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
You can use `impl ` for a more concise way of defining struct operations but the designs created do not support being converted into IR and can therefore not be compiled to verilog or other outputs.

**To Reproduce**
Steps to reproduce the behavior:
1. Create a design with `impl` methods
2. From the `top` fn try to call an impl method
3. See error

**Expected behavior**
The ir_convert creates a file where an invoke of the impl'd function is present

**Additional context**
Add any other context about the problem here.

```
% cat /tmp/foobar.x
struct F {}

impl F {
pub fn bar(self) -> F { trace_fmt!("foo"); F {} }
}

struct G { f: F }
impl G {
pub fn foo(self) -> F {
self.f.bar()
}
}

fn top_fn() -> F {
let g = G { f: F {} };
g.foo()
}

% bazel run //xls/dslx/ir_convert:ir_converter_main -- /tmp/foobar.x --top=top_fn --alsologtostderr
...
Error: UNIMPLEMENTED: Only calls to named functions are currently supported for IR conversion; callee: g.foo
=== Source Location Trace: ===
xls/dslx/ir_convert/extract_conversion_order.cc:296
xls/dslx/ir_convert/extract_conversion_order.cc:225
xls/dslx/ir_convert/extract_conversion_order.cc:679
xls/dslx/ir_convert/extract_conversion_order.cc:725
xls/dslx/ir_convert/extract_conversion_order.cc:915
xls/dslx/ir_convert/ir_converter.cc:417
xls/dslx/ir_convert/ir_converter.cc:555
xls/dslx/ir_convert/ir_converter.cc:604
xls/dslx/ir_convert/ir_converter_main.cc:137
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.