load_complex and store_complex instructions (#309)
* Start adding the load_complex and store_complex instructions. N.b.: The text format is not correct yet. Requires changes to the lexer and parser. I'm not sure why I needed to change the RuntimeError to Exception yet. Will fix. * Get first few encodings of load_complex working. Still needs var args type checking. * Clean up ModRM helper functions in binemit. * Implement 32-bit displace for load_complex * Use encoding helpers instead of doing them all by hand * Initial implementation of store_complex * Parse value list for load/store_complex with + as delimiter. Looks nice. * Add sign/zero-extension and size variants for load_complex. * Add size variants of store_complex. * Add asm helper lines to load/store complex bin tests. * Example of length-checking the instruction ValueList for an encoding. Extremely questionable implementation. * Fix Python linting issues * First draft of postopt pass to fold adds and loads into load_complex. Just simple loads for now. * Optimization pass now works with all types of loads. * Add store+add -> store_complex to postopt pass * Put complex address optimization behind ISA flag. * Add load/store complex for f32 and f64 * Fixes changes to lexer that broke NaN parsing. Abstracts away the repeated checks for whether or not the characters following a + or - are going to be parsed as a number or not. * Fix formatting issues * Fix register restrictions for complex addresses. * Encoding tests for x86-32. * Add documentation for newly added instructions, recipes, and cdsl changes. * Fix python formatting again * Apply value-list length predicates to all LoadComplex and StoreComplex instructions. * Add predicate types to new encoding helpers for mypy. * Import FieldPredicate to satisfy mypy. * Add and fix some "asm" strings in the encoding tests. * Line-up 'bin' comments in x86/binary64 test * Test parsing of offset-less store_complex instruction. * 'sNaN' not 'sNan' * Bounds check the lookup for polymorphic typevar operand. * Fix encodings for istore16_complex.
This commit is contained in:
committed by
Dan Gohman
parent
5aa84a744b
commit
f636d795c5
@@ -246,6 +246,7 @@ x = Operand('x', Mem, doc='Value to be stored')
|
||||
a = Operand('a', Mem, doc='Value loaded')
|
||||
p = Operand('p', iAddr)
|
||||
Flags = Operand('Flags', memflags)
|
||||
args = Operand('args', VARIABLE_ARGS, doc='Address arguments')
|
||||
|
||||
load = Instruction(
|
||||
'load', r"""
|
||||
@@ -256,6 +257,15 @@ load = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
load_complex = Instruction(
|
||||
'load_complex', r"""
|
||||
Load from memory at ``sum(args) + Offset``.
|
||||
|
||||
This is a polymorphic instruction that can load any value type which
|
||||
has a memory representation.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
store = Instruction(
|
||||
'store', r"""
|
||||
Store ``x`` to memory at ``p + Offset``.
|
||||
@@ -265,6 +275,16 @@ store = Instruction(
|
||||
""",
|
||||
ins=(Flags, x, p, Offset), can_store=True)
|
||||
|
||||
store_complex = Instruction(
|
||||
'store_complex', r"""
|
||||
Store ``x`` to memory at ``sum(args) + Offset``.
|
||||
|
||||
This is a polymorphic instruction that can store any value type with a
|
||||
memory representation.
|
||||
""",
|
||||
ins=(Flags, x, args, Offset), can_store=True)
|
||||
|
||||
|
||||
iExt8 = TypeVar(
|
||||
'iExt8', 'An integer type with more than 8 bits',
|
||||
ints=(16, 64))
|
||||
@@ -279,6 +299,14 @@ uload8 = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
uload8_complex = Instruction(
|
||||
'uload8_complex', r"""
|
||||
Load 8 bits from memory at ``sum(args) + Offset`` and zero-extend.
|
||||
|
||||
This is equivalent to ``load.i8`` followed by ``uextend``.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
sload8 = Instruction(
|
||||
'sload8', r"""
|
||||
Load 8 bits from memory at ``p + Offset`` and sign-extend.
|
||||
@@ -287,6 +315,14 @@ sload8 = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
sload8_complex = Instruction(
|
||||
'sload8_complex', r"""
|
||||
Load 8 bits from memory at ``sum(args) + Offset`` and sign-extend.
|
||||
|
||||
This is equivalent to ``load.i8`` followed by ``uextend``.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
istore8 = Instruction(
|
||||
'istore8', r"""
|
||||
Store the low 8 bits of ``x`` to memory at ``p + Offset``.
|
||||
@@ -295,6 +331,14 @@ istore8 = Instruction(
|
||||
""",
|
||||
ins=(Flags, x, p, Offset), can_store=True)
|
||||
|
||||
istore8_complex = Instruction(
|
||||
'istore8_complex', r"""
|
||||
Store the low 8 bits of ``x`` to memory at ``sum(args) + Offset``.
|
||||
|
||||
This is equivalent to ``ireduce.i8`` followed by ``store.i8``.
|
||||
""",
|
||||
ins=(Flags, x, args, Offset), can_store=True)
|
||||
|
||||
iExt16 = TypeVar(
|
||||
'iExt16', 'An integer type with more than 16 bits',
|
||||
ints=(32, 64))
|
||||
@@ -309,6 +353,14 @@ uload16 = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
uload16_complex = Instruction(
|
||||
'uload16_complex', r"""
|
||||
Load 16 bits from memory at ``sum(args) + Offset`` and zero-extend.
|
||||
|
||||
This is equivalent to ``load.i16`` followed by ``uextend``.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
sload16 = Instruction(
|
||||
'sload16', r"""
|
||||
Load 16 bits from memory at ``p + Offset`` and sign-extend.
|
||||
@@ -317,6 +369,14 @@ sload16 = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
sload16_complex = Instruction(
|
||||
'sload16_complex', r"""
|
||||
Load 16 bits from memory at ``sum(args) + Offset`` and sign-extend.
|
||||
|
||||
This is equivalent to ``load.i16`` followed by ``uextend``.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
istore16 = Instruction(
|
||||
'istore16', r"""
|
||||
Store the low 16 bits of ``x`` to memory at ``p + Offset``.
|
||||
@@ -325,6 +385,14 @@ istore16 = Instruction(
|
||||
""",
|
||||
ins=(Flags, x, p, Offset), can_store=True)
|
||||
|
||||
istore16_complex = Instruction(
|
||||
'istore16_complex', r"""
|
||||
Store the low 16 bits of ``x`` to memory at ``sum(args) + Offset``.
|
||||
|
||||
This is equivalent to ``ireduce.i16`` followed by ``store.i16``.
|
||||
""",
|
||||
ins=(Flags, x, args, Offset), can_store=True)
|
||||
|
||||
iExt32 = TypeVar(
|
||||
'iExt32', 'An integer type with more than 32 bits',
|
||||
ints=(64, 64))
|
||||
@@ -339,6 +407,14 @@ uload32 = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
uload32_complex = Instruction(
|
||||
'uload32_complex', r"""
|
||||
Load 32 bits from memory at ``sum(args) + Offset`` and zero-extend.
|
||||
|
||||
This is equivalent to ``load.i32`` followed by ``uextend``.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
sload32 = Instruction(
|
||||
'sload32', r"""
|
||||
Load 32 bits from memory at ``p + Offset`` and sign-extend.
|
||||
@@ -347,6 +423,14 @@ sload32 = Instruction(
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a, can_load=True)
|
||||
|
||||
sload32_complex = Instruction(
|
||||
'sload32_complex', r"""
|
||||
Load 32 bits from memory at ``sum(args) + Offset`` and sign-extend.
|
||||
|
||||
This is equivalent to ``load.i32`` followed by ``uextend``.
|
||||
""",
|
||||
ins=(Flags, args, Offset), outs=a, can_load=True)
|
||||
|
||||
istore32 = Instruction(
|
||||
'istore32', r"""
|
||||
Store the low 32 bits of ``x`` to memory at ``p + Offset``.
|
||||
@@ -355,6 +439,14 @@ istore32 = Instruction(
|
||||
""",
|
||||
ins=(Flags, x, p, Offset), can_store=True)
|
||||
|
||||
istore32_complex = Instruction(
|
||||
'istore32_complex', r"""
|
||||
Store the low 32 bits of ``x`` to memory at ``sum(args) + Offset``.
|
||||
|
||||
This is equivalent to ``ireduce.i32`` followed by ``store.i32``.
|
||||
""",
|
||||
ins=(Flags, x, args, Offset), can_store=True)
|
||||
|
||||
x = Operand('x', Mem, doc='Value to be stored')
|
||||
a = Operand('a', Mem, doc='Value loaded')
|
||||
Offset = Operand('Offset', offset32, 'In-bounds offset into stack slot')
|
||||
|
||||
Reference in New Issue
Block a user