72c72
< * Base class for branches with 19 bit displacements.
---
> * Base class for branches with n bit displacements.
74c74,75
< class Branch19 : public BranchDisp
---
> template<int bits>
> class BranchNBits : public BranchDisp
78c79
< Branch19(const char *mnem, MachInst _machInst,
---
> BranchNBits(const char *mnem, MachInst _machInst,
82c83
< disp = sign_ext(DISP19 << 2, 21);
---
> disp = sign_ext(_machInst << 2, bits + 2);
87,116d87
< * Base class for branches with 22 bit displacements.
< */
< class Branch22 : public BranchDisp
< {
< protected:
< // Constructor
< Branch22(const char *mnem, MachInst _machInst,
< OpClass __opClass) :
< BranchDisp(mnem, _machInst, __opClass)
< {
< disp = sign_ext(DISP22 << 2, 24);
< }
< };
<
< /**
< * Base class for branches with 30 bit displacements.
< */
< class Branch30 : public BranchDisp
< {
< protected:
< // Constructor
< Branch30(const char *mnem, MachInst _machInst,
< OpClass __opClass) :
< BranchDisp(mnem, _machInst, __opClass)
< {
< disp = sign_ext(DISP30 << 2, 32);
< }
< };
<
< /**
151a123,129
>
> template class BranchNBits<19>;
>
> template class BranchNBits<22>;
>
> template class BranchNBits<30>;
>
158,163c136,137
<
< if (_numSrcRegs > 0)
< {
< printReg(response, _srcRegIdx[0]);
< for(int x = 1; x < _numSrcRegs; x++)
< {
---
> printRegArray(response, _srcRegIdx, _numSrcRegs);
> if(_numDestRegs && _numSrcRegs)
165,167c139
< printReg(response, _srcRegIdx[x]);
< }
< }
---
> printDestReg(response, 0);
169,175d140
< if (_numDestRegs > 0)
< {
< if(_numSrcRegs > 0)
< response << ", ";
< printReg(response, _destRegIdx[0]);
< }
<
185,195c150
<
< if (_numSrcRegs > 0)
< {
< printReg(response, _srcRegIdx[0]);
< for(int x = 1; x < _numSrcRegs; x++)
< {
< response << ", ";
< printReg(response, _srcRegIdx[x]);
< }
< }
<
---
> printRegArray(response, _srcRegIdx, _numSrcRegs);
198d152
<
200d153
<
202d154
< {
204,205c156
< printReg(response, _destRegIdx[0]);
< }
---
> printDestReg(response, 0);
295c246
< def format Branch19(code, *opt_flags) {{
---
> def format BranchN(bits, code, *opt_flags) {{
298c249
< iop = InstObjParams(name, Name, 'Branch19', codeBlk, opt_flags)
---
> iop = InstObjParams(name, Name, "BranchNBits<%d>" % bits, codeBlk, opt_flags)
306,327d256
< def format Branch22(code, *opt_flags) {{
< code = re.sub(r'handle_annul', handle_annul, code)
< codeBlk = CodeBlock(code)
< iop = InstObjParams(name, Name, 'Branch22', codeBlk, opt_flags)
< header_output = BasicDeclare.subst(iop)
< decoder_output = BasicConstructor.subst(iop)
< exec_output = BranchExecute.subst(iop)
< decode_block = BasicDecode.subst(iop)
< }};
<
< // Primary format for branch instructions:
< def format Branch30(code, *opt_flags) {{
< code = re.sub(r'handle_annul', handle_annul, code)
< codeBlk = CodeBlock(code)
< iop = InstObjParams(name, Name, 'Branch30', codeBlk, opt_flags)
< header_output = BasicDeclare.subst(iop)
< decoder_output = BasicConstructor.subst(iop)
< exec_output = BranchExecute.subst(iop)
< decode_block = BasicDecode.subst(iop)
< }};
<
< // Primary format for branch instructions: