Commit 9431b7ce authored by Kunshan Wang's avatar Kunshan Wang

Parser test passed.

parent 4d4846eb
......@@ -543,7 +543,7 @@ class UIRTextReader(val idFactory: IDFactory) {
i.dis = ii.dis; i.ena = ii.ena; i.exc = Option(ii.wpExc).map(resBB); i.keepAlives = ii.keepAliveClause
}
case ii: InstCCallContext =>
InstCCall(CallConv.withName(ii.callconv.getText), ii.funcTy, null, null, null).later(phase4) { i =>
InstCCall(CallConv.withName(ii.callconv.getText), ii.funcTy, ii.funcSig, null, null).later(phase4) { i =>
i.callee = ii.callee; i.argList = ii.argList
}
case ii: InstNewStackContext =>
......
package uvm.ir.textinput
import org.scalatest._
import uvm._
trait AbstractReaderSpec extends FlatSpec with Matchers
with TestingBundlesValidators {
val EMPTY_BUNDLE = new Bundle()
def parseFile(fileName: String, globalBundle: Bundle): Bundle
def theSubject: String
behavior of theSubject
it should "read simple type definitions" in {
val b = parseFile("tests/uvm-parsing-test/types.uir", EMPTY_BUNDLE)
validateTypes(b)
}
it should "read simple constant definitions" in {
val b = parseFile("tests/uvm-parsing-test/constants.uir", EMPTY_BUNDLE)
validateConstants(b)
}
it should "read simple function definitions" in {
val b = parseFile("tests/uvm-parsing-test/functions.uir", EMPTY_BUNDLE)
validateFunctions(b)
}
it should "read simple instruction definitions" in {
val b = parseFile("tests/uvm-parsing-test/instructions.uir", EMPTY_BUNDLE)
validateInstructions(b)
}
it should "handle loading of multiple bundles" in {
//val gb = parseFile("tests/uvm-parsing-test/redef-base.uir", EMPTY_BUNDLE)
//val b = parseFile("tests/uvm-parsing-test/redef-overlay.uir", gb)
//validateRedef(gb, b)
//gb.merge(b)
//validateRedefAfterMerge(gb, b)
}
}
\ No newline at end of file
......@@ -5,14 +5,44 @@ import org.scalatest.Matchers
import uvm.Bundle
class UIRTextReaderSpec extends AbstractReaderSpec {
override def theSubject = "UIRTextReader"
class UIRTextReaderSpec extends FlatSpec with Matchers
with TestingBundlesValidators {
override def parseFile(fileName: String, globalBundle: Bundle): Bundle = {
val idf = new IDFactory()
def parseFile(fileName: String, globalBundle: Bundle, fac: Option[IDFactory] = None): Bundle = {
val idf = fac.getOrElse(new IDFactory())
val r = new UIRTextReader(idf)
val ir = r.read(new java.io.FileReader(fileName), globalBundle)
ir
}
val EMPTY_BUNDLE = new Bundle()
behavior of "UIRTextReader"
it should "read simple type definitions" in {
val b = parseFile("tests/uvm-parsing-test/types.uir", EMPTY_BUNDLE)
validateTypes(b)
}
it should "read simple constant definitions" in {
val b = parseFile("tests/uvm-parsing-test/constants.uir", EMPTY_BUNDLE)
validateConstants(b)
}
it should "read simple function definitions" in {
val b = parseFile("tests/uvm-parsing-test/functions.uir", EMPTY_BUNDLE)
validateFunctions(b)
}
it should "read simple instruction definitions" in {
val b = parseFile("tests/uvm-parsing-test/instructions.uir", EMPTY_BUNDLE)
validateInstructions(b)
}
it should "handle loading of multiple bundles" in {
val idf = new IDFactory()
val gb = parseFile("tests/uvm-parsing-test/redef-base.uir", EMPTY_BUNDLE, Some(idf))
val b = parseFile("tests/uvm-parsing-test/redef-overlay.uir", gb, Some(idf))
validateRedef(gb, b)
//gb.merge(b)
//validateRedefAfterMerge(gb, b)
}
}
\ No newline at end of file
......@@ -394,8 +394,10 @@
.funcdef @swapstack VERSION @swapstack_v1 <@npnr_sig> () {
%entry:
%curstack = COMMINST @uvm.current_stack
%coro = NEWSTACK <@iii_sig> @callee2 (%curstack)
%ss1 = SWAPSTACK %coro RET_WITH <@i64> PASS_VOID
%coro = NEWSTACK <@iii_sig> @callee2 (%curstack) EXC(%cont %exc)
%cont:
%ss1 = SWAPSTACK %coro RET_WITH <@i64> PASS_VOID KEEPALIVE(%curstack)
%ss2 = SWAPSTACK %coro RET_WITH <@i64> PASS_VOID EXC(%nor %exc)
%nor:
......
.typedef @i64 = int<64>
.const @I64_42 <@i64> = 42
.funcsig @IntReturner = @i64 ()
.funcdef @meaning_of_life <@IntReturner> () {
%ret = RET <@i64> 42
.funcdef @meaning_of_life VERSION @meaning_of_life_v1 <@IntReturner> () {
%entry:
%ret = RET <@i64> @I64_42
}
.funcdecl @foxsay <@IntReturner>
.funcdef @foxsay <@IntReturner> () {
%ret = RET <@i64> 99
.const @I64_99 <@i64> = 99
.const @I64_43 <@i64> = 43
.funcdef @foxsay VERSION @foxsay_v1 <@IntReturner> () {
%entry:
%ret = RET <@i64> @I64_99
}
.funcdef @meaning_of_life <@IntReturner> () {
%ret = RET <@i64> 43
.funcdef @meaning_of_life VERSION @meaning_of_life_v2 <@IntReturner> () {
%entry:
%ret = RET <@i64> @I64_43
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment