res.append((os.path.join(insns_dir, fname), insn))
return res
-patterns = ['WRITE_RD', 'RS1', 'RS2', 'RS3',
- 'WRITE_FRD', 'FRS1', 'FRS2', 'FRS3']
+intpatterns = ['WRITE_RD', 'RS1', 'RS2', 'RS3']
+floatpatterns = ['WRITE_FRD', 'FRS1', 'FRS2', 'FRS3']
+patterns = intpatterns + floatpatterns
def find_registers(fname):
res = []
+ isintfloat = 0x0 + 0xf << 4
with open(fname) as f:
f = f.read()
for pattern in patterns:
p = pattern
if p.startswith('WRITE_'):
p = p[6:]
+ if pattern in intpatterns:
+ idx = intpatterns.index(pattern)
+ isintfloat += 1 << idx
+ if pattern in floatpatterns:
+ idx = floatpatterns.index(pattern)
+ isintfloat &= ~(1 << (idx+4))
res.append('#define USING_REG_%s' % p)
if not res:
- return '#define USING_NOREGS'
+ return '#define USING_NOREGS\n' \
+ '#define REGS_PATTERN 0x0\n'
+ res.append('#define REGS_PATTERN 0x%x' % isintfloat)
return '\n'.join(res)
if __name__ == '__main__':
#ifndef USING_NOREGS
int voffs = 0;
int vlen = 1;
- sv_insn_t insn(bits, voffs);
+ // need to know if register is used as float or int.
+ // REGS_PATTERN is generated by id_regs.py (per opcode)
+ unsigned int floatintmap = REGS_PATTERN;
+ sv_insn_t insn(bits, voffs, floatintmap);
bool vectorop = false;
reg_t predicate = 0;
// identify which regs have had their CSR entries set as vectorised.
return false;
}
-uint64_t sv_insn_t::remap(uint64_t reg)
+uint64_t sv_insn_t::remap(uint64_t reg, bool isint)
{
return reg;
}
#include "sv.h"
#include "decode.h"
+#define REG_RD 0x1
+#define REG_RS1 0x2
+#define REG_RS2 0x4
+#define REG_RS3 0x8
+
class sv_insn_t: public insn_t
{
public:
- sv_insn_t(insn_bits_t bits, int& v) : insn_t(bits), voffs(v) {}
- uint64_t rd () { return remap(insn_t::rd()); }
- uint64_t rs1() { return remap(insn_t::rs1()); }
- uint64_t rs2() { return remap(insn_t::rs2()); }
- uint64_t rs3() { return remap(insn_t::rs3()); }
+ sv_insn_t(insn_bits_t bits, int& v, unsigned int f) :
+ insn_t(bits), voffs(v), fimap(f) {}
+ uint64_t rd () { return remap(insn_t::rd (), fimap & REG_RD); }
+ uint64_t rs1() { return remap(insn_t::rs1(), fimap & REG_RS1); }
+ uint64_t rs2() { return remap(insn_t::rs2(), fimap & REG_RS2); }
+ uint64_t rs3() { return remap(insn_t::rs3(), fimap & REG_RS3); }
private:
int &voffs;
+ unsigned int fimap;
// remaps the register through the lookup table.
// will need to take the current loop index/offset somehow
- uint64_t remap(uint64_t reg);
+ uint64_t remap(uint64_t reg, bool isint);
};
#endif