Commit ea6be94b authored by Kunshan Wang's avatar Kunshan Wang

Instruction tests.

parent 3427f5e4
......@@ -691,6 +691,320 @@ trait TestingBundlesValidators extends Matchers with ExtraMatchers {
its.opnd shouldBe (my inst "%new2")
its.ty shouldBeA[TypeIRef] { _.ty shouldBe (our ty "@sid") }
}
my inst "%getfieldiref" shouldBeA[InstGetFieldIRef] { its =>
its.referentTy shouldBe (our ty "@sid")
its.index shouldBe 0
its.opnd shouldBe (my inst "%getiref")
its.ty shouldBeA[TypeIRef] { _.ty shouldBeATypeIntOf 64 }
}
my inst "%getelemiref" shouldBeA[InstGetElemIRef] { its =>
its.referentTy shouldBe (our ty "@al")
its.opnd shouldBe (my inst "%alloca2")
its.index shouldBe (my param "%p1")
its.ty shouldBeA[TypeIRef] { _.ty shouldBeATypeIntOf 64 }
}
my inst "%shiftiref" shouldBeA[InstShiftIRef] { its =>
its.referentTy shouldBeATypeIntOf 8
its.opnd shouldBe (my inst "%getvarpartiref")
its.offset shouldBe (my param "%p1")
its.ty shouldBeA[TypeIRef] { _.ty shouldBeATypeIntOf 8 }
}
my inst "%getfixedpartiref" shouldBeA[InstGetFixedPartIRef] { its =>
its.referentTy shouldBe (our ty "@hic")
its.opnd shouldBe (my inst "%allocahybrid")
its.ty shouldBeA[TypeIRef] { _.ty shouldBeATypeIntOf 64 }
}
my inst "%getvarpartiref" shouldBeA[InstGetVarPartIRef] { its =>
its.referentTy shouldBe (our ty "@hic")
its.opnd shouldBe (my inst "%allocahybrid")
its.ty shouldBeA[TypeIRef] { _.ty shouldBeATypeIntOf 8 }
}
my inst "%load" shouldBeA[InstLoad] { its =>
its.ord shouldBe MemoryOrdering.NOT_ATOMIC
its.referentTy shouldBeATypeIntOf 64
its.loc shouldBe (my inst "%alloca")
its.ty shouldBeATypeIntOf 64
}
my inst "%store" shouldBeA[InstStore] { its =>
its.ord shouldBe MemoryOrdering.NOT_ATOMIC
its.referentTy shouldBeATypeIntOf 64
its.loc shouldBe (my inst "%alloca")
its.newVal shouldBeAConstIntOf(64, 42)
its.ty shouldBeA[TypeVoid] thatsIt
}
my inst "%cmpxchg" shouldBeA[InstCmpXchg] { its =>
its.ordSucc shouldBe MemoryOrdering.ACQUIRE
its.ordFail shouldBe MemoryOrdering.MONOTONIC
its.referentTy shouldBeATypeIntOf 64
its.loc shouldBe (my inst "%alloca")
its.expected shouldBeAConstIntOf(64, 42)
its.desired shouldBeAConstIntOf(64, 0)
its.ty shouldBeATypeIntOf 64
}
my inst "%atomicrmw" shouldBeA[InstAtomicRMW] { its =>
its.ord shouldBe MemoryOrdering.ACQ_REL
its.op shouldBe AtomicRMWOptr.ADD
its.referentTy shouldBeATypeIntOf 64
its.loc shouldBe (my inst "%alloca")
its.opnd shouldBeAConstIntOf(64, 50)
its.ty shouldBeATypeIntOf 64
}
my inst "%fence" shouldBeA[InstFence] { its =>
its.ord shouldBe (MemoryOrdering.MONOTONIC)
its.ty shouldBeA[TypeVoid] thatsIt
}
}
in (our func "@memorder") { (func, cfg) =>
val my = cfg
my inst "%l0" shouldBeA[InstLoad] { _.ord = MemoryOrdering.NOT_ATOMIC }
my inst "%l1" shouldBeA[InstLoad] { _.ord = MemoryOrdering.UNORDERED }
my inst "%l2" shouldBeA[InstLoad] { _.ord = MemoryOrdering.MONOTONIC }
my inst "%f3" shouldBeA[InstFence] { _.ord = MemoryOrdering.ACQUIRE }
my inst "%f4" shouldBeA[InstFence] { _.ord = MemoryOrdering.RELEASE }
my inst "%f5" shouldBeA[InstFence] { _.ord = MemoryOrdering.ACQ_REL }
my inst "%l6" shouldBeA[InstLoad] { _.ord = MemoryOrdering.SEQ_CST }
}
in (our func "@atomicrmwops") { (func, cfg) =>
val my = cfg
my inst "%old0" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.XCHG }
my inst "%old1" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.ADD }
my inst "%old2" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.SUB }
my inst "%old3" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.AND }
my inst "%old4" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.NAND }
my inst "%old5" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.OR }
my inst "%old6" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.XOR }
my inst "%old7" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.MAX }
my inst "%old8" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.MIN }
my inst "%old9" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.UMAX }
my inst "%olda" shouldBeA[InstAtomicRMW] { _.op = AtomicRMWOptr.UMIN }
}
in (our func "@traps") { (func, cfg) =>
val my = cfg
my inst "%tp" shouldBeA[InstTrap] { its =>
its.retTy shouldBeATypeIntOf 32
its.nor shouldBe (my bb "%trapcont")
its.exc shouldBe (my bb "%trapexc")
its.keepAlives shouldBe Seq(my inst "%b", my inst "%wp")
}
my inst "%wp" shouldBeA[InstWatchpoint] { its =>
its.wpID shouldBe 1
its.retTy shouldBeATypeIntOf 64
its.dis shouldBe (my bb "%body")
its.nor shouldBe (my bb "%wpcont")
its.exc shouldBe (my bb "%wpexc")
its.keepAlives shouldBe Seq(my inst "%a")
}
}
in (our func "@ccall") { (func, cfg) =>
val my = cfg
my inst "%rv" shouldBeA[InstCCall] { its =>
its.callConv shouldBe CallConv.DEFAULT
its.sig.retTy shouldBeA[TypeVoid] thatsIt
its.sig.paramTy(0) shouldBeA[TypeDouble] thatsIt
its.sig.paramTy.size shouldBe 1
its.callee shouldBe (my param "%p0")
its.args.size shouldBe 1
its.args(0) shouldBeAConstDoubleOf(3.14d)
}
}
in (our func "@stack_and_intrinsic") { (func, cfg) =>
val my = cfg
my inst "%ns" shouldBeA[InstNewStack] { its =>
its.sig shouldBe (our sig "@iiisig")
its.callee shouldBe (our const "@callee2")
its.args.size shouldBe 2
its.args(0) shouldBeAConstIntOf(64, 5)
its.args(1) shouldBeAConstIntOf(64, 6)
}
my inst "%i" shouldBeA[InstICall] { its =>
its.iFunc shouldBe IFuncs.UVM_SWAP_STACK
its.args.size shouldBe 1
its.args(0) shouldBe (my inst "%ns")
its.keepAlives.size shouldBe 1
its.keepAlives(0) shouldBe (my inst "%b")
}
my inst "%j" shouldBeA[InstIInvoke] { its =>
its.iFunc shouldBe IFuncs.UVM_KILL_STACK
its.args.size shouldBe 1
its.args(0) shouldBe (my inst "%ns")
its.nor shouldBe (my bb "%nor")
its.exc shouldBe (my bb "%exc")
its.keepAlives.size shouldBe 2
its.keepAlives(0) shouldBe (my inst "%b")
its.keepAlives(1) shouldBe (my inst "%c")
}
}
in (our func "@inference") { (func, cfg) =>
val my = cfg
my inst "%add" shouldBeA[InstBinOp] { its =>
its.op1 shouldBeAConstIntOf(8, 41)
its.op2 shouldBeAConstIntOf(8, 42)
}
my inst "%sub" shouldBeA[InstBinOp] { its =>
its.op1 shouldBeAConstIntOf(16, 43)
its.op2 shouldBeAConstIntOf(16, 44)
}
my inst "%mul" shouldBeA[InstBinOp] { its =>
its.op1 shouldBeAConstIntOf(32, 45)
its.op2 shouldBeAConstIntOf(32, 46)
}
my inst "%udiv" shouldBeA[InstBinOp] { its =>
its.op1 shouldBeAConstIntOf(64, 47)
its.op2 shouldBeAConstIntOf(64, 48)
}
my inst "%fadd" shouldBeA[InstBinOp] { its =>
its.op1 shouldBeAConstFloatOf(49.0f)
its.op2 shouldBeAConstFloatOf(50.0f)
}
my inst "%fsub" shouldBeA[InstBinOp] { its =>
its.op1 shouldBeAConstDoubleOf(51.0d)
its.op2 shouldBeAConstDoubleOf(52.0d)
}
my inst "%eq" shouldBeA[InstCmp] { its =>
its.op1 shouldBeAConstIntOf(64, 53)
its.op2 shouldBeAConstIntOf(64, 54)
}
my inst "%fueq" shouldBeA[InstCmp] { its =>
its.op1 shouldBeAConstDoubleOf(55.0d)
its.op2 shouldBeAConstDoubleOf(56.0d)
}
my inst "%trunc" shouldBeA[InstConv] { its =>
its.opnd shouldBeAConstIntOf(64, 57)
}
my inst "%fptrunc" shouldBeA[InstConv] { its =>
its.opnd shouldBeAConstDoubleOf(58.0d)
}
my inst "%refcast" shouldBeA[InstConv] { its =>
its.opnd shouldBeA[ConstNull] { _.constTy shouldBeA[TypeRef] {
_.ty shouldBeA[TypeVoid] thatsIt
}}
}
my inst "%irefcast" shouldBeA[InstConv] { its =>
its.opnd shouldBeA[ConstNull] { _.constTy shouldBeA[TypeIRef] {
_.ty shouldBeA[TypeVoid] thatsIt
}}
}
my inst "%select" shouldBeA[InstSelect] { its =>
its.ifTrue shouldBeAConstDoubleOf(59.0d)
its.ifFalse shouldBeAConstDoubleOf(60.0d)
}
my inst "%switch" shouldBeA[InstSwitch] { its =>
its.opnd shouldBeAConstIntOf(32, 61)
its.cases(0)._1 shouldBeAConstIntOf(32, 62)
}
my inst "%phi" shouldBeA[InstPhi] { its =>
its.cases(0)._2 shouldBeAConstIntOf(32, 63)
}
my inst "%call" shouldBeA[InstCall] { its =>
its.args(0) shouldBeAConstIntOf(8, 64)
its.args(1) shouldBeAConstIntOf(16, 65)
its.args(2) shouldBeAConstIntOf(32, 66)
its.args(3) shouldBeAConstIntOf(64, 67)
its.args(4) shouldBeAConstFloatOf(68.0f)
its.args(5) shouldBeAConstDoubleOf(69.0d)
}
my inst "%invoke" shouldBeA[InstInvoke] { its =>
its.args(0) shouldBeAConstIntOf(8, 70)
its.args(1) shouldBeAConstIntOf(16, 71)
its.args(2) shouldBeAConstIntOf(32, 72)
its.args(3) shouldBeAConstIntOf(64, 73)
its.args(4) shouldBeAConstFloatOf(74.0f)
its.args(5) shouldBeAConstDoubleOf(75.0d)
}
my inst "%tailcall" shouldBeA[InstTailCall] { its =>
its.args(0) shouldBeAConstIntOf(8, 76)
its.args(1) shouldBeAConstIntOf(16, 77)
its.args(2) shouldBeAConstIntOf(32, 78)
its.args(3) shouldBeAConstIntOf(64, 79)
its.args(4) shouldBeAConstFloatOf(80.0f)
its.args(5) shouldBeAConstDoubleOf(81.0d)
}
my inst "%extractvalue" shouldBeA[InstExtractValue] { its =>
its.opnd shouldBeA[ConstStruct] { s =>
s.fields(0) shouldBeAConstIntOf(8, 82)
s.fields(1) shouldBeAConstIntOf(16, 83)
s.fields(2) shouldBeAConstIntOf(32, 84)
s.fields(3) shouldBeAConstIntOf(64, 85)
s.fields(4) shouldBeAConstFloatOf(86.0f)
s.fields(5) shouldBeAConstDoubleOf(87.0d)
}
}
my inst "%insertvalue" shouldBeA[InstInsertValue] { its =>
its.opnd shouldBeA[ConstStruct] { s =>
s.fields(0) shouldBeAConstIntOf(8, 88)
s.fields(1) shouldBeAConstIntOf(16, 89)
s.fields(2) shouldBeAConstIntOf(32, 90)
s.fields(3) shouldBeAConstIntOf(64, 91)
s.fields(4) shouldBeAConstFloatOf(92.0f)
s.fields(5) shouldBeAConstDoubleOf(93.0d)
}
its.newVal shouldBeAConstIntOf(8, 94)
}
my inst "%store" shouldBeA[InstStore] { its =>
its.newVal shouldBeAConstIntOf(32, 99)
}
my inst "%cmpxchg" shouldBeA[InstCmpXchg] { its =>
its.expected shouldBeAConstIntOf(32, 100)
its.desired shouldBeAConstIntOf(32, 101)
}
my inst "%atomicrmw" shouldBeA[InstAtomicRMW] { its =>
its.opnd shouldBeAConstIntOf(32, 102)
}
my inst "%ccall" shouldBeA[InstCCall] { its =>
its.args(0) shouldBeAConstIntOf(8, 103)
its.args(1) shouldBeAConstIntOf(16, 104)
its.args(2) shouldBeAConstIntOf(32, 105)
its.args(3) shouldBeAConstIntOf(64, 106)
its.args(4) shouldBeAConstFloatOf(107.0f)
its.args(5) shouldBeAConstDoubleOf(108.0d)
}
my inst "%newstack" shouldBeA[InstNewStack] { its =>
its.args(0) shouldBeAConstIntOf(8, 109)
its.args(1) shouldBeAConstIntOf(16, 110)
its.args(2) shouldBeAConstIntOf(32, 111)
its.args(3) shouldBeAConstIntOf(64, 112)
its.args(4) shouldBeAConstFloatOf(113.0f)
its.args(5) shouldBeAConstDoubleOf(114.0d)
}
}
}
}
\ No newline at end of file
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