52a53,88
> //This class is for instructions that explicitly read control
> //registers. It provides a special generateDisassembly function.
> class RdPriv : public Priv
> {
> protected:
> //Constructor
> RdPriv(const char *mnem, ExtMachInst _machInst,
> OpClass __opClass, char const * _regName) :
> Priv(mnem, _machInst, __opClass), regName(_regName)
> {
> }
>
> std::string generateDisassembly(Addr pc,
> const SymbolTable *symtab) const;
>
> char const * regName;
> };
>
> //This class is for instructions that explicitly write control
> //registers. It provides a special generateDisassembly function.
> class WrPriv : public Priv
> {
> protected:
> //Constructor
> WrPriv(const char *mnem, ExtMachInst _machInst,
> OpClass __opClass, char const * _regName) :
> Priv(mnem, _machInst, __opClass), regName(_regName)
> {
> }
>
> std::string generateDisassembly(Addr pc,
> const SymbolTable *symtab) const;
>
> char const * regName;
> };
>
68a105,121
> //This class is for instructions that explicitly write control
> //registers. It provides a special generateDisassembly function.
> class WrPrivImm : public PrivImm
> {
> protected:
> //Constructor
> WrPrivImm(const char *mnem, ExtMachInst _machInst,
> OpClass __opClass, char const * _regName) :
> PrivImm(mnem, _machInst, __opClass), regName(_regName)
> {
> }
>
> std::string generateDisassembly(Addr pc,
> const SymbolTable *symtab) const;
>
> char const * regName;
> };
80a134,176
>
> std::string RdPriv::generateDisassembly(Addr pc,
> const SymbolTable *symtab) const
> {
> std::stringstream response;
>
> printMnemonic(response, mnemonic);
>
> ccprintf(response, " %%%s, ", regName);
> printDestReg(response, 0);
>
> return response.str();
> }
>
> std::string WrPriv::generateDisassembly(Addr pc,
> const SymbolTable *symtab) const
> {
> std::stringstream response;
>
> printMnemonic(response, mnemonic);
>
> ccprintf(response, " ");
> printSrcReg(response, 0);
> ccprintf(response, ", ");
> printSrcReg(response, 1);
> ccprintf(response, ", %%%s", regName);
>
> return response.str();
> }
>
> std::string WrPrivImm::generateDisassembly(Addr pc,
> const SymbolTable *symtab) const
> {
> std::stringstream response;
>
> printMnemonic(response, mnemonic);
>
> ccprintf(response, " ");
> printSrcReg(response, 0);
> ccprintf(response, ", 0x%x, %%%s", imm, regName);
>
> return response.str();
> }
82a179,187
> def template ControlRegConstructor {{
> inline %(class_name)s::%(class_name)s(ExtMachInst machInst)
> : %(base_class)s("%(mnemonic)s", machInst,
> %(op_class)s, "%(reg_name)s")
> {
> %(constructor)s;
> }
> }};
>
105,106c210,228
< iop = InstObjParams(name, Name, 'Priv', code,
< opt_flags, {"check": checkCode})
---
> #If these are rd, rdpr, rdhpr, wr, wrpr, or wrhpr instructions,
> #cut any other info out of the mnemonic. Also pick a different
> #base class.
> regBase = 'Priv'
> regName = ''
> for mnem in ["rdhpr", "rdpr", "rd"]:
> if name.startswith(mnem):
> regName = name[len(mnem):]
> name = mnem
> regBase = 'RdPriv'
> break
> for mnem in ["wrhpr", "wrpr", "wr"]:
> if name.startswith(mnem):
> regName = name[len(mnem):]
> name = mnem
> regBase = 'WrPriv'
> break
> iop = InstObjParams(name, Name, regBase, code,
> opt_flags, {"check": checkCode, "reg_name": regName})
108c230,233
< decoder_output = BasicConstructor.subst(iop)
---
> if regName == '':
> decoder_output = BasicConstructor.subst(iop)
> else:
> decoder_output = ControlRegConstructor.subst(iop)
111,112c236,237
< imm_iop = InstObjParams(name, Name + 'Imm', 'PrivImm',
< immCode, opt_flags, {"check": checkCode})
---
> imm_iop = InstObjParams(name, Name + 'Imm', regBase + 'Imm',
> immCode, opt_flags, {"check": checkCode, "reg_name": regName})
114c239,242
< decoder_output += BasicConstructor.subst(imm_iop)
---
> if regName == '':
> decoder_output += BasicConstructor.subst(imm_iop)
> else:
> decoder_output += ControlRegConstructor.subst(imm_iop)