};
+/**
+ * Class for integer compare operations.
+ */
+class IntCompOp : public IntOp
+{
+ protected:
+
+ uint32_t length;
+ uint32_t field;
+
+ /// Constructor
+ IntCompOp(const char *mnem, MachInst _machInst, OpClass __opClass)
+ : IntOp(mnem, _machInst, __opClass),
+ length(machInst.l),
+ field(machInst.bf)
+ {
+ }
+};
+
+
+/**
+ * Class for integer immediate compare operations.
+ */
+class IntImmCompOp : public IntCompOp
+{
+ protected:
+
+ int32_t simm;
+
+ /// Constructor
+ IntImmCompOp(const char *mnem, MachInst _machInst, OpClass __opClass)
+ : IntCompOp(mnem, _machInst, __opClass),
+ simm((int16_t)machInst.si)
+ {
+ }
+};
+
+
+/**
+ * Class for integer immediate compare logical operations.
+ */
+class IntImmCompLogicOp : public IntCompOp
+{
+ protected:
+
+ uint32_t uimm;
+
+ /// Constructor
+ IntImmCompLogicOp(const char *mnem, MachInst _machInst, OpClass __opClass)
+ : IntCompOp(mnem, _machInst, __opClass),
+ uimm(machInst.ui)
+ {
+ }
+};
+
+
/**
* Class for integer operations with a shift.
*/
}
}
- format IntImmOp {
- 10: cmpli({{
- Xer xer = XER;
- uint32_t cr = makeCRField(Ra, (uint32_t)uimm, xer.so);
- CR = insertCRField(CR, BF, cr);
- }});
+ format IntImmCompOp {
11: cmpi({{
- Xer xer = XER;
- uint32_t cr = makeCRField(Ra_sw, (int32_t)imm, xer.so);
- CR = insertCRField(CR, BF, cr);
+ cr = makeCRField(Ra_sw, (int32_t)simm, xer.so);
}});
}
+ format IntImmCompLogicOp {
+ 10: cmpli({{
+ cr = makeCRField(Ra, (uint32_t)uimm, xer.so);
+ }});
+ }
+
format IntImmLogicOp {
24: ori({{ Ra = Rs | uimm; }});
25: oris({{ Ra = Rs | (uimm << 16); }});
}});
}
- format IntOp {
+ format IntCompOp {
0: cmp({{
- Xer xer = XER;
- uint32_t cr = makeCRField(Ra_sw, Rb_sw, xer.so);
- CR = insertCRField(CR, BF, cr);
+ cr = makeCRField(Ra_sw, Rb_sw, xer.so);
}});
32: cmpl({{
- Xer xer = XER;
- uint32_t cr = makeCRField(Ra, Rb, xer.so);
- CR = insertCRField(CR, BF, cr);
+ cr = makeCRField(Ra, Rb, xer.so);
}});
}
}};
+// Integer compare instructions.
+def format IntCompOp(code, inst_flags = []) {{
+
+ # Add code to setup variables
+ code = 'M5_VAR_USED uint32_t cr = 0;\n' + code
+ code += 'CR = insertCRField(CR, field, cr);\n'
+
+ # Add code to access XER
+ code = readXERCode + code
+
+ # Generate the class
+ (header_output, decoder_output, decode_block, exec_output) = \
+ GenAluOp(name, Name, 'IntCompOp', code, inst_flags, BasicDecode,
+ BasicConstructor)
+}};
+
+
+// Integer immediate compare instructions.
+def format IntImmCompOp(code, inst_flags = []) {{
+
+ # Add code to setup variables
+ code = 'M5_VAR_USED uint32_t cr = 0;\n' + code
+ code += 'CR = insertCRField(CR, field, cr);\n'
+
+ # Add code to access XER
+ code = readXERCode + code
+
+ # Generate the class
+ (header_output, decoder_output, decode_block, exec_output) = \
+ GenAluOp(name, Name, 'IntImmCompOp', code, inst_flags, BasicDecode,
+ BasicConstructor)
+}};
+
+
+// Integer immediate compare logical instructions.
+def format IntImmCompLogicOp(code, inst_flags = []) {{
+
+ # Add code to setup variables
+ code = 'M5_VAR_USED uint32_t cr = 0;\n' + code
+ code += 'CR = insertCRField(CR, field, cr);\n'
+
+ # Add code to access XER
+ code = readXERCode + code
+
+ # Generate the class
+ (header_output, decoder_output, decode_block, exec_output) = \
+ GenAluOp(name, Name, 'IntImmCompLogicOp', code, inst_flags,
+ BasicDecode, BasicConstructor)
+}};
+
+
// Integer instructions that perform logic operations. The result is
// always written into Ra. All instructions have 2 versions depending on
// whether the Rc bit is set to compute the CR0 code. This is determined