Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/striga/x86/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,31 @@ def syscall(sem: Semantics):
return [Successor(sem.insn.address, sem.const64(fallthrough))]


@semantic
def stc(sem: Semantics):
sem.flag_write("cf", sem.i1.constant(1))


@semantic
def clc(sem: Semantics):
sem.flag_write("cf", sem.i1.constant(0))


@semantic
def int_(sem: Semantics):
sem.ir.ret_void()
return []


@semantic
def cmc(sem: Semantics):
sem.flag_write("cf", bool_not(sem, sem.flag_read("cf")))


@semantic
def int3(sem: Semantics):
sem.ir.ret_void()
return []
@semantic
def nop(sem: Semantics):
pass
Expand All @@ -401,3 +426,16 @@ def nop(sem: Semantics):
@semantic
def pause(sem: Semantics):
pass
@semantic
def lfence(sem: Semantics):
pass


@semantic
def mfence(sem: Semantics):
pass


@semantic
def sfence(sem: Semantics):
pass
11 changes: 11 additions & 0 deletions src/striga/x86/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ def cqo(sem: Semantics):
sem.reg_write("rdx", sem.ir.ashr(rax, sem.const64(63)))


@semantic
def bswap(sem: Semantics):
value = sem.op_read(0)
width = value.type.int_width
assert width in (32, 64)

intrinsic = sem.module.get_intrinsic_declaration(
lookup_intrinsic_id(f"llvm.bswap.i{width}"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this function coming from?

[value.type],
)
sem.op_write(0, sem.ir.call(intrinsic, [value]))
@semantic
def xchg(sem: Semantics):
src = sem.op_read(1)
Expand Down