From 41bc0fc5b27b97f6235e5cd3fe089ff43b588bef Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 4 Jun 2007 15:59:20 +0000 Subject: [PATCH] Reworking x86's microcode system. This is a work in progress, and X86 doesn't compile. src/arch/x86/isa/decoder/one_byte_opcodes.isa: src/arch/x86/isa/macroop.isa: src/arch/x86/isa/main.isa: src/arch/x86/isa/microasm.isa: src/arch/x86/isa/microops/base.isa: src/arch/x86/isa/microops/microops.isa: src/arch/x86/isa/operands.isa: src/arch/x86/isa/microops/regop.isa: src/arch/x86/isa/microops/specop.isa: Reworking x86's microcode system --HG-- extra : convert_revision : cab66be59ed758b192226af17eddd5a86aa190f3 --- src/arch/x86/isa/decoder/one_byte_opcodes.isa | 22 +- src/arch/x86/isa/macroop.isa | 3 +- src/arch/x86/isa/main.isa | 4 - src/arch/x86/isa/microasm.isa | 164 +-------- src/arch/x86/isa/microops/base.isa | 202 +++++++---- src/arch/x86/isa/microops/microops.isa | 8 +- src/arch/x86/isa/microops/regop.isa | 328 ++++++++++++++++++ src/arch/x86/isa/microops/specop.isa | 125 +++++++ src/arch/x86/isa/operands.isa | 3 + 9 files changed, 623 insertions(+), 236 deletions(-) create mode 100644 src/arch/x86/isa/microops/regop.isa create mode 100644 src/arch/x86/isa/microops/specop.isa diff --git a/src/arch/x86/isa/decoder/one_byte_opcodes.isa b/src/arch/x86/isa/decoder/one_byte_opcodes.isa index 12f3c5f96..0ee9c53c6 100644 --- a/src/arch/x86/isa/decoder/one_byte_opcodes.isa +++ b/src/arch/x86/isa/decoder/one_byte_opcodes.isa @@ -61,12 +61,11 @@ 0x1: decode OPCODE_OP_TOP5 { format WarnUnimpl { 0x00: decode OPCODE_OP_BOTTOM3 { - 0x4: Inst::ADD(rAl,Ib); - 0x5: Inst::ADD(rAx,Iz); + 0x4: ADD(); + 0x5: ADD(); 0x6: push_ES(); 0x7: pop_ES(); - default: MultiInst::ADD(OPCODE_OP_BOTTOM3, - [Eb,Gb],[Ev,Gv],[Gb,Eb],[Gv,Ev]); + default: ADD(); } 0x01: decode OPCODE_OP_BOTTOM3 { 0x0: or_Eb_Gb(); @@ -123,13 +122,12 @@ 0x7: das(); } 0x06: decode OPCODE_OP_BOTTOM3 { - 0x4: Inst::XOR(rAl,Ib); - 0x5: Inst::XOR(rAx,Iz); + 0x4: Inst::XOR(ALIb); + 0x5: Inst::XOR(rAX,Iz); 0x6: M5InternalError::error( {{"Tried to execute the SS segment override prefix!"}}); 0x7: aaa(); - default: MultiInst::XOR(OPCODE_OP_BOTTOM3, - [Eb,Gb],[Ev,Gv],[Gb,Eb],[Gv,Ev]); + default: MultiInst::XOR(EbGb, EvGv, GbEb, GvEv); } 0x07: decode OPCODE_OP_BOTTOM3 { 0x0: cmp_Eb_Gb(); @@ -237,10 +235,10 @@ 0x7: xchg_Ev_Gv(); } 0x11: decode OPCODE_OP_BOTTOM3 { - 0x0: Inst::MOV(Eb, Gb); - 0x1: Inst::MOV(Ev, Gv); - 0x2: Inst::MOV(Gb, Eb); - 0x3: Inst::MOV(Gv, Ev); + 0x0: MOV(); + 0x1: MOV(); + 0x2: MOV(); + 0x3: MOV(); 0x4: mov_MwRv_Sw(); //What to do with this one? 0x5: lea_Gv_M(); 0x6: mov_Sw_MwRv(); diff --git a/src/arch/x86/isa/macroop.isa b/src/arch/x86/isa/macroop.isa index 663ec7aee..ba21c41a7 100644 --- a/src/arch/x86/isa/macroop.isa +++ b/src/arch/x86/isa/macroop.isa @@ -149,7 +149,8 @@ let {{ for op in opSeq: allocMicroOps += \ "microOps[%d] = %s;\n" % \ - (micropc, op.getAllocator('"' + name + '"', True, False, #op.delayed, + (micropc, op.getAllocator('"' + name + '"', True, False, + #op.delayed, micropc == 0, micropc == numMicroOps - 1)) micropc += 1 diff --git a/src/arch/x86/isa/main.isa b/src/arch/x86/isa/main.isa index 063d7125d..a9f01d3e0 100644 --- a/src/arch/x86/isa/main.isa +++ b/src/arch/x86/isa/main.isa @@ -81,10 +81,6 @@ namespace X86ISA; //Include code to build macroops. ##include "macroop.isa" -//Include the simple microcode assembler. This will hopefully stay -//unspecialized for x86 and can later be made available to other ISAs. -##include "microasm.isa" - //////////////////////////////////////////////////////////////////// // // X86 only infrastructure code. diff --git a/src/arch/x86/isa/microasm.isa b/src/arch/x86/isa/microasm.isa index 9d21b6bcc..50a0b10e7 100644 --- a/src/arch/x86/isa/microasm.isa +++ b/src/arch/x86/isa/microasm.isa @@ -57,22 +57,24 @@ //////////////////////////////////////////////////////////////////// // -// The microcode assembler +// Microcode assembler specialization for x86 // let {{ - # These are used when setting up microops so that they can specialize their - # base class template properly. - RegOpType = "RegisterOperand" - ImmOpType = "ImmediateOperand" + from micro_asm import MicroAssembler, Combinational_Macroop, Rom_Macroop, Rom + class X86Macroop(Combinational_Macroop): + def __init__(self, name): + super(X86Macroop, self).__init__(name) + self.directives = { + } + + mainRom = Rom('main ROM') }}; let {{ - class MicroOpStatement(object): - def __init__(self): - self.className = '' - self.label = '' - self.args = [] + class X86Microop(object): + def __init__(self, name): + self.name = name # This converts a list of python bools into # a comma seperated list of C++ bools. @@ -87,145 +89,5 @@ let {{ def getAllocator(self, mnemonic, *microFlags): args = '' - signature = "<" - emptySig = True - for arg in self.args: - if not emptySig: - signature += ", " - emptySig = False - if arg.has_key("operandImm"): - args += ", %s" % arg["operandImm"] - signature += ImmOpType - elif arg.has_key("operandReg"): - args += ", %s" % arg["operandReg"] - signature += RegOpType - elif arg.has_key("operandLabel"): - raise Exception, "Found a label while creating allocator string." - else: - raise Exception, "Unrecognized operand type." - signature += ">" - return 'new %s%s(machInst, %s%s%s)' % (self.className, signature, mnemonic, self.microFlagsText(microFlags), args) -}}; - -let{{ - def assembleMicro(name, Name, code): - - # This function takes in a block of microcode assembly and returns - # a python list of objects which describe it. - - # Keep this around in case we need it later - orig_code = code - # A list of the statements we've found thus far - statements = [] - - # Regular expressions to pull each piece of the statement out at a - # time. Each expression expects the thing it's looking for to be at - # the beginning of the line, so the previous component is stripped - # before continuing. - labelRe = re.compile(r'^[ \t]*(?P