Merge commit '57999ac9b9d32775efc271e0edfed27b784ee1c6' as 'parallel-rsp'

This commit is contained in:
Logan McNaughton committed 2020-10-31 15:49:56 -06:00
commit d9155d3878
377 files changed
+137898

No files matched your search

+1
View File
@@ -0,0 +1 @@
ChangeLog merge=merge-changelog
+33
View File
@@ -0,0 +1,33 @@
+*
autom4te.cache
aclocal.m4
depcomp
INSTALL
Makefile
Makefile.in
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
install-sh
libtool
lightning-*.tar.*
ltmain.sh
missing
size
stamp-h1
test-driver
check/.deps
doc/.deps
lib/.deps
m4/libtool.m4
m4/lt~obsolete.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
doc/mdate-sh
doc/texinfo.tex
lightning.pc
+12
View File
@@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = https://git.savannah.gnu.org/git/lightning.git
branch = master
commit = b0b8eb5e856c0d29053dc842e1919a2eb58c8cda
parent = 9f797430963d9cf0fcef7d963466f9cac7026de2
method = merge
cmdver = 0.4.1
+14
View 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
View 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
View 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
View 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.
File diff suppressed because it is too large. Load diff
+45
View File
@@ -0,0 +1,45 @@
#
# Copyright 2000, 2001, 2002, 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.
#
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = \
check \
doc \
include \
lib
pkgconfiglibdir = $(libdir)/pkgconfig
pkgconfiglib_DATA = lightning.pc
if get_jit_size
JIT_SIZE_PATH = "$(top_builddir)/jit_$(cpu)-sz.c"
AM_CPPFLAGS=-DGET_JIT_SIZE=1 -DJIT_SIZE_PATH='$(JIT_SIZE_PATH)'
AM_CFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE $(LIGHTNING_CFLAGS)
noinst_PROGRAMS = size
size_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
size_SOURCES = size.c
get_jit_size:: $(JIT_SIZE_PATH)
$(JIT_SIZE_PATH):
make clean
make check
$(top_builddir)/size
CLEANFILES = $(JIT_SIZE_PATH)
endif
+199
View 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.
+3
View File
@@ -0,0 +1,3 @@
GNU lightning is a library to aid in making portable programs
that compile assembly code at run time. For more information,
look at the info documentation.
+21
View File
@@ -0,0 +1,21 @@
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>
Bruno Haible <bruno@clisp.org>
Marc Nieper-Wißkirchen <marc@nieper-wisskirchen.de>
+28
View File
@@ -0,0 +1,28 @@
* Validate that divrem in jit_x86-cpu.c is not modifying
the non result arguments. This is not verified by clobber.tst,
as it only checks registers not involved in the operation
(because it does not know about values being set as input
for the the operation).
* Write a simple higher level language implementation generating
jit with lightning, that could be some lisp or C like language.
* rerun ./configure --enable-devel-get-jit-size and regenerate
the related jit_$arch-sz.c for the ports where nodata is
meaningful:
hppa (done)
i586 (done)
ia64
mips o32 (done)
mips n32
mips n64
powerpc 32 (done)
powerpc 64 (done)
ppc
s390x (done)
sparc (done)
x86_64 (done)
Missing ones are due to no longer (remote) access to such hosts
and may be broken with jit_set_data(..., JIT_DISABLE_DATA).
(ia64 hp-ux or linx), (irix mips for 32 or 64 abi), and
(darwin ppc).
+22
View File
@@ -0,0 +1,22 @@
0
1
1
1
0
1
1
1
0
1
1
0
1
1
1
0
1
1
1
0
1
1
+118
View File
@@ -0,0 +1,118 @@
.data 32
dfmt:
.c "%1.0f\n"
ifmt:
.c "%d\n"
.code
jmpi main
#define def_test_double(a, b, c) \
name test_double_##a##_##b##_##c \
test_double_##a##_##b##_##c: \
prolog \
arg_d $d0 \
arg_d $d1 \
getarg_d %b $d0 \
getarg_d %c $d1 \
subr_d %a %b %c \
retr_d %a \
epilog
#define test_double(a, b, c, x, y) \
prepare \
pushargi_d x \
pushargi_d y \
finishi test_double_##a##_##b##_##c \
retval_d %f0 \
prepare \
pushargi dfmt \
ellipsis \
pushargr_d %f0 \
finishi @printf
#define def_test_int(a, b, c) \
name test_int_##a##_##b##_##c \
test_int_##a##_##b##_##c: \
prolog \
arg $i0 \
arg $i1 \
getarg %b $i0 \
getarg %c $i1 \
subr %a %b %c \
retr %a \
epilog
#define test_int(a, b, c, x, y) \
prepare \
pushargi x \
pushargi y \
finishi test_int_##a##_##b##_##c \
retval %r0 \
prepare \
pushargi ifmt \
ellipsis \
pushargr %r0 \
finishi @printf
def_test_double(f0, f0, f0)
def_test_double(f0, f0, f1)
def_test_double(f0, f1, f0)
def_test_double(f0, f1, f2)
def_test_double(f3, f3, f3)
def_test_double(f3, f3, f1)
def_test_double(f3, f1, f3)
def_test_double(f3, f1, f2)
def_test_double(f3, f0, f0)
def_test_double(f3, f0, f3)
def_test_double(f3, f3, f0)
def_test_int(r0, r0, r0)
def_test_int(r0, r0, r1)
def_test_int(r0, r1, r0)
def_test_int(r0, r1, r2)
def_test_int(v0, v0, v0)
def_test_int(v0, v0, r1)
def_test_int(v0, r1, v0)
def_test_int(v0, r1, r2)
def_test_int(v0, r0, r0)
def_test_int(v0, r0, v0)
def_test_int(v0, v0, r0)
name main
main:
prolog
test_double(f0, f0, f0, 3.0, 2.0)
test_double(f0, f0, f1, 3.0, 2.0)
test_double(f0, f1, f0, 3.0, 2.0)
test_double(f0, f1, f2, 3.0, 2.0)
test_double(f3, f3, f3, 3.0, 2.0)
test_double(f3, f3, f1, 3.0, 2.0)
test_double(f3, f1, f3, 3.0, 2.0)
test_double(f3, f1, f2, 3.0, 2.0)
test_double(f3, f0, f0, 3.0, 2.0)
test_double(f3, f0, f3, 3.0, 2.0)
test_double(f3, f3, f0, 3.0, 2.0)
test_int(r0, r0, r0, 3, 2)
test_int(r0, r0, r1, 3, 2)
test_int(r0, r1, r0, 3, 2)
test_int(r0, r1, r2, 3, 2)
test_int(v0, v0, v0, 3, 2)
test_int(v0, v0, r1, 3, 2)
test_int(v0, r1, v0, 3, 2)
test_int(v0, r1, r2, 3, 2)
test_int(v0, r0, r0, 3, 2)
test_int(v0, r0, v0, 3, 2)
test_int(v0, v0, r0, 3, 2)
ret
epilog
+318
View File
@@ -0,0 +1,318 @@
#
# Copyright 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.
#
AM_CFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE
check_PROGRAMS = lightning ccall self setcode nodata ctramp carg cva_list
lightning_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
lightning_SOURCES = lightning.c
ccall_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
ccall_SOURCES = ccall.c
self_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
self_SOURCES = self.c
setcode_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
setcode_SOURCES = setcode.c
nodata_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
nodata_SOURCES = nodata.c
ctramp_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
ctramp_SOURCES = ctramp.c
carg_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
carg_SOURCES = carg.c
cva_list_LDADD = $(top_builddir)/lib/liblightning.la -lm $(SHLIB)
cva_list_SOURCES = cva_list.c
$(top_builddir)/lib/liblightning.la:
cd $(top_builddir)/lib; $(MAKE) $(AM_MAKEFLAGS) liblightning.la
EXTRA_DIST = \
3to2.tst 3to2.ok \
add.tst add.ok \
align.tst align.ok \
allocai.tst allocai.ok \
allocar.tst allocar.ok \
bp.tst bp.ok \
divi.tst divi.ok \
fib.tst fib.ok \
rpn.tst rpn.ok \
ldst.inc \
ldstr.tst ldstr.ok \
ldsti.tst ldsti.ok \
ldstxr.tst ldstxr.ok \
ldstxi.tst ldstxi.ok \
ldstr-c.tst ldstr-c.ok \
ldstxr-c.tst ldstxr-c.ok \
ldstxi-c.tst ldstxi-c.ok \
cvt.tst cvt.ok \
hton.tst hton.ok \
branch.tst branch.ok \
alu.inc \
alu_add.tst alu_add.ok \
alux_add.tst alux_add.ok \
alu_sub.tst alu_sub.ok \
alux_sub.tst alux_sub.ok \
alu_rsb.tst alu_rsb.ok \
alu_mul.tst alu_mul.ok \
alu_div.tst alu_div.ok \
alu_rem.tst alu_rem.ok \
alu_and.tst alu_and.ok \
alu_or.tst alu_or.ok \
alu_xor.tst alu_xor.ok \
alu_lsh.tst alu_lsh.ok \
alu_rsh.tst alu_rsh.ok \
alu_com.tst alu_com.ok \
alu_neg.tst alu_neg.ok \
fop_abs.tst fop_abs.ok \
fop_sqrt.tst fop_sqrt.ok \
varargs.tst varargs.ok \
stack.tst stack.ok \
clobber.tst clobber.ok \
carry.tst carry.ok \
call.tst call.ok \
float.tst float.ok \
jmpr.tst jmpr.ok \
put.tst put.ok \
qalu.inc \
qalu_mul.tst qalu_mul.ok \
qalu_div.tst qalu_div.ok \
range.tst range.ok \
ranger.tst ranger.ok \
ret.tst ret.ok \
tramp.tst tramp.ok \
va_list.tst va_list.ok \
check.sh \
check.x87.sh \
check.arm.sh check.swf.sh \
check.arm.swf.sh \
check.arm4.swf.sh \
check.nodata.sh \
check.x87.nodata.sh \
run-test all.tst
base_TESTS = \
3to2 add align allocai \
allocar bp divi fib rpn \
ldstr ldsti \
ldstxr ldstxi \
ldstr-c ldstxr-c ldstxi-c \
cvt hton branch \
alu_add alux_add \
alu_sub alux_sub alu_rsb \
alu_mul alu_div alu_rem \
alu_and alu_or alu_xor \
alu_lsh alu_rsh \
alu_com alu_neg \
fop_abs fop_sqrt \
varargs stack \
clobber carry call \
float jmpr put \
qalu_mul qalu_div \
range ranger ret tramp \
va_list
$(base_TESTS): check.sh
$(LN_S) $(srcdir)/check.sh $@
TESTS = $(base_TESTS)
if test_x86_x87
#x87_TESTS = $(addsuffix .x87, $(base_TESTS))
x87_TESTS = \
3to2.x87 add.x87 allocai.x87 \
allocar.x87 bp.x87 divi.x87 fib.x87 \
rpn.x87 ldstr.x87 ldsti.x87 \
ldstxr.x87 ldstxi.x87 \
ldstr-c.x87 ldstxr-c.x87 ldstxi-c.x87 \
cvt.x87 branch.x87 \
alu_add.x87 alux_add.x87 \
alu_sub.x87 alux_sub.x87 alu_rsb.x87 \
alu_mul.x87 alu_div.x87 alu_rem.x87 \
alu_and.x87 alu_or.x87 alu_xor.x87 \
alu_lsh.x87 alu_rsh.x87 \
alu_com.x87 alu_neg.x87 \
fop_abs.x87 fop_sqrt.x87 \
varargs.x87 stack.x87 \
clobber.x87 carry.x87 call.x87 \
float.x87 jmpr.x87 put.x87 \
va_list.x87
$(x87_TESTS): check.x87.sh
$(LN_S) $(srcdir)/check.x87.sh $@
TESTS += $(x87_TESTS)
#x87_nodata_TESTS = $(addsuffix .x87.nodata, $(base_TESTS))
x87_nodata_TESTS = \
3to2.x87.nodata add.x87.nodata allocai.x87.nodata \
allocar.x87.nodata bp.x87.nodata divi.x87.nodata fib.x87.nodata \
rpn.x87.nodata ldstr.x87.nodata ldsti.x87.nodata \
ldstxr.x87.nodata ldstxi.x87.nodata \
ldstr-c.x87.nodata ldstxr-c.x87.nodata ldstxi-c.x87.nodata \
cvt.x87.nodata branch.x87.nodata \
alu_add.x87.nodata alux_add.x87.nodata \
alu_sub.x87.nodata alux_sub.x87.nodata alu_rsb.x87.nodata \
alu_mul.x87.nodata alu_div.x87.nodata alu_rem.x87.nodata \
alu_and.x87.nodata alu_or.x87.nodata alu_xor.x87.nodata \
alu_lsh.x87.nodata alu_rsh.x87.nodata \
alu_com.x87.nodata alu_neg.x87.nodata \
fop_abs.x87.nodata fop_sqrt.x87.nodata \
varargs.x87.nodata stack.x87.nodata \
clobber.x87.nodata carry.x87.nodata call.x87.nodata \
float.x87.nodata jmpr.x87.nodata put.x87.nodata \
va_list.x87.nodata
$(x87_nodata_TESTS): check.x87.nodata.sh
$(LN_S) $(srcdir)/check.x87.nodata.sh $@
TESTS += $(x87_nodata_TESTS)
endif
if test_arm_arm
#arm_TESTS = $(addsuffix .arm, $(base_TESTS))
arm_TESTS = \
3to2.arm add.arm align.arm allocai.arm \
allocar.arm bp.arm divi.arm fib.arm \
rpn.arm ldstr.arm ldsti.arm \
ldstxr.arm ldstxi.arm \
ldstr-c.arm ldstxr-c.arm ldstxi-c.arm \
cvt.arm hton.arm branch.arm \
alu_add.arm alux_add.arm \
alu_sub.arm alux_sub.arm alu_rsb.arm \
alu_mul.arm alu_div.arm alu_rem.arm \
alu_and.arm alu_or.arm alu_xor.arm \
alu_lsh.arm alu_rsh.arm \
alu_com.arm alu_neg.arm \
fop_abs.arm fop_sqrt.arm \
varargs.arm stack.arm \
clobber.arm carry.arm call.arm \
float.arm jmpr.arm tramp.arm range.arm \
ranger.arm put.arm va_list.arm
$(arm_TESTS): check.arm.sh
$(LN_S) $(srcdir)/check.arm.sh $@
TESTS += $(arm_TESTS)
endif
if test_arm_swf
#swf_TESTS = $(addsuffix .swf, $(base_TESTS))
swf_TESTS = \
3to2.swf add.swf allocai.swf \
allocar.swf bp.swf divi.swf fib.swf \
rpn.swf ldstr.swf ldsti.swf \
ldstxr.swf ldstxi.swf \
ldstr-c.swf ldstxr-c.swf ldstxi-c.swf \
cvt.swf hton.swf branch.swf \
alu_add.swf alux_add.swf \
alu_sub.swf alux_sub.swf alu_rsb.swf \
alu_mul.swf alu_div.swf alu_rem.swf \
alu_and.swf alu_or.swf alu_xor.swf \
alu_lsh.swf alu_rsh.swf \
alu_com.swf alu_neg.swf \
fop_abs.swf fop_sqrt.swf \
varargs.swf stack.swf \
clobber.swf carry.swf call.swf \
float.swf jmpr.swf tramp.swf range.swf \
ranger.swf put.swf va_list.swf
$(swf_TESTS): check.swf.sh
$(LN_S) $(srcdir)/check.swf.sh $@
TESTS += $(swf_TESTS)
if test_arm_arm
#arm_swf_TESTS = $(addsuffix .arm.swf, $(base_TESTS))
arm_swf_TESTS = \
3to2.arm.swf add.arm.swf allocai.arm.swf \
allocar.arm.swf bp.arm.swf divi.arm.swf fib.arm.swf \
rpn.arm.swf ldstr.arm.swf ldsti.arm.swf \
ldstxr.arm.swf ldstxi.arm.swf \
ldstr-c.arm.swf ldstxr-c.arm.swf ldstxi-c.arm.swf \
cvt.arm.swf hton.arm.swf branch.arm.swf \
alu_add.arm.swf alux_add.arm.swf \
alu_sub.arm.swf alux_sub.arm.swf alu_rsb.arm.swf \
alu_mul.arm.swf alu_div.arm.swf alu_rem.arm.swf \
alu_and.arm.swf alu_or.arm.swf alu_xor.arm.swf \
alu_lsh.arm.swf alu_rsh.arm.swf \
alu_com.arm.swf alu_neg.arm.swf \
fop_abs.arm.swf fop_sqrt.arm.swf \
varargs.arm.swf stack.arm.swf \
clobber.arm.swf carry.arm.swf call.arm.swf \
float.arm.swf jmpr.arm.swf tramp.arm.swf range.arm.swf \
ranger.arm.swf put.arm.swf va_list.arm.swf
$(arm_swf_TESTS): check.arm.swf.sh
$(LN_S) $(srcdir)/check.arm.swf.sh $@
TESTS += $(arm_swf_TESTS)
endif
if test_arm_arm
#arm4_swf_TESTS = $(addsuffix .arm4.swf, $(base_TESTS))
arm4_swf_TESTS = \
3to2.arm4.swf add.arm4.swf allocai.arm4.swf \
allocar.arm4.swf bp.arm4.swf divi.arm4.swf fib.arm4.swf \
rpn.arm4.swf ldstr.arm4.swf ldsti.arm4.swf \
ldstxr.arm4.swf ldstxi.arm4.swf \
ldstr-c.arm4.swf ldstxr-c.arm4.swf ldstxi-c.arm4.swf \
cvt.arm4.swf hton.arm4.swf branch.arm4.swf \
alu_add.arm4.swf alux_add.arm4.swf \
alu_sub.arm4.swf alux_sub.arm4.swf alu_rsb.arm4.swf \
alu_mul.arm4.swf alu_div.arm4.swf alu_rem.arm4.swf \
alu_and.arm4.swf alu_or.arm4.swf alu_xor.arm4.swf \
alu_lsh.arm4.swf alu_rsh.arm4.swf \
alu_com.arm4.swf alu_neg.arm4.swf \
fop_abs.arm4.swf fop_sqrt.arm4.swf \
varargs.arm4.swf stack.arm4.swf \
clobber.arm4.swf carry.arm4.swf call.arm4.swf \
float.arm4.swf jmpr.arm4.swf tramp.arm4.swf \
range.arm4.swf ranger.arm4.swf put.arm4.swf \
va_list.arm4.swf
$(arm4_swf_TESTS): check.arm4.swf.sh
$(LN_S) $(srcdir)/check.arm4.swf.sh $@
TESTS += $(arm4_swf_TESTS)
endif
endif
if test_nodata
#nodata_TESTS = $(addsuffix .nodata, $(base_TESTS))
nodata_TESTS = \
3to2.nodata add.nodata allocai.nodata \
allocar.nodata bp.nodata divi.nodata fib.nodata \
rpn.nodata ldstr.nodata ldsti.nodata \
ldstxr.nodata ldstxi.nodata \
ldstr-c.nodata ldstxr-c.nodata ldstxi-c.nodata \
cvt.nodata branch.nodata \
alu_add.nodata alux_add.nodata \
alu_sub.nodata alux_sub.nodata alu_rsb.nodata \
alu_mul.nodata alu_div.nodata alu_rem.nodata \
alu_and.nodata alu_or.nodata alu_xor.nodata \
alu_lsh.nodata alu_rsh.nodata \
alu_com.nodata alu_neg.nodata \
fop_abs.nodata fop_sqrt.nodata \
varargs.nodata stack.nodata \
clobber.nodata carry.nodata call.nodata \
float.nodata jmpr.nodata tramp.nodata \
range.nodata ranger.nodata put.nodata \
va_list.nodata
$(nodata_TESTS): check.nodata.sh
$(LN_S) $(srcdir)/check.nodata.sh $@
TESTS += $(nodata_TESTS)
endif
TESTS += ccall self setcode nodata ctramp carg cva_list
CLEANFILES = $(TESTS)
#TESTS_ENVIRONMENT=$(srcdir)/run-test;
debug: lightning
$(LIBTOOL) --mode=execute gdb lightning
+1
View File
@@ -0,0 +1 @@
5 + 4 = 9
+35
View File
@@ -0,0 +1,35 @@
.data 32
fmt:
.c "%d + %d = %d\n"
.code
jmpi main
name test
test:
prolog
arg $i0
arg $i1
getarg %r0 $i0
getarg %r1 $i1
addr %r0 %r0 %r1
retr %r0
epilog
name main
main:
prolog
prepare
pushargi 5
pushargi 4
finishi test
retval %r0
prepare
pushargi fmt
ellipsis
pushargi 5
pushargi 4
pushargr %r0
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
10
+28
View File
@@ -0,0 +1,28 @@
.data 32
fmt:
.c "%d\n"
.code
prolog
movi %r0 1
jmpi L1 /* should not generate this */
align $(__WORDSIZE / 8) /* possible nops */
L1:
bgei L4 %r0 10
addi %r0 %r0 1
jmpi L2
movr %r1 %r0 /* to force jump generation */
align $(__WORDSIZE / 8) /* possible nops */
L2:
bgti L4 %r0 10 /* never executed */
align $(__WORDSIZE / 8) /* possible nops */
L3:
jmpi L1
align $(__WORDSIZE / 8) /* possible nops */
L4:
prepare
pushargi fmt
ellipsis
pushargr %r0
finishi @printf
ret
epilog
+415
View File
@@ -0,0 +1,415 @@
.disasm // only disassemble
.code
prolog
allocai 32 $buf
arg $c
arg $uc
arg $s
arg $us
arg $i
#if __WORDSIZE == 64
arg $ui
arg $l
#endif
getarg_c %r0 $c
getarg_uc %r0 $uc
getarg_s %r0 $s
getarg_us %r0 $us
getarg_i %r0 $i
#if __WORDSIZE == 64
getarg_ui %r0 $ui
getarg_l %r0 $l
#endif
addr %r0 %r1 %r2
addi %r0 %r1 2
addcr %r0 %r1 %r2
addci %r0 %r1 2
addxr %r0 %r1 %r2
addxi %r0 %r1 2
subr %r0 %r1 %r2
subi %r0 %r1 2
subcr %r0 %r1 %r2
subci %r0 %r1 2
subxr %r0 %r1 %r2
subxi %r0 %r1 2
mulr %r0 %r1 %r2
muli %r0 %r1 2
qmulr %r0 %r1 %r2 %v0
qmuli %r0 %r1 %r2 3
qmulr_u %r0 %r1 %r2 %v0
qmuli_u %r0 %r1 %r2 3
divr %r0 %r1 %r2
divi %r0 %r1 2
divr_u %r0 %r1 %r2
divi_u %r0 %r1 2
qdivr %r0 %r1 %r2 %v0
qdivi %r0 %r1 %r2 3
qdivr_u %r0 %r1 %r2 %v0
qdivi_u %r0 %r1 %r2 3
remr %r0 %r1 %r2
remi %r0 %r1 2
remr_u %r0 %r1 %r2
remi_u %r0 %r1 2
andr %r0 %r1 %r2
andi %r0 %r1 2
orr %r0 %r1 %r2
ori %r0 %r1 2
xorr %r0 %r1 %r2
xori %r0 %r1 2
lshr %r0 %r1 %r2
lshi %r0 %r1 2
rshr %r0 %r1 %r2
rshi %r0 %r1 2
rshr_u %r0 %r1 %r2
rshi_u %r0 %r1 2
negr %r0 %r1
comr %r0 %r1
ltr %r0 %r1 %r2
lti %r0 %r1 2
ltr_u %r0 %r1 %r2
lti_u %r0 %r1 2
ler %r0 %r1 %r2
lei %r0 %r1 2
ler_u %r0 %r1 %r2
lei_u %r0 %r1 2
eqr %r0 %r1 %r2
eqi %r0 %r1 2
ger %r0 %r1 %r2
gei %r0 %r1 2
ger_u %r0 %r1 %r2
gei_u %r0 %r1 2
gtr %r0 %r1 %r2
gti %r0 %r1 2
gtr_u %r0 %r1 %r2
gti_u %r0 %r1 2
ner %r0 %r1 %r2
nei %r0 %r1 2
movr %r0 %r1
movi %r0 1
extr_c %r0 %r1
extr_uc %r0 %r1
extr_s %r0 %r1
extr_us %r0 %r1
#if __WORDSIZE == 64
extr_i %r0 %r1
extr_ui %r0 %r1
#endif
htonr %r0 %r1
ntohr %r0 %r1
ldr_c %r0 %r1
ldi_c %r0 0x80000000
ldr_uc %r0 %r1
ldi_uc %r0 0x80000000
ldr_s %r0 %r1
ldi_s %r0 0x80000000
ldr_us %r0 %r1
ldi_us %r0 0x80000000
ldr_i %r0 %r1
ldi_i %r0 0x80000000
#if __WORDSIZE == 64
ldr_ui %r0 %r1
ldi_ui %r0 0x80000000
ldr_l %r0 %r1
ldi_l %r0 0x80000000
#endif
ldxr_c %r0 %r1 %r2
ldxi_c %r0 %r1 1
ldxr_uc %r0 %r1 %r2
ldxi_uc %r0 %r1 1
ldxr_s %r0 %r1 %r2
ldxi_s %r0 %r1 2
ldxr_us %r0 %r1 %r2
ldxi_us %r0 %r1 2
ldxr_i %r0 %r1 %r2
ldxi_i %r0 %r1 4
#if __WORDSIZE == 64
ldxr_ui %r0 %r1 %r2
ldxi_ui %r0 %r1 4
ldxr_l %r0 %r1 %r2
ldxi_l %r0 %r1 8
#endif
str_c %r1 %r0
sti_c 0x80000000 %r1
str_s %r1 %r0
sti_s 0x80000000 %r1
str_i %r1 %r0
sti_i 0x80000000 %r1
#if __WORDSIZE == 64
str_l %r1 %r0
sti_l 0x80000000 %r1
#endif
stxr_c %r2 %r1 %r0
stxi_c 1 %r1 %r0
stxr_s %r2 %r1 %r0
stxi_s 2 %r1 %r0
stxr_i %r2 %r1 %r0
stxi_i 4 %r1 %r0
#if __WORDSIZE == 64
stxr_l %r2 %r1 %r0
stxi_l 8 %r1 %r0
#endif
cond:
bltr cond %r0 %r1
condi:
blti condi %r0 1
condu:
bltr_u condu %r0 %r1
condiu:
blti_u condiu %r0 1
bler cond %r0 %r1
blei condi %r0 1
bler_u condu %r0 %r1
blei_u condiu %r0 1
bool:
beqr bool %r0 %r1
booli:
beqi booli %r0 1
bger cond %r0 %r1
bgei condi %r0 1
bger_u condu %r0 %r1
bgei_u condiu %r0 1
bgtr cond %r0 %r1
bgti condi %r0 1
bgtr_u condu %r0 %r1
bgti_u condiu %r0 1
bner bool %r0 %r1
bnei booli %r0 1
mask:
bmsr mask %r0 %r1
maski:
bmsi maski %r0 1
bmcr mask %r0 %r1
bmci maski %r0 1
as:
boaddr as %r0 %r1
asi:
boaddi asi %r0 1
asu:
boaddr_u as %r0 %r1
boaddi_u asi %r0 1
bxaddr as %r0 %r1
bxaddi asi %r0 1
bxaddr_u as %r0 %r1
bxaddi_u asi %r0 1
bosubr as %r0 %r1
bosubi asi %r0 1
bosubr_u as %r0 %r1
bosubi_u asi %r0 1
bxsubr as %r0 %r1
bxsubi asi %r0 1
bxsubr_u as %r0 %r1
bxsubi_u asi %r0 1
label:
jmpr %r0
jmpi label
callr %r0
calli label
prepare
pushargr %r0
finishr %r0
prepare
pushargi 1
ellipsis
finishi 0x80000000
ret
retr %r1
reti 2
retval_c %r1
retval_uc %r1
retval_s %r1
retval_us %r1
retval_i %r1
#if __WORDSIZE == 64
retval_ui %r1
retval_l %r1
#endif
arg_f $f
getarg_f %f1 $f
addr_f %f0 %f1 %f2
addi_f %f0 %f1 0.5
subr_f %f0 %f1 %f2
subi_f %f0 %f1 0.5
mulr_f %f0 %f1 %f2
muli_f %f0 %f1 0.5
divr_f %f0 %f1 %f2
divi_f %f0 %f1 0.5
negr_f %f0 %f1
absr_f %f0 %f1
sqrtr_f %f0 %f1
ltr_f %r0 %f0 %f1
lti_f %r0 %f0 0.5
ler_f %r0 %f0 %f1
lei_f %r0 %f0 0.5
eqr_f %r0 %f0 %f1
eqi_f %r0 %f0 0.5
ger_f %r0 %f0 %f1
gei_f %r0 %f0 0.5
gtr_f %r0 %f0 %f1
gti_f %r0 %f0 0.5
ner_f %r0 %f0 %f1
nei_f %r0 %f0 0.5
unltr_f %r0 %f0 %f1
unlti_f %r0 %f0 0.5
unler_f %r0 %f0 %f1
unlei_f %r0 %f0 0.5
uneqr_f %r0 %f0 %f1
uneqi_f %r0 %f0 0.5
unger_f %r0 %f0 %f1
ungei_f %r0 %f0 0.5
ungtr_f %r0 %f0 %f1
ungti_f %r0 %f0 0.5
ltgtr_f %r0 %f0 %f1
ltgti_f %r0 %f0 0.5
ordr_f %r0 %f0 %f1
ordi_f %r0 %f0 0.5
unordr_f %r0 %f0 %f1
unordi_f %r0 %f0 0.5
truncr_f_i %r0 %f0
#if __WORDSIZE == 64
truncr_f_l %r0 %f0
#endif
extr_f %f0 %r0
extr_d_f %f0 %f1
movr_f %f0 %f1
movi_f %f0 1.5
ldr_f %f0 %r0
ldi_f %f0 0x80000000
ldxr_f %f0 %r0 %r1
ldxi_f %f0 %r0 4
str_f %r0 %f0
sti_f 0x80000000 %f0
stxr_f %r1 %r0 %f0
stxi_f 4 %r0 %f0
/* FIXME the bordr_d at the end will cause an assertion on riscv due to
* too distant jump (does not fit in a 12 bit signed int) */
ord:
bltr_f ord %f0 %f1
ordi:
blti_f ordi %f0 0.5
bler_f ord %f0 %f1
blei_f ordi %f0 0.5
beqr_f ord %f0 %f1
beqi_f ordi %f0 0.5
bger_f ord %f0 %f1
bgei_f ordi %f0 0.5
bgtr_f ord %f0 %f1
bgti_f ordi %f0 0.5
bner_f ord %f0 %f1
bnei_f ordi %f0 0.5
unord:
bunltr_f unord %f0 %f1
unordi:
bunlti_f unordi %f0 0.5
bunler_f unord %f0 %f1
bunlei_f unordi %f0 0.5
buneqr_f unord %f0 %f1
buneqi_f unordi %f0 0.5
bunger_f unord %f0 %f1
bungei_f unordi %f0 0.5
bungtr_f unord %f0 %f1
bungti_f unordi %f0 0.5
bltgtr_f unord %f0 %f1
bltgti_f unordi %f0 0.5
bordr_f unord %f0 %f1
bordi_f unordi %f0 0.5
bunordr_f unord %f0 %f1
bunordi_f unordi %f0 0.5
prepare
pushargr_f %f1
pushargi_f 0.5
finishi 0x80000000
retr_f %f1
reti_f 0.5
retval_f %f1
arg_d $f
getarg_d %f1 $f
addr_d %f0 %f1 %f2
addi_d %f0 %f1 0.5
subr_d %f0 %f1 %f2
subi_d %f0 %f1 0.5
mulr_d %f0 %f1 %f2
muli_d %f0 %f1 0.5
divr_d %f0 %f1 %f2
divi_d %f0 %f1 0.5
negr_d %f0 %f1
absr_d %f0 %f1
sqrtr_d %f0 %f1
ltr_d %r0 %f0 %f1
lti_d %r0 %f0 0.5
ler_d %r0 %f0 %f1
lei_d %r0 %f0 0.5
eqr_d %r0 %f0 %f1
eqi_d %r0 %f0 0.5
ger_d %r0 %f0 %f1
gei_d %r0 %f0 0.5
gtr_d %r0 %f0 %f1
gti_d %r0 %f0 0.5
ner_d %r0 %f0 %f1
nei_d %r0 %f0 0.5
unltr_d %r0 %f0 %f1
unlti_d %r0 %f0 0.5
unler_d %r0 %f0 %f1
unlei_d %r0 %f0 0.5
uneqr_d %r0 %f0 %f1
uneqi_d %r0 %f0 0.5
unger_d %r0 %f0 %f1
ungei_d %r0 %f0 0.5
ungtr_d %r0 %f0 %f1
ungti_d %r0 %f0 0.5
ltgtr_d %r0 %f0 %f1
ltgti_d %r0 %f0 0.5
ordr_d %r0 %f0 %f1
ordi_d %r0 %f0 0.5
unordr_d %r0 %f0 %f1
unordi_d %r0 %f0 0.5
truncr_d_i %r0 %f0
#if __WORDSIZE == 64
truncr_d_l %r0 %f0
#endif
extr_d %f0 %r0
extr_f_d %f0 %f1
movr_d %f0 %f1
movi_d %f0 1.5
ldr_d %f0 %r0
ldi_d %f0 0x80000000
ldxr_d %f0 %r0 %r1
ldxi_d %f0 %r0 8
str_d %r0 %f0
sti_d 0x80000000 %f0
stxr_d %r1 %r0 %f0
stxi_d 8 %r0 %f0
bltr_d ord %f0 %f1
blti_d ordi %f0 0.5
bler_d ord %f0 %f1
blei_d ordi %f0 0.5
beqr_d ord %f0 %f1
beqi_d ordi %f0 0.5
bger_d ord %f0 %f1
bgei_d ordi %f0 0.5
bgtr_d ord %f0 %f1
bgti_d ordi %f0 0.5
bner_d ord %f0 %f1
bnei_d ordi %f0 0.5
bunltr_d unord %f0 %f1
bunlti_d unordi %f0 0.5
bunler_d unord %f0 %f1
bunlei_d unordi %f0 0.5
buneqr_d unord %f0 %f1
buneqi_d unordi %f0 0.5
bunger_d unord %f0 %f1
bungei_d unordi %f0 0.5
bungtr_d unord %f0 %f1
bungti_d unordi %f0 0.5
bltgtr_d unord %f0 %f1
bltgti_d unordi %f0 0.5
bordr_d unord %f0 %f1
bordi_d unordi %f0 0.5
bunordr_d unord %f0 %f1
bunordi_d unordi %f0 0.5
prepare
pushargr_d %f1
pushargi_d 0.5
finishi 0x80000000
retr_d %f1
reti_d 0.5
retval_d %f1
+2
View File
@@ -0,0 +1,2 @@
received 7777
succeeded
+100
View File
@@ -0,0 +1,100 @@
.data 128
idfmt:
.c "received %d\n"
failure_message:
.c "numbers don't add up to zero\n"
report_message:
.c "failed: got %i instead of %i\n"
succeeded_message:
.c "succeeded\n"
.code
jmpi main
/*
static int
identity (int arg)
{
printf ("received %i\n", arg);
return arg;
}
*/
name identify
identify:
prolog
arg $i
getarg %v0 $i
prepare
pushargi idfmt
ellipsis
pushargr %v0
finishi @printf
retr %v0
epilog
name identity_func
identity_func:
prolog
arg $i
getarg %r1 $i
/* Store the argument on the stack. */
allocai $(__WORDSIZE >> 3) $off
stxi $off %fp %r1
/* Store the negative of the argument on the stack. */
allocai $(__WORDSIZE >> 3) $neg
negr %r2 %r1
stxi $neg %fp %r2
/* Invoke FUNC. */
prepare
pushargr %r1
finishi identify
/* Ignore the result. */
/* Restore the negative and the argument from the stack. */
ldxi %r2 %fp $neg
ldxi %v1 %fp $off
/* Make sure they still add to zero. */
addr %r0 %v1 %r2
bnei branch %r0 0
/* Return it. */
retr %v1
/* Display a failure message. */
branch:
prepare
pushargi failure_message
ellipsis
finishi @printf
/* Leave. */
retr %v1
epilog
name main
main:
prolog
prepare
pushargi 7777
finishi identity_func
retval %r0
beqi succeeded %r0 7777
prepare
pushargi report_message
ellipsis
pushargr %r0
pushargi 7777
finishi @printf
reti 1
succeeded:
prepare
pushargi succeeded_message
ellipsis
finishi @printf
reti 0
epilog
+4
View File
@@ -0,0 +1,4 @@
1 2 3
3 4 5
5 6 7
7 8 9
+403
View File
@@ -0,0 +1,403 @@
#define szof_c 1
#define szof_uc szof_c
#define szof_s 2
#define szof_us szof_s
#define szof_i 4
#if __WORDSIZE == 64
# define szof_ui szof_i
# define szof_l 8
#endif
#define szof_f 4
#define szof_d 8
#define FILL(T) \
name fill##T \
fill##T: \
prolog \
arg $argp \
getarg %v0 $argp \
arg $argi \
getarg %r0 $argi \
muli %r0 %r0 szof##T \
addr %v1 %v0 %r0 \
movi %r0 0 \
fill##T##loop: \
bger fill##T##done %v0 %v1 \
str##T %v0 %r0 \
addi %r0 %r0 1 \
addi %v0 %v0 szof##T \
jmpi fill##T##loop \
fill##T##done: \
ret \
epilog
#define FILLF(T) \
name fill##T \
fill##T: \
prolog \
arg $argp \
getarg %v0 $argp \
arg $argi \
getarg %r0 $argi \
muli %r0 %r0 szof##T \
addr %v1 %v0 %r0 \
movi##T %f0 0.0 \
fill##T##loop: \
bger fill##T##done %v0 %v1 \
str##T %v0 %f0 \
addi##T %f0 %f0 1.0 \
addi %v0 %v0 szof##T \
jmpi fill##T##loop \
fill##T##done: \
ret \
epilog
#define fill_uc fill_c
#define fill_us fill_s
#define fill_ui fill_i
#define ARG( T, N) arg $arg##T##N
#define ARGF( T, N) arg##T $arg##T##N
#define ARG1( K, T) ARG##K(T, 0)
#define ARG2( K, T) ARG1( K, T) ARG##K(T, 1)
#define ARG3( K, T) ARG2( K, T) ARG##K(T, 2)
#define ARG4( K, T) ARG3( K, T) ARG##K(T, 3)
#define ARG5( K, T) ARG4( K, T) ARG##K(T, 4)
#define ARG6( K, T) ARG5( K, T) ARG##K(T, 5)
#define ARG7( K, T) ARG6( K, T) ARG##K(T, 6)
#define ARG8( K, T) ARG7( K, T) ARG##K(T, 7)
#define ARG9( K, T) ARG8( K, T) ARG##K(T, 8)
#define ARG10(K, T) ARG9( K, T) ARG##K(T, 9)
#define ARG11(K, T) ARG10(K, T) ARG##K(T, 10)
#define ARG12(K, T) ARG11(K, T) ARG##K(T, 11)
#define ARG13(K, T) ARG12(K, T) ARG##K(T, 12)
#define ARG14(K, T) ARG13(K, T) ARG##K(T, 13)
#define ARG15(K, T) ARG14(K, T) ARG##K(T, 14)
#define ARG16(K, T) ARG15(K, T) ARG##K(T, 15)
#define ARG_c(N) ARG##N( , _c)
#define ARG_uc(N) ARG##N( , _uc)
#define ARG_s(N) ARG##N( , _s)
#define ARG_us(N) ARG##N( , _us)
#define ARG_i(N) ARG##N( , _i)
#define ARG_ui(N) ARG##N( , _ui)
#define ARG_l(N) ARG##N( , _l)
#define ARG_f(N) ARG##N(F, _f)
#define ARG_d(N) ARG##N(F, _d)
#define CHK(N, T, V) \
getarg %r0 $arg##T##V \
ldxi##T %r1 %v0 $(V * szof##T) \
beqr N##T##V %r0 %r1 \
calli @abort \
N##T##V:
#define CHKF(N, T, V) \
getarg##T %f0 $arg##T##V \
ldxi##T %f1 %v0 $(V * szof##T) \
beqr##T N##T##V %f0 %f1 \
calli @abort \
N##T##V:
#define GET1( K, N, T, V) CHK##K(N, T, 0)
#define GET2( K, N, T, V) GET1( K, N, T, V) CHK##K(N, T, 1)
#define GET3( K, N, T, V) GET2( K, N, T, V) CHK##K(N, T, 2)
#define GET4( K, N, T, V) GET3( K, N, T, V) CHK##K(N, T, 3)
#define GET5( K, N, T, V) GET4( K, N, T, V) CHK##K(N, T, 4)
#define GET6( K, N, T, V) GET5( K, N, T, V) CHK##K(N, T, 5)
#define GET7( K, N, T, V) GET6( K, N, T, V) CHK##K(N, T, 6)
#define GET8( K, N, T, V) GET7( K, N, T, V) CHK##K(N, T, 7)
#define GET9( K, N, T, V) GET8( K, N, T, V) CHK##K(N, T, 8)
#define GET10(K, N, T, V) GET9( K, N, T, V) CHK##K(N, T, 9)
#define GET11(K, N, T, V) GET10(K, N, T, V) CHK##K(N, T, 10)
#define GET12(K, N, T, V) GET11(K, N, T, V) CHK##K(N, T, 11)
#define GET13(K, N, T, V) GET12(K, N, T, V) CHK##K(N, T, 12)
#define GET14(K, N, T, V) GET13(K, N, T, V) CHK##K(N, T, 13)
#define GET15(K, N, T, V) GET14(K, N, T, V) CHK##K(N, T, 14)
#define GET16(K, N, T, V) GET15(K, N, T, V) CHK##K(N, T, 15)
#define GET_c(N, M) GET##N( , c##N, _c, M)
#define GET_uc(N, M) GET##N( , uc##N, _uc, M)
#define GET_s(N, M) GET##N( , s##N, _s, M)
#define GET_us(N, M) GET##N( , us##N, _us, M)
#define GET_i(N, M) GET##N( , i##N, _i, M)
#define GET_ui(N, M) GET##N( , ui##N, _ui, M)
#define GET_l(N, M) GET##N( , l##N, _l, M)
#define GET_f(N, M) GET##N(F, f##N, _f, M)
#define GET_d(N, M) GET##N(F, d##N, _d, M)
#define PUSH( T, V) pushargi V
#define PUSHF( T, V) pushargi##T V
#define PUSH0( K, T) /**/
#define PUSH1( K, T) PUSH##K(T, 0)
#define PUSH2( K, T) PUSH1( K, T) PUSH##K(T, 1)
#define PUSH3( K, T) PUSH2( K, T) PUSH##K(T, 2)
#define PUSH4( K, T) PUSH3( K, T) PUSH##K(T, 3)
#define PUSH5( K, T) PUSH4( K, T) PUSH##K(T, 4)
#define PUSH6( K, T) PUSH5( K, T) PUSH##K(T, 5)
#define PUSH7( K, T) PUSH6( K, T) PUSH##K(T, 6)
#define PUSH8( K, T) PUSH7( K, T) PUSH##K(T, 7)
#define PUSH9( K, T) PUSH8( K, T) PUSH##K(T, 8)
#define PUSH10(K, T) PUSH9( K, T) PUSH##K(T, 9)
#define PUSH11(K, T) PUSH10(K, T) PUSH##K(T, 10)
#define PUSH12(K, T) PUSH11(K, T) PUSH##K(T, 11)
#define PUSH13(K, T) PUSH12(K, T) PUSH##K(T, 12)
#define PUSH14(K, T) PUSH13(K, T) PUSH##K(T, 13)
#define PUSH15(K, T) PUSH14(K, T) PUSH##K(T, 14)
#define PUSH16(K, T) PUSH15(K, T) PUSH##K(T, 15)
#define PUSH_c( N) PUSH##N( , _c)
#define PUSH_uc(N) PUSH##N( , _uc)
#define PUSH_s( N) PUSH##N( , _s)
#define PUSH_us(N) PUSH##N( , _us)
#define PUSH_i( N) PUSH##N( , _i)
#define PUSH_ui(N) PUSH##N( , _ui)
#define PUSH_l( N) PUSH##N( , _l)
#define PUSH_f( N) PUSH##N(F, _f)
#define PUSH_d( N) PUSH##N(F, _d)
/* bottom function */
#define DEF0(T) \
name test##T##_0 \
test##T##_0: \
prolog \
ret \
epilog
#define DEFN(N, M, T) \
name test##T##_##N \
test##T##_##N: \
prolog \
arg $argp \
/* stack buffer in %v0 */ \
getarg %v0 $argp \
ARG##T(N) \
/* validate arguments */ \
GET##T(N, M) \
/* heap buffer in %v1 */ \
prepare \
pushargi $(N * szof##T) \
finishi @malloc \
retval %v1 \
/* copy stack bufer to heap buffer */ \
prepare \
pushargr %v1 \
pushargr %v0 \
pushargi $(N * szof##T) \
finishi MEMCPY \
/* stack buffer for next function in %v2 */ \
movi %r0 $(M * szof##T) \
allocar %v2 %r0 \
addr %v2 %v2 %fp \
/* fill stack buffer for next function */ \
prepare \
pushargr %v2 \
pushargi M \
finishi fill##T \
/* call next function */ \
prepare \
pushargr %v2 \
PUSH##T(M) \
finishi test##T##_##M \
/* validate stack buffer */ \
prepare \
pushargr %v1 \
pushargr %v0 \
pushargi $(N * szof##T) \
finishi @memcmp \
retval %r0 \
beqi test##T##_##N##_done %r0 0 \
calli @abort \
test##T##_##N##_done: \
/* release heap bufer */ \
prepare \
pushargr %v1 \
finishi @free \
ret \
epilog
/* top function */
#define DEFX(T) \
name test##T##_17 \
test##T##_17: \
prolog \
/* heap buffer in %v1 */ \
prepare \
pushargi $(16 * szof##T) \
finishi @malloc \
retval %v1 \
/* stack buffer for next function in %v2 */ \
movi %r0 $(16 * szof##T) \
allocar %v2 %r0 \
addr %v2 %v2 %fp \
/* fill stack buffer for next function */ \
prepare \
pushargr %v2 \
pushargi 16 \
finishi fill##T \
/* copy stack buffer to heap buffer */ \
prepare \
pushargr %v1 \
pushargr %v2 \
pushargi $(16 * szof##T) \
finishi MEMCPY \
/* call next function */ \
prepare \
pushargr %v2 \
PUSH##T(16) \
finishi test##T##_16 \
/* validate stack buffer */ \
prepare \
pushargr %v1 \
pushargr %v2 \
pushargi $(16 * szof##T) \
finishi @memcmp \
retval %r0 \
beqi test##T##_17_done %r0 0 \
calli @abort \
test##T##_17_done: \
/* release heap bufer */ \
prepare \
pushargr %v1 \
finishi @free \
ret \
epilog
#define DEF( T) \
DEF0( T) \
DEFN( 1, 0, T) \
DEFN( 2, 1, T) \
DEFN( 3, 2, T) \
DEFN( 4, 3, T) \
DEFN( 5, 4, T) \
DEFN( 6, 5, T) \
DEFN( 7, 6, T) \
DEFN( 8, 7, T) \
DEFN( 9, 8, T) \
DEFN(10, 9, T) \
DEFN(11, 10, T) \
DEFN(12, 11, T) \
DEFN(13, 12, T) \
DEFN(14, 13, T) \
DEFN(15, 14, T) \
DEFN(16, 15, T) \
DEFX(T)
#define CALL(T) calli test##T##_17
.data 16
fmt:
.c "%d %d %d\n"
.code
jmpi main
#if _AIX
# define MEMCPY memcpy
/* error: Function not implemented (memcpy) */
name memcpy
memcpy:
prolog
arg $dst
arg $src
arg $len
getarg %r0 $dst
getarg %r1 $src
getarg %r2 $len
movr %v1 %r0
blti memcpy_done %r2 1
memcpy_loop:
subi %r2 %r2 1
ldxr_c %v0 %r1 %r2
stxr_c %r2 %r0 %v0
bgti memcpy_loop %r2 0
memcpy_done:
retr %v1
epilog
#else
# define MEMCPY @memcpy
#endif
FILL(_c)
FILL(_s)
FILL(_i)
#if __WORDSIZE == 64
FILL(_l)
#endif
FILLF(_f)
FILLF(_d)
DEF(_c)
DEF(_uc)
DEF(_s)
DEF(_us)
DEF(_i)
#if __WORDSIZE == 64
DEF(_ui)
DEF(_l)
#endif
DEF(_f)
DEF(_d)
name main
main:
prolog
CALL(_c)
CALL(_uc)
CALL(_s)
CALL(_us)
CALL(_i)
#if __WORDSIZE == 64
CALL(_ui)
CALL(_l)
#endif
CALL(_f)
CALL(_d)
// loop control
movi %v2 1
// loop a few times calling allocar
loop:
// allocate 12 bytes
movi %r0 12
allocar %v0 %r0
// offset
movr %v1 %v0
// 1
stxr_i %v1 %fp %v2
// 2
addi %v2 %v2 1
addi %v1 %v1 4
stxr_i %v1 %fp %v2
// 3
addi %v2 %v2 1
addi %v1 %v1 4
stxr_i %v1 %fp %v2
// reload
movr %v1 %v0
// 1
ldxr_i %r0 %fp %v1
// 2
addi %v1 %v1 4
ldxr_i %r1 %fp %v1
// 3
addi %v1 %v1 4
ldxr_i %r2 %fp %v1
prepare
pushargi fmt
ellipsis
pushargr %r0
pushargr %r1
pushargr %r2
finishi @printf
blti loop %v2 9
ret
epilog
+360
View File
@@ -0,0 +1,360 @@
.data 8
ok:
.c "ok\n"
/* ia64 code generation is not optimized for size, and also some
* codes generate quite long sequences due to need for stops causing
* no code template match and needing to add nops, and other cases
* are division/remainder that needs function calls, or float division
* that requires a quite long sequence.
* (the brute force tests of all register combinations can easily
* generate several GB of jit).
*/
/* 3 operand */
/* reg0 = reg1 op reg2 */
#define ALUR(N, T, OP, I0, I1, V, R0, R1, R2) \
movi %R1 I0 \
movi %R2 I1 \
OP##r##T %R0 %R1 %R2 \
beqi OP##T##N##r_##R0##R1##R2 %R0 V \
calli @abort \
OP##T##N##r_##R0##R1##R2:
/* reg0 = reg1 op im */
#define ALUI(N, T, OP, I0, I1, V, R0, R1, R2) \
movi %R1 I0 \
movi %R2 V \
OP##i##T %R0 %R1 I1 \
beqr OP##T##N##i_##R0##R1##R2 %R0 %R2 \
calli @abort \
OP##T##N##i_##R0##R1##R2:
/* reg0 = reg0 op reg1 */
#define ALUR0(N, T, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I0 \
movi %R1 I1 \
movi %R2 V \
OP##r##T %R0 %R0 %R1 \
beqr OP##T##N##r_0##R0##R1##R2 %R0 %R2 \
calli @abort \
OP##T##N##r_0##R0##R1##R2:
/* reg0 = reg1 op reg0 */
#define ALUR1(N, T, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I1 \
movi %R1 I0 \
movi %R2 V \
OP##r##T %R0 %R1 %R0 \
beqr OP##T##N##r_1##R0##R1##R2 %R0 %R2 \
calli @abort \
OP##T##N##r_1##R0##R1##R2:
/* reg0 = reg0 op im */
#define ALUI0(N, T, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I0 \
movi %R1 V \
OP##i##T %R0 %R0 I1 \
beqr OP##T##N##i_0##R0##R1##R2 %R0 %R1 \
calli @abort \
OP##T##N##i_0##R0##R1##R2:
#define ALU3(N, T, OP, I0, I1, V, R0, R1, R2) \
ALUR(N, T, OP, I0, I1, V, R0, R1, R2) \
ALUI(N, T, OP, I0, I1, V, R0, R1, R2) \
ALUR0(N, T, OP, I0, I1, V, R0, R1, R2) \
ALUR1(N, T, OP, I0, I1, V, R0, R1, R2) \
ALUI0(N, T, OP, I0, I1, V, R0, R1, R2)
#define ALU2(N, T, OP, I0, I1, V, R0, R1, R2) \
ALU3(N, T, OP, I0, I1, V, R0, R1, R2) \
ALU3(N, T, OP, I0, I1, V, R0, R2, R1)
#define ALU1(N, T, OP, I0, I1, V, R0, R1, R2) \
ALU2(N, T, OP, I0, I1, V, R0, R1, R2) \
ALU2(N, T, OP, I0, I1, V, R1, R0, R2) \
ALU2(N, T, OP, I0, I1, V, R2, R1, R0)
#if __ia64__
# define ALU(N, T, OP, I0, I1, V) \
ALU3(N, T, OP, I0, I1, V, r0, r1, r2) \
ALU3(N, T, OP, I0, I1, V, v0, v1, v2)
#else
# define ALU(N, T, OP, I0, I1, V) \
ALU1(N, T, OP, I0, I1, V, v0, v1, v2) \
ALU1(N, T, OP, I0, I1, V, v0, v1, r0) \
ALU1(N, T, OP, I0, I1, V, v0, v1, r1) \
ALU1(N, T, OP, I0, I1, V, v0, v1, r2) \
ALU1(N, T, OP, I0, I1, V, v1, v2, r1) \
ALU1(N, T, OP, I0, I1, V, v1, v2, r2) \
ALU1(N, T, OP, I0, I1, V, v2, r0, r1) \
ALU1(N, T, OP, I0, I1, V, v2, r0, r2) \
ALU1(N, T, OP, I0, I1, V, r0, r1, r2)
#endif
/* 3 carry set/propagate */
/*
* r0 = i0
* r1 = i1
* r2 = 0
* r0 = r0 opc r1 <only want carry>
* r2 = r2 opx r2 <r2 must match v>
*/
#define ALUXII(N, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I0 \
movi %R2 0 \
OP##ci %R0 %R0 I1 \
OP##xi %R2 %R2 0 \
beqi OP##N##ii##R0##R1##R2 %R2 V \
calli @abort \
OP##N##ii##R0##R1##R2:
#define ALUXIR(N, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I0 \
movi %R2 0 \
OP##ci %R0 %R0 I1 \
OP##xr %R2 %R2 %R2 \
beqi OP##N##ir##R0##R1##R2 %R2 V \
calli @abort \
OP##N##ir##R0##R1##R2:
#define ALUXRI(N, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I0 \
movi %R1 I1 \
movi %R2 0 \
OP##cr %R0 %R0 %R1 \
OP##xi %R2 %R2 0 \
beqi OP##N##ri##R0##R1##R2 %R2 V \
calli @abort \
OP##N##ri##R0##R1##R2:
#define ALUXRR(N, OP, I0, I1, V, R0, R1, R2) \
movi %R0 I0 \
movi %R1 I1 \
movi %R2 0 \
OP##cr %R0 %R0 %R1 \
OP##xr %R2 %R2 %R2 \
beqi OP##N##rr##R0##R1##R2 %R2 V \
calli @abort \
OP##N##rr##R0##R1##R2:
#define ALUX2(N, OP, I0, I1, V, R0, R1, R2) \
ALUXII(N, OP, I0, I1, V, R0, R1, R2) \
ALUXIR(N, OP, I0, I1, V, R0, R1, R2) \
ALUXRI(N, OP, I0, I1, V, R0, R1, R2) \
ALUXRR(N, OP, I0, I1, V, R0, R1, R2)
#define ALUX1(N, OP, I0, I1, V, R0, R1, R2) \
ALUX2(N, OP, I0, I1, V, R0, R1, R2) \
ALUX2(N, OP, I0, I1, V, R0, R2, R1)
#define ALUX0(N, OP, I0, I1, V, R0, R1, R2) \
ALUX1(N, OP, I0, I1, V, R0, R1, R2) \
ALUX1(N, OP, I0, I1, V, R1, R0, R2) \
ALUX1(N, OP, I0, I1, V, R2, R1, R0)
#if __ia64__
# define ALUX(N, OP, I0, I1, V) \
ALUX2(N, OP, I0, I1, V, r0, r1, r2) \
ALUX2(N, OP, I0, I1, V, v0, v1, v2)
#else
# define ALUX(N, OP, I0, I1, V) \
ALUX0(N, OP, I0, I1, V, v0, v1, v2) \
ALUX0(N, OP, I0, I1, V, v0, v1, r0) \
ALUX0(N, OP, I0, I1, V, v0, v1, r1) \
ALUX0(N, OP, I0, I1, V, v0, v1, r2) \
ALUX0(N, OP, I0, I1, V, v1, v2, r0) \
ALUX0(N, OP, I0, I1, V, v1, v2, r1) \
ALUX0(N, OP, I0, I1, V, v1, v2, r2) \
ALUX0(N, OP, I0, I1, V, v2, r0, r1) \
ALUX0(N, OP, I0, I1, V, v2, r0, r2) \
ALUX0(N, OP, I0, I1, V, r0, r1, r2)
#endif
/* unary int */
#define UNR(N, OP, I, V, R0, R1) \
movi %R1 I \
OP##r %R0 %R1 \
beqi OP##N##R0##R1 %R0 V \
calli @abort \
OP##N##R0##R1:
#define UNRC(N, OP, I, V, R0, R1) \
movi %R0 I \
OP##r %R0 %R0 \
beqi OP##N##c##R0##R1 %R0 V \
calli @abort \
OP##N##c##R0##R1:
#define UN2(N, OP, I, V, R0, R1) \
UNR(N, OP, I, V, R0, R1) \
UNRC(N, OP, I, V, R0, R1)
#define UN1(N, OP, I, V, R0, R1) \
UN2(N, OP, I, V, R0, R1) \
UN2(N, OP, I, V, R1, R0)
#if __ia64__
# define UN(N, OP, I, V) \
UN2(N, OP, I, V, r0, r1) \
UN2(N, OP, I, V, v0, v1)
#else
# define UN(N, OP, I, V) \
UN1(N, OP, I, V, v0, v1) \
UN1(N, OP, I, V, v0, v2) \
UN1(N, OP, I, V, v0, r0) \
UN1(N, OP, I, V, v0, r1) \
UN1(N, OP, I, V, v0, r2) \
UN1(N, OP, I, V, v1, v2) \
UN1(N, OP, I, V, v1, r0) \
UN1(N, OP, I, V, v1, r1) \
UN1(N, OP, I, V, v1, r2) \
UN1(N, OP, I, V, v2, r0) \
UN1(N, OP, I, V, v2, r1) \
UN1(N, OP, I, V, v2, r2) \
UN1(N, OP, I, V, r0, r1) \
UN1(N, OP, I, V, r0, r2) \
UN1(N, OP, I, V, r1, r2)
#endif
/* reg0 = reg1 op reg2 */
#define FOPR(N, T, OP, I0, I1, V, F0, F1, F2) \
movi##T %F1 I0 \
movi##T %F2 I1 \
OP##r##T %F0 %F1 %F2 \
beqi##T OP##T##N##F0##F1##F2 %F0 V \
calli @abort \
OP##T##N##F0##F1##F2:
/* reg0 = reg0 op reg1 */
#define FOPR0(N, T, OP, I0, I1, V, F0, F1, F2) \
movi##T %F0 I0 \
movi##T %F1 I1 \
OP##r##T %F0 %F0 %F1 \
beqi##T OP##T##N##0##F0##F1##F2 %F0 V \
calli @abort \
OP##T##N##0##F0##F1##F2:
/* reg1 = reg0 op reg1 */
#define FOPR1(N, T, OP, I0, I1, V, F0, F1, F2) \
movi##T %F0 I0 \
movi##T %F1 I1 \
OP##r##T %F1 %F0 %F1 \
beqi##T OP##T##N##1##F0##F1##F2 %F1 V \
calli @abort \
OP##T##N##1##F0##F1##F2:
/* reg0 = reg1 op im */
#define FOPI(N, T, OP, I0, I1, V, F0, F1, F2) \
movi##T %F1 I0 \
movi##T %F2 V \
OP##i##T %F0 %F1 I1 \
beqr##T OP##T##N##i##F0##F1##F2 %F0 %F2 \
calli @abort \
OP##T##N##i##F0##F1##F2:
/* reg0 = reg0 op im */
#define FOPI0(N, T, OP, I0, I1, V, F0, F1, F2) \
movi##T %F0 I0 \
movi##T %F2 V \
OP##i##T %F0 %F0 I1 \
beqr##T OP##T##N##i0##F0##F1##F2 %F0 %F2 \
calli @abort \
OP##T##N##i0##F0##F1##F2:
#define FOP1(N, T, OP, I0, I1, V, F0, F1, F2) \
FOPR(N, T, OP, I0, I1, V, F0, F1, F2) \
FOPR0(N, T, OP, I0, I1, V, F0, F1, F2) \
FOPR1(N, T, OP, I0, I1, V, F0, F1, F2) \
FOPI(N, T, OP, I0, I1, V, F0, F1, F2) \
FOPI0(N, T, OP, I0, I1, V, F0, F1, F2)
#if __ia64__
# define FOP(N, T, OP, I0, I1, V) \
FOP1(N, T, OP, I0, I1, V, f0, f1, f2)
#else
# define FOP(N, T, OP, I0, I1, V) \
FOP1(N, T, OP, I0, I1, V, f0, f1, f2) \
FOP1(N, T, OP, I0, I1, V, f0, f2, f3) \
FOP1(N, T, OP, I0, I1, V, f0, f3, f4) \
FOP1(N, T, OP, I0, I1, V, f0, f5, f1)
#endif
/* unary float */
#define FUNR(N, T, OP, I, V, R0, R1) \
movi##T %R1 I \
OP##r##T %R0 %R1 \
beqi##T OP##N##T##R0##R1 %R0 V \
calli @abort \
OP##N##T##R0##R1:
#define FUNRC(N, T, OP, I, V, R0, R1) \
movi##T %R0 I \
OP##r##T %R0 %R0 \
beqi##T OP##N##T##c##R0##R1 %R0 V \
calli @abort \
OP##N##T##c##R0##R1:
#define FUN2(N, T, OP, I, V, R0, R1) \
FUNR(N, T, OP, I, V, R0, R1) \
FUNRC(N, T, OP, I, V, R0, R1)
#define FUN1(N, T, OP, I, V, R0, R1) \
FUN2(N, T, OP, I, V, R0, R1) \
FUN2(N, T, OP, I, V, R1, R0)
#if __ia64__
# define FUN(N, T, OP, I, V) \
FUN2(N, T, OP, I, V, f0, f1)
#else
# define FUN(N, T, OP, I, V) \
FUN1(N, T, OP, I, V, f0, f1) \
FUN1(N, T, OP, I, V, f0, f2) \
FUN1(N, T, OP, I, V, f0, f3) \
FUN1(N, T, OP, I, V, f0, f4) \
FUN1(N, T, OP, I, V, f0, f5)
#endif
/* unordered comparison unary float */
#define UFUNR(N, T, OP, I, V, R0, R1) \
movi##T %R1 I \
OP##r##T %R0 %R1 \
buneqi##T OP##N##T##u##R0##R1 %R0 V \
calli @abort \
OP##N##T##u##R0##R1:
#define UFUNRC(N, T, OP, I, V, R0, R1) \
movi##T %R0 I \
OP##r##T %R0 %R0 \
buneqi##T OP##N##T##uc##R0##R1 %R0 V \
calli @abort \
OP##N##T##uc##R0##R1:
#define UFUN2(N, T, OP, I, V, R0, R1) \
UFUNR(N, T, OP, I, V, R0, R1) \
UFUNRC(N, T, OP, I, V, R0, R1)
#define UFUN1(N, T, OP, I, V, R0, R1) \
UFUN2(N, T, OP, I, V, R0, R1) \
UFUN2(N, T, OP, I, V, R1, R0)
#if __ia64__
# define UFUN(N, T, OP, I, V) \
UFUN2(N, T, OP, I, V, f0, f1)
#else
# define UFUN(N, T, OP, I, V) \
UFUN1(N, T, OP, I, V, f0, f1) \
UFUN1(N, T, OP, I, V, f0, f2) \
UFUN1(N, T, OP, I, V, f0, f3) \
UFUN1(N, T, OP, I, V, f0, f4) \
UFUN1(N, T, OP, I, V, f0, f5)
#endif
. $( $NaN = 0.0/0.0)
. $( $Inf = 1.0/0.0)
. $($nInf = -1.0/0.0)
+1
View File
@@ -0,0 +1 @@
ok
+47
View File
@@ -0,0 +1,47 @@
#include "alu.inc"
.code
prolog
#define ADD(N, I0, I1, V) ALU(N, , add, I0, I1, V)
ADD(0, 0x7fffffff, 1, 0x80000000)
ADD(1, 1, 0x7fffffff, 0x80000000)
ADD(2, 0x80000000, 1, 0x80000001)
ADD(3, 1, 0x80000000, 0x80000001)
ADD(4, 0x7fffffff, 0x80000000, 0xffffffff)
ADD(5, 0x80000000, 0x7fffffff, 0xffffffff)
ADD(6, 0x7fffffff, 0, 0x7fffffff)
ADD(7, 0, 0x7fffffff, 0x7fffffff)
#if __WORDSIZE == 32
ADD(8, 0x7fffffff, 0xffffffff, 0x7ffffffe)
ADD(9, 0xffffffff, 0x7fffffff, 0x7ffffffe)
ADD(10, 0xffffffff, 0xffffffff, 0xfffffffe)
#else
ADD(8, 0x7fffffff, 0xffffffff, 0x17ffffffe)
ADD(9, 0xffffffff, 0x7fffffff, 0x17ffffffe)
ADD(10, 0xffffffff, 0xffffffff, 0x1fffffffe)
ADD(11, 0x7fffffffffffffff, 1, 0x8000000000000000)
ADD(12, 1, 0x7fffffffffffffff, 0x8000000000000000)
ADD(13, 0x8000000000000000, 1, 0x8000000000000001)
ADD(14, 1, 0x8000000000000000, 0x8000000000000001)
ADD(15, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff)
ADD(16, 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff)
ADD(17, 0x7fffffffffffffff, 0xffffffffffffffff, 0x7ffffffffffffffe)
ADD(18, 0x7fffffffffffffff, 0x7fffffffffffffff, 0xfffffffffffffffe)
ADD(19, 0xffffffffffffffff, 0xffffffffffffffff, 0xfffffffffffffffe)
#endif
#undef ADD
#define ADD(N, T, I0, I1, V) FOP(N, T, add, I0, I1, V)
ADD(0, _f, -0.5, 0.5, 0.0)
ADD(1, _f, 0.25, 0.75, 1.0)
ADD(0, _d, -0.5, 0.5, 0.0)
ADD(1, _d, 0.25, 0.75, 1.0)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+36
View File
@@ -0,0 +1,36 @@
#include "alu.inc"
.code
prolog
#define AND(N, I0, I1, V) ALU(N, , and, I0, I1, V)
AND(0, 0x7fffffff, 1, 1)
AND(1, 1, 0x7fffffff, 1)
AND(2, 0x80000000, 1, 0)
AND(3, 1, 0x80000000, 0)
AND(4, 0x7fffffff, 0x80000000, 0)
AND(5, 0x80000000, 0x7fffffff, 0)
AND(6, 0x7fffffff, 0xffffffff, 0x7fffffff)
AND(7, 0xffffffff, 0x7fffffff, 0x7fffffff)
AND(8, 0xffffffff, 0xffffffff, 0xffffffff)
AND(9, 0x7fffffff, 0, 0)
AND(10, 0, 0x7fffffff, 0)
#if __WORDSIZE == 64
AND(11, 0x7fffffffffffffff, 1, 1)
AND(12, 1, 0x7fffffffffffffff, 1)
AND(13, 0x8000000000000000, 1, 0)
AND(14, 1, 0x8000000000000000, 0)
AND(15, 0x7fffffffffffffff, 0x8000000000000000, 0)
AND(16, 0x8000000000000000, 0x7fffffffffffffff, 0)
AND(17, 0x7fffffffffffffff, 0xffffffffffffffff, 0x7fffffffffffffff)
AND(18, 0xffffffffffffffff, 0x7fffffffffffffff, 0x7fffffffffffffff)
AND(19, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+33
View File
@@ -0,0 +1,33 @@
#include "alu.inc"
.code
prolog
#define COM(N, I0, V) UN(N, com, I0, V)
#if __WORDSIZE == 32
COM(0, 0, 0xffffffff)
COM(1, 1, 0xfffffffe)
COM(2, 0xffffffff, 0)
COM(3, 0x80000000, 0x7fffffff)
COM(4, 0x7fffffff, 0x80000000)
COM(5, 0x80000001, 0x7ffffffe)
#else
COM(0, 0, 0xffffffffffffffff)
COM(1, 1, 0xfffffffffffffffe)
COM(2, 0xffffffff, 0xffffffff00000000)
COM(3, 0x80000000, 0xffffffff7fffffff)
COM(4, 0x7fffffff, 0xffffffff80000000)
COM(5, 0x80000001, 0xffffffff7ffffffe)
COM(6, 0xffffffffffffffff, 0)
COM(7, 0x8000000000000000, 0x7fffffffffffffff)
COM(8, 0x7fffffffffffffff, 0x8000000000000000)
COM(9, 0x8000000000000001, 0x7ffffffffffffffe)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+83
View File
@@ -0,0 +1,83 @@
#include "alu.inc"
.code
prolog
#define DIV(N, I0, I1, V) ALU(N, , div, I0, I1, V)
#define UDIV(N, I0, I1, V) ALU(N, _u, div, I0, I1, V)
DIV(0, 0x7fffffff, 1, 0x7fffffff)
DIV(1, 1, 0x7fffffff, 0)
DIV(2, 0x80000000, 1, 0x80000000)
DIV(3, 1, 0x80000000, 0)
DIV(4, 0x7fffffff, 2, 0x3fffffff)
DIV(5, 2, 0x7fffffff, 0)
DIV(6, 2, 0x80000000, 0)
DIV(7, 0x7fffffff, 0x80000000, 0)
DIV(8, 0, 0x7fffffff, 0)
DIV(9, 0xffffffff, 0xffffffff, 1)
UDIV(0, 0x7fffffff, 1, 0x7fffffff)
UDIV(1, 1, 0x7fffffff, 0)
UDIV(2, 0x80000000, 1, 0x80000000)
UDIV(3, 1, 0x80000000, 0)
UDIV(4, 0x7fffffff, 2, 0x3fffffff)
UDIV(5, 2, 0x7fffffff, 0)
UDIV(6, 0x80000000, 2, 0x40000000)
UDIV(7, 2, 0x80000000, 0)
UDIV(8, 0x7fffffff, 0x80000000, 0)
UDIV(9, 0x80000000, 0x7fffffff, 1)
UDIV(10,0, 0x7fffffff, 0)
UDIV(11,0x7fffffff, 0xffffffff, 0)
UDIV(12,0xffffffff, 0x7fffffff, 2)
UDIV(13,0xffffffff, 0xffffffff, 1)
#if __WORDSIZE == 32
DIV(10, 0x80000000, 2, 0xc0000000)
DIV(11, 0x80000000, 0x7fffffff, 0xffffffff)
DIV(12, 0x7fffffff, 0xffffffff, 0x80000001)
DIV(13, 0xffffffff, 0x7fffffff, 0)
#else
DIV(10, 0x80000000, 2, 0x40000000)
DIV(11, 0x80000000, 0x7fffffff, 1)
DIV(12, 0x7fffffff, 0xffffffff, 0)
DIV(13, 0xffffffff, 0x7fffffff, 2)
DIV(14, 0x7fffffffffffffff, 1, 0x7fffffffffffffff)
DIV(15, 1, 0x7fffffffffffffff, 0)
DIV(16, 0x8000000000000000, 1, 0x8000000000000000)
DIV(17, 1, 0x8000000000000000, 0)
DIV(18, 0x7fffffffffffffff, 2, 0x3fffffffffffffff)
DIV(19, 2, 0x7fffffffffffffff, 0)
DIV(20, 0x8000000000000000, 2, 0xc000000000000000)
DIV(21, 2, 0x8000000000000000, 0)
DIV(22, 0x7fffffffffffffff, 0x8000000000000000, 0)
DIV(23, 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff)
DIV(24, 0x7fffffffffffffff, 0xffffffffffffffff, 0x8000000000000001)
DIV(25, 0xffffffffffffffff, 0x7fffffffffffffff, 0)
DIV(26, 0xffffffffffffffff, 0xffffffffffffffff, 1)
UDIV(14,0x7fffffffffffffff, 1, 0x7fffffffffffffff)
UDIV(15,1, 0x7fffffffffffffff, 0)
UDIV(16,0x8000000000000000, 1, 0x8000000000000000)
UDIV(17,1, 0x8000000000000000, 0)
UDIV(18,0x7fffffffffffffff, 2, 0x3fffffffffffffff)
UDIV(19,2, 0x7fffffffffffffff, 0)
UDIV(20,0x8000000000000000, 2, 0x4000000000000000)
UDIV(21,2, 0x8000000000000000, 0)
UDIV(22,0x7fffffffffffffff, 0x8000000000000000, 0)
UDIV(23,0x8000000000000000, 0x7fffffffffffffff, 1)
UDIV(24,0x7fffffffffffffff, 0xffffffffffffffff, 0)
UDIV(25,0xffffffffffffffff, 0x7fffffffffffffff, 2)
UDIV(26,0xffffffffffffffff, 0xffffffffffffffff, 1)
#endif
#undef DIV
#define DIV(N, T, I0, I1, V) FOP(N, T, div, I0, I1, V)
DIV(0, _f, -0.5, 0.5, -1.0)
DIV(1, _f, 1.25, 0.5, 2.5)
DIV(0, _d, -0.5, 0.5, -1.0)
DIV(1, _d, 1.25, 0.5, 2.5)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+57
View File
@@ -0,0 +1,57 @@
#include "alu.inc"
.code
prolog
#define LSH(N, I0, I1, V) ALU(N, , lsh, I0, I1, V)
LSH(0, 0x7f, 1, 0xfe)
LSH(1, 0x7fff, 2, 0x1fffc)
LSH(2, 0x81, 16, 0x810000)
LSH(3, 0xff, 15, 0x7f8000)
LSH(4, 0x7fffffff, 0, 0x7fffffff)
#if __WORDSIZE == 32
LSH(5, 0xffffffff, 8, 0xffffff00)
LSH(6, 0x7fffffff, 3, 0xfffffff8)
LSH(7, -0x7f, 31, 0x80000000)
LSH(8, -0x7fff, 30, 0x40000000)
LSH(9, -0x7fffffff, 29, 0x20000000)
LSH(10, 0x80000001, 28, 0x10000000)
LSH(11, 0x8001, 17, 0x20000)
LSH(12, 0x80000001, 18, 0x40000)
LSH(13, -0xffff, 24, 0x1000000)
#else
LSH(5, 0xffffffff, 8, 0xffffffff00)
LSH(6, 0x7fffffff, 3, 0x3fffffff8)
LSH(7, -0x7f, 31, 0xffffffc080000000)
LSH(8, -0x7fff, 30, 0xffffe00040000000)
LSH(9, -0x7fffffff, 29, 0xf000000020000000)
LSH(10, 0x80000001, 28, 0x800000010000000)
LSH(11, 0x8001, 17, 0x100020000)
LSH(12, 0x80000001, 18, 0x2000000040000)
LSH(13, -0xffff, 24, 0xffffff0001000000)
LSH(14, 0x7f, 33, 0xfe00000000)
LSH(15, 0x7ffff, 34, 0x1ffffc00000000)
LSH(16, 0x7fffffff, 35, 0xfffffff800000000)
LSH(17, -0x7f, 63, 0x8000000000000000)
LSH(18, -0x7fff, 62, 0x4000000000000000)
LSH(19, -0x7fffffff, 61, 0x2000000000000000)
LSH(20, 0x80000001, 60, 0x1000000000000000)
LSH(21, 0x81, 48, 0x81000000000000)
LSH(22, 0x8001, 49, 0x2000000000000)
LSH(23, 0x80000001, 40, 0x10000000000)
LSH(24, 0xff, 47, 0x7f800000000000)
LSH(25, 0xffff0001, 56, 0x100000000000000)
LSH(26, 0xffffffff, 40, 0xffffff0000000000)
LSH(27, 0x7fffffffff, 33, 0xfffffffe00000000)
LSH(28, -0x7fffffffff, 63, 0x8000000000000000)
LSH(29, 0x8000000001, 48, 0x1000000000000)
LSH(30, 0xffffffffff, 47, 0xffff800000000000)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+59
View File
@@ -0,0 +1,59 @@
#include "alu.inc"
.code
prolog
#define MUL(N, I0, I1, V) ALU(N, , mul, I0, I1, V)
MUL(0, 0x7fffffff, 1, 0x7fffffff)
MUL(1, 1, 0x7fffffff, 0x7fffffff)
MUL(2, 0x80000000, 1, 0x80000000)
MUL(3, 1, 0x80000000, 0x80000000)
MUL(4, 0x7fffffff, 2, 0xfffffffe)
MUL(5, 2, 0x7fffffff, 0xfffffffe)
MUL(6, 0x7fffffff, 0, 0)
MUL(7, 0, 0x7fffffff, 0)
#if __WORDSIZE == 32
MUL(8, 0x80000000, 2, 0)
MUL(9, 2, 0x80000000, 0)
MUL(10, 0x7fffffff, 0x80000000, 0x80000000)
MUL(11, 0x80000000, 0x7fffffff, 0x80000000)
MUL(12, 0x7fffffff, 0xffffffff, 0x80000001)
MUL(13, 0xffffffff, 0x7fffffff, 0x80000001)
MUL(14, 0xffffffff, 0xffffffff, 1)
#else
MUL(8, 0x80000000, 2, 0x100000000)
MUL(9, 2, 0x80000000, 0x100000000)
MUL(10, 0x7fffffff, 0x80000000, 0x3fffffff80000000)
MUL(11, 0x80000000, 0x7fffffff, 0x3fffffff80000000)
MUL(12, 0x7fffffff, 0xffffffff, 0x7ffffffe80000001)
MUL(13, 0xffffffff, 0x7fffffff, 0x7ffffffe80000001)
MUL(14, 0xffffffff, 0xffffffff, 0xfffffffe00000001)
MUL(15, 0x7fffffffffffffff, 1, 0x7fffffffffffffff)
MUL(16, 1, 0x7fffffffffffffff, 0x7fffffffffffffff)
MUL(17, 0x8000000000000000, 1, 0x8000000000000000)
MUL(18, 1, 0x8000000000000000, 0x8000000000000000)
MUL(19, 0x7fffffffffffffff, 2, 0xfffffffffffffffe)
MUL(20, 2, 0x7fffffffffffffff, 0xfffffffffffffffe)
MUL(21, 0x8000000000000000, 2, 0)
MUL(22, 2, 0x8000000000000000, 0)
MUL(23, 0x7fffffffffffffff, 0x8000000000000000, 0x8000000000000000)
MUL(24, 0x8000000000000000, 0x7fffffffffffffff, 0x8000000000000000)
MUL(25, 0x7fffffffffffffff, 0xffffffffffffffff, 0x8000000000000001)
MUL(26, 0xffffffffffffffff, 0x7fffffffffffffff, 0x8000000000000001)
MUL(27, 0xffffffffffffffff, 0xffffffffffffffff, 1)
#endif
#undef MUL
#define MUL(N, T, I0, I1, V) FOP(N, T, mul, I0, I1, V)
MUL(0, _f, -0.5, 0.5, -0.25)
MUL(1, _f, 0.25, 0.75, 0.1875)
MUL(0, _d, -0.5, 0.5, -0.25)
MUL(1, _d, 0.25, 0.75, 0.1875)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+42
View File
@@ -0,0 +1,42 @@
#include "alu.inc"
.code
prolog
#define NEG(N, I, V) UN(N, neg, I, V)
NEG(0, 0, 0)
#if __WORDSIZE == 32
NEG(1, 1, 0xffffffff)
NEG(2, 0xffffffff, 1)
NEG(3, 0x80000000, 0x80000000)
NEG(4, 0x7fffffff, 0x80000001)
NEG(5, 0x80000001, 0x7fffffff)
#else
NEG(1, 1, 0xffffffffffffffff)
NEG(2, 0xffffffff, 0xffffffff00000001)
NEG(3, 0x80000000, 0xffffffff80000000)
NEG(4, 0x7fffffff, 0xffffffff80000001)
NEG(5, 0x80000001, 0xffffffff7fffffff)
NEG(6, 0xffffffffffffffff, 1)
NEG(7, 0x8000000000000000, 0x8000000000000000)
NEG(8, 0x7fffffffffffffff, 0x8000000000000001)
#endif
#undef NEG
#define NEG(N, T, I, V) FUN(N, T, neg, I, V)
NEG(0, _f, 0.0, -0.0)
NEG(1, _f, 0.5, -0.5)
NEG(2, _f, $(1 / 0.0), $(-1.0 / 0))
NEG(3, _f, -1.25, 1.25)
NEG(0, _d, 0.0, -0.0)
NEG(1, _d, 0.5, -0.5)
NEG(2, _d, $(1.0 / 0), $(-1 / 0.0))
NEG(3, _d, -1.25, 1.25)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+36
View File
@@ -0,0 +1,36 @@
#include "alu.inc"
.code
prolog
#define OR(N, I0, I1, V) ALU(N, , or, I0, I1, V)
OR(0, 0x7fffffff, 1, 0x7fffffff)
OR(1, 1, 0x7fffffff, 0x7fffffff)
OR(2, 0x80000000, 1, 0x80000001)
OR(3, 1, 0x80000000, 0x80000001)
OR(4, 0x7fffffff, 0x80000000, 0xffffffff)
OR(5, 0x80000000, 0x7fffffff, 0xffffffff)
OR(6, 0x7fffffff, 0xffffffff, 0xffffffff)
OR(7, 0xffffffff, 0x7fffffff, 0xffffffff)
OR(8, 0xffffffff, 0xffffffff, 0xffffffff)
OR(9, 0x7fffffff, 0, 0x7fffffff)
OR(10, 0, 0x7fffffff, 0x7fffffff)
#if __WORDSIZE == 64
OR(11, 0x7fffffffffffffff, 1, 0x7fffffffffffffff)
OR(12, 1, 0x7fffffffffffffff, 0x7fffffffffffffff)
OR(13, 0x8000000000000000, 1, 0x8000000000000001)
OR(14, 1, 0x8000000000000000, 0x8000000000000001)
OR(15, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff)
OR(16, 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff)
OR(17, 0x7fffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff)
OR(18, 0xffffffffffffffff, 0x7fffffffffffffff, 0xffffffffffffffff)
OR(19, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+76
View File
@@ -0,0 +1,76 @@
#include "alu.inc"
.code
prolog
#define REM(N, I0, I1, V) ALU(N, , rem, I0, I1, V)
#define UREM(N, I0, I1, V) ALU(N, _u, rem, I0, I1, V)
REM(0, 0x7fffffff, 1, 0)
REM(1, 1, 0x7fffffff, 1)
REM(2, 0x80000000, 1, 0)
REM(3, 1, 0x80000000, 1)
REM(4, 0x7fffffff, 2, 1)
REM(5, 2, 0x7fffffff, 2)
REM(6, 0x80000000, 2, 0)
REM(7, 2, 0x80000000, 2)
REM(8, 0x7fffffff, 0x80000000, 0x7fffffff)
REM(9, 0, 0x7fffffff, 0)
REM(10, 0xffffffff, 0xffffffff, 0)
UREM(0, 0x7fffffff, 1, 0)
UREM(1, 1, 0x7fffffff, 1)
UREM(2, 0x80000000, 1, 0)
UREM(3, 1, 0x80000000, 1)
UREM(4, 0x7fffffff, 2, 1)
UREM(5, 2, 0x7fffffff, 2)
UREM(6, 0x80000000, 2, 0)
UREM(7, 2, 0x80000000, 2)
UREM(8, 0x7fffffff, 0x80000000, 0x7fffffff)
UREM(9, 0x80000000, 0x7fffffff, 1)
UREM(10,0, 0x7fffffff, 0)
UREM(11,0x7fffffff, 0xffffffff, 0x7fffffff)
UREM(12,0xffffffff, 0x7fffffff, 1)
UREM(13,0xffffffff, 0xffffffff, 0)
#if __WORDSIZE == 32
REM(11, 0x80000000, 0x7fffffff, 0xffffffff)
REM(12, 0x7fffffff, 0xffffffff, 0)
REM(13, 0xffffffff, 0x7fffffff, 0xffffffff)
#else
REM(11, 0x80000000, 0x7fffffff, 1)
REM(12, 0x7fffffff, 0xffffffff, 0x7fffffff)
REM(13, 0xffffffff, 0x7fffffff, 1)
REM(14, 0x7fffffffffffffff, 1, 0)
REM(15, 1, 0x7fffffffffffffff, 1)
REM(16, 0x8000000000000000, 1, 0)
REM(17, 1, 0x8000000000000000, 1)
REM(18, 0x7fffffffffffffff, 2, 1)
REM(19, 2, 0x7fffffffffffffff, 2)
REM(20, 0x8000000000000000, 2, 0)
REM(21, 2, 0x8000000000000000, 2)
REM(22, 0x7fffffffffffffff, 0x8000000000000000, 0x7fffffffffffffff)
REM(23, 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff)
REM(24, 0x7fffffffffffffff, 0xffffffffffffffff, 0)
REM(25, 0xffffffffffffffff, 0x7fffffffffffffff, 0xffffffffffffffff)
REM(26, 0xffffffffffffffff, 0xffffffffffffffff, 0)
UREM(14,0x7fffffffffffffff, 1, 0)
UREM(15,1, 0x7fffffffffffffff, 1)
UREM(16,0x8000000000000000, 1, 0)
UREM(17,1, 0x8000000000000000, 1)
UREM(18,0x7fffffffffffffff, 2, 1)
UREM(19,2, 0x7fffffffffffffff, 2)
UREM(20,0x8000000000000000, 2, 0)
UREM(21,2, 0x8000000000000000, 2)
UREM(22,0x7fffffffffffffff, 0x8000000000000000, 0x7fffffffffffffff)
UREM(23,0x8000000000000000, 0x7fffffffffffffff, 1)
UREM(24,0x7fffffffffffffff, 0xffffffffffffffff, 0x7fffffffffffffff)
UREM(25,0xffffffffffffffff, 0x7fffffffffffffff, 1)
UREM(26,0xffffffffffffffff, 0xffffffffffffffff, 0)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+49
View File
@@ -0,0 +1,49 @@
#include "alu.inc"
.code
prolog
#define RSB(N, I0, I1, V) ALU(N, , rsb, I0, I1, V)
RSB(0, 1, 0x7fffffff, 0x7ffffffe)
RSB(2, 1, 0x80000000, 0x7fffffff)
RSB(3, 0x7fffffff, 0x80000000, 1)
RSB(4, 0xffffffff, 0xffffffff, 0)
RSB(5, 0x7fffffff, 0xffffffff, 0x80000000)
RSB(6, 0, 0x7fffffff, 0x7fffffff)
#if __WORDSIZE == 32
RSB(7, 0x7fffffff, 1, 0x80000002)
RSB(8, 0x80000000, 1, 0x80000001)
RSB(9, 0x80000000, 0x7fffffff, 0xffffffff)
RSB(10, 0xffffffff, 0x7fffffff, 0x80000000)
RSB(11, 0x7fffffff, 0, 0x80000001)
#else
RSB(7, 0x7fffffff, 1, 0xffffffff80000002)
RSB(8, 0xffffffff80000000, 1, 0x80000001)
RSB(9, 0xffffffff80000000, 0x7fffffff, 0xffffffff)
RSB(10, 0xffffffffffffffff, 0xffffffff7fffffff, 0xffffffff80000000)
RSB(11, 0x7fffffff, 0, 0xffffffff80000001)
RSB(12, 1, 0x7fffffffffffffff, 0x7ffffffffffffffe)
RSB(13, 0x7fffffffffffffff, 1, 0x8000000000000002)
RSB(14, 1, 0x8000000000000000, 0x7fffffffffffffff)
RSB(15, 0x8000000000000000, 1, 0x8000000000000001)
RSB(16, 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff)
RSB(17, 0x7fffffffffffffff, 0x8000000000000000, 1)
RSB(18, 0xffffffffffffffff, 0x7fffffffffffffff, 0x8000000000000000)
RSB(19, 0x7fffffffffffffff, 0xffffffffffffffff, 0x8000000000000000)
RSB(20, 0xffffffffffffffff, 0xffffffffffffffff, 0)
#endif
#undef RSB
#define RSB(N, T, I0, I1, V) FOP(N, T, rsb, I0, I1, V)
RSB(0, _f, 0.5, -0.5, -1.0)
RSB(1, _f, 0.75, 0.25, -0.5)
RSB(0, _d, 0.5, -0.5, -1.0)
RSB(1, _d, 0.75, 0.25, -0.5)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+85
View File
@@ -0,0 +1,85 @@
#include "alu.inc"
.code
prolog
#define RSH(N, I0, I1, V) ALU(N, , rsh, I0, I1, V)
#define URSH(N, I0, I1, V) ALU(N, _u, rsh, I0, I1, V)
RSH(0, 0xfe, 1, 0x7f)
RSH(1, 0x1fffc, 2, 0x7fff)
RSH(2, 0x40000000, 30, 1)
RSH(3, 0x20000000, 29, 1)
RSH(4, 0x10000000, 28, 1)
RSH(5, 0x810000, 16, 0x81)
RSH(6, 0x20000, 17, 1)
RSH(7, 0x40000, 18, 1)
RSH(8, 0x7f8000, 15, 0xff)
RSH(9, 0x1000000, 24, 1)
RSH(10, 0x7fffffff, 0, 0x7fffffff)
URSH(0, 0xfe, 1, 0x7f)
URSH(1, 0x1fffc, 2, 0x7fff)
URSH(2, 0x80000000, 31, 1)
URSH(3, 0x40000000, 30, 1)
URSH(4, 0x20000000, 29, 1)
URSH(5, 0x10000000, 28, 1)
URSH(6, 0x810000, 16, 0x81)
URSH(7, 0x20000, 17, 1)
URSH(8, 0x40000, 18, 1)
URSH(9,0x7f8000, 15, 0xff)
URSH(10,0x1000000, 24, 1)
URSH(11,0xffffff00, 8, 0xffffff)
URSH(12,0x7fffffff, 0, 0x7fffffff)
#if __WORDSIZE == 32
RSH(11, 0xfffffff8, 3, 0xffffffff)
RSH(12, 0x80000000, 31, 0xffffffff)
RSH(13, 0xffffff00, 8, 0xffffffff)
URSH(13,0xfffffff8, 3, 0x1fffffff)
#else
RSH(11, 0x3fffffff8, 3, 0x7fffffff)
RSH(12, 0xffffffc080000000, 31, 0xffffffffffffff81)
RSH(13, 0xffffff00, 8, 0xffffff)
RSH(14, 0xfe00000000, 33, 0x7f)
RSH(15, 0x1ffffc00000000, 34, 0x7ffff)
RSH(16, 0xfffffff800000000, 29, 0xffffffffffffffc0)
RSH(17, 0x8000000000000000, 63, 0xffffffffffffffff)
RSH(18, 0x4000000000000000, 62, 1)
RSH(19, 0x2000000000000000, 61, 1)
RSH(20, 0x1000000000000000, 60, 1)
RSH(21, 0x81000000000000, 48, 0x81)
RSH(22, 0x2000000000000, 49, 1)
RSH(23, 0x10000000000, 40, 1)
RSH(24, 0x7f800000000000, 47, 0xff)
RSH(25, 0x100000000000000, 56, 1)
RSH(26, 0xffffff0000000000, 40, 0xffffffffffffffff)
RSH(27, 0xfffffffe00000000, 33, 0xffffffffffffffff)
RSH(28, 0x8000000000000001, 63, 0xffffffffffffffff)
RSH(29, 0x1000000000000, 48, 1)
RSH(30, 0xffff800000000000, 47, 0xffffffffffffffff)
URSH(13,0x3fffffff8, 3, 0x7fffffff)
URSH(14,0xffffffc080000000, 31, 0x1ffffff81)
URSH(15,0xfe00000000, 33, 0x7f)
URSH(16,0x1ffffc00000000, 34, 0x7ffff)
URSH(17,0xfffffff800000000, 29, 0x7ffffffc0)
URSH(18,0x8000000000000000, 63, 1)
URSH(19,0x4000000000000000, 62, 1)
URSH(20,0x2000000000000000, 61, 1)
URSH(21,0x1000000000000000, 60, 1)
URSH(22,0x81000000000000, 48, 0x81)
URSH(23,0x2000000000000, 49, 1)
URSH(24,0x10000000000, 40, 1)
URSH(25,0x7f800000000000, 47, 0xff)
URSH(26,0x100000000000000, 56, 1)
URSH(27,0xffffff0000000000, 40, 0xffffff)
URSH(28,0xfffffffe00000000, 33, 0x7fffffff)
URSH(29,0x8000000000000001, 63, 1)
URSH(30,0x1000000000000, 48, 1)
URSH(31,0xffff800000000000, 47, 0x1ffff)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+49
View File
@@ -0,0 +1,49 @@
#include "alu.inc"
.code
prolog
#define SUB(N, I0, I1, V) ALU(N, , sub, I0, I1, V)
SUB(0, 0x7fffffff, 1, 0x7ffffffe)
SUB(2, 0x80000000, 1, 0x7fffffff)
SUB(3, 0x80000000, 0x7fffffff, 1)
SUB(4, 0xffffffff, 0xffffffff, 0)
SUB(5, 0xffffffff, 0x7fffffff, 0x80000000)
SUB(6, 0x7fffffff, 0, 0x7fffffff)
#if __WORDSIZE == 32
SUB(7, 1, 0x7fffffff, 0x80000002)
SUB(8, 1, 0x80000000, 0x80000001)
SUB(9, 0x7fffffff, 0x80000000, 0xffffffff)
SUB(10, 0x7fffffff, 0xffffffff, 0x80000000)
SUB(11, 0, 0x7fffffff, 0x80000001)
#else
SUB(7, 1, 0x7fffffff, 0xffffffff80000002)
SUB(8, 1, 0xffffffff80000000, 0x80000001)
SUB(9, 0x7fffffff, 0xffffffff80000000, 0xffffffff)
SUB(10, 0xffffffff7fffffff, 0xffffffffffffffff, 0xffffffff80000000)
SUB(11, 0, 0x7fffffff, 0xffffffff80000001)
SUB(12, 0x7fffffffffffffff, 1, 0x7ffffffffffffffe)
SUB(13, 1, 0x7fffffffffffffff, 0x8000000000000002)
SUB(14, 0x8000000000000000, 1, 0x7fffffffffffffff)
SUB(15, 1, 0x8000000000000000, 0x8000000000000001)
SUB(16, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff)
SUB(17, 0x8000000000000000, 0x7fffffffffffffff, 1)
SUB(18, 0x7fffffffffffffff, 0xffffffffffffffff, 0x8000000000000000)
SUB(19, 0xffffffffffffffff, 0x7fffffffffffffff, 0x8000000000000000)
SUB(20, 0xffffffffffffffff, 0xffffffffffffffff, 0)
#endif
#undef SUB
#define SUB(N, T, I0, I1, V) FOP(N, T, sub, I0, I1, V)
SUB(0, _f, -0.5, 0.5, -1.0)
SUB(1, _f, 0.25, 0.75, -0.5)
SUB(0, _d, -0.5, 0.5, -1.0)
SUB(1, _d, 0.25, 0.75, -0.5)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+36
View File
@@ -0,0 +1,36 @@
#include "alu.inc"
.code
prolog
#define XOR(N, I0, I1, V) ALU(N, , xor, I0, I1, V)
XOR(0, 0x7fffffff, 1, 0x7ffffffe)
XOR(1, 1, 0x7fffffff, 0x7ffffffe)
XOR(2, 0x80000000, 1, 0x80000001)
XOR(3, 1, 0x80000000, 0x80000001)
XOR(4, 0x7fffffff, 0x80000000, 0xffffffff)
XOR(5, 0x80000000, 0x7fffffff, 0xffffffff)
XOR(6, 0x7fffffff, 0xffffffff, 0x80000000)
XOR(7, 0xffffffff, 0x7fffffff, 0x80000000)
XOR(9, 0xffffffff, 0xffffffff, 0)
XOR(10, 0x7fffffff, 0, 0x7fffffff)
XOR(11, 0, 0x7fffffff, 0x7fffffff)
#if __WORDSIZE == 64
XOR(12, 0x7fffffffffffffff, 1, 0x7ffffffffffffffe)
XOR(13, 1, 0x7fffffffffffffff, 0x7ffffffffffffffe)
XOR(14, 0x8000000000000000, 1, 0x8000000000000001)
XOR(15, 1, 0x8000000000000000, 0x8000000000000001)
XOR(16, 0x7fffffffffffffff, 0x8000000000000000, 0xffffffffffffffff)
XOR(17, 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff)
XOR(18, 0x7fffffffffffffff, 0xffffffffffffffff, 0x8000000000000000)
XOR(19, 0xffffffffffffffff, 0x7fffffffffffffff, 0x8000000000000000)
XOR(20, 0xffffffffffffffff, 0xffffffffffffffff, 0)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+49
View File
@@ -0,0 +1,49 @@
#include "alu.inc"
.code
prolog
#define ADDX(N, I0, I1, V) ALUX(N, add, I0, I1, V)
/* nothing */
ADDX(0, 0, 0, 0)
#if __WORDSIZE == 32
/* carry */
ADDX(1, 0xffffffff, 0xffffffff, 1)
/* overflow */
ADDX(2, 0x7fffffff, 1, 0)
/* overflow */
ADDX(3, 0x7fffffff, 0x7fffffff, 0)
/* carry */
ADDX(4, 0x7fffffff, 0x80000000, 0)
/* carry+overflow */
ADDX(5, 0x80000000, 0x80000000, 1)
#else
/* nothing */
ADDX(1, 0xffffffff, 0xffffffff, 0)
/* nothing */
ADDX(2, 0x7fffffff, 1, 0)
/* nothing */
ADDX(3, 0x7fffffff, 0x7fffffff, 0)
/* nothing */
ADDX(4, 0x7fffffff, 0x80000000, 0)
/* nothing */
ADDX(5, 0x80000000, 0x80000000, 0)
/* carry */
ADDX(6, 0xffffffffffffffff, 0xffffffffffffffff, 1)
/* overflow */
ADDX(7, 0x7fffffffffffffff, 1, 0)
/* overflow */
ADDX(8, 0x7fffffffffffffff, 0x7fffffffffffffff, 0)
/* overflow */
ADDX(9, 0x7fffffffffffffff, 0x8000000000000000, 0)
/* carry+overflow */
ADDX(10,0x8000000000000000, 0x8000000000000000, 1)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+49
View File
@@ -0,0 +1,49 @@
#include "alu.inc"
.code
prolog
#define SUBX(N, I0, I1, V) ALUX(N, sub, I0, I1, V)
/* nothing */
SUBX(0, 0, 0, 0)
#if __WORDSIZE == 32
/* carry */
SUBX(1, 0x7fffffff, 0xffffffff, 0xffffffff)
/* overflow */
SUBX(2, 0x80000000, 1, 0)
/* carry */
SUBX(3, 0x7fffffff, 0x80000000, 0xffffffff)
/* overflow */
SUBX(4, 0x80000000, 0x7fffffff, 0)
/* carry+overflow */
SUBX(5, 1, 0x80000000, 0xffffffff)
#else
/* carry */
SUBX(1, 0x7fffffff, 0xffffffff, -1)
/* nothing */
SUBX(2, 0x80000000, 1, 0)
/* carry */
SUBX(3, 0x7fffffff, 0x80000000, -1)
/* nothing */
SUBX(4, 0x80000000, 0x7fffffff, 0)
/* carry */
SUBX(5, 1, 0x80000000, -1)
/* carry */
SUBX(6, 0x7fffffffffffffff, 0xffffffffffffffff, -1)
/* overflow */
SUBX(7, 0x8000000000000000, 1, 0)
/* carry */
SUBX(8, 0x7fffffffffffffff, 0x8000000000000000, -1)
/* overflow */
SUBX(9, 0x8000000000000000, 0x7fffffffffffffff, 0)
/* carry+overflow */
SUBX(10,1, 0x8000000000000000, -1)
#endif
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
nfibs(32) = 2178309
+46
View File
@@ -0,0 +1,46 @@
.data 32
fmt:
.c "nfibs(%d) = %d\n"
.code
jmpi main
name rfibs
rfibs:
prolog
arg $in
getarg %r0 $in /* R0 = N */
beqi out %r0 0
movr %v0 %r0 /* V0 = R0 */
movi %r0 1
blei_u out %v0 2
subi %v1 %v0 1 /* V1 = N-1 */
subi %v2 %v0 2 /* V1 = N-2 */
prepare
pushargr %v1
finishi rfibs
retval %v1 /* V1 = rfibs(N-1) */
prepare
pushargr %v2
finishi rfibs
retval %r0 /* R0 = rfibs(N-2) */
addr %r0 %r0 %v1
out:
retr %r0
epilog
name main
main:
prolog
prepare
pushargi 32
finishi rfibs
retval %v0
prepare
pushargi fmt
ellipsis
pushargi 32
pushargr %v0
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+563
View File
@@ -0,0 +1,563 @@
#if __WORDSIZE == 64
# define I7f 0x7fffffffffffffff
# define I80 0x8000000000000000
# define I81 0x8000000000000001
# define Iff 0xffffffffffffffff
#else
# define I7f 0x7fffffff
# define I80 0x80000000
# define I81 0x80000001
# define Iff 0xffffffff
#endif
.data 12
ok:
.c "ok\n"
. $($NaN = 0.0 / 0.0)
#define BOP(N, Ls, Rs, Lu, Ru, R0, R1) \
movi %R0 Ls \
movi %R1 Rs \
b##N##r N##r_##R0##_##R1 %R0 %R1 \
calli @abort \
N##r_##R0##_##R1: \
b##N##i N##i_##R0##_##R1 %R0 Rs \
calli @abort \
N##i_##R0##_##R1: \
movi %R0 Lu \
movi %R1 Ru \
b##N##r_u N##r_u_##R0##_##R1 %R0 %R1 \
calli @abort \
N##r_u_##R0##_##R1: \
b##N##i_u N##i_u_##R0##_##R1 %R0 Ru \
calli @abort \
N##i_u_##R0##_##R1: \
movi %R0 Ls \
movi %R1 Rs \
N##r %R0 %R0 %R1 \
beqi _##N##r_##R0##_##R1 %R0 1 \
calli @abort \
_##N##r_##R0##_##R1: \
movi %R0 Ls \
N##i %R1 %R0 Rs \
beqi _##N##i_##R0##_##R1 %R1 1 \
calli @abort \
_##N##i_##R0##_##R1: \
movi %R0 Lu \
movi %R1 Ru \
N##r_u %R0 %R0 %R1 \
beqi _##N##r_u_##R0##_##R1 %R0 1 \
calli @abort \
_##N##r_u_##R0##_##R1: \
movi %R0 Lu \
N##i_u %R1 %R0 Ru \
beqi _##N##i_u_##R0##_##R1 %R1 1 \
calli @abort \
_##N##i_u_##R0##_##R1:
#define EB(N, L, R, R0, R1) \
movi %R0 L \
movi %R1 R \
b##N##r N##r_##R0##_##R1 %R0 %R1 \
calli @abort \
N##r_##R0##_##R1: \
b##N##i N##i_##R0##_##R1 %R0 R \
calli @abort \
N##i_##R0##_##R1: \
movi %R0 L \
movi %R1 R \
N##r %R0 %R0 %R1 \
beqi _##N##r_##R0##_##R1 %R0 1 \
calli @abort \
_##N##r_##R0##_##R1: \
movi %R0 L \
N##i %R1 %R0 R \
beqi _##N##i_##R0##_##R1 %R1 1 \
calli @abort \
_##N##i_##R0##_##R1:
#define XEB(N, L, R, R0, R1) \
movi %R0 L \
movi %R1 R \
b##N##r N##r_##R0##_##R1 %R0 %R1 \
calli @abort \
N##r_##R0##_##R1: \
b##N##i N##i_##R0##_##R1 %R0 R \
calli @abort \
N##i_##R0##_##R1:
#define XBOP(N, Ls, Rs, Lu, Ru, R0, R1) \
movi %R0 Ls \
movi %R1 Rs \
b##N##r N##r_##R0##_##R1 %R0 %R1 \
calli @abort \
N##r_##R0##_##R1: \
movi %R0 Ls \
b##N##i N##i_##R0##_##R1 %R0 Rs \
calli @abort \
N##i_##R0##_##R1: \
movi %R0 Lu \
movi %R1 Ru \
b##N##r_u N##r_u_##R0##_##R1 %R0 %R1 \
calli @abort \
N##r_u_##R0##_##R1: \
movi %R0 Lu \
b##N##i_u N##i_u_##R0##_##R1 %R0 Ru \
calli @abort \
N##i_u_##R0##_##R1:
#define BOPI(N, Ls, Rs, Lu, Ru) \
BOP(N, Ls, Rs, Lu, Ru, v0, v1) \
BOP(N, Ls, Rs, Lu, Ru, v0, v2) \
BOP(N, Ls, Rs, Lu, Ru, v0, r0) \
BOP(N, Ls, Rs, Lu, Ru, v0, r1) \
BOP(N, Ls, Rs, Lu, Ru, v0, r2) \
BOP(N, Ls, Rs, Lu, Ru, v1, v0) \
BOP(N, Ls, Rs, Lu, Ru, v1, v2) \
BOP(N, Ls, Rs, Lu, Ru, v1, r0) \
BOP(N, Ls, Rs, Lu, Ru, v1, r1) \
BOP(N, Ls, Rs, Lu, Ru, v1, r2) \
BOP(N, Ls, Rs, Lu, Ru, v2, v0) \
BOP(N, Ls, Rs, Lu, Ru, v2, v1) \
BOP(N, Ls, Rs, Lu, Ru, v2, r0) \
BOP(N, Ls, Rs, Lu, Ru, v2, r1) \
BOP(N, Ls, Rs, Lu, Ru, v2, r2) \
BOP(N, Ls, Rs, Lu, Ru, r0, v0) \
BOP(N, Ls, Rs, Lu, Ru, r0, v1) \
BOP(N, Ls, Rs, Lu, Ru, r0, v2) \
BOP(N, Ls, Rs, Lu, Ru, r0, r1) \
BOP(N, Ls, Rs, Lu, Ru, r0, r2) \
BOP(N, Ls, Rs, Lu, Ru, r1, v0) \
BOP(N, Ls, Rs, Lu, Ru, r1, v1) \
BOP(N, Ls, Rs, Lu, Ru, r1, v2) \
BOP(N, Ls, Rs, Lu, Ru, r1, r0) \
BOP(N, Ls, Rs, Lu, Ru, r1, r2) \
BOP(N, Ls, Rs, Lu, Ru, r2, v0) \
BOP(N, Ls, Rs, Lu, Ru, r2, v1) \
BOP(N, Ls, Rs, Lu, Ru, r2, v2) \
BOP(N, Ls, Rs, Lu, Ru, r2, r0) \
BOP(N, Ls, Rs, Lu, Ru, r2, r1)
#define EBI(N, L, R) \
EB(N, L, R, v0, v1) \
EB(N, L, R, v0, v2) \
EB(N, L, R, v0, r0) \
EB(N, L, R, v0, r1) \
EB(N, L, R, v0, r2) \
EB(N, L, R, v1, v0) \
EB(N, L, R, v1, v2) \
EB(N, L, R, v1, r0) \
EB(N, L, R, v1, r1) \
EB(N, L, R, v1, r2) \
EB(N, L, R, v2, v0) \
EB(N, L, R, v2, v1) \
EB(N, L, R, v2, r0) \
EB(N, L, R, v2, r1) \
EB(N, L, R, v2, r2) \
EB(N, L, R, r0, v0) \
EB(N, L, R, r0, v1) \
EB(N, L, R, r0, v2) \
EB(N, L, R, r0, r1) \
EB(N, L, R, r0, r2) \
EB(N, L, R, r1, v0) \
EB(N, L, R, r1, v1) \
EB(N, L, R, r1, v2) \
EB(N, L, R, r1, r0) \
EB(N, L, R, r1, r2) \
EB(N, L, R, r2, v0) \
EB(N, L, R, r2, v1) \
EB(N, L, R, r2, v2) \
EB(N, L, R, r2, r0) \
EB(N, L, R, r2, r1)
#define XEBI(N, L, R) \
XEB(N, L, R, v0, v1) \
XEB(N, L, R, v0, v2) \
XEB(N, L, R, v0, r0) \
XEB(N, L, R, v0, r1) \
XEB(N, L, R, v0, r2) \
XEB(N, L, R, v1, v0) \
XEB(N, L, R, v1, v2) \
XEB(N, L, R, v1, r0) \
XEB(N, L, R, v1, r1) \
XEB(N, L, R, v1, r2) \
XEB(N, L, R, v2, v0) \
XEB(N, L, R, v2, v1) \
XEB(N, L, R, v2, r0) \
XEB(N, L, R, v2, r1) \
XEB(N, L, R, v2, r2) \
XEB(N, L, R, r0, v0) \
XEB(N, L, R, r0, v1) \
XEB(N, L, R, r0, v2) \
XEB(N, L, R, r0, r1) \
XEB(N, L, R, r0, r2) \
XEB(N, L, R, r1, v0) \
XEB(N, L, R, r1, v1) \
XEB(N, L, R, r1, v2) \
XEB(N, L, R, r1, r0) \
XEB(N, L, R, r1, r2) \
XEB(N, L, R, r2, v0) \
XEB(N, L, R, r2, v1) \
XEB(N, L, R, r2, v2) \
XEB(N, L, R, r2, r0) \
XEB(N, L, R, r2, r1)
#define XBOPI(N, Ls, Rs, Lu, Ru) \
XBOP(N, Ls, Rs, Lu, Ru, v0, v1) \
XBOP(N, Ls, Rs, Lu, Ru, v0, v2) \
XBOP(N, Ls, Rs, Lu, Ru, v0, r0) \
XBOP(N, Ls, Rs, Lu, Ru, v0, r1) \
XBOP(N, Ls, Rs, Lu, Ru, v0, r2) \
XBOP(N, Ls, Rs, Lu, Ru, v1, v0) \
XBOP(N, Ls, Rs, Lu, Ru, v1, v2) \
XBOP(N, Ls, Rs, Lu, Ru, v1, r0) \
XBOP(N, Ls, Rs, Lu, Ru, v1, r1) \
XBOP(N, Ls, Rs, Lu, Ru, v1, r2) \
XBOP(N, Ls, Rs, Lu, Ru, v2, v0) \
XBOP(N, Ls, Rs, Lu, Ru, v2, v1) \
XBOP(N, Ls, Rs, Lu, Ru, v2, r0) \
XBOP(N, Ls, Rs, Lu, Ru, v2, r1) \
XBOP(N, Ls, Rs, Lu, Ru, v2, r2) \
XBOP(N, Ls, Rs, Lu, Ru, r0, v0) \
XBOP(N, Ls, Rs, Lu, Ru, r0, v1) \
XBOP(N, Ls, Rs, Lu, Ru, r0, v2) \
XBOP(N, Ls, Rs, Lu, Ru, r0, r1) \
XBOP(N, Ls, Rs, Lu, Ru, r0, r2) \
XBOP(N, Ls, Rs, Lu, Ru, r1, v0) \
XBOP(N, Ls, Rs, Lu, Ru, r1, v1) \
XBOP(N, Ls, Rs, Lu, Ru, r1, v2) \
XBOP(N, Ls, Rs, Lu, Ru, r1, r0) \
XBOP(N, Ls, Rs, Lu, Ru, r1, r2) \
XBOP(N, Ls, Rs, Lu, Ru, r2, v0) \
XBOP(N, Ls, Rs, Lu, Ru, r2, v1) \
XBOP(N, Ls, Rs, Lu, Ru, r2, v2) \
XBOP(N, Ls, Rs, Lu, Ru, r2, r0) \
XBOP(N, Ls, Rs, Lu, Ru, r2, r1)
#define TBOPF(N, T, L, R) \
movi_##T %f0 L \
movi_##T %f1 R \
b##N##r##_##T N##r_##T %f0 %f1 \
calli @abort \
N##r_##T: \
b##N##i##_##T N##i_##T %f0 R \
calli @abort \
N##i_##T: \
movi_##T %f1 $NaN \
b##N##r##_##T N##r_##T##_##u %f0 %f1 \
jmpi N##r_##T##_##u0 \
N##r_##T##_##u: \
calli @abort \
N##r##_##T##_##u0: \
b##N##i##_##T N##i_##T##_##u %f0 $NaN \
jmpi N##i_##T##_##u0 \
N##i##_##T##_##u: \
calli @abort \
N##i##_##T##_##u0:
#define BOPF(N, L, R) \
TBOPF(N, f, L, R) \
TBOPF(N, d, L, R)
#define TUBOPF(N, T, L, R) \
movi_##T %f0 L \
movi_##T %f1 R \
b##N##r##_##T N##r_##T %f0 %f1 \
calli @abort \
N##r_##T: \
b##N##i##_##T N##i_##T %f0 R \
calli @abort \
N##i_##T: \
movi_##T %f1 $NaN \
b##N##r##_##T N##r_##T##_##u %f0 %f1 \
calli @abort \
N##r_##T##_##u: \
b##N##i##_##T N##i_##T##_##u %f0 $NaN \
calli @abort \
N##i##_##T##_##u:
#define UBOPF(N, L, R) \
TUBOPF(N, f, L, R) \
TUBOPF(N, d, L, R)
.code
prolog
movi %r0 -1
movi %r1 1
bltr xltr_r0_r1 %r0 %r1
calli @abort
xltr_r0_r1:
blti xlti_r0_r1 %r0 1
calli @abort
xlti_r0_r1:
movi %r0 1
movi %r1 -1
bltr_u xltru_r0_r1 %r0 %r1
calli @abort
xltru_r0_r1:
blti_u xltiu_r0_r1 %r0 -1
calli @abort
xltiu_r0_r1:
movi %r0 -1
movi %r1 -1
bler xler_r0_r1 %r0 %r1
calli @abort
xler_r0_r1:
blti xlei_r0_r1 %r0 1
calli @abort
xlei_r0_r1:
movi %r0 1
movi %r1 -1
bltr_u xlteu_r0_r1 %r0 %r1
calli @abort
xlteu_r0_r1:
blei_u xleiu_r0_r1 %r0 -1
calli @abort
xleiu_r0_r1:
movi %r0 32
movi %r1 32
beqr xeqr_r0_r1 %r0 %r1
calli @abort
xeqr_r0_r1:
beqi xeqi_r0_r1 %r0 32
calli @abort
xeqi_r0_r1:
movi %r0 -2
movi %r1 -2
bger xger_r0_r1 %r0 %r1
calli @abort
xger_r0_r1:
bgei xgei_r0_r1 %r0 -2
calli @abort
xgei_r0_r1:
movi %r0 2
movi %r1 2
bger_u xgeru_r0_r1 %r0 %r1
calli @abort
xgeru_r0_r1:
bgei_u xgeiu_r0_r1 %r0 2
calli @abort
xgeiu_r0_r1:
movi %r0 2
movi %r1 -2
bgtr xgtr_r0_r1 %r0 %r1
calli @abort
xgtr_r0_r1:
bgti xgti_r0_r1 %r0 -2
calli @abort
xgti_r0_r1:
movi %r0 -2
movi %r1 2
bgtr_u xgtru_r0_r1 %r0 %r1
calli @abort
xgtru_r0_r1:
bgti_u xgtiu_r0_r1 %r0 2
calli @abort
xgtiu_r0_r1:
movi %r0 -3
movi %r1 3
bner xner_r0_r1 %r0 %r1
calli @abort
xner_r0_r1:
bnei xnei_r0_r1 %r0 3
calli @abort
xnei_r0_r1:
movi %r0 1
movi %r1 3
bmsr xmsr_r0_r1 %r0 %r1
calli @abort
xmsr_r0_r1:
bmsi xmsi_r0_r1 %r0 3
calli @abort
xmsi_r0_r1:
movi %r0 1
movi %r1 2
bmcr xmcr_r0_r1 %r0 %r1
calli @abort
xmcr_r0_r1:
bmci xmci_r0_r1 %r0 2
calli @abort
xmci_r0_r1:
movi %r0 I7f
movi %r1 1
boaddr xoaddr_r0_r1 %r0 %r1
calli @abort
xoaddr_r0_r1:
movi %r0 Iff
movi %r1 1
boaddr_u xoaddr_u_r0_r1 %r0 %r1
calli @abort
xoaddr_u_r0_r1:
movi %r0 I7f
boaddi xoaddi_r0_r1 %r0 1
calli @abort
xoaddi_r0_r1:
movi %r0 Iff
boaddi_u xoaddi_u_r0_r1 %r0 1
calli @abort
xoaddi_u_r0_r1:
movi %r0 I80
movi %r1 1
bxaddr xxaddr_r0_r1 %r0 %r1
calli @abort
xxaddr_r0_r1:
movi %r0 I80
bxaddi xxaddi_r0_r1 %r0 1
calli @abort
xxaddi_r0_r1:
movi %r0 I7f
movi %r1 1
bxaddr_u xxaddr_u_r0_r1 %r0 %r1
calli @abort
xxaddr_u_r0_r1:
movi %r0 I7f
bxaddi_u xxaddi_u_r0_r1 %r0 1
calli @abort
xxaddi_u_r0_r1:
movi %r0 I80
movi %r1 1
bosubr xosubr_r0_r1 %r0 %r1
calli @abort
xosubr_r0_r1:
movi %r0 0
movi %r1 1
bosubr_u xosubr_u_r0_r1 %r0 %r1
calli @abort
xosubr_u_r0_r1:
movi %r0 I80
bosubi xosubi_r0_r1 %r0 1
calli @abort
xosubi_r0_r1:
movi %r0 0
bosubi_u xosubi_u_r0_r1 %r0 1
calli @abort
xosubi_u_r0_r1:
movi %r0 I81
movi %r1 1
bxsubr xxsubr_r0_r1 %r0 %r1
calli @abort
xxsubr_r0_r1:
movi %r0 I81
bxsubi xxsubi_r0_r1 %r0 1
calli @abort
xxsubi_r0_r1:
movi %r0 I80
movi %r1 1
bxsubr_u xxsubr_u_r0_r1 %r0 %r1
calli @abort
xxsubr_u_r0_r1:
movi %r0 I80
bxsubi_u xxsubi_u_r0_r1 %r0 1
calli @abort
xxsubi_u_r0_r1:
movi_f %f0 1
movi_f %f1 2
bltr_f xltr_f_f0_f1 %f0 %f1
calli @abort
xltr_f_f0_f1:
blti_f xlti_f_f0_f1 %f0 2
calli @abort
xlti_f_f0_f1:
movi_f %f0 -1
movi_f %f1 -1
bler_f xler_f_f0_f1 %f0 %f1
calli @abort
xler_f_f0_f1:
blei_f xlei_f_f0_f1 %f0 -1
calli @abort
xlei_f_f0_f1:
movi_f %f0 -2
movi_f %f1 -2
beqr_f xeqr_f_f0_f1 %f0 %f1
calli @abort
xeqr_f_f0_f1:
beqi_f xeqi_f_f0_f1 %f0 -2
calli @abort
xeqi_f_f0_f1:
movi_f %f0 -3
movi_f %f1 -3
bger_f xger_f_f0_f1 %f0 %f1
calli @abort
xger_f_f0_f1:
bgei_f xgei_f_f0_f1 %f0 -3
calli @abort
xgei_f_f0_f1:
movi_f %f0 2
movi_f %f1 1
bgtr_f xgtr_f_f0_f1 %f0 %f1
calli @abort
xgtr_f_f0_f1:
bgti_f xgti_f_f0_f1 %f0 1
calli @abort
xgti_f_f0_f1:
movi_f %f0 0
movi_f %f1 2
bner_f xner_f_f0_f1 %f0 %f1
calli @abort
xner_f_f0_f1:
bnei_f xnei_f_f0_f1 %f0 2
calli @abort
xnei_f_f0_f1:
BOPI(lt, -1, 1, 1, -1)
BOPI(le, -1, -1, 1, 1)
EBI(eq, 32, 32)
BOPI(ge, -2, -2, 2, 2)
BOPI(gt, 2, -2, -2, 2)
EBI(ne, 3, -3)
XEBI(ms, 1, 3)
XEBI(mc, 1, 2)
XBOPI(oadd, I7f, 1, Iff, 1)
XBOPI(xadd, I80, 1, I7f, 1)
XBOPI(osub, I80, 1, 0, 1)
XBOPI(xsub, I81, 1, I80, 1)
BOPF(lt, 1, 2)
BOPF(le, 2, 2)
BOPF(eq, 3, 3)
BOPF(ge, 3, 3)
BOPF(gt, 4, 3)
UBOPF(ne, 4, 3)
UBOPF(unlt, 1, 2)
UBOPF(unle, 2, 2)
UBOPF(uneq, 3, 3)
UBOPF(unge, 3, 3)
UBOPF(ungt, 4, 3)
BOPF(ltgt, 4, 3)
movi_f %f0 5
movi_f %f1 5
bordr_f ordr_f %f0 %f1
calli @abort
ordr_f:
bordi_f ordi_f %f0 1
calli @abort
ordi_f:
bordi_f ordi_f_u %f0 $NaN
jmpi ordi_f_u0
ordi_f_u:
calli @abort
ordi_f_u0:
movi_f %f0 5
movi_f %f1 5
bunordr_f unordr_f %f0 %f1
jmpi unordr_f_0
unordr_f:
calli @abort
unordr_f_0:
bunordi_f unordi_f %f0 1
jmpi unordi_f_0
unordi_f:
calli @abort
unordi_f_0:
bunordi_f unordi_f_1 %f0 $NaN
calli @abort
unordi_f_1:
// just to know did not crash or abort
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+4
View File
@@ -0,0 +1,4 @@
forward
backward
forward
backward
+272
View File
@@ -0,0 +1,272 @@
#define def_wi(i) \
name _w##i \
_w##i: \
prolog \
arg $arg##i \
getarg##i %r0 $arg##i \
retr %r0 \
epilog
#define def_wf(f) \
name _w##f \
_w##f: \
prolog \
arg##f $arg##f \
getarg##f %f0 $arg##f \
truncr##f %r0 %f0 \
retr %r0 \
epilog
#define def_fi(f, i) \
name f##i \
f##i: \
prolog \
arg $arg##i \
getarg##i %r0 $arg##i \
extr##f %f0 %r0 \
retr##f %f0 \
epilog
#define def_f(f) \
name f##f \
f##f: \
prolog \
arg##f $arg##f \
getarg##f %f0 $arg##f \
retr##f %f0 \
epilog
#define def_ff(f, g) \
name f##g \
name f##g \
f##g: \
prolog \
arg##g $arg##g \
getarg##g %f0 $arg##g \
extr##g##f %f0 %f0 \
retr##f %f0 \
epilog
.data 32
fstr:
.c "forward"
bstr:
.c "backward"
.code
jmpi main
def_wi(_c)
def_wi(_uc)
def_wi(_s)
def_wi(_us)
#if __WORDSIZE == 64
def_wi(_i)
def_wi(_ui)
#endif
def_wf(_f)
def_wf(_d)
def_fi(_f, _c)
def_fi(_f, _uc)
def_fi(_f, _s)
def_fi(_f, _us)
def_fi(_f, _i)
#if __WORDSIZE == 64
def_fi(_f, _ui)
def_fi(_f, _l)
#endif
def_fi(_d, _c)
def_fi(_d, _uc)
def_fi(_d, _s)
def_fi(_d, _us)
def_fi(_d, _i)
#if __WORDSIZE == 64
def_fi(_d, _ui)
def_fi(_d, _l)
#endif
def_f(_f)
def_f(_d)
def_ff(_f, _d)
def_ff(_d, _f)
name main
main:
prolog
#define _call_w(n, i, a, r) \
prepare \
pushargi a \
finishi _w##i \
retval %r0 \
extr##i %r0 %r0 \
beqi _w##i##_##n %r0 r \
calli @abort \
_w##i##_##n:
#define call_w(n, i, a, r) _call_w(n, i, a, r)
#define _call_wf(n, f, a, r) \
prepare \
pushargi##f a \
finishi _w##f \
retval %r0 \
extr##f %f0 %r0 \
beqi##f _w##f##_##n %f0 r \
calli @abort \
_w##f##_##n:
#define call_wf(n, f, a, r) _call_wf(n, f, a, r)
#define _call_fi(n, f, i, a, r) \
prepare \
pushargi a \
finishi f##i \
retval##f %f0 \
beqi##f f##i##n %f0 r \
calli @abort \
f##i##n:
#define call_fi(n, f, i, a, r) _call_fi(n, f, i, a, r)
#define _call_f(n, f, a, r) \
prepare \
pushargi##f a \
finishi f##f \
retval##f %f0 \
beqi##f f##f##n %f0 r \
calli @abort \
f##f##n:
#define call_f(n, f, a, r) _call_f(n, f, a, r)
#define _call_ff(n, f, g, a, r) \
prepare \
pushargi##g a \
finishi f##g \
retval##f %f0 \
beqi##f f##g##n %f0 r \
calli @abort \
f##g##n:
#define call_ff(n, f, g, a, r) _call_ff(n, f, g, a, r)
#define c7f 0x7f
#define c80 0x80
#define c81 0x81
#define cff 0xff
#define s7f 0x7fff
#define s80 0x8000
#define s81 0x8001
#define i7f 0x7fffffff
#define i80 0x80000000
#define i81 0x80000001
#define iff 0xffffffff
#define l7f 0x7fffffffffffffff
#define l80 0x8000000000000000
#define l81 0x8000000000000001
#define f7f 127.0
#define f80 -128.0
#define f81 -127.0
#define uf80 128.0
#define uf81 127.0
#if __WORDSIZE == 32
# define wc80 0xffffff80
# define wc81 0xffffff81
# define ws80 0xffff8000
# define ws81 0xffff8001
#else
# define wc80 0xffffffffffffff80
# define wc81 0xffffffffffffff81
# define ws80 0xffffffffffff8000
# define ws81 0xffffffffffff8001
# define wi80 0xffffffff80000000
# define wi81 0xffffffff80000001
#endif
call_w(__LINE__, _c, c7f, c7f)
call_w(__LINE__, _c, c80, wc80)
call_w(__LINE__, _c, c81, wc81)
call_w(__LINE__, _uc, c7f, c7f)
call_w(__LINE__, _uc, c80, c80)
call_w(__LINE__, _uc, c81, c81)
call_w(__LINE__, _s, s7f, s7f)
call_w(__LINE__, _s, s80, ws80)
call_w(__LINE__, _s, s81, ws81)
call_w(__LINE__, _us, s7f, s7f)
call_w(__LINE__, _us, s80, s80)
call_w(__LINE__, _us, s81, s81)
#if __WORDSIZE == 64
call_w(__LINE__, _i, i7f, i7f)
call_w(__LINE__, _i, i80, wi80)
call_w(__LINE__, _i, i81, wi81)
call_w(__LINE__, _ui, i7f, i7f)
call_w(__LINE__, _ui, i80, i80)
call_w(__LINE__, _ui, i81, i81)
#endif
call_wf(__LINE__, _f, c7f, f7f)
call_wf(__LINE__, _f, wc80, f80)
call_wf(__LINE__, _f, wc81, f81)
call_wf(__LINE__, _d, c7f, f7f)
call_wf(__LINE__, _d, wc80, f80)
call_wf(__LINE__, _d, wc81, f81)
call_fi(__LINE__, _f, _c, c7f, f7f)
call_fi(__LINE__, _f, _c, c80, f80)
call_fi(__LINE__, _f, _uc, c7f, f7f)
call_fi(__LINE__, _f, _uc, c80, uf80)
call_fi(__LINE__, _f, _s, c7f, f7f)
call_fi(__LINE__, _f, _s, c80, uf80)
call_fi(__LINE__, _f, _us, c7f, f7f)
call_fi(__LINE__, _f, _us, c80, uf80)
call_fi(__LINE__, _f, _i, c7f, f7f)
call_fi(__LINE__, _f, _i, c80, uf80)
#if __WORDSIZE == 64
call_fi(__LINE__, _f, _ui, c7f, f7f)
call_fi(__LINE__, _f, _ui, c80, uf80)
call_fi(__LINE__, _f, _l, c7f, f7f)
call_fi(__LINE__, _f, _l, c80, uf80)
#endif
call_fi(__LINE__, _d, _c, c7f, f7f)
call_fi(__LINE__, _d, _c, c80, f80)
call_fi(__LINE__, _d, _uc, c7f, f7f)
call_fi(__LINE__, _d, _uc, c80, uf80)
call_fi(__LINE__, _d, _s, c7f, f7f)
call_fi(__LINE__, _d, _s, c80, uf80)
call_fi(__LINE__, _d, _us, c7f, f7f)
call_fi(__LINE__, _d, _us, c80, uf80)
call_fi(__LINE__, _d, _i, c7f, f7f)
call_fi(__LINE__, _d, _i, c80, uf80)
#if __WORDSIZE == 64
call_fi(__LINE__, _d, _ui, c7f, f7f)
call_fi(__LINE__, _d, _ui, c80, uf80)
call_fi(__LINE__, _d, _l, c7f, f7f)
call_fi(__LINE__, _d, _l, c80, uf80)
#endif
call_f(__LINE__, _f, f7f, f7f)
call_f(__LINE__, _d, f7f, f7f)
call_ff(__LINE__, _f, _d, f80, f80)
call_ff(__LINE__, _d, _f, f81, f81)
movi %r0 forward
callr %r0
calli iforward
ret
epilog
name backward
backward:
prolog
prepare
pushargi bstr
finishi @puts
ret
epilog
name forward
forward:
prolog
prepare
pushargi fstr
finishi @puts
movi %r0 backward
callr %r0
ret
epilog
name iforward
iforward:
prolog
prepare
pushargi fstr
finishi @puts
calli backward
ret
epilog
+538
View File
@@ -0,0 +1,538 @@
#include <lightning.h>
#include <stdio.h>
/* Simple test for arguments handling, that also shows how to use
* arguments to store values.
* Register arguments, if available, are very fast, but are also
* very volatile on some ports, because some ports will do C calls
* to implement division, remainder, sometimes multiplication, or
* some float operations.
* Arguments in registers should be fetched in the prolog of the
* function, and if they must be saved, they should be saved in
* the prolog.
* The predicate macro "jit_arg_register_p(arg)" allows knowing if
* an argument lives in a register, where it is known for being a very
* fast to read/write temporary storage.
*/
#define W jit_word_t
#define F jit_float32_t
#define D jit_float64_t
jit_state_t *_jit;
void
cw(W a1, W a2, W a3, W a4, W a5, W a6, W a7, W a8,
W a9, W a10, W a11, W a12, W a13, W a14, W a15, W a16)
{
if ( a1 != 1 || a2 != 2 || a3 != 3 || a4 != 4 ||
a5 != 5 || a6 != 6 || a7 != 7 || a8 != 8 ||
a9 != 9 || a10 != 10 || a11 != 11 || a12 != 12 ||
a13 != 13 || a14 != 14 || a15 != 15 || a16 != 16)
abort();
}
void
cf(F a1, F a2, F a3, F a4, F a5, F a6, F a7, F a8,
F a9, F a10, F a11, F a12, F a13, F a14, F a15, F a16)
{
if ( a1 != 1 || a2 != 2 || a3 != 3 || a4 != 4 ||
a5 != 5 || a6 != 6 || a7 != 7 || a8 != 8 ||
a9 != 9 || a10 != 10 || a11 != 11 || a12 != 12 ||
a13 != 13 || a14 != 14 || a15 != 15 || a16 != 16)
abort();
}
void
cd(D a1, D a2, D a3, D a4, D a5, D a6, D a7, D a8,
D a9, D a10, D a11, D a12, D a13, D a14, D a15, D a16)
{
if ( a1 != 1 || a2 != 2 || a3 != 3 || a4 != 4 ||
a5 != 5 || a6 != 6 || a7 != 7 || a8 != 8 ||
a9 != 9 || a10 != 10 || a11 != 11 || a12 != 12 ||
a13 != 13 || a14 != 14 || a15 != 15 || a16 != 16)
abort();
}
int
main(int argc, char *argv[])
{
void (*code)(void);
jit_node_t *jmp, *pass;
jit_node_t *jw, *jf, *jd;
jit_int32_t s1, s2, s3, s4, s5, s6, s7, s8,
s9, s10, s11, s12, s13, s14, s15, s16;
jit_node_t *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8,
*a9, *a10, *a11, *a12, *a13, *a14, *a15, *a16;
init_jit(argv[0]);
_jit = jit_new_state();
/* jump to "main" label */
jmp = jit_jmpi();
/* Create jit function that
* o Receives 16 word arguments
* o Save in the stack any register argument. Also force register
* arguments to be clobbered to properly make the test
* o Calls a C function that receives 16 word arguments, with
* values different from the ones received by this function
* o Reload from stack any register argument
* o Validated all arguments were not modified in the known
* cases it could have been clobbered
*/
jw = jit_label();
jit_name("jw");
jit_note(__FILE__, __LINE__);
jit_prolog();
a1 = jit_arg();
a2 = jit_arg();
a3 = jit_arg();
a4 = jit_arg();
a5 = jit_arg();
a6 = jit_arg();
a7 = jit_arg();
a8 = jit_arg();
a9 = jit_arg();
a10 = jit_arg();
a11 = jit_arg();
a12 = jit_arg();
a13 = jit_arg();
a14 = jit_arg();
a15 = jit_arg();
a16 = jit_arg();
#define SAVE_ARG(N) \
do { \
if (jit_arg_register_p(a##N)) { \
s##N = jit_allocai(sizeof(W)); \
jit_getarg(JIT_R0, a##N); \
jit_stxi(s##N, JIT_FP, JIT_R0); \
jit_putargi(-1, a##N); \
} \
} while (0)
SAVE_ARG(1);
SAVE_ARG(2);
SAVE_ARG(3);
SAVE_ARG(4);
SAVE_ARG(5);
SAVE_ARG(6);
SAVE_ARG(7);
SAVE_ARG(8);
SAVE_ARG(9);
SAVE_ARG(10);
SAVE_ARG(11);
SAVE_ARG(12);
SAVE_ARG(13);
SAVE_ARG(14);
SAVE_ARG(15);
SAVE_ARG(16);
#undef SAVE_ARG
jit_prepare();
{
jit_pushargi(1);
jit_pushargi(2);
jit_pushargi(3);
jit_pushargi(4);
jit_pushargi(5);
jit_pushargi(6);
jit_pushargi(7);
jit_pushargi(8);
jit_pushargi(9);
jit_pushargi(10);
jit_pushargi(11);
jit_pushargi(12);
jit_pushargi(13);
jit_pushargi(14);
jit_pushargi(15);
jit_pushargi(16);
}
jit_finishi(cw);
#define LOAD_ARG(N) \
do { \
if (jit_arg_register_p(a##N)) { \
jit_ldxi(JIT_R0, JIT_FP, s##N); \
jit_putargr(JIT_R0, a##N); \
} \
} while (0)
LOAD_ARG(1);
LOAD_ARG(2);
LOAD_ARG(3);
LOAD_ARG(4);
LOAD_ARG(5);
LOAD_ARG(6);
LOAD_ARG(7);
LOAD_ARG(8);
LOAD_ARG(9);
LOAD_ARG(10);
LOAD_ARG(11);
LOAD_ARG(12);
LOAD_ARG(13);
LOAD_ARG(14);
LOAD_ARG(15);
LOAD_ARG(16);
#undef LOAD_ARG
pass = jit_forward();
#define CHECK_ARG(N) \
do { \
jit_getarg(JIT_R0, a##N); \
jit_patch_at(jit_beqi(JIT_R0, 17 - N), pass); \
} while (0)
CHECK_ARG(1);
CHECK_ARG(2);
CHECK_ARG(3);
CHECK_ARG(4);
CHECK_ARG(5);
CHECK_ARG(6);
CHECK_ARG(7);
CHECK_ARG(8);
CHECK_ARG(9);
CHECK_ARG(10);
CHECK_ARG(11);
CHECK_ARG(12);
CHECK_ARG(13);
CHECK_ARG(14);
CHECK_ARG(15);
CHECK_ARG(16);
#undef CHECK_ARG
jit_calli(abort);
jit_link(pass);
jit_ret();
jit_epilog();
/* Create jit function that
* o Receives 16 float arguments
* o Save in the stack any register argument. Also force register
* arguments to be clobbered to properly make the test
* o Calls a C function that receives 16 float arguments, with
* values different from the ones received by this function
* o Reload from stack any register argument
* o Validated all arguments were not modified in the known
* cases it could have been clobbered
*/
jf = jit_label();
jit_name("jf");
jit_note(__FILE__, __LINE__);
jit_prolog();
a1 = jit_arg_f();
a2 = jit_arg_f();
a3 = jit_arg_f();
a4 = jit_arg_f();
a5 = jit_arg_f();
a6 = jit_arg_f();
a7 = jit_arg_f();
a8 = jit_arg_f();
a9 = jit_arg_f();
a10 = jit_arg_f();
a11 = jit_arg_f();
a12 = jit_arg_f();
a13 = jit_arg_f();
a14 = jit_arg_f();
a15 = jit_arg_f();
a16 = jit_arg_f();
#define SAVE_ARG(N) \
do { \
if (jit_arg_register_p(a##N)) { \
s##N = jit_allocai(sizeof(F)); \
jit_getarg_f(JIT_F0, a##N); \
jit_stxi_f(s##N, JIT_FP, JIT_F0); \
jit_putargi_f(-1, a##N); \
} \
} while (0)
SAVE_ARG(1);
SAVE_ARG(2);
SAVE_ARG(3);
SAVE_ARG(4);
SAVE_ARG(5);
SAVE_ARG(6);
SAVE_ARG(7);
SAVE_ARG(8);
SAVE_ARG(9);
SAVE_ARG(10);
SAVE_ARG(11);
SAVE_ARG(12);
SAVE_ARG(13);
SAVE_ARG(14);
SAVE_ARG(15);
SAVE_ARG(16);
#undef SAVE_ARG
jit_prepare();
{
jit_pushargi_f(1);
jit_pushargi_f(2);
jit_pushargi_f(3);
jit_pushargi_f(4);
jit_pushargi_f(5);
jit_pushargi_f(6);
jit_pushargi_f(7);
jit_pushargi_f(8);
jit_pushargi_f(9);
jit_pushargi_f(10);
jit_pushargi_f(11);
jit_pushargi_f(12);
jit_pushargi_f(13);
jit_pushargi_f(14);
jit_pushargi_f(15);
jit_pushargi_f(16);
}
jit_finishi(cf);
#define LOAD_ARG(N) \
do { \
if (jit_arg_register_p(a##N)) { \
jit_ldxi_f(JIT_F0, JIT_FP, s##N); \
jit_putargr_f(JIT_F0, a##N); \
} \
} while (0)
LOAD_ARG(1);
LOAD_ARG(2);
LOAD_ARG(3);
LOAD_ARG(4);
LOAD_ARG(5);
LOAD_ARG(6);
LOAD_ARG(7);
LOAD_ARG(8);
LOAD_ARG(9);
LOAD_ARG(10);
LOAD_ARG(11);
LOAD_ARG(12);
LOAD_ARG(13);
LOAD_ARG(14);
LOAD_ARG(15);
LOAD_ARG(16);
#undef LOAD_ARG
pass = jit_forward();
#define CHECK_ARG(N) \
do { \
jit_getarg_f(JIT_F0, a##N); \
jit_patch_at(jit_beqi_f(JIT_F0, 17 - N), pass); \
} while (0)
CHECK_ARG(1);
CHECK_ARG(2);
CHECK_ARG(3);
CHECK_ARG(4);
CHECK_ARG(5);
CHECK_ARG(6);
CHECK_ARG(7);
CHECK_ARG(8);
CHECK_ARG(9);
CHECK_ARG(10);
CHECK_ARG(11);
CHECK_ARG(12);
CHECK_ARG(13);
CHECK_ARG(14);
CHECK_ARG(15);
CHECK_ARG(16);
#undef CHECK_ARG
jit_calli(abort);
jit_link(pass);
jit_ret();
jit_epilog();
/* Create jit function that
* o Receives 16 double arguments
* o Save in the stack any register argument. Also force register
* arguments to be clobbered to properly make the test
* o Calls a C function that receives 16 double arguments, with
* values different from the ones received by this function
* o Reload from stack any register argument
* o Validated all arguments were not modified in the known
* cases it could have been clobbered
*/
jd = jit_label();
jit_name("jd");
jit_note(__FILE__, __LINE__);
jit_prolog();
a1 = jit_arg_d();
a2 = jit_arg_d();
a3 = jit_arg_d();
a4 = jit_arg_d();
a5 = jit_arg_d();
a6 = jit_arg_d();
a7 = jit_arg_d();
a8 = jit_arg_d();
a9 = jit_arg_d();
a10 = jit_arg_d();
a11 = jit_arg_d();
a12 = jit_arg_d();
a13 = jit_arg_d();
a14 = jit_arg_d();
a15 = jit_arg_d();
a16 = jit_arg_d();
#define SAVE_ARG(N) \
do { \
if (jit_arg_register_p(a##N)) { \
s##N = jit_allocai(sizeof(D)); \
jit_getarg_d(JIT_F0, a##N); \
jit_stxi_d(s##N, JIT_FP, JIT_F0); \
jit_putargi_d(-1, a##N); \
} \
} while (0)
SAVE_ARG(1);
SAVE_ARG(2);
SAVE_ARG(3);
SAVE_ARG(4);
SAVE_ARG(5);
SAVE_ARG(6);
SAVE_ARG(7);
SAVE_ARG(8);
SAVE_ARG(9);
SAVE_ARG(10);
SAVE_ARG(11);
SAVE_ARG(12);
SAVE_ARG(13);
SAVE_ARG(14);
SAVE_ARG(15);
SAVE_ARG(16);
#undef SAVE_ARG
jit_prepare();
{
jit_pushargi_d(1);
jit_pushargi_d(2);
jit_pushargi_d(3);
jit_pushargi_d(4);
jit_pushargi_d(5);
jit_pushargi_d(6);
jit_pushargi_d(7);
jit_pushargi_d(8);
jit_pushargi_d(9);
jit_pushargi_d(10);
jit_pushargi_d(11);
jit_pushargi_d(12);
jit_pushargi_d(13);
jit_pushargi_d(14);
jit_pushargi_d(15);
jit_pushargi_d(16);
}
jit_finishi(cd);
#define LOAD_ARG(N) \
do { \
if (jit_arg_register_p(a##N)) { \
jit_ldxi_d(JIT_F0, JIT_FP, s##N); \
jit_putargr_d(JIT_F0, a##N); \
} \
} while (0)
LOAD_ARG(1);
LOAD_ARG(2);
LOAD_ARG(3);
LOAD_ARG(4);
LOAD_ARG(5);
LOAD_ARG(6);
LOAD_ARG(7);
LOAD_ARG(8);
LOAD_ARG(9);
LOAD_ARG(10);
LOAD_ARG(11);
LOAD_ARG(12);
LOAD_ARG(13);
LOAD_ARG(14);
LOAD_ARG(15);
LOAD_ARG(16);
#undef LOAD_ARG
pass = jit_forward();
#define CHECK_ARG(N) \
do { \
jit_getarg_d(JIT_F0, a##N); \
jit_patch_at(jit_beqi_d(JIT_F0, 17 - N), pass); \
} while (0)
CHECK_ARG(1);
CHECK_ARG(2);
CHECK_ARG(3);
CHECK_ARG(4);
CHECK_ARG(5);
CHECK_ARG(6);
CHECK_ARG(7);
CHECK_ARG(8);
CHECK_ARG(9);
CHECK_ARG(10);
CHECK_ARG(11);
CHECK_ARG(12);
CHECK_ARG(13);
CHECK_ARG(14);
CHECK_ARG(15);
CHECK_ARG(16);
#undef CHECK_ARG
jit_calli(abort);
jit_link(pass);
jit_ret();
jit_epilog();
/* Create a jit function that calls the 3 previous ones.
* o First call the function that receives 16 word arguments
* o Then call the function that receives 16 float arguments
* o Finally call the function that receives 16 double arguments
*/
jit_patch(jmp);
jit_name("main");
jit_note(__FILE__, __LINE__);
jit_prolog();
jit_prepare();
{
jit_pushargi(16);
jit_pushargi(15);
jit_pushargi(14);
jit_pushargi(13);
jit_pushargi(12);
jit_pushargi(11);
jit_pushargi(10);
jit_pushargi(9);
jit_pushargi(8);
jit_pushargi(7);
jit_pushargi(6);
jit_pushargi(5);
jit_pushargi(4);
jit_pushargi(3);
jit_pushargi(2);
jit_pushargi(1);
}
jit_patch_at(jit_finishi(NULL), jw);
jit_prepare();
{
jit_pushargi_f(16);
jit_pushargi_f(15);
jit_pushargi_f(14);
jit_pushargi_f(13);
jit_pushargi_f(12);
jit_pushargi_f(11);
jit_pushargi_f(10);
jit_pushargi_f(9);
jit_pushargi_f(8);
jit_pushargi_f(7);
jit_pushargi_f(6);
jit_pushargi_f(5);
jit_pushargi_f(4);
jit_pushargi_f(3);
jit_pushargi_f(2);
jit_pushargi_f(1);
}
jit_patch_at(jit_finishi(NULL), jf);
jit_prepare();
{
jit_pushargi_d(16);
jit_pushargi_d(15);
jit_pushargi_d(14);
jit_pushargi_d(13);
jit_pushargi_d(12);
jit_pushargi_d(11);
jit_pushargi_d(10);
jit_pushargi_d(9);
jit_pushargi_d(8);
jit_pushargi_d(7);
jit_pushargi_d(6);
jit_pushargi_d(5);
jit_pushargi_d(4);
jit_pushargi_d(3);
jit_pushargi_d(2);
jit_pushargi_d(1);
}
jit_patch_at(jit_finishi(NULL), jd);
jit_ret();
jit_epilog();
code = jit_emit();
jit_clear_state();
(*code)();
jit_destroy_state();
finish_jit();
return (0);
}
+1
View File
@@ -0,0 +1 @@
ok
+186
View File
@@ -0,0 +1,186 @@
#define ix0 0
#define lx0 0
#define ix1 1
#define lx1 1
#define ix2 2
#define lx2 2
#define ix4 4
#define lx4 4
#if __WORDSIZE == 32
# define ix7fe 0x7ffffffe
# define ix7f 0x7fffffff
# define ix80 0x80000000
# define iff 0xffffffff
# define ife 0xfffffffe
# define ifd 0xfffffffd
# define ifc 0xfffffffc
#else
# define ix7fe 0x7ffffffffffffffe
# define ix7f 0x7fffffffffffffff
# define ix80 0x8000000000000000
# define iff 0xffffffffffffffff
# define ife 0xfffffffffffffffe
# define ifd 0xfffffffffffffffd
# define ifc 0xfffffffffffffffc
#endif
/* check jumps are taken and result value is correct */
#define bopr_t(l, u, op, r0, r1, il, ir, iv) \
movi %r0 il \
movi %r1 ir \
b##op##r##u op##u##r##l##r0##r1 %r0 %r1 \
/* validate did jump */ \
movi %r0 0x5a5a5a5a \
op##u##r##l##r0##r1: \
beqi op##u##r##l##ok##r0##r1 %r0 iv \
calli @abort \
op##u##r##l##ok##r0##r1:
#define bopi_t(l, u, op, r0, il, ir, iv) \
movi %r0 il \
b##op##i##u op##u##i##l##r0##r1 %r0 ir \
/* validate did jump */ \
movi %r0 0x5a5a5a5a \
op##u##i##l##r0##r1: \
beqi op##u##i##l##ok##r0##r1 %r0 iv \
calli @abort \
op##u##i##l##ok##r0##r1:
#define bopr_f(l, u, op, r0, r1, il, ir, iv) \
movi %r0 il \
movi %r1 ir \
b##op##r##u op##u##r##l##r0##r1 %r0 %r1 \
beqi op##u##r##l##ok##r0##r1 %r0 iv \
op##u##r##l##r0##r1: \
calli @abort \
op##u##r##l##ok##r0##r1:
#define bopi_f(l, u, op, r0, il, ir, iv) \
movi %r0 il \
b##op##i##u op##u##i##l##r0##r1 %r0 ir \
beqi op##u##i##l##ok##r0##r1 %r0 iv \
op##u##i##l##r0##r1: \
calli @abort \
op##u##i##l##ok##r0##r1:
#define ccop(cc, l, u, op, r0, r1, il, ir, iv) \
bopr##cc(l, u, op, r0, r1, i##il, i##ir, i##iv) \
bopi##cc(l, u, op, r0, i##il, i##ir, i##iv)
#define tadd(l, u, r0, r1, il, ir, iv) \
ccop(_t, l, u, oadd, r0, r1, il, ir, iv) \
ccop(_f, l, u, xadd, r0, r1, il, ir, iv)
#define fadd(l, u, r0, r1, il, ir, iv) \
ccop(_f, l, u, oadd, r0, r1, il, ir, iv) \
ccop(_t, l, u, xadd, r0, r1, il, ir, iv)
#define tsub(l, u, r0, r1, il, ir, iv) \
ccop(_t, l, u, osub, r0, r1, il, ir, iv) \
ccop(_f, l, u, xsub, r0, r1, il, ir, iv)
#define fsub(l, u, r0, r1, il, ir, iv) \
ccop(_f, l, u, osub, r0, r1, il, ir, iv) \
ccop(_t, l, u, xsub, r0, r1, il, ir, iv)
#define xopr6(l,op,r0,r1,r2,r3,r4,r5,llo,lhi,rlo,rhi,vlo,vhi) \
movi %r1 llo \
movi %r2 lhi \
movi %r4 rlo \
movi %r5 rhi \
op##cr %r0 %r1 %r4 \
op##xr %r3 %r2 %r5 \
beqi op##l##L##r0##r1##r2##r3##r4##r5 %r0 vlo \
calli @abort \
op##l##L##r0##r1##r2##r3##r4##r5: \
beqi op##l##H##r0##r1##r2##r3##r4##r5 %r3 vhi \
calli @abort \
op##l##H##r0##r1##r2##r3##r4##r5:
#define xopr4_(l,op,r0,r1,r2,r3,llo,lhi,rlo,rhi,vlo,vhi) \
movi %r0 llo \
movi %r1 lhi \
movi %r2 rlo \
movi %r3 rhi \
op##cr %r0 %r0 %r2 \
op##xr %r1 %r1 %r3 \
beqi op##l##L_##r0##r1##r2##r3 %r0 vlo \
calli @abort \
op##l##L_##r0##r1##r2##r3: \
beqi op##l##H_##r0##r1##r2##r3 %r1 vhi \
calli @abort \
op##l##H_##r0##r1##r2##r3:
#define xopr_4(l,op,r0,r1,r2,r3,llo,lhi,rlo,rhi,vlo,vhi) \
movi %r0 rlo \
movi %r1 rhi \
movi %r2 llo \
movi %r3 lhi \
op##cr %r0 %r2 %r0 \
op##xr %r1 %r3 %r1 \
beqi op##l##_L##r0##r1##r2##r3 %r0 vlo \
calli @abort \
op##l##_L##r0##r1##r2##r3: \
beqi op##l##_H##r0##r1##r2##r3 %r1 vhi \
calli @abort \
op##l##_H##r0##r1##r2##r3:
#define xaddr(l,llo,lhi,rlo,rhi,vlo,vhi) \
xopr6(l,add,r0,r1,r2,v0,v1,v2,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi) \
xopr4_(l,add,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi) \
xopr_4(l,add,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)
#define xsubr(l,llo,lhi,rlo,rhi,vlo,vhi) \
xopr6(l,sub,r0,r1,r2,v0,v1,v2,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi) \
xopr4_(l,sub,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi) \
xopr_4(l,sub,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)
.data 16
ok:
.c "ok\n"
.code
prolog
tadd(__LINE__, , r0, r1, x7f, x1, x80)
fadd(__LINE__, , r0, r1, x7fe, x1, x7f)
tsub(__LINE__, , r0, r1, x80, x1, x7f)
fsub(__LINE__, , r0, r1, x7f, x1, x7fe)
tadd(__LINE__, _u, r0, r1, ff, x1, x0)
fadd(__LINE__, _u, r0, r1, x7f, x1, x80)
tsub(__LINE__, _u, r0, r1, x0, x1, ff)
fsub(__LINE__, _u, r0, r1, x80, x1, x7f)
/* 0xffffffffffffffff + 1 = 0x10000000000000000 */
xaddr(__LINE__, ff, ff, x1, x0, x0, x0)
/* 1 + 0xffffffffffffffff = 0x10000000000000000 */
xaddr(__LINE__, x1, x0, ff, ff, x0, x0)
/* 0xfffffffeffffffff + 1 = 0xffffffff00000000 */
xaddr(__LINE__, ff, fe, x1, x0, x0, ff)
/* 1 + 0xfffffffeffffffff = 0xffffffff00000000 */
xaddr(__LINE__, x1, x0, ff, fe, x0, ff)
/* 0xfffffffefffffffe + 2 = 0xffffffff00000000 */
xaddr(__LINE__, fe, fe, x2, x0, x0, ff)
/* 2 + 0xfffffffefffffffe = 0xffffffff00000000 */
xaddr(__LINE__, x2, x0, fe, fe, x0, ff)
/* 0xffffffffffffffff - 1 = 0xfffffffffffffffe */
xsubr(__LINE__, ff, ff, x1, x0, fe, ff)
/* 1 - 0xffffffffffffffff = -0xfffffffffffffffe */
xsubr(__LINE__, x1, x0, ff, ff, x2, x0)
/* 0xfffffffeffffffff - 1 = 0xfffffffefffffffe */
xsubr(__LINE__, ff, fe, x1, x0, fe, fe)
/* 1 - 0xfffffffeffffffff = -0xfffffffefffffffe */
xsubr(__LINE__, x1, x0, ff, fe, x2, x1)
/* 0xfffffffefffffffe - 2 = 0xfffffffefffffffc */
xsubr(__LINE__, fe, fe, x2, x0, fc, fe)
/* 2 + 0xfffffffefffffffe = -0xfffffffefffffffc */
xsubr(__LINE__, x2, x0, fe, fe, x4, x1)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+903
View File
@@ -0,0 +1,903 @@
#include <lightning.h>
#include <stdio.h>
#define _w0 0
#define _w1 1
#define _w2 (_w1-2)
#define _w3 (_w2-3)
#define _w4 (_w3-4)
#define _w5 (_w4-5)
#define _w6 (_w5-6)
#define _w7 (_w6-7)
#define _w8 (_w7-8)
#define _w9 (_w8-9)
#define _w10 (_w9-10)
#define _w11 (_w10-11)
#define _w12 (_w11-12)
#define _w13 (_w12-13)
#define _w14 (_w13-14)
#define _w15 (_w14-15)
#define _c0 _w0
#define _c1 _w1
#define _c2 _w2
#define _c3 _w3
#define _c4 _w4
#define _c5 _w5
#define _c6 _w6
#define _c7 _w7
#define _c8 _w8
#define _c9 _w9
#define _c10 _w10
#define _c11 _w11
#define _c12 _w12
#define _c13 _w13
#define _c14 _w14
#define _c15 _w15
#define _uc0 (_w0&0xff)
#define _uc1 (_w1&0xff)
#define _uc2 (_w2&0xff)
#define _uc3 (_w3&0xff)
#define _uc4 (_w4&0xff)
#define _uc5 (_w5&0xff)
#define _uc6 (_w6&0xff)
#define _uc7 (_w7&0xff)
#define _uc8 (_w8&0xff)
#define _uc9 (_w9&0xff)
#define _uc10 (_w10&0xff)
#define _uc11 (_w11&0xff)
#define _uc12 (_w12&0xff)
#define _uc13 (_w13&0xff)
#define _uc14 (_w14&0xff)
#define _uc15 (_w15&0xff)
#define _s0 _w0
#define _s1 _w1
#define _s2 _w2
#define _s3 _w3
#define _s4 _w4
#define _s5 _w5
#define _s6 _w6
#define _s7 _w7
#define _s8 _w8
#define _s9 _w9
#define _s10 _w10
#define _s11 _w11
#define _s12 _w12
#define _s13 _w13
#define _s14 _w14
#define _s15 _w15
#define _us0 (_w0&0xffff)
#define _us1 (_w1&0xffff)
#define _us2 (_w2&0xffff)
#define _us3 (_w3&0xffff)
#define _us4 (_w4&0xffff)
#define _us5 (_w5&0xffff)
#define _us6 (_w6&0xffff)
#define _us7 (_w7&0xffff)
#define _us8 (_w8&0xffff)
#define _us9 (_w9&0xffff)
#define _us10 (_w10&0xffff)
#define _us11 (_w11&0xffff)
#define _us12 (_w12&0xffff)
#define _us13 (_w13&0xffff)
#define _us14 (_w14&0xffff)
#define _us15 (_w15&0xffff)
#define _i0 _w0
#define _i1 _w1
#define _i2 _w2
#define _i3 _w3
#define _i4 _w4
#define _i5 _w5
#define _i6 _w6
#define _i7 _w7
#define _i8 _w8
#define _i9 _w9
#define _i10 _w10
#define _i11 _w11
#define _i12 _w12
#define _i13 _w13
#define _i14 _w14
#define _i15 _w15
#if __WORDSIZE == 64
# define _ui0 (_w0&0xffffffff)
# define _ui1 (_w1&0xffffffff)
# define _ui2 (_w2&0xffffffff)
# define _ui3 (_w3&0xffffffff)
# define _ui4 (_w4&0xffffffff)
# define _ui5 (_w5&0xffffffff)
# define _ui6 (_w6&0xffffffff)
# define _ui7 (_w7&0xffffffff)
# define _ui8 (_w8&0xffffffff)
# define _ui9 (_w9&0xffffffff)
# define _ui10 (_w10&0xffffffff)
# define _ui11 (_w11&0xffffffff)
# define _ui12 (_w12&0xffffffff)
# define _ui13 (_w13&0xffffffff)
# define _ui14 (_w14&0xffffffff)
# define _ui15 (_w15&0xffffffff)
# define _l0 _w0
# define _l1 _w1
# define _l2 _w2
# define _l3 _w3
# define _l4 _w4
# define _l5 _w5
# define _l6 _w6
# define _l7 _w7
# define _l8 _w8
# define _l9 _w9
# define _l10 _w10
# define _l11 _w11
# define _l12 _w12
# define _l13 _w13
# define _l14 _w14
# define _l15 _w15
#endif
/*
* Types
*/
typedef signed char _c;
typedef unsigned char _uc;
typedef signed short _s;
typedef unsigned short _us;
typedef signed int _i;
#if __WORDSIZE == 64
typedef unsigned int _ui;
typedef jit_word_t _l;
#endif
typedef float _f;
typedef double _d;
#define prt0(T) T C##T##0(void);
#define prt1(T) prt0(T) \
T C##T##1(T);
#define prt2(T) prt1(T) \
T C##T##2(T,T);
#define prt3(T) prt2(T) \
T C##T##3(T,T,T);
#define prt4(T) prt3(T) \
T C##T##4(T,T,T,T);
#define prt5(T) prt4(T) \
T C##T##5(T,T,T,T,T);
#define prt6(T) prt5(T) \
T C##T##6(T,T,T,T,T,T);
#define prt7(T) prt6(T) \
T C##T##7(T,T,T,T,T,T,T);
#define prt8(T) prt7(T) \
T C##T##8(T,T,T,T,T,T,T,T);
#define prt9(T) prt8(T) \
T C##T##9(T,T,T,T,T,T,T,T,T);
#define prt10(T) prt9(T) \
T C##T##10(T,T,T,T,T,T,T,T,T,T);
#define prt11(T) prt10(T) \
T C##T##11(T,T,T,T,T,T,T,T,T,T,T);
#define prt12(T) prt11(T) \
T C##T##12(T,T,T,T,T,T,T,T,T,T,T,T);
#define prt13(T) prt12(T) \
T C##T##13(T,T,T,T,T,T,T,T,T,T,T,T,T);
#define prt14(T) prt13(T) \
T C##T##14(T,T,T,T,T,T,T,T,T,T,T,T,T,T);
#define prt15(T) prt14(T) \
T C##T##15(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T);
#define prt(T) prt15(T)
prt(_c)
prt(_uc)
prt(_s)
prt(_us)
prt(_i)
#if __WORDSIZE == 64
prt(_ui)
prt(_l)
#endif
prt(_f)
prt(_d)
#undef prt
#undef prt15
#undef prt14
#undef prt13
#undef prt12
#undef prt11
#undef prt10
#undef prt9
#undef prt8
#undef prt7
#undef prt6
#undef prt5
#undef prt4
#undef prt3
#undef prt2
#undef prt1
#undef prt0
#define prtn(N,T) T J##T##n(void);
#define prt0(T) prtn(0,T)
#define prt1(T) prt0(T) prtn(1,T)
#define prt2(T) prt1(T) prtn(2,T)
#define prt3(T) prt2(T) prtn(3,T)
#define prt4(T) prt3(T) prtn(4,T)
#define prt5(T) prt4(T) prtn(5,T)
#define prt6(T) prt5(T) prtn(6,T)
#define prt7(T) prt6(T) prtn(7,T)
#define prt8(T) prt7(T) prtn(8,T)
#define prt9(T) prt8(T) prtn(9,T)
#define prt10(T) prt9(T) prtn(10,T)
#define prt11(T) prt10(T) prtn(11,T)
#define prt12(T) prt11(T) prtn(12,T)
#define prt13(T) prt12(T) prtn(13,T)
#define prt14(T) prt13(T) prtn(14,T)
#define prt15(T) prt14(T) prtn(15,T)
#define prt(T) prt15(T)
prt(_c)
prt(_uc)
prt(_s)
prt(_us)
prt(_i)
#if __WORDSIZE == 64
prt(_ui)
prt(_l)
#endif
prt(_f)
prt(_d)
#undef prt
#undef prt15
#undef prt14
#undef prt13
#undef prt12
#undef prt11
#undef prt10
#undef prt9
#undef prt8
#undef prt7
#undef prt6
#undef prt5
#undef prt4
#undef prt3
#undef prt2
#undef prt1
#undef prt0
#undef prtn
/*
* Initialization
*/
#define dat0(T) T (*j##T##0)(void); \
jit_node_t *n##T##0;
#define dat1(T) dat0(T) \
T (*j##T##1)(T); \
jit_node_t *n##T##1;
#define dat2(T) dat1(T) \
T (*j##T##2)(T,T); \
jit_node_t *n##T##2;
#define dat3(T) dat2(T) \
T (*j##T##3)(T,T,T); \
jit_node_t *n##T##3;
#define dat4(T) dat3(T) \
T (*j##T##4)(T,T,T,T); \
jit_node_t *n##T##4;
#define dat5(T) dat4(T) \
T (*j##T##5)(T,T,T,T,T); \
jit_node_t *n##T##5;
#define dat6(T) dat5(T) \
T (*j##T##6)(T,T,T,T,T,T); \
jit_node_t *n##T##6;
#define dat7(T) dat6(T) \
T (*j##T##7)(T,T,T,T,T,T,T); \
jit_node_t *n##T##7;
#define dat8(T) dat7(T) \
T (*j##T##8)(T,T,T,T,T,T,T,T); \
jit_node_t *n##T##8;
#define dat9(T) dat8(T) \
T (*j##T##9)(T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##9;
#define dat10(T) dat9(T) \
T (*j##T##10)(T,T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##10;
#define dat11(T) dat10(T) \
T (*j##T##11)(T,T,T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##11;
#define dat12(T) dat11(T) \
T (*j##T##12)(T,T,T,T,T,T,T,T,T,T,T,T); \
jit_node_t *n##T##12;
#define dat13(T) dat12(T) \
T (*j##T##13)(T,T,T,T,T,T,T,T,T,T,T,T,T);\
jit_node_t *n##T##13;
#define dat14(T) dat13(T) \
T (*j##T##14)(T,T,T,T,T,T,T,T,T,T,T,T,T,T);\
jit_node_t *n##T##14;
#define dat15(T) dat14(T) \
T (*j##T##15)(T,T,T,T,T,T,T,T,T,T,T,T,T,T,T);\
jit_node_t *n##T##15;
#define dat(T) dat15(T)
dat(_c)
dat(_uc)
dat(_s)
dat(_us)
dat(_i)
#if __WORDSIZE == 64
dat(_ui)
dat(_l)
#endif
dat(_f)
dat(_d)
#undef dat
#undef dat15
#undef dat14
#undef dat13
#undef dat12
#undef dat11
#undef dat10
#undef dat9
#undef dat8
#undef dat7
#undef dat6
#undef dat5
#undef dat4
#undef dat3
#undef dat2
#undef dat1
#undef dat0
/*
* Implementation
*/
#define dcl0(T) \
T C##T##0(void) \
{ \
return (0); \
}
#define dcl1(T) \
dcl0(T) \
T C##T##1(T A) \
{ \
return (A); \
}
#define dcl2(T) \
dcl1(T) \
T C##T##2(T A,T B) \
{ \
return (A-B); \
}
#define dcl3(T) \
dcl2(T) \
T C##T##3(T A,T B,T C) \
{ \
return (A-B-C); \
}
#define dcl4(T) \
dcl3(T) \
T C##T##4(T A,T B,T C,T D) \
{ \
return (A-B-C-D); \
}
#define dcl5(T) \
dcl4(T) \
T C##T##5(T A,T B,T C,T D,T E) \
{ \
return (A-B-C-D-E); \
}
#define dcl6(T) \
dcl5(T) \
T C##T##6(T A,T B,T C,T D,T E,T F) \
{ \
return (A-B-C-D-E-F); \
}
#define dcl7(T) \
dcl6(T) \
T C##T##7(T A,T B,T C,T D,T E,T F,T G) \
{ \
return (A-B-C-D-E-F-G); \
}
#define dcl8(T) \
dcl7(T) \
T C##T##8(T A,T B,T C,T D,T E,T F,T G,T H) \
{ \
return (A-B-C-D-E-F-G-H); \
}
#define dcl9(T) \
dcl8(T) \
T C##T##9(T A,T B,T C,T D,T E,T F,T G,T H,T I) \
{ \
return (A-B-C-D-E-F-G-H-I); \
}
#define dcl10(T) \
dcl9(T) \
T C##T##10(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J) \
{ \
return (A-B-C-D-E-F-G-H-I-J); \
}
#define dcl11(T) \
dcl10(T) \
T C##T##11(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K); \
}
#define dcl12(T) \
dcl11(T) \
T C##T##12(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L); \
}
#define dcl13(T) \
dcl12(T) \
T C##T##13(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L,T M) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L-M); \
}
#define dcl14(T) \
dcl13(T) \
T C##T##14(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L,T M,T N) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L-M-N); \
}
#define dcl15(T) \
dcl14(T) \
T C##T##15(T A,T B,T C,T D,T E,T F,T G,T H,T I,T J,T K,T L,T M,T N,T O) \
{ \
return (A-B-C-D-E-F-G-H-I-J-K-L-M-N-O); \
}
#define dcl(T) dcl15(T)
dcl(_c)
dcl(_uc)
dcl(_s)
dcl(_us)
dcl(_i)
#if __WORDSIZE == 64
dcl(_ui)
dcl(_l)
#endif
dcl(_f)
dcl(_d)
#undef dcl
#undef dcl15
#undef dcl14
#undef dcl13
#undef dcl12
#undef dcl11
#undef dcl10
#undef dcl9
#undef dcl8
#undef dcl7
#undef dcl6
#undef dcl5
#undef dcl4
#undef dcl3
#undef dcl2
#undef dcl1
#undef dcl0
#define dcl0(T) \
T CJ##T##0(void) \
{ \
return ((*j##T##0)()); \
}
#define dcl1(T) \
dcl0(T) \
T CJ##T##1(void) \
{ \
return ((*j##T##1)(1)); \
}
#define dcl2(T) \
dcl1(T) \
T CJ##T##2(void) \
{ \
return ((*j##T##2)(1,2)); \
}
#define dcl3(T) \
dcl2(T) \
T CJ##T##3(void) \
{ \
return ((*j##T##3)(1,2,3)); \
}
#define dcl4(T) \
dcl3(T) \
T CJ##T##4(void) \
{ \
return ((*j##T##4)(1,2,3,4)); \
}
#define dcl5(T) \
dcl4(T) \
T CJ##T##5(void) \
{ \
return ((*j##T##5)(1,2,3,4,5)); \
}
#define dcl6(T) \
dcl5(T) \
T CJ##T##6(void) \
{ \
return ((*j##T##6)(1,2,3,4,5,6)); \
}
#define dcl7(T) \
dcl6(T) \
T CJ##T##7(void) \
{ \
return ((*j##T##7)(1,2,3,4,5,6,7)); \
}
#define dcl8(T) \
dcl7(T) \
T CJ##T##8(void) \
{ \
return ((*j##T##8)(1,2,3,4,5,6,7,8)); \
}
#define dcl9(T) \
dcl8(T) \
T CJ##T##9(void) \
{ \
return ((*j##T##9)(1,2,3,4,5,6,7,8,9)); \
}
#define dcl10(T) \
dcl9(T) \
T CJ##T##10(void) \
{ \
return ((*j##T##10)(1,2,3,4,5,6,7,8,9,10)); \
}
#define dcl11(T) \
dcl10(T) \
T CJ##T##11(void) \
{ \
return ((*j##T##11)(1,2,3,4,5,6,7,8,9,10,11)); \
}
#define dcl12(T) \
dcl11(T) \
T CJ##T##12(void) \
{ \
return ((*j##T##12)(1,2,3,4,5,6,7,8,9,10,11,12)); \
}
#define dcl13(T) \
dcl12(T) \
T CJ##T##13(void) \
{ \
return ((*j##T##13)(1,2,3,4,5,6,7,8,9,10,11,12,13)); \
}
#define dcl14(T) \
dcl13(T) \
T CJ##T##14(void) \
{ \
return ((*j##T##14)(1,2,3,4,5,6,7,8,9,10,11,12,13,14)); \
}
#define dcl15(T) \
dcl14(T) \
T CJ##T##15(void) \
{ \
return ((*j##T##15)(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)); \
}
#define dcl(t) dcl15(t)
dcl(_c)
dcl(_uc)
dcl(_s)
dcl(_us)
dcl(_i)
#if __WORDSIZE == 64
dcl(_ui)
dcl(_l)
#endif
dcl(_f)
dcl(_d)
#undef dcl
#undef dcl15
#undef dcl14
#undef dcl13
#undef dcl12
#undef dcl11
#undef dcl10
#undef dcl9
#undef dcl8
#undef dcl7
#undef dcl6
#undef dcl5
#undef dcl4
#undef dcl3
#undef dcl2
#undef dcl1
#undef dcl0
int
main(int argc, char *argv[])
{
jit_state_t *_jit;
jit_node_t *jmpi_main;
void (*function)(void);
jit_node_t *a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9;
jit_node_t *a10,*a11,*a12,*a13,*a14,*a15;
jit_node_t *jmp;
init_jit(argv[0]);
_jit = jit_new_state();
jmpi_main = jit_jmpi();
#define arg0(T) /**/
#define arg1(T) a1 = jit_arg##T();
#define arg2(T) arg1(T) a2 = jit_arg##T();
#define arg3(T) arg2(T) a3 = jit_arg##T();
#define arg4(T) arg3(T) a4 = jit_arg##T();
#define arg5(T) arg4(T) a5 = jit_arg##T();
#define arg6(T) arg5(T) a6 = jit_arg##T();
#define arg7(T) arg6(T) a7 = jit_arg##T();
#define arg8(T) arg7(T) a8 = jit_arg##T();
#define arg9(T) arg8(T) a9 = jit_arg##T();
#define arg10(T) arg9(T) a10 = jit_arg##T();
#define arg11(T) arg10(T) a11 = jit_arg##T();
#define arg12(T) arg11(T) a12 = jit_arg##T();
#define arg13(T) arg12(T) a13 = jit_arg##T();
#define arg14(T) arg13(T) a14 = jit_arg##T();
#define arg15(T) arg14(T) a15 = jit_arg##T();
#define get0(B,T,R) jit_movi##B(R##0,0);
#define get1(B,T,R) jit_getarg##B(R##0,a##1);
#define get2(B,T,R) \
get1(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##2); \
jit_subr##B(R##0, R##1, R##0);
#define get3(B,T,R) \
get2(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##3); \
jit_subr##B(R##0, R##1, R##0);
#define get4(B,T,R) \
get3(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##4); \
jit_subr##B(R##0, R##1, R##0);
#define get5(B,T,R) \
get4(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##5); \
jit_subr##B(R##0, R##1, R##0);
#define get6(B,T,R) \
get5(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##6); \
jit_subr##B(R##0, R##1, R##0);
#define get7(B,T,R) \
get6(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##7); \
jit_subr##B(R##0, R##1, R##0);
#define get8(B,T,R) \
get7(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##8); \
jit_subr##B(R##0, R##1, R##0);
#define get9(B,T,R) \
get8(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##9); \
jit_subr##B(R##0, R##1, R##0);
#define get10(B,T,R) \
get9(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##10); \
jit_subr##B(R##0, R##1, R##0);
#define get11(B,T,R) \
get10(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##11); \
jit_subr##B(R##0, R##1, R##0);
#define get12(B,T,R) \
get11(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##12); \
jit_subr##B(R##0, R##1, R##0);
#define get13(B,T,R) \
get12(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##13); \
jit_subr##B(R##0, R##1, R##0);
#define get14(B,T,R) \
get13(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##14); \
jit_subr##B(R##0, R##1, R##0);
#define get15(B,T,R) \
get14(B,T,R); \
jit_movr##B(R##1, R##0); \
jit_getarg##T(R##0, a##15); \
jit_subr##B(R##0, R##1, R##0);
#if __WORDSIZE == 32
# define jit_extr_i(u, v) /**/
#else
# define jit_extr_l(u, v) /**/
#endif
#define strfy(n) #n
#define defi(T, N) \
n##T##N = jit_name(strfy(n##T##N)); \
jit_note("ccall.c", __LINE__); \
jit_prolog(); \
arg##N(); \
get##N(,T,JIT_R) \
jit_extr##T(JIT_R0, JIT_R0); \
jit_retr(JIT_R0); \
jit_epilog();
#define deff(T, N) \
n##T##N = jit_name(strfy(n##T##N)); \
jit_note("ccall.c", __LINE__); \
jit_prolog(); \
arg##N(T); \
get##N(T,T,JIT_F); \
jit_retr##T(JIT_F0); \
jit_epilog();
#define def0(X, T) def##X(T, 0)
#define def1(X, T) def0(X, T) def##X(T, 1)
#define def2(X, T) def1(X, T) def##X(T, 2)
#define def3(X, T) def2(X, T) def##X(T, 3)
#define def4(X, T) def3(X, T) def##X(T, 4)
#define def5(X, T) def4(X, T) def##X(T, 5)
#define def6(X, T) def5(X, T) def##X(T, 6)
#define def7(X, T) def6(X, T) def##X(T, 7)
#define def8(X, T) def7(X, T) def##X(T, 8)
#define def9(X, T) def8(X, T) def##X(T, 9)
#define def10(X, T) def9(X, T) def##X(T, 10)
#define def11(X, T) def10(X, T) def##X(T, 11)
#define def12(X, T) def11(X, T) def##X(T, 12)
#define def13(X, T) def12(X, T) def##X(T, 13)
#define def14(X, T) def13(X, T) def##X(T, 14)
#define def15(X, T) def14(X, T) def##X(T, 15)
#define def(T) def15(i, T)
def(_c)
def(_uc)
def(_s)
def(_us)
def(_i)
#if __WORDSIZE == 64
def(_ui)
def(_l)
#endif
#undef def
#define def(T) def15(f, T)
def(_f)
def(_d)
#undef def
jit_patch(jmpi_main);
jit_name("main");
jit_note("ccall.c", __LINE__);
jit_prolog();
#define push0(T) /**/
#define push1(T) jit_pushargi##T(1);
#define push2(T) push1(T) jit_pushargi##T(2);
#define push3(T) push2(T) jit_pushargi##T(3);
#define push4(T) push3(T) jit_pushargi##T(4);
#define push5(T) push4(T) jit_pushargi##T(5);
#define push6(T) push5(T) jit_pushargi##T(6);
#define push7(T) push6(T) jit_pushargi##T(7);
#define push8(T) push7(T) jit_pushargi##T(8);
#define push9(T) push8(T) jit_pushargi##T(9);
#define push10(T) push9(T) jit_pushargi##T(10);
#define push11(T) push10(T) jit_pushargi##T(11);
#define push12(T) push11(T) jit_pushargi##T(12);
#define push13(T) push12(T) jit_pushargi##T(13);
#define push14(T) push13(T) jit_pushargi##T(14);
#define push15(T) push14(T) jit_pushargi##T(15);
#define calin(T,N) \
jit_prepare(); \
push##N() \
jit_finishi(C##T##N); \
jit_retval##T(JIT_R0); \
jmp = jit_beqi(JIT_R0, T##N); \
jit_calli(abort); \
jit_patch(jmp);
#define calfn(T,N) \
jit_prepare(); \
push##N(T) \
jit_finishi(C##T##N); \
jit_retval##T(JIT_F0); \
jmp = jit_beqi##T(JIT_F0, _w##N); \
jit_calli(abort); \
jit_patch(jmp);
#define calx0(X,T) cal##X##n(T,0)
#define calx1(X,T) calx0(X,T) cal##X##n(T,1)
#define calx2(X,T) calx1(X,T) cal##X##n(T,2)
#define calx3(X,T) calx2(X,T) cal##X##n(T,3)
#define calx4(X,T) calx3(X,T) cal##X##n(T,4)
#define calx5(X,T) calx4(X,T) cal##X##n(T,5)
#define calx6(X,T) calx5(X,T) cal##X##n(T,6)
#define calx7(X,T) calx6(X,T) cal##X##n(T,7)
#define calx8(X,T) calx7(X,T) cal##X##n(T,8)
#define calx9(X,T) calx8(X,T) cal##X##n(T,9)
#define calx10(X,T) calx9(X,T) cal##X##n(T,10)
#define calx11(X,T) calx10(X,T) cal##X##n(T,11)
#define calx12(X,T) calx11(X,T) cal##X##n(T,12)
#define calx13(X,T) calx12(X,T) cal##X##n(T,13)
#define calx14(X,T) calx13(X,T) cal##X##n(T,14)
#define calx15(X,T) calx14(X,T) cal##X##n(T,15)
#define cali(T) calx15(i,T)
#define calf(T) calx15(f,T)
cali(_c)
cali(_uc)
cali(_s)
cali(_us)
cali(_i)
#if __WORDSIZE == 64
cali(_ui)
cali(_l)
#endif
calf(_f)
calf(_d)
#undef calin
#undef calfn
#define calin(T,N) \
jit_prepare(); \
push##N() \
jit_finishi(CJ##T##N); \
jit_retval##T(JIT_R0); \
jmp = jit_beqi(JIT_R0, T##N); \
jit_calli(abort); \
jit_patch(jmp);
#define calfn(T,N) \
jit_prepare(); \
push##N(T) \
jit_finishi(CJ##T##N); \
jit_retval##T(JIT_F0); \
jmp = jit_beqi##T(JIT_F0, _w##N); \
jit_calli(abort); \
jit_patch(jmp);
cali(_c)
cali(_uc)
cali(_s)
cali(_us)
cali(_i)
#if __WORDSIZE == 64
cali(_ui)
cali(_l)
#endif
calf(_f)
calf(_d)
jit_ret();
function = jit_emit();
#define initn(T,N) j##T##N = jit_address(n##T##N);
#define init0(T) initn(T,0)
#define init1(T) init0(T) initn(T,1)
#define init2(T) init1(T) initn(T,2)
#define init3(T) init2(T) initn(T,3)
#define init4(T) init3(T) initn(T,4)
#define init5(T) init4(T) initn(T,5)
#define init6(T) init5(T) initn(T,6)
#define init7(T) init6(T) initn(T,7)
#define init8(T) init7(T) initn(T,8)
#define init9(T) init8(T) initn(T,9)
#define init10(T) init9(T) initn(T,10)
#define init11(T) init10(T) initn(T,11)
#define init12(T) init11(T) initn(T,12)
#define init13(T) init12(T) initn(T,13)
#define init14(T) init13(T) initn(T,14)
#define init15(T) init14(T) initn(T,15)
#define init(T) init15(T)
init(_c)
init(_uc)
init(_s)
init(_us)
init(_i)
#if __WORDSIZE == 64
init(_ui)
init(_l)
#endif
init(_f)
init(_d)
#if 0
jit_print();
jit_disassemble();
#endif
jit_clear_state();
(*function)();
jit_destroy_state();
finish_jit();
printf("ok\n");
return (0);
}
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.arm$||'`
./lightning -mthumb=0 $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.arm\.swf$||'`
./lightning -mthumb=0 -mvfp=0 $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.arm4\.swf$||'`
./lightning -mcpu=4 -mthumb=0 -mvfp=0 $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.nodata$||'`
./lightning -d $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0`
./lightning $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.swf$||'`
./lightning -mvfp=0 $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.x87.nodata$||'`
./lightning -data=0 -mx87=1 $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
test=`basename $0 | sed -e 's|\.x87$||'`
./lightning -mx87=1 $srcdir/$test.tst | tr -d \\r > $test.out
if test $? != 0; then
exit $?
fi
cmp -s $srcdir/$test.ok $test.out
result=$?
if test $result != 0; then
diff $srcdir/$test.ok $test.out
rm $test.out
exit 1
fi
rm $test.out
+1
View File
@@ -0,0 +1 @@
ok
File diff suppressed because it is too large. Load diff
+123
View File
@@ -0,0 +1,123 @@
#include <lightning.h>
#include <stdio.h>
jit_state_t *_jit;
long top;
long stk[1024];
int
main(int argc, char *argv[])
{
void *address;
void (*call)(void*);
jit_state_t *frame_jit, *tramp_jit;
jit_node_t *arg, *done, *xfibs, *out, *ret1, *ret2;
init_jit(argv[0]);
_jit = frame_jit = jit_new_state();
jit_name("main");
jit_prolog();
jit_frame(64);
arg = jit_arg();
jit_getarg(JIT_R1, arg);
/* Initialize language stack */
jit_movi(JIT_R0, (jit_word_t)stk);
jit_sti(&top, JIT_R0);
/* return address */
done = jit_movi(JIT_R0, 0);
/* argument */
jit_movi(JIT_V0, 32);
/* jump to code */
jit_jmpr(JIT_R1);
jit_patch(done);
jit_prepare();
jit_pushargi((jit_word_t)"xfibs(%d) = %d\n");
jit_ellipsis();
jit_pushargi(32);
jit_pushargr(JIT_V0);
jit_finishi(printf);
jit_ret();
jit_epilog();
call = jit_emit();
jit_clear_state();
#define SIZE sizeof(jit_word_t)
_jit = tramp_jit = jit_new_state();
jit_name("xfibs");
xfibs = jit_label();
jit_prolog();
jit_tramp(64);
out = jit_blti(JIT_V0, 2);
jit_subi(JIT_V1, JIT_V0, 1); /* V1 = N-1 */
jit_subi(JIT_V2, JIT_V0, 2); /* V1 = N-2 */
/* save return address */
jit_ldi(JIT_R1, &top);
jit_stxi(SIZE * 0, JIT_R1, JIT_R0);
/* save operands */
jit_stxi(SIZE * 1, JIT_R1, JIT_V0);
jit_stxi(SIZE * 2, JIT_R1, JIT_V1);
jit_stxi(SIZE * 3, JIT_R1, JIT_V2);
/* adjust "language" stack */
jit_addi(JIT_R1, JIT_R1, SIZE * 4);
jit_sti(&top, JIT_R1);
/* return address */
ret1 = jit_movi(JIT_R0, 0);
/* argument */
jit_movr(JIT_V0, JIT_V1);
/* indirect goto */
jit_patch_at(jit_jmpi(), xfibs);
jit_patch(ret1);
jit_movr(JIT_V1, JIT_V0); /* V1 = rfibs(N-1) */
/* save V1 */
jit_ldi(JIT_R1, &top);
jit_stxi(-SIZE * 2, JIT_R1, JIT_V1);
/* reload V2 */
jit_ldxi(JIT_V2, JIT_R1, -SIZE * 1);
/* return address */
ret2 = jit_movi(JIT_R0, 0);
/* argument */
jit_movr(JIT_V0, JIT_V2);
/* indirect goto */
jit_patch_at(jit_jmpi(), xfibs);
jit_patch(ret2);
jit_movr(JIT_V2, JIT_V0); /* V2 = rfibs(N-2) */
/* reload return address */
jit_ldi(JIT_R1, &top);
jit_subi(JIT_R1, JIT_R1, SIZE * 4);
jit_ldxi(JIT_R0, JIT_R1, SIZE * 0);
/* reload operands */
jit_ldxi(JIT_V0, JIT_R1, SIZE * 1);
jit_ldxi(JIT_V1, JIT_R1, SIZE * 2);
/* V2 already loaded */
/* update "language" stack */
jit_sti(&top, JIT_R1);
jit_addi(JIT_V1, JIT_V1, 1);
jit_addr(JIT_V0, JIT_V1, JIT_V2);
jit_jmpr(JIT_R0);
jit_patch(out);
jit_movi(JIT_V0, 1);
jit_jmpr(JIT_R0);
jit_epilog();
address = jit_emit();
jit_clear_state();
(*call)(address);
jit_destroy_state();
_jit = frame_jit;
jit_destroy_state();
return 0;
}
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
ok
+380
View File
@@ -0,0 +1,380 @@
.data 12
ok:
.c "ok\n"
#if __WORDSIZE == 32
# define w7f 0x7fffffff
# define w80 0x80000000
# define w81 0x80000001
# define wff 0xffffffff
# define LEXTII2(N, R0, R1)
# define LEXTIC2(N, R0)
#else
# define w7f 0x7fffffffffffffff
# define w80 0x8000000000000000
# define w81 0x8000000000000001
# define wff 0xffffffffffffffff
# define i7f wff
# define ui7f 0xffffffff
# define i80 0
# define ui80 0
# define i81 1
# define ui81 1
# define iff wff
# define uiff 0xffffffff
# define LEXTII2(N, R0, R1) \
EXTII2(N, i, R0, R1) \
EXTII2(N, ui, R0, R1)
# define LEXTIC2(N, R0) \
EXTIC2(N, i, R0) \
EXTIC2(N, ui, R0)
#endif
#define c7f wff
#define uc7f 0xff
#define s7f wff
#define us7f 0xffff
#define c80 0
#define uc80 0
#define s80 0
#define us80 0
#define c81 1
#define uc81 1
#define s81 1
#define us81 1
#define cff wff
#define ucff 0xff
#define sff wff
#define usff 0xffff
#define EXTII2(N, T, R0, R1) \
movi %R0 w##N \
extr_##T %R1 %R0 \
beqi T##_##R0##_##R1##_##N %R1 T##N \
calli @abort \
T##_##R0##_##R1##_##N:
#define EXTII1(N, R0, R1) \
EXTII2(N, c, R0, R1) \
EXTII2(N, uc, R0, R1) \
EXTII2(N, s, R0, R1) \
EXTII2(N, us, R0, R1) \
LEXTII2(N, R0, R1)
#define EXTII0(R0, R1) \
EXTII1(7f, R0, R1) \
EXTII1(80, R0, R1) \
EXTII1(81, R0, R1) \
EXTII1(ff, R0, R1)
#define EXTIC2(N, T, R0) \
movi %R0 w##N \
extr_##T %R0 %R0 \
beqi T##_##R0##_##N %R0 T##N \
calli @abort \
T##_##R0##_##N:
#define EXTIC1(N, R0) \
EXTIC2(N, c, R0) \
EXTIC2(N, uc, R0) \
EXTIC2(N, s, R0) \
EXTIC2(N, us, R0) \
LEXTIC2(N, R0)
#define EXTIC0(R0) \
EXTIC1(7f, R0) \
EXTIC1(80, R0) \
EXTIC1(81, R0) \
EXTIC1(ff, R0)
#define EXTII(V0, V1, V2, R0, R1, R2) \
EXTII0(V0, V1) \
EXTII0(V0, V2) \
EXTII0(V0, R0) \
EXTII0(V0, R1) \
EXTII0(V0, R2) \
EXTII0(V1, V0) \
EXTII0(V1, V2) \
EXTII0(V1, R0) \
EXTII0(V1, R1) \
EXTII0(V1, R2) \
EXTII0(V2, V0) \
EXTII0(V2, V1) \
EXTII0(V2, R0) \
EXTII0(V2, R1) \
EXTII0(V2, R2) \
EXTII0(R0, V0) \
EXTII0(R0, V1) \
EXTII0(R0, V2) \
EXTII0(R0, R1) \
EXTII0(R0, R2) \
EXTII0(R1, V0) \
EXTII0(R1, V1) \
EXTII0(R1, V2) \
EXTII0(R1, R0) \
EXTII0(R1, R2) \
EXTII0(R2, V0) \
EXTII0(R2, V1) \
EXTII0(R2, V2) \
EXTII0(R2, R0) \
EXTII0(R2, R1) \
EXTIC0(V0) \
EXTIC0(V1) \
EXTIC0(V2) \
EXTIC0(R0) \
EXTIC0(R1) \
EXTIC0(R2)
#define EXIF1(N, V, R0, R1) \
movi %R0 V \
extr_f %R1 %R0 \
beqi_f wf##_##R0##_##R1##_##N %R1 V \
wf##_##R0##_##R1##_##N:
#define EXIF0(R0, R1) \
EXIF1(0, -1, R0, R1) \
EXIF1(1, 64, R0, R1)
#define EXIF(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
EXIF0(V0, F0) \
EXIF0(V1, F1) \
EXIF0(V2, F2) \
EXIF0(R0, F3) \
EXIF0(R1, F4) \
EXIF0(R2, F5)
#define EXID1(N, V, R0, R1) \
movi %R0 V \
extr_d %R1 %R0 \
beqi_d wd##_##R0##_##R1##_##N %R1 V \
wd##_##R0##_##R1##_##N:
#define EXID0(R0, R1) \
EXID1(0, -1, R0, R1) \
EXID1(1, 64, R0, R1)
#define EXID(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
EXID0(V0, F0) \
EXID0(V1, F1) \
EXID0(V2, F2) \
EXID0(R0, F3) \
EXID0(R1, F4) \
EXID0(R2, F5)
#define EXFI1(N, V, R0, R1) \
movi_f %R1 V \
truncr_f %R0 %R1 \
beqi fi##_##R0##_##R1##_##N %R0 V \
calli @abort \
fi##_##R0##_##R1##_##N:
#define EXFI0(R0, R1) \
EXFI1(0, 42, R0, R1) \
EXFI1(1, -128, R0, R1)
#define EXFI(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
EXFI0(V0, F5) \
EXFI0(V1, F4) \
EXFI0(V2, F3) \
EXFI0(R0, F2) \
EXFI0(R1, F1) \
EXFI0(R2, F0)
#define EXDI1(N, V, R0, R1) \
movi_d %R1 V \
truncr_d %R0 %R1 \
beqi di##_##R0##_##R1##_##N %R0 V \
calli @abort \
di##_##R0##_##R1##_##N:
#define EXDI0(R0, R1) \
EXDI1(0, 42, R0, R1) \
EXDI1(1, -128, R0, R1)
#define EXDI(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
EXDI0(V0, F5) \
EXDI0(V1, F4) \
EXDI0(V2, F3) \
EXDI0(R0, F2) \
EXDI0(R1, F1) \
EXDI0(R2, F0)
#define LEXFI1(N, V, R0, R1) \
movi_f %R1 V \
truncr_f_i %R0 %R1 \
andi %R0 %R0 0xffffffff \
beqi lfi##_##R0##_##R1##_##N %R0 $(V & 0xffffffff) \
calli @abort \
lfi##_##R0##_##R1##_##N:
#define LEXFI0(R0, R1) \
LEXFI1(0, 42, R0, R1) \
LEXFI1(1, -128, R0, R1)
#define LEXFI(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
LEXFI0(V0, F5) \
LEXFI0(V1, F4) \
LEXFI0(V2, F3) \
LEXFI0(R0, F2) \
LEXFI0(R1, F1) \
LEXFI0(R2, F0)
#define LEXDI1(N, V, R0, R1) \
movi_d %R1 V \
truncr_d_i %R0 %R1 \
andi %R0 %R0 0xffffffff \
beqi ldi##_##R0##_##R1##_##N %R0 $(V & 0xffffffff) \
calli @abort \
ldi##_##R0##_##R1##_##N:
#define LEXDI0(R0, R1) \
LEXDI1(0, 42, R0, R1) \
LEXDI1(1, -128, R0, R1)
#define LEXDI(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
LEXDI0(V0, F5) \
LEXDI0(V1, F4) \
LEXDI0(V2, F3) \
LEXDI0(R0, F2) \
LEXDI0(R1, F1) \
LEXDI0(R2, F0)
#define EXTFD2(V, R0, R1) \
movi_f %R0 V \
extr_f_d %R1 %R0 \
beqi_d fd##_##R0##_##R1 %R1 V \
calli @abort \
fd##_##R0##_##R1:
#define EXTFD1(R0, R1) \
EXTFD2(1.25, R0, R1)
#define EXTFDC2(V, R0) \
movi_f %R0 V \
extr_f_d %R0 %R0 \
beqi_d fdc##_##R0 %R0 V \
calli @abort \
fdc##_##R0:
#define EXTFDC1(R0) \
EXTFDC2(-0.75, R0)
#define EXTFD(R0, R1, R2, R3, R4, R5) \
EXTFD1(R0, R1) \
EXTFD1(R0, R2) \
EXTFD1(R0, R3) \
EXTFD1(R0, R4) \
EXTFD1(R0, R5) \
EXTFDC1(R0) \
EXTFDC1(R1) \
EXTFDC1(R2) \
EXTFDC1(R3) \
EXTFDC1(R4) \
EXTFDC1(R5)
#define EXTDF2(V, R0, R1) \
movi_d %R0 V \
extr_d_f %R1 %R0 \
beqi_f df##_##R0##_##R1 %R1 V \
calli @abort \
df##_##R0##_##R1:
#define EXTDF1(R0, R1) \
EXTDF2(1.25, R0, R1)
#define EXTDFC2(V, R0) \
movi_d %R0 V \
extr_d_f %R0 %R0 \
beqi_f dfc##_##R0 %R0 V \
calli @abort \
dfc##_##R0:
#define EXTDFC1(R0) \
EXTDFC2(-0.75, R0)
#define EXTDF(R0, R1, R2, R3, R4, R5) \
EXTDF1(R0, R1) \
EXTDF1(R0, R2) \
EXTDF1(R0, R3) \
EXTDF1(R0, R4) \
EXTDF1(R0, R5) \
EXTDFC1(R0) \
EXTDFC1(R1) \
EXTDFC1(R2) \
EXTDFC1(R3) \
EXTDFC1(R4) \
EXTDFC1(R5)
.code
prolog
/* simple sequence for easier disassembly reading and encoding check */
movi %r0 w7f
extr_c %r1 %r0
beqi xc %r1 c7f
calli @abort
xc:
movi %r0 w7f
extr_uc %r1 %r0
beqi xuc %r1 uc7f
calli @abort
xuc:
movi %r0 w7f
extr_s %r1 %r0
beqi xs %r1 s7f
calli @abort
xs:
movi %r0 w7f
extr_us %r1 %r0
beqi xus %r1 us7f
calli @abort
xus:
#if __WORDSIZE == 64
movi %r0 w7f
extr_i %r1 %r0
beqi xi %r1 i7f
calli @abort
xi:
movi %r0 w7f
extr_ui %r1 %r0
beqi xui %r1 ui7f
calli @abort
xui:
#endif
movi %r0 -2
extr_f %f0 %r0
beqi_f xif %f0 -2
calli @abort
xif:
movi %r0 32
extr_d %f0 %r0
beqi_d xid %f0 32
calli @abort
xid:
movi_f %f0 -128
truncr_f %r0 %f0
beqi xfi %r0 -128
calli @abort
xfi:
movi_d %f0 -128
truncr_d %r0 %f0
beqi xdi %r0 -128
calli @abort
xdi:
#if __WORDSIZE == 64
movi_f %f0 -128
truncr_f_i %r0 %f0
andi %r0 %r0 0xffffffff
beqi yfi %r0 $(-128 & 0xffffffff)
calli @abort
yfi:
movi_d %f0 -128
truncr_d_i %r0 %f0
andi %r0 %r0 0xffffffff
beqi ydi %r0 $(-128 & 0xffffffff)
calli @abort
ydi:
#endif
movi_f %f0 0.5
extr_f_d %f1 %f0
beqi_d xfd %f1 0.5
calli @abort
xfd:
movi_d %f0 0.5
extr_d_f %f1 %f0
beqi_f xdf %f1 0.5
calli @abort
xdf:
EXTII(v0, v1, v2, r0, r1, r2)
EXIF(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
EXID(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
EXFI(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
#if __WORDSIZE == 64
LEXFI(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
LEXDI(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
#endif
EXDI(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
EXTFD(f0, f1, f2, f3, f4, f5)
EXTDF(f0, f1, f2, f3, f4, f5)
// just to know did not abort
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+6
View File
@@ -0,0 +1,6 @@
40/8 = 5 (expected 5)
64/8 = 8 (expected 8)
80/8 = 10 (expected 10)
98304/32768 = 3 (expected 3)
65536/32768 = 2 (expected 2)
163840/32768 = 5 (expected 5)
+85
View File
@@ -0,0 +1,85 @@
.data 128
small_ops:
.i 40 64 80
large_ops:
.i 98304 65536 163840
fmt:
.c "%i/%i = %i (expected %i)\n"
x:
.c "%d\n"
.code
jmpi main
#define generate_divider(operand) \
name divider_##operand \
divider_##operand: \
prolog \
arg $i \
getarg %r1 $i \
divi %r2 %r1 operand \
retr %r2 \
epilog
generate_divider(8)
generate_divider(32768)
#define generate_test_divider(divisor) \
name test_divider_##divisor \
test_divider_##divisor: \
prolog \
allocai 4 $loc \
arg $p \
arg $c \
getarg %v0 $p \
getarg %v1 $c \
muli %v1 %v1 4 \
addr %v1 %v0 %v1 \
loop_##divisor: \
bger done_##divisor %v0 %v1 \
ldr_i %v2 %v0 \
prepare \
pushargr %v2 \
finishi divider_##divisor \
retval %v2 \
ldr_i %r2 %v0 \
divi %r0 %r2 divisor \
/* save div result */ \
stxi_i $loc %fp %r0 \
prepare \
pushargi fmt \
ellipsis \
pushargr %r2 \
pushargi divisor \
pushargr %v2 \
pushargr %r0 \
finishi @printf \
addi %v0 %v0 4 \
/* reload div result */ \
ldxi_i %r0 %fp $loc \
beqr loop_##divisor %r0 %v2 \
/* return if failed */ \
reti 1 \
done_##divisor: \
reti 0 \
epilog
generate_test_divider(8)
generate_test_divider(32768)
name main
main:
prolog
prepare
pushargi small_ops
pushargi 3
finishi test_divider_8
retval %r0
bnei fail %r0 0
prepare
pushargi large_ops
pushargi 3
finishi test_divider_32768
retval %r0
bnei fail %r0 0
reti 0
fail:
reti 1
epilog
+1
View File
@@ -0,0 +1 @@
nfibs(32) = 2178309
+62
View File
@@ -0,0 +1,62 @@
.data 32
format:
.c "nfibs(%d) = %d\n"
.code
jmpi main
name nfibs
nfibs:
prolog
arg $in
getarg %r0 $in // R0 = n
beqi ref %r0 0
movr %r1 %r0
movi %r0 1
blei_u ref %r1 2
subi %r2 %r1 2
movr %r1 %r0
loop:
subi %r2 %r2 1 // decr. counter
movr %v0 %r0 // V0 = R0
addr %r0 %r0 %r1 // R0 = R0 + R1
movr %r1 %v0 // R1 = V0
bnei loop %r2 0 // if (R2) goto loop
ref:
retr %r0 // RET = R0
epilog
name main
main:
prolog
arg $argc
arg $argv
getarg_i %r0 $argc
blei default %r0 1
getarg %r0 $argv
addi %r0 %r0 $(__WORDSIZE >> 3)
ldr %r0 %r0
prepare
pushargr %r0
finishi @atoi
retval %r0
jmpi call
default:
movi %r0 32
call:
movr %v0 %r0
prepare
pushargr %r0
finishi nfibs
retval %r0
prepare
pushargi format
ellipsis
pushargr %v0
pushargr %r0
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+367
View File
@@ -0,0 +1,367 @@
.data 4
ok:
.c "ok"
. $($NaN = 0.0 / 0.0)
. $($pInf = 1.0 / 0.0)
. $($nInf = -1.0 / 0.0)
#if __WORDSIZE == 32
# define x7f 0x7fffffff
# define x80 0x80000000
#else
# define x7f 0x7fffffffffffffff
# define x80 0x8000000000000000
#endif
#if __mips__ || __sparc__ || __hppa__ || __riscv
# define wnan x7f
#elif __arm__ || __aarch64__ || __alpha__
# define wnan 0
#else
# define wnan x80
#endif
#if __mips__ || __arm__ || __ppc__ || __sparc__ || __hppa__ || __aarch64__ || __s390__ || __riscv
# define wpinf x7f
#elif __alpha__
/* (at least) bug compatible with gcc 4.2.3 -ieee */
# define wpinf 0
#else
# define wpinf x80
#endif
#if __alpha__
/* (at least) bug compatible with gcc 4.2.3 -ieee */
# define wninf 0
#else
# define wninf x80
#endif
/* ensure result is correct and 0 or 1 in the result register */
#define xtcmp(l, t, op, r0, f0, f1, li, ri) \
movi##t %f0 li \
movi##t %f1 ri \
op##r##t %r0 %f0 %f1 \
bnei T##op##r##t##r0##f0##f1##l %r0 0 \
calli @abort \
T##op##r##t##r0##f0##f1##l: \
movi##t %f0 li \
movi##t %f1 ri \
b##op##r##t bT##op##r##t##r0##f0##f1##l %f0 %f1 \
calli @abort \
bT##op##r##t##r0##f0##f1##l: \
movi##t %f1 li \
op##i##t %r0 %f0 ri \
bnei T##op##i##t##r0##f0##f1##l %r0 0 \
calli @abort \
T##op##i##t##r0##f0##f1##l: \
movi##t %f1 li \
b##op##i##t bT##op##i##t##r0##f0##f1##l %f0 ri \
calli @abort \
bT##op##i##t##r0##f0##f1##l: \
movi##t %f0 li \
movi##t %f1 ri \
op##r##t %r0 %f0 %f1 \
beqi F##op##r##t##r0##f0##f1##l %r0 1 \
calli @abort \
F##op##r##t##r0##f0##f1##l: \
movi##t %f1 li \
op##i##t %r0 %f0 ri \
beqi F##op##i##t##r0##f0##f1##l %r0 1 \
calli @abort \
F##op##i##t##r0##f0##f1##l:
#define tcmp1(l, t, op, r0, li, ri) \
xtcmp(l, t, op, r0, f0, f1, li, ri) \
xtcmp(l, t, op, r0, f1, f2, li, ri) \
xtcmp(l, t, op, r0, f2, f3, li, ri) \
xtcmp(l, t, op, r0, f3, f4, li, ri) \
xtcmp(l, t, op, r0, f4, f5, li, ri)
#define tcmp0(l, t, op, li, ri) \
tcmp1(l, t, op, v0, li, ri) \
tcmp1(l, t, op, v1, li, ri) \
tcmp1(l, t, op, v2, li, ri) \
tcmp1(l, t, op, r0, li, ri) \
tcmp1(l, t, op, r1, li, ri) \
tcmp1(l, t, op, r2, li, ri)
#if __ia64__
# define tcmp(l, op, li, ri) \
xtcmp(l, _f, op, r0, f0, f1, li, ri) \
xtcmp(l, _d, op, r0, f0, f1, li, ri)
#else
# define tcmp(l, op, li, ri) \
tcmp0(l, _f, op, li, ri) \
tcmp0(l, _d, op, li, ri)
#endif
#define xfcmp(l, t, op, r0, f0, f1, li, ri) \
movi##t %f0 li \
movi##t %f1 ri \
op##r##t %r0 %f0 %f1 \
beqi T##op##r##t##r0##f0##f1##l %r0 0 \
calli @abort \
T##op##r##t##r0##f0##f1##l: \
movi##t %f1 li \
op##i##t %r0 %f0 ri \
beqi T##op##i##t##r0##f0##f1##l %r0 0 \
calli @abort \
T##op##i##t##r0##f0##f1##l: \
movi##t %f0 li \
movi##t %f1 ri \
op##r##t %r0 %f0 %f1 \
bnei F##op##r##t##r0##f0##f1##l %r0 1 \
calli @abort \
F##op##r##t##r0##f0##f1##l: \
movi##t %f1 li \
op##i##t %r0 %f0 ri \
bnei F##op##i##t##r0##f0##f1##l %r0 1 \
calli @abort \
F##op##i##t##r0##f0##f1##l:
#define fcmp1(l, t, op, r0, li, ri) \
xfcmp(l, t, op, r0, f0, f1, li, ri) \
xfcmp(l, t, op, r0, f1, f2, li, ri) \
xfcmp(l, t, op, r0, f2, f3, li, ri) \
xfcmp(l, t, op, r0, f3, f4, li, ri) \
xfcmp(l, t, op, r0, f4, f5, li, ri)
#define fcmp0(l, t, op, li, ri) \
fcmp1(l, t, op, v0, li, ri) \
fcmp1(l, t, op, v1, li, ri) \
fcmp1(l, t, op, v2, li, ri) \
fcmp1(l, t, op, r0, li, ri) \
fcmp1(l, t, op, r1, li, ri) \
fcmp1(l, t, op, r2, li, ri)
#if __ia64__
# define fcmp(l, op, li, ri) \
xfcmp(l, _f, op, r0, f0, f1, li, ri) \
xfcmp(l, _d, op, r0, f0, f1, li, ri)
#else
# define fcmp(l, op, li, ri) \
fcmp0(l, _f, op, li, ri) \
fcmp0(l, _d, op, li, ri)
#endif
#define xf2w(l, f, r0, f0, iv, fv) \
movi##f %f0 fv \
truncr##f %r0 %f0 \
beqi W##f##r0##f0##l %r0 iv \
calli @abort \
W##f##r0##f0##l:
#define f2w1(l, t, r0, iv, fv) \
xf2w(l, t, r0, f0, iv, fv) \
xf2w(l, t, r0, f1, iv, fv) \
xf2w(l, t, r0, f2, iv, fv) \
xf2w(l, t, r0, f3, iv, fv) \
xf2w(l, t, r0, f4, iv, fv) \
xf2w(l, t, r0, f5, iv, fv)
#define f2w0(l, t, iv, fv) \
f2w1(l, t, v0, iv, fv) \
f2w1(l, t, v1, iv, fv) \
f2w1(l, t, v2, iv, fv) \
f2w1(l, t, r0, iv, fv) \
f2w1(l, t, r1, iv, fv) \
f2w1(l, t, r2, iv, fv)
#if __ia64__
# define f2w(l, iv, fv) \
xf2w(l, _f, r0, f0, iv, fv) \
xf2w(l, _d, r0, f0, iv, fv)
#else
# define f2w(l, iv, fv) \
f2w0(l, _f, iv, fv) \
f2w0(l, _d, iv, fv)
#endif
.code
prolog
tcmp(__LINE__, lt, 0, 1)
tcmp(__LINE__, lt, $nInf, $pInf)
tcmp(__LINE__, lt, $nInf, 0)
tcmp(__LINE__, lt, 0, $pInf)
fcmp(__LINE__, lt, $NaN, 0)
fcmp(__LINE__, lt, $NaN, $NaN)
fcmp(__LINE__, lt, $nInf, $NaN)
fcmp(__LINE__, lt, 1, 0)
fcmp(__LINE__, lt, 0, 0)
fcmp(__LINE__, lt, $pInf, $nInf)
fcmp(__LINE__, lt, 0, $nInf)
fcmp(__LINE__, lt, 0, $NaN)
tcmp(__LINE__, le, 0, 1)
tcmp(__LINE__, le, 0, 0)
tcmp(__LINE__, le, 1, 1)
tcmp(__LINE__, le, $nInf, $pInf)
tcmp(__LINE__, le, $nInf, 0)
tcmp(__LINE__, le, 0, $pInf)
fcmp(__LINE__, le, $NaN, 0)
fcmp(__LINE__, le, $NaN, $NaN)
fcmp(__LINE__, le, $nInf, $NaN)
fcmp(__LINE__, le, 1, 0)
fcmp(__LINE__, le, $pInf, $nInf)
fcmp(__LINE__, le, 0, $nInf)
fcmp(__LINE__, le, 0, $NaN)
tcmp(__LINE__, eq, 0, 0)
tcmp(__LINE__, eq, 1, 1)
fcmp(__LINE__, eq, $NaN, 0)
fcmp(__LINE__, eq, $NaN, $NaN)
fcmp(__LINE__, eq, $nInf, $NaN)
fcmp(__LINE__, eq, 0, 1)
fcmp(__LINE__, eq, 1, 0)
fcmp(__LINE__, eq, $pInf, $nInf)
fcmp(__LINE__, eq, 0, $nInf)
fcmp(__LINE__, eq, 0, $NaN)
tcmp(__LINE__, ge, 1, 0)
tcmp(__LINE__, ge, 0, 0)
tcmp(__LINE__, ge, 1, 1)
tcmp(__LINE__, ge, $pInf, $nInf)
tcmp(__LINE__, ge, 0, $nInf)
tcmp(__LINE__, ge, $pInf, 0)
fcmp(__LINE__, ge, $NaN, 0)
fcmp(__LINE__, ge, $NaN, $NaN)
fcmp(__LINE__, ge, $nInf, $NaN)
fcmp(__LINE__, ge, 0, 1)
fcmp(__LINE__, ge, $nInf, $pInf)
fcmp(__LINE__, ge, $nInf, 0)
fcmp(__LINE__, ge, 0, $NaN)
tcmp(__LINE__, gt, 1, 0)
tcmp(__LINE__, gt, $pInf, $nInf)
tcmp(__LINE__, gt, 0, $nInf)
tcmp(__LINE__, gt, $pInf, 0)
fcmp(__LINE__, gt, $NaN, 0)
fcmp(__LINE__, gt, $NaN, $NaN)
fcmp(__LINE__, gt, $nInf, $NaN)
fcmp(__LINE__, gt, 0, 1)
fcmp(__LINE__, gt, 0, 0)
fcmp(__LINE__, gt, $nInf, $pInf)
fcmp(__LINE__, gt, $nInf, 0)
fcmp(__LINE__, gt, 0, $NaN)
tcmp(__LINE__, ne, 0, 1)
tcmp(__LINE__, ne, 1, 0)
tcmp(__LINE__, ne, $NaN, $NaN)
tcmp(__LINE__, ne, $nInf, $pInf)
tcmp(__LINE__, ne, $NaN, 0)
tcmp(__LINE__, ne, $nInf, $NaN)
tcmp(__LINE__, ne, $pInf, $nInf)
tcmp(__LINE__, ne, 0, $nInf)
tcmp(__LINE__, ne, 0, $NaN)
fcmp(__LINE__, ne, 0, 0)
fcmp(__LINE__, ne, 1, 1)
tcmp(__LINE__, unlt, 0, 1)
tcmp(__LINE__, unlt, $nInf, $pInf)
tcmp(__LINE__, unlt, $nInf, 0)
tcmp(__LINE__, unlt, 0, $pInf)
tcmp(__LINE__, unlt, $NaN, 0)
tcmp(__LINE__, unlt, $NaN, $NaN)
tcmp(__LINE__, unlt, $nInf, $NaN)
tcmp(__LINE__, unlt, 0, $NaN)
fcmp(__LINE__, unlt, 1, 0)
fcmp(__LINE__, unlt, 0, 0)
fcmp(__LINE__, unlt, $pInf, $nInf)
fcmp(__LINE__, unlt, 0, $nInf)
tcmp(__LINE__, unle, 0, 1)
tcmp(__LINE__, unle, 0, 0)
tcmp(__LINE__, unle, 1, 1)
tcmp(__LINE__, unle, $nInf, $pInf)
tcmp(__LINE__, unle, $nInf, 0)
tcmp(__LINE__, unle, 0, $pInf)
tcmp(__LINE__, unle, $NaN, 0)
tcmp(__LINE__, unle, $NaN, $NaN)
tcmp(__LINE__, unle, $nInf, $NaN)
tcmp(__LINE__, unle, 0, $NaN)
fcmp(__LINE__, unle, 1, 0)
fcmp(__LINE__, unle, $pInf, $nInf)
fcmp(__LINE__, unle, 0, $nInf)
tcmp(__LINE__, uneq, 0, 0)
tcmp(__LINE__, uneq, 1, 1)
tcmp(__LINE__, uneq, $NaN, 0)
tcmp(__LINE__, uneq, $NaN, $NaN)
tcmp(__LINE__, uneq, $nInf, $NaN)
tcmp(__LINE__, uneq, 0, $NaN)
fcmp(__LINE__, uneq, 0, 1)
fcmp(__LINE__, uneq, 1, 0)
fcmp(__LINE__, uneq, $pInf, $nInf)
fcmp(__LINE__, uneq, 0, $nInf)
tcmp(__LINE__, unge, 1, 0)
tcmp(__LINE__, unge, 0, 0)
tcmp(__LINE__, unge, 1, 1)
tcmp(__LINE__, unge, $pInf, $nInf)
tcmp(__LINE__, unge, 0, $nInf)
tcmp(__LINE__, unge, $pInf, 0)
tcmp(__LINE__, unge, $NaN, 0)
tcmp(__LINE__, unge, $NaN, $NaN)
tcmp(__LINE__, unge, $nInf, $NaN)
tcmp(__LINE__, unge, 0, $NaN)
fcmp(__LINE__, unge, 0, 1)
fcmp(__LINE__, unge, $nInf, $pInf)
fcmp(__LINE__, unge, $nInf, 0)
tcmp(__LINE__, ungt, 1, 0)
tcmp(__LINE__, ungt, $pInf, $nInf)
tcmp(__LINE__, ungt, 0, $nInf)
tcmp(__LINE__, ungt, $pInf, 0)
tcmp(__LINE__, ungt, $NaN, 0)
tcmp(__LINE__, ungt, $NaN, $NaN)
tcmp(__LINE__, ungt, $nInf, $NaN)
tcmp(__LINE__, ungt, 0, $NaN)
fcmp(__LINE__, ungt, 0, 1)
fcmp(__LINE__, ungt, 0, 0)
fcmp(__LINE__, ungt, $nInf, $pInf)
fcmp(__LINE__, ungt, $nInf, 0)
tcmp(__LINE__, ltgt, 0, 1)
tcmp(__LINE__, ltgt, 1, 0)
tcmp(__LINE__, ltgt, $nInf, $pInf)
tcmp(__LINE__, ltgt, $pInf, $nInf)
tcmp(__LINE__, ltgt, 0, $nInf)
fcmp(__LINE__, ltgt, $NaN, $NaN)
fcmp(__LINE__, ltgt, $NaN, 0)
fcmp(__LINE__, ltgt, $nInf, $NaN)
fcmp(__LINE__, ltgt, 0, $NaN)
fcmp(__LINE__, ltgt, 0, 0)
fcmp(__LINE__, ltgt, 1, 1)
tcmp(__LINE__, ord, 0, 1)
tcmp(__LINE__, ord, 1, 0)
tcmp(__LINE__, ord, $nInf, $pInf)
tcmp(__LINE__, ord, $pInf, $nInf)
tcmp(__LINE__, ord, 0, $nInf)
tcmp(__LINE__, ord, 0, 0)
tcmp(__LINE__, ord, 1, 1)
fcmp(__LINE__, ord, $NaN, $NaN)
fcmp(__LINE__, ord, $NaN, 0)
fcmp(__LINE__, ord, $nInf, $NaN)
fcmp(__LINE__, ord, 0, $NaN)
tcmp(__LINE__, unord, $NaN, $NaN)
tcmp(__LINE__, unord, $NaN, 0)
tcmp(__LINE__, unord, $nInf, $NaN)
tcmp(__LINE__, unord, 0, $NaN)
fcmp(__LINE__, unord, 0, 1)
fcmp(__LINE__, unord, 1, 0)
fcmp(__LINE__, unord, $nInf, $pInf)
fcmp(__LINE__, unord, $pInf, $nInf)
fcmp(__LINE__, unord, 0, $nInf)
fcmp(__LINE__, unord, 0, 0)
fcmp(__LINE__, unord, 1, 1)
f2w(__LINE__, 0, 0)
f2w(__LINE__, 1, 1)
/* not all loongson agree on it */
#if !__mips__
f2w(__LINE__, wninf, $nInf)
#endif
f2w(__LINE__, wpinf, $pInf)
f2w(__LINE__, wnan, $NaN)
prepare
pushargi ok
ellipsis
finishi @puts
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+31
View File
@@ -0,0 +1,31 @@
#include "alu.inc"
.code
prolog
#define ABS(N, T, I, V) FUN(N, T, abs, I, V)
#define UABS(N, T, I, V) UFUN(N, T, abs, I, V)
ABS(0, _f, -0.0, 0.0)
ABS(1, _f, 0.5, 0.5)
ABS(2, _f, -0.5, 0.5)
ABS(3, _f, $Inf, $Inf)
ABS(4, _f, $nInf, $Inf)
ABS(5, _f, 1.25, 1.25)
ABS(6, _f, -1.25, 1.25)
ABS(7, _f, $nInf, $Inf)
UABS(0, _f, $NaN, $NaN)
ABS(0, _d, -0.0, 0.0)
ABS(1, _d, 0.5, 0.5)
ABS(2, _d, -0.5, 0.5)
ABS(3, _d, $Inf, $Inf)
ABS(4, _d, $nInf, $Inf)
ABS(5, _d, 1.25, 1.25)
ABS(6, _d, -1.25, 1.25)
ABS(7, _d, $nInf, $Inf)
UABS(0, _d, $NaN, $NaN)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+23
View File
@@ -0,0 +1,23 @@
#include "alu.inc"
.code
prolog
#define SQRT(N, T, I, V) FUN(N, T, sqrt, I, V)
#define USQRT(N, T, I, V) UFUN(N, T, sqrt, I, V)
SQRT(0, _f, -0.0, 0.0)
SQRT(1, _f, 4.0, 2.0)
SQRT(2, _f, 2.25, 1.5)
SQRT(3, _f, $Inf, $Inf)
USQRT(0, _f, $NaN, $NaN)
SQRT(0, _d, -0.0, 0.0)
SQRT(1, _d, 4.0, 2.0)
SQRT(2, _d, 2.25, 1.5)
SQRT(3, _d, $Inf, $Inf)
USQRT(0, _d, $NaN, $NaN)
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+169
View File
@@ -0,0 +1,169 @@
.data 16
ok:
.c "ok\n"
#define us12_i 0x1234
#define us7f_i 0x7ff7
#define us80_i 0x8008
#define usff_i 0xffff
#define ui12_i 0x01234567
#define ui7f_i 0x7f7ff7f7
#define ui80_i 0x80800808
#define uiff_i 0xffffffff
#define ul12_i 0x0123456789abcdef
#define ul7f_i 0x7f7f7f7ff7f7f7f7
#define ul80_i 0x8080808008080808
#define ulff_i 0xffffffffffffffff
#if __WORDSIZE == 32
# define xus12_i 0xffff1234
# define xus7f_i 0x10107ff7
# define xus80_i 0x81188008
# define xusff_i 0xeaaeffff
#else
# define xus12_i 0xffffffffffff1234
# define xus7f_i 0x1010100101017ff7
# define xus80_i 0x8181811818818008
# define xusff_i 0xeaeaeaaeaeaeffff
# define xui12_i 0xffffffff01234567
# define xui7f_i 0x101001017f7ff7f7
# define xui80_i 0x8181181880800808
# define xuiff_i 0xeaeaaeaeffffffff
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define us12_o 0x3412
# define us7f_o 0xf77f
# define us80_o 0x0880
# define usff_o 0xffff
# define ui12_o 0x67452301
# define ui7f_o 0xf7f77f7f
# define ui80_o 0x08088080
# define uiff_o 0xffffffff
# define ul12_o 0xefcdab8967452301
# define ul7f_o 0xf7f7f7f77f7f7f7f
# define ul80_o 0x0808080880808080
# define ulff_o 0xffffffffffffffff
#else
# define us12_o us12_i
# define us7f_o us7f_i
# define us80_o us80_i
# define usff_o usff_i
# define ui12_o ui12_i
# define ui7f_o ui7f_i
# define ui80_o ui80_i
# define uiff_o uiff_i
# define ul12_o ul12_i
# define ul7f_o ul7f_i
# define ul80_o ul80_i
# define ulff_o ulff_i
#endif
#define HTON4(I, O, T, R0, R1) \
movi %R0 I \
htonr_##T %R1 %R0 \
beqi T##R0##R1##I %R1 O \
calli @abort \
T##R0##R1##I:
#define HTON3(T, R0, R1) \
HTON4(T##12_i, T##12_o, T, R0, R1) \
HTON4(x##T##12_i, T##12_o, T, R0, R1) \
HTON4(T##7f_i, T##7f_o, T, R0, R1) \
HTON4(x##T##7f_i, T##7f_o, T, R0, R1) \
HTON4(T##80_i, T##80_o, T, R0, R1) \
HTON4(x##T##80_i, T##80_o, T, R0, R1) \
HTON4(T##ff_i, T##ff_o, T, R0, R1) \
HTON4(x##T##ff_i, T##ff_o, T, R0, R1)
#define HTON3x(T, R0, R1) \
HTON4(T##12_i, T##12_o, T, R0, R1) \
HTON4(T##7f_i, T##7f_o, T, R0, R1) \
HTON4(T##80_i, T##80_o, T, R0, R1) \
HTON4(T##ff_i, T##ff_o, T, R0, R1)
#define HTON2(T, V0, V1, V2, R0, R1, R2) \
HTON3(T, V0, V0) \
HTON3(T, V0, V1) \
HTON3(T, V0, V2) \
HTON3(T, V0, R0) \
HTON3(T, V0, R1) \
HTON3(T, V0, R2) \
#define HTON2x(T, V0, V1, V2, R0, R1, R2) \
HTON3x(T, V0, V0) \
HTON3x(T, V0, V1) \
HTON3x(T, V0, V2) \
HTON3x(T, V0, R0) \
HTON3x(T, V0, R1) \
HTON3x(T, V0, R2) \
#define HTON1(T, V0, V1, V2, R0, R1, R2) \
HTON2(T, V0, V1, V2, R0, R1, R2) \
HTON2(T, V1, V2, R0, R1, R2, V0) \
HTON2(T, V2, R0, R1, R2, V0, V1) \
HTON2(T, R0, R1, R2, V0, V1, V2) \
HTON2(T, R1, R2, V0, V1, V2, R0) \
HTON2(T, R2, V0, V1, V2, R0, R1)
#define HTON1x(T, V0, V1, V2, R0, R1, R2) \
HTON2x(T, V0, V1, V2, R0, R1, R2) \
HTON2x(T, V1, V2, R0, R1, R2, V0) \
HTON2x(T, V2, R0, R1, R2, V0, V1) \
HTON2x(T, R0, R1, R2, V0, V1, V2) \
HTON2x(T, R1, R2, V0, V1, V2, R0) \
HTON2x(T, R2, V0, V1, V2, R0, R1)
#if __WORDSIZE == 32
# define HTON(V0, V1, V2, R0, R1, R2) \
HTON1(us, V0, V1, V2, R0, R1, R2) \
HTON1x(ui, V0, V1, V2, R0, R1, R2)
#else
# define HTON(V0, V1, V2, R0, R1, R2) \
HTON1(us, V0, V1, V2, R0, R1, R2) \
HTON1(ui, V0, V1, V2, R0, R1, R2) \
HTON1x(ul, V0, V1, V2, R0, R1, R2)
#endif
.code
prolog
/* simple sequence for easier disassembly reading and encoding check */
movi %r0 us12_i
htonr_us %r1 %r0
beqi us %r1 us12_o
calli @abort
us:
movi %r0 xus12_i
htonr_us %r1 %r0
beqi xus %r1 us12_o
calli @abort
xus:
movi %r0 ui12_i
htonr_ui %r1 %r0
beqi ui %r1 ui12_o
calli @abort
ui:
#if __WORDSIZE == 64
movi %r0 xui12_i
htonr_ui %r1 %r0
beqi xui %r1 ui12_o
calli @abort
xui:
movi %r0 ul12_i
htonr_ul %r1 %r0
beqi ul %r1 ul12_o
calli @abort
ul:
#endif
HTON(v0, v1, v2, r0, r1, r2)
// just to know did not abort
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+66
View File
@@ -0,0 +1,66 @@
/*
This is a very simple check to a condition that on lightning 2.0.5
could cause an assertion on some backends, due to correcting a problem
with temporaries that could not be saved/reloaded due to being used only
in the hardware instruction, or being considered live for too long on the
lightning instruction, and that could not be reloaded after the jump target
(or after false/true target on conditional branches).
If this code in lib/lightning.c:_jit_update():
for (regno = 0; regno < _jitc->reglen; regno++) {
spec = jit_class(_rvs[regno].spec);
if (jit_regset_tstbit(mask, regno) &&
(spec & (jit_class_gpr|jit_class_fpr)) &&
!(spec & jit_class_sav))
jit_regset_clrbit(mask, regno);
}
were removed, this test case, on x86_64 would fail like this:
lt-lightning: lightning.c:305: _jit_get_reg: Assertion `regspec & 0x02000000' failed.
Aborted (core dumped)
*/
.data 32
ret:
#if __WORDSIZE == 32
.i 0
#else
.l 0
#endif
ok:
.c "ok"
.code
prolog
jmpi start
add_v1_v2:
addr %v1 %v1 %v2
ldi %r0 ret
jmpr %r0
start:
movi %v1 1
movi %v2 2
movi %r0 ret_add_v1_v2
sti ret %r0
movi %v0 add_v1_v2
jmpr %v0
movi_d %f0 3
beqi_d pass_movi_f0 %f0 3
calli @abort
pass_movi_f0:
beqi pass_check_v2 %v2 2
calli @abort
pass_check_v2:
ret_add_v1_v2:
beqi pass_add_v1_v2 %v1 3
calli @abort
pass_add_v1_v2:
prepare
pushargi ok
finishi @puts
ret
epilog
+102
View File
@@ -0,0 +1,102 @@
#if __WORDSIZE == 64
# define L0 0x8000000000000001
# define LL0 L0
# define LC0 0xffffffffffffff81
# define LS0 0xffffffffffff8001
# define LI0 0xffffffff80000001
# define L1 0x8000000000000000
# define LL1 L1
# define LC1 0xffffffffffffff80
# define LS1 0xffffffffffff8000
# define LI1 0xffffffff80000000
# define L2 0x7fffffffffffffff
# define LL2 L2
# define LC2 0x000000000000007f
# define LS2 0x0000000000007fff
# define LI2 0x000000007fffffff
# define L3 0xffffffffffffffff
# define LL3 L3
# define LC3 0xffffffffffffffff
# define LS3 0xffffffffffffffff
# define LI3 0xffffffffffffffff
# define XC LC0
# define XS LS0
# define XI LI0
#else
# define XC IC0
# define XS IS0
# define XI II0
#endif
#define I0 0x80000001
#define II0 I0
#define IC0 0xffffff81
#define IS0 0xffff8001
#define I1 0x80000000
#define II1 I1
#define IC1 0xffffff80
#define IS1 0xffff8000
#define I2 0x7fffffff
#define II2 I2
#define IC2 0x0000007f
#define IS2 0x00007fff
#define I3 0xffffffff
#define II3 I3
#define IC3 0xffffffff
#define IS3 0xffffffff
#define S0 0x8001
#define S1 0x8000
#define S2 0x7fff
#define S3 0xffff
#define C0 0x81
#define C1 0x80
#define C2 0x7f
#define C3 0xff
#define F0 0.25
#define F1 0.75
#define F2 -0.25
#define F3 -0.75
#define D0 0.25
#define D1 0.75
#define D2 -0.25
#define D3 -0.75
.data 512
ok:
.c "ok\n"
.align 8
t0:
c0:
.c 0
uc0:
.c 0
s0:
.s 0
us0:
.s 0
.align 4
i0:
.i 0
#if __WORDSIZE == 64
ui0:
.i 0
.align 8
l0:
.l 0
#endif
f0:
.f 0
.align 8
d0:
.d 0
. $($offc = c0 - t0)
. $($offuc = uc0 - t0)
. $($offs = s0 - t0)
. $($offus = us0 - t0)
. $($offi = i0 - t0)
#if __WORDSIZE == 64
. $($offui = ui0 - t0)
. $($offl = l0 - t0)
#endif
. $($offf = f0 - t0)
. $($offd = d0 - t0)
+1
View File
@@ -0,0 +1 @@
ok
+146
View File
@@ -0,0 +1,146 @@
#include "ldst.inc"
#if __WORDSIZE == 64
# define LDSTL(N, R0) \
sti_i ui0 %R0 \
movi %R0 L##N \
sti_l l0 %R0
# define SI(C, N, x, X, R0) \
ldi_##x %R0 x##0 \
beqi L##x##C %R0 L##X##N \
calli @abort \
L##x##C:
# define LDRL(C, N, R0) \
UI(C, N, i, I, R0) \
SI(C, N, l, L, R0)
#else
# define LDSTL(C, R0)
# define SI(C, N, x, X, R0) \
ldi_##x %R0 x##0 \
beqi L##x##C %R0 I##X##N \
calli @abort \
L##x##C:
# define LDRL(C, N, R0)
#endif
#define UI(C, N, x, X, R0) \
ldi_u##x %R0 u##x##0 \
beqi Lu##x##C %R0 X##N \
calli @abort \
Lu##x##C:
#define FF(C, N, x, X, F0) \
ldi_##x %F0 x##0 \
beqi_##x L##x##C %F0 X##N \
L##x##C:
#define LDST1(X, N, R0, F0) \
movi %R0 C##N \
sti_c c0 %R0 \
sti_c uc0 %R0 \
movi %R0 S##N \
sti_s s0 %R0 \
sti_s us0 %R0 \
movi %R0 I##N \
sti_i i0 %R0 \
LDSTL(N, R0) \
movi_f %F0 F##N \
sti_f f0 %F0 \
movi_d %F0 D##N \
sti_d d0 %F0 \
SI(X, N, c, C, R0) \
UI(X, N, c, C, R0) \
SI(X, N, s, S, R0) \
UI(X, N, s, S, R0) \
SI(X, N, i, I, R0) \
LDRL(X, N, R0) \
FF(X, N, f, F, F0) \
FF(X, N, d, D, F0)
#define LDST0(R0, F0) \
LDST1(0_##R0##_##F0, 0, R0, F0) \
LDST1(1_##R0##_##F0, 1, R0, F0) \
LDST1(2_##R0##_##F0, 2, R0, F0) \
LDST1(3_##R0##_##F0, 3, R0, F0)
#define LDST(V0, V1, V2, R0, R1, R2, F0, F1, F2, F3, F4, F5) \
LDST0(V0, F0) \
LDST0(V1, F1) \
LDST0(V2, F3) \
LDST0(R0, F4) \
LDST0(R1, F5) \
LDST0(R2, F0)
.code
prolog
/* Simple test to simplify validating encodings before
* brute force tests */
movi %r1 0x81
sti_c c0 %r1
sti_c uc0 %r1
movi %r1 0x8001
sti_s s0 %r1
sti_s us0 %r1
movi %r1 0x80000001
sti_i i0 %r1
#if __WORDSIZE == 64
sti_i ui0 %r1
movi %r1 0x8000000000000001
sti_l l0 %r1
#endif
movi_f %f0 0.5
sti_f f0 %f0
movi_d %f0 0.25
sti_d d0 %f0
ldi_c %r1 c0
beqi Lc %r1 XC
calli @abort
Lc:
ldi_uc %r1 uc0
beqi Luc %r1 0x81
calli @abort
Luc:
ldi_s %r1 s0
beqi Ls %r1 XS
calli @abort
Ls:
ldi_us %r1 us0
beqi Lus %r1 0x8001
calli @abort
Lus:
ldi_i %r1 i0
beqi Li %r1 XI
calli @abort
Li:
#if __WORDSIZE == 64
ldi_ui %r1 ui0
beqi Lui %r1 0x80000001
calli @abort
Lui:
ldi_l %r1 l0
beqi Ll %r1 0x8000000000000001
calli @abort
Ll:
#endif
ldi_f %f0 f0
beqi_f Lf %f0 0.5
calli @abort
Lf:
ldi_d %f0 d0
beqi_d Ld %f0 0.25
calli @abort
Ld:
LDST(v0, v1, v2, r0, r1, r2, f0, f1, f2, f3, f4, f5)
// just to know did not abort
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
+155
View File
@@ -0,0 +1,155 @@
#include "ldst.inc"
#if __WORDSIZE == 64
# define LDSTL(N, R0, R1) \
movi %R0 $(t0 + $offui) \
str_i %R0 %R1 \
movi %R0 $(t0 + $offl) \
movi %R1 L##N \
str_l %R0 %R1
# define SI(C, N, x, X, R0) \
movi %R0 $(t0 + $off##x) \
ldr_##x %R0 %R0 \
beqi L##x##C %R0 L##X##N \
calli @abort \
L##x##C:
# define LDRL(C, N, R0, R1) \
UI(C, N, i, I, R0) \
SI(C, N, l, L, R0)
#else
# define LDSTL(C, R0, R1)
# define SI(C, N, x, X, R0) \
movi %R0 $(t0 + $off##x) \
ldr_##x %R0 %R0 \
beqi L##x##C %R0 I##X##N \
calli @abort \
L##x##C:
# define LDRL(C, N, R0, R1)
#endif
#define UI(C, N, x, X, R0) \
movi %R0 $(t0 + $offu##x) \
ldr_u##x %R0 %R0 \
beqi Lu##x##C %R0 X##N \
calli @abort \
Lu##x##C:
#define LDST1(X, N, R0, R1) \
movi %R0 $(t0 + $offc) \
movi %R1 C##N \
str_c %R0 %R1 \
movi %R0 $(t0 + $offuc) \
str_c %R0 %R1 \
movi %R0 $(t0 + $offs) \
movi %R1 S##N \
str_s %R0 %R1 \
movi %R0 $(t0 + $offus) \
str_s %R0 %R1 \
movi %R0 $(t0 + $offi) \
movi %R1 I##N \
str_i %R0 %R1 \
LDSTL(N, R0, R1) \
movi %R0 $(t0 + $offf) \
SI(X, N, c, C, R0) \
UI(X, N, c, C, R0) \
SI(X, N, s, S, R0) \
UI(X, N, s, S, R0) \
SI(X, N, i, I, R0) \
LDRL(X, N, R0, R1) \
#define LDST0(R0, R1) \
LDST1(0_##R0##_##R1, 0, R0, R1) \
LDST1(1_##R0##_##R1, 1, R0, R1) \
LDST1(2_##R0##_##R1, 2, R0, R1) \
LDST1(3_##R0##_##R1, 3, R0, R1)
#define LDST(V0, V1, V2, R0, R1, R2) \
LDST0(V0, V1) \
LDST0(V0, V2) \
LDST0(V0, R0) \
LDST0(V0, R1) \
LDST0(V0, R2) \
LDST0(V1, V0) \
LDST0(V1, V2) \
LDST0(V1, R0) \
LDST0(V1, R1) \
LDST0(V1, R2) \
LDST0(V2, R0) \
LDST0(V2, R1) \
LDST0(V2, R2)
.code
prolog
/* Simple test to simplify validating encodings before
* brute force tests */
movi %r0 $(t0 + $offc)
movi %r1 0x81
str_c %r0 %r1
movi %r0 $(t0 + $offuc)
str_c %r0 %r1
movi %r0 $(t0 + $offs)
movi %r1 0x8001
str_s %r0 %r1
movi %r0 $(t0 + $offus)
str_s %r0 %r1
movi %r0 $(t0 + $offi)
movi %r1 0x80000001
str_i %r0 %r1
#if __WORDSIZE == 64
movi %r0 $(t0 + $offui)
str_i %r0 %r1
movi %r0 $(t0 + $offl)
movi %r1 0x8000000000000001
str_l %r0 %r1
#endif
movi %r0 $(t0 + $offc)
ldr_c %r0 %r0
beqi Lc %r0 XC
calli @abort
Lc:
movi %r0 $(t0 + $offuc)
ldr_uc %r0 %r0
beqi Luc %r0 0x81
calli @abort
Luc:
movi %r0 $(t0 + $offs)
ldr_s %r0 %r0
beqi Ls %r0 XS
calli @abort
Ls:
movi %r0 $(t0 + $offus)
ldr_us %r0 %r0
beqi Lus %r0 0x8001
calli @abort
Lus:
movi %r0 $(t0 + $offi)
ldr_i %r0 %r0
beqi Li %r0 XI
calli @abort
Li:
#if __WORDSIZE == 64
movi %r0 $(t0 + $offui)
ldr_ui %r0 %r0
beqi Lui %r0 0x80000001
calli @abort
Lui:
movi %r0 $(t0 + $offl)
ldr_l %r0 %r0
beqi Ll %r0 0x8000000000000001
calli @abort
Ll:
#endif
LDST(v0, v1, v2, r0, r1, r2)
// just to know did not abort
prepare
pushargi ok
ellipsis
finishi @printf
ret
epilog
+1
View File
@@ -0,0 +1 @@
ok
Loaded 100 of 377 files, more files were not shown because too many files have changed in this diff. Show more