specialize.isa (4716:68cc9f2d4f73) | specialize.isa (4746:7960a6867f55) |
---|---|
1// -*- mode:c++ -*- 2 3// Copyright (c) 2007 The Hewlett-Packard Development Company 4// All rights reserved. 5// 6// Redistribution and use of this software in source and binary forms, 7// with or without modification, are permitted provided that the 8// following conditions are met: --- 100 unchanged lines hidden (view full) --- 109 parser = re.compile(r"(?P<tag>[A-Z]+)(?P<size>[a-z]*)|(r(?P<reg>[A-Z0-9]+)(?P<rsize>[a-z]*))") 110 def __init__(self, opTypeString): 111 match = OpType.parser.search(opTypeString) 112 if match == None: 113 raise Exception, "Problem parsing operand type %s" % opTypeString 114 self.reg = match.group("reg") 115 self.tag = match.group("tag") 116 self.size = match.group("size") | 1// -*- mode:c++ -*- 2 3// Copyright (c) 2007 The Hewlett-Packard Development Company 4// All rights reserved. 5// 6// Redistribution and use of this software in source and binary forms, 7// with or without modification, are permitted provided that the 8// following conditions are met: --- 100 unchanged lines hidden (view full) --- 109 parser = re.compile(r"(?P<tag>[A-Z]+)(?P<size>[a-z]*)|(r(?P<reg>[A-Z0-9]+)(?P<rsize>[a-z]*))") 110 def __init__(self, opTypeString): 111 match = OpType.parser.search(opTypeString) 112 if match == None: 113 raise Exception, "Problem parsing operand type %s" % opTypeString 114 self.reg = match.group("reg") 115 self.tag = match.group("tag") 116 self.size = match.group("size") |
117 self.rsize = match.group("rsize") | 117 if not self.size: 118 self.size = match.group("rsize") |
118 119 ModRMRegIndex = "(MODRM_REG | (REX_R << 3))" 120 ModRMRMIndex = "(MODRM_RM | (REX_B << 3))" 121 InstRegIndex = "(OPCODE_OP_BOTTOM3 | (REX_B << 3))" 122 123 # This function specializes the given piece of code to use a particular 124 # set of argument types described by "opTypes". 125 def specializeInst(Name, opTypes, env): 126 # print "Specializing %s with opTypes %s" % (Name, opTypes) 127 while len(opTypes): 128 # Parse the operand type string we're working with 129 opType = OpType(opTypes[0]) 130 opTypes.pop(0) 131 | 119 120 ModRMRegIndex = "(MODRM_REG | (REX_R << 3))" 121 ModRMRMIndex = "(MODRM_RM | (REX_B << 3))" 122 InstRegIndex = "(OPCODE_OP_BOTTOM3 | (REX_B << 3))" 123 124 # This function specializes the given piece of code to use a particular 125 # set of argument types described by "opTypes". 126 def specializeInst(Name, opTypes, env): 127 # print "Specializing %s with opTypes %s" % (Name, opTypes) 128 while len(opTypes): 129 # Parse the operand type string we're working with 130 opType = OpType(opTypes[0]) 131 opTypes.pop(0) 132 |
133 if opType.tag not in ("I", "J"): 134 if opType.size: 135 env.setSize(opType.size) 136 |
|
132 if opType.reg: 133 #Figure out what to do with fixed register operands 134 #This is the index to use, so we should stick it some place. 135 if opType.reg in ("A", "B", "C", "D"): 136 env.addReg("INTREG_R%sX | (REX_B << 3)" % opType.reg) 137 else: 138 env.addReg("INTREG_R%s | (REX_B << 3)" % opType.reg) | 137 if opType.reg: 138 #Figure out what to do with fixed register operands 139 #This is the index to use, so we should stick it some place. 140 if opType.reg in ("A", "B", "C", "D"): 141 env.addReg("INTREG_R%sX | (REX_B << 3)" % opType.reg) 142 else: 143 env.addReg("INTREG_R%s | (REX_B << 3)" % opType.reg) |
139 if opType.size: 140 if opType.rsize in ("l", "h", "b"): 141 print "byte" 142 elif opType.rsize == "x": 143 print "word" 144 else: 145 print "Didn't recognize fixed register size %s!" % opType.rsize | |
146 Name += "_R" 147 elif opType.tag == "B": 148 # This refers to registers whose index is encoded as part of the opcode 149 Name += "_R" 150 env.addReg(InstRegIndex) 151 elif opType.tag == "M": 152 # This refers to memory. The macroop constructor sets up modrm 153 # addressing. Non memory modrm settings should cause an error. --- 34 unchanged lines hidden --- | 144 Name += "_R" 145 elif opType.tag == "B": 146 # This refers to registers whose index is encoded as part of the opcode 147 Name += "_R" 148 env.addReg(InstRegIndex) 149 elif opType.tag == "M": 150 # This refers to memory. The macroop constructor sets up modrm 151 # addressing. Non memory modrm settings should cause an error. --- 34 unchanged lines hidden --- |