@@ -135,6 +135,75 @@ def Xls_TranslationLinkage : Xls_Attr<"TranslationLinkage"> {
135135 let attrName = "xls.translation_linkage";
136136}
137137
138+ def Xls_FlopKindNone : I32EnumAttrCase<"kNone", 0, "none"> {
139+ let summary = "No flop.";
140+ let description = [{
141+ Adds no buffer to the input/output.
142+
143+ See https://google.github.io/xls/codegen_options/#io-behavior for more information.
144+ }];
145+ }
146+ def Xls_FlopKindFlop : I32EnumAttrCase<"kFlop", 1, "flop"> {
147+ let summary = "Basic flop.";
148+ let description = [{
149+ Adds a pipeline stage to the input/output. This is essentially a single-element FIFO
150+
151+ See https://google.github.io/xls/codegen_options/#io-behavior for more information.
152+ }];
153+ }
154+ def Xls_FlopKindSkid : I32EnumAttrCase<"kSkid", 2, "skid"> {
155+ let summary = "Skip flop.";
156+ let description = [{
157+ Adds a skid buffer to the input/output. The skid buffer can hold 2 entries.
158+
159+ See https://google.github.io/xls/codegen_options/#io-behavior for more information.
160+ }];
161+ }
162+ def Xls_FlopKindZeroLatency : I32EnumAttrCase<"kZeroLatency", 3, "zero-latency"> {
163+ let summary = "Zero-latency flop.";
164+ let description = [{
165+ Adds a zero-latency buffer to the input/output. This is essentially a
166+ single-element FIFO with bypass.
167+
168+ See https://google.github.io/xls/codegen_options/#io-behavior for more information.
169+ }];
170+ }
171+ def Xls_FlopKind : I32EnumAttr<"FlopKind", "XLS flop kind",
172+ [Xls_FlopKindNone, Xls_FlopKindFlop, Xls_FlopKindSkid, Xls_FlopKindZeroLatency]> {
173+ let genSpecializedAttr = 0;
174+ let cppNamespace = "::mlir::xls";
175+ }
176+ def Xls_FlopKindAttr : EnumAttr<Xls_Dialect, Xls_FlopKind, "flop_kind"> {
177+ let summary = "Channel flop/buffer kind.";
178+ let description = [{
179+ The inputs/outputs of procs/blocks can optionally be fitted with one of a
180+ number of buffer types. This is specified on the channel connected to this
181+ proc input/output, using the `input_flop_kind` and `output_flop_kind`
182+ property.
183+
184+ See https://google.github.io/xls/codegen_options/#io-behavior for more information.
185+ }];
186+ }
187+
188+ def Xls_FifoConfig : Xls_Attr<"FifoConfig"> {
189+ let summary = "FIFO Configuration Attribute";
190+ let description = [{
191+ Definies the properties of the physical FIFO to be instantiated from
192+ an (internal) channel.
193+ }];
194+
195+ let parameters = (ins
196+ "int64_t":$fifo_depth,
197+ "bool":$bypass,
198+ "bool":$register_push_outputs,
199+ "bool":$register_pop_outputs
200+ );
201+
202+ let mnemonic = "fifo_config";
203+
204+ let assemblyFormat = "`<` struct(params) `>`";
205+ }
206+
138207class GetShapeSplat<string name> :
139208 StrFunc<"getShapeSplat($" # name # ".getType())">;
140209
@@ -1626,6 +1695,9 @@ def Xls_ChanOp : Xls_Op<"chan", [
16261695 let arguments = (ins
16271696 SymbolNameAttr:$sym_name,
16281697 TypeAttr:$type,
1698+ OptionalAttr<Xls_FifoConfig>: $fifo_config,
1699+ OptionalAttr<Xls_FlopKindAttr>: $input_flop_kind,
1700+ OptionalAttr<Xls_FlopKindAttr>: $output_flop_kind,
16291701 DefaultValuedAttr<BoolAttr, "true">:$send_supported,
16301702 DefaultValuedAttr<BoolAttr, "true">:$recv_supported
16311703 );
@@ -1653,7 +1725,6 @@ def Xls_ChanOp : Xls_Op<"chan", [
16531725 void setArgAttrsAttr(ArrayAttr) { return; }
16541726 void setResAttrsAttr(ArrayAttr) { return; }
16551727 }];
1656-
16571728}
16581729
16591730def Xls_InstantiateEprocOp : Xls_Op<"instantiate_eproc", [DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
@@ -1763,7 +1834,10 @@ def Xls_SchanOp : Xls_Op<"schan", [Pure, HasParent<"SprocOp">]> {
17631834 }];
17641835 let arguments = (ins
17651836 StrAttr:$name,
1766- TypeAttr:$type
1837+ TypeAttr:$type,
1838+ OptionalAttr<Xls_FifoConfig>: $fifo_config,
1839+ OptionalAttr<Xls_FlopKindAttr>: $input_flop_kind,
1840+ OptionalAttr<Xls_FlopKindAttr>: $output_flop_kind
17671841 );
17681842 let results = (outs
17691843 Xls_SchanType:$out,
@@ -1774,7 +1848,8 @@ def Xls_SchanOp : Xls_Op<"schan", [Pure, HasParent<"SprocOp">]> {
17741848 OpBuilder<(ins "::mlir::StringRef":$name, "::mlir::Type":$element_type), [{
17751849 auto inChanTy = SchanType::get($_builder.getContext(), element_type, /*isInput=*/true);
17761850 auto outChanTy = SchanType::get($_builder.getContext(), element_type, /*isInput=*/false);
1777- build($_builder, $_state, ::mlir::TypeRange{outChanTy, inChanTy}, name, element_type);
1851+ // TODO(jpienaar): Remove unecessary default args once they are generated automatically.
1852+ build($_builder, $_state, ::mlir::TypeRange{outChanTy, inChanTy}, name, element_type, /*fifo_config=*/nullptr, /*input_flop_kind=*/nullptr, /*output_flop_kind=*/nullptr);
17781853 }]>
17791854 ];
17801855}
0 commit comments