circt/test/Dialect/LLHD/IR/inst.mlir

70 lines
3.9 KiB
MLIR
Raw Normal View History

Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
//RUN: circt-opt %s -split-input-file -verify-diagnostics | circt-opt | FileCheck %s
// Testing Objectives:
// * inst can only be used in entities
// * inst must always refer to a valid proc or entity (match symbol name, input and output operands)
// * syntax: no inputs and outputs, one input zero outputs, zero inputs one output, multiple inputs and outputs
// * check that number of inputs and number of outputs are verified separately
// CHECK-LABEL: @empty_entity
llhd.entity @empty_entity() -> () {}
// CHECK-LABEL: @one_input_entity
llhd.entity @one_input_entity(%arg : !llhd.sig<i32>) -> () {}
// CHECK-LABEL: @one_output_entity
llhd.entity @one_output_entity() -> (%arg : !llhd.sig<i32>) {}
// CHECK-LABEL: @entity
llhd.entity @entity(%arg0 : !llhd.sig<i32>, %arg1 : !llhd.sig<i16>) -> (%out0 : !llhd.sig<i8>, %out1 : !llhd.sig<i4>) {}
// CHECK-LABEL: @empty_proc
llhd.proc @empty_proc() -> () {
llhd.halt
Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
}
// CHECK-LABEL: @one_input_proc
llhd.proc @one_input_proc(%arg : !llhd.sig<i32>) -> () {
llhd.halt
Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
}
// CHECK-LABEL: @one_output_proc
llhd.proc @one_output_proc() -> (%arg : !llhd.sig<i32>) {
llhd.halt
Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
}
// CHECK-LABEL: @proc
llhd.proc @proc(%arg0 : !llhd.sig<i32>, %arg1 : !llhd.sig<i16>) -> (%out0 : !llhd.sig<i8>, %out1 : !llhd.sig<i4>) {
llhd.halt
Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
}
// CHECK-LABEL: @hwModule
hw.module @hwModule(%arg0 : i32, %arg1 : i16) -> (arg2: i8) {
%0 = hw.constant 2 : i8
hw.output %0 : i8
}
Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
// CHECK: llhd.entity @caller (%[[ARG0:.*]] : !llhd.sig<i32>, %[[ARG1:.*]] : !llhd.sig<i16>) -> (%[[OUT0:.*]] : !llhd.sig<i8>, %[[OUT1:.*]] : !llhd.sig<i4>) {
llhd.entity @caller(%arg0 : !llhd.sig<i32>, %arg1 : !llhd.sig<i16>) -> (%out0 : !llhd.sig<i8>, %out1 : !llhd.sig<i4>) {
// CHECK-NEXT: llhd.inst "empty_entity" @empty_entity() -> () : () -> ()
"llhd.inst"() {callee=@empty_entity, operand_segment_sizes=array<i32: 0,0>, name="empty_entity"} : () -> ()
// CHECK-NEXT: llhd.inst "empty_proc" @empty_proc() -> () : () -> ()
"llhd.inst"() {callee=@empty_proc, operand_segment_sizes=array<i32: 0,0>, name="empty_proc"} : () -> ()
// CHECK-NEXT: llhd.inst "one_in_entity" @one_input_entity(%[[ARG0]]) -> () : (!llhd.sig<i32>) -> ()
"llhd.inst"(%arg0) {callee=@one_input_entity, operand_segment_sizes=array<i32: 1,0>, name="one_in_entity"} : (!llhd.sig<i32>) -> ()
// CHECK-NEXT: llhd.inst "one_in_proc" @one_input_proc(%[[ARG0]]) -> () : (!llhd.sig<i32>) -> ()
"llhd.inst"(%arg0) {callee=@one_input_proc, operand_segment_sizes=array<i32: 1,0>, name="one_in_proc"} : (!llhd.sig<i32>) -> ()
// CHECK-NEXT: llhd.inst "one_out_entity" @one_output_entity() -> (%[[ARG0]]) : () -> !llhd.sig<i32>
"llhd.inst"(%arg0) {callee=@one_output_entity, operand_segment_sizes=array<i32: 0,1>, name="one_out_entity"} : (!llhd.sig<i32>) -> ()
// CHECK-NEXT: llhd.inst "one_out_proc" @one_output_proc() -> (%[[ARG0]]) : () -> !llhd.sig<i32>
"llhd.inst"(%arg0) {callee=@one_output_proc, operand_segment_sizes=array<i32: 0,1>, name="one_out_proc"} : (!llhd.sig<i32>) -> ()
// CHECK-NEXT: llhd.inst "entity" @entity(%[[ARG0]], %[[ARG1]]) -> (%[[OUT0]], %[[OUT1]]) : (!llhd.sig<i32>, !llhd.sig<i16>) -> (!llhd.sig<i8>, !llhd.sig<i4>)
"llhd.inst"(%arg0, %arg1, %out0, %out1) {callee=@entity, operand_segment_sizes=array<i32: 2,2>, name="entity"} : (!llhd.sig<i32>, !llhd.sig<i16>, !llhd.sig<i8>, !llhd.sig<i4>) -> ()
// CHECK-NEXT: llhd.inst "proc" @proc(%[[ARG0]], %[[ARG1]]) -> (%[[OUT0]], %[[OUT1]]) : (!llhd.sig<i32>, !llhd.sig<i16>) -> (!llhd.sig<i8>, !llhd.sig<i4>)
"llhd.inst"(%arg0, %arg1, %out0, %out1) {callee=@proc, operand_segment_sizes=array<i32: 2,2>, name="proc"} : (!llhd.sig<i32>, !llhd.sig<i16>, !llhd.sig<i8>, !llhd.sig<i4>) -> ()
// CHECK-NEXT: llhd.inst "module" @hwModule(%[[ARG0]], %[[ARG1]]) -> (%[[OUT0]]) : (!llhd.sig<i32>, !llhd.sig<i16>) -> !llhd.sig<i8>
llhd.inst "module" @hwModule(%arg0, %arg1) -> (%out0) : (!llhd.sig<i32>, !llhd.sig<i16>) -> !llhd.sig<i8>
// CHECK-NEXT: }
Merge LLHD project into CIRCT (#14) * Merge LLHD project into CIRCT * Split LLHDOps.td into multiple smaller files * move LLHDToLLVM init definition and prune includes * Format tablegen files with 2 space indent, 80 col width; move out trait helper function * Move implementation logic from LLHDOps.h to cpp file * Empty lines for breathing space; nicer operation separators * Move simulator to Dialect/LLHD/Simulator * move `State.h` and `signal-runtime-wrappers.h` to lib directory * pass ModuleOp by value * make getters const, return ModuleOp by value * Use isa, cast, dyn_cast appropriately * wrap struct in anon namespace; make helpers static * [cmake] Fold into LINK_LIBS * fix for loops * replace floating point with `divideCeil` * prune redundant includes * make llhd-sim helpers static * remove StandardToLLVM pass registration * move verilog printer to cpp file, add global function as public API * Move transformation pass base classes and registration to lib, add file header boilerplate * Few improvements * Return diagnostics directly * isa instead of kindof * Improve walks * etc. * add 'using namespace llvm;' again * Always pass a location when creating new ops * Improve cmake files * remove unnecessary `LLVMSupport` links. * add `PUBLIC` where missing. * move LLVMCore under `LINK_COMPONENTS`. * Add file headers and improve simulator comments * Some LLHDToLLVM improvements * Fix walks. * Use `std::array` instead of `SmallVector` when resize is not needed. * Fix a potential sefgault by passing an ArrayRef with no data owner. * Remove some unnecessary steps. * Remove some unnecessary const strings. * Add new LowerToLLVMOptions argument The new argument was added in 10643c9ad85bf072816bd271239281ec50a52e31. * Add missing file header boilerplate and newline * Improve for-loop * use static instead of anonymous namespace for functions * fit to 80 columns, cast instead of dyn_cast * Changes for LLVM update * use llvm format instead of std::stringstream and iomanip Co-authored-by: rodonisi <simon@rodoni.ch>
2020-07-03 02:04:33 +08:00
}