summaryrefslogtreecommitdiff
path: root/src/arch/x86/isa/microops/base.isa
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/x86/isa/microops/base.isa')
-rw-r--r--src/arch/x86/isa/microops/base.isa140
1 files changed, 41 insertions, 99 deletions
diff --git a/src/arch/x86/isa/microops/base.isa b/src/arch/x86/isa/microops/base.isa
index f0aab7872..79ac4493a 100644
--- a/src/arch/x86/isa/microops/base.isa
+++ b/src/arch/x86/isa/microops/base.isa
@@ -55,25 +55,23 @@
//
// Authors: Gabe Black
-//The operand types a microop template can be specialized with
-output header {{
- enum OperandType {
- RegisterOperand,
- ImmediateOperand
- };
+let {{
+ # This will be populated with mappings between microop mnemonics and
+ # the classes that represent them.
+ microopClasses = {}
}};
//A class which is the base of all x86 micro ops. It provides a function to
//set necessary flags appropriately.
output header {{
- class X86MicroOpBase : public X86StaticInst
+ class X86MicroopBase : public X86StaticInst
{
protected:
const char * instMnem;
uint8_t opSize;
uint8_t addrSize;
- X86MicroOpBase(ExtMachInst _machInst,
+ X86MicroopBase(ExtMachInst _machInst,
const char *mnem, const char *_instMnem,
bool isMicro, bool isDelayed,
bool isFirst, bool isLast,
@@ -81,10 +79,10 @@ output header {{
X86StaticInst(mnem, _machInst, __opClass),
instMnem(_instMnem)
{
- flags[IsMicroOp] = isMicro;
+ flags[IsMicroop] = isMicro;
flags[IsDelayedCommit] = isDelayed;
- flags[IsFirstMicroOp] = isFirst;
- flags[IsLastMicroOp] = isLast;
+ flags[IsFirstMicroop] = isFirst;
+ flags[IsLastMicroop] = isLast;
}
std::string generateDisassembly(Addr pc,
@@ -99,96 +97,40 @@ output header {{
};
}};
-// This sets up a class which is templated on the type of
-// arguments a particular flavor of a microcode instruction
-// can accept. It's parameters are specialized to create polymorphic
-// behavior in microops.
-def template BaseMicroOpTemplateDeclare {{
- template%(signature)s
- class %(class_name)s;
-}};
-
-let {{
- def buildBaseMicroOpTemplate(Name, numParams):
- assert(numParams > 0)
- signature = "<"
- signature += "int SignatureOperandTypeSpecifier0"
- for count in xrange(1,numParams):
- signature += \
- ", int SingatureOperandTypeSpecifier%d" % count
- signature += ">"
- subs = {"signature" : signature, "class_name" : Name}
- return BaseMicroOpTemplateDeclare.subst(subs)
-}};
+//////////////////////////////////////////////////////////////////////////
+//
+// Base class for the python representation of x86 microops
+//
+//////////////////////////////////////////////////////////////////////////
let {{
- def buildMicroOpTemplateDict(*params):
- signature = "<"
- if len(params):
- signature += params[0]
- if len(params) > 1:
- for param in params[1:]:
- signature += ", %s" % param
- signature += ">"
- subs = {"param_dec" : "", "param_arg_dec" : "",
- "param_init" : "", "signature" : signature}
- for count in xrange(len(params)):
- subs["param_dec"] += "uint64_t param%d;\n" % count
- subs["param_arg_dec"] += ", uint64_t _param%d" % count
- subs["param_init"] += ", param%d(_param%d)" % (count, count)
- return subs
-}};
-
-// A tmeplate for building a specialized version of the microcode
-// instruction which specifies which arguments it wants
-def template MicroOpDeclare {{
- template<>
- class %(class_name)s%(signature)s : public X86MicroOpBase
- {
- protected:
- %(param_dec)s
- void buildMe();
-
- public:
- %(class_name)s(ExtMachInst _machInst,
- const char * instMnem,
- bool isMicro, bool isDelayed,
- bool isFirst, bool isLast
- %(param_arg_dec)s);
-
- %(class_name)s(ExtMachInst _machInst,
- const char * instMnem
- %(param_arg_dec)s);
-
- %(BasicExecDeclare)s
- };
+ class X86Microop(object):
+ def __init__(self, name):
+ self.name = name
+
+ # This converts a python bool into a C++ bool
+ def cppBool(self, val):
+ if val:
+ return "true"
+ else:
+ return "false"
+
+ # This converts a list of python bools into
+ # a comma seperated list of C++ bools.
+ def microFlagsText(self, vals):
+ text = ""
+ for val in vals:
+ text += ", %s" % self.cppBool(val)
+ return text
+
+ def getAllocator(self, mnemonic, *microFlags):
+ return 'new %s(machInst, %s)' % (self.className, mnemonic, self.microFlagsText(microFlags))
}};
-def template MicroOpConstructor {{
-
- inline void %(class_name)s%(signature)s::buildMe()
- {
- %(constructor)s;
- }
-
- inline %(class_name)s%(signature)s::%(class_name)s(
- ExtMachInst machInst, const char * instMnem
- %(param_arg_dec)s) :
- %(base_class)s(machInst, "%(mnemonic)s", instMnem,
- false, false, false, false, %(op_class)s)
- %(param_init)s
- {
- buildMe();
- }
+//////////////////////////////////////////////////////////////////////////
+//
+// FpOp Microop templates
+//
+//////////////////////////////////////////////////////////////////////////
- inline %(class_name)s%(signature)s::%(class_name)s(
- ExtMachInst machInst, const char * instMnem,
- bool isMicro, bool isDelayed, bool isFirst, bool isLast
- %(param_arg_dec)s)
- : %(base_class)s(machInst, "%(mnemonic)s", instMnem,
- isMicro, isDelayed, isFirst, isLast, %(op_class)s)
- %(param_init)s
- {
- buildMe();
- }
-}};
+//TODO Actually write an fp microop base class.