microasm.isa revision 4528
14309Sgblack@eecs.umich.edu// -*- mode:c++ -*- 24309Sgblack@eecs.umich.edu 34309Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company 44309Sgblack@eecs.umich.edu// All rights reserved. 54309Sgblack@eecs.umich.edu// 64309Sgblack@eecs.umich.edu// Redistribution and use of this software in source and binary forms, 74309Sgblack@eecs.umich.edu// with or without modification, are permitted provided that the 84309Sgblack@eecs.umich.edu// following conditions are met: 94309Sgblack@eecs.umich.edu// 104309Sgblack@eecs.umich.edu// The software must be used only for Non-Commercial Use which means any 114309Sgblack@eecs.umich.edu// use which is NOT directed to receiving any direct monetary 124309Sgblack@eecs.umich.edu// compensation for, or commercial advantage from such use. Illustrative 134309Sgblack@eecs.umich.edu// examples of non-commercial use are academic research, personal study, 144309Sgblack@eecs.umich.edu// teaching, education and corporate research & development. 154309Sgblack@eecs.umich.edu// Illustrative examples of commercial use are distributing products for 164309Sgblack@eecs.umich.edu// commercial advantage and providing services using the software for 174309Sgblack@eecs.umich.edu// commercial advantage. 184309Sgblack@eecs.umich.edu// 194309Sgblack@eecs.umich.edu// If you wish to use this software or functionality therein that may be 204309Sgblack@eecs.umich.edu// covered by patents for commercial use, please contact: 214309Sgblack@eecs.umich.edu// Director of Intellectual Property Licensing 224309Sgblack@eecs.umich.edu// Office of Strategy and Technology 234309Sgblack@eecs.umich.edu// Hewlett-Packard Company 244309Sgblack@eecs.umich.edu// 1501 Page Mill Road 254309Sgblack@eecs.umich.edu// Palo Alto, California 94304 264309Sgblack@eecs.umich.edu// 274309Sgblack@eecs.umich.edu// Redistributions of source code must retain the above copyright notice, 284309Sgblack@eecs.umich.edu// this list of conditions and the following disclaimer. Redistributions 294309Sgblack@eecs.umich.edu// in binary form must reproduce the above copyright notice, this list of 304309Sgblack@eecs.umich.edu// conditions and the following disclaimer in the documentation and/or 314309Sgblack@eecs.umich.edu// other materials provided with the distribution. Neither the name of 324309Sgblack@eecs.umich.edu// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 334309Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 344309Sgblack@eecs.umich.edu// this software without specific prior written permission. No right of 354309Sgblack@eecs.umich.edu// sublicense is granted herewith. Derivatives of the software and 364309Sgblack@eecs.umich.edu// output created using the software may be prepared, but only for 374309Sgblack@eecs.umich.edu// Non-Commercial Uses. Derivatives of the software may be shared with 384309Sgblack@eecs.umich.edu// others provided: (i) the others agree to abide by the list of 394309Sgblack@eecs.umich.edu// conditions herein which includes the Non-Commercial Use restrictions; 404309Sgblack@eecs.umich.edu// and (ii) such Derivatives of the software include the above copyright 414309Sgblack@eecs.umich.edu// notice to acknowledge the contribution from this software where 424309Sgblack@eecs.umich.edu// applicable, this list of conditions and the disclaimer below. 434309Sgblack@eecs.umich.edu// 444309Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 454309Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 464309Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 474309Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 484309Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 494309Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 504309Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 514309Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 524309Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 534309Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 544309Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 554309Sgblack@eecs.umich.edu// 564309Sgblack@eecs.umich.edu// Authors: Gabe Black 574309Sgblack@eecs.umich.edu 584528Sgblack@eecs.umich.edu//##include "microops/microops.isa" 594528Sgblack@eecs.umich.edu//##include "macroop.isa" 604528Sgblack@eecs.umich.edu 614528Sgblack@eecs.umich.edulet {{ 624528Sgblack@eecs.umich.edu import sys 634528Sgblack@eecs.umich.edu sys.path[0:0] = ["src/arch/x86/isa/"] 644528Sgblack@eecs.umich.edu from insts import microcode 654528Sgblack@eecs.umich.edu print microcode 664528Sgblack@eecs.umich.edu from micro_asm import MicroAssembler, Rom_Macroop, Rom 674528Sgblack@eecs.umich.edu mainRom = Rom('main ROM') 684528Sgblack@eecs.umich.edu assembler = MicroAssembler(X86Macroop, microopClasses, mainRom, Rom_Macroop) 694528Sgblack@eecs.umich.edu macroopDict = assembler.assemble(microcode) 704528Sgblack@eecs.umich.edu}}; 714528Sgblack@eecs.umich.edu 724309Sgblack@eecs.umich.edu//////////////////////////////////////////////////////////////////// 734309Sgblack@eecs.umich.edu// 744519Sgblack@eecs.umich.edu// Microcode assembler specialization for x86 754336Sgblack@eecs.umich.edu// 764336Sgblack@eecs.umich.edu 774336Sgblack@eecs.umich.edulet {{ 784519Sgblack@eecs.umich.edu from micro_asm import MicroAssembler, Combinational_Macroop, Rom_Macroop, Rom 794519Sgblack@eecs.umich.edu class X86Macroop(Combinational_Macroop): 804519Sgblack@eecs.umich.edu def __init__(self, name): 814519Sgblack@eecs.umich.edu super(X86Macroop, self).__init__(name) 824519Sgblack@eecs.umich.edu self.directives = { 834519Sgblack@eecs.umich.edu } 844519Sgblack@eecs.umich.edu 854519Sgblack@eecs.umich.edu mainRom = Rom('main ROM') 864344Sgblack@eecs.umich.edu}}; 874344Sgblack@eecs.umich.edu 884344Sgblack@eecs.umich.edulet {{ 894519Sgblack@eecs.umich.edu class X86Microop(object): 904519Sgblack@eecs.umich.edu def __init__(self, name): 914519Sgblack@eecs.umich.edu self.name = name 924309Sgblack@eecs.umich.edu 934323Sgblack@eecs.umich.edu # This converts a list of python bools into 944323Sgblack@eecs.umich.edu # a comma seperated list of C++ bools. 954323Sgblack@eecs.umich.edu def microFlagsText(self, vals): 964323Sgblack@eecs.umich.edu text = "" 974323Sgblack@eecs.umich.edu for val in vals: 984323Sgblack@eecs.umich.edu if val: 994323Sgblack@eecs.umich.edu text += ", true" 1004323Sgblack@eecs.umich.edu else: 1014323Sgblack@eecs.umich.edu text += ", false" 1024323Sgblack@eecs.umich.edu return text 1034323Sgblack@eecs.umich.edu 1044371Sgblack@eecs.umich.edu def getAllocator(self, mnemonic, *microFlags): 1054528Sgblack@eecs.umich.edu return 'new %s(machInst, %s)' % (self.className, mnemonic, self.microFlagsText(microFlags)) 1064323Sgblack@eecs.umich.edu}}; 107