Skip to content
Merged
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
44 changes: 0 additions & 44 deletions src/fpy/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@
)
from fpy.bytecode.directives import (
FloatDivideDirective,
FloatSubtractDirective,
FloatToUnsignedIntDirective,
FloatAbsDirective,
IntAbsDirective,
IntegerTruncate64To32Directive,
IntegerZeroExtend32To64Directive,
PeekDirective,
PushTimeDirective,
PushValDirective,
FloatLogDirective,
Expand Down Expand Up @@ -153,46 +149,6 @@ def generate_sleep_until_llvm(builder, args):
)


def generate_sleep_float(
node: Ast, const_args: dict[int, FpyValue], arg_types: list[FpyType]
) -> list[Directive | Ir]:
# convert F64 to seconds and microseconds
dirs = [
# first do seconds
# copy the f64
PushValDirective(FpyValue(StackSizeType, 8).serialize()),
PushValDirective(FpyValue(StackSizeType, 0).serialize()),
PeekDirective(),
# convert to U64
FloatToUnsignedIntDirective(),
# and then U32
IntegerTruncate64To32Directive(),
# now we have f64, u32 (seconds) on stack
# now do microseconds
# copy the f64 and u32
PushValDirective(FpyValue(StackSizeType, 12).serialize()),
PushValDirective(FpyValue(StackSizeType, 0).serialize()),
PeekDirective(),
# turn the u32 into a float
IntegerZeroExtend32To64Directive(),
UnsignedIntToFloatDirective(),
# subtract, this should give us the frac
FloatSubtractDirective(),
# okay now multiply by 1000000
PushValDirective(FpyValue(F64, 1_000_000.0).serialize()),
# now convert to u32
FloatToUnsignedIntDirective(),
IntegerTruncate64To32Directive(),
]

return dirs


MACRO_SLEEP_FLOAT = BuiltinFuncSymbol(
"sleep", NOTHING, [("seconds", F64, None)], generate_sleep_float
)


def generate_log_signed_int(
node: Ast, const_args: dict[int, FpyValue], arg_types: list[FpyType]
) -> list[Directive | Ir]:
Expand Down
Loading