X86: Make the microassembler accept lines which are just labels.
The labels on these lines will be associated with whatever the next microop is. --HG-- extra : convert_revision : 80c260e48ec1c16e6325061608e37c95a0610cfa
This commit is contained in:
parent
03880cf828
commit
8b738f7f12
3 changed files with 27 additions and 7 deletions
|
@ -140,9 +140,9 @@ def handle_statement(parser, container, statement):
|
||||||
raise
|
raise
|
||||||
try:
|
try:
|
||||||
for label in statement.labels:
|
for label in statement.labels:
|
||||||
container.labels[label.name] = microop
|
container.labels[label.text] = microop
|
||||||
if label.extern:
|
if label.extern:
|
||||||
container.externs[label.name] = microop
|
container.externs[label.text] = microop
|
||||||
container.add_microop(microop)
|
container.add_microop(microop)
|
||||||
except:
|
except:
|
||||||
print_error("Error adding microop.")
|
print_error("Error adding microop.")
|
||||||
|
@ -439,6 +439,11 @@ def p_labels_1(t):
|
||||||
t[1].append(t[2])
|
t[1].append(t[2])
|
||||||
t[0] = t[1]
|
t[0] = t[1]
|
||||||
|
|
||||||
|
# labels on lines by themselves are attached to the following instruction.
|
||||||
|
def p_labels_2(t):
|
||||||
|
'labels : labels NEWLINE'
|
||||||
|
t[0] = t[1]
|
||||||
|
|
||||||
def p_label_0(t):
|
def p_label_0(t):
|
||||||
'label : ID COLON'
|
'label : ID COLON'
|
||||||
label = Label()
|
label = Label()
|
||||||
|
|
|
@ -97,9 +97,10 @@ def macroop CPUID_R {
|
||||||
# Standard functions.
|
# Standard functions.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
standardStart:
|
||||||
|
|
||||||
# 0x00000000 -- Processor Vendor and Largest Standard Function Number
|
# 0x00000000 -- Processor Vendor and Largest Standard Function Number
|
||||||
standardStart: limm rax, 0x00000001, dataSize=4
|
limm rax, 0x00000001, dataSize=4
|
||||||
limm rbx, 0x68747541, dataSize=4
|
limm rbx, 0x68747541, dataSize=4
|
||||||
limm rdx, 0x69746e65, dataSize=4
|
limm rdx, 0x69746e65, dataSize=4
|
||||||
limm rcx, 0x444d4163, dataSize=4
|
limm rcx, 0x444d4163, dataSize=4
|
||||||
|
@ -122,9 +123,10 @@ standardStart: limm rax, 0x00000001, dataSize=4
|
||||||
# Extended functions.
|
# Extended functions.
|
||||||
#
|
#
|
||||||
|
|
||||||
# 0x80000000 -- Processor Vendor and Largest Extended Function Number
|
extendedStart:
|
||||||
|
|
||||||
extendedStart: limm rax, 0x80000018, dataSize=4
|
# 0x80000000 -- Processor Vendor and Largest Extended Function Number
|
||||||
|
limm rax, 0x80000018, dataSize=4
|
||||||
limm rbx, 0x68747541, dataSize=4
|
limm rbx, 0x68747541, dataSize=4
|
||||||
limm rdx, 0x69746e65, dataSize=4
|
limm rdx, 0x69746e65, dataSize=4
|
||||||
limm rcx, 0x444d4163, dataSize=4
|
limm rcx, 0x444d4163, dataSize=4
|
||||||
|
@ -400,6 +402,7 @@ extendedStart: limm rax, 0x80000018, dataSize=4
|
||||||
fault "NoFault"
|
fault "NoFault"
|
||||||
fault "NoFault"
|
fault "NoFault"
|
||||||
|
|
||||||
end: fault "NoFault"
|
end:
|
||||||
|
fault "NoFault"
|
||||||
};
|
};
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -126,6 +126,8 @@ def template MacroDeclare {{
|
||||||
*/
|
*/
|
||||||
class %(class_name)s : public %(base_class)s
|
class %(class_name)s : public %(base_class)s
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
%(declareLabels)s
|
||||||
public:
|
public:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
%(class_name)s(ExtMachInst machInst, X86ISA::EmulEnv env);
|
%(class_name)s(ExtMachInst machInst, X86ISA::EmulEnv env);
|
||||||
|
@ -151,6 +153,9 @@ def template MacroConstructor {{
|
||||||
let {{
|
let {{
|
||||||
from micro_asm import Combinational_Macroop, Rom_Macroop
|
from micro_asm import Combinational_Macroop, Rom_Macroop
|
||||||
class X86Macroop(Combinational_Macroop):
|
class X86Macroop(Combinational_Macroop):
|
||||||
|
def add_microop(self, microop):
|
||||||
|
microop.micropc = len(self.microops)
|
||||||
|
self.microops.append(microop)
|
||||||
def setAdjustEnv(self, val):
|
def setAdjustEnv(self, val):
|
||||||
self.adjust_env = val
|
self.adjust_env = val
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
@ -166,7 +171,14 @@ let {{
|
||||||
def getDeclaration(self):
|
def getDeclaration(self):
|
||||||
#FIXME This first parameter should be the mnemonic. I need to
|
#FIXME This first parameter should be the mnemonic. I need to
|
||||||
#write some code which pulls that out
|
#write some code which pulls that out
|
||||||
iop = InstObjParams(self.name, self.name, "Macroop", {"code" : ""})
|
declareLabels = ""
|
||||||
|
for (label, microop) in self.labels.items():
|
||||||
|
declareLabels += "const static uint64_t label_%s = %d;\n" \
|
||||||
|
% (label, microop.micropc)
|
||||||
|
iop = InstObjParams(self.name, self.name, "Macroop",
|
||||||
|
{"code" : "",
|
||||||
|
"declareLabels" : declareLabels
|
||||||
|
})
|
||||||
return MacroDeclare.subst(iop);
|
return MacroDeclare.subst(iop);
|
||||||
def getDefinition(self):
|
def getDefinition(self):
|
||||||
#FIXME This first parameter should be the mnemonic. I need to
|
#FIXME This first parameter should be the mnemonic. I need to
|
||||||
|
|
Loading…
Reference in a new issue