summaryrefslogtreecommitdiff
path: root/arch/mips/isa/base.isa
blob: 846d161b9e774427cd58e3f4397c94ffc1dc9e4a (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// -*- mode:c++ -*-

////////////////////////////////////////////////////////////////////
//
// Base class for MIPS instructions, and some support functions
//

//Outputs to decoder.hh
output header {{
        /**
         * Base class for all MIPS static instructions.
         */
        class MipsStaticInst : public StaticInst<MIPSISA>
        {
        protected:

                // Constructor.
                MipsStaticInst(const char *mnem, MachInst _machInst, OpClass __opClass)
                    : StaticInst<MIPSISA>(mnem, _machInst, __opClass)
                {
                }

                std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const;
        };

}};

//Ouputs to decoder.cc
output decoder {{

        std::string MipsStaticInst::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();
        }

}};