Add structure based bitfield syntax to the isa_parser. This is primarily useful for x86.
--HG-- extra : convert_revision : dfe6df160d00adec1830d9b88520ba20834d1209
This commit is contained in:
parent
39182808bc
commit
e3d3ab4513
|
@ -81,12 +81,12 @@ tokens = reserved + (
|
||||||
# code literal
|
# code literal
|
||||||
'CODELIT',
|
'CODELIT',
|
||||||
|
|
||||||
# ( ) [ ] { } < > , ; : :: *
|
# ( ) [ ] { } < > , ; . : :: *
|
||||||
'LPAREN', 'RPAREN',
|
'LPAREN', 'RPAREN',
|
||||||
'LBRACKET', 'RBRACKET',
|
'LBRACKET', 'RBRACKET',
|
||||||
'LBRACE', 'RBRACE',
|
'LBRACE', 'RBRACE',
|
||||||
'LESS', 'GREATER', 'EQUALS',
|
'LESS', 'GREATER', 'EQUALS',
|
||||||
'COMMA', 'SEMI', 'COLON', 'DBLCOLON',
|
'COMMA', 'SEMI', 'DOT', 'COLON', 'DBLCOLON',
|
||||||
'ASTERISK',
|
'ASTERISK',
|
||||||
|
|
||||||
# C preprocessor directives
|
# C preprocessor directives
|
||||||
|
@ -113,6 +113,7 @@ t_GREATER = r'\>'
|
||||||
t_EQUALS = r'='
|
t_EQUALS = r'='
|
||||||
t_COMMA = r','
|
t_COMMA = r','
|
||||||
t_SEMI = r';'
|
t_SEMI = r';'
|
||||||
|
t_DOT = r'\.'
|
||||||
t_COLON = r':'
|
t_COLON = r':'
|
||||||
t_DBLCOLON = r'::'
|
t_DBLCOLON = r'::'
|
||||||
t_ASTERISK = r'\*'
|
t_ASTERISK = r'\*'
|
||||||
|
@ -261,6 +262,7 @@ def p_defs_and_outputs_1(t):
|
||||||
def p_def_or_output(t):
|
def p_def_or_output(t):
|
||||||
'''def_or_output : def_format
|
'''def_or_output : def_format
|
||||||
| def_bitfield
|
| def_bitfield
|
||||||
|
| def_bitfield_struct
|
||||||
| def_template
|
| def_template
|
||||||
| def_operand_types
|
| def_operand_types
|
||||||
| def_operands
|
| def_operands
|
||||||
|
@ -364,15 +366,21 @@ def p_def_bitfield_1(t):
|
||||||
t[0] = GenCode(header_output = hash_define)
|
t[0] = GenCode(header_output = hash_define)
|
||||||
|
|
||||||
# alternate form for structure member: 'def bitfield <ID> <ID>'
|
# alternate form for structure member: 'def bitfield <ID> <ID>'
|
||||||
def p_def_bitfield_2(t):
|
def p_def_bitfield_struct(t):
|
||||||
'def_bitfield : DEF nothing BITFIELD ID ID SEMI'
|
'def_bitfield_struct : DEF opt_signed BITFIELD ID id_with_dot SEMI'
|
||||||
|
if (t[2] != ''):
|
||||||
|
error(t.lineno(1), 'error: structure bitfields are always unsigned.')
|
||||||
expr = 'machInst.%s' % t[5]
|
expr = 'machInst.%s' % t[5]
|
||||||
hash_define = '#undef %s\n#define %s\t%s\n' % (t[4], t[4], expr)
|
hash_define = '#undef %s\n#define %s\t%s\n' % (t[4], t[4], expr)
|
||||||
t[0] = GenCode(header_output = hash_define)
|
t[0] = GenCode(header_output = hash_define)
|
||||||
|
|
||||||
def p_nothing(t):
|
def p_id_with_dot_0(t):
|
||||||
'nothing : empty'
|
'id_with_dot : ID'
|
||||||
t[0] = ''
|
t[0] = t[1]
|
||||||
|
|
||||||
|
def p_id_with_dot_1(t):
|
||||||
|
'id_with_dot : ID DOT id_with_dot'
|
||||||
|
t[0] = t[1] + t[2] + t[3]
|
||||||
|
|
||||||
def p_opt_signed_0(t):
|
def p_opt_signed_0(t):
|
||||||
'opt_signed : SIGNED'
|
'opt_signed : SIGNED'
|
||||||
|
|
Loading…
Reference in a new issue