specop.isa (4696:459853ed322c) specop.isa (5163:f08b480df4c3)
1// Copyright (c) 2007 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// Redistribution and use of this software in source and binary forms,
5// with or without modification, are permitted provided that the
6// following conditions are met:
7//
8// The software must be used only for Non-Commercial Use which means any

--- 46 unchanged lines hidden (view full) ---

55
56//////////////////////////////////////////////////////////////////////////
57//
58// Fault Microop
59//
60//////////////////////////////////////////////////////////////////////////
61
62output header {{
1// Copyright (c) 2007 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// Redistribution and use of this software in source and binary forms,
5// with or without modification, are permitted provided that the
6// following conditions are met:
7//
8// The software must be used only for Non-Commercial Use which means any

--- 46 unchanged lines hidden (view full) ---

55
56//////////////////////////////////////////////////////////////////////////
57//
58// Fault Microop
59//
60//////////////////////////////////////////////////////////////////////////
61
62output header {{
63 class MicroFault : public X86ISA::X86MicroopBase
63 class MicroFaultBase : public X86ISA::X86MicroopBase
64 {
65 protected:
66 Fault fault;
64 {
65 protected:
66 Fault fault;
67 void buildMe();
67 uint8_t cc;
68
69 public:
68
69 public:
70 MicroFault(ExtMachInst _machInst, const char * instMnem,
70 MicroFaultBase(ExtMachInst _machInst, const char * instMnem,
71 bool isMicro, bool isDelayed, bool isFirst, bool isLast,
71 bool isMicro, bool isDelayed, bool isFirst, bool isLast,
72 Fault _fault);
72 Fault _fault, uint8_t _cc);
73
73
74 MicroFault(ExtMachInst _machInst, const char * instMnem,
75 Fault _fault);
74 MicroFaultBase(ExtMachInst _machInst, const char * instMnem,
75 Fault _fault, uint8_t _cc);
76
76
77 %(BasicExecDeclare)s
78
79 std::string generateDisassembly(Addr pc,
80 const SymbolTable *symtab) const;
81 };
82}};
83
77 std::string generateDisassembly(Addr pc,
78 const SymbolTable *symtab) const;
79 };
80}};
81
84output decoder {{
85 Fault MicroFault::execute(%(CPU_exec_context)s *xc,
82def template MicroFaultDeclare {{
83 class %(class_name)s : public %(base_class)s
84 {
85 private:
86 void buildMe();
87 public:
88 %(class_name)s(ExtMachInst _machInst, const char * instMnem,
89 bool isMicro, bool isDelayed, bool isFirst, bool isLast,
90 Fault _fault, uint8_t _cc);
91
92 %(class_name)s(ExtMachInst _machInst, const char * instMnem,
93 Fault _fault, uint8_t _cc);
94
95 %(BasicExecDeclare)s
96 };
97}};
98
99def template MicroFaultExecute {{
100 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
86 Trace::InstRecord *traceData) const
87 {
101 Trace::InstRecord *traceData) const
102 {
88 //Return the fault we were constructed with
89 return fault;
103 %(op_decl)s;
104 %(op_rd)s;
105 if (%(cond_test)s) {
106 //Return the fault we were constructed with
107 return fault;
108 } else {
109 return NoFault;
110 }
90 }
91}};
92
93output decoder {{
111 }
112}};
113
114output decoder {{
94 inline MicroFault::MicroFault(
95 ExtMachInst machInst, const char * instMnem, Fault _fault) :
115 inline MicroFaultBase::MicroFaultBase(
116 ExtMachInst machInst, const char * instMnem,
117 Fault _fault, uint8_t _cc) :
96 X86MicroopBase(machInst, "fault", instMnem,
118 X86MicroopBase(machInst, "fault", instMnem,
97 false, false, false, false, No_OpClass), fault(_fault)
119 false, false, false, false, No_OpClass),
120 fault(_fault), cc(_cc)
98 {
99 }
100
121 {
122 }
123
101 inline MicroFault::MicroFault(
124 inline MicroFaultBase::MicroFaultBase(
102 ExtMachInst machInst, const char * instMnem,
103 bool isMicro, bool isDelayed, bool isFirst, bool isLast,
125 ExtMachInst machInst, const char * instMnem,
126 bool isMicro, bool isDelayed, bool isFirst, bool isLast,
104 Fault _fault) :
127 Fault _fault, uint8_t _cc) :
105 X86MicroopBase(machInst, "fault", instMnem,
106 isMicro, isDelayed, isFirst, isLast, No_OpClass),
128 X86MicroopBase(machInst, "fault", instMnem,
129 isMicro, isDelayed, isFirst, isLast, No_OpClass),
107 fault(_fault)
130 fault(_fault), cc(_cc)
108 {
109 }
110}};
111
131 {
132 }
133}};
134
135def template MicroFaultConstructor {{
136
137 inline void %(class_name)s::buildMe()
138 {
139 %(constructor)s;
140 }
141
142 inline %(class_name)s::%(class_name)s(
143 ExtMachInst machInst, const char * instMnem,
144 Fault _fault, uint8_t _cc) :
145 %(base_class)s(machInst, instMnem, _fault, _cc)
146 {
147 buildMe();
148 }
149
150 inline %(class_name)s::%(class_name)s(
151 ExtMachInst machInst, const char * instMnem,
152 bool isMicro, bool isDelayed, bool isFirst, bool isLast,
153 Fault _fault, uint8_t _cc) :
154 %(base_class)s(machInst, instMnem,
155 isMicro, isDelayed, isFirst, isLast, _fault, _cc)
156 {
157 buildMe();
158 }
159}};
160
112output decoder {{
161output decoder {{
113 std::string MicroFault::generateDisassembly(Addr pc,
162 std::string MicroFaultBase::generateDisassembly(Addr pc,
114 const SymbolTable *symtab) const
115 {
116 std::stringstream response;
117
118 printMnemonic(response, instMnem, mnemonic);
119 if(fault)
120 response << fault->name();
121 else
122 response << "No Fault";
123
124 return response.str();
125 }
126}};
127
128let {{
129 class Fault(X86Microop):
163 const SymbolTable *symtab) const
164 {
165 std::stringstream response;
166
167 printMnemonic(response, instMnem, mnemonic);
168 if(fault)
169 response << fault->name();
170 else
171 response << "No Fault";
172
173 return response.str();
174 }
175}};
176
177let {{
178 class Fault(X86Microop):
130 def __init__(self, fault):
179 className = "MicroFault"
180 def __init__(self, fault, flags=None):
131 self.fault = fault
181 self.fault = fault
182 if flags:
183 if not isinstance(flags, (list, tuple)):
184 raise Exception, "flags must be a list or tuple of flags"
185 self.cond = " | ".join(flags)
186 self.className += "Flags"
187 else:
188 self.cond = "0"
132
133 def getAllocator(self, *microFlags):
189
190 def getAllocator(self, *microFlags):
134 allocator = '''new MicroFault(machInst, mnemonic
135 %(flags)s, %(fault)s)''' % {
191 allocator = '''new %(class_name)s(machInst, mnemonic
192 %(flags)s, %(fault)s, %(cc)s)''' % {
193 "class_name" : self.className,
136 "flags" : self.microFlagsText(microFlags),
194 "flags" : self.microFlagsText(microFlags),
137 "fault" : self.fault}
195 "fault" : self.fault,
196 "cc" : self.cond}
138 return allocator
197 return allocator
198
199 iop = InstObjParams("fault", "MicroFault", "MicroFaultBase",
200 {"code": "",
201 "cond_test": "checkCondition(ccFlagBits, cc)"})
202 exec_output = MicroFaultExecute.subst(iop)
203 header_output = MicroFaultDeclare.subst(iop)
204 decoder_output = MicroFaultConstructor.subst(iop)
205 iop = InstObjParams("fault", "MicroFaultFlags", "MicroFaultBase",
206 {"code": "",
207 "cond_test": "true"})
208 exec_output += MicroFaultExecute.subst(iop)
209 header_output += MicroFaultDeclare.subst(iop)
210 decoder_output += MicroFaultConstructor.subst(iop)
139 microopClasses["fault"] = Fault
140}};
211 microopClasses["fault"] = Fault
212}};