Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Failure CompileError #520

Closed
myreen opened this issue Sep 4, 2018 · 4 comments
Closed

Remove Failure CompileError #520

myreen opened this issue Sep 4, 2018 · 4 comments

Comments

@myreen
Copy link
Contributor

myreen commented Sep 4, 2018

Currently, the compiler is allowed to return Failure CompileError
for any input program. At present, these compiler errors can only
occur when a code label is too far from the current program location,
i.e. the jump offset that needs to be encoded in the instruction just
does not fit the instruction encoding.

This issue is about removing such compiler errors completely by:

  1. annotating each instruction that might cause such an encoding
    error with two registers that can safely be used as temporaries
    when computing the target address

  2. adjust the lab_to_target compiler so that it makes use of
    these temporaries

  3. adjust the semantics of LabLang and StackLang so that these
    instructions delete the registers mentioned in temporary
    register annotations

I suspect the word_to_stack compiler knows which two registers are
available to be used as temporaries on the StackLang side.

@myreen
Copy link
Contributor Author

myreen commented Sep 4, 2018

Note that this issue goes against #186.

@myreen
Copy link
Contributor Author

myreen commented Sep 4, 2018

A potentially less intrusive approach could be to leave the compiler
implementation as is, but instead construct a compiler configuration
transformer
that given a normal compiler configuration produces a new
configuration where two registers are reserved (unusable by CakeML's
register allocator). These reserved registers can then be used to
implement "smart" encoders for instructions that require unusually
large code offsets.

One could prove that, given such a tweaked compiler configuration,
the compiler can never return Failure CompileError.

Use of such defensively written compiler configurations might not have a
performance impact on architectures that provide more than 16 registers,
since CakeML is unlikely to be able to make effective use of that many
registers anyway.

@sorear
Copy link
Contributor

sorear commented Sep 12, 2020

What's going to happen if I feed code that would be >4GB compiled to a 32-bit backend? Also, this seems to be in contradiction with #544.

@xrchz
Copy link
Member

xrchz commented Dec 9, 2024

This should be taken into account by #1080 and will be superseded by that.

@xrchz xrchz closed this as completed Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants