assembler: add support for VE_SAT/ME_SAT
This commit is contained in:
parent
c0cdfccefa
commit
6d0bc8538b
@ -38,16 +38,21 @@ def emit_destination_op(dst_op: DestinationOp):
|
|||||||
math_inst = int(type(dst_op.opcode) is ME)
|
math_inst = int(type(dst_op.opcode) is ME)
|
||||||
if dst_op.macro:
|
if dst_op.macro:
|
||||||
assert dst_op.opcode.value in {0, 1}
|
assert dst_op.opcode.value in {0, 1}
|
||||||
|
ve_sat = int((not math_inst) and dst_op.sat)
|
||||||
|
me_sat = int(math_inst and dst_op.sat)
|
||||||
|
|
||||||
value = (
|
value = (
|
||||||
pvs_dst.OPCODE_gen(dst_op.opcode.value)
|
pvs_dst.OPCODE_gen(dst_op.opcode.value)
|
||||||
| pvs_dst.MATH_INST_gen(math_inst)
|
| pvs_dst.MATH_INST_gen(math_inst)
|
||||||
|
| pvs_dst.MACRO_INST_gen(int(dst_op.macro))
|
||||||
| pvs_dst.REG_TYPE_gen(dst_reg_type(dst_op.type))
|
| pvs_dst.REG_TYPE_gen(dst_reg_type(dst_op.type))
|
||||||
| pvs_dst.OFFSET_gen(dst_op.offset)
|
| pvs_dst.OFFSET_gen(dst_op.offset)
|
||||||
| pvs_dst.WE_X_gen(we_x(dst_op.write_enable))
|
| pvs_dst.WE_X_gen(we_x(dst_op.write_enable))
|
||||||
| pvs_dst.WE_Y_gen(we_y(dst_op.write_enable))
|
| pvs_dst.WE_Y_gen(we_y(dst_op.write_enable))
|
||||||
| pvs_dst.WE_Z_gen(we_z(dst_op.write_enable))
|
| pvs_dst.WE_Z_gen(we_z(dst_op.write_enable))
|
||||||
| pvs_dst.WE_W_gen(we_w(dst_op.write_enable))
|
| pvs_dst.WE_W_gen(we_w(dst_op.write_enable))
|
||||||
| pvs_dst.MACRO_INST_gen(int(dst_op.macro))
|
| pvs_dst.VE_SAT_gen(ve_sat)
|
||||||
|
| pvs_dst.ME_SAT_gen(me_sat)
|
||||||
)
|
)
|
||||||
yield value
|
yield value
|
||||||
|
|
||||||
|
|||||||
@ -102,6 +102,7 @@ class KW(Enum):
|
|||||||
relative_a0 = auto()
|
relative_a0 = auto()
|
||||||
relative_i0 = auto()
|
relative_i0 = auto()
|
||||||
constant = auto()
|
constant = auto()
|
||||||
|
saturation = auto()
|
||||||
|
|
||||||
keywords = [
|
keywords = [
|
||||||
(KW.temporary , b"temporary" , b"temp"),
|
(KW.temporary , b"temporary" , b"temp"),
|
||||||
@ -114,6 +115,7 @@ keywords = [
|
|||||||
(KW.relative_a0 , b"relative_a0" , None),
|
(KW.relative_a0 , b"relative_a0" , None),
|
||||||
(KW.relative_i0 , b"relative_i0" , None),
|
(KW.relative_i0 , b"relative_i0" , None),
|
||||||
(KW.constant , b"constant" , b"const"),
|
(KW.constant , b"constant" , b"const"),
|
||||||
|
(KW.saturation , b"saturation" , b"sat"),
|
||||||
]
|
]
|
||||||
|
|
||||||
def find_keyword(b: memoryview):
|
def find_keyword(b: memoryview):
|
||||||
|
|||||||
@ -25,6 +25,7 @@ class DestinationOp:
|
|||||||
offset: int
|
offset: int
|
||||||
write_enable: set[int]
|
write_enable: set[int]
|
||||||
opcode: Union[VE, ME]
|
opcode: Union[VE, ME]
|
||||||
|
sat: bool
|
||||||
macro: bool
|
macro: bool
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -173,8 +174,21 @@ class Parser:
|
|||||||
write_enable = parse_dest_write_enable(write_enable_token)
|
write_enable = parse_dest_write_enable(write_enable_token)
|
||||||
self.consume(TT.equal, "expected equals")
|
self.consume(TT.equal, "expected equals")
|
||||||
opcode = self.opcode()
|
opcode = self.opcode()
|
||||||
|
sat = False
|
||||||
|
if self.match(TT.dot):
|
||||||
|
self.advance()
|
||||||
|
suffix = self.consume(TT.keyword, "expected saturation suffix")
|
||||||
|
if suffix.keyword is not KW.saturation:
|
||||||
|
raise ParserError("expected saturation suffix", token)
|
||||||
|
sat = True
|
||||||
|
|
||||||
macro = False
|
macro = False
|
||||||
return DestinationOp(destination_type, offset_value, write_enable, opcode, macro)
|
return DestinationOp(type=destination_type,
|
||||||
|
offset=offset_value,
|
||||||
|
write_enable=write_enable,
|
||||||
|
opcode=opcode,
|
||||||
|
sat=sat,
|
||||||
|
macro=macro)
|
||||||
|
|
||||||
def source_type(self):
|
def source_type(self):
|
||||||
token = self.consume(TT.keyword, "expected source type")
|
token = self.consume(TT.keyword, "expected source type")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user