Adapt to lightning -> lightening name change
* libguile/jit.c: Include lightening.h. * libguile/Makefile.am: Adapt.
This commit is contained in:
parent
2e4fb1e665
commit
e9be4ea73d
257 changed files with 87 additions and 85 deletions
4
libguile/lightening/.gitignore
vendored
Normal file
4
libguile/lightening/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
*.o
|
||||
+*
|
||||
/lightning.info
|
||||
/tests/test-*
|
||||
9
libguile/lightening/.gitlab-ci.yml
Normal file
9
libguile/lightening/.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# use the official gcc image, based on debian
|
||||
# can use verions as well, like gcc:5.2
|
||||
# see https://hub.docker.com/_/gcc/
|
||||
image: gcc
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- make -C tests check
|
||||
14
libguile/lightening/AUTHORS
Normal file
14
libguile/lightening/AUTHORS
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Paulo Cesar Pereira de Andrade <pcpa@gnu.org>
|
||||
|
||||
Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
PPC assembler by Ian Piumarta <piumarta@inria.fr>
|
||||
|
||||
i386 assembler by Ian Piumarta <piumarta@inria.fr>
|
||||
and Gwenole Beauchesne <gb.public@free.fr>
|
||||
|
||||
x86-64 backend by Matthew Flatt <mflatt@cs.utah.edu>
|
||||
|
||||
Major PPC contributions by Laurent Michel <ldm@thorgal.homelinux.org>
|
||||
|
||||
Major SPARC contributions by Ludovic Courtes <ludo@chbouib.org>
|
||||
676
libguile/lightening/COPYING
Normal file
676
libguile/lightening/COPYING
Normal file
|
|
@ -0,0 +1,676 @@
|
|||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
355
libguile/lightening/COPYING.DOC
Normal file
355
libguile/lightening/COPYING.DOC
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
GNU Free Documentation License
|
||||
Version 1.1, March 2000
|
||||
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
0. PREAMBLE
|
||||
|
||||
The purpose of this License is to make a manual, textbook, or other
|
||||
written document "free" in the sense of freedom: to assure everyone
|
||||
the effective freedom to copy and redistribute it, with or without
|
||||
modifying it, either commercially or noncommercially. Secondarily,
|
||||
this License preserves for the author and publisher a way to get
|
||||
credit for their work, while not being considered responsible for
|
||||
modifications made by others.
|
||||
|
||||
This License is a kind of "copyleft", which means that derivative
|
||||
works of the document must themselves be free in the same sense. It
|
||||
complements the GNU General Public License, which is a copyleft
|
||||
license designed for free software.
|
||||
|
||||
We have designed this License in order to use it for manuals for free
|
||||
software, because free software needs free documentation: a free
|
||||
program should come with manuals providing the same freedoms that the
|
||||
software does. But this License is not limited to software manuals;
|
||||
it can be used for any textual work, regardless of subject matter or
|
||||
whether it is published as a printed book. We recommend this License
|
||||
principally for works whose purpose is instruction or reference.
|
||||
|
||||
|
||||
1. APPLICABILITY AND DEFINITIONS
|
||||
|
||||
This License applies to any manual or other work that contains a
|
||||
notice placed by the copyright holder saying it can be distributed
|
||||
under the terms of this License. The "Document", below, refers to any
|
||||
such manual or work. Any member of the public is a licensee, and is
|
||||
addressed as "you".
|
||||
|
||||
A "Modified Version" of the Document means any work containing the
|
||||
Document or a portion of it, either copied verbatim, or with
|
||||
modifications and/or translated into another language.
|
||||
|
||||
A "Secondary Section" is a named appendix or a front-matter section of
|
||||
the Document that deals exclusively with the relationship of the
|
||||
publishers or authors of the Document to the Document's overall subject
|
||||
(or to related matters) and contains nothing that could fall directly
|
||||
within that overall subject. (For example, if the Document is in part a
|
||||
textbook of mathematics, a Secondary Section may not explain any
|
||||
mathematics.) The relationship could be a matter of historical
|
||||
connection with the subject or with related matters, or of legal,
|
||||
commercial, philosophical, ethical or political position regarding
|
||||
them.
|
||||
|
||||
The "Invariant Sections" are certain Secondary Sections whose titles
|
||||
are designated, as being those of Invariant Sections, in the notice
|
||||
that says that the Document is released under this License.
|
||||
|
||||
The "Cover Texts" are certain short passages of text that are listed,
|
||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||
the Document is released under this License.
|
||||
|
||||
A "Transparent" copy of the Document means a machine-readable copy,
|
||||
represented in a format whose specification is available to the
|
||||
general public, whose contents can be viewed and edited directly and
|
||||
straightforwardly with generic text editors or (for images composed of
|
||||
pixels) generic paint programs or (for drawings) some widely available
|
||||
drawing editor, and that is suitable for input to text formatters or
|
||||
for automatic translation to a variety of formats suitable for input
|
||||
to text formatters. A copy made in an otherwise Transparent file
|
||||
format whose markup has been designed to thwart or discourage
|
||||
subsequent modification by readers is not Transparent. A copy that is
|
||||
not "Transparent" is called "Opaque".
|
||||
|
||||
Examples of suitable formats for Transparent copies include plain
|
||||
ASCII without markup, Texinfo input format, LaTeX input format, SGML
|
||||
or XML using a publicly available DTD, and standard-conforming simple
|
||||
HTML designed for human modification. Opaque formats include
|
||||
PostScript, PDF, proprietary formats that can be read and edited only
|
||||
by proprietary word processors, SGML or XML for which the DTD and/or
|
||||
processing tools are not generally available, and the
|
||||
machine-generated HTML produced by some word processors for output
|
||||
purposes only.
|
||||
|
||||
The "Title Page" means, for a printed book, the title page itself,
|
||||
plus such following pages as are needed to hold, legibly, the material
|
||||
this License requires to appear in the title page. For works in
|
||||
formats which do not have any title page as such, "Title Page" means
|
||||
the text near the most prominent appearance of the work's title,
|
||||
preceding the beginning of the body of the text.
|
||||
|
||||
|
||||
2. VERBATIM COPYING
|
||||
|
||||
You may copy and distribute the Document in any medium, either
|
||||
commercially or noncommercially, provided that this License, the
|
||||
copyright notices, and the license notice saying this License applies
|
||||
to the Document are reproduced in all copies, and that you add no other
|
||||
conditions whatsoever to those of this License. You may not use
|
||||
technical measures to obstruct or control the reading or further
|
||||
copying of the copies you make or distribute. However, you may accept
|
||||
compensation in exchange for copies. If you distribute a large enough
|
||||
number of copies you must also follow the conditions in section 3.
|
||||
|
||||
You may also lend copies, under the same conditions stated above, and
|
||||
you may publicly display copies.
|
||||
|
||||
|
||||
3. COPYING IN QUANTITY
|
||||
|
||||
If you publish printed copies of the Document numbering more than 100,
|
||||
and the Document's license notice requires Cover Texts, you must enclose
|
||||
the copies in covers that carry, clearly and legibly, all these Cover
|
||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||
the back cover. Both covers must also clearly and legibly identify
|
||||
you as the publisher of these copies. The front cover must present
|
||||
the full title with all words of the title equally prominent and
|
||||
visible. You may add other material on the covers in addition.
|
||||
Copying with changes limited to the covers, as long as they preserve
|
||||
the title of the Document and satisfy these conditions, can be treated
|
||||
as verbatim copying in other respects.
|
||||
|
||||
If the required texts for either cover are too voluminous to fit
|
||||
legibly, you should put the first ones listed (as many as fit
|
||||
reasonably) on the actual cover, and continue the rest onto adjacent
|
||||
pages.
|
||||
|
||||
If you publish or distribute Opaque copies of the Document numbering
|
||||
more than 100, you must either include a machine-readable Transparent
|
||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||
a publicly-accessible computer-network location containing a complete
|
||||
Transparent copy of the Document, free of added material, which the
|
||||
general network-using public has access to download anonymously at no
|
||||
charge using public-standard network protocols. If you use the latter
|
||||
option, you must take reasonably prudent steps, when you begin
|
||||
distribution of Opaque copies in quantity, to ensure that this
|
||||
Transparent copy will remain thus accessible at the stated location
|
||||
until at least one year after the last time you distribute an Opaque
|
||||
copy (directly or through your agents or retailers) of that edition to
|
||||
the public.
|
||||
|
||||
It is requested, but not required, that you contact the authors of the
|
||||
Document well before redistributing any large number of copies, to give
|
||||
them a chance to provide you with an updated version of the Document.
|
||||
|
||||
|
||||
4. MODIFICATIONS
|
||||
|
||||
You may copy and distribute a Modified Version of the Document under
|
||||
the conditions of sections 2 and 3 above, provided that you release
|
||||
the Modified Version under precisely this License, with the Modified
|
||||
Version filling the role of the Document, thus licensing distribution
|
||||
and modification of the Modified Version to whoever possesses a copy
|
||||
of it. In addition, you must do these things in the Modified Version:
|
||||
|
||||
A. Use in the Title Page (and on the covers, if any) a title distinct
|
||||
from that of the Document, and from those of previous versions
|
||||
(which should, if there were any, be listed in the History section
|
||||
of the Document). You may use the same title as a previous version
|
||||
if the original publisher of that version gives permission.
|
||||
B. List on the Title Page, as authors, one or more persons or entities
|
||||
responsible for authorship of the modifications in the Modified
|
||||
Version, together with at least five of the principal authors of the
|
||||
Document (all of its principal authors, if it has less than five).
|
||||
C. State on the Title page the name of the publisher of the
|
||||
Modified Version, as the publisher.
|
||||
D. Preserve all the copyright notices of the Document.
|
||||
E. Add an appropriate copyright notice for your modifications
|
||||
adjacent to the other copyright notices.
|
||||
F. Include, immediately after the copyright notices, a license notice
|
||||
giving the public permission to use the Modified Version under the
|
||||
terms of this License, in the form shown in the Addendum below.
|
||||
G. Preserve in that license notice the full lists of Invariant Sections
|
||||
and required Cover Texts given in the Document's license notice.
|
||||
H. Include an unaltered copy of this License.
|
||||
I. Preserve the section entitled "History", and its title, and add to
|
||||
it an item stating at least the title, year, new authors, and
|
||||
publisher of the Modified Version as given on the Title Page. If
|
||||
there is no section entitled "History" in the Document, create one
|
||||
stating the title, year, authors, and publisher of the Document as
|
||||
given on its Title Page, then add an item describing the Modified
|
||||
Version as stated in the previous sentence.
|
||||
J. Preserve the network location, if any, given in the Document for
|
||||
public access to a Transparent copy of the Document, and likewise
|
||||
the network locations given in the Document for previous versions
|
||||
it was based on. These may be placed in the "History" section.
|
||||
You may omit a network location for a work that was published at
|
||||
least four years before the Document itself, or if the original
|
||||
publisher of the version it refers to gives permission.
|
||||
K. In any section entitled "Acknowledgements" or "Dedications",
|
||||
preserve the section's title, and preserve in the section all the
|
||||
substance and tone of each of the contributor acknowledgements
|
||||
and/or dedications given therein.
|
||||
L. Preserve all the Invariant Sections of the Document,
|
||||
unaltered in their text and in their titles. Section numbers
|
||||
or the equivalent are not considered part of the section titles.
|
||||
M. Delete any section entitled "Endorsements". Such a section
|
||||
may not be included in the Modified Version.
|
||||
N. Do not retitle any existing section as "Endorsements"
|
||||
or to conflict in title with any Invariant Section.
|
||||
|
||||
If the Modified Version includes new front-matter sections or
|
||||
appendices that qualify as Secondary Sections and contain no material
|
||||
copied from the Document, you may at your option designate some or all
|
||||
of these sections as invariant. To do this, add their titles to the
|
||||
list of Invariant Sections in the Modified Version's license notice.
|
||||
These titles must be distinct from any other section titles.
|
||||
|
||||
You may add a section entitled "Endorsements", provided it contains
|
||||
nothing but endorsements of your Modified Version by various
|
||||
parties--for example, statements of peer review or that the text has
|
||||
been approved by an organization as the authoritative definition of a
|
||||
standard.
|
||||
|
||||
You may add a passage of up to five words as a Front-Cover Text, and a
|
||||
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
||||
of Cover Texts in the Modified Version. Only one passage of
|
||||
Front-Cover Text and one of Back-Cover Text may be added by (or
|
||||
through arrangements made by) any one entity. If the Document already
|
||||
includes a cover text for the same cover, previously added by you or
|
||||
by arrangement made by the same entity you are acting on behalf of,
|
||||
you may not add another; but you may replace the old one, on explicit
|
||||
permission from the previous publisher that added the old one.
|
||||
|
||||
The author(s) and publisher(s) of the Document do not by this License
|
||||
give permission to use their names for publicity for or to assert or
|
||||
imply endorsement of any Modified Version.
|
||||
|
||||
|
||||
5. COMBINING DOCUMENTS
|
||||
|
||||
You may combine the Document with other documents released under this
|
||||
License, under the terms defined in section 4 above for modified
|
||||
versions, provided that you include in the combination all of the
|
||||
Invariant Sections of all of the original documents, unmodified, and
|
||||
list them all as Invariant Sections of your combined work in its
|
||||
license notice.
|
||||
|
||||
The combined work need only contain one copy of this License, and
|
||||
multiple identical Invariant Sections may be replaced with a single
|
||||
copy. If there are multiple Invariant Sections with the same name but
|
||||
different contents, make the title of each such section unique by
|
||||
adding at the end of it, in parentheses, the name of the original
|
||||
author or publisher of that section if known, or else a unique number.
|
||||
Make the same adjustment to the section titles in the list of
|
||||
Invariant Sections in the license notice of the combined work.
|
||||
|
||||
In the combination, you must combine any sections entitled "History"
|
||||
in the various original documents, forming one section entitled
|
||||
"History"; likewise combine any sections entitled "Acknowledgements",
|
||||
and any sections entitled "Dedications". You must delete all sections
|
||||
entitled "Endorsements."
|
||||
|
||||
|
||||
6. COLLECTIONS OF DOCUMENTS
|
||||
|
||||
You may make a collection consisting of the Document and other documents
|
||||
released under this License, and replace the individual copies of this
|
||||
License in the various documents with a single copy that is included in
|
||||
the collection, provided that you follow the rules of this License for
|
||||
verbatim copying of each of the documents in all other respects.
|
||||
|
||||
You may extract a single document from such a collection, and distribute
|
||||
it individually under this License, provided you insert a copy of this
|
||||
License into the extracted document, and follow this License in all
|
||||
other respects regarding verbatim copying of that document.
|
||||
|
||||
|
||||
7. AGGREGATION WITH INDEPENDENT WORKS
|
||||
|
||||
A compilation of the Document or its derivatives with other separate
|
||||
and independent documents or works, in or on a volume of a storage or
|
||||
distribution medium, does not as a whole count as a Modified Version
|
||||
of the Document, provided no compilation copyright is claimed for the
|
||||
compilation. Such a compilation is called an "aggregate", and this
|
||||
License does not apply to the other self-contained works thus compiled
|
||||
with the Document, on account of their being thus compiled, if they
|
||||
are not themselves derivative works of the Document.
|
||||
|
||||
If the Cover Text requirement of section 3 is applicable to these
|
||||
copies of the Document, then if the Document is less than one quarter
|
||||
of the entire aggregate, the Document's Cover Texts may be placed on
|
||||
covers that surround only the Document within the aggregate.
|
||||
Otherwise they must appear on covers around the whole aggregate.
|
||||
|
||||
|
||||
8. TRANSLATION
|
||||
|
||||
Translation is considered a kind of modification, so you may
|
||||
distribute translations of the Document under the terms of section 4.
|
||||
Replacing Invariant Sections with translations requires special
|
||||
permission from their copyright holders, but you may include
|
||||
translations of some or all Invariant Sections in addition to the
|
||||
original versions of these Invariant Sections. You may include a
|
||||
translation of this License provided that you also include the
|
||||
original English version of this License. In case of a disagreement
|
||||
between the translation and the original English version of this
|
||||
License, the original English version will prevail.
|
||||
|
||||
|
||||
9. TERMINATION
|
||||
|
||||
You may not copy, modify, sublicense, or distribute the Document except
|
||||
as expressly provided for under this License. Any other attempt to
|
||||
copy, modify, sublicense or distribute the Document is void, and will
|
||||
automatically terminate your rights under this License. However,
|
||||
parties who have received copies, or rights, from you under this
|
||||
License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
|
||||
10. FUTURE REVISIONS OF THIS LICENSE
|
||||
|
||||
The Free Software Foundation may publish new, revised versions
|
||||
of the GNU Free Documentation License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns. See
|
||||
http://www.gnu.org/copyleft/.
|
||||
|
||||
Each version of the License is given a distinguishing version number.
|
||||
If the Document specifies that a particular numbered version of this
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that specified version or
|
||||
of any later version that has been published (not as a draft) by the
|
||||
Free Software Foundation. If the Document does not specify a version
|
||||
number of this License, you may choose any version ever published (not
|
||||
as a draft) by the Free Software Foundation.
|
||||
|
||||
|
||||
ADDENDUM: How to use this License for your documents
|
||||
|
||||
To use this License in a document you have written, include a copy of
|
||||
the License in the document and put the following copyright and
|
||||
license notices just after the title page:
|
||||
|
||||
Copyright (c) YEAR YOUR NAME.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with the Invariant Sections being LIST THEIR TITLES, with the
|
||||
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
If you have no Invariant Sections, write "with no Invariant Sections"
|
||||
instead of saying which ones are invariant. If you have no
|
||||
Front-Cover Texts, write "no Front-Cover Texts" instead of
|
||||
"Front-Cover Texts being LIST"; likewise for Back-Cover Texts.
|
||||
|
||||
If your document contains nontrivial examples of program code, we
|
||||
recommend releasing these examples in parallel under your choice of
|
||||
free software license, such as the GNU General Public License,
|
||||
to permit their use in free software.
|
||||
165
libguile/lightening/COPYING.LESSER
Normal file
165
libguile/lightening/COPYING.LESSER
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
17
libguile/lightening/ChangeLog
Normal file
17
libguile/lightening/ChangeLog
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
-*- text -*-
|
||||
|
||||
Starting from October 30, 2018, the Lightening project no longer stores
|
||||
change logs in `ChangeLog' files. Instead, changes are detailed in the
|
||||
version control system's logs. They can be seen by downloading a copy
|
||||
of the Git repository:
|
||||
|
||||
$ git clone https://gitlab.com/wingo/lightening
|
||||
$ git log
|
||||
|
||||
Alternatively, they can be seen on the web, using the Gitweb interface
|
||||
at:
|
||||
|
||||
https://gitlab.com/wingo/lightening
|
||||
|
||||
Change logs from upstream GNU Lightning are still available in
|
||||
ChangeLog.lightning.
|
||||
4018
libguile/lightening/ChangeLog.lightning
Normal file
4018
libguile/lightening/ChangeLog.lightning
Normal file
File diff suppressed because it is too large
Load diff
199
libguile/lightening/NEWS
Normal file
199
libguile/lightening/NEWS
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
NEWS FROM 1.99 TO 1.99a
|
||||
|
||||
o Lightning now builds and pass all test cases on AIX 7.1 powerpc,
|
||||
HP-UX 11iv2 hppa, HP-UX 11iv3 ia64, Solaris 10 Sparc, Solaris 11
|
||||
x86_64, and Irix 6.5.30 mips (using n32 abi).
|
||||
|
||||
NEWS FROM VERSION 1.3 TO 1.99
|
||||
|
||||
o The 1.99 version is a major lightning redesign and an
|
||||
alpha version.
|
||||
|
||||
o Unless for some special power users usage, the major
|
||||
difference in the rework is that now function calls push
|
||||
arguments from left to right, what is both, more natural for
|
||||
programers, and also more natural to implement for architectures
|
||||
that pass arguments in registers and have alignment constraints,
|
||||
usually for 64 bit double arguments.
|
||||
|
||||
o Add mips backend, implementing the o32 abi.
|
||||
|
||||
o Added arm backend implementing all combinations of software float,
|
||||
vfp, neon, arm and thumb instruction sets, softfp and hardp abis,
|
||||
armv5, armv6, and armv7.
|
||||
|
||||
o Added sse2+ code generation for the 32 bit x86 backend.
|
||||
|
||||
o Added sse3 and sse4.x optional code generation for the 64 bit
|
||||
x86 backend, code generation based on detected cpu.
|
||||
|
||||
o Reworked and added full lightning instruction set to ppc 32;
|
||||
tested on ppc64 hardware and Darwin 32 operating system.
|
||||
|
||||
o Added ppc64 backend, built and tested on Fedora ppc.
|
||||
|
||||
o Reworked the sparc backend, built and tested on Debian sparc.
|
||||
|
||||
o Added an ia64 backend, built and tested on Debian ia64.
|
||||
|
||||
o Added an hppa backend, built and tested on Debian hppa.
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 1.2 TO 1.3
|
||||
|
||||
o Initial support for x86-64 back-end (mostly untested).
|
||||
|
||||
o lightning is more strict on casts from integer to pointer.
|
||||
Be sure to use the _p variants when your immediates are
|
||||
of pointer type. This was done to ease 64-bit cleanliness
|
||||
tests.
|
||||
|
||||
o Many bug fixes.
|
||||
|
||||
o JIT_FPRET is used as JIT_RET to move return values.
|
||||
jit_retval_[fd] is used to retrieve return values.
|
||||
|
||||
o jit_pushr/jit_popr are deprecated, you need to #define
|
||||
JIT_NEED_PUSH_POP prior to including lightning.h if you
|
||||
want to use them.
|
||||
|
||||
o Support for stack-allocated variables. Because of this,
|
||||
backends defining JIT_FP should now rename it to JIT_AP.
|
||||
JIT_FP is now a user-visible register used in ldxi/ldxr
|
||||
to access stack-allocated variables.
|
||||
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 1.1.2 TO 1.2
|
||||
|
||||
o Floating-point interface rewritten, uses a register file
|
||||
architecture rather than a stack.
|
||||
|
||||
o Many bug fixes.
|
||||
|
||||
o jit_prepare and jit_retval are now jit_prepare_i and
|
||||
jit_retval_i.
|
||||
|
||||
o Support for Fedora Core 1's exec-shield feature.
|
||||
|
||||
o PPC supports both SysV and Darwin ABIs.
|
||||
|
||||
o More (and more complete) examples provided.
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 1.1.1 TO 1.1.2
|
||||
|
||||
o This release fixes the bugs in PowerPC cache flushing and in
|
||||
SPARC testing.
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 1.1 TO 1.1.1
|
||||
|
||||
o Merge changes from Debian
|
||||
|
||||
This version was released to have a distributable version of lightning
|
||||
after the recent crack of the GNU FTP machines. It does not fix
|
||||
outstanding bugs; I apologize for the inconvenience.
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 1.0 TO 1.1
|
||||
|
||||
o Several bug fixes
|
||||
|
||||
o improved infrastructure for embedding GNU lightning (lightningize
|
||||
script)
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.99 TO 1.0
|
||||
|
||||
o SPARC backend tested on GNU Smalltalk
|
||||
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.98 TO 0.99
|
||||
|
||||
o Added floating point function support (thanks to Laurent Michel);
|
||||
unfortunately this broke even more the PPC and SPARC floating point
|
||||
stuff :-(
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.97 to 0.98
|
||||
|
||||
o PPC backend tested on GNU Smalltalk
|
||||
|
||||
o switched to autoconf 2.50
|
||||
|
||||
o new (much faster) PPC cache flushing code by John McIntosh
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.96 to 0.97
|
||||
|
||||
o support for cross-assembling and for disassembling the code that the tests
|
||||
generate
|
||||
|
||||
o PPC microtests pass (tested directly by me), SPARC was said to work
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.95 to 0.96
|
||||
|
||||
o fixed implementation of delay slots to be coherent with the manual
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.94 to 0.95
|
||||
|
||||
o adc/sbc replaced with addc/addx/subc/subx to allow for more optimization
|
||||
(inspired by the PPC instruction set).
|
||||
|
||||
o A few fixes and much less warnings from the compiler
|
||||
|
||||
o Automake-ized everything
|
||||
|
||||
o i386 backend generates smaller code for bms/bmc/or/xor by using byte
|
||||
or word versions if possible
|
||||
|
||||
o Moved backends to separate directories
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.93 to 0.94
|
||||
|
||||
o Manual builds as DVI file.
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.92 to 0.93
|
||||
|
||||
o Floating-point front-end (began supporting PPC & SPARC).
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.91 to 0.92
|
||||
|
||||
o Floating-point front-end (only x86 supported).
|
||||
|
||||
---
|
||||
|
||||
NEWS FROM VERSION 0.9 to 0.91
|
||||
|
||||
o Carrying supported in addition/subtraction.
|
||||
|
||||
o insn type changed to jit_insn.
|
||||
|
||||
o Misc bug fixes.
|
||||
|
||||
o Reentrancy supported.
|
||||
|
||||
o SPARC run-time assembler rewritten.
|
||||
|
||||
o The run-time assembler can be disabled for debugging purposes.
|
||||
37
libguile/lightening/README.md
Normal file
37
libguile/lightening/README.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Lightening
|
||||
|
||||
Lightening is a just-in-time code generation library derived from GNU
|
||||
Lightning, adapted to the purposes of the GNU Guile project.
|
||||
|
||||
## Use
|
||||
|
||||
```
|
||||
gcc -flto -O2 -g -o lightening.o -c lightening/lightening.c
|
||||
gcc -flto -O2 -g -o my-program lightening.o my-program.c
|
||||
```
|
||||
|
||||
See the GNU Lightning manual for more on how to program against
|
||||
Lightening (much of the details are the same).
|
||||
|
||||
## What's the difference with GNU Lightning?
|
||||
|
||||
This project is called Lightening because it's lighter-weight than GNU
|
||||
Lightning. When you go to generate code at run-time with GNU Lightning,
|
||||
what happens is that you build up a graph of nodes which GNU Lightning
|
||||
"optimizes" before finally emitting machine code. These optimizations
|
||||
can improve register allocation around call sites. However they are not
|
||||
helpful from a Guile perspective, as they get in the way of register
|
||||
allocation that we need to do; and they actually prevent access to all
|
||||
the registers that we would like to have.
|
||||
|
||||
Guile needs a simple, light-weight code generation library. The GNU
|
||||
Lightning architecture-specific backends provide the bulk of this
|
||||
functionality, and Lightening wraps it all in a lightweight API.
|
||||
|
||||
## Status
|
||||
|
||||
Only the x86-64 port is currently usable. I plan to re-enable 32-bit
|
||||
x86 shortly, and then work on 32-bit and 64-bit ARM. Other
|
||||
architectures may come with time, but help is very much appreciated
|
||||
there. The test suite is still in progress but will be fairly
|
||||
comprehensive in terms of API surface.
|
||||
19
libguile/lightening/THANKS
Normal file
19
libguile/lightening/THANKS
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Thanks to all the following people for their help in
|
||||
improving GNU lightning:
|
||||
|
||||
Paolo Bonzini <bonzini@gnu.org>
|
||||
Eli Barzilay <eli@barzilay.org>
|
||||
Ludovic Courtes <ludo@chbouib.org>
|
||||
Matthew Flatt <mflatt@cs.utah.edu>
|
||||
Laurent Michel <ldm@thorgal.homelinux.org>
|
||||
Paulo Cesar Pereira de Andrade <pcpa@gnu.org>
|
||||
Mike Spivey <mike@comlab.ox.ac.uk>
|
||||
Basile Starynkevitch <basile@starynkevitch.net>
|
||||
Sam Steingold <sds@gnu.org>
|
||||
Jens Troeger <savage@light-speed.de>
|
||||
Tom Tromey <tromey@redhat.com>
|
||||
Trent Nelson <trent@snakebite.org>
|
||||
Vitaly Magerya <vmagerya@gmail.com>
|
||||
Brandon Invergo <brandon@gnu.org>
|
||||
Holger Hans Peter Freyther <holger@moiji-mobile.com>
|
||||
Jon Arintok <jon.arintok@gmail.com>
|
||||
80
libguile/lightening/lightening.am
Normal file
80
libguile/lightening/lightening.am
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# Copyright 2000, 2001, 2002, 2012-2019 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of Lightening.
|
||||
#
|
||||
# Lightening is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Lightening is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
# License for more details.
|
||||
#
|
||||
|
||||
lightening = $(top_srcdir)/libguile/lightening
|
||||
|
||||
lightening_c_files = \
|
||||
$(lightening)/lightening/lightening.c
|
||||
|
||||
lightening_extra_files = \
|
||||
$(lightening)/AUTHORS \
|
||||
$(lightening)/ChangeLog \
|
||||
$(lightening)/ChangeLog.lightening \
|
||||
$(lightening)/COPYING \
|
||||
$(lightening)/COPYING.DOC \
|
||||
$(lightening)/COPYING.LESSER \
|
||||
$(lightening)/lightening.am \
|
||||
$(lightening)/lightening.texi \
|
||||
$(lightening)/NEWS \
|
||||
$(lightening)/README.md \
|
||||
$(lightening)/THANKS \
|
||||
\
|
||||
$(lightening)/lightening.h \
|
||||
\
|
||||
$(lightening)/lightening/endian.h \
|
||||
\
|
||||
$(lightening)/lightening/arm.h \
|
||||
$(lightening)/lightening/mips.h \
|
||||
$(lightening)/lightening/ppc.h \
|
||||
$(lightening)/lightening/sparc.h \
|
||||
$(lightening)/lightening/x86.h \
|
||||
$(lightening)/lightening/ia64.h \
|
||||
$(lightening)/lightening/hppa.h \
|
||||
$(lightening)/lightening/aarch64.h \
|
||||
$(lightening)/lightening/s390.h \
|
||||
$(lightening)/lightening/alpha.h \
|
||||
\
|
||||
$(lightening)/lightening/aarch64.c \
|
||||
$(lightening)/lightening/aarch64-cpu.c \
|
||||
$(lightening)/lightening/aarch64-fpu.c \
|
||||
$(lightening)/lightening/alpha.c \
|
||||
$(lightening)/lightening/alpha-cpu.c \
|
||||
$(lightening)/lightening/alpha-fpu.c \
|
||||
$(lightening)/lightening/arm.c \
|
||||
$(lightening)/lightening/arm-cpu.c \
|
||||
$(lightening)/lightening/arm-swf.c \
|
||||
$(lightening)/lightening/arm-vfp.c \
|
||||
$(lightening)/lightening/hppa.c \
|
||||
$(lightening)/lightening/hppa-cpu.c \
|
||||
$(lightening)/lightening/hppa-fpu.c \
|
||||
$(lightening)/lightening/ia64.c \
|
||||
$(lightening)/lightening/ia64-cpu.c \
|
||||
$(lightening)/lightening/ia64-fpu.c \
|
||||
$(lightening)/lightening/mips.c \
|
||||
$(lightening)/lightening/mips-cpu.c \
|
||||
$(lightening)/lightening/mips-fpu.c \
|
||||
$(lightening)/lightening/ppc.c \
|
||||
$(lightening)/lightening/ppc-cpu.c \
|
||||
$(lightening)/lightening/ppc-fpu.c \
|
||||
$(lightening)/lightening/s390.c \
|
||||
$(lightening)/lightening/s390-cpu.c \
|
||||
$(lightening)/lightening/s390-fpu.c \
|
||||
$(lightening)/lightening/sparc.c \
|
||||
$(lightening)/lightening/sparc-cpu.c \
|
||||
$(lightening)/lightening/sparc-fpu.c \
|
||||
$(lightening)/lightening/x86.c \
|
||||
$(lightening)/lightening/x86-cpu.c \
|
||||
$(lightening)/lightening/x86-sse.c
|
||||
519
libguile/lightening/lightening.h
Normal file
519
libguile/lightening/lightening.h
Normal file
|
|
@ -0,0 +1,519 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
* Andy Wingo
|
||||
*/
|
||||
|
||||
#ifndef _jit_h
|
||||
#define _jit_h
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "lightening/endian.h"
|
||||
|
||||
CHOOSE_32_64(typedef int32_t jit_word_t,
|
||||
typedef int64_t jit_word_t);
|
||||
CHOOSE_32_64(typedef uint32_t jit_uword_t,
|
||||
typedef uint64_t jit_uword_t);
|
||||
typedef float jit_float32_t;
|
||||
typedef double jit_float64_t;
|
||||
typedef void* jit_pointer_t;
|
||||
typedef int jit_bool_t;
|
||||
typedef struct jit_gpr { int bits; } jit_gpr_t;
|
||||
typedef struct jit_fpr { int bits; } jit_fpr_t;
|
||||
|
||||
typedef void* jit_addr_t;
|
||||
typedef ptrdiff_t jit_off_t;
|
||||
typedef intptr_t jit_imm_t;
|
||||
typedef uintptr_t jit_uimm_t;
|
||||
|
||||
#define JIT_GPR(bits) ((jit_gpr_t) { bits })
|
||||
#define JIT_FPR(bits) ((jit_fpr_t) { bits })
|
||||
static inline jit_gpr_t jit_gpr(int bits) { return JIT_GPR(bits); }
|
||||
static inline jit_fpr_t jit_fpr(int bits) { return JIT_FPR(bits); }
|
||||
|
||||
enum jit_reloc_kind
|
||||
{
|
||||
JIT_RELOC_ABSOLUTE,
|
||||
JIT_RELOC_REL8,
|
||||
JIT_RELOC_REL16,
|
||||
JIT_RELOC_REL32,
|
||||
JIT_RELOC_REL64,
|
||||
};
|
||||
|
||||
typedef struct jit_reloc
|
||||
{
|
||||
uint8_t kind;
|
||||
uint8_t inst_start_offset;
|
||||
uint16_t flags;
|
||||
uint32_t offset;
|
||||
} jit_reloc_t;
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
# define JIT_API extern __attribute__ ((__visibility__("hidden")))
|
||||
#else
|
||||
# define JIT_API extern
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
# include "lightening/x86.h"
|
||||
#elif defined(__mips__)
|
||||
# include "lightening/mips.h"
|
||||
#elif defined(__arm__)
|
||||
# include "lightening/arm.h"
|
||||
#elif defined(__ppc__) || defined(__powerpc__)
|
||||
# include "lightening/ppc.h"
|
||||
#elif defined(__sparc__)
|
||||
# include "lightening/sparc.h"
|
||||
#elif defined(__ia64__)
|
||||
# include "lightening/ia64.h"
|
||||
#elif defined(__hppa__)
|
||||
# include "lightening/hppa.h"
|
||||
#elif defined(__aarch64__)
|
||||
# include "lightening/aarch64.h"
|
||||
#elif defined(__s390__) || defined(__s390x__)
|
||||
# include "lightening/s390.h"
|
||||
#elif defined(__alpha__)
|
||||
# include "lightening/alpha.h"
|
||||
#endif
|
||||
|
||||
#define JIT_R(index) JIT_GPR(jit_r(index))
|
||||
#define JIT_V(index) JIT_GPR(jit_v(index))
|
||||
#define JIT_F(index) JIT_FPR(jit_f(index))
|
||||
#define JIT_R_NUM jit_r_num()
|
||||
#define JIT_V_NUM jit_v_num()
|
||||
#define JIT_F_NUM jit_f_num()
|
||||
|
||||
#define jit_class_chk 0x02000000 /* just checking */
|
||||
#define jit_class_arg 0x08000000 /* argument register */
|
||||
#define jit_class_sav 0x10000000 /* callee save */
|
||||
#define jit_class_gpr 0x20000000 /* general purpose */
|
||||
#define jit_class_fpr 0x40000000 /* float */
|
||||
#define jit_class(bits) ((bits) & 0xffff0000)
|
||||
#define jit_regno(bits) ((bits) & 0x00007fff)
|
||||
|
||||
typedef struct jit_state jit_state_t;
|
||||
enum jit_arg_loc
|
||||
{
|
||||
JIT_ARG_LOC_IMM,
|
||||
JIT_ARG_LOC_GPR,
|
||||
JIT_ARG_LOC_FPR,
|
||||
JIT_ARG_LOC_MEM
|
||||
};
|
||||
|
||||
typedef enum jit_arg_abi
|
||||
{
|
||||
JIT_ARG_ABI_UINT8,
|
||||
JIT_ARG_ABI_INT8,
|
||||
JIT_ARG_ABI_UINT16,
|
||||
JIT_ARG_ABI_INT16,
|
||||
JIT_ARG_ABI_UINT32,
|
||||
JIT_ARG_ABI_INT32,
|
||||
JIT_ARG_ABI_UINT64,
|
||||
JIT_ARG_ABI_INT64,
|
||||
JIT_ARG_ABI_POINTER,
|
||||
JIT_ARG_ABI_FLOAT,
|
||||
JIT_ARG_ABI_DOUBLE,
|
||||
JIT_ARG_ABI_INTMAX = CHOOSE_32_64(JIT_ARG_ABI_INT32, JIT_ARG_ABI_INT64)
|
||||
} jit_arg_abi_t;
|
||||
|
||||
typedef struct jit_arg
|
||||
{
|
||||
enum jit_arg_loc kind;
|
||||
union
|
||||
{
|
||||
intptr_t imm;
|
||||
jit_gpr_t gpr;
|
||||
jit_fpr_t fpr;
|
||||
struct { jit_gpr_t base; ptrdiff_t offset; } mem;
|
||||
} loc;
|
||||
} jit_arg_t;
|
||||
|
||||
typedef union jit_anyreg
|
||||
{
|
||||
jit_gpr_t gpr;
|
||||
jit_fpr_t fpr;
|
||||
} jit_anyreg_t;
|
||||
|
||||
JIT_API jit_bool_t init_jit(void);
|
||||
|
||||
JIT_API jit_state_t *jit_new_state(void);
|
||||
JIT_API void jit_destroy_state(jit_state_t*);
|
||||
|
||||
JIT_API void jit_begin(jit_state_t*, uint8_t*, size_t);
|
||||
JIT_API jit_bool_t jit_has_overflow(jit_state_t*);
|
||||
JIT_API void jit_reset(jit_state_t*);
|
||||
JIT_API void* jit_end(jit_state_t*, size_t*);
|
||||
|
||||
JIT_API void jit_align(jit_state_t*, unsigned);
|
||||
|
||||
JIT_API jit_pointer_t jit_address(jit_state_t*);
|
||||
JIT_API void jit_patch_here(jit_state_t*, jit_reloc_t);
|
||||
JIT_API void jit_patch_there(jit_state_t*, jit_reloc_t, jit_pointer_t);
|
||||
|
||||
/* Note that all functions that take jit_arg_t args[] use the args as scratch
|
||||
space while shuffling values into position. */
|
||||
JIT_API void jit_calli(jit_state_t *, jit_pointer_t f,
|
||||
size_t argc, const jit_arg_abi_t abi[],
|
||||
jit_arg_t args[]);
|
||||
JIT_API void jit_callr(jit_state_t *, jit_gpr_t f,
|
||||
size_t argc, const jit_arg_abi_t abi[],
|
||||
jit_arg_t args[]);
|
||||
JIT_API void jit_receive(jit_state_t*, size_t argc,
|
||||
const jit_arg_abi_t abi[], jit_arg_t args[]);
|
||||
JIT_API void jit_load_args(jit_state_t *_jit, size_t argc,
|
||||
const jit_arg_abi_t abi[], jit_arg_t args[],
|
||||
const jit_anyreg_t regs[]);
|
||||
|
||||
#define JIT_PROTO_0(stem, ret) \
|
||||
ret jit_##stem (jit_state_t* _jit)
|
||||
#define JIT_PROTO_1(stem, ret, ta) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a)
|
||||
#define JIT_PROTO_2(stem, ret, ta, tb) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a, jit_##tb##_t b)
|
||||
#define JIT_PROTO_3(stem, ret, ta, tb, tc) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a, jit_##tb##_t b, jit_##tc##_t c)
|
||||
#define JIT_PROTO_4(stem, ret, ta, tb, tc, td) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a, jit_##tb##_t b, jit_##tc##_t c, jit_##td##_t d)
|
||||
|
||||
#define JIT_PROTO_RFF__(stem) JIT_PROTO_2(stem, jit_reloc_t, fpr, fpr)
|
||||
#define JIT_PROTO_RGG__(stem) JIT_PROTO_2(stem, jit_reloc_t, gpr, gpr)
|
||||
#define JIT_PROTO_RG___(stem) JIT_PROTO_1(stem, jit_reloc_t, gpr)
|
||||
#define JIT_PROTO_RGi__(stem) JIT_PROTO_2(stem, jit_reloc_t, gpr, imm)
|
||||
#define JIT_PROTO_RGu__(stem) JIT_PROTO_2(stem, jit_reloc_t, gpr, uimm)
|
||||
#define JIT_PROTO_R____(stem) JIT_PROTO_0(stem, jit_reloc_t)
|
||||
#define JIT_PROTO__FFF_(stem) JIT_PROTO_3(stem, void, fpr, fpr, fpr)
|
||||
#define JIT_PROTO__FF__(stem) JIT_PROTO_2(stem, void, fpr, fpr)
|
||||
#define JIT_PROTO__FGG_(stem) JIT_PROTO_3(stem, void, fpr, gpr, gpr)
|
||||
#define JIT_PROTO__FG__(stem) JIT_PROTO_2(stem, void, fpr, gpr)
|
||||
#define JIT_PROTO__FGo_(stem) JIT_PROTO_3(stem, void, fpr, gpr, off)
|
||||
#define JIT_PROTO__F___(stem) JIT_PROTO_1(stem, void, fpr)
|
||||
#define JIT_PROTO__Fd__(stem) JIT_PROTO_2(stem, void, fpr, float64)
|
||||
#define JIT_PROTO__Ff__(stem) JIT_PROTO_2(stem, void, fpr, float32)
|
||||
#define JIT_PROTO__Fp__(stem) JIT_PROTO_2(stem, void, fpr, pointer)
|
||||
#define JIT_PROTO__GF__(stem) JIT_PROTO_2(stem, void, gpr, fpr)
|
||||
#define JIT_PROTO__GGF_(stem) JIT_PROTO_3(stem, void, gpr, gpr, fpr)
|
||||
#define JIT_PROTO__GGGG(stem) JIT_PROTO_4(stem, void, gpr, gpr, gpr, gpr)
|
||||
#define JIT_PROTO__GGG_(stem) JIT_PROTO_3(stem, void, gpr, gpr, gpr)
|
||||
#define JIT_PROTO__GGGi(stem) JIT_PROTO_4(stem, void, gpr, gpr, gpr, imm)
|
||||
#define JIT_PROTO__GGGu(stem) JIT_PROTO_4(stem, void, gpr, gpr, gpr, uimm)
|
||||
#define JIT_PROTO__GG__(stem) JIT_PROTO_2(stem, void, gpr, gpr)
|
||||
#define JIT_PROTO__GGi_(stem) JIT_PROTO_3(stem, void, gpr, gpr, imm)
|
||||
#define JIT_PROTO__GGo_(stem) JIT_PROTO_3(stem, void, gpr, gpr, off)
|
||||
#define JIT_PROTO__GGu_(stem) JIT_PROTO_3(stem, void, gpr, gpr, uimm)
|
||||
#define JIT_PROTO__G___(stem) JIT_PROTO_1(stem, void, gpr)
|
||||
#define JIT_PROTO__Gi__(stem) JIT_PROTO_2(stem, void, gpr, imm)
|
||||
#define JIT_PROTO__Gp__(stem) JIT_PROTO_2(stem, void, gpr, pointer)
|
||||
#define JIT_PROTO______(stem) JIT_PROTO_0(stem, void)
|
||||
#define JIT_PROTO__i___(stem) JIT_PROTO_1(stem, void, imm)
|
||||
#define JIT_PROTO__oGF_(stem) JIT_PROTO_3(stem, void, off, gpr, fpr)
|
||||
#define JIT_PROTO__oGG_(stem) JIT_PROTO_3(stem, void, off, gpr, gpr)
|
||||
#define JIT_PROTO__pF__(stem) JIT_PROTO_2(stem, void, pointer, fpr)
|
||||
#define JIT_PROTO__pG__(stem) JIT_PROTO_2(stem, void, pointer, gpr)
|
||||
#define JIT_PROTO__p___(stem) JIT_PROTO_1(stem, void, pointer)
|
||||
|
||||
#define FOR_EACH_INSTRUCTION(M) \
|
||||
M(_GGG_, addr) \
|
||||
M(_FFF_, addr_f) \
|
||||
M(_FFF_, addr_d) \
|
||||
M(_GGi_, addi) \
|
||||
M(_GGG_, addcr) \
|
||||
M(_GGi_, addci) \
|
||||
M(_GGG_, addxr) \
|
||||
M(_GGi_, addxi) \
|
||||
M(_GGG_, subr) \
|
||||
M(_FFF_, subr_f) \
|
||||
M(_FFF_, subr_d) \
|
||||
M(_GGi_, subi) \
|
||||
M(_GGG_, subcr) \
|
||||
M(_GGi_, subci) \
|
||||
M(_GGG_, subxr) \
|
||||
M(_GGi_, subxi) \
|
||||
M(_GGG_, mulr) \
|
||||
M(_FFF_, mulr_f) \
|
||||
M(_FFF_, mulr_d) \
|
||||
M(_GGi_, muli) \
|
||||
M(_GGGG, qmulr) \
|
||||
M(_GGGi, qmuli) \
|
||||
M(_GGGG, qmulr_u) \
|
||||
M(_GGGu, qmuli_u) \
|
||||
M(_GGG_, divr) \
|
||||
M(_FFF_, divr_f) \
|
||||
M(_FFF_, divr_d) \
|
||||
M(_GGi_, divi) \
|
||||
M(_GGG_, divr_u) \
|
||||
M(_GGu_, divi_u) \
|
||||
M(_GGGG, qdivr) \
|
||||
M(_GGGi, qdivi) \
|
||||
M(_GGGG, qdivr_u) \
|
||||
M(_GGGu, qdivi_u) \
|
||||
M(_GGG_, remr) \
|
||||
M(_GGi_, remi) \
|
||||
M(_GGG_, remr_u) \
|
||||
M(_GGu_, remi_u) \
|
||||
\
|
||||
M(_GGG_, andr) \
|
||||
M(_GGu_, andi) \
|
||||
M(_GGG_, orr) \
|
||||
M(_GGu_, ori) \
|
||||
M(_GGG_, xorr) \
|
||||
M(_GGu_, xori) \
|
||||
\
|
||||
M(_GGG_, lshr) \
|
||||
M(_GGu_, lshi) \
|
||||
M(_GGG_, rshr) \
|
||||
M(_GGu_, rshi) \
|
||||
M(_GGG_, rshr_u) \
|
||||
M(_GGu_, rshi_u) \
|
||||
\
|
||||
M(_GG__, negr) \
|
||||
M(_GG__, comr) \
|
||||
\
|
||||
M(_GG__, movr) \
|
||||
M(_Gi__, movi) \
|
||||
M(RG___, mov_addr) \
|
||||
M(_GG__, extr_c) \
|
||||
M(_GG__, extr_uc) \
|
||||
M(_GG__, extr_s) \
|
||||
M(_GG__, extr_us) \
|
||||
WHEN_64(M(_GG__, extr_i)) \
|
||||
WHEN_64(M(_GG__, extr_ui)) \
|
||||
\
|
||||
M(_GG__, bswapr_us) \
|
||||
M(_GG__, bswapr_ui) \
|
||||
WHEN_64(M(_GG__, bswapr_ul)) \
|
||||
\
|
||||
M(_GG__, ldr_c) \
|
||||
M(_Gp__, ldi_c) \
|
||||
M(_GG__, ldr_uc) \
|
||||
M(_Gp__, ldi_uc) \
|
||||
M(_GG__, ldr_s) \
|
||||
M(_Gp__, ldi_s) \
|
||||
M(_GG__, ldr_us) \
|
||||
M(_Gp__, ldi_us) \
|
||||
M(_GG__, ldr_i) \
|
||||
M(_Gp__, ldi_i) \
|
||||
WHEN_64(M(_GG__, ldr_ui)) \
|
||||
WHEN_64(M(_Gp__, ldi_ui)) \
|
||||
WHEN_64(M(_GG__, ldr_l)) \
|
||||
WHEN_64(M(_Gp__, ldi_l)) \
|
||||
M(_FG__, ldr_f) \
|
||||
M(_Fp__, ldi_f) \
|
||||
M(_FG__, ldr_d) \
|
||||
M(_Fp__, ldi_d) \
|
||||
\
|
||||
M(_GGG_, ldxr_c) \
|
||||
M(_GGo_, ldxi_c) \
|
||||
M(_GGG_, ldxr_uc) \
|
||||
M(_GGo_, ldxi_uc) \
|
||||
M(_GGG_, ldxr_s) \
|
||||
M(_GGo_, ldxi_s) \
|
||||
M(_GGG_, ldxr_us) \
|
||||
M(_GGo_, ldxi_us) \
|
||||
M(_GGG_, ldxr_i) \
|
||||
M(_GGo_, ldxi_i) \
|
||||
WHEN_64(M(_GGG_, ldxr_ui)) \
|
||||
WHEN_64(M(_GGo_, ldxi_ui)) \
|
||||
WHEN_64(M(_GGG_, ldxr_l)) \
|
||||
WHEN_64(M(_GGo_, ldxi_l)) \
|
||||
M(_FGG_, ldxr_f) \
|
||||
M(_FGo_, ldxi_f) \
|
||||
M(_FGG_, ldxr_d) \
|
||||
M(_FGo_, ldxi_d) \
|
||||
\
|
||||
M(_GG__, str_c) \
|
||||
M(_pG__, sti_c) \
|
||||
M(_GG__, str_s) \
|
||||
M(_pG__, sti_s) \
|
||||
M(_GG__, str_i) \
|
||||
M(_pG__, sti_i) \
|
||||
WHEN_64(M(_GG__, str_l)) \
|
||||
WHEN_64(M(_pG__, sti_l)) \
|
||||
M(_GF__, str_f) \
|
||||
M(_pF__, sti_f) \
|
||||
M(_GF__, str_d) \
|
||||
M(_pF__, sti_d) \
|
||||
\
|
||||
M(_GGG_, stxr_c) \
|
||||
M(_oGG_, stxi_c) \
|
||||
M(_GGG_, stxr_s) \
|
||||
M(_oGG_, stxi_s) \
|
||||
M(_GGG_, stxr_i) \
|
||||
M(_oGG_, stxi_i) \
|
||||
WHEN_64(M(_GGG_, stxr_l)) \
|
||||
WHEN_64(M(_oGG_, stxi_l)) \
|
||||
M(_GGF_, stxr_f) \
|
||||
M(_oGF_, stxi_f) \
|
||||
M(_GGF_, stxr_d) \
|
||||
M(_oGF_, stxi_d) \
|
||||
\
|
||||
M(RGG__, bltr) \
|
||||
M(RFF__, bltr_f) \
|
||||
M(RFF__, bltr_d) \
|
||||
M(RGi__, blti) \
|
||||
M(RGG__, bltr_u) \
|
||||
M(RGu__, blti_u) \
|
||||
M(RGG__, bler) \
|
||||
M(RFF__, bler_f) \
|
||||
M(RFF__, bler_d) \
|
||||
M(RGi__, blei) \
|
||||
M(RGG__, bler_u) \
|
||||
M(RGu__, blei_u) \
|
||||
M(RGG__, beqr) \
|
||||
M(RFF__, beqr_f) \
|
||||
M(RFF__, beqr_d) \
|
||||
M(RGi__, beqi) \
|
||||
M(RGG__, bger) \
|
||||
M(RFF__, bger_f) \
|
||||
M(RFF__, bger_d) \
|
||||
M(RGi__, bgei) \
|
||||
M(RGG__, bger_u) \
|
||||
M(RGu__, bgei_u) \
|
||||
M(RGG__, bgtr) \
|
||||
M(RFF__, bgtr_f) \
|
||||
M(RFF__, bgtr_d) \
|
||||
M(RGi__, bgti) \
|
||||
M(RGG__, bgtr_u) \
|
||||
M(RGu__, bgti_u) \
|
||||
M(RGG__, bner) \
|
||||
M(RFF__, bner_f) \
|
||||
M(RFF__, bner_d) \
|
||||
M(RGi__, bnei) \
|
||||
\
|
||||
M(RFF__, bunltr_f) \
|
||||
M(RFF__, bunltr_d) \
|
||||
M(RFF__, bunler_f) \
|
||||
M(RFF__, bunler_d) \
|
||||
M(RFF__, buneqr_f) \
|
||||
M(RFF__, buneqr_d) \
|
||||
M(RFF__, bunger_f) \
|
||||
M(RFF__, bunger_d) \
|
||||
M(RFF__, bungtr_f) \
|
||||
M(RFF__, bungtr_d) \
|
||||
M(RFF__, bltgtr_f) \
|
||||
M(RFF__, bltgtr_d) \
|
||||
M(RFF__, bordr_f) \
|
||||
M(RFF__, bordr_d) \
|
||||
M(RFF__, bunordr_f) \
|
||||
M(RFF__, bunordr_d) \
|
||||
\
|
||||
M(RGG__, bmsr) \
|
||||
M(RGu__, bmsi) \
|
||||
M(RGG__, bmcr) \
|
||||
M(RGu__, bmci) \
|
||||
\
|
||||
M(RGG__, boaddr) \
|
||||
M(RGi__, boaddi) \
|
||||
M(RGG__, boaddr_u) \
|
||||
M(RGu__, boaddi_u) \
|
||||
M(RGG__, bxaddr) \
|
||||
M(RGi__, bxaddi) \
|
||||
M(RGG__, bxaddr_u) \
|
||||
M(RGu__, bxaddi_u) \
|
||||
M(RGG__, bosubr) \
|
||||
M(RGi__, bosubi) \
|
||||
M(RGG__, bosubr_u) \
|
||||
M(RGu__, bosubi_u) \
|
||||
M(RGG__, bxsubr) \
|
||||
M(RGi__, bxsubi) \
|
||||
M(RGG__, bxsubr_u) \
|
||||
M(RGu__, bxsubi_u) \
|
||||
\
|
||||
M(_i___, nop) \
|
||||
\
|
||||
M(_G___, jmpr) \
|
||||
M(_p___, jmpi) \
|
||||
M(R____, jmp) \
|
||||
\
|
||||
M(_G___, pushr) \
|
||||
M(_F___, pushr_d) \
|
||||
M(_G___, popr) \
|
||||
M(_F___, popr_d) \
|
||||
\
|
||||
M(_____, ret) \
|
||||
M(_G___, retr) \
|
||||
M(_F___, retr_f) \
|
||||
M(_F___, retr_d) \
|
||||
M(_i___, reti) \
|
||||
M(_G___, retval_c) \
|
||||
M(_G___, retval_uc) \
|
||||
M(_G___, retval_s) \
|
||||
M(_G___, retval_us) \
|
||||
M(_G___, retval_i) \
|
||||
WHEN_64(M(_G___, retval_ui)) \
|
||||
WHEN_64(M(_G___, retval_l)) \
|
||||
M(_F___, retval_f) \
|
||||
M(_F___, retval_d) \
|
||||
\
|
||||
M(_FF__, negr_f) \
|
||||
M(_FF__, negr_d) \
|
||||
M(_FF__, absr_f) \
|
||||
M(_FF__, absr_d) \
|
||||
M(_FF__, sqrtr_f) \
|
||||
M(_FF__, sqrtr_d) \
|
||||
\
|
||||
M(_GF__, truncr_f_i) \
|
||||
M(_FG__, extr_f) \
|
||||
M(_FG__, extr_d) \
|
||||
M(_FF__, extr_d_f) \
|
||||
M(_FF__, extr_f_d) \
|
||||
M(_FF__, movr_f) \
|
||||
M(_FF__, movr_d) \
|
||||
M(_Ff__, movi_f) \
|
||||
M(_Fd__, movi_d) \
|
||||
M(_GF__, truncr_d_i) \
|
||||
WHEN_64(M(_GF__, truncr_f_l)) \
|
||||
WHEN_64(M(_GF__, truncr_d_l)) \
|
||||
/* EOL */
|
||||
|
||||
#define DECLARE_INSTRUCTION(kind, stem) JIT_API JIT_PROTO_##kind(stem);
|
||||
FOR_EACH_INSTRUCTION(DECLARE_INSTRUCTION)
|
||||
#undef DECLARE_INSTRUCTION
|
||||
|
||||
#if __WORDSIZE == 32
|
||||
# define jit_ldr(j,u,v) jit_ldr_i(j,u,v)
|
||||
# define jit_ldi(j,u,v) jit_ldi_i(j,u,v)
|
||||
# define jit_ldxr(j,u,v,w) jit_ldxr_i(j,u,v,w)
|
||||
# define jit_ldxi(j,u,v,w) jit_ldxi_i(j,u,v,w)
|
||||
# define jit_str(j,u,v) jit_str_i(j,u,v)
|
||||
# define jit_sti(j,u,v) jit_sti_i(j,u,v)
|
||||
# define jit_stxr(j,u,v,w) jit_stxr_i(j,u,v,w)
|
||||
# define jit_stxi(j,u,v,w) jit_stxi_i(j,u,v,w)
|
||||
# define jit_retval(j,u) jit_retval_i(j,u)
|
||||
# define jit_bswapr(j,u,v) jit_bswapr_ui(j,u,v)
|
||||
# define jit_truncr_d(j,u,v) jit_truncr_d_i(j,u,v)
|
||||
# define jit_truncr_f(j,u,v) jit_truncr_f_i(j,u,v)
|
||||
#else
|
||||
# define jit_ldr(j,u,v) jit_ldr_l(j,u,v)
|
||||
# define jit_ldi(j,u,v) jit_ldi_l(j,u,v)
|
||||
# define jit_ldxr(j,u,v,w) jit_ldxr_l(j,u,v,w)
|
||||
# define jit_ldxi(j,u,v,w) jit_ldxi_l(j,u,v,w)
|
||||
# define jit_str(j,u,v) jit_str_l(j,u,v)
|
||||
# define jit_sti(j,u,v) jit_sti_l(j,u,v)
|
||||
# define jit_stxr(j,u,v,w) jit_stxr_l(j,u,v,w)
|
||||
# define jit_stxi(j,u,v,w) jit_stxi_l(j,u,v,w)
|
||||
# define jit_retval(j,u) jit_retval_l(j,u)
|
||||
# define jit_bswapr(j,u,v) jit_bswapr_ul(j,u,v)
|
||||
# define jit_truncr_d(j,u,v) jit_truncr_d_l(j,u,v)
|
||||
# define jit_truncr_f(j,u,v) jit_truncr_f_l(j,u,v)
|
||||
#endif
|
||||
|
||||
#endif /* _jit_h */
|
||||
2446
libguile/lightening/lightening/aarch64-cpu.c
Normal file
2446
libguile/lightening/lightening/aarch64-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
914
libguile/lightening/lightening/aarch64-fpu.c
Normal file
914
libguile/lightening/lightening/aarch64-fpu.c
Normal file
|
|
@ -0,0 +1,914 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#if PROTO
|
||||
# define A64_SCVTF 0x1e220000
|
||||
# define A64_FMOVWV 0x1e260000
|
||||
# define A64_FMOVVW 0x1e270000
|
||||
# define A64_FMOVXV 0x9e260000
|
||||
# define A64_FMOVVX 0x9e270000
|
||||
# define A64_FCVTZS 0x1e380000
|
||||
# define A64_FCMPE 0x1e202010
|
||||
# define A64_FMOV 0x1e204000
|
||||
# define A64_FABS 0x1e20c000
|
||||
# define A64_FNEG 0x1e214000
|
||||
# define A64_FSQRT 0x1e21c000
|
||||
# define A64_FCVTS 0x1e224000
|
||||
# define A64_FCVTD 0x1e22c000
|
||||
# define A64_FMUL 0x1e200800
|
||||
# define A64_FDIV 0x1e201800
|
||||
# define A64_FADD 0x1e202800
|
||||
# define A64_FSUB 0x1e203800
|
||||
# define FCMPES(Rn,Rm) os_vv(A64_FCMPE,0,Rn,Rm)
|
||||
# define FCMPED(Rn,Rm) os_vv(A64_FCMPE,1,Rn,Rm)
|
||||
# define FMOVS(Rd,Rn) osvv_(A64_FMOV,0,Rd,Rn)
|
||||
# define FMOVD(Rd,Rn) osvv_(A64_FMOV,1,Rd,Rn)
|
||||
# define FMOVWS(Rd,Rn) osvv_(A64_FMOVWV,0,Rd,Rn)
|
||||
# define FMOVSW(Rd,Rn) osvv_(A64_FMOVVW,0,Rd,Rn)
|
||||
# define FMOVXD(Rd,Rn) osvv_(A64_FMOVXV,1,Rd,Rn)
|
||||
# define FMOVDX(Rd,Rn) osvv_(A64_FMOVVX,1,Rd,Rn)
|
||||
# define FCVT_SD(Rd,Rn) osvv_(A64_FCVTS,1,Rd,Rn)
|
||||
# define FCVT_DS(Rd,Rn) osvv_(A64_FCVTD,0,Rd,Rn)
|
||||
# define SCVTFS(Rd,Rn) osvv_(A64_SCVTF|XS,0,Rd,Rn)
|
||||
# define SCVTFD(Rd,Rn) osvv_(A64_SCVTF|XS,1,Rd,Rn)
|
||||
# define FCVTSZ_WS(Rd,Rn) osvv_(A64_FCVTZS,0,Rd,Rn)
|
||||
# define FCVTSZ_WD(Rd,Rn) osvv_(A64_FCVTZS,1,Rd,Rn)
|
||||
# define FCVTSZ_XS(Rd,Rn) osvv_(A64_FCVTZS|XS,0,Rd,Rn)
|
||||
# define FCVTSZ_XD(Rd,Rn) osvv_(A64_FCVTZS|XS,1,Rd,Rn)
|
||||
# define FABSS(Rd,Rn) osvv_(A64_FABS,0,Rd,Rn)
|
||||
# define FABSD(Rd,Rn) osvv_(A64_FABS,1,Rd,Rn)
|
||||
# define FNEGS(Rd,Rn) osvv_(A64_FNEG,0,Rd,Rn)
|
||||
# define FNEGD(Rd,Rn) osvv_(A64_FNEG,1,Rd,Rn)
|
||||
# define FSQRTS(Rd,Rn) osvv_(A64_FSQRT,0,Rd,Rn)
|
||||
# define FSQRTD(Rd,Rn) osvv_(A64_FSQRT,1,Rd,Rn)
|
||||
# define FADDS(Rd,Rn,Rm) osvvv(A64_FADD,0,Rd,Rn,Rm)
|
||||
# define FADDD(Rd,Rn,Rm) osvvv(A64_FADD,1,Rd,Rn,Rm)
|
||||
# define FSUBS(Rd,Rn,Rm) osvvv(A64_FSUB,0,Rd,Rn,Rm)
|
||||
# define FSUBD(Rd,Rn,Rm) osvvv(A64_FSUB,1,Rd,Rn,Rm)
|
||||
# define FMULS(Rd,Rn,Rm) osvvv(A64_FMUL,0,Rd,Rn,Rm)
|
||||
# define FMULD(Rd,Rn,Rm) osvvv(A64_FMUL,1,Rd,Rn,Rm)
|
||||
# define FDIVS(Rd,Rn,Rm) osvvv(A64_FDIV,0,Rd,Rn,Rm)
|
||||
# define FDIVD(Rd,Rn,Rm) osvvv(A64_FDIV,1,Rd,Rn,Rm)
|
||||
# define osvvv(Op,Sz,Rd,Rn,Rm) _osvvv(_jit,Op,Sz,Rd,Rn,Rm)
|
||||
static void _osvvv(jit_state_t*,int32_t,int32_t,
|
||||
int32_t,int32_t,int32_t);
|
||||
# define osvv_(Op,Sz,Rd,Rn) _osvv_(_jit,Op,Sz,Rd,Rn)
|
||||
static void _osvv_(jit_state_t*,int32_t,
|
||||
int32_t,int32_t,int32_t);
|
||||
# define os_vv(Op,Sz,Rn,Rm) _os_vv(_jit,Op,Sz,Rn,Rm)
|
||||
static void _os_vv(jit_state_t*,int32_t,
|
||||
int32_t,int32_t,int32_t);
|
||||
# define truncr_f_i(r0,r1) _truncr_f_i(_jit,r0,r1)
|
||||
static void _truncr_f_i(jit_state_t*,int32_t,int32_t);
|
||||
# define truncr_f_l(r0,r1) FCVTSZ_XS(r0,r1)
|
||||
# define truncr_d_i(r0,r1) _truncr_d_i(_jit,r0,r1)
|
||||
static void _truncr_d_i(jit_state_t*,int32_t,int32_t);
|
||||
# define truncr_d_l(r0,r1) FCVTSZ_XD(r0,r1)
|
||||
# define addr_f(r0,r1,r2) FADDS(r0,r1,r2)
|
||||
# define addi_f(r0,r1,i0) _addi_f(_jit,r0,r1,i0)
|
||||
static void _addi_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define subr_f(r0,r1,r2) FSUBS(r0,r1,r2)
|
||||
# define subi_f(r0,r1,i0) _subi_f(_jit,r0,r1,i0)
|
||||
static void _subi_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define rsbr_f(r0, r1, r2) subr_f(r0, r2, r1)
|
||||
# define rsbi_f(r0, r1, i0) _rsbi_f(_jit, r0, r1, i0)
|
||||
static void _rsbi_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define mulr_f(r0,r1,r2) FMULS(r0,r1,r2)
|
||||
# define muli_f(r0,r1,i0) _muli_f(_jit,r0,r1,i0)
|
||||
static void _muli_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define divr_f(r0,r1,r2) FDIVS(r0,r1,r2)
|
||||
# define divi_f(r0,r1,i0) _divi_f(_jit,r0,r1,i0)
|
||||
static void _divi_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define absr_f(r0,r1) FABSS(r0,r1)
|
||||
# define negr_f(r0,r1) FNEGS(r0,r1)
|
||||
# define sqrtr_f(r0,r1) FSQRTS(r0,r1)
|
||||
# define extr_f(r0,r1) SCVTFS(r0,r1)
|
||||
# define ldr_f(r0,r1) _ldr_f(_jit,r0,r1)
|
||||
static void _ldr_f(jit_state_t*,int32_t,int32_t);
|
||||
# define ldi_f(r0,i0) _ldi_f(_jit,r0,i0)
|
||||
static void _ldi_f(jit_state_t*,int32_t,jit_word_t);
|
||||
# define ldxr_f(r0,r1,r2) _ldxr_f(_jit,r0,r1,r2)
|
||||
static void _ldxr_f(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define ldxi_f(r0,r1,i0) _ldxi_f(_jit,r0,r1,i0)
|
||||
static void _ldxi_f(jit_state_t*,int32_t,int32_t,jit_word_t);
|
||||
# define str_f(r0,r1) _str_f(_jit,r0,r1)
|
||||
static void _str_f(jit_state_t*,int32_t,int32_t);
|
||||
# define sti_f(i0,r0) _sti_f(_jit,i0,r0)
|
||||
static void _sti_f(jit_state_t*,jit_word_t,int32_t);
|
||||
# define stxr_f(r0,r1,r2) _stxr_f(_jit,r0,r1,r2)
|
||||
static void _stxr_f(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define stxi_f(i0,r0,r1) _stxi_f(_jit,i0,r0,r1)
|
||||
static void _stxi_f(jit_state_t*,jit_word_t,int32_t,int32_t);
|
||||
# define movr_f(r0,r1) _movr_f(_jit,r0,r1)
|
||||
static void _movr_f(jit_state_t*,int32_t,int32_t);
|
||||
# define movi_f(r0,i0) _movi_f(_jit,r0,i0)
|
||||
static void _movi_f(jit_state_t*,int32_t,jit_float32_t);
|
||||
# define extr_d_f(r0,r1) FCVT_SD(r0,r1)
|
||||
# define fccr(cc,r0,r1,r2) _fccr(_jit,cc,r0,r1,r2)
|
||||
static void _fccr(jit_state_t*,int32_t,int32_t,int32_t,int32_t);
|
||||
# define fcci(cc,r0,r1,i0) _fcci(_jit,cc,r0,r1,i0)
|
||||
static void _fcci(jit_state_t*,
|
||||
int32_t,int32_t,int32_t,jit_float32_t);
|
||||
# define ltr_f(r0,r1,r2) fccr(CC_MI,r0,r1,r2)
|
||||
# define lti_f(r0,r1,i0) fcci(CC_MI,r0,r1,i0)
|
||||
# define ler_f(r0,r1,r2) fccr(CC_LS,r0,r1,r2)
|
||||
# define lei_f(r0,r1,i0) fcci(CC_LS,r0,r1,i0)
|
||||
# define eqr_f(r0,r1,r2) fccr(CC_EQ,r0,r1,r2)
|
||||
# define eqi_f(r0,r1,i0) fcci(CC_EQ,r0,r1,i0)
|
||||
# define ger_f(r0,r1,r2) fccr(CC_GE,r0,r1,r2)
|
||||
# define gei_f(r0,r1,i0) fcci(CC_GE,r0,r1,i0)
|
||||
# define gtr_f(r0,r1,r2) fccr(CC_GT,r0,r1,r2)
|
||||
# define gti_f(r0,r1,i0) fcci(CC_GT,r0,r1,i0)
|
||||
# define ner_f(r0,r1,r2) fccr(CC_NE,r0,r1,r2)
|
||||
# define nei_f(r0,r1,i0) fcci(CC_NE,r0,r1,i0)
|
||||
# define unltr_f(r0,r1,r2) fccr(CC_LT,r0,r1,r2)
|
||||
# define unlti_f(r0,r1,i0) fcci(CC_LT,r0,r1,i0)
|
||||
# define unler_f(r0,r1,r2) fccr(CC_LE,r0,r1,r2)
|
||||
# define unlei_f(r0,r1,i0) fcci(CC_LE,r0,r1,i0)
|
||||
# define uneqr_f(r0,r1,r2) _uneqr_f(_jit,r0,r1,r2)
|
||||
static void _uneqr_f(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define uneqi_f(r0,r1,i0) _uneqi_f(_jit,r0,r1,i0)
|
||||
static void _uneqi_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define unger_f(r0,r1,r2) fccr(CC_PL,r0,r1,r2)
|
||||
# define ungei_f(r0,r1,i0) fcci(CC_PL,r0,r1,i0)
|
||||
# define ungtr_f(r0,r1,r2) fccr(CC_HI,r0,r1,r2)
|
||||
# define ungti_f(r0,r1,i0) fcci(CC_HI,r0,r1,i0)
|
||||
# define ltgtr_f(r0,r1,r2) _ltgtr_f(_jit,r0,r1,r2)
|
||||
static void _ltgtr_f(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define ltgti_f(r0,r1,i0) _ltgti_f(_jit,r0,r1,i0)
|
||||
static void _ltgti_f(jit_state_t*,int32_t,int32_t,jit_float32_t);
|
||||
# define ordr_f(r0,r1,r2) fccr(CC_VC,r0,r1,r2)
|
||||
# define ordi_f(r0,r1,i0) fcci(CC_VC,r0,r1,i0)
|
||||
# define unordr_f(r0,r1,r2) fccr(CC_VS,r0,r1,r2)
|
||||
# define unordi_f(r0,r1,i0) fcci(CC_VS,r0,r1,i0)
|
||||
#define fbccr(cc,i0,r0,r1) _fbccr(_jit,cc,i0,r0,r1)
|
||||
static jit_word_t
|
||||
_fbccr(jit_state_t*,int32_t,jit_word_t,int32_t,int32_t);
|
||||
#define fbcci(cc,i0,r0,i1) _fbcci(_jit,cc,i0,r0,i1)
|
||||
static jit_word_t
|
||||
_fbcci(jit_state_t*,int32_t,jit_word_t,int32_t,jit_float32_t);
|
||||
# define bltr_f(i0,r0,r1) fbccr(BCC_MI,i0,r0,r1)
|
||||
# define blti_f(i0,r0,i1) fbcci(BCC_MI,i0,r0,i1)
|
||||
# define bler_f(i0,r0,r1) fbccr(BCC_LS,i0,r0,r1)
|
||||
# define blei_f(i0,r0,i1) fbcci(BCC_LS,i0,r0,i1)
|
||||
# define beqr_f(i0,r0,r1) fbccr(BCC_EQ,i0,r0,r1)
|
||||
# define beqi_f(i0,r0,i1) fbcci(BCC_EQ,i0,r0,i1)
|
||||
# define bger_f(i0,r0,r1) fbccr(BCC_GE,i0,r0,r1)
|
||||
# define bgei_f(i0,r0,i1) fbcci(BCC_GE,i0,r0,i1)
|
||||
# define bgtr_f(i0,r0,r1) fbccr(BCC_GT,i0,r0,r1)
|
||||
# define bgti_f(i0,r0,i1) fbcci(BCC_GT,i0,r0,i1)
|
||||
# define bner_f(i0,r0,r1) fbccr(BCC_NE,i0,r0,r1)
|
||||
# define bnei_f(i0,r0,i1) fbcci(BCC_NE,i0,r0,i1)
|
||||
# define bunltr_f(i0,r0,r1) fbccr(BCC_LT,i0,r0,r1)
|
||||
# define bunlti_f(i0,r0,i1) fbcci(BCC_LT,i0,r0,i1)
|
||||
# define bunler_f(i0,r0,r1) fbccr(BCC_LE,i0,r0,r1)
|
||||
# define bunlei_f(i0,r0,i1) fbcci(BCC_LE,i0,r0,i1)
|
||||
# define buneqr_f(i0,r0,r1) _buneqr_f(_jit,i0,r0,r1)
|
||||
static jit_word_t _buneqr_f(jit_state_t*,jit_word_t,int32_t,int32_t);
|
||||
# define buneqi_f(i0,r0,i1) _buneqi_f(_jit,i0,r0,i1)
|
||||
static jit_word_t _buneqi_f(jit_state_t*,jit_word_t,int32_t,jit_float32_t);
|
||||
# define bunger_f(i0,r0,r1) fbccr(BCC_PL,i0,r0,r1)
|
||||
# define bungei_f(i0,r0,i1) fbcci(BCC_PL,i0,r0,i1)
|
||||
# define bungtr_f(i0,r0,r1) fbccr(BCC_HI,i0,r0,r1)
|
||||
# define bungti_f(i0,r0,i1) fbcci(BCC_HI,i0,r0,i1)
|
||||
# define bltgtr_f(i0,r0,r1) _bltgtr_f(_jit,i0,r0,r1)
|
||||
static jit_word_t _bltgtr_f(jit_state_t*,jit_word_t,int32_t,int32_t);
|
||||
# define bltgti_f(i0,r0,i1) _bltgti_f(_jit,i0,r0,i1)
|
||||
static jit_word_t _bltgti_f(jit_state_t*,jit_word_t,int32_t,jit_float32_t);
|
||||
# define bordr_f(i0,r0,r1) fbccr(BCC_VC,i0,r0,r1)
|
||||
# define bordi_f(i0,r0,i1) fbcci(BCC_VC,i0,r0,i1)
|
||||
# define bunordr_f(i0,r0,r1) fbccr(BCC_VS,i0,r0,r1)
|
||||
# define bunordi_f(i0,r0,i1) fbcci(BCC_VS,i0,r0,i1)
|
||||
# define addr_d(r0,r1,r2) FADDD(r0,r1,r2)
|
||||
# define addi_d(r0,r1,i0) _addi_d(_jit,r0,r1,i0)
|
||||
static void _addi_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define subr_d(r0,r1,r2) FSUBD(r0,r1,r2)
|
||||
# define subi_d(r0,r1,i0) _subi_d(_jit,r0,r1,i0)
|
||||
static void _subi_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define rsbr_d(r0, r1, r2) subr_d(r0, r2, r1)
|
||||
# define rsbi_d(r0, r1, i0) _rsbi_d(_jit, r0, r1, i0)
|
||||
static void _rsbi_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define mulr_d(r0,r1,r2) FMULD(r0,r1,r2)
|
||||
# define muli_d(r0,r1,i0) _muli_d(_jit,r0,r1,i0)
|
||||
static void _muli_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define divr_d(r0,r1,r2) FDIVD(r0,r1,r2)
|
||||
# define divi_d(r0,r1,i0) _divi_d(_jit,r0,r1,i0)
|
||||
static void _divi_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define absr_d(r0,r1) FABSD(r0,r1)
|
||||
# define negr_d(r0,r1) FNEGD(r0,r1)
|
||||
# define sqrtr_d(r0,r1) FSQRTD(r0,r1)
|
||||
# define extr_d(r0,r1) SCVTFD(r0,r1)
|
||||
# define ldr_d(r0,r1) _ldr_d(_jit,r0,r1)
|
||||
static void _ldr_d(jit_state_t*,int32_t,int32_t);
|
||||
# define ldi_d(r0,i0) _ldi_d(_jit,r0,i0)
|
||||
static void _ldi_d(jit_state_t*,int32_t,jit_word_t);
|
||||
# define ldxr_d(r0,r1,r2) _ldxr_d(_jit,r0,r1,r2)
|
||||
static void _ldxr_d(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define ldxi_d(r0,r1,i0) _ldxi_d(_jit,r0,r1,i0)
|
||||
static void _ldxi_d(jit_state_t*,int32_t,int32_t,jit_word_t);
|
||||
# define str_d(r0,r1) _str_d(_jit,r0,r1)
|
||||
static void _str_d(jit_state_t*,int32_t,int32_t);
|
||||
# define sti_d(i0,r0) _sti_d(_jit,i0,r0)
|
||||
static void _sti_d(jit_state_t*,jit_word_t,int32_t);
|
||||
# define stxr_d(r0,r1,r2) _stxr_d(_jit,r0,r1,r2)
|
||||
static void _stxr_d(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define stxi_d(i0,r0,r1) _stxi_d(_jit,i0,r0,r1)
|
||||
static void _stxi_d(jit_state_t*,jit_word_t,int32_t,int32_t);
|
||||
# define movr_d(r0,r1) _movr_d(_jit,r0,r1)
|
||||
static void _movr_d(jit_state_t*,int32_t,int32_t);
|
||||
# define movi_d(r0,i0) _movi_d(_jit,r0,i0)
|
||||
static void _movi_d(jit_state_t*,int32_t,jit_float64_t);
|
||||
# define extr_f_d(r0,r1) FCVT_DS(r0,r1)
|
||||
# define dccr(cc,r0,r1,r2) _dccr(_jit,cc,r0,r1,r2)
|
||||
static void _dccr(jit_state_t*,int32_t,int32_t,int32_t,int32_t);
|
||||
# define dcci(cc,r0,r1,i0) _dcci(_jit,cc,r0,r1,i0)
|
||||
static void _dcci(jit_state_t*,
|
||||
int32_t,int32_t,int32_t,jit_float64_t);
|
||||
# define ltr_d(r0,r1,r2) dccr(CC_MI,r0,r1,r2)
|
||||
# define lti_d(r0,r1,i0) dcci(CC_MI,r0,r1,i0)
|
||||
# define ler_d(r0,r1,r2) dccr(CC_LS,r0,r1,r2)
|
||||
# define lei_d(r0,r1,i0) dcci(CC_LS,r0,r1,i0)
|
||||
# define eqr_d(r0,r1,r2) dccr(CC_EQ,r0,r1,r2)
|
||||
# define eqi_d(r0,r1,i0) dcci(CC_EQ,r0,r1,i0)
|
||||
# define ger_d(r0,r1,r2) dccr(CC_GE,r0,r1,r2)
|
||||
# define gei_d(r0,r1,i0) dcci(CC_GE,r0,r1,i0)
|
||||
# define gtr_d(r0,r1,r2) dccr(CC_GT,r0,r1,r2)
|
||||
# define gti_d(r0,r1,i0) dcci(CC_GT,r0,r1,i0)
|
||||
# define ner_d(r0,r1,r2) dccr(CC_NE,r0,r1,r2)
|
||||
# define nei_d(r0,r1,i0) dcci(CC_NE,r0,r1,i0)
|
||||
# define unltr_d(r0,r1,r2) dccr(CC_LT,r0,r1,r2)
|
||||
# define unlti_d(r0,r1,i0) dcci(CC_LT,r0,r1,i0)
|
||||
# define unler_d(r0,r1,r2) dccr(CC_LE,r0,r1,r2)
|
||||
# define unlei_d(r0,r1,i0) dcci(CC_LE,r0,r1,i0)
|
||||
# define uneqr_d(r0,r1,r2) _uneqr_d(_jit,r0,r1,r2)
|
||||
static void _uneqr_d(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define uneqi_d(r0,r1,i0) _uneqi_d(_jit,r0,r1,i0)
|
||||
static void _uneqi_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define unger_d(r0,r1,r2) dccr(CC_PL,r0,r1,r2)
|
||||
# define ungei_d(r0,r1,i0) dcci(CC_PL,r0,r1,i0)
|
||||
# define ungtr_d(r0,r1,r2) dccr(CC_HI,r0,r1,r2)
|
||||
# define ungti_d(r0,r1,i0) dcci(CC_HI,r0,r1,i0)
|
||||
# define ltgtr_d(r0,r1,r2) _ltgtr_d(_jit,r0,r1,r2)
|
||||
static void _ltgtr_d(jit_state_t*,int32_t,int32_t,int32_t);
|
||||
# define ltgti_d(r0,r1,i0) _ltgti_d(_jit,r0,r1,i0)
|
||||
static void _ltgti_d(jit_state_t*,int32_t,int32_t,jit_float64_t);
|
||||
# define ordr_d(r0,r1,r2) dccr(CC_VC,r0,r1,r2)
|
||||
# define ordi_d(r0,r1,i0) dcci(CC_VC,r0,r1,i0)
|
||||
# define unordr_d(r0,r1,r2) dccr(CC_VS,r0,r1,r2)
|
||||
# define unordi_d(r0,r1,i0) dcci(CC_VS,r0,r1,i0)
|
||||
#define dbccr(cc,i0,r0,r1) _dbccr(_jit,cc,i0,r0,r1)
|
||||
static jit_word_t
|
||||
_dbccr(jit_state_t*,int32_t,jit_word_t,int32_t,int32_t);
|
||||
#define dbcci(cc,i0,r0,i1) _dbcci(_jit,cc,i0,r0,i1)
|
||||
static jit_word_t
|
||||
_dbcci(jit_state_t*,int32_t,jit_word_t,int32_t,jit_float64_t);
|
||||
# define bltr_d(i0,r0,r1) dbccr(BCC_MI,i0,r0,r1)
|
||||
# define blti_d(i0,r0,i1) dbcci(BCC_MI,i0,r0,i1)
|
||||
# define bler_d(i0,r0,r1) dbccr(BCC_LS,i0,r0,r1)
|
||||
# define blei_d(i0,r0,i1) dbcci(BCC_LS,i0,r0,i1)
|
||||
# define beqr_d(i0,r0,r1) dbccr(BCC_EQ,i0,r0,r1)
|
||||
# define beqi_d(i0,r0,i1) dbcci(BCC_EQ,i0,r0,i1)
|
||||
# define bger_d(i0,r0,r1) dbccr(BCC_GE,i0,r0,r1)
|
||||
# define bgei_d(i0,r0,i1) dbcci(BCC_GE,i0,r0,i1)
|
||||
# define bgtr_d(i0,r0,r1) dbccr(BCC_GT,i0,r0,r1)
|
||||
# define bgti_d(i0,r0,i1) dbcci(BCC_GT,i0,r0,i1)
|
||||
# define bner_d(i0,r0,r1) dbccr(BCC_NE,i0,r0,r1)
|
||||
# define bnei_d(i0,r0,i1) dbcci(BCC_NE,i0,r0,i1)
|
||||
# define bunltr_d(i0,r0,r1) dbccr(BCC_LT,i0,r0,r1)
|
||||
# define bunlti_d(i0,r0,i1) dbcci(BCC_LT,i0,r0,i1)
|
||||
# define bunler_d(i0,r0,r1) dbccr(BCC_LE,i0,r0,r1)
|
||||
# define bunlei_d(i0,r0,i1) dbcci(BCC_LE,i0,r0,i1)
|
||||
# define buneqr_d(i0,r0,r1) _buneqr_d(_jit,i0,r0,r1)
|
||||
static jit_word_t _buneqr_d(jit_state_t*,jit_word_t,int32_t,int32_t);
|
||||
# define buneqi_d(i0,r0,i1) _buneqi_d(_jit,i0,r0,i1)
|
||||
static jit_word_t _buneqi_d(jit_state_t*,jit_word_t,int32_t,jit_float64_t);
|
||||
# define bunger_d(i0,r0,r1) dbccr(BCC_PL,i0,r0,r1)
|
||||
# define bungei_d(i0,r0,i1) dbcci(BCC_PL,i0,r0,i1)
|
||||
# define bungtr_d(i0,r0,r1) dbccr(BCC_HI,i0,r0,r1)
|
||||
# define bungti_d(i0,r0,i1) dbcci(BCC_HI,i0,r0,i1)
|
||||
# define bltgtr_d(i0,r0,r1) _bltgtr_d(_jit,i0,r0,r1)
|
||||
static jit_word_t _bltgtr_d(jit_state_t*,jit_word_t,int32_t,int32_t);
|
||||
# define bltgti_d(i0,r0,i1) _bltgti_d(_jit,i0,r0,i1)
|
||||
static jit_word_t _bltgti_d(jit_state_t*,jit_word_t,int32_t,jit_float64_t);
|
||||
# define bordr_d(i0,r0,r1) dbccr(BCC_VC,i0,r0,r1)
|
||||
# define bordi_d(i0,r0,i1) dbcci(BCC_VC,i0,r0,i1)
|
||||
# define bunordr_d(i0,r0,r1) dbccr(BCC_VS,i0,r0,r1)
|
||||
# define bunordi_d(i0,r0,i1) dbcci(BCC_VS,i0,r0,i1)
|
||||
# define vaarg_d(r0, r1) _vaarg_d(_jit, r0, r1)
|
||||
static void _vaarg_d(jit_state_t*, int32_t, int32_t);
|
||||
#endif
|
||||
|
||||
#if CODE
|
||||
static void
|
||||
_osvvv(jit_state_t *_jit, int32_t Op, int32_t Sz,
|
||||
int32_t Rd, int32_t Rn, int32_t Rm)
|
||||
{
|
||||
instr_t i;
|
||||
assert(!(Rd & ~0x1f));
|
||||
assert(!(Rn & ~0x1f));
|
||||
assert(!(Rm & ~0x1f));
|
||||
assert(!(Sz & ~0x3));
|
||||
assert(!(Op & ~0xffe0fc00));
|
||||
i.w = Op;
|
||||
i.size.b = Sz;
|
||||
i.Rd.b = Rd;
|
||||
i.Rn.b = Rn;
|
||||
i.Rm.b = Rm;
|
||||
ii(i.w);
|
||||
}
|
||||
|
||||
static void
|
||||
_osvv_(jit_state_t *_jit, int32_t Op,
|
||||
int32_t Sz, int32_t Rd, int32_t Rn)
|
||||
{
|
||||
instr_t i;
|
||||
assert(!(Rd & ~0x1f));
|
||||
assert(!(Rn & ~0x1f));
|
||||
assert(!(Sz & ~0x3));
|
||||
assert(!(Op & ~0xfffffc00));
|
||||
i.w = Op;
|
||||
i.size.b = Sz;
|
||||
i.Rd.b = Rd;
|
||||
i.Rn.b = Rn;
|
||||
ii(i.w);
|
||||
}
|
||||
|
||||
static void
|
||||
_os_vv(jit_state_t *_jit, int32_t Op,
|
||||
int32_t Sz, int32_t Rn, int32_t Rm)
|
||||
{
|
||||
instr_t i;
|
||||
assert(!(Rn & ~0x1f));
|
||||
assert(!(Rm & ~0x1f));
|
||||
assert(!(Sz & ~0x3));
|
||||
assert(!(Op & ~0xff20fc1f));
|
||||
i.w = Op;
|
||||
i.size.b = Sz;
|
||||
i.Rn.b = Rn;
|
||||
i.Rm.b = Rm;
|
||||
ii(i.w);
|
||||
}
|
||||
|
||||
#define fopi(name) \
|
||||
static void \
|
||||
_##name##i_f(jit_state_t *_jit, \
|
||||
int32_t r0, int32_t r1, jit_float32_t i0) \
|
||||
{ \
|
||||
int32_t reg = jit_get_reg(jit_class_fpr); \
|
||||
movi_f(rn(reg), i0); \
|
||||
name##r_f(r0, r1, rn(reg)); \
|
||||
jit_unget_reg(reg); \
|
||||
}
|
||||
#define dopi(name) \
|
||||
static void \
|
||||
_##name##i_d(jit_state_t *_jit, \
|
||||
int32_t r0, int32_t r1, jit_float64_t i0) \
|
||||
{ \
|
||||
int32_t reg = jit_get_reg(jit_class_fpr); \
|
||||
movi_d(rn(reg), i0); \
|
||||
name##r_d(r0, r1, rn(reg)); \
|
||||
jit_unget_reg(reg); \
|
||||
}
|
||||
#define fbopi(name) \
|
||||
static jit_word_t \
|
||||
_b##name##i_f(jit_state_t *_jit, \
|
||||
jit_word_t i0, int32_t r0, jit_float32_t i1) \
|
||||
{ \
|
||||
jit_word_t word; \
|
||||
int32_t reg = jit_get_reg(jit_class_fpr| \
|
||||
jit_class_nospill); \
|
||||
movi_f(rn(reg), i1); \
|
||||
word = b##name##r_f(i0, r0, rn(reg)); \
|
||||
jit_unget_reg(reg); \
|
||||
return (word); \
|
||||
}
|
||||
#define dbopi(name) \
|
||||
static jit_word_t \
|
||||
_b##name##i_d(jit_state_t *_jit, \
|
||||
jit_word_t i0, int32_t r0, jit_float64_t i1) \
|
||||
{ \
|
||||
jit_word_t word; \
|
||||
int32_t reg = jit_get_reg(jit_class_fpr| \
|
||||
jit_class_nospill); \
|
||||
movi_d(rn(reg), i1); \
|
||||
word = b##name##r_d(i0, r0, rn(reg)); \
|
||||
jit_unget_reg(reg); \
|
||||
return (word); \
|
||||
}
|
||||
|
||||
static void
|
||||
_truncr_f_i(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
FCVTSZ_WS(r0, r1);
|
||||
extr_i(r0, r0);
|
||||
}
|
||||
|
||||
static void
|
||||
_truncr_d_i(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
FCVTSZ_WD(r0, r1);
|
||||
extr_i(r0, r0);
|
||||
}
|
||||
|
||||
fopi(add)
|
||||
fopi(sub)
|
||||
fopi(rsb)
|
||||
fopi(mul)
|
||||
fopi(div)
|
||||
|
||||
static void
|
||||
_ldr_f(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldr_i(rn(reg), r1);
|
||||
FMOVSW(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_ldi_f(jit_state_t *_jit, int32_t r0, jit_word_t i0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldi_i(rn(reg), i0);
|
||||
FMOVSW(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_ldxr_f(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldxr_i(rn(reg), r1, r2);
|
||||
FMOVSW(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_ldxi_f(jit_state_t *_jit, int32_t r0, int32_t r1, jit_word_t i0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldxi_i(rn(reg), r1, i0);
|
||||
FMOVSW(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_str_f(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVWS(rn(reg), r1);
|
||||
str_i(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_sti_f(jit_state_t *_jit, jit_word_t i0, int32_t r0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVWS(rn(reg), r0);
|
||||
sti_i(i0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_stxr_f(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVWS(rn(reg), r2);
|
||||
stxr_i(r0, r1, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_stxi_f(jit_state_t *_jit, jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVWS(rn(reg), r1);
|
||||
stxi_i(i0, r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_movr_f(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
if (r0 != r1)
|
||||
FMOVS(r0, r1);
|
||||
}
|
||||
|
||||
static void
|
||||
_movi_f(jit_state_t *_jit, int32_t r0, jit_float32_t i0)
|
||||
{
|
||||
union {
|
||||
int32_t i;
|
||||
jit_float32_t f;
|
||||
} u;
|
||||
int32_t reg;
|
||||
u.f = i0;
|
||||
if (u.i == 0)
|
||||
FMOVSW(r0, WZR_REGNO);
|
||||
else {
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
/* prevent generating unused top 32 bits */
|
||||
movi(rn(reg), ((jit_word_t)u.i) & 0xffffffff);
|
||||
FMOVSW(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_fccr(jit_state_t *_jit, int32_t cc,
|
||||
int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
FCMPES(r1, r2);
|
||||
CSET(r0, cc);
|
||||
}
|
||||
|
||||
static void
|
||||
_fcci(jit_state_t *_jit, int32_t cc,
|
||||
int32_t r0, int32_t r1, jit_float32_t i0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_fpr);
|
||||
movi_f(rn(reg), i0);
|
||||
fccr(cc, r0, r1, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_uneqr_f(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
jit_word_t w;
|
||||
FCMPES(r1, r2);
|
||||
CSET(r0, CC_VS);
|
||||
w = _jit->pc.w;
|
||||
B_C(BCC_VS, 1); /* unordered satisfies condition */
|
||||
CSET(r0, CC_EQ); /* equal satisfies condition */
|
||||
patch_at(w, _jit->pc.w);
|
||||
}
|
||||
fopi(uneq)
|
||||
|
||||
static void
|
||||
_ltgtr_f(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
jit_word_t w;
|
||||
FCMPES(r1, r2);
|
||||
CSET(r0, CC_VC); /* set to 1 if ordered */
|
||||
w = _jit->pc.w;
|
||||
B_C(BCC_VS, 1); /* unordered does not satisfy condition */
|
||||
CSET(r0, CC_NE); /* set to 1 if not equal */
|
||||
patch_at(w, _jit->pc.w);
|
||||
}
|
||||
fopi(ltgt)
|
||||
|
||||
static jit_word_t
|
||||
_fbccr(jit_state_t *_jit, int32_t cc,
|
||||
jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t w, d;
|
||||
FCMPES(r0, r1);
|
||||
w = _jit->pc.w;
|
||||
d = (i0 - w) >> 2;
|
||||
B_C(cc, d);
|
||||
return (w);
|
||||
}
|
||||
|
||||
static jit_word_t
|
||||
_fbcci(jit_state_t *_jit, int32_t cc,
|
||||
jit_word_t i0, int32_t r0, jit_float32_t i1)
|
||||
{
|
||||
jit_word_t w;
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_fpr|jit_class_nospill);
|
||||
movi_f(rn(reg), i1);
|
||||
w = fbccr(cc, i0, r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
return (w);
|
||||
}
|
||||
|
||||
static jit_word_t
|
||||
_buneqr_f(jit_state_t *_jit, jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t u, v, w;
|
||||
FCMPES(r0, r1);
|
||||
u = _jit->pc.w;
|
||||
B_C(BCC_VS, 1); /* unordered satisfies condition */
|
||||
v = _jit->pc.w;
|
||||
B_C(BCC_NE, 1); /* not equal (or unordered) does not satisfy */
|
||||
patch_at(u, _jit->pc.w);
|
||||
w = _jit->pc.w;
|
||||
B((i0 - w) >> 2);
|
||||
patch_at(v, _jit->pc.w);
|
||||
return (w);
|
||||
}
|
||||
fbopi(uneq)
|
||||
|
||||
static jit_word_t
|
||||
_bltgtr_f(jit_state_t *_jit, jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t u, v, w;
|
||||
FCMPES(r0, r1);
|
||||
u = _jit->pc.w;
|
||||
B_C(BCC_VS, 2); /* jump over if unordered */
|
||||
v = _jit->pc.w;
|
||||
B_C(BCC_EQ, 1); /* jump over if equal */
|
||||
w = _jit->pc.w;
|
||||
B((i0 - w) >> 2);
|
||||
patch_at(u, _jit->pc.w);
|
||||
patch_at(v, _jit->pc.w);
|
||||
return (w);
|
||||
}
|
||||
fbopi(ltgt)
|
||||
|
||||
dopi(add)
|
||||
dopi(sub)
|
||||
dopi(rsb)
|
||||
dopi(mul)
|
||||
dopi(div)
|
||||
|
||||
static void
|
||||
_ldr_d(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldr_l(rn(reg), r1);
|
||||
FMOVDX(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_ldi_d(jit_state_t *_jit, int32_t r0, jit_word_t i0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldi_l(rn(reg), i0);
|
||||
FMOVDX(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_ldxr_d(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldxr_l(rn(reg), r1, r2);
|
||||
FMOVDX(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_ldxi_d(jit_state_t *_jit, int32_t r0, int32_t r1, jit_word_t i0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
ldxi_l(rn(reg), r1, i0);
|
||||
FMOVDX(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_str_d(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVXD(rn(reg), r1);
|
||||
str_l(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_sti_d(jit_state_t *_jit, jit_word_t i0, int32_t r0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVXD(rn(reg), r0);
|
||||
sti_l(i0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_stxr_d(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVXD(rn(reg), r2);
|
||||
stxr_l(r0, r1, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_stxi_d(jit_state_t *_jit, jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
FMOVXD(rn(reg), r1);
|
||||
stxi_l(i0, r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_movr_d(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
if (r0 != r1)
|
||||
FMOVD(r0, r1);
|
||||
}
|
||||
|
||||
static void
|
||||
_movi_d(jit_state_t *_jit, int32_t r0, jit_float64_t i0)
|
||||
{
|
||||
union {
|
||||
int64_t l;
|
||||
jit_float64_t d;
|
||||
} u;
|
||||
int32_t reg;
|
||||
u.d = i0;
|
||||
if (u.l == 0)
|
||||
FMOVDX(r0, XZR_REGNO);
|
||||
else {
|
||||
reg = jit_get_reg(jit_class_gpr);
|
||||
movi(rn(reg), u.l);
|
||||
FMOVDX(r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_dccr(jit_state_t *_jit, int32_t cc,
|
||||
int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
FCMPED(r1, r2);
|
||||
CSET(r0, cc);
|
||||
}
|
||||
|
||||
static void
|
||||
_dcci(jit_state_t *_jit, int32_t cc,
|
||||
int32_t r0, int32_t r1, jit_float64_t i0)
|
||||
{
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_fpr);
|
||||
movi_d(rn(reg), i0);
|
||||
dccr(cc, r0, r1, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
}
|
||||
|
||||
static void
|
||||
_uneqr_d(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
jit_word_t w;
|
||||
FCMPED(r1, r2);
|
||||
CSET(r0, CC_VS);
|
||||
w = _jit->pc.w;
|
||||
B_C(BCC_VS, 1); /* unordered satisfies condition */
|
||||
CSET(r0, CC_EQ); /* equal satisfies condition */
|
||||
patch_at(w, _jit->pc.w);
|
||||
}
|
||||
dopi(uneq)
|
||||
|
||||
static void
|
||||
_ltgtr_d(jit_state_t *_jit, int32_t r0, int32_t r1, int32_t r2)
|
||||
{
|
||||
jit_word_t w;
|
||||
FCMPED(r1, r2);
|
||||
CSET(r0, CC_VC); /* set to 1 if ordered */
|
||||
w = _jit->pc.w;
|
||||
B_C(BCC_VS, 1); /* unordered does not satisfy condition */
|
||||
CSET(r0, CC_NE); /* set to 1 if not equal */
|
||||
patch_at(w, _jit->pc.w);
|
||||
}
|
||||
dopi(ltgt)
|
||||
|
||||
static jit_word_t
|
||||
_dbccr(jit_state_t *_jit, int32_t cc,
|
||||
jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t w, d;
|
||||
FCMPED(r0, r1);
|
||||
w = _jit->pc.w;
|
||||
d = (i0 - w) >> 2;
|
||||
B_C(cc, d);
|
||||
return (w);
|
||||
}
|
||||
|
||||
static jit_word_t
|
||||
_dbcci(jit_state_t *_jit, int32_t cc,
|
||||
jit_word_t i0, int32_t r0, jit_float64_t i1)
|
||||
{
|
||||
jit_word_t w;
|
||||
int32_t reg;
|
||||
reg = jit_get_reg(jit_class_fpr|jit_class_nospill);
|
||||
movi_d(rn(reg), i1);
|
||||
w = dbccr(cc, i0, r0, rn(reg));
|
||||
jit_unget_reg(reg);
|
||||
return (w);
|
||||
}
|
||||
|
||||
static jit_word_t
|
||||
_buneqr_d(jit_state_t *_jit, jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t u, v, w;
|
||||
FCMPED(r0, r1);
|
||||
u = _jit->pc.w;
|
||||
B_C(BCC_VS, 1); /* unordered satisfies condition */
|
||||
v = _jit->pc.w;
|
||||
B_C(BCC_NE, 1); /* not equal (or unordered) does not satisfy */
|
||||
patch_at(u, _jit->pc.w);
|
||||
w = _jit->pc.w;
|
||||
B((i0 - w) >> 2);
|
||||
patch_at(v, _jit->pc.w);
|
||||
return (w);
|
||||
}
|
||||
dbopi(uneq)
|
||||
|
||||
static jit_word_t
|
||||
_bltgtr_d(jit_state_t *_jit, jit_word_t i0, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t u, v, w;
|
||||
FCMPED(r0, r1);
|
||||
u = _jit->pc.w;
|
||||
B_C(BCC_VS, 2); /* jump over if unordered */
|
||||
v = _jit->pc.w;
|
||||
B_C(BCC_EQ, 1); /* jump over if equal */
|
||||
w = _jit->pc.w;
|
||||
B((i0 - w) >> 2);
|
||||
patch_at(u, _jit->pc.w);
|
||||
patch_at(v, _jit->pc.w);
|
||||
return (w);
|
||||
}
|
||||
dbopi(ltgt)
|
||||
|
||||
static void
|
||||
_vaarg_d(jit_state_t *_jit, int32_t r0, int32_t r1)
|
||||
{
|
||||
jit_word_t ge_code;
|
||||
jit_word_t lt_code;
|
||||
int32_t rg0, rg1;
|
||||
|
||||
assert(_jitc->function->self.call & jit_call_varargs);
|
||||
|
||||
rg0 = jit_get_reg(jit_class_gpr);
|
||||
rg1 = jit_get_reg(jit_class_gpr);
|
||||
|
||||
/* Load the fp offset in save area in the first temporary. */
|
||||
ldxi_i(rn(rg0), r1, offsetof(jit_va_list_t, fpoff));
|
||||
|
||||
/* Jump over if there are no remaining arguments in the save area. */
|
||||
ge_code = bgei(_jit->pc.w, rn(rg0), 0);
|
||||
|
||||
/* Load the gp save pointer in the second temporary. */
|
||||
ldxi(rn(rg1), r1, offsetof(jit_va_list_t, fptop));
|
||||
|
||||
/* Load the vararg argument in the first argument. */
|
||||
ldxr_d(r0, rn(rg1), rn(rg0));
|
||||
|
||||
/* Update the fp offset. */
|
||||
addi(rn(rg0), rn(rg0), 16);
|
||||
stxi_i(offsetof(jit_va_list_t, fpoff), r1, rn(rg0));
|
||||
|
||||
/* Will only need one temporary register below. */
|
||||
jit_unget_reg(rg1);
|
||||
|
||||
/* Jump over overflow code. */
|
||||
lt_code = jmpi_p(_jit->pc.w);
|
||||
|
||||
/* Where to land if argument is in overflow area. */
|
||||
patch_at(ge_code, _jit->pc.w);
|
||||
|
||||
/* Load stack pointer. */
|
||||
ldxi(rn(rg0), r1, offsetof(jit_va_list_t, stack));
|
||||
|
||||
/* Load argument. */
|
||||
ldr_d(r0, rn(rg0));
|
||||
|
||||
/* Update stack pointer. */
|
||||
addi(rn(rg0), rn(rg0), 8);
|
||||
stxi(offsetof(jit_va_list_t, stack), r1, rn(rg0));
|
||||
|
||||
/* Where to land if argument is in gp save area. */
|
||||
patch_at(lt_code, _jit->pc.w);
|
||||
|
||||
jit_unget_reg(rg0);
|
||||
}
|
||||
#endif
|
||||
1582
libguile/lightening/lightening/aarch64.c
Normal file
1582
libguile/lightening/lightening/aarch64.c
Normal file
File diff suppressed because it is too large
Load diff
89
libguile/lightening/lightening/aarch64.h
Normal file
89
libguile/lightening/lightening/aarch64.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_aarch64_h
|
||||
#define _jit_aarch64_h
|
||||
|
||||
#define JIT_HASH_CONSTS 0
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define JIT_FP _R29
|
||||
typedef enum {
|
||||
#define jit_r(i) (_R9 + (i))
|
||||
#define jit_r_num() 7
|
||||
#define jit_v(i) (_R19 + (i))
|
||||
#define jit_v_num() 10
|
||||
#define jit_f(i) (_V8 + (i))
|
||||
#define jit_f_num() 8
|
||||
#define JIT_R0 _R9
|
||||
#define JIT_R1 _R10
|
||||
#define JIT_R2 _R11
|
||||
#define JIT_R3 _R12
|
||||
#define JIT_R4 _R13
|
||||
#define JIT_R5 _R14
|
||||
#define JIT_R6 _R15
|
||||
_R8, /* indirect result */
|
||||
_R18, /* platform register */
|
||||
_R17, /* IP1 */
|
||||
_R16, /* IP0 */
|
||||
_R9, _R10, _R11, _R12, /* temporaries */
|
||||
_R13, _R14, _R15,
|
||||
#define JIT_V0 _R19
|
||||
#define JIT_V1 _R20
|
||||
#define JIT_V2 _R21
|
||||
#define JIT_V3 _R22
|
||||
#define JIT_V4 _R23
|
||||
#define JIT_V5 _R24
|
||||
#define JIT_V6 _R25
|
||||
#define JIT_V7 _R26
|
||||
#define JIT_V8 _R27
|
||||
#define JIT_V9 _R28
|
||||
_R19, _R20, _R21, _R22, /* callee save */
|
||||
_R23, _R24, _R25, _R26,
|
||||
_R27, _R28,
|
||||
_SP, /* stack pointer */
|
||||
_R30, /* link register */
|
||||
_R29, /* frame pointer */
|
||||
_R7, _R6, _R5, _R4,
|
||||
_R3, _R2, _R1, _R0,
|
||||
#define JIT_F0 _V8
|
||||
#define JIT_F1 _V9
|
||||
#define JIT_F2 _V10
|
||||
#define JIT_F3 _V11
|
||||
#define JIT_F4 _V12
|
||||
#define JIT_F5 _V13
|
||||
#define JIT_F6 _V14
|
||||
#define JIT_F7 _V15
|
||||
_V31, _V30, _V29, _V28, /* temporaries */
|
||||
_V27, _V26, _V25, _V24,
|
||||
_V23, _V22, _V21, _V20,
|
||||
_V19, _V18, _V17, _V16,
|
||||
/* callee save */
|
||||
_V8, _V9, _V10, _V11,
|
||||
_V12, _V13, _V14, _V15,
|
||||
_V7, _V6, _V5, _V4, /* arguments */
|
||||
_V3, _V2, _V1, _V0,
|
||||
_NOREG,
|
||||
#define JIT_NOREG _NOREG
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_aarch64_h */
|
||||
2792
libguile/lightening/lightening/alpha-cpu.c
Normal file
2792
libguile/lightening/lightening/alpha-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1588
libguile/lightening/lightening/alpha-fpu.c
Normal file
1588
libguile/lightening/lightening/alpha-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1551
libguile/lightening/lightening/alpha.c
Normal file
1551
libguile/lightening/lightening/alpha.c
Normal file
File diff suppressed because it is too large
Load diff
105
libguile/lightening/lightening/alpha.h
Normal file
105
libguile/lightening/lightening/alpha.h
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (C) 2014-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_alpha_h
|
||||
#define _jit_alpha_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define JIT_FP _FP
|
||||
typedef enum {
|
||||
#define jit_r(i) (_S0 + (i))
|
||||
#define jit_r_num() 3
|
||||
#define jit_v(i) (_S3 + (i))
|
||||
#define jit_v_num() 3
|
||||
#define jit_f(i) (_F2 + (i))
|
||||
#define jit_f_num() 8
|
||||
/* Volatile - Assembly temporary register */
|
||||
_AT,
|
||||
/* Volatile - Return value register */
|
||||
_V0,
|
||||
/* Volatile - Temporary registers */
|
||||
_T0, _T1, _T2, _T3,
|
||||
_T4, _T5, _T6, _T7,
|
||||
_T8, _T9, _T10, _T11,
|
||||
/* FIXME Use callee save register for r0-r2 (instead of 12+ JIT_RN
|
||||
* and 6 JIT_VN because division must call a function)
|
||||
* FIX would be to create proper functions that do not clobber
|
||||
* registers and inject/inline them in the jit */
|
||||
#define JIT_R0 _S0
|
||||
#define JIT_R1 _S1
|
||||
#define JIT_R2 _S2
|
||||
#define JIT_V0 _S3
|
||||
#define JIT_V1 _S4
|
||||
#define JIT_V2 _S5
|
||||
/* Nonvolatile - Saved registers */
|
||||
_S0, _S1, _S2, _S3,
|
||||
_S4, _S5,
|
||||
/* Nonvolatile - Frame pointer */
|
||||
_FP,
|
||||
/* Volatile - Argument registers */
|
||||
_A5, _A4, _A3, _A2,
|
||||
_A1, _A0,
|
||||
/* Volatile - Return address register */
|
||||
_RA,
|
||||
/* Volatile - Temporary register */
|
||||
_PV,
|
||||
/* Nonvolatile - Global pointer */
|
||||
_GP,
|
||||
/* Nonvolatile - Stack pointer */
|
||||
_SP,
|
||||
/* Constant RAZ / writes ignored */
|
||||
_ZERO,
|
||||
#define JIT_F0 _F2
|
||||
#define JIT_F1 _F3
|
||||
#define JIT_F2 _F4
|
||||
#define JIT_F3 _F5
|
||||
#define JIT_F4 _F6
|
||||
#define JIT_F5 _F7
|
||||
#define JIT_F6 _F8
|
||||
#define JIT_F7 _F9
|
||||
/* Volatile - Return value register (real part) */
|
||||
_F0,
|
||||
/* Volatile - Return value register (imaginary part) */
|
||||
_F1,
|
||||
/* Nonvolatile - Saved registers */
|
||||
_F2, _F3, _F4, _F5,
|
||||
_F6, _F7, _F8, _F9,
|
||||
/* Volatile - Temporary registers */
|
||||
_F10, _F11, _F12, _F13,
|
||||
_F14, _F15,
|
||||
/* Volatile - Argument registers */
|
||||
_F21, _F20, _F19, _F18,
|
||||
_F17, _F16,
|
||||
/* Volatile - Temporary registers */
|
||||
_F22, _F23, _R24, _F25,
|
||||
_F26, _F27, _F28, _F29,
|
||||
_F30,
|
||||
/* Constant - RAZ / writes ignored */
|
||||
_F31,
|
||||
/* Lightning internal invalid register identifier */
|
||||
_NOREG,
|
||||
#define JIT_NOREG _NOREG
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_alpha_h */
|
||||
3955
libguile/lightening/lightening/arm-cpu.c
Normal file
3955
libguile/lightening/lightening/arm-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
2640
libguile/lightening/lightening/arm-swf.c
Normal file
2640
libguile/lightening/lightening/arm-swf.c
Normal file
File diff suppressed because it is too large
Load diff
2330
libguile/lightening/lightening/arm-vfp.c
Normal file
2330
libguile/lightening/lightening/arm-vfp.c
Normal file
File diff suppressed because it is too large
Load diff
2274
libguile/lightening/lightening/arm.c
Normal file
2274
libguile/lightening/lightening/arm.c
Normal file
File diff suppressed because it is too large
Load diff
127
libguile/lightening/lightening/arm.h
Normal file
127
libguile/lightening/lightening/arm.h
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_arm_h
|
||||
#define _jit_arm_h
|
||||
|
||||
#define JIT_HASH_CONSTS 0
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define jit_swf_p() (jit_cpu.vfp == 0)
|
||||
#define jit_hardfp_p() jit_cpu.abi
|
||||
#define jit_ldrt_strt_p() jit_cpu.ldrt_strt
|
||||
|
||||
#define JIT_FP _R11
|
||||
typedef enum {
|
||||
#define jit_r(i) (_R4 + (i))
|
||||
#define jit_r_num() 3
|
||||
#define jit_v(i) (_R7 + (i))
|
||||
#define jit_v_num() 3
|
||||
#define jit_f(i) (jit_cpu.abi ? _D8 + ((i)<<1) : _D0 - ((i)<<1))
|
||||
#define jit_f_num() 8
|
||||
_R12, /* ip - temporary */
|
||||
#define JIT_R0 _R4
|
||||
#define JIT_R1 _R5
|
||||
#define JIT_R2 _R6
|
||||
_R4, /* r4 - variable */
|
||||
_R5, /* r5 - variable */
|
||||
_R6, /* r6 - variable */
|
||||
#define JIT_V0 _R7
|
||||
#define JIT_V1 _R8
|
||||
#define JIT_V2 _R9
|
||||
_R7, /* r7 - variable */
|
||||
_R8, /* r8 - variable */
|
||||
_R9, /* r9 - variable */
|
||||
_R10, /* sl - stack limit */
|
||||
_R11, /* fp - frame pointer */
|
||||
_R13, /* sp - stack pointer */
|
||||
_R14, /* lr - link register */
|
||||
_R15, /* pc - program counter */
|
||||
_R3, /* r3 - argument/result */
|
||||
_R2, /* r2 - argument/result */
|
||||
_R1, /* r1 - argument/result */
|
||||
_R0, /* r0 - argument/result */
|
||||
#define JIT_F0 (jit_hardfp_p() ? _D8 : _D0)
|
||||
#define JIT_F1 (jit_hardfp_p() ? _D9 : _D1)
|
||||
#define JIT_F2 (jit_hardfp_p() ? _D10 : _D2)
|
||||
#define JIT_F3 (jit_hardfp_p() ? _D11 : _D3)
|
||||
#define JIT_F4 (jit_hardfp_p() ? _D12 : _D4)
|
||||
#define JIT_F5 (jit_hardfp_p() ? _D13 : _D5)
|
||||
#define JIT_F6 (jit_hardfp_p() ? _D14 : _D6)
|
||||
#define JIT_F7 (jit_hardfp_p() ? _D15 : _D7)
|
||||
_S16, _D8 = _S16, _Q4 = _D8,
|
||||
_S17,
|
||||
_S18, _D9 = _S18,
|
||||
_S19,
|
||||
_S20, _D10 = _S20, _Q5 = _D10,
|
||||
_S21,
|
||||
_S22, _D11 = _S22,
|
||||
_S23,
|
||||
_S24, _D12 = _S24, _Q6 = _D12,
|
||||
_S25,
|
||||
_S26, _D13 = _S26,
|
||||
_S27,
|
||||
_S28, _D14 = _S28, _Q7 = _D14,
|
||||
_S29,
|
||||
_S30, _D15 = _S30,
|
||||
_S31,
|
||||
_S15,
|
||||
_S14, _D7 = _S14,
|
||||
_S13,
|
||||
_S12, _D6 = _S12, _Q3 = _D6,
|
||||
_S11,
|
||||
_S10, _D5 = _S10,
|
||||
_S9,
|
||||
_S8, _D4 = _S8, _Q2 = _D4,
|
||||
_S7,
|
||||
_S6, _D3 = _S6,
|
||||
_S5,
|
||||
_S4, _D2 = _S4, _Q1 = _D2,
|
||||
_S3,
|
||||
_S2, _D1 = _S2,
|
||||
_S1,
|
||||
_S0, _D0 = _S0, _Q0 = _D0,
|
||||
_NOREG,
|
||||
#define JIT_NOREG _NOREG
|
||||
} jit_reg_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t version : 4;
|
||||
uint32_t extend : 1;
|
||||
/* only generate thumb instructions for thumb2 */
|
||||
uint32_t thumb : 1;
|
||||
uint32_t vfp : 3;
|
||||
uint32_t neon : 1;
|
||||
uint32_t abi : 2;
|
||||
/* use strt+offset instead of str.w?
|
||||
* on special cases it causes a SIGILL at least on qemu, probably
|
||||
* due to some memory ordering constraint not being respected, so,
|
||||
* disable by default */
|
||||
uint32_t ldrt_strt : 1;
|
||||
} jit_cpu_t;
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
JIT_API jit_cpu_t jit_cpu;
|
||||
|
||||
#endif /* _jit_arm_h */
|
||||
110
libguile/lightening/lightening/endian.h
Normal file
110
libguile/lightening/lightening/endian.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
* Andy Wingo
|
||||
*/
|
||||
|
||||
#ifndef _jit_endian_h
|
||||
#define _jit_endian_h
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__hpux) && defined(__hppa__)
|
||||
# include <machine/param.h>
|
||||
#endif
|
||||
#if defined(__alpha__) && defined(__osf__)
|
||||
# include <machine/endian.h>
|
||||
#endif
|
||||
|
||||
#ifndef __WORDSIZE
|
||||
# if defined(WORDSIZE) /* ppc darwin */
|
||||
# define __WORDSIZE WORDSIZE
|
||||
# elif defined(__SIZEOF_POINTER__) /* ppc aix */
|
||||
# define __WORDSIZE (__SIZEOF_POINTER__ << 3)
|
||||
# elif defined(_ILP32) /* hppa hp-ux */
|
||||
# define __WORDSIZE 32
|
||||
# elif defined(_LP64) /* ia64 hp-ux (with cc +DD64) */
|
||||
# define __WORDSIZE 64
|
||||
# elif defined(_MIPS_SZPTR) /* mips irix */
|
||||
# if _MIPS_SZPTR == 32
|
||||
# define __WORDSIZE 32
|
||||
# else
|
||||
# define __WORDSIZE 64
|
||||
# endif
|
||||
# else /* From FreeBSD 9.1 stdint.h */
|
||||
# if defined(UINTPTR_MAX) && defined(UINT64_MAX) && \
|
||||
(UINTPTR_MAX == UINT64_MAX)
|
||||
# define __WORDSIZE 64
|
||||
# else
|
||||
# define __WORDSIZE 32
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef __LITTLE_ENDIAN
|
||||
# if defined(LITTLE_ENDIAN) /* ppc darwin */
|
||||
# define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
# elif defined(__ORDER_LITTLE_ENDIAN__) /* ppc aix */
|
||||
# define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
|
||||
# else
|
||||
# define __LITTLE_ENDIAN 1234
|
||||
# endif
|
||||
#endif
|
||||
#ifndef __BIG_ENDIAN
|
||||
# if defined(BIG_ENDIAN) /* ppc darwin */
|
||||
# define __BIG_ENDIAN BIG_ENDIAN
|
||||
# elif defined(__ORDER_BIG_ENDIAN__) /* ppc aix */
|
||||
# define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
|
||||
# else
|
||||
# define __BIG_ENDIAN 4321
|
||||
# endif
|
||||
#endif
|
||||
#ifndef __BYTE_ORDER
|
||||
# if defined(BYTE_ORDER) /* ppc darwin */
|
||||
# define __BYTE_ORDER BYTE_ORDER
|
||||
# elif defined(__BYTE_ORDER__) /* ppc aix */
|
||||
# define __BYTE_ORDER __BYTE_ORDER__
|
||||
# elif defined(_BIG_ENDIAN) /* hppa hp-ux */
|
||||
# define __BYTE_ORDER __BIG_ENDIAN
|
||||
# elif defined(__BIG_ENDIAN__) /* ia64 hp-ux */
|
||||
# define __BYTE_ORDER __BIG_ENDIAN
|
||||
# elif defined(__i386__) /* 32 bit x86 solaris */
|
||||
# define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
# elif defined(__x86_64__) /* 64 bit x86 solaris */
|
||||
# define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
# elif defined(__MIPSEB) /* mips irix */
|
||||
# define __BYTE_ORDER __BIG_ENDIAN
|
||||
# else
|
||||
# error cannot figure __BYTE_ORDER
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __WORDSIZE == 32
|
||||
#define CHOOSE_32_64(x, y) x
|
||||
#elif __WORDSIZE == 64
|
||||
#define CHOOSE_32_64(x, y) y
|
||||
#else
|
||||
#error unhandled __WORDSIZE
|
||||
#endif
|
||||
|
||||
#define WHEN_64(x) CHOOSE_32_64(/**/, x)
|
||||
|
||||
|
||||
#endif /* _jit_endian_h */
|
||||
2793
libguile/lightening/lightening/hppa-cpu.c
Normal file
2793
libguile/lightening/lightening/hppa-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1039
libguile/lightening/lightening/hppa-fpu.c
Normal file
1039
libguile/lightening/lightening/hppa-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1582
libguile/lightening/lightening/hppa.c
Normal file
1582
libguile/lightening/lightening/hppa.c
Normal file
File diff suppressed because it is too large
Load diff
134
libguile/lightening/lightening/hppa.h
Normal file
134
libguile/lightening/lightening/hppa.h
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_hppa_h
|
||||
#define _jit_hppa_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
typedef enum {
|
||||
_R0, /* Always zero */
|
||||
_R1, /* ADDIL implicit target */
|
||||
_R2, /* B,L implicit target */
|
||||
#define jit_r_num() 4
|
||||
#define jit_r(n) ((n) < 3 ? _R4 + (n) : _R10 + (n) - 3)
|
||||
#define jit_v_num() 11
|
||||
#define jit_v(n) ((n) < 3 ? _R7 + (n) : _R11 + (n) - 3)
|
||||
#define jit_f_num() 8
|
||||
#define jit_f(n) (_F12 - (n))
|
||||
#define JIT_FP _R3
|
||||
#define JIT_R0 _R4
|
||||
#define JIT_R1 _R5
|
||||
#define JIT_R2 _R6
|
||||
#define JIT_R3 _R10
|
||||
#define JIT_V0 _R7
|
||||
#define JIT_V1 _R8
|
||||
#define JIT_V2 _R9
|
||||
#define JIT_V3 _R11
|
||||
#define JIT_V4 _R12
|
||||
#define JIT_V5 _R13
|
||||
#define JIT_V6 _R14
|
||||
#define JIT_V7 _R15
|
||||
#define JIT_V8 _R16
|
||||
#define JIT_V9 _R17
|
||||
#define JIT_V10 _R18
|
||||
_R3,
|
||||
_R19,
|
||||
_R20,
|
||||
_R21,
|
||||
_R22,
|
||||
_R29, /* ret1 */
|
||||
_R28, /* ret0 */
|
||||
_R4,
|
||||
_R5,
|
||||
_R6,
|
||||
_R7,
|
||||
_R8,
|
||||
_R9,
|
||||
_R10,
|
||||
_R11,
|
||||
_R12,
|
||||
_R13,
|
||||
_R14,
|
||||
_R15,
|
||||
_R16,
|
||||
_R17,
|
||||
_R18,
|
||||
_R23, /* arg3 */
|
||||
_R24, /* arg2 */
|
||||
_R25, /* arg1 */
|
||||
_R26, /* arg0 */
|
||||
_R27, /* Data Pointer */
|
||||
_R30, /* Stack Pointer */
|
||||
_R31, /* Link register */
|
||||
#define JIT_F0 _F12
|
||||
#define JIT_F1 _F13
|
||||
#define JIT_F2 _F14
|
||||
#define JIT_F3 _F15
|
||||
#define JIT_F4 _F16
|
||||
#define JIT_F5 _F17
|
||||
#define JIT_F6 _F18
|
||||
#define JIT_F7 _F19
|
||||
#define JIT_F8 _F20
|
||||
#define JIT_F9 _F21
|
||||
/* Caller Saves */
|
||||
_F31,
|
||||
_F30,
|
||||
_F29,
|
||||
_F28,
|
||||
_F27,
|
||||
_F26,
|
||||
_F25,
|
||||
_F24,
|
||||
_F23,
|
||||
_F22,
|
||||
_F11,
|
||||
_F10,
|
||||
_F9,
|
||||
_F8,
|
||||
/* Arguments */
|
||||
_F7, /* farg3 */
|
||||
_F6, /* farg2 */
|
||||
_F5, /* farg1 */
|
||||
_F4, /* farg0 */
|
||||
/* Callee Saves */
|
||||
_F21,
|
||||
_F20,
|
||||
_F19,
|
||||
_F18,
|
||||
_F17,
|
||||
_F16,
|
||||
_F15,
|
||||
_F14,
|
||||
_F13,
|
||||
_F12,
|
||||
/* Floating-Pointer Status and Exception */
|
||||
_F0,
|
||||
_F1,
|
||||
_F2,
|
||||
_F3,
|
||||
#define JIT_NOREG _NOREG
|
||||
_NOREG,
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_hppa */
|
||||
5415
libguile/lightening/lightening/ia64-cpu.c
Normal file
5415
libguile/lightening/lightening/ia64-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1762
libguile/lightening/lightening/ia64-fpu.c
Normal file
1762
libguile/lightening/lightening/ia64-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1768
libguile/lightening/lightening/ia64.c
Normal file
1768
libguile/lightening/lightening/ia64.c
Normal file
File diff suppressed because it is too large
Load diff
120
libguile/lightening/lightening/ia64.h
Normal file
120
libguile/lightening/lightening/ia64.h
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_ia64_h
|
||||
#define _jit_ia64_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define JIT_FP _R4 /* Not abi specific */
|
||||
typedef enum {
|
||||
#define JIT_R0 _R40
|
||||
#define JIT_R1 _R41
|
||||
#define JIT_R2 _R42
|
||||
#define JIT_R3 _R43
|
||||
#define JIT_V0 _R44
|
||||
#define JIT_V1 _R45
|
||||
#define JIT_V2 _R46
|
||||
#define JIT_V3 _R47
|
||||
#define jit_r_num() 4
|
||||
#define jit_r(n) (_R40 + (n))
|
||||
#define jit_v_num() 4
|
||||
#define jit_v(n) (_R44 + (n))
|
||||
_R0, /* constant - Always 0 */
|
||||
_R1, /* special - Global Data pointer (gp) */
|
||||
/* r2-r3 - scratch - Use with 22-bit immediate add - scratch */
|
||||
_R2, _R3,
|
||||
/* r4-r7 - preserved */
|
||||
_R4, _R5, _R6, _R7,
|
||||
_R8, /* scratch - Return value; structure/union return pointer */
|
||||
/* r9-r11 - scratch - Return values */
|
||||
_R9, _R10, _R11,
|
||||
_R12, /* special - Memory stack pointer (sp) */
|
||||
_R13, /* special - Reserved as a thread pointer (tp)*/
|
||||
/* r14-r31 - scratch */
|
||||
_R31, _R30,
|
||||
_R29, _R28, _R27, _R26, _R25, _R24, _R23, _R22,
|
||||
_R21, _R20, _R19, _R18, _R17, _R16, _R15, _R14,
|
||||
/* r32-r39 - aka in0-in7 - Incoming register arguments */
|
||||
_R32, _R33, _R34, _R35, _R36, _R37, _R38, _R39,
|
||||
/* r40-r127 - loc0...locn,out0...outn */
|
||||
_R40, _R41, _R42, _R43, _R44, _R45, _R46, _R47,
|
||||
_R48, _R49, _R50, _R51, _R52, _R53, _R54, _R55,
|
||||
_R56, _R57, _R58, _R59, _R60, _R61, _R62, _R63,
|
||||
_R64, _R65, _R66, _R67, _R68, _R69, _R70, _R71,
|
||||
_R72, _R73, _R74, _R75, _R76, _R77, _R78, _R79,
|
||||
_R80, _R81, _R82, _R83, _R84, _R85, _R86, _R87,
|
||||
_R88, _R89, _R90, _R91, _R92, _R93, _R94, _R95,
|
||||
_R96, _R97, _R98, _R99, _R100, _R101, _R102, _R103,
|
||||
_R104, _R105, _R106, _R107, _R108, _R109, _R110, _R111,
|
||||
_R112, _R113, _R114, _R115, _R116, _R117, _R118, _R119,
|
||||
_R120, _R121, _R122, _R123, _R124, _R125, _R126, _R127,
|
||||
#define JIT_F0 _F16
|
||||
#define JIT_F1 _F17
|
||||
#define JIT_F2 _F18
|
||||
#define JIT_F3 _F19
|
||||
#define JIT_F4 _F20
|
||||
#define JIT_F5 _F21
|
||||
#define jit_f_num() 6
|
||||
#define jit_f(n) (_F16 + (n))
|
||||
_F0, /* constant - Always 0.0 */
|
||||
_F1, /* constant - Always 1.0 */
|
||||
/* f2-f5 - preserved */
|
||||
_F2, _F3, _F4, _F5,
|
||||
/* f6-f7 - scratch */
|
||||
_F6, _F7,
|
||||
/* f8-f15 - scratch - Argument/return registers */
|
||||
_F8, _F9, _F10, _F11, _F12, _F13, _F14, _F15,
|
||||
/* f16-f31 - preserved */
|
||||
_F16, _F17, _F18, _F19, _F20, _F21, _F22, _F23,
|
||||
_F24, _F25, _F26, _F27, _F28, _F29, _F30, _F31,
|
||||
/* f32-f127 - scratch - Rotating registers or scratch */
|
||||
_F32, _F33, _F34, _F35, _F36, _F37, _F38, _F39,
|
||||
_F40, _F41, _F42, _F43, _F44, _F45, _F46, _F47,
|
||||
_F48, _F49, _F50, _F51, _F52, _F53, _F54, _F55,
|
||||
_F56, _F57, _F58, _F59, _F60, _F61, _F62, _F63,
|
||||
_F64, _F65, _F66, _F67, _F68, _F69, _F70, _F71,
|
||||
_F72, _F73, _F74, _F75, _F76, _F77, _F78, _F79,
|
||||
_F80, _F81, _F82, _F83, _F84, _F85, _F86, _F87,
|
||||
_F88, _F89, _F90, _F91, _F92, _F93, _F94, _F95,
|
||||
_F96, _F97, _F98, _F99, _F100, _F101, _F102, _F103,
|
||||
_F104, _F105, _F106, _F107, _F108, _F109, _F110, _F111,
|
||||
_F112, _F113, _F114, _F115, _F116, _F117, _F118, _F119,
|
||||
|
||||
#if 0
|
||||
/* Do not list these to not need an unique identifier larger
|
||||
* than 255 for jit_regset_t */
|
||||
_F120, _F121, _F122, _F123, _F124, _F125, _F126, _F127,
|
||||
#endif
|
||||
|
||||
/* Fake registers. Required because while "in" parameters start at r32,
|
||||
* "out" parameters start *after* registers allocated for temporaries,
|
||||
* and that are supposed to kept alive (what is desirable, that is, to
|
||||
* not spill/reload them in memory) */
|
||||
_OUT0, _OUT1, _OUT2, _OUT3, _OUT4, _OUT5, _OUT6, _OUT7,
|
||||
|
||||
#define JIT_NOREG _NOREG
|
||||
_NOREG,
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_ia64_h */
|
||||
490
libguile/lightening/lightening/lightening.c
Normal file
490
libguile/lightening/lightening/lightening.c
Normal file
|
|
@ -0,0 +1,490 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "../lightening.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define maybe_unused __attribute__ ((unused))
|
||||
#else
|
||||
# define maybe_unused /**/
|
||||
#endif
|
||||
|
||||
#define rc(value) jit_class_##value
|
||||
#define rn(reg) (jit_regno(_rvs[jit_regno(reg.bits)].spec))
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
# define JIT_SP JIT_GPR(_RSP)
|
||||
# define JIT_RET JIT_GPR(_RAX)
|
||||
# if __X32
|
||||
# define JIT_FRET JIT_FPR(_ST0)
|
||||
# else
|
||||
# if __CYGWIN__
|
||||
# define JIT_RA0 JIT_GPR(_RCX)
|
||||
# else
|
||||
# define JIT_RA0 JIT_GPR(_RDI)
|
||||
# endif
|
||||
# define JIT_FA0 JIT_FPR(_XMM0)
|
||||
# define JIT_FRET JIT_FPR(_XMM0)
|
||||
# endif
|
||||
#elif defined(__mips__)
|
||||
# define JIT_RA0 JIT_GPR(_A0)
|
||||
# define JIT_FA0 JIT_FPR(_F12)
|
||||
# define JIT_SP JIT_GPR(_SP)
|
||||
# define JIT_RET JIT_GPR(_V0)
|
||||
# define JIT_FRET JIT_FPR(_F0)
|
||||
#elif defined(__arm__)
|
||||
# define JIT_RA0 JIT_GPR(_R0)
|
||||
# define JIT_FA0 JIT_FPR(_D0)
|
||||
# define JIT_SP JIT_GPR(_R13)
|
||||
# define JIT_RET JIT_GPR(_R0)
|
||||
# if defined(__ARM_PCS_VFP)
|
||||
# define JIT_FRET JIT_FPR(_D0)
|
||||
# else
|
||||
# define JIT_FRET JIT_FPR(_R0)
|
||||
# endif
|
||||
#elif defined(__ppc__) || defined(__powerpc__)
|
||||
# define JIT_RA0 JIT_GPR(_R3)
|
||||
# define JIT_FA0 JIT_FPR(_F1)
|
||||
# define JIT_SP JIT_GPR(_R1)
|
||||
# define JIT_RET JIT_GPR(_R3)
|
||||
# define JIT_FRET JIT_FPR(_F1)
|
||||
#elif defined(__sparc__)
|
||||
# define JIT_SP JIT_GPR(_SP)
|
||||
# define JIT_RET JIT_GPR(_I0)
|
||||
# define JIT_FRET JIT_FPR(_F0)
|
||||
#elif defined(__ia64__)
|
||||
# define JIT_SP JIT_GPR(_R12)
|
||||
# define JIT_RET JIT_GPR(_R8)
|
||||
# define JIT_FRET JIT_FPR(_F8)
|
||||
#elif defined(__hppa__)
|
||||
# define JIT_SP JIT_GPR(_R30)
|
||||
# define JIT_RET JIT_GPR(_R28)
|
||||
# define JIT_FRET JIT_FPR(_F4)
|
||||
#elif defined(__aarch64__)
|
||||
# define JIT_RA0 JIT_GPR(_R0)
|
||||
# define JIT_FA0 JIT_FPR(_V0)
|
||||
# define JIT_SP JIT_GPR(_SP)
|
||||
# define JIT_RET JIT_GPR(_R0)
|
||||
# define JIT_FRET JIT_FPR(_V0)
|
||||
#elif defined(__s390__) || defined(__s390x__)
|
||||
# define JIT_SP JIT_GPR(_R15)
|
||||
# define JIT_RET JIT_GPR(_R2)
|
||||
# define JIT_FRET JIT_FPR(_F0)
|
||||
#elif defined(__alpha__)
|
||||
# define JIT_SP JIT_GPR(_SP)
|
||||
# define JIT_RET JIT_GPR(_V0)
|
||||
# define JIT_FRET JIT_FPR(_F0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Private jit_class bitmasks
|
||||
*/
|
||||
#define jit_class_named 0x00400000 /* hit must be the named reg */
|
||||
#define jit_class_nospill 0x00800000 /* hint to fail if need spill */
|
||||
#define jit_class_sft 0x01000000 /* not a hardware register */
|
||||
#define jit_class_rg8 0x04000000 /* x86 8 bits */
|
||||
#define jit_class_xpr 0x80000000 /* float / vector */
|
||||
/* Used on sparc64 where %f0-%f31 can be encode for single float
|
||||
* but %f32 to %f62 only as double precision */
|
||||
#define jit_class_sng 0x10000000 /* Single precision float */
|
||||
#define jit_class_dbl 0x20000000 /* Only double precision float */
|
||||
#define jit_regno_patch 0x00008000 /* this is a register
|
||||
* returned by a "user" call
|
||||
* to jit_get_reg() */
|
||||
|
||||
union jit_pc
|
||||
{
|
||||
uint8_t *uc;
|
||||
uint16_t *us;
|
||||
uint32_t *ui;
|
||||
uint64_t *ul;
|
||||
intptr_t w;
|
||||
uintptr_t uw;
|
||||
};
|
||||
|
||||
struct jit_state
|
||||
{
|
||||
union jit_pc pc;
|
||||
uint8_t *start;
|
||||
uint8_t *last_instruction_start;
|
||||
uint8_t *limit;
|
||||
uint8_t temp_gpr_saved;
|
||||
uint8_t temp_fpr_saved;
|
||||
uint8_t overflow;
|
||||
};
|
||||
|
||||
enum jit_reloc_flags
|
||||
{
|
||||
JIT_RELOC_CAN_SHORTEN = 1<<0
|
||||
};
|
||||
|
||||
struct jit_register
|
||||
{
|
||||
jit_reg_t spec;
|
||||
char *name;
|
||||
};
|
||||
|
||||
typedef struct jit_register jit_register_t;
|
||||
|
||||
static const jit_register_t _rvs[];
|
||||
|
||||
#define jit_regload_reload 0 /* convert to reload */
|
||||
#define jit_regload_delete 1 /* just remove node */
|
||||
#define jit_regload_isdead 2 /* delete and unset live bit */
|
||||
|
||||
#define ASSERT(x) do { if (!(x)) abort(); } while (0)
|
||||
#if defined(__GNUC__)
|
||||
# define UNLIKELY(exprn) __builtin_expect(exprn, 0)
|
||||
#else
|
||||
# define UNLIKELY(exprn) exprn
|
||||
#endif
|
||||
|
||||
static jit_bool_t jit_get_cpu(void);
|
||||
static jit_bool_t jit_init(jit_state_t *);
|
||||
static void jit_flush(void *fptr, void *tptr);
|
||||
static void jit_try_shorten(jit_state_t *_jit, jit_reloc_t reloc);
|
||||
|
||||
jit_bool_t
|
||||
init_jit(void)
|
||||
{
|
||||
return jit_get_cpu ();
|
||||
}
|
||||
|
||||
jit_state_t *
|
||||
jit_new_state(void)
|
||||
{
|
||||
jit_state_t *_jit = malloc (sizeof (*_jit));
|
||||
if (!_jit)
|
||||
abort ();
|
||||
|
||||
memset(_jit, 0, sizeof (*_jit));
|
||||
|
||||
if (!jit_init (_jit));
|
||||
|
||||
return _jit;
|
||||
}
|
||||
|
||||
void
|
||||
jit_destroy_state(jit_state_t *_jit)
|
||||
{
|
||||
free (_jit);
|
||||
}
|
||||
|
||||
jit_pointer_t
|
||||
jit_address(jit_state_t *_jit)
|
||||
{
|
||||
return _jit->pc.uc;
|
||||
}
|
||||
|
||||
void
|
||||
jit_begin(jit_state_t *_jit, uint8_t* buf, size_t length)
|
||||
{
|
||||
ASSERT (!_jit->start);
|
||||
|
||||
_jit->start = buf;
|
||||
_jit->limit = buf + length;
|
||||
jit_reset(_jit);
|
||||
}
|
||||
|
||||
jit_bool_t
|
||||
jit_has_overflow(jit_state_t *_jit)
|
||||
{
|
||||
ASSERT (_jit->start);
|
||||
return _jit->overflow;
|
||||
}
|
||||
|
||||
void
|
||||
jit_reset(jit_state_t *_jit)
|
||||
{
|
||||
ASSERT (_jit->start);
|
||||
_jit->pc.uc = _jit->start;
|
||||
_jit->overflow = 0;
|
||||
}
|
||||
|
||||
void*
|
||||
jit_end(jit_state_t *_jit, size_t *length)
|
||||
{
|
||||
uint8_t *code = _jit->start;
|
||||
uint8_t *end = _jit->pc.uc;
|
||||
|
||||
ASSERT (code);
|
||||
ASSERT (code <= end);
|
||||
ASSERT (end <= _jit->limit);
|
||||
ASSERT (!_jit->overflow);
|
||||
|
||||
jit_flush (code, end);
|
||||
|
||||
if (length) {
|
||||
*length = end - code;
|
||||
}
|
||||
|
||||
_jit->pc.uc = _jit->start = _jit->limit = NULL;
|
||||
_jit->overflow = 0;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static int
|
||||
is_power_of_two (unsigned x)
|
||||
{
|
||||
return x && !(x & (x-1));
|
||||
}
|
||||
|
||||
void
|
||||
jit_align(jit_state_t *_jit, unsigned align)
|
||||
{
|
||||
ASSERT (is_power_of_two (align));
|
||||
uintptr_t here = _jit->pc.w;
|
||||
uintptr_t there = (here + align - 1) & ~(align - 1);
|
||||
if (there - here)
|
||||
jit_nop(_jit, there - here);
|
||||
}
|
||||
|
||||
static inline void emit_u8(jit_state_t *_jit, uint8_t u8) {
|
||||
if (UNLIKELY(_jit->pc.uc + 1 > _jit->limit)) {
|
||||
_jit->overflow = 1;
|
||||
} else {
|
||||
*_jit->pc.uc++ = u8;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void emit_u16(jit_state_t *_jit, uint16_t u16) {
|
||||
if (UNLIKELY(_jit->pc.us + 1 > (uint16_t*)_jit->limit)) {
|
||||
_jit->overflow = 1;
|
||||
} else {
|
||||
*_jit->pc.us++ = u16;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void emit_u32(jit_state_t *_jit, uint32_t u32) {
|
||||
if (UNLIKELY(_jit->pc.ui + 1 > (uint32_t*)_jit->limit)) {
|
||||
_jit->overflow = 1;
|
||||
} else {
|
||||
*_jit->pc.ui++ = u32;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void emit_u64(jit_state_t *_jit, uint64_t u64) {
|
||||
if (UNLIKELY(_jit->pc.ul + 1 > (uint64_t*)_jit->limit)) {
|
||||
_jit->overflow = 1;
|
||||
} else {
|
||||
*_jit->pc.ul++ = u64;
|
||||
}
|
||||
}
|
||||
|
||||
static inline jit_reloc_t
|
||||
jit_reloc (jit_state_t *_jit, enum jit_reloc_kind kind,
|
||||
uint8_t inst_start_offset, uint16_t flags)
|
||||
{
|
||||
jit_reloc_t ret;
|
||||
|
||||
ret.kind = kind;
|
||||
ret.inst_start_offset = inst_start_offset;
|
||||
ret.flags = 0;
|
||||
ret.offset = _jit->pc.uc - _jit->start;
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case JIT_RELOC_ABSOLUTE:
|
||||
if (sizeof(intptr_t) == 4)
|
||||
emit_u32 (_jit, 0);
|
||||
else
|
||||
emit_u64 (_jit, 0);
|
||||
break;
|
||||
case JIT_RELOC_REL8:
|
||||
emit_u8 (_jit, 0);
|
||||
break;
|
||||
case JIT_RELOC_REL16:
|
||||
emit_u16 (_jit, 0);
|
||||
break;
|
||||
case JIT_RELOC_REL32:
|
||||
emit_u32 (_jit, 0);
|
||||
break;
|
||||
case JIT_RELOC_REL64:
|
||||
emit_u64 (_jit, 0);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
jit_patch_here(jit_state_t *_jit, jit_reloc_t reloc)
|
||||
{
|
||||
jit_patch_there (_jit, reloc, jit_address (_jit));
|
||||
}
|
||||
|
||||
void
|
||||
jit_patch_there(jit_state_t* _jit, jit_reloc_t reloc, jit_pointer_t addr)
|
||||
{
|
||||
if (_jit->overflow)
|
||||
return;
|
||||
union jit_pc loc;
|
||||
loc.uc = _jit->start + reloc.offset;
|
||||
ptrdiff_t diff;
|
||||
|
||||
switch (reloc.kind)
|
||||
{
|
||||
case JIT_RELOC_ABSOLUTE:
|
||||
if (sizeof(diff) == 4)
|
||||
*loc.ui = (uintptr_t)addr;
|
||||
else
|
||||
*loc.ul = (uintptr_t)addr;
|
||||
if (loc.uc + sizeof(diff) == _jit->pc.uc &&
|
||||
(reloc.flags & JIT_RELOC_CAN_SHORTEN))
|
||||
jit_try_shorten (_jit, reloc);
|
||||
break;
|
||||
case JIT_RELOC_REL8:
|
||||
diff = ((uint8_t*)addr) - (loc.uc + 1);
|
||||
ASSERT (INT8_MIN <= diff && diff <= INT8_MAX);
|
||||
*loc.uc = diff;
|
||||
break;
|
||||
case JIT_RELOC_REL16:
|
||||
diff = ((uint8_t*)addr) - (loc.uc + 2);
|
||||
ASSERT (INT16_MIN <= diff && diff <= INT16_MAX);
|
||||
*loc.us = diff;
|
||||
if ((loc.uc + 1) == _jit->pc.uc && (reloc.flags & JIT_RELOC_CAN_SHORTEN))
|
||||
jit_try_shorten (_jit, reloc);
|
||||
break;
|
||||
case JIT_RELOC_REL32:
|
||||
diff = ((uint8_t*)addr) - (loc.uc + 4);
|
||||
ASSERT (INT32_MIN <= diff && diff <= INT32_MAX);
|
||||
*loc.ui = diff;
|
||||
if ((loc.ui + 1) == _jit->pc.ui && (reloc.flags & JIT_RELOC_CAN_SHORTEN))
|
||||
jit_try_shorten (_jit, reloc);
|
||||
break;
|
||||
case JIT_RELOC_REL64:
|
||||
diff = ((uint8_t*)addr) - (loc.uc + 8);
|
||||
*loc.ul = diff;
|
||||
if ((loc.ul + 1) == _jit->pc.ul && (reloc.flags & JIT_RELOC_CAN_SHORTEN))
|
||||
jit_try_shorten (_jit, reloc);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
# include "x86.c"
|
||||
#elif defined(__mips__)
|
||||
# include "mips.c"
|
||||
#elif defined(__arm__)
|
||||
# include "arm.c"
|
||||
#elif defined(__ppc__) || defined(__powerpc__)
|
||||
# include "ppc.c"
|
||||
#elif defined(__sparc__)
|
||||
# include "sparc.c"
|
||||
#elif defined(__ia64__)
|
||||
# include "ia64.c"
|
||||
#elif defined(__hppa__)
|
||||
# include "hppa.c"
|
||||
#elif defined(__aarch64__)
|
||||
# include "aarch64.c"
|
||||
#elif defined(__s390__) || defined(__s390x__)
|
||||
# include "s390.c"
|
||||
#elif defined(__alpha__)
|
||||
# include "alpha.c"
|
||||
#endif
|
||||
|
||||
#define JIT_IMPL_0(stem, ret) \
|
||||
ret jit_##stem (jit_state_t* _jit) \
|
||||
{ \
|
||||
return stem(_jit); \
|
||||
}
|
||||
#define JIT_IMPL_1(stem, ret, ta) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a) \
|
||||
{ \
|
||||
return stem(_jit, unwrap_##ta(a)); \
|
||||
}
|
||||
#define JIT_IMPL_2(stem, ret, ta, tb) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a, jit_##tb##_t b) \
|
||||
{ \
|
||||
return stem(_jit, unwrap_##ta(a), unwrap_##tb(b)); \
|
||||
}
|
||||
#define JIT_IMPL_3(stem, ret, ta, tb, tc) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a, jit_##tb##_t b, jit_##tc##_t c) \
|
||||
{ \
|
||||
return stem(_jit, unwrap_##ta(a), unwrap_##tb(b), unwrap_##tc(c)); \
|
||||
}
|
||||
#define JIT_IMPL_4(stem, ret, ta, tb, tc, td) \
|
||||
ret jit_##stem (jit_state_t* _jit, jit_##ta##_t a, jit_##tb##_t b, jit_##tc##_t c, jit_##td##_t d) \
|
||||
{ \
|
||||
return stem(_jit, unwrap_##ta(a), unwrap_##tb(b), unwrap_##tc(c), unwrap_##td(d)); \
|
||||
}
|
||||
|
||||
#define JIT_IMPL_RFF__(stem) JIT_IMPL_2(stem, jit_reloc_t, fpr, fpr)
|
||||
#define JIT_IMPL_RGG__(stem) JIT_IMPL_2(stem, jit_reloc_t, gpr, gpr)
|
||||
#define JIT_IMPL_RG___(stem) JIT_IMPL_1(stem, jit_reloc_t, gpr)
|
||||
#define JIT_IMPL_RGi__(stem) JIT_IMPL_2(stem, jit_reloc_t, gpr, imm)
|
||||
#define JIT_IMPL_RGu__(stem) JIT_IMPL_2(stem, jit_reloc_t, gpr, uimm)
|
||||
#define JIT_IMPL_R____(stem) JIT_IMPL_0(stem, jit_reloc_t)
|
||||
#define JIT_IMPL__FFF_(stem) JIT_IMPL_3(stem, void, fpr, fpr, fpr)
|
||||
#define JIT_IMPL__FF__(stem) JIT_IMPL_2(stem, void, fpr, fpr)
|
||||
#define JIT_IMPL__FGG_(stem) JIT_IMPL_3(stem, void, fpr, gpr, gpr)
|
||||
#define JIT_IMPL__FG__(stem) JIT_IMPL_2(stem, void, fpr, gpr)
|
||||
#define JIT_IMPL__FGo_(stem) JIT_IMPL_3(stem, void, fpr, gpr, off)
|
||||
#define JIT_IMPL__F___(stem) JIT_IMPL_1(stem, void, fpr)
|
||||
#define JIT_IMPL__Fd__(stem) JIT_IMPL_2(stem, void, fpr, float64)
|
||||
#define JIT_IMPL__Ff__(stem) JIT_IMPL_2(stem, void, fpr, float32)
|
||||
#define JIT_IMPL__Fp__(stem) JIT_IMPL_2(stem, void, fpr, pointer)
|
||||
#define JIT_IMPL__GF__(stem) JIT_IMPL_2(stem, void, gpr, fpr)
|
||||
#define JIT_IMPL__GGF_(stem) JIT_IMPL_3(stem, void, gpr, gpr, fpr)
|
||||
#define JIT_IMPL__GGGG(stem) JIT_IMPL_4(stem, void, gpr, gpr, gpr, gpr)
|
||||
#define JIT_IMPL__GGG_(stem) JIT_IMPL_3(stem, void, gpr, gpr, gpr)
|
||||
#define JIT_IMPL__GGGi(stem) JIT_IMPL_4(stem, void, gpr, gpr, gpr, imm)
|
||||
#define JIT_IMPL__GGGu(stem) JIT_IMPL_4(stem, void, gpr, gpr, gpr, uimm)
|
||||
#define JIT_IMPL__GG__(stem) JIT_IMPL_2(stem, void, gpr, gpr)
|
||||
#define JIT_IMPL__GGi_(stem) JIT_IMPL_3(stem, void, gpr, gpr, imm)
|
||||
#define JIT_IMPL__GGo_(stem) JIT_IMPL_3(stem, void, gpr, gpr, off)
|
||||
#define JIT_IMPL__GGu_(stem) JIT_IMPL_3(stem, void, gpr, gpr, uimm)
|
||||
#define JIT_IMPL__G___(stem) JIT_IMPL_1(stem, void, gpr)
|
||||
#define JIT_IMPL__Gi__(stem) JIT_IMPL_2(stem, void, gpr, imm)
|
||||
#define JIT_IMPL__Gp__(stem) JIT_IMPL_2(stem, void, gpr, pointer)
|
||||
#define JIT_IMPL______(stem) JIT_IMPL_0(stem, void)
|
||||
#define JIT_IMPL__i___(stem) JIT_IMPL_1(stem, void, imm)
|
||||
#define JIT_IMPL__oGF_(stem) JIT_IMPL_3(stem, void, off, gpr, fpr)
|
||||
#define JIT_IMPL__oGG_(stem) JIT_IMPL_3(stem, void, off, gpr, gpr)
|
||||
#define JIT_IMPL__pF__(stem) JIT_IMPL_2(stem, void, pointer, fpr)
|
||||
#define JIT_IMPL__pG__(stem) JIT_IMPL_2(stem, void, pointer, gpr)
|
||||
#define JIT_IMPL__p___(stem) JIT_IMPL_1(stem, void, pointer)
|
||||
|
||||
#define unwrap_gpr(r) rn(r)
|
||||
#define unwrap_fpr(r) rn(r)
|
||||
#define unwrap_imm(i) i
|
||||
#define unwrap_uimm(u) u
|
||||
#define unwrap_off(o) o
|
||||
#define unwrap_pointer(p) ((uintptr_t) p)
|
||||
#define unwrap_float32(f) f
|
||||
#define unwrap_float64(d) d
|
||||
|
||||
#define IMPL_INSTRUCTION(kind, stem) JIT_IMPL_##kind(stem)
|
||||
FOR_EACH_INSTRUCTION(IMPL_INSTRUCTION)
|
||||
#undef IMPL_INSTRUCTION
|
||||
3153
libguile/lightening/lightening/mips-cpu.c
Normal file
3153
libguile/lightening/lightening/mips-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1844
libguile/lightening/lightening/mips-fpu.c
Normal file
1844
libguile/lightening/lightening/mips-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1929
libguile/lightening/lightening/mips.c
Normal file
1929
libguile/lightening/lightening/mips.c
Normal file
File diff suppressed because it is too large
Load diff
115
libguile/lightening/lightening/mips.h
Normal file
115
libguile/lightening/lightening/mips.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_mips_h
|
||||
#define _jit_mips_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
#if _MIPS_SIM != _ABIO32
|
||||
# define NEW_ABI 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define JIT_FP _FP
|
||||
typedef enum {
|
||||
#define jit_r(i) (_V0 + (i))
|
||||
#if NEW_ABI
|
||||
# define jit_r_num() 7
|
||||
#else
|
||||
# define jit_r_num() 11
|
||||
#endif
|
||||
#define jit_v(i) (_S0 + (i))
|
||||
#define jit_v_num() 8
|
||||
#define jit_f(i) (_F0 + (i))
|
||||
#if NEW_ABI
|
||||
# define jit_f_num() 6
|
||||
#else
|
||||
# define jit_f_num() 8
|
||||
#endif
|
||||
_AT,
|
||||
#define JIT_R0 _V0
|
||||
#define JIT_R1 _V1
|
||||
#if NEW_ABI
|
||||
# define JIT_R2 _T4
|
||||
# define JIT_R3 _T5
|
||||
# define JIT_R4 _T6
|
||||
# define JIT_R5 _T7
|
||||
# define JIT_R6 _T8
|
||||
#else
|
||||
# define JIT_R2 _T0
|
||||
# define JIT_R3 _T1
|
||||
# define JIT_R4 _T2
|
||||
# define JIT_R5 _T3
|
||||
# define JIT_R6 _T4
|
||||
# define JIT_R7 _T5
|
||||
# define JIT_R8 _T6
|
||||
# define JIT_R9 _T7
|
||||
# define JIT_R10 _T8
|
||||
#endif
|
||||
_V0, _V1,
|
||||
#if !NEW_ABI
|
||||
_T0, _T1, _T2, _T3,
|
||||
#endif
|
||||
_T4, _T5, _T6, _T7, _T8, _T9,
|
||||
#define JIT_V0 _S0
|
||||
#define JIT_V1 _S1
|
||||
#define JIT_V2 _S2
|
||||
#define JIT_V3 _S3
|
||||
#define JIT_V4 _S4
|
||||
#define JIT_V5 _S5
|
||||
#define JIT_V6 _S6
|
||||
#define JIT_V7 _S7
|
||||
_S0, _S1, _S2, _S3, _S4, _S5, _S6, _S7,
|
||||
_ZERO, _K0, _K1, _RA,
|
||||
_GP,
|
||||
_SP, _FP,
|
||||
#if NEW_ABI
|
||||
_A7, _A6, _A5, _A4,
|
||||
#endif
|
||||
_A3, _A2, _A1, _A0,
|
||||
#define JIT_F0 _F0
|
||||
#define JIT_F1 _F2
|
||||
#define JIT_F2 _F4
|
||||
#define JIT_F3 _F6
|
||||
#define JIT_F4 _F8
|
||||
#define JIT_F5 _F10
|
||||
#if !NEW_ABI
|
||||
# define JIT_F6 _F16
|
||||
# define JIT_F7 _F18
|
||||
#endif
|
||||
_F0, _F2, _F4, _F6, _F8, _F10,
|
||||
/* callee save float registers */
|
||||
#if !NEW_ABI
|
||||
_F16, _F18,
|
||||
#endif
|
||||
_F20, _F22, _F24, _F26, _F28, _F30,
|
||||
#if NEW_ABI
|
||||
_F19, _F18, _F17, _F16, _F15, _F14, _F13, _F12,
|
||||
#else
|
||||
_F14, _F12,
|
||||
#endif
|
||||
#define JIT_NOREG _NOREG
|
||||
_NOREG,
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_mips_h */
|
||||
3483
libguile/lightening/lightening/ppc-cpu.c
Normal file
3483
libguile/lightening/lightening/ppc-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1194
libguile/lightening/lightening/ppc-fpu.c
Normal file
1194
libguile/lightening/lightening/ppc-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1745
libguile/lightening/lightening/ppc.c
Normal file
1745
libguile/lightening/lightening/ppc.c
Normal file
File diff suppressed because it is too large
Load diff
109
libguile/lightening/lightening/ppc.h
Normal file
109
libguile/lightening/lightening/ppc.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_ppc_h
|
||||
#define _jit_ppc_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
#if __powerpc__
|
||||
# if _CALL_ELF == 2
|
||||
/* __BYTE_ORDER == __LITTLE_ENDIAN */
|
||||
# define ABI_ELFv2 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
typedef enum {
|
||||
#if __ppc__
|
||||
# define jit_r(i) (_R11 + (i))
|
||||
#else
|
||||
# define jit_r(i) (_R28 + (i))
|
||||
#endif
|
||||
#define jit_r_num() 3
|
||||
#if __ppc__
|
||||
# define jit_v(i) (_R30 - (i))
|
||||
# define jit_v_num() 17
|
||||
#else
|
||||
# define jit_v(i) (_R27 - (i))
|
||||
# define jit_v_num() 14
|
||||
#endif
|
||||
#define jit_f(i) (_F14 + (i))
|
||||
#define jit_f_num() 8
|
||||
_R0,
|
||||
#if __ppc__
|
||||
# define JIT_R0 _R11
|
||||
# define JIT_R1 _R12
|
||||
# define JIT_R2 _R13
|
||||
#else
|
||||
# define JIT_R0 _R28
|
||||
# define JIT_R1 _R29
|
||||
# define JIT_R2 _R30
|
||||
#endif
|
||||
_R11, _R12, _R13, _R2,
|
||||
#define JIT_V0 jit_v(0)
|
||||
#define JIT_V1 jit_v(1)
|
||||
#define JIT_V2 jit_v(2)
|
||||
#define JIT_V3 jit_v(3)
|
||||
#define JIT_V4 jit_v(4)
|
||||
#define JIT_V5 jit_v(5)
|
||||
#define JIT_V6 jit_v(6)
|
||||
#define JIT_V7 jit_v(7)
|
||||
#define JIT_V8 jit_v(8)
|
||||
#define JIT_V9 jit_v(9)
|
||||
#define JIT_V10 jit_v(10)
|
||||
#define JIT_V11 jit_v(11)
|
||||
#define JIT_V12 jit_v(12)
|
||||
#define JIT_V13 jit_v(13)
|
||||
#if __ppc__
|
||||
# define JIT_V14 jit_v(14)
|
||||
# define JIT_V15 jit_v(15)
|
||||
# define JIT_V16 jit_v(16)
|
||||
#endif
|
||||
_R14, _R15, _R16, _R17, _R18, _R19, _R20, _R21,
|
||||
_R22, _R23, _R24, _R25, _R26, _R27, _R28, _R29,
|
||||
_R30,
|
||||
_R1,
|
||||
#define JIT_FP _R31
|
||||
_R31,
|
||||
_R10, _R9, _R8, _R7, _R6, _R5, _R4, _R3,
|
||||
_F0,
|
||||
_F14, _F15, _F16, _F17, _F18, _F19, _F20, _F21,
|
||||
#define JIT_F0 _F14
|
||||
#define JIT_F1 _F15
|
||||
#define JIT_F2 _F16
|
||||
#define JIT_F3 _F17
|
||||
#define JIT_F4 _F18
|
||||
#define JIT_F5 _F19
|
||||
#define JIT_F6 _F20
|
||||
#define JIT_F7 _F21
|
||||
/* FIXME _F20-_F31 not (easily) accessible and only _F14-_F21
|
||||
* saved/restored (if used) */
|
||||
_F22, _F23, _F24, _F25, _F26, _F27, _F28, _F29,
|
||||
_F30, _F31,
|
||||
_F13, _F12, _F11, _F10, _F9, _F8, _F7, _F6,
|
||||
_F5, _F4, _F3, _F2, _F1,
|
||||
_NOREG,
|
||||
#define JIT_NOREG _NOREG
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_ppc_h */
|
||||
3848
libguile/lightening/lightening/s390-cpu.c
Normal file
3848
libguile/lightening/lightening/s390-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1316
libguile/lightening/lightening/s390-fpu.c
Normal file
1316
libguile/lightening/lightening/s390-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1687
libguile/lightening/lightening/s390.c
Normal file
1687
libguile/lightening/lightening/s390.c
Normal file
File diff suppressed because it is too large
Load diff
68
libguile/lightening/lightening/s390.h
Normal file
68
libguile/lightening/lightening/s390.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_s390_h
|
||||
#define _jit_s390_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 2
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define JIT_FP _R13
|
||||
typedef enum {
|
||||
#define jit_r(i) (_R12 + ((i) << 1))
|
||||
#define jit_r_num() 3
|
||||
#define jit_v(i) (_R11 + ((i) << 1))
|
||||
#define jit_v_num() 3
|
||||
#define jit_f(i) (_F8 + (i))
|
||||
#define jit_f_num() 6
|
||||
#define JIT_R0 _R12
|
||||
#define JIT_R1 _R10
|
||||
#define JIT_R2 _R8
|
||||
#define JIT_V0 _R11
|
||||
#define JIT_V1 _R9
|
||||
#define JIT_V2 _R7
|
||||
_R0, _R1, /* Volatile */
|
||||
_R12, /* Saved, GOT */
|
||||
_R11, _R10, _R9, _R8, /* Saved */
|
||||
_R7, /* Saved */
|
||||
_R6, /* Saved, parameter */
|
||||
_R5, _R4, _R3, /* Parameter passing */
|
||||
_R2, /* Volatile, parameter and return value */
|
||||
_R13, /* Saved, literal pool pointer */
|
||||
_R14, /* Volatile, return address */
|
||||
_R15, /* Saved, stack pointer */
|
||||
#define JIT_F0 _F8
|
||||
#define JIT_F1 _F9
|
||||
#define JIT_F2 _F10
|
||||
#define JIT_F3 _F11
|
||||
#define JIT_F4 _F12
|
||||
#define JIT_F5 _F13
|
||||
_F1, _F3, _F5, _F7, /* Volatile */
|
||||
_F14, _F15, _F8, _F9, /* Saved */
|
||||
_F10, _F11, _F12, _F13, /* Saved */
|
||||
_F6, _F4, _F2, /* Volatile, parameter */
|
||||
_F0, /* Volatile, parameter and return value */
|
||||
_NOREG,
|
||||
#define JIT_NOREG _NOREG
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_s390_h */
|
||||
2568
libguile/lightening/lightening/sparc-cpu.c
Normal file
2568
libguile/lightening/lightening/sparc-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1499
libguile/lightening/lightening/sparc-fpu.c
Normal file
1499
libguile/lightening/lightening/sparc-fpu.c
Normal file
File diff suppressed because it is too large
Load diff
1926
libguile/lightening/lightening/sparc.c
Normal file
1926
libguile/lightening/lightening/sparc.c
Normal file
File diff suppressed because it is too large
Load diff
102
libguile/lightening/lightening/sparc.h
Normal file
102
libguile/lightening/lightening/sparc.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2017 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_sparc_h
|
||||
#define _jit_sparc_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 3
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define JIT_FP _FP
|
||||
typedef enum {
|
||||
#define jit_r(i) (_G2 + (i))
|
||||
#define jit_r_num() 3
|
||||
#define jit_v(i) (_L0 + (i))
|
||||
#define jit_v_num() 8
|
||||
#if __WORDSIZE == 32
|
||||
# define jit_f(i) (_F0 + ((i) << 1))
|
||||
# define jit_f_num() 8
|
||||
#else
|
||||
# define jit_f(i) (_F32 - (i))
|
||||
# define jit_f_num() 16
|
||||
#endif
|
||||
#define JIT_R0 _G2
|
||||
#define JIT_R1 _G3
|
||||
#define JIT_R2 _G4
|
||||
#define JIT_V0 _L0
|
||||
#define JIT_V1 _L1
|
||||
#define JIT_V2 _L2
|
||||
#define JIT_V3 _L3
|
||||
#define JIT_V4 _L4
|
||||
#define JIT_V5 _L5
|
||||
#define JIT_V6 _L6
|
||||
#define JIT_V7 _L7
|
||||
_G0, _G1, _G2, _G3, _G4, _G5, _G6, _G7,
|
||||
_O0, _O1, _O2, _O3, _O4, _O5, _SP, _O7,
|
||||
_L0, _L1, _L2, _L3, _L4, _L5, _L6, _L7,
|
||||
_I0, _I1, _I2, _I3, _I4, _I5, _FP, _I7,
|
||||
#if __WORDSIZE == 32
|
||||
# define JIT_F0 _F0
|
||||
# define JIT_F1 _F2
|
||||
# define JIT_F2 _F4
|
||||
# define JIT_F3 _F6
|
||||
# define JIT_F4 _F8
|
||||
# define JIT_F5 _F10
|
||||
# define JIT_F6 _F12
|
||||
# define JIT_F7 _F14
|
||||
_F0, _F1, _F2, _F3, _F4, _F5, _F6, _F7,
|
||||
_F8, _F9, _F10, _F11, _F12, _F13, _F14, _F15,
|
||||
#else
|
||||
/* All single precision operations have a high cost due to being
|
||||
* stored on registers only encodable as double precision.
|
||||
* The cost is due to needing to move values to a register with
|
||||
* value <= 31.
|
||||
* This is a limitation due to using fixed named registers in
|
||||
* lightning. */
|
||||
# define JIT_F0 _F32
|
||||
# define JIT_F1 _F34
|
||||
# define JIT_F2 _F36
|
||||
# define JIT_F3 _F38
|
||||
# define JIT_F4 _F40
|
||||
# define JIT_F5 _F42
|
||||
# define JIT_F6 _F44
|
||||
# define JIT_F7 _F46
|
||||
# define JIT_F8 _F48
|
||||
# define JIT_F9 _F50
|
||||
# define JIT_F10 _F52
|
||||
# define JIT_F11 _F54
|
||||
# define JIT_F12 _F56
|
||||
# define JIT_F13 _F58
|
||||
# define JIT_F14 _F60
|
||||
# define JIT_F15 _F62
|
||||
_F62, _F60, _F58, _F56, _F54, _F52, _F50, _F48,
|
||||
_F46, _F44, _F42, _F40, _F38, _F36, _F34, _F32,
|
||||
_F31, _F30, _F29, _F28, _F27, _F26, _F25, _F24,
|
||||
_F23, _F22, _F21, _F20, _F19, _F18, _F17, _F16,
|
||||
_F15, _F14, _F13, _F12, _F11, _F10, _F9, _F8,
|
||||
_F7, _F6, _F5, _F4, _F3, _F2, _F1, _F0,
|
||||
#endif
|
||||
#define JIT_NOREG _NOREG
|
||||
_NOREG,
|
||||
} jit_reg_t;
|
||||
|
||||
#endif /* _jit_sparc_h */
|
||||
2762
libguile/lightening/lightening/x86-cpu.c
Normal file
2762
libguile/lightening/lightening/x86-cpu.c
Normal file
File diff suppressed because it is too large
Load diff
1036
libguile/lightening/lightening/x86-sse.c
Normal file
1036
libguile/lightening/lightening/x86-sse.c
Normal file
File diff suppressed because it is too large
Load diff
1344
libguile/lightening/lightening/x86-x87.c
Normal file
1344
libguile/lightening/lightening/x86-x87.c
Normal file
File diff suppressed because it is too large
Load diff
832
libguile/lightening/lightening/x86.c
Normal file
832
libguile/lightening/lightening/x86.c
Normal file
|
|
@ -0,0 +1,832 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#if __X32
|
||||
# define jit_arg_reg_p(i) 0
|
||||
# define jit_arg_f_reg_p(i) 0
|
||||
# define stack_framesize 20
|
||||
# define stack_adjust 12
|
||||
# define CVT_OFFSET -12
|
||||
# define REAL_WORDSIZE 4
|
||||
# define va_gp_increment 4
|
||||
# define va_fp_increment 8
|
||||
#else
|
||||
# if __CYGWIN__
|
||||
# define jit_arg_reg_p(i) ((i) >= 0 && (i) < 4)
|
||||
# define jit_arg_f_reg_p(i) jit_arg_reg_p(i)
|
||||
# define stack_framesize 152
|
||||
# define va_fp_increment 8
|
||||
# else
|
||||
# define jit_arg_reg_p(i) ((i) >= 0 && (i) < 6)
|
||||
# define jit_arg_f_reg_p(i) ((i) >= 0 && (i) < 8)
|
||||
# define stack_framesize 56
|
||||
# define first_gp_argument rdi
|
||||
# define first_gp_offset offsetof(jit_va_list_t, rdi)
|
||||
# define first_gp_from_offset(gp) ((gp) / 8)
|
||||
# define last_gp_argument r9
|
||||
# define va_gp_max_offset \
|
||||
(offsetof(jit_va_list_t, r9) - offsetof(jit_va_list_t, rdi) + 8)
|
||||
# define first_fp_argument xmm0
|
||||
# define first_fp_offset offsetof(jit_va_list_t, xmm0)
|
||||
# define last_fp_argument xmm7
|
||||
# define va_fp_max_offset \
|
||||
(offsetof(jit_va_list_t, xmm7) - offsetof(jit_va_list_t, rdi) + 16)
|
||||
# define va_fp_increment 16
|
||||
# define first_fp_from_offset(fp) (((fp) - va_gp_max_offset) / 16)
|
||||
# endif
|
||||
# define va_gp_increment 8
|
||||
# define stack_adjust 8
|
||||
# define CVT_OFFSET -8
|
||||
# define REAL_WORDSIZE 8
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#if __X32 || __CYGWIN__
|
||||
typedef jit_pointer_t jit_va_list_t;
|
||||
#else
|
||||
typedef struct jit_va_list {
|
||||
int32_t gpoff;
|
||||
int32_t fpoff;
|
||||
jit_pointer_t over;
|
||||
jit_pointer_t save;
|
||||
/* Declared explicitly as int64 for the x32 abi */
|
||||
int64_t rdi;
|
||||
int64_t rsi;
|
||||
int64_t rdx;
|
||||
int64_t rcx;
|
||||
int64_t r8;
|
||||
int64_t r9;
|
||||
jit_float64_t xmm0;
|
||||
jit_float64_t _up0;
|
||||
jit_float64_t xmm1;
|
||||
jit_float64_t _up1;
|
||||
jit_float64_t xmm2;
|
||||
jit_float64_t _up2;
|
||||
jit_float64_t xmm3;
|
||||
jit_float64_t _up3;
|
||||
jit_float64_t xmm4;
|
||||
jit_float64_t _up4;
|
||||
jit_float64_t xmm5;
|
||||
jit_float64_t _up5;
|
||||
jit_float64_t xmm6;
|
||||
jit_float64_t _up6;
|
||||
jit_float64_t xmm7;
|
||||
jit_float64_t _up7;
|
||||
} jit_va_list_t;
|
||||
#endif
|
||||
|
||||
jit_cpu_t jit_cpu;
|
||||
static const jit_register_t _rvs[] = {
|
||||
#if __X32
|
||||
{ rc(gpr) | rc(rg8) | 0, "%eax" },
|
||||
{ rc(gpr) | rc(rg8) | 1, "%ecx" },
|
||||
{ rc(gpr) | rc(rg8) | 2, "%edx" },
|
||||
{ rc(sav) | rc(rg8) | rc(gpr) | 3, "%ebx" },
|
||||
{ rc(sav) | rc(gpr) | 6, "%esi" },
|
||||
{ rc(sav) | rc(gpr) | 7, "%edi" },
|
||||
{ rc(sav) | 4, "%esp" },
|
||||
{ rc(sav) | 5, "%ebp" },
|
||||
{ rc(xpr) | rc(fpr) | 0, "%xmm0" },
|
||||
{ rc(xpr) | rc(fpr) | 1, "%xmm1" },
|
||||
{ rc(xpr) | rc(fpr) | 2, "%xmm2" },
|
||||
{ rc(xpr) | rc(fpr) | 3, "%xmm3" },
|
||||
{ rc(xpr) | rc(fpr) | 4, "%xmm4" },
|
||||
{ rc(xpr) | rc(fpr) | 5, "%xmm5" },
|
||||
{ rc(xpr) | rc(fpr) | 6, "%xmm6" },
|
||||
{ rc(xpr) | rc(fpr) | 7, "%xmm7" },
|
||||
#elif __CYGWIN__
|
||||
{ rc(gpr) | rc(rg8) | 0, "%rax" },
|
||||
{ rc(gpr) | rc(rg8) | rc(rg8) | 10, "%r10" },
|
||||
{ rc(gpr) | rc(rg8) | rc(rg8) | 11, "%r11" },
|
||||
{ rc(sav) | rc(rg8) | rc(gpr) | 3, "%rbx" },
|
||||
{ rc(sav) | rc(gpr) | 7, "%rdi" },
|
||||
{ rc(sav) | rc(gpr) | 6, "%rsi" },
|
||||
{ rc(sav) | rc(gpr) | 12, "%r12" },
|
||||
{ rc(sav) | rc(gpr) | 13, "%r13" },
|
||||
{ rc(sav) | rc(gpr) | 14, "%r14" },
|
||||
{ rc(sav) | rc(gpr) | 15, "%r15" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 9, "%r9" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 8, "%r8" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 2, "%rdx" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 1, "%rcx" },
|
||||
{ rc(sav) | 4, "%rsp" },
|
||||
{ rc(sav) | 5, "%rbp" },
|
||||
{ rc(xpr) | rc(fpr) | 4, "%xmm4" },
|
||||
{ rc(xpr) | rc(fpr) | 5, "%xmm5" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 6, "%xmm6" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 7, "%xmm7" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 8, "%xmm8" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 9, "%xmm9" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 10, "%xmm10" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 11, "%xmm11" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 12, "%xmm12" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 13, "%xmm13" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 14, "%xmm14" },
|
||||
{ rc(sav) | rc(xpr) | rc(fpr) | 15, "%xmm15" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 3, "%xmm3" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 2, "%xmm2" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 1, "%xmm1" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 0, "%xmm0" },
|
||||
#else
|
||||
/* %rax is a pseudo flag argument for varargs functions */
|
||||
{ rc(arg) | rc(gpr) | rc(rg8) | 0, "%rax" },
|
||||
{ rc(gpr) | rc(rg8) | 10, "%r10" },
|
||||
{ rc(gpr) | rc(rg8) | 11, "%r11" },
|
||||
{ rc(gpr) | rc(rg8) | 12, "%r12" },
|
||||
{ rc(sav) | rc(rg8) | rc(gpr) | 3, "%rbx" },
|
||||
{ rc(sav) | rc(rg8) | rc(gpr) | 13, "%r13" },
|
||||
{ rc(sav) | rc(rg8) | rc(gpr) | 14, "%r14" },
|
||||
{ rc(sav) | rc(rg8) | rc(gpr) | 15, "%r15" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 9, "%r9" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 8, "%r8" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 1, "%rcx" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 2, "%rdx" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 6, "%rsi" },
|
||||
{ rc(arg) | rc(rg8) | rc(gpr) | 7, "%rdi" },
|
||||
{ rc(sav) | 4, "%rsp" },
|
||||
{ rc(sav) | 5, "%rbp" },
|
||||
{ rc(xpr) | rc(fpr) | 8, "%xmm8" },
|
||||
{ rc(xpr) | rc(fpr) | 9, "%xmm9" },
|
||||
{ rc(xpr) | rc(fpr) | 10, "%xmm10" },
|
||||
{ rc(xpr) | rc(fpr) | 11, "%xmm11" },
|
||||
{ rc(xpr) | rc(fpr) | 12, "%xmm12" },
|
||||
{ rc(xpr) | rc(fpr) | 13, "%xmm13" },
|
||||
{ rc(xpr) | rc(fpr) | 14, "%xmm14" },
|
||||
{ rc(xpr) | rc(fpr) | 15, "%xmm15" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 7, "%xmm7" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 6, "%xmm6" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 5, "%xmm5" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 4, "%xmm4" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 3, "%xmm3" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 2, "%xmm2" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 1, "%xmm1" },
|
||||
{ rc(xpr) | rc(arg) | rc(fpr) | 0, "%xmm0" },
|
||||
#endif
|
||||
{ _NOREG, "<none>" },
|
||||
};
|
||||
|
||||
#include "x86-cpu.c"
|
||||
#include "x86-sse.c"
|
||||
|
||||
jit_bool_t
|
||||
jit_get_cpu(void)
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
uint32_t sse3 : 1;
|
||||
uint32_t pclmulqdq : 1;
|
||||
uint32_t dtes64 : 1; /* amd reserved */
|
||||
uint32_t monitor : 1;
|
||||
uint32_t ds_cpl : 1; /* amd reserved */
|
||||
uint32_t vmx : 1; /* amd reserved */
|
||||
uint32_t smx : 1; /* amd reserved */
|
||||
uint32_t est : 1; /* amd reserved */
|
||||
uint32_t tm2 : 1; /* amd reserved */
|
||||
uint32_t ssse3 : 1;
|
||||
uint32_t cntx_id : 1; /* amd reserved */
|
||||
uint32_t __reserved0 : 1;
|
||||
uint32_t fma : 1;
|
||||
uint32_t cmpxchg16b : 1;
|
||||
uint32_t xtpr : 1; /* amd reserved */
|
||||
uint32_t pdcm : 1; /* amd reserved */
|
||||
uint32_t __reserved1 : 1;
|
||||
uint32_t pcid : 1; /* amd reserved */
|
||||
uint32_t dca : 1; /* amd reserved */
|
||||
uint32_t sse4_1 : 1;
|
||||
uint32_t sse4_2 : 1;
|
||||
uint32_t x2apic : 1; /* amd reserved */
|
||||
uint32_t movbe : 1; /* amd reserved */
|
||||
uint32_t popcnt : 1;
|
||||
uint32_t tsc : 1; /* amd reserved */
|
||||
uint32_t aes : 1;
|
||||
uint32_t xsave : 1;
|
||||
uint32_t osxsave : 1;
|
||||
uint32_t avx : 1;
|
||||
uint32_t __reserved2 : 1; /* amd F16C */
|
||||
uint32_t __reserved3 : 1;
|
||||
uint32_t __alwayszero : 1; /* amd RAZ */
|
||||
} bits;
|
||||
jit_uword_t cpuid;
|
||||
} ecx;
|
||||
union {
|
||||
struct {
|
||||
uint32_t fpu : 1;
|
||||
uint32_t vme : 1;
|
||||
uint32_t de : 1;
|
||||
uint32_t pse : 1;
|
||||
uint32_t tsc : 1;
|
||||
uint32_t msr : 1;
|
||||
uint32_t pae : 1;
|
||||
uint32_t mce : 1;
|
||||
uint32_t cmpxchg8b : 1;
|
||||
uint32_t apic : 1;
|
||||
uint32_t __reserved0 : 1;
|
||||
uint32_t sep : 1;
|
||||
uint32_t mtrr : 1;
|
||||
uint32_t pge : 1;
|
||||
uint32_t mca : 1;
|
||||
uint32_t cmov : 1;
|
||||
uint32_t pat : 1;
|
||||
uint32_t pse36 : 1;
|
||||
uint32_t psn : 1; /* amd reserved */
|
||||
uint32_t clfsh : 1;
|
||||
uint32_t __reserved1 : 1;
|
||||
uint32_t ds : 1; /* amd reserved */
|
||||
uint32_t acpi : 1; /* amd reserved */
|
||||
uint32_t mmx : 1;
|
||||
uint32_t fxsr : 1;
|
||||
uint32_t sse : 1;
|
||||
uint32_t sse2 : 1;
|
||||
uint32_t ss : 1; /* amd reserved */
|
||||
uint32_t htt : 1;
|
||||
uint32_t tm : 1; /* amd reserved */
|
||||
uint32_t __reserved2 : 1;
|
||||
uint32_t pbe : 1; /* amd reserved */
|
||||
} bits;
|
||||
jit_uword_t cpuid;
|
||||
} edx;
|
||||
#if __X32
|
||||
int ac, flags;
|
||||
#endif
|
||||
jit_uword_t eax, ebx;
|
||||
|
||||
#if __X32
|
||||
/* adapted from glibc __sysconf */
|
||||
__asm__ volatile ("pushfl;\n\t"
|
||||
"popl %0;\n\t"
|
||||
"movl $0x240000, %1;\n\t"
|
||||
"xorl %0, %1;\n\t"
|
||||
"pushl %1;\n\t"
|
||||
"popfl;\n\t"
|
||||
"pushfl;\n\t"
|
||||
"popl %1;\n\t"
|
||||
"xorl %0, %1;\n\t"
|
||||
"pushl %0;\n\t"
|
||||
"popfl"
|
||||
: "=r" (flags), "=r" (ac));
|
||||
|
||||
/* i386 or i486 without cpuid */
|
||||
if ((ac & (1 << 21)) == 0)
|
||||
/* probably without x87 as well */
|
||||
return false;
|
||||
#endif
|
||||
|
||||
/* query %eax = 1 function */
|
||||
__asm__ volatile (
|
||||
#if __X32 || __X64_32
|
||||
"xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
|
||||
#else
|
||||
"xchgq %%rbx, %1; cpuid; xchgq %%rbx, %1"
|
||||
#endif
|
||||
: "=a" (eax), "=r" (ebx),
|
||||
"=c" (ecx.cpuid), "=d" (edx.cpuid)
|
||||
: "0" (1));
|
||||
|
||||
jit_cpu.fpu = edx.bits.fpu;
|
||||
jit_cpu.cmpxchg8b = edx.bits.cmpxchg8b;
|
||||
jit_cpu.cmov = edx.bits.cmov;
|
||||
jit_cpu.mmx = edx.bits.mmx;
|
||||
jit_cpu.sse = edx.bits.sse;
|
||||
jit_cpu.sse2 = edx.bits.sse2;
|
||||
jit_cpu.sse3 = ecx.bits.sse3;
|
||||
jit_cpu.pclmulqdq = ecx.bits.pclmulqdq;
|
||||
jit_cpu.ssse3 = ecx.bits.ssse3;
|
||||
jit_cpu.fma = ecx.bits.fma;
|
||||
jit_cpu.cmpxchg16b = ecx.bits.cmpxchg16b;
|
||||
jit_cpu.sse4_1 = ecx.bits.sse4_1;
|
||||
jit_cpu.sse4_2 = ecx.bits.sse4_2;
|
||||
jit_cpu.movbe = ecx.bits.movbe;
|
||||
jit_cpu.popcnt = ecx.bits.popcnt;
|
||||
jit_cpu.aes = ecx.bits.aes;
|
||||
jit_cpu.avx = ecx.bits.avx;
|
||||
|
||||
/* query %eax = 0x80000001 function */
|
||||
__asm__ volatile (
|
||||
#if __X64
|
||||
# if __X64_32
|
||||
"xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
|
||||
# else
|
||||
"xchgq %%rbx, %1; cpuid; xchgq %%rbx, %1"
|
||||
# endif
|
||||
: "=a" (eax), "=r" (ebx),
|
||||
"=c" (ecx.cpuid), "=d" (edx.cpuid)
|
||||
: "0" (0x80000001));
|
||||
jit_cpu.lahf = ecx.cpuid & 1;
|
||||
#endif
|
||||
|
||||
return jit_cpu.sse2;
|
||||
}
|
||||
|
||||
jit_bool_t
|
||||
jit_init(jit_state_t *_jit)
|
||||
{
|
||||
return jit_cpu.sse2;
|
||||
}
|
||||
|
||||
void
|
||||
jit_epilog(jit_state_t *_jit)
|
||||
{
|
||||
/* TODO: Restore registers. */
|
||||
}
|
||||
|
||||
static jit_bool_t
|
||||
is_fpr_arg(jit_arg_abi_t arg)
|
||||
{
|
||||
switch (arg)
|
||||
{
|
||||
case JIT_ARG_ABI_UINT8:
|
||||
case JIT_ARG_ABI_INT8:
|
||||
case JIT_ARG_ABI_UINT16:
|
||||
case JIT_ARG_ABI_INT16:
|
||||
case JIT_ARG_ABI_UINT32:
|
||||
case JIT_ARG_ABI_INT32:
|
||||
case JIT_ARG_ABI_UINT64:
|
||||
case JIT_ARG_ABI_INT64:
|
||||
case JIT_ARG_ABI_POINTER:
|
||||
return 0;
|
||||
case JIT_ARG_ABI_FLOAT:
|
||||
case JIT_ARG_ABI_DOUBLE:
|
||||
return 1;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static jit_bool_t
|
||||
is_gpr_arg(jit_arg_abi_t arg)
|
||||
{
|
||||
return !is_fpr_arg(arg);
|
||||
}
|
||||
|
||||
static const jit_gpr_t abi_gpr_args[] = {
|
||||
#if __X32
|
||||
/* No GPRs in args. */
|
||||
#elif __CYGWIN__
|
||||
JIT_GPR(_RCX), JIT_GPR(_RDX), JIT_GPR(_R8), JIT_GPR(_R9)
|
||||
#else
|
||||
JIT_GPR(_RDI), JIT_GPR(_RSI), JIT_GPR(_RDX), JIT_GPR(_RCX), JIT_GPR(_R8), JIT_GPR(_R9)
|
||||
#endif
|
||||
};
|
||||
|
||||
static const jit_fpr_t abi_fpr_args[] = {
|
||||
#if __X32
|
||||
/* No FPRs in args. */
|
||||
#elif __CYGWIN__
|
||||
JIT_FPR(_XMM0), JIT_FPR(_XMM1), JIT_FPR(_XMM2), JIT_FPR(_XMM3)
|
||||
#else
|
||||
JIT_FPR(_XMM0), JIT_FPR(_XMM1), JIT_FPR(_XMM2), JIT_FPR(_XMM3), JIT_FPR(_XMM4), JIT_FPR(_XMM5), JIT_FPR(_XMM6), JIT_FPR(_XMM7)
|
||||
#endif
|
||||
};
|
||||
|
||||
static const int abi_gpr_arg_count = sizeof(abi_gpr_args) / sizeof(abi_gpr_args[0]);
|
||||
static const int abi_fpr_arg_count = sizeof(abi_fpr_args) / sizeof(abi_fpr_args[0]);
|
||||
|
||||
struct abi_arg_iterator
|
||||
{
|
||||
const jit_arg_abi_t *abi;
|
||||
size_t argc;
|
||||
|
||||
size_t arg_idx;
|
||||
size_t gpr_idx;
|
||||
size_t fpr_idx;
|
||||
size_t stack_size;
|
||||
};
|
||||
|
||||
static void
|
||||
next_abi_arg(struct abi_arg_iterator *iter, jit_arg_t *arg)
|
||||
{
|
||||
ASSERT(iter->arg_idx < iter->argc);
|
||||
jit_arg_abi_t abi = iter->abi[iter->arg_idx];
|
||||
if (is_gpr_arg(abi)) {
|
||||
if (iter->gpr_idx < abi_gpr_arg_count) {
|
||||
arg->kind = JIT_ARG_LOC_GPR;
|
||||
arg->loc.gpr = abi_gpr_args[iter->gpr_idx++];
|
||||
#ifdef __CYGWIN__
|
||||
iter->fpr_idx++;
|
||||
#endif
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
} else {
|
||||
ASSERT(is_fpr_arg(abi));
|
||||
if (iter->fpr_idx < abi_fpr_arg_count) {
|
||||
arg->kind = JIT_ARG_LOC_FPR;
|
||||
arg->loc.fpr = abi_fpr_args[iter->fpr_idx++];
|
||||
#ifdef __CYGWIN__
|
||||
iter->gpr_idx++;
|
||||
#endif
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
iter->arg_idx++;
|
||||
}
|
||||
|
||||
static void
|
||||
abi_gpr_to_mem(jit_state_t *_jit, jit_arg_abi_t abi,
|
||||
jit_gpr_t src, jit_gpr_t base, ptrdiff_t offset)
|
||||
{
|
||||
switch (abi) {
|
||||
case JIT_ARG_ABI_UINT8:
|
||||
case JIT_ARG_ABI_INT8:
|
||||
jit_stxi_c(_jit, offset, base, src);
|
||||
break;
|
||||
case JIT_ARG_ABI_UINT16:
|
||||
case JIT_ARG_ABI_INT16:
|
||||
jit_stxi_s(_jit, offset, base, src);
|
||||
break;
|
||||
case JIT_ARG_ABI_UINT32:
|
||||
case JIT_ARG_ABI_INT32:
|
||||
#if __WORDSIZE == 32
|
||||
case JIT_ARG_ABI_POINTER:
|
||||
#endif
|
||||
jit_stxi_i(_jit, offset, base, src);
|
||||
break;
|
||||
#if __WORDSIZE == 64
|
||||
case JIT_ARG_ABI_UINT64:
|
||||
case JIT_ARG_ABI_INT64:
|
||||
case JIT_ARG_ABI_POINTER:
|
||||
jit_stxi_l(_jit, offset, base, src);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
abi_fpr_to_mem(jit_state_t *_jit, jit_arg_abi_t abi,
|
||||
jit_fpr_t src, jit_gpr_t base, ptrdiff_t offset)
|
||||
{
|
||||
switch (abi) {
|
||||
case JIT_ARG_ABI_FLOAT:
|
||||
jit_stxi_f(_jit, offset, base, src);
|
||||
break;
|
||||
case JIT_ARG_ABI_DOUBLE:
|
||||
jit_stxi_d(_jit, offset, base, src);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
abi_mem_to_gpr(jit_state_t *_jit, jit_arg_abi_t abi,
|
||||
jit_gpr_t dst, jit_gpr_t base, ptrdiff_t offset)
|
||||
{
|
||||
switch (abi) {
|
||||
case JIT_ARG_ABI_UINT8:
|
||||
jit_ldxi_uc(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_INT8:
|
||||
jit_ldxi_c(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_UINT16:
|
||||
jit_ldxi_us(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_INT16:
|
||||
jit_ldxi_s(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_UINT32:
|
||||
jit_ldxi_ui(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_INT32:
|
||||
jit_ldxi_i(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_UINT64:
|
||||
jit_ldxi_l(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_INT64:
|
||||
jit_ldxi_l(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_POINTER:
|
||||
jit_ldxi_l(_jit, dst, base, offset);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
abi_mem_to_fpr(jit_state_t *_jit, jit_arg_abi_t abi,
|
||||
jit_fpr_t dst, jit_gpr_t base, ptrdiff_t offset)
|
||||
{
|
||||
switch (abi) {
|
||||
case JIT_ARG_ABI_FLOAT:
|
||||
jit_ldxi_f(_jit, dst, base, offset);
|
||||
break;
|
||||
case JIT_ARG_ABI_DOUBLE:
|
||||
jit_ldxi_d(_jit, dst, base, offset);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
store_mem_abi_arg(jit_state_t *_jit, jit_arg_abi_t abi,
|
||||
jit_arg_t *arg, jit_gpr_t base, ptrdiff_t offset)
|
||||
{
|
||||
switch (arg->kind) {
|
||||
case JIT_ARG_LOC_GPR:
|
||||
abi_gpr_to_mem(_jit, abi, arg->loc.gpr, base, offset);
|
||||
break;
|
||||
|
||||
case JIT_ARG_LOC_FPR:
|
||||
abi_fpr_to_mem(_jit, abi, arg->loc.fpr, base, offset);
|
||||
break;
|
||||
|
||||
case JIT_ARG_LOC_MEM:
|
||||
if (is_gpr_arg(abi)) {
|
||||
jit_gpr_t tmp = get_temp_gpr(_jit);
|
||||
abi_mem_to_gpr(_jit, abi, tmp, arg->loc.mem.base, arg->loc.mem.offset);
|
||||
abi_gpr_to_mem(_jit, abi, tmp, base, offset);
|
||||
unget_temp_gpr(_jit);
|
||||
} else {
|
||||
jit_fpr_t tmp = get_temp_xpr(_jit);
|
||||
abi_mem_to_fpr(_jit, abi, tmp, arg->loc.mem.base, arg->loc.mem.offset);
|
||||
abi_fpr_to_mem(_jit, abi, tmp, base, offset);
|
||||
unget_temp_xpr(_jit);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
arg->kind = JIT_ARG_LOC_MEM;
|
||||
arg->loc.mem.base = base;
|
||||
arg->loc.mem.offset = offset;
|
||||
}
|
||||
|
||||
static void
|
||||
shuffle_gpr_arg(jit_state_t *_jit, jit_gpr_t dst, size_t argc,
|
||||
jit_arg_t *args, size_t idx)
|
||||
{
|
||||
ASSERT(args[idx].kind == JIT_ARG_LOC_GPR);
|
||||
|
||||
if (rn(args[idx].loc.gpr) == rn(dst))
|
||||
return;
|
||||
|
||||
/* Arg in a reg but it's not the right one. See if this reg
|
||||
holds some other arg, and swap if so. */
|
||||
for (size_t j=idx+1; j<argc; j++)
|
||||
if (args[j].kind == JIT_ARG_LOC_GPR && rn(args[j].loc.gpr) == rn(dst))
|
||||
{
|
||||
xchgr(_jit, rn(args[idx].loc.gpr), rn(dst));
|
||||
args[j].loc.gpr = args[idx].loc.gpr;
|
||||
args[idx].loc.gpr = dst;
|
||||
/* Could be this register holds a value for more than one argument;
|
||||
update subsequent args if any. */
|
||||
for (size_t k=j+1; k<argc; k++)
|
||||
if (args[k].kind == JIT_ARG_LOC_GPR && rn(args[k].loc.gpr) == rn(dst))
|
||||
args[k].loc.gpr = args[j].loc.gpr;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Arg in reg, but it's not the right one, and the desired reg
|
||||
is free. */
|
||||
jit_movr(_jit, dst, args[idx].loc.gpr);
|
||||
args[idx].loc.gpr = dst;
|
||||
}
|
||||
|
||||
static void
|
||||
shuffle_fpr_arg(jit_state_t *_jit, jit_fpr_t dst, size_t argc,
|
||||
jit_arg_t *args, size_t idx)
|
||||
{
|
||||
ASSERT(args[idx].kind == JIT_ARG_LOC_FPR);
|
||||
|
||||
if (rn(args[idx].loc.fpr) == rn(dst))
|
||||
return;
|
||||
|
||||
/* Arg in a reg but it's not the right one. See if this reg
|
||||
holds some other arg, and swap if so. */
|
||||
for (size_t j=idx+1; j<argc; j++)
|
||||
if (args[j].kind == JIT_ARG_LOC_FPR && rn(args[j].loc.fpr) == rn(dst))
|
||||
{
|
||||
jit_fpr_t tmp = get_temp_xpr(_jit);
|
||||
jit_movr_d (_jit, tmp, args[idx].loc.fpr);
|
||||
jit_movr_d (_jit, args[idx].loc.fpr, dst);
|
||||
jit_movr_d (_jit, dst, tmp);
|
||||
unget_temp_xpr(_jit);
|
||||
args[j].loc.fpr = args[idx].loc.fpr;
|
||||
args[idx].loc.fpr = dst;
|
||||
/* Could be this register holds a value for more than one argument;
|
||||
update subsequent args if any. */
|
||||
for (size_t k=j+1; k<argc; k++)
|
||||
if (args[k].kind == JIT_ARG_LOC_FPR && rn(args[k].loc.fpr) == rn(dst))
|
||||
args[k].loc.fpr = args[j].loc.fpr;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Arg in reg, but it's not the right one, and the desired reg
|
||||
is free. */
|
||||
jit_movr_d(_jit, dst, args[idx].loc.fpr);
|
||||
args[idx].loc.fpr = dst;
|
||||
}
|
||||
|
||||
static void
|
||||
reset_abi_arg_iterator(struct abi_arg_iterator *iter, size_t argc,
|
||||
const jit_arg_abi_t *abi)
|
||||
{
|
||||
memset(iter, 0, sizeof *iter);
|
||||
iter->argc = argc;
|
||||
iter->abi = abi;
|
||||
}
|
||||
|
||||
static void
|
||||
prepare_args(jit_state_t *_jit, size_t argc, const jit_arg_abi_t abi[],
|
||||
jit_arg_t args[])
|
||||
{
|
||||
jit_arg_t scratch;
|
||||
struct abi_arg_iterator iter;
|
||||
|
||||
// Compute stack arg size.
|
||||
reset_abi_arg_iterator(&iter, argc, abi);
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
next_abi_arg(&iter, &scratch);
|
||||
|
||||
// Put all ABI memory arguments in place. We do this first because it might
|
||||
// free up some registers.
|
||||
if (iter.stack_size)
|
||||
{
|
||||
size_t stack_size = iter.stack_size;
|
||||
subi(_jit, _RSP_REGNO, _RSP_REGNO, stack_size);
|
||||
reset_abi_arg_iterator(&iter, argc, abi);
|
||||
for (size_t i = 0; i < argc; i++) {
|
||||
next_abi_arg(&iter, &scratch);
|
||||
if (scratch.kind == JIT_ARG_LOC_MEM)
|
||||
store_mem_abi_arg(_jit, abi[i], &args[i],
|
||||
scratch.loc.mem.base, scratch.loc.mem.offset);
|
||||
}
|
||||
}
|
||||
|
||||
// We move on now to the ABI register arguments. All args whose values are in
|
||||
// registers are ABI register arguments, but they might not be the right
|
||||
// register for the correponding ABI argument. Note that there may be ABI
|
||||
// register arguments whose values are still in memory; we will load them
|
||||
// later.
|
||||
reset_abi_arg_iterator(&iter, argc, abi);
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
{
|
||||
next_abi_arg(&iter, &scratch);
|
||||
switch (scratch.kind) {
|
||||
case JIT_ARG_LOC_GPR:
|
||||
if (args[i].kind == JIT_ARG_LOC_GPR)
|
||||
shuffle_gpr_arg(_jit, scratch.loc.gpr, argc, args, i);
|
||||
break;
|
||||
|
||||
case JIT_ARG_LOC_FPR:
|
||||
if (args[i].kind == JIT_ARG_LOC_FPR)
|
||||
shuffle_fpr_arg(_jit, scratch.loc.fpr, argc, args, i);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The only thing that's left is ABI register arguments whose values are still
|
||||
// in memory; load them now.
|
||||
reset_abi_arg_iterator(&iter, argc, abi);
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
{
|
||||
next_abi_arg(&iter, &scratch);
|
||||
switch (scratch.kind) {
|
||||
case JIT_ARG_LOC_GPR:
|
||||
if (args[i].kind == JIT_ARG_LOC_MEM) {
|
||||
abi_mem_to_gpr(_jit, abi[i], scratch.loc.gpr, args[i].loc.mem.base,
|
||||
args[i].loc.mem.offset);
|
||||
args[i].kind = JIT_ARG_LOC_GPR;
|
||||
args[i].loc.gpr = scratch.loc.gpr;
|
||||
}
|
||||
break;
|
||||
|
||||
case JIT_ARG_LOC_FPR:
|
||||
if (args[i].kind == JIT_ARG_LOC_MEM) {
|
||||
abi_mem_to_fpr(_jit, abi[i], scratch.loc.fpr, args[i].loc.mem.base,
|
||||
args[i].loc.mem.offset);
|
||||
args[i].kind = JIT_ARG_LOC_FPR;
|
||||
args[i].loc.fpr = scratch.loc.fpr;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_stack_after_call(jit_state_t *_jit, size_t argc,
|
||||
const jit_arg_abi_t abi[])
|
||||
{
|
||||
jit_arg_t scratch;
|
||||
struct abi_arg_iterator iter;
|
||||
|
||||
// Compute stack arg size.
|
||||
reset_abi_arg_iterator(&iter, argc, abi);
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
next_abi_arg(&iter, &scratch);
|
||||
|
||||
if (iter.stack_size)
|
||||
jit_addi(_jit, JIT_SP, JIT_SP, iter.stack_size);
|
||||
}
|
||||
|
||||
void
|
||||
jit_calli(jit_state_t *_jit, jit_pointer_t f,
|
||||
size_t argc, const jit_arg_abi_t abi[], jit_arg_t args[])
|
||||
{
|
||||
prepare_args(_jit, argc, abi, args);
|
||||
|
||||
calli(_jit, (jit_word_t)f);
|
||||
|
||||
cleanup_stack_after_call(_jit, argc, abi);
|
||||
}
|
||||
|
||||
void
|
||||
jit_callr(jit_state_t *_jit, jit_gpr_t f,
|
||||
size_t argc, const jit_arg_abi_t abi[], jit_arg_t args[])
|
||||
{
|
||||
prepare_args(_jit, argc, abi, args);
|
||||
|
||||
callr(_jit, rn(f));
|
||||
|
||||
cleanup_stack_after_call(_jit, argc, abi);
|
||||
}
|
||||
|
||||
void
|
||||
jit_receive(jit_state_t *_jit,
|
||||
size_t argc, const jit_arg_abi_t abi[], jit_arg_t args[])
|
||||
{
|
||||
struct abi_arg_iterator iter;
|
||||
|
||||
reset_abi_arg_iterator(&iter, argc, abi);
|
||||
for (size_t i = 0; i < argc; i++)
|
||||
next_abi_arg(&iter, &args[i]);
|
||||
}
|
||||
|
||||
void
|
||||
jit_load_args(jit_state_t *_jit, size_t argc,
|
||||
const jit_arg_abi_t abi[], jit_arg_t args[],
|
||||
const jit_anyreg_t regs[])
|
||||
{
|
||||
/* First shuffle any arguments that are already in registers into
|
||||
position. */
|
||||
for (size_t i = 0; i < argc; i++) {
|
||||
switch (args[i].kind) {
|
||||
case JIT_ARG_LOC_IMM:
|
||||
abort();
|
||||
case JIT_ARG_LOC_GPR:
|
||||
shuffle_gpr_arg(_jit, regs[i].gpr, argc, args, i);
|
||||
break;
|
||||
case JIT_ARG_LOC_FPR:
|
||||
shuffle_fpr_arg(_jit, regs[i].fpr, argc, args, i);
|
||||
break;
|
||||
case JIT_ARG_LOC_MEM:
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now load spilled arguments from memory into registers. */
|
||||
for (size_t i = 0; i < argc; i++) {
|
||||
if (args[i].kind == JIT_ARG_LOC_MEM) {
|
||||
if (is_gpr_arg(abi[i]))
|
||||
abi_mem_to_gpr(_jit, abi[i], regs[i].gpr, args[i].loc.mem.base,
|
||||
args[i].loc.mem.offset);
|
||||
else
|
||||
abi_mem_to_fpr(_jit, abi[i], regs[i].fpr, args[i].loc.mem.base,
|
||||
args[i].loc.mem.offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
jit_flush(void *fptr, void *tptr)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
jit_try_shorten(jit_state_t *_jit, jit_reloc_t reloc)
|
||||
{
|
||||
}
|
||||
215
libguile/lightening/lightening/x86.h
Normal file
215
libguile/lightening/lightening/x86.h
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU lightning.
|
||||
*
|
||||
* GNU lightning is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* GNU lightning is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* Authors:
|
||||
* Paulo Cesar Pereira de Andrade
|
||||
*/
|
||||
|
||||
#ifndef _jit_x86_h
|
||||
#define _jit_x86_h
|
||||
|
||||
#define JIT_HASH_CONSTS 1
|
||||
#define JIT_NUM_OPERANDS 2
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
#define jit_sse2_p() jit_cpu.sse2
|
||||
#define jit_x87_reg_p(reg) ((reg) >= _ST0 && (reg) <= _ST6)
|
||||
#if __WORDSIZE == 32
|
||||
# if defined(__x86_64__)
|
||||
# define __X64 1
|
||||
# define __X64_32 1
|
||||
# define __X32 0
|
||||
# else
|
||||
# define __X64 0
|
||||
# define __X64_32 0
|
||||
# define __X32 1
|
||||
# endif
|
||||
#else
|
||||
# define __X64 1
|
||||
# define __X64_32 0
|
||||
# define __X32 0
|
||||
#endif
|
||||
|
||||
#define JIT_FP JIT_GPR(_RBP)
|
||||
typedef enum {
|
||||
#if __X32
|
||||
# define jit_r(i) (_RAX + (i))
|
||||
# define jit_r_num() 3
|
||||
# define jit_v(i) (_RBX + (i))
|
||||
# define jit_v_num() 3
|
||||
# define jit_f(i) (jit_cpu.sse2 ? _XMM0 + (i) : _ST0 + (i))
|
||||
# define jit_f_num() (jit_cpu.sse2 ? 8 : 6)
|
||||
# define JIT_R0 JIT_GPR(_RAX)
|
||||
# define JIT_R1 JIT_GPR(_RCX)
|
||||
# define JIT_R2 JIT_GPR(_RDX)
|
||||
_RAX, _RCX, _RDX,
|
||||
# define JIT_V0 JIT_GPR(_RBX)
|
||||
# define JIT_V1 JIT_GPR(_RSI)
|
||||
# define JIT_V2 JIT_GPR(_RDI)
|
||||
_RBX, _RSI, _RDI,
|
||||
_RSP, _RBP,
|
||||
# define JIT_F0 JIT_FPR(_XMM0)
|
||||
# define JIT_F1 JIT_FPR(_XMM1)
|
||||
# define JIT_F2 JIT_FPR(_XMM2)
|
||||
# define JIT_F3 JIT_FPR(_XMM3)
|
||||
# define JIT_F4 JIT_FPR(_XMM4)
|
||||
# define JIT_F5 JIT_FPR(_XMM5)
|
||||
# define JIT_F6 JIT_FPR(_XMM6)
|
||||
_XMM0, _XMM1, _XMM2, _XMM3, _XMM4, _XMM5, _XMM6, _XMM7,
|
||||
# define jit_sse_reg_p(reg) ((reg) >= _XMM0 && (reg) <= _XMM7)
|
||||
#else
|
||||
# if __CYGWIN__
|
||||
# define jit_r(i) (_RAX + (i))
|
||||
# define jit_r_num() 3
|
||||
# define jit_v(i) (_RBX + (i))
|
||||
# define jit_v_num() 7
|
||||
# define jit_f(index) (_XMM4 + (index))
|
||||
# define jit_f_num() 12
|
||||
# define JIT_R0 JIT_GPR(_RAX)
|
||||
# define JIT_R1 JIT_GPR(_R10)
|
||||
# define JIT_R2 JIT_GPR(_R11)
|
||||
# define JIT_V0 JIT_GPR(_RBX)
|
||||
# define JIT_V1 JIT_GPR(_RDI)
|
||||
# define JIT_V2 JIT_GPR(_RSI)
|
||||
# define JIT_V3 JIT_GPR(_R12)
|
||||
# define JIT_V4 JIT_GPR(_R13)
|
||||
# define JIT_V5 JIT_GPR(_R14)
|
||||
# define JIT_V6 JIT_GPR(_R15)
|
||||
/* Volatile - Return value register */
|
||||
_RAX,
|
||||
/* Volatile */
|
||||
_R10, _R11,
|
||||
/* Nonvolatile */
|
||||
_RBX, _RDI, _RSI,
|
||||
_R12, _R13, _R14, _R15,
|
||||
/* Volatile - Integer arguments (4 to 1) */
|
||||
_R9, _R8, _RDX, _RCX,
|
||||
/* Nonvolatile */
|
||||
_RSP, _RBP,
|
||||
# define JIT_F0 JIT_FPR(_XMM0)
|
||||
# define JIT_F1 JIT_FPR(_XMM1)
|
||||
# define JIT_F2 JIT_FPR(_XMM2)
|
||||
# define JIT_F3 JIT_FPR(_XMM3)
|
||||
# define JIT_F4 JIT_FPR(_XMM4)
|
||||
# define JIT_F5 JIT_FPR(_XMM5)
|
||||
# define JIT_F6 JIT_FPR(_XMM6)
|
||||
# define JIT_F7 JIT_FPR(_XMM7)
|
||||
# define JIT_F8 JIT_FPR(_XMM8)
|
||||
# define JIT_F9 JIT_FPR(_XMM9)
|
||||
# define JIT_F10 JIT_FPR(_XMM10)
|
||||
# define JIT_F11 JIT_FPR(_XMM11)
|
||||
# define JIT_F12 JIT_FPR(_XMM12)
|
||||
# define JIT_F13 JIT_FPR(_XMM13)
|
||||
# define JIT_F14 JIT_FPR(_XMM14)
|
||||
# define JIT_F15 JIT_FPR(_XMM15)
|
||||
/* Volatile */
|
||||
_XMM4, _XMM5,
|
||||
/* Nonvolatile */
|
||||
_XMM6, _XMM7, _XMM8, _XMM9, _XMM10,
|
||||
_XMM11, _XMM12, _XMM13, _XMM14, _XMM15,
|
||||
/* Volatile - FP arguments (4 to 1) */
|
||||
_XMM3, _XMM2, _XMM1, _XMM0,
|
||||
# define jit_sse_reg_p(reg) ((reg) >= _XMM4 && (reg) <= _XMM0)
|
||||
# else
|
||||
# define jit_r(i) (_RAX + (i))
|
||||
# define jit_r_num() 4
|
||||
# define jit_v(i) (_RBX + (i))
|
||||
# define jit_v_num() 4
|
||||
# define jit_f(index) (_XMM8 + (index))
|
||||
# define jit_f_num() 8
|
||||
# define JIT_R0 JIT_GPR(_RAX)
|
||||
# define JIT_R1 JIT_GPR(_R10)
|
||||
# define JIT_R2 JIT_GPR(_R11)
|
||||
# define JIT_R3 JIT_GPR(_R12)
|
||||
_RAX, _R10, _R11, _R12,
|
||||
# define JIT_V0 JIT_GPR(_RBX)
|
||||
# define JIT_V1 JIT_GPR(_R13)
|
||||
# define JIT_V2 JIT_GPR(_R14)
|
||||
# define JIT_V3 JIT_GPR(_R15)
|
||||
_RBX, _R13, _R14, _R15,
|
||||
_R9, _R8, _RCX, _RDX, _RSI, _RDI,
|
||||
_RSP, _RBP,
|
||||
# define JIT_F0 JIT_FPR(_XMM0)
|
||||
# define JIT_F1 JIT_FPR(_XMM1)
|
||||
# define JIT_F2 JIT_FPR(_XMM2)
|
||||
# define JIT_F3 JIT_FPR(_XMM3)
|
||||
# define JIT_F4 JIT_FPR(_XMM4)
|
||||
# define JIT_F5 JIT_FPR(_XMM5)
|
||||
# define JIT_F6 JIT_FPR(_XMM6)
|
||||
# define JIT_F7 JIT_FPR(_XMM7)
|
||||
# define JIT_F8 JIT_FPR(_XMM8)
|
||||
# define JIT_F9 JIT_FPR(_XMM9)
|
||||
# define JIT_F10 JIT_FPR(_XMM10)
|
||||
# define JIT_F11 JIT_FPR(_XMM11)
|
||||
# define JIT_F12 JIT_FPR(_XMM12)
|
||||
# define JIT_F13 JIT_FPR(_XMM13)
|
||||
# define JIT_F14 JIT_FPR(_XMM14)
|
||||
# define JIT_F15 JIT_FPR(_XMM15)
|
||||
_XMM8, _XMM9, _XMM10, _XMM11, _XMM12, _XMM13, _XMM14, _XMM15,
|
||||
_XMM7, _XMM6, _XMM5, _XMM4, _XMM3, _XMM2, _XMM1, _XMM0,
|
||||
# define jit_sse_reg_p(reg) ((reg) >= _XMM8 && (reg) <= _XMM0)
|
||||
# endif
|
||||
#endif
|
||||
# define JIT_NOREG _NOREG
|
||||
_NOREG,
|
||||
} jit_reg_t;
|
||||
|
||||
typedef struct {
|
||||
/* x87 present */
|
||||
uint32_t fpu : 1;
|
||||
/* cmpxchg8b instruction */
|
||||
uint32_t cmpxchg8b : 1;
|
||||
/* cmov and fcmov branchless conditional mov */
|
||||
uint32_t cmov : 1;
|
||||
/* mmx registers/instructions available */
|
||||
uint32_t mmx : 1;
|
||||
/* sse registers/instructions available */
|
||||
uint32_t sse : 1;
|
||||
/* sse2 registers/instructions available */
|
||||
uint32_t sse2 : 1;
|
||||
/* sse3 instructions available */
|
||||
uint32_t sse3 : 1;
|
||||
/* pcmulqdq instruction */
|
||||
uint32_t pclmulqdq : 1;
|
||||
/* ssse3 suplemental sse3 instructions available */
|
||||
uint32_t ssse3 : 1;
|
||||
/* fused multiply/add using ymm state */
|
||||
uint32_t fma : 1;
|
||||
/* cmpxchg16b instruction */
|
||||
uint32_t cmpxchg16b : 1;
|
||||
/* sse4.1 instructions available */
|
||||
uint32_t sse4_1 : 1;
|
||||
/* sse4.2 instructions available */
|
||||
uint32_t sse4_2 : 1;
|
||||
/* movbe instruction available */
|
||||
uint32_t movbe : 1;
|
||||
/* popcnt instruction available */
|
||||
uint32_t popcnt : 1;
|
||||
/* aes instructions available */
|
||||
uint32_t aes : 1;
|
||||
/* avx instructions available */
|
||||
uint32_t avx : 1;
|
||||
/* lahf/sahf available in 64 bits mode */
|
||||
uint32_t lahf : 1;
|
||||
} jit_cpu_t;
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
JIT_API jit_cpu_t jit_cpu;
|
||||
|
||||
#endif /* _jit_x86_h */
|
||||
1760
libguile/lightening/lightning.texi
Normal file
1760
libguile/lightening/lightning.texi
Normal file
File diff suppressed because it is too large
Load diff
24
libguile/lightening/tests/Makefile
Normal file
24
libguile/lightening/tests/Makefile
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
TESTS=$(sort $(basename $(wildcard *.c)))
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -O0 -g
|
||||
|
||||
all: $(addprefix test-,$(TESTS))
|
||||
|
||||
check: all
|
||||
@echo "Running unit tests..."
|
||||
@set -e; for test in $(TESTS); do \
|
||||
echo "Testing: $$test"; \
|
||||
./test-$$test; \
|
||||
done
|
||||
@echo "Success."
|
||||
|
||||
lightening.o: ../lightening.h ../lightening/*.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o lightening.o -c ../lightening/lightening.c
|
||||
|
||||
test-%: %.c lightening.o test.h
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening.o $<
|
||||
|
||||
clean:
|
||||
rm -f $(addprefix test-,$(TESTS))
|
||||
rm -f lightening.o
|
||||
30
libguile/lightening/tests/absr_d.c
Normal file
30
libguile/lightening/tests/absr_d.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_absr_d(j, JIT_F0, JIT_F0);
|
||||
jit_retr_d(j, JIT_F0);
|
||||
|
||||
double (*f)(double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0.0) == 0.0);
|
||||
ASSERT(f(-0.0) == 0.0);
|
||||
ASSERT(f(0.5) == 0.5);
|
||||
ASSERT(f(-0.5) == 0.5);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
30
libguile/lightening/tests/absr_f.c
Normal file
30
libguile/lightening/tests/absr_f.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_absr_f(j, JIT_F0, JIT_F0);
|
||||
jit_retr_f(j, JIT_F0);
|
||||
|
||||
float (*f)(float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0.0) == 0.0);
|
||||
ASSERT(f(-0.0) == 0.0);
|
||||
ASSERT(f(0.5) == 0.5);
|
||||
ASSERT(f(-0.5) == 0.5);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
29
libguile/lightening/tests/addi.c
Normal file
29
libguile/lightening/tests/addi.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_addi(j, JIT_R0, JIT_R0, 69);
|
||||
jit_retr(j, JIT_R0);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
int (*f)(int) = ret;
|
||||
ASSERT(f(42) == 111);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
29
libguile/lightening/tests/addr.c
Normal file
29
libguile/lightening/tests/addr.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 }};
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_addr(j, JIT_R0, JIT_R0, JIT_R1);
|
||||
jit_retr(j, JIT_R0);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
int (*f)(int, int) = ret;
|
||||
ASSERT(f(42, 69) == 111);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
30
libguile/lightening/tests/addr_d.c
Normal file
30
libguile/lightening/tests/addr_d.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 }};
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_addr_d(j, JIT_F0, JIT_F0, JIT_F1);
|
||||
jit_retr_d(j, JIT_F0);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
double (*f)(double, double) = ret;
|
||||
ASSERT(f(42., 69.) == 111.);
|
||||
ASSERT(f(42.5, 69.5) == 112.);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
30
libguile/lightening/tests/addr_f.c
Normal file
30
libguile/lightening/tests/addr_f.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 }};
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_addr_f(j, JIT_F0, JIT_F0, JIT_F1);
|
||||
jit_retr_f(j, JIT_F0);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
float (*f)(float, float) = ret;
|
||||
ASSERT(f(42.f, 69.f) == 111.f);
|
||||
ASSERT(f(42.5f, 69.5f) == 112.f);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
65
libguile/lightening/tests/addx.c
Normal file
65
libguile/lightening/tests/addx.c
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 }};
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
jit_movi(j, JIT_R2, 0);
|
||||
jit_addcr(j, JIT_R0, JIT_R0, JIT_R1);
|
||||
jit_addxi(j, JIT_R2, JIT_R2, 0);
|
||||
jit_retr(j, JIT_R2);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = ret;
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
|
||||
#if __WORDSIZE == 32
|
||||
/* carry */
|
||||
ASSERT(f(0xffffffff, 0xffffffff) == 1);
|
||||
/* overflow */
|
||||
ASSERT(f(0x7fffffff, 1) == 0);
|
||||
/* overflow */
|
||||
ASSERT(f(0x7fffffff, 0x7fffffff) == 0);
|
||||
/* carry */
|
||||
ASSERT(f(0x7fffffff, 0x80000000) == 0);
|
||||
/* carry+overflow */
|
||||
ASSERT(f(0x80000000, 0x80000000) == 1);
|
||||
#else
|
||||
/* nothing */
|
||||
ASSERT(f(0xffffffff, 0xffffffff) == 0);
|
||||
/* nothing */
|
||||
ASSERT(f(0x7fffffff, 1) == 0);
|
||||
/* nothing */
|
||||
ASSERT(f(0x7fffffff, 0x7fffffff) == 0);
|
||||
/* nothing */
|
||||
ASSERT(f(0x7fffffff, 0x80000000) == 0);
|
||||
/* nothing */
|
||||
ASSERT(f(0x80000000, 0x80000000) == 0);
|
||||
/* carry */
|
||||
ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 1);
|
||||
/* overflow */
|
||||
ASSERT(f(0x7fffffffffffffff, 1) == 0);
|
||||
/* overflow */
|
||||
ASSERT(f(0x7fffffffffffffff, 0x7fffffffffffffff) == 0);
|
||||
/* overflow */
|
||||
ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0);
|
||||
/* carry+overflow */
|
||||
ASSERT(f(0x8000000000000000, 0x8000000000000000) == 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
35
libguile/lightening/tests/andi.c
Normal file
35
libguile/lightening/tests/andi.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_andi(j, JIT_R0, JIT_R0, 1);
|
||||
jit_retr(j, JIT_R0);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
intmax_t (*f)(intmax_t) = ret;
|
||||
|
||||
ASSERT(f(0x7fffffff) == 1);
|
||||
ASSERT(f(0x80000000) == 0);
|
||||
#if __WORDSIZE == 64
|
||||
ASSERT(f(0x7fffffffffffffff) == 1);
|
||||
ASSERT(f(0x8000000000000000) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
51
libguile/lightening/tests/andr.c
Normal file
51
libguile/lightening/tests/andr.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 }};
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_andr(j, JIT_R0, JIT_R0, JIT_R1);
|
||||
jit_retr(j, JIT_R0);
|
||||
|
||||
size_t size = 0;
|
||||
void* ret = jit_end(j, &size);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = ret;
|
||||
|
||||
ASSERT(f(0x7fffffff, 1) == 1);
|
||||
ASSERT(f(1, 0x7fffffff) == 1);
|
||||
ASSERT(f(0x80000000, 1) == 0);
|
||||
ASSERT(f(1, 0x80000000) == 0);
|
||||
ASSERT(f(0x7fffffff, 0x80000000) == 0);
|
||||
ASSERT(f(0x80000000, 0x7fffffff) == 0);
|
||||
ASSERT(f(0x7fffffff, 0xffffffff) == 0x7fffffff);
|
||||
ASSERT(f(0xffffffff, 0x7fffffff) == 0x7fffffff);
|
||||
ASSERT(f(0xffffffff, 0xffffffff) == 0xffffffff);
|
||||
ASSERT(f(0x7fffffff, 0) == 0);
|
||||
ASSERT(f(0, 0x7fffffff) == 0);
|
||||
#if __WORDSIZE == 64
|
||||
ASSERT(f(0x7fffffffffffffff, 1) == 1);
|
||||
ASSERT(f(1, 0x7fffffffffffffff) == 1);
|
||||
ASSERT(f(0x8000000000000000, 1) == 0);
|
||||
ASSERT(f(1, 0x8000000000000000) == 0);
|
||||
ASSERT(f(0x7fffffffffffffff, 0x8000000000000000) == 0);
|
||||
ASSERT(f(0x8000000000000000, 0x7fffffffffffffff) == 0);
|
||||
ASSERT(f(0x7fffffffffffffff, 0xffffffffffffffff) == 0x7fffffffffffffff);
|
||||
ASSERT(f(0xffffffffffffffff, 0x7fffffffffffffff) == 0x7fffffffffffffff);
|
||||
ASSERT(f(0xffffffffffffffff, 0xffffffffffffffff) == 0xffffffffffffffff);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/beqi.c
Normal file
31
libguile/lightening/tests/beqi.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_beqi(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
34
libguile/lightening/tests/beqr.c
Normal file
34
libguile/lightening/tests/beqr.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_beqr(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
ASSERT(f(1, 1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
37
libguile/lightening/tests/beqr_d.c
Normal file
37
libguile/lightening/tests/beqr_d.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_beqr_d(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(double, double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
ASSERT(f(1, 1) == 1);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
37
libguile/lightening/tests/beqr_f.c
Normal file
37
libguile/lightening/tests/beqr_f.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_beqr_f(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(float, float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
ASSERT(f(1, 1) == 1);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/bgei.c
Normal file
31
libguile/lightening/tests/bgei.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgei(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/bgei_u.c
Normal file
31
libguile/lightening/tests/bgei_u.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgei_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bger.c
Normal file
33
libguile/lightening/tests/bger.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bger(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bger_d.c
Normal file
36
libguile/lightening/tests/bger_d.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bger_d(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(double, double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bger_f.c
Normal file
36
libguile/lightening/tests/bger_f.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bger_f(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(float, float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bger_u.c
Normal file
33
libguile/lightening/tests/bger_u.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bger_u(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/bgti.c
Normal file
31
libguile/lightening/tests/bgti.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgti(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/bgti_u.c
Normal file
31
libguile/lightening/tests/bgti_u.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgti_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 1);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bgtr.c
Normal file
33
libguile/lightening/tests/bgtr.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgtr(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bgtr_d.c
Normal file
36
libguile/lightening/tests/bgtr_d.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgtr_d(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(double, double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bgtr_f.c
Normal file
36
libguile/lightening/tests/bgtr_f.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgtr_f(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(float, float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bgtr_u.c
Normal file
33
libguile/lightening/tests/bgtr_u.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bgtr_u(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 0);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/blei.c
Normal file
31
libguile/lightening/tests/blei.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blei(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/blei_u.c
Normal file
31
libguile/lightening/tests/blei_u.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blei_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bler.c
Normal file
33
libguile/lightening/tests/bler.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bler(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bler_d.c
Normal file
36
libguile/lightening/tests/bler_d.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bler_d(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(double, double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bler_f.c
Normal file
36
libguile/lightening/tests/bler_f.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bler_f(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(float, float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bler_u.c
Normal file
33
libguile/lightening/tests/bler_u.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bler_u(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
38
libguile/lightening/tests/bltgtr_d.c
Normal file
38
libguile/lightening/tests/bltgtr_d.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bltgtr_d(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(double, double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
ASSERT(f(1, 1) == 0);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0.0/0.0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
38
libguile/lightening/tests/bltgtr_f.c
Normal file
38
libguile/lightening/tests/bltgtr_f.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bltgtr_f(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(float, float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
ASSERT(f(1, 1) == 0);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0.0/0.0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/blti.c
Normal file
31
libguile/lightening/tests/blti.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blti(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
31
libguile/lightening/tests/blti_u.c
Normal file
31
libguile/lightening/tests/blti_u.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_blti_u(j, JIT_R0, 0);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 0);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bltr.c
Normal file
33
libguile/lightening/tests/bltr.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bltr(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bltr_d.c
Normal file
36
libguile/lightening/tests/bltr_d.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_DOUBLE, JIT_ARG_ABI_DOUBLE };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bltr_d(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(double, double) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
36
libguile/lightening/tests/bltr_f.c
Normal file
36
libguile/lightening/tests/bltr_f.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_FLOAT, JIT_ARG_ABI_FLOAT };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .fpr=JIT_F0 }, { .fpr=JIT_F1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bltr_f(j, JIT_F0, JIT_F1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(float, float) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 0);
|
||||
|
||||
ASSERT(f(0, 0.0/0.0) == 0);
|
||||
ASSERT(f(0.0/0.0, 0) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
33
libguile/lightening/tests/bltr_u.c
Normal file
33
libguile/lightening/tests/bltr_u.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bltr_u(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 0);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 0);
|
||||
ASSERT(f(-1, 0) == 0);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
32
libguile/lightening/tests/bmci.c
Normal file
32
libguile/lightening/tests/bmci.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[1];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 } };
|
||||
|
||||
jit_receive(j, 1, abi, args);
|
||||
jit_load_args(j, 1, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bmci(j, JIT_R0, 1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0) == 1);
|
||||
ASSERT(f(1) == 0);
|
||||
ASSERT(f(-1) == 0);
|
||||
ASSERT(f(2) == 1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
37
libguile/lightening/tests/bmcr.c
Normal file
37
libguile/lightening/tests/bmcr.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "test.h"
|
||||
|
||||
static void
|
||||
run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
|
||||
{
|
||||
jit_begin(j, arena_base, arena_size);
|
||||
|
||||
const jit_arg_abi_t abi[] = { JIT_ARG_ABI_INTMAX, JIT_ARG_ABI_INTMAX };
|
||||
jit_arg_t args[2];
|
||||
const jit_anyreg_t regs[] = { { .gpr=JIT_R0 }, { .gpr=JIT_R1 } };
|
||||
|
||||
jit_receive(j, 2, abi, args);
|
||||
jit_load_args(j, 2, abi, args, regs);
|
||||
|
||||
jit_reloc_t r = jit_bmcr(j, JIT_R0, JIT_R1);
|
||||
jit_reti(j, 0);
|
||||
jit_patch_here(j, r);
|
||||
jit_reti(j, 1);
|
||||
|
||||
intmax_t (*f)(intmax_t, intmax_t) = jit_end(j, NULL);
|
||||
|
||||
ASSERT(f(0, 0) == 1);
|
||||
ASSERT(f(0, 1) == 1);
|
||||
ASSERT(f(1, 0) == 1);
|
||||
ASSERT(f(-1, 0) == 1);
|
||||
ASSERT(f(0, -1) == 1);
|
||||
ASSERT(f(1, 1) == 0);
|
||||
ASSERT(f(1, -1) == 0);
|
||||
ASSERT(f(-1, 1) == 0);
|
||||
ASSERT(f(-1, -1) == 0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return main_helper(argc, argv, run_test);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue