-
Notifications
You must be signed in to change notification settings - Fork 48
/
SeqFPMem.scala
38 lines (31 loc) · 1.2 KB
/
SeqFPMem.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package torture
import scala.collection.mutable.ArrayBuffer
import Rand._
class SeqFPMem(xregs: HWRegPool, fregs_s: HWRegPool, fregs_d: HWRegPool, mem: Mem) extends InstSeq
{
override val seqname = "fpmem"
def seq_load_addrfn(op: Opcode, addrfn: (Int) => Int, fregpool: HWRegPool) = () =>
{
val reg_addr = reg_write_hidden(xregs)
val reg_dest = reg_write_visible(fregpool)
val addr = addrfn(mem.size)
val imm = rand_imm()
insts += LA(reg_addr, BaseImm(mem.toString, addr-imm))
insts += op(reg_dest, RegImm(reg_addr, imm))
}
def seq_store_addrfn(op: Opcode, addrfn: (Int) => Int, fregpool: HWRegPool) = () =>
{
val reg_addr = reg_write_hidden(xregs)
val reg_src = reg_read_visible(fregpool)
val addr = addrfn(mem.size)
val imm = rand_imm()
insts += LA(reg_addr, BaseImm(mem.toString, addr-imm))
insts += op(reg_src, RegImm(reg_addr, imm))
}
val candidates = new ArrayBuffer[() => insts.type]
candidates += seq_load_addrfn(FLW, rand_addr_w, fregs_s)
candidates += seq_store_addrfn(FSW, rand_addr_w, fregs_s)
candidates += seq_load_addrfn(FLD, rand_addr_d, fregs_d)
candidates += seq_store_addrfn(FSD, rand_addr_d, fregs_d)
rand_pick(candidates)()
}