Add load and store instructions.
Define a MemFlags class, currently holding a notrap and aligned flag.
This commit is contained in:
@@ -9,7 +9,7 @@ from __future__ import absolute_import
|
||||
from cdsl.formats import InstructionFormat
|
||||
from cdsl.operands import VALUE, VARIABLE_ARGS
|
||||
from .immediates import imm64, uimm8, ieee32, ieee64, offset32, uoffset32
|
||||
from .immediates import intcc, floatcc
|
||||
from .immediates import intcc, floatcc, memflags
|
||||
from .entities import ebb, sig_ref, func_ref, jump_table, stack_slot
|
||||
|
||||
Nullary = InstructionFormat()
|
||||
@@ -53,6 +53,9 @@ IndirectCall = InstructionFormat(
|
||||
sig_ref, VALUE, VARIABLE_ARGS,
|
||||
multiple_results=True)
|
||||
|
||||
Load = InstructionFormat(memflags, VALUE, offset32)
|
||||
Store = InstructionFormat(memflags, VALUE, VALUE, offset32)
|
||||
|
||||
StackLoad = InstructionFormat(stack_slot, offset32)
|
||||
StackStore = InstructionFormat(VALUE, stack_slot, offset32)
|
||||
|
||||
|
||||
@@ -90,3 +90,9 @@ floatcc = ImmediateKind(
|
||||
'ugt': 'UnorderedOrGreaterThan',
|
||||
'uge': 'UnorderedOrGreaterThanOrEqual',
|
||||
})
|
||||
|
||||
#: Flags for memory operations like :inst:`load` and :inst:`store`.
|
||||
memflags = ImmediateKind(
|
||||
'memflags',
|
||||
'Memory operation flags',
|
||||
default_member='flags', rust_type='MemFlags')
|
||||
|
||||
@@ -10,7 +10,7 @@ from cdsl.typevar import TypeVar
|
||||
from cdsl.instructions import Instruction, InstructionGroup
|
||||
from base.types import i8, f32, f64, b1
|
||||
from base.immediates import imm64, uimm8, ieee32, ieee64, offset32, uoffset32
|
||||
from base.immediates import intcc, floatcc
|
||||
from base.immediates import intcc, floatcc, memflags
|
||||
from base import entities
|
||||
import base.formats # noqa
|
||||
|
||||
@@ -211,6 +211,25 @@ x = Operand('x', Mem, doc='Value to be stored')
|
||||
a = Operand('a', Mem, doc='Value loaded')
|
||||
p = Operand('p', iAddr)
|
||||
addr = Operand('addr', iAddr)
|
||||
Flags = Operand('Flags', memflags)
|
||||
|
||||
load = Instruction(
|
||||
'load', r"""
|
||||
Load from memory at ``p + Offset``.
|
||||
|
||||
This is a polymorphic instruction that can load any value type which
|
||||
has a memory representation.
|
||||
""",
|
||||
ins=(Flags, p, Offset), outs=a)
|
||||
|
||||
store = Instruction(
|
||||
'store', r"""
|
||||
Store ``x`` to memory at ``p + Offset``.
|
||||
|
||||
This is a polymorphic instruction that can store any value type with a
|
||||
memory representation.
|
||||
""",
|
||||
ins=(Flags, x, p, Offset))
|
||||
|
||||
stack_load = Instruction(
|
||||
'stack_load', r"""
|
||||
|
||||
Reference in New Issue
Block a user