From 9f4ebf915608403715bfb349a8871d4316e4a0c9 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 10 Apr 2007 17:25:15 +0000 Subject: [PATCH] Reworked x86 a bit --HG-- extra : convert_revision : def1a30e54b59c718c451a631a1be6f8e787e843 --- src/arch/x86/isa/formats/multi.isa | 4 +-- src/arch/x86/isa/macroop.isa | 51 +++++++++++++++++++++++------- src/arch/x86/isa/microasm.isa | 21 ++++++------ src/arch/x86/isa/microops/base.isa | 49 +++++++++++++++++++--------- src/arch/x86/isa/specialize.isa | 38 +++++++++------------- 5 files changed, 102 insertions(+), 61 deletions(-) diff --git a/src/arch/x86/isa/formats/multi.isa b/src/arch/x86/isa/formats/multi.isa index 7ad5ecd48..8f91c249c 100644 --- a/src/arch/x86/isa/formats/multi.isa +++ b/src/arch/x86/isa/formats/multi.isa @@ -72,7 +72,7 @@ def format Inst(*opTypeSet) {{ (header_output, decoder_output, decode_block, - exec_output) = doInst(name, Name, list(opTypeSet)) + exce_output) = doInst(name, Name, list(opTypeSet)).makeList() }}; def format MultiInst(switchVal, *opTypeSets) {{ @@ -82,5 +82,5 @@ def format MultiInst(switchVal, *opTypeSets) {{ (header_output, decoder_output, decode_block, - exec_output) = doSplitDecode(name, Name, doInst, switchVal, switcher) + exec_output) = doSplitDecode(name, Name, doInst, switchVal, switcher).makeList() }}; diff --git a/src/arch/x86/isa/macroop.isa b/src/arch/x86/isa/macroop.isa index 7d41a2dea..663ec7aee 100644 --- a/src/arch/x86/isa/macroop.isa +++ b/src/arch/x86/isa/macroop.isa @@ -55,26 +55,30 @@ // // Authors: Gabe Black +////////////////////////////////////////////////////////////////////////////// +// +// Architecture independent +// + // Execute method for macroops. def template MacroExecPanic {{ Fault execute(%(CPU_exec_context)s *, Trace::InstRecord *) const { panic("Tried to execute macroop directly!"); - M5_DUMMY_RETURN + return NoFault; } }}; output header {{ - // Base class for most macroops, except ones that need to commit as - // they go. - class X86MacroInst : public StaticInst + // Base class for macroops + class MacroOp : public StaticInst { protected: const uint32_t numMicroOps; //Constructor. - X86MacroInst(const char *mnem, ExtMachInst _machInst, + MacroOp(const char *mnem, ExtMachInst _machInst, uint32_t _numMicroOps) : StaticInst(mnem, _machInst, No_OpClass), numMicroOps(_numMicroOps) @@ -84,7 +88,7 @@ output header {{ flags[IsMacroOp] = true; } - ~X86MacroInst() + ~MacroOp() { delete [] microOps; } @@ -97,10 +101,29 @@ output header {{ return microOps[microPC]; } + std::string generateDisassembly(Addr pc, + const SymbolTable *symtab) const + { + return mnemonic; + } + %(MacroExecPanic)s }; }}; +// Basic instruction class declaration template. +def template MacroDeclare {{ + /** + * Static instruction class for "%(mnemonic)s". + */ + class %(class_name)s : public %(base_class)s + { + public: + // Constructor. + %(class_name)s(ExtMachInst machInst); + }; +}}; + // Basic instruction class constructor template. def template MacroConstructor {{ inline %(class_name)s::%(class_name)s(ExtMachInst machInst) @@ -113,23 +136,27 @@ def template MacroConstructor {{ } }}; +////////////////////////////////////////////////////////////////////////////// +// +// X86 specific +// + let {{ def genMacroOp(name, Name, opSeq): - baseClass = 'X86MacroInst' - numMicroOps = len(opSeq.ops) + numMicroOps = len(opSeq) allocMicroOps = '' micropc = 0 - for op in opSeq.ops: + for op in opSeq: allocMicroOps += \ "microOps[%d] = %s;\n" % \ - (micropc, op.getAllocator(True, op.delayed, + (micropc, op.getAllocator('"' + name + '"', True, False, #op.delayed, micropc == 0, micropc == numMicroOps - 1)) micropc += 1 - iop = InstObjParams(name, Name, baseClass, + iop = InstObjParams(name, Name, 'MacroOp', {'code' : '', 'num_micro_ops' : numMicroOps, 'alloc_micro_ops' : allocMicroOps}) - header_output = BasicDeclare.subst(iop) + header_output = MacroDeclare.subst(iop) decoder_output = MacroConstructor.subst(iop) decode_block = BasicDecode.subst(iop) exec_output = '' diff --git a/src/arch/x86/isa/microasm.isa b/src/arch/x86/isa/microasm.isa index 23567aae9..9d21b6bcc 100644 --- a/src/arch/x86/isa/microasm.isa +++ b/src/arch/x86/isa/microasm.isa @@ -85,7 +85,7 @@ let {{ text += ", false" return text - def getAllocator(self, *microFlags): + def getAllocator(self, mnemonic, *microFlags): args = '' signature = "<" emptySig = True @@ -104,7 +104,7 @@ let {{ else: raise Exception, "Unrecognized operand type." signature += ">" - return 'new %s%s(machInst%s%s)' % (self.className, signature, self.microFlagsText(microFlags), args) + return 'new %s%s(machInst, %s%s%s)' % (self.className, signature, mnemonic, self.microFlagsText(microFlags), args) }}; let{{ @@ -123,7 +123,7 @@ let{{ # the beginning of the line, so the previous component is stripped # before continuing. labelRe = re.compile(r'^[ \t]*(?P