7d9b93d825
arch/sparc/isa/formats.isa: Changed the file extensions to .isa again. arch/sparc/isa/main.isa: Changed the file extensions to .isa again --HG-- rename : arch/sparc/isa_desc/base.h => arch/sparc/isa/base.isa rename : arch/sparc/isa_desc/bitfields.h => arch/sparc/isa/bitfields.isa rename : arch/sparc/isa_desc/decoder.h => arch/sparc/isa/decoder.isa rename : arch/sparc/isa_desc/formats.h => arch/sparc/isa/formats.isa rename : arch/sparc/isa_desc/formats/basic.format => arch/sparc/isa/formats/basic.isa rename : arch/sparc/isa_desc/formats/branch.format => arch/sparc/isa/formats/branch.isa rename : arch/sparc/isa_desc/formats/integerop.format => arch/sparc/isa/formats/integerop.isa rename : arch/sparc/isa_desc/formats/mem.format => arch/sparc/isa/formats/mem.isa rename : arch/sparc/isa_desc/formats/noop.format => arch/sparc/isa/formats/noop.isa rename : arch/sparc/isa_desc/formats/trap.format => arch/sparc/isa/formats/trap.isa rename : arch/sparc/isa_desc/includes.h => arch/sparc/isa/includes.isa rename : arch/sparc/isa_desc/isa_desc => arch/sparc/isa/main.isa rename : arch/sparc/isa_desc/operands.h => arch/sparc/isa/operands.isa extra : convert_revision : acb087e81d06ca5d67fe9b402423d7930f6ae798
82 lines
2.9 KiB
Text
82 lines
2.9 KiB
Text
////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Base class for sparc instructions, and some support functions
|
|
//
|
|
|
|
output header {{
|
|
/**
|
|
* Base class for all SPARC static instructions.
|
|
*/
|
|
class SparcStaticInst : public StaticInst<SPARCISA>
|
|
{
|
|
protected:
|
|
|
|
// Constructor.
|
|
SparcStaticInst(const char *mnem, MachInst _machInst, OpClass __opClass)
|
|
: StaticInst<SPARCISA>(mnem, _machInst, __opClass)
|
|
{
|
|
}
|
|
|
|
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
|
|
};
|
|
|
|
bool passesCondition(struct {uint8_t c:1; uint8_t v:1; uint8_t z:1; uint8_t n:1} codes, uint8_t condition);
|
|
}};
|
|
|
|
output decoder {{
|
|
|
|
std::string SparcStaticInst::generateDisassembly(Addr pc, const SymbolTable *symtab) const
|
|
{
|
|
std::stringstream ss;
|
|
|
|
ccprintf(ss, "%-10s ", mnemonic);
|
|
|
|
// just print the first two source regs... if there's
|
|
// a third one, it's a read-modify-write dest (Rc),
|
|
// e.g. for CMOVxx
|
|
if(_numSrcRegs > 0)
|
|
{
|
|
printReg(ss, _srcRegIdx[0]);
|
|
}
|
|
if(_numSrcRegs > 1)
|
|
{
|
|
ss << ",";
|
|
printReg(ss, _srcRegIdx[1]);
|
|
}
|
|
|
|
// just print the first dest... if there's a second one,
|
|
// it's generally implicit
|
|
if(_numDestRegs > 0)
|
|
{
|
|
if(_numSrcRegs > 0)
|
|
ss << ",";
|
|
printReg(ss, _destRegIdx[0]);
|
|
}
|
|
|
|
return ss.str();
|
|
}
|
|
|
|
bool passesCondition(struct {uint8_t c:1; uint8_t v:1; uint8_t z:1; uint8_t n:1} codes, uint8_t condition)
|
|
{
|
|
switch(condition)
|
|
{
|
|
case 0b1000: return true;
|
|
case 0b0000: return false;
|
|
case 0b1001: return !codes.z;
|
|
case 0b0001: return codes.z;
|
|
case 0b1010: return !(codes.z | (codes.n ^ codes.v));
|
|
case 0b0010: return codes.z | (codes.n ^ codes.v);
|
|
case 0b1011: return !(codes.n ^ codes.v);
|
|
case 0b0011: return (codes.n ^ codes.v);
|
|
case 0b1100: return !(codes.c | codes.z);
|
|
case 0b0100: return (codes.c | codes.z);
|
|
case 0b1101: return !codes.c;
|
|
case 0b0101: return codes.c;
|
|
case 0b1110: return !codes.n;
|
|
case 0b0110: return codes.n;
|
|
case 0b1111: return !codes.v;
|
|
case 0b0111: return codes.v;
|
|
}
|
|
}
|
|
}};
|
|
|