diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..499f720a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +.travis.yml export-ignore diff --git a/.hgignore b/.hgignore deleted file mode 100644 index 083d8a63..00000000 --- a/.hgignore +++ /dev/null @@ -1,51 +0,0 @@ -syntax: glob -*.bc -*.diff -*.o -*.obj -*.orig -*.patch -*.a -*.s -*.so -*.swp -*.rej -*~ -Makefile -CMakeFiles -CMakeCache.txt -cmake_install.cmake -.DS_Store -CMakeLists.txt.user* -.directory -druntime -phobos -druntime-orig -phobos-orig - -syntax: regexp -^obj/ -^tests/dstress/ -^tests/reference/ -^tango/ -^druntime/ -^phobos/ -^import/ -^bin/ldc2?$ -^bin/ldc2?\.conf$ -^bin/ldc2?\.rebuild\.conf$ -^idgen\.make$ -^impcnvgen\.make$ -^ldc\.make$ -^revisions\.pl$ -^gen/revisions\.h$ -^gen/llvm-version\.h$ -^dmd2?/idgen$ -^dmd2?/impcnvgen$ -^dmd2?/impcnvtab\.c$ -^dmd2?/id\.c$ -^dmd2?/id\.h$ -^tests/runminitest$ -^tests/findregressions$ -^tests/makewebstatistics$ -^tests/mini/obj/ diff --git a/LICENSE b/LICENSE index ca6bb677..55b9e450 100644 --- a/LICENSE +++ b/LICENSE @@ -1,38 +1,1020 @@ -LDC is released under the "three-clause BSD" license reproduced below with +Overview +======== + +LDC is released under the "three-clause BSD" LDC license reproduced below, with the following exceptions: -The DMD frontend in dmd/* is originally written by Walter Bright and released -under the artistic license (dmd/artistic.txt) or the GPL version 1 (dmd/gpl.txt). +Compiler (bin/ in binary packages): + - LDC uses the DMD frontend (dmd/* and dmd2/* in source code distributions), + which was originally written by Walter Bright and is released under the + Artistic license or the GPL version 1. LDMD (driver/ldmd.cpp) and the RTTI + handling code (gen/typinf.cpp) are also partly derived from DMD. -The files gen/asmstmt.cpp and gen/asm-*.h were originally written by David -Friedman for GDC and released under the artistic license (dmd/artistic.txt) or -the GPL version 2 or later. + - LDC incorporates code (gen/asmstmt.cpp and gen/asm-*.h) originally written + by David Friedman for GDC and released under the Artistic license or the + GPL version 2 or later. + + - LDC uses the libconfig++ library under the terms of the GNU LGPL 2.1. + + - The LDC project makes use of the LLVM framework, which is govenered by the + University of Illinois Open Source License. A few LDC source files directly + incorporate code derived from LLVM, see the file headers for details. + +Libraries (lib/ and import/ in binary packages): + - The D standard library, comprised of druntime (runtime/druntime) and + Phobos (runtime/phobos), is distributed under the terms of the Boost + Software License. See the individual source files for author information. --- "three-clause BSD" -- -Copyright (c) 2007-2009 LDC Team. +Full license texts +================== + +-- LDC license ----------------------------------------------------------------- + +Copyright (c) 2007-2012 LDC Team. All rights reserved. -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - * Neither the name of the LDC Team nor the names of its contributors may be - used to endorse or promote products derived from this software without specific + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the LDC Team nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +-- Runtime library license ----------------------------------------------------- + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + + +-- LLVM license ---------------------------------------------------------------- + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2012 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + + +-- DMD license ----------------------------------------------------------------- + +Copyright (c) 1999-2012 by Digital Mars written by Walter Bright. + +DMD is released under the terms of the Artistic license or the GNU General +Public License, version 1. + +-- + The "Artistic License" + + Preamble + +The intent of this document is to state the conditions under which a +Package may be copied, such that the Copyright Holder maintains some +semblance of artistic control over the development of the package, +while giving the users of the package the right to use and distribute +the Package in a more-or-less customary fashion, plus the right to make +reasonable modifications. + +Definitions: + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and +when you changed that file, and provided that you do at least ONE of the +following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as uunet.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) give non-standard executables non-standard names, and clearly + document the differences in manual pages (or equivalent), together + with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this +Package. You may not charge a fee for this Package itself. However, +you may distribute this Package in aggregate with other (possibly +commercial) programs as part of a larger (possibly commercial) software +distribution provided that you do not advertise this Package as a +product of your own. You may embed this Package's interpreter within +an executable of yours (by linking); this shall be construed as a mere +form of aggregation, provided that the complete Standard Version of the +interpreter is so embedded. + +6. The source code and object code supplied as input to or produced as +output from the programs of this Package do not automatically fall +under the copyright of this Package, but belong to whoever generated +them, and may be sold commercially, and may be aggregated with this +Package. + +7. Aggregation of this Package with a commercial distribution is always +permitted provided that the use of this Package is embedded; that is, +when no overt attempt is made to make this Package's interfaces visible +to the end user of the commercial distribution. Such use shall not be +construed as a distribution of this Package. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End +--- + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute 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 and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + + 7. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + END OF TERMS AND CONDITIONS + + + Appendix: 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 humanity, 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 convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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 1, 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision 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, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + + +-- libconfig license ----------------------------------------------------------- + +Copyright (C) 2005-2010 Mark A Lindner + +-- + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 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. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. 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 not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the 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 +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library 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 2 of the License, or (at your option) any later version. + + This library 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. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/README b/README index b65fd7cb..ba19f8a5 100644 --- a/README +++ b/README @@ -10,8 +10,8 @@ and relies on the LLVM Core libraries for code generation. LDC is fully Open Source; the parts of the code not taken/adapted from other projects are BSD-licensed (see the LICENSE file for details). -Please consult the project website for further information: -http://ldc-developers.github.com +Please consult the D wiki for further information: +http://wiki.dlang.org/LDC Installation @@ -20,14 +20,14 @@ Installation In-depth material on building and installing LDC and the standard libraries, including experimental instructions for running LDC on Windows, is available on the project wiki, at -https://github.com/ldc-developers/ldc/wiki/Installation. +http://wiki.dlang.org/Building_LDC_from_source. For the impatient, a quick guide for building on *nix systems: 1) Make sure your system has the necessary prerequisites: - a working C++ build environment, - CMake, - - LLVM 3.0+ (3.1 preferred), + - LLVM 3.0+ (3.2 preferred), - libconfig++ (http://hyperrealm.com/libconfig/libconfig.html). 2) Check out the library submodules, if you have not already: @@ -51,8 +51,10 @@ Contact ------- The best way to get in touch with the developers is either via the -mailing list at ldc-dev@googlegroups.com, or the #ldc IRC channel on -FreeNode. We can usually be found on the main (Digital Mars) language -newsgroups (http://forum.dlang.org) as well. +digitalmars.D.ldc forum/newsgroup/mailing list (http://forum.dlang.org) +or the #ldc IRC channel on FreeNode. + +For further documentation, contributor information, etc. please see the +D wiki: http://wiki.dlang.org/LDC Feedback of any kind is very much appreciated! diff --git a/dmd/dsymbol.c b/dmd/dsymbol.c index fe727ab5..6b60124f 100644 --- a/dmd/dsymbol.c +++ b/dmd/dsymbol.c @@ -53,7 +53,6 @@ Dsymbol::Dsymbol() this->errors = false; #if IN_LLVM this->llvmInternal = LLVMnone; - this->irsym = NULL; #endif } @@ -73,7 +72,6 @@ Dsymbol::Dsymbol(Identifier *ident) this->errors = false; #if IN_LLVM this->llvmInternal = LLVMnone; - this->irsym = NULL; #endif } diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index 77c03810..4c5a4538 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -97,7 +97,6 @@ struct Classsym; #if IN_LLVM class Ir; -class IrSymbol; namespace llvm { class Value; @@ -284,7 +283,6 @@ struct Dsymbol : Object int llvmInternal; IrDsymbol ir; - IrSymbol* irsym; #endif }; diff --git a/dmd/mars.c b/dmd/mars.c index 77483466..15c0281a 100644 --- a/dmd/mars.c +++ b/dmd/mars.c @@ -71,7 +71,7 @@ Global::Global() copyright = "Copyright (c) 1999-2012 by Digital Mars and Tomas Lindquist Olsen"; written = "written by Walter Bright and Tomas Lindquist Olsen"; version = "v1.075"; - ldc_version = "LDC trunk"; + ldc_version = "trunk"; llvm_version = "LLVM "LDC_LLVM_VERSION_STRING; global.structalign = STRUCTALIGN_DEFAULT; diff --git a/dmd2/dsymbol.c b/dmd2/dsymbol.c index fdc799ed..2228feb5 100644 --- a/dmd2/dsymbol.c +++ b/dmd2/dsymbol.c @@ -54,7 +54,6 @@ Dsymbol::Dsymbol() #if IN_LLVM this->llvmInternal = LLVMnone; - this->irsym = NULL; #endif } @@ -75,7 +74,6 @@ Dsymbol::Dsymbol(Identifier *ident) #if IN_LLVM this->llvmInternal = LLVMnone; - this->irsym = NULL; #endif } diff --git a/dmd2/dsymbol.h b/dmd2/dsymbol.h index 47f97f2a..28b3fa60 100644 --- a/dmd2/dsymbol.h +++ b/dmd2/dsymbol.h @@ -99,7 +99,6 @@ struct TYPE; #if IN_LLVM class Ir; -class IrSymbol; namespace llvm { class Value; @@ -290,7 +289,6 @@ struct Dsymbol : Object int llvmInternal; IrDsymbol ir; - IrSymbol* irsym; #endif }; diff --git a/dmd2/mars.c b/dmd2/mars.c index 607c2964..67280066 100644 --- a/dmd2/mars.c +++ b/dmd2/mars.c @@ -101,7 +101,7 @@ Global::Global() ; version = "v2.060"; #if IN_LLVM - ldc_version = "LDC trunk"; + ldc_version = "trunk"; llvm_version = "LLVM "LDC_LLVM_VERSION_STRING; #endif global.structalign = STRUCTALIGN_DEFAULT; diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp index 0a10e807..1f3ccd93 100644 --- a/driver/cl_options.cpp +++ b/driver/cl_options.cpp @@ -1,3 +1,12 @@ +//===-- cl_options.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "driver/cl_options.h" #include "gen/cl_helpers.h" @@ -249,7 +258,7 @@ static cl::list linkerSwitches("L", cl::opt moduleDepsFile("deps", cl::desc("Write module dependencies to filename"), cl::value_desc("filename")); - + cl::opt mArch("march", cl::desc("Architecture to generate code for:")); diff --git a/driver/cl_options.h b/driver/cl_options.h index 2fed81b0..ca9b657f 100644 --- a/driver/cl_options.h +++ b/driver/cl_options.h @@ -1,3 +1,17 @@ +//===-- driver/cl_options.h - LDC command line options ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Defines the LDC command line options as handled using the LLVM command +// line parsing library. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_CL_OPTIONS_H #define LDC_CL_OPTIONS_H diff --git a/driver/configfile.cpp b/driver/configfile.cpp index 25f3440e..1af2f525 100644 --- a/driver/configfile.cpp +++ b/driver/configfile.cpp @@ -1,3 +1,12 @@ +//===-- configfile.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include #include #include diff --git a/driver/configfile.h b/driver/configfile.h index 95a6fa2a..9465a877 100644 --- a/driver/configfile.h +++ b/driver/configfile.h @@ -1,3 +1,16 @@ +//===-- driver/configfile.h - LDC config file handling ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Handles reading and parsing of an LDC config file (ldc.conf/ldc2.conf). +// +//===----------------------------------------------------------------------===// + #ifndef LDC_CONF_CONFIGFILE_H #define LDC_CONF_CONFIGFILE_H diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp index e506a921..0b731ed2 100644 --- a/driver/ldmd.cpp +++ b/driver/ldmd.cpp @@ -1,11 +1,15 @@ -/** - * Wrapper allowing use of LDC as drop-in replacement for DMD. - * - * Copyright (c) 2012 by the LDC Team. - * - * Command line parsing code originally - * Copyright (c) 1999-2012 by Digital Mars. - */ +//===-- ldmd.cpp - Drop-in DMD replacement wrapper for LDC ----------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license, except for the +// command line handling code, which originated from DMD. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Wrapper allowing use of LDC as drop-in replacement for DMD. +// // The reason why full command line parsing is required instead of just // rewriting the names of a few switches is an annoying impedance mismatch // between the way how DMD handles arguments and the LLVM command line library: @@ -37,6 +41,8 @@ // Note: This program inherited ugly C-style string handling and memory leaks // from DMD, but this should not be a problem due to the short-livedness of // the process. +// +//===----------------------------------------------------------------------===// #ifndef LDC_EXE_NAME # error "Please define LDC_EXE_NAME to the name of the LDC executable to use." @@ -147,9 +153,9 @@ Usage:\n\ @cmdfile read arguments from cmdfile\n\ -c do not link\n" #if 0 - "-cov do code coverage analysis\n" +" -cov do code coverage analysis\n" #endif - "-D generate documentation\n\ +" -D generate documentation\n\ -Dddocdir write documentation file to docdir directory\n\ -Dffilename write documentation file to filename\n\ -d allow deprecated features\n\ @@ -177,7 +183,7 @@ Usage:\n\ -m64 generate 64 bit code\n\ -man open web browser on manual page\n" #if 0 - "-map generate linker .map file\n" +" -map generate linker .map file\n" #endif #if DMDV2 " -noboundscheck turns off array bounds checking for all functions\n" @@ -189,9 +195,9 @@ Usage:\n\ -offilename name output file to filename\n\ -op do not strip paths from source file\n" #if 0 - "-profile profile runtime performance of generated code\n" +" -profile profile runtime performance of generated code\n" #endif - "-property enforce property syntax\n\ +" -property enforce property syntax\n\ -quiet suppress unnecessary messages\n\ -release compile release version\n\ -run srcfile args... run resulting program, passing args\n\ diff --git a/driver/linker.cpp b/driver/linker.cpp index 381dad36..71e068a6 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -1,3 +1,12 @@ +//===-- linker.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "llvm/Linker.h" #include "llvm/ADT/Triple.h" diff --git a/driver/linker.h b/driver/linker.h index e2844732..d5220224 100644 --- a/driver/linker.h +++ b/driver/linker.h @@ -1,3 +1,17 @@ +//===-- driver/linker.h - Linker invocation ---------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Handles locating and executing the system linker for generating +// libraries/executables. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_LINKER_H #define LDC_GEN_LINKER_H diff --git a/driver/main.cpp b/driver/main.cpp index db382d60..0af27ca2 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -1,7 +1,11 @@ -// Pulled out of dmd/mars.c - -// some things are taken from llvm's llc tool -// which uses the llvm license +//===-- main.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// #include "gen/llvmcompat.h" #include "gen/llvm.h" @@ -86,15 +90,13 @@ static cl::list debuglibs("debuglib", cl::CommaSeparated); void printVersion() { - printf("LLVM D Compiler %s\nbased on DMD %s and %s\n%s\n%s\n", - global.ldc_version, global.version, global.llvm_version, global.copyright, global.written); - printf("D Language Documentation: http://d-programming-language.org/index.html\n" - "LDC Homepage: https://github.com/ldc-developers/ldc\n"); - printf("\n"); + printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version); + printf(" based on DMD %s and %s\n", global.version, global.llvm_version); printf(" Default target: %s\n", llvm::sys::getDefaultTargetTriple().c_str()); std::string CPU = llvm::sys::getHostCPUName(); if (CPU == "generic") CPU = "(unknown)"; printf(" Host CPU: %s\n", CPU.c_str()); + printf(" http://dlang.org - http://wiki.dlang.org/LDC\n"); printf("\n"); // Without explicitly flushing here, only the target list is visible when @@ -238,11 +240,12 @@ int main(int argc, char** argv) // Handle fixed-up arguments! cl::SetVersionPrinter(&printVersion); -#if LDC_LLVM_VER >= 302 - cl::ParseCommandLineOptions(final_args.size(), const_cast(&final_args[0]), "LLVM-based D Compiler\n"); -#else - cl::ParseCommandLineOptions(final_args.size(), const_cast(&final_args[0]), "LLVM-based D Compiler\n", true); + cl::ParseCommandLineOptions(final_args.size(), const_cast(&final_args[0]), + "LDC - the LLVM D compiler\n" +#if LDC_LLVM_VER < 302 + , true #endif + ); // Print config file path if -v was passed if (global.params.verbose) { diff --git a/driver/toobj.cpp b/driver/toobj.cpp index a7047651..3e084a7b 100644 --- a/driver/toobj.cpp +++ b/driver/toobj.cpp @@ -1,153 +1,153 @@ - -// Copyright (c) 1999-2004 by Digital Mars -// All Rights Reserved -// written by Walter Bright -// www.digitalmars.com -// License for redistribution is by either the Artistic License -// in artistic.txt, or the GNU General Public License in gnu.txt. -// See the included readme.txt for details. - -#include -#include - -#include "llvm/Analysis/Verifier.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Module.h" -#include "llvm/PassManager.h" -#include "llvm/Support/Program.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Target/TargetMachine.h" - -#include "gen/irstate.h" -#include "gen/logger.h" -#include "gen/optimizer.h" - - -// fwd decl -void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out, - llvm::TargetMachine::CodeGenFileType fileType); - -////////////////////////////////////////////////////////////////////////////////////////// - -void writeModule(llvm::Module* m, std::string filename) -{ - // run optimizer - ldc_optimize_module(m); - - // eventually do our own path stuff, dmd's is a bit strange. - typedef llvm::sys::Path LLPath; - - // write LLVM bitcode - if (global.params.output_bc) { - LLPath bcpath = LLPath(filename); - bcpath.eraseSuffix(); - bcpath.appendSuffix(std::string(global.bc_ext)); - Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str()); - std::string errinfo; - llvm::raw_fd_ostream bos(bcpath.c_str(), errinfo, llvm::raw_fd_ostream::F_Binary); - if (bos.has_error()) - { - error("cannot write LLVM bitcode file '%s': %s", bcpath.c_str(), errinfo.c_str()); - fatal(); - } - llvm::WriteBitcodeToFile(m, bos); - } - - // write LLVM IR - if (global.params.output_ll) { - LLPath llpath = LLPath(filename); - llpath.eraseSuffix(); - llpath.appendSuffix(std::string(global.ll_ext)); - Logger::println("Writing LLVM asm to: %s\n", llpath.c_str()); - std::string errinfo; - llvm::raw_fd_ostream aos(llpath.c_str(), errinfo); - if (aos.has_error()) - { - error("cannot write LLVM asm file '%s': %s", llpath.c_str(), errinfo.c_str()); - fatal(); - } - m->print(aos, NULL); - } - - // write native assembly - if (global.params.output_s) { - LLPath spath = LLPath(filename); - spath.eraseSuffix(); - spath.appendSuffix(std::string(global.s_ext)); - Logger::println("Writing native asm to: %s\n", spath.c_str()); - std::string err; - { - llvm::raw_fd_ostream out(spath.c_str(), err); - if (err.empty()) - { - emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_AssemblyFile); - } - else - { - error("cannot write native asm: %s", err.c_str()); - fatal(); - } - } - } - - if (global.params.output_o) { - LLPath objpath = LLPath(filename); - Logger::println("Writing object file to: %s\n", objpath.c_str()); - std::string err; - { - llvm::raw_fd_ostream out(objpath.c_str(), err, llvm::raw_fd_ostream::F_Binary); - if (err.empty()) - { - emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile); - } - else - { - error("cannot write object file: %s", err.c_str()); - fatal(); - } - } - } -} - -/* ================================================================== */ - -// based on llc code, University of Illinois Open Source License -void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& out, - llvm::TargetMachine::CodeGenFileType fileType) -{ - using namespace llvm; - - // Build up all of the passes that we want to do to the module. - FunctionPassManager Passes(&m); - +//===-- toobj.cpp ---------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + +#include +#include + +#include "llvm/Analysis/Verifier.h" +#include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/Module.h" +#include "llvm/PassManager.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Target/TargetMachine.h" + +#include "gen/irstate.h" +#include "gen/logger.h" +#include "gen/optimizer.h" + + +// fwd decl +void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out, + llvm::TargetMachine::CodeGenFileType fileType); + +////////////////////////////////////////////////////////////////////////////////////////// + +void writeModule(llvm::Module* m, std::string filename) +{ + // run optimizer + ldc_optimize_module(m); + + // eventually do our own path stuff, dmd's is a bit strange. + typedef llvm::sys::Path LLPath; + + // write LLVM bitcode + if (global.params.output_bc) { + LLPath bcpath = LLPath(filename); + bcpath.eraseSuffix(); + bcpath.appendSuffix(std::string(global.bc_ext)); + Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str()); + std::string errinfo; + llvm::raw_fd_ostream bos(bcpath.c_str(), errinfo, llvm::raw_fd_ostream::F_Binary); + if (bos.has_error()) + { + error("cannot write LLVM bitcode file '%s': %s", bcpath.c_str(), errinfo.c_str()); + fatal(); + } + llvm::WriteBitcodeToFile(m, bos); + } + + // write LLVM IR + if (global.params.output_ll) { + LLPath llpath = LLPath(filename); + llpath.eraseSuffix(); + llpath.appendSuffix(std::string(global.ll_ext)); + Logger::println("Writing LLVM asm to: %s\n", llpath.c_str()); + std::string errinfo; + llvm::raw_fd_ostream aos(llpath.c_str(), errinfo); + if (aos.has_error()) + { + error("cannot write LLVM asm file '%s': %s", llpath.c_str(), errinfo.c_str()); + fatal(); + } + m->print(aos, NULL); + } + + // write native assembly + if (global.params.output_s) { + LLPath spath = LLPath(filename); + spath.eraseSuffix(); + spath.appendSuffix(std::string(global.s_ext)); + Logger::println("Writing native asm to: %s\n", spath.c_str()); + std::string err; + { + llvm::raw_fd_ostream out(spath.c_str(), err); + if (err.empty()) + { + emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_AssemblyFile); + } + else + { + error("cannot write native asm: %s", err.c_str()); + fatal(); + } + } + } + + if (global.params.output_o) { + LLPath objpath = LLPath(filename); + Logger::println("Writing object file to: %s\n", objpath.c_str()); + std::string err; + { + llvm::raw_fd_ostream out(objpath.c_str(), err, llvm::raw_fd_ostream::F_Binary); + if (err.empty()) + { + emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile); + } + else + { + error("cannot write object file: %s", err.c_str()); + fatal(); + } + } + } +} + +/* ================================================================== */ + +// based on llc code, University of Illinois Open Source License +void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& out, + llvm::TargetMachine::CodeGenFileType fileType) +{ + using namespace llvm; + + // Build up all of the passes that we want to do to the module. + FunctionPassManager Passes(&m); + #if LDC_LLVM_VER >= 302 if (const DataLayout *DL = Target.getDataLayout()) Passes.add(new DataLayout(*DL)); else Passes.add(new DataLayout(&m)); #else - if (const TargetData *TD = Target.getTargetData()) - Passes.add(new TargetData(*TD)); - else - Passes.add(new TargetData(&m)); + if (const TargetData *TD = Target.getTargetData()) + Passes.add(new TargetData(*TD)); + else + Passes.add(new TargetData(&m)); #endif - - llvm::formatted_raw_ostream fout(out); - if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel())) - assert(0 && "no support for asm output"); - - Passes.doInitialization(); - - // Run our queue of passes all at once now, efficiently. - for (llvm::Module::iterator I = m.begin(), E = m.end(); I != E; ++I) - if (!I->isDeclaration()) - Passes.run(*I); - - Passes.doFinalization(); - - // release module from module provider so we can delete it ourselves - //std::string Err; - //llvm::Module* rmod = Provider.releaseModule(&Err); - //assert(rmod); -} + + llvm::formatted_raw_ostream fout(out); + if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel())) + assert(0 && "no support for asm output"); + + Passes.doInitialization(); + + // Run our queue of passes all at once now, efficiently. + for (llvm::Module::iterator I = m.begin(), E = m.end(); I != E; ++I) + if (!I->isDeclaration()) + Passes.run(*I); + + Passes.doFinalization(); + + // release module from module provider so we can delete it ourselves + //std::string Err; + //llvm::Module* rmod = Provider.releaseModule(&Err); + //assert(rmod); +} diff --git a/driver/toobj.h b/driver/toobj.h index ecc4c0a5..bae370d8 100644 --- a/driver/toobj.h +++ b/driver/toobj.h @@ -1,3 +1,16 @@ +//===-- driver/toobj.h - Object file emission -------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Handles emission of "finished" LLVM modules to on-disk object files. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_TOOBJ_H #define LDC_GEN_TOOBJ_H diff --git a/gen/aa.cpp b/gen/aa.cpp index 1fc02f86..bc4d6927 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -1,3 +1,12 @@ +//===-- aa.cpp ------------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mtype.h" @@ -78,7 +87,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) if (lvalue) { // valuesize param LLValue* valsize = DtoConstSize_t(getTypePaddedSize(DtoType(type))); - + ret = gIR->CreateCallOrInvoke4(func, aaval, keyti, valsize, pkey, "aa.index").getInstruction(); } else { ret = gIR->CreateCallOrInvoke3(func, aaval, keyti, pkey, "aa.index").getInstruction(); @@ -266,7 +275,7 @@ LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r) #else llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEq"); LLFunctionType* funcTy = func->getFunctionType(); - + LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(0)); LLValue* abval = DtoBitCast(r->getRVal(), funcTy->getParamType(1)); LLValue* aaTypeInfo = DtoTypeInfoOf(t); diff --git a/gen/aa.h b/gen/aa.h index d5e72eb5..0154f302 100644 --- a/gen/aa.h +++ b/gen/aa.h @@ -1,3 +1,17 @@ +//===-- gen/aa.h - Associative array codegen helpers ------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Helpers for generating calls to associative array runtime functions. +// +//===----------------------------------------------------------------------===// + + #ifndef LDC_GEN_AA_H #define LDC_GEN_AA_H diff --git a/gen/abi-generic.h b/gen/abi-generic.h index b104c143..b77fca44 100644 --- a/gen/abi-generic.h +++ b/gen/abi-generic.h @@ -1,3 +1,16 @@ +//===-- gen/abi-generic.h - Generic Target ABI helpers ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Contains helpers for handling rewrites common to more than one target ABI. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_ABI_GENERIC #define LDC_GEN_ABI_GENERIC diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index fa9b7c96..547fa374 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -1,30 +1,37 @@ -/* TargetABI implementation for x86-64. - * Written for LDC by Frits van Bommel in 2009. - * - * extern(C) implements the C calling convention for x86-64, as found in - * http://www.x86-64.org/documentation/abi-0.99.pdf - * - * Note: - * Where a discrepancy was found between llvm-gcc and the ABI documentation, - * llvm-gcc behavior was used for compatibility (after it was verified that - * regular gcc has the same behavior). - * - * LLVM gets it right for most types, but complex numbers and structs need some - * help. To make sure it gets those right we essentially bitcast small structs - * to a type to which LLVM assigns the appropriate registers, and pass that - * instead. Structs that are required to be passed in memory are explicitly - * marked with the ByVal attribute to ensure no part of them ends up in - * registers when only a subset of the desired registers are available. - * - * We don't perform the same transformation for D-specific types that contain - * multiple parts, such as dynamic arrays and delegates. They're passed as if - * the parts were passed as separate parameters. This helps make things like - * printf("%.*s", o.toString()) work as expected; if we didn't do this that - * wouldn't work if there were 4 other integer/pointer arguments before the - * toString() call because the string got bumped to memory with one integer - * register still free. Keeping it untransformed puts the length in a register - * and the pointer in memory, as printf expects it. - */ +//===-- abi-x86-64.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// extern(C) implements the C calling convention for x86-64, as found in +// http://www.x86-64.org/documentation/abi-0.99.pdf +// +// Note: +// Where a discrepancy was found between llvm-gcc and the ABI documentation, +// llvm-gcc behavior was used for compatibility (after it was verified that +// regular gcc has the same behavior). +// +// LLVM gets it right for most types, but complex numbers and structs need some +// help. To make sure it gets those right we essentially bitcast small structs +// to a type to which LLVM assigns the appropriate registers, and pass that +// instead. Structs that are required to be passed in memory are explicitly +// marked with the ByVal attribute to ensure no part of them ends up in +// registers when only a subset of the desired registers are available. +// +// We don't perform the same transformation for D-specific types that contain +// multiple parts, such as dynamic arrays and delegates. They're passed as if +// the parts were passed as separate parameters. This helps make things like +// printf("%.*s", o.toString()) work as expected; if we didn't do this that +// wouldn't work if there were 4 other integer/pointer arguments before the +// toString() call because the string got bumped to memory with one integer +// register still free. Keeping it untransformed puts the length in a register +// and the pointer in memory, as printf expects it. +// +//===----------------------------------------------------------------------===// #include "mtype.h" #include "declaration.h" diff --git a/gen/abi-x86-64.h b/gen/abi-x86-64.h index d5ad76cc..8ce2376a 100644 --- a/gen/abi-x86-64.h +++ b/gen/abi-x86-64.h @@ -1,3 +1,16 @@ +//===-- gen/abi-x86-64.h - x86_64 ABI description ---------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// The ABI implementation used for 64 bit x86 (i.e. x86_64/AMD64/x64) targets. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_GEN_ABI_X86_64_H__ #define __LDC_GEN_ABI_X86_64_H__ diff --git a/gen/abi-x86.cpp b/gen/abi-x86.cpp index 1be10a85..a5b768e0 100644 --- a/gen/abi-x86.cpp +++ b/gen/abi-x86.cpp @@ -1,3 +1,12 @@ +//===-- abi-x86.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mars.h" diff --git a/gen/abi-x86.h b/gen/abi-x86.h index 0fe6a2a8..70638e04 100644 --- a/gen/abi-x86.h +++ b/gen/abi-x86.h @@ -1,3 +1,16 @@ +//===-- gen/abi-x86.h - x86 ABI description ---------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// The ABI implementation used for 32 bit x86 targets. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_GEN_ABI_X86_H__ #define __LDC_GEN_ABI_X86_H__ diff --git a/gen/abi.cpp b/gen/abi.cpp index 67761579..64850688 100644 --- a/gen/abi.cpp +++ b/gen/abi.cpp @@ -1,3 +1,12 @@ +//===-- abi.cpp -----------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include diff --git a/gen/abi.h b/gen/abi.h index 48a7fe48..9eda79a7 100644 --- a/gen/abi.h +++ b/gen/abi.h @@ -1,3 +1,19 @@ +//===-- gen/abi.h - Target ABI description for IR generation ----*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// This interface is used by the IR generation code to accomodate any +// additional transformations necessary for the given target ABI (the direct +// LLVM IR representation for C structs unfortunately does not always lead to +// the right ABI, for example on x86_64). +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_GEN_ABI_H__ #define __LDC_GEN_ABI_H__ diff --git a/gen/arrays.cpp b/gen/arrays.cpp index a39744c4..058f8a79 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -1,3 +1,12 @@ +//===-- arrays.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mtype.h" diff --git a/gen/arrays.h b/gen/arrays.h index 409cf123..4d2d18a3 100644 --- a/gen/arrays.h +++ b/gen/arrays.h @@ -1,3 +1,16 @@ +//===-- gen/arrays.h - D array codegen helpers ------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Helper functions for manipulating D dynamic array (slice) types/values. +// +//===----------------------------------------------------------------------===// + #ifndef LLVMC_GEN_ARRAYS_H #define LLVMC_GEN_ARRAYS_H diff --git a/gen/asm-x86-32.h b/gen/asm-x86-32.h index 31882afb..064d0843 100644 --- a/gen/asm-x86-32.h +++ b/gen/asm-x86-32.h @@ -1,5 +1,16 @@ -// Taken from GDC source tree. Original by David Friedman. -// Released under the Artistic License found in dmd/artistic.txt +//===-- gen/asm-x86-32.h - x86 inline assembler handling --------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file originates from work by David Friedman for GDC released under +// the GPL 2 and Artistic licenses. See the LICENSE file for details. +// +//===----------------------------------------------------------------------===// +// +// Parses "DMD-style" x86 inline assembly blocks and converts them to +// GDC/LLVM inline assembler syntax. +// +//===----------------------------------------------------------------------===// #include "id.h" #if defined(_MSC_VER) diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index 88e1a42b..92c23e4d 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -1,5 +1,16 @@ -// Taken from GDC source tree. Original by David Friedman. -// Released under the Artistic License found in dmd/artistic.txt +//===-- gen/asm-x86-64.h - x86_64 inline assembler handling -----*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file originates from work by David Friedman for GDC released under +// the GPL 2 and Artistic licenses. See the LICENSE file for details. +// +//===----------------------------------------------------------------------===// +// +// Parses "DMD-style" x86_64 inline assembly blocks and converts them to +// GDC/LLVM inline assembler syntax. +// +//===----------------------------------------------------------------------===// #include "id.h" #if defined(_MSC_VER) diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 145942a5..957e8b63 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -1,5 +1,11 @@ -// Taken from GDC source tree. Original by David Friedman. -// Released under the Artistic License found in dmd/artistic.txt +//===-- asmstmt.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file originates from work by David Friedman for GDC released under +// the GPL 2 and Artistic licenses. See the LICENSE file for details. +// +//===----------------------------------------------------------------------===// #include "gen/llvm.h" #include "llvm/InlineAsm.h" diff --git a/gen/binops.cpp b/gen/binops.cpp index 6829660c..d4eeeb15 100644 --- a/gen/binops.cpp +++ b/gen/binops.cpp @@ -1,3 +1,12 @@ +//===-- binops.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "declaration.h" @@ -17,13 +26,13 @@ DValue* DtoBinAdd(DValue* lhs, DValue* rhs) LLValue *l, *r; l = lhs->getRVal(); r = rhs->getRVal(); - + LLValue* res; if (t->isfloating()) res = gIR->ir->CreateFAdd(l, r, "tmp"); else res = gIR->ir->CreateAdd(l, r, "tmp"); - + return new DImValue( t, res ); } @@ -35,13 +44,13 @@ DValue* DtoBinSub(DValue* lhs, DValue* rhs) LLValue *l, *r; l = lhs->getRVal(); r = rhs->getRVal(); - + LLValue* res; if (t->isfloating()) res = gIR->ir->CreateFSub(l, r, "tmp"); else res = gIR->ir->CreateSub(l, r, "tmp"); - + return new DImValue( t, res ); } @@ -53,7 +62,7 @@ DValue* DtoBinMul(Type* targettype, DValue* lhs, DValue* rhs) LLValue *l, *r; l = lhs->getRVal(); r = rhs->getRVal(); - + LLValue* res; if (t->isfloating()) res = gIR->ir->CreateFMul(l, r, "tmp"); @@ -70,7 +79,7 @@ DValue* DtoBinDiv(Type* targettype, DValue* lhs, DValue* rhs) LLValue *l, *r; l = lhs->getRVal(); r = rhs->getRVal(); - + LLValue* res; if (t->isfloating()) res = gIR->ir->CreateFDiv(l, r, "tmp"); @@ -120,7 +129,7 @@ LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op) Logger::println("floating"); res = DtoBinFloatsEquals(loc, lhs, rhs, op); } - + assert(res); return res; } diff --git a/gen/cl_helpers.cpp b/gen/cl_helpers.cpp index 6b09c384..dcfe59dc 100644 --- a/gen/cl_helpers.cpp +++ b/gen/cl_helpers.cpp @@ -1,3 +1,12 @@ +//===-- cl_helpers.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/cl_helpers.h" #include "mars.h" diff --git a/gen/cl_helpers.h b/gen/cl_helpers.h index 03205661..06bd195d 100644 --- a/gen/cl_helpers.h +++ b/gen/cl_helpers.h @@ -1,3 +1,17 @@ +//===-- gen/cl_helpers.h - Command line processing helpers ------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Helpers to augment the LLVM command line parsing library with some extra +// functionality. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_CL_HELPERS_H #define LDC_CL_HELPERS_H diff --git a/gen/classes.cpp b/gen/classes.cpp index 2e268bea..f06ee792 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -1,3 +1,12 @@ +//===-- classes.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mtype.h" @@ -296,7 +305,7 @@ DValue* DtoCastClass(DValue* val, Type* _to) IrTypeClass* typeclass = stripModifiers(fc)->irtype->isClass(); // find interface impl - + size_t i_index = typeclass->getInterfaceIndex(it); assert(i_index != ~0 && "requesting interface that is not implemented by this class"); diff --git a/gen/classes.h b/gen/classes.h index 4c65084f..27be1b99 100644 --- a/gen/classes.h +++ b/gen/classes.h @@ -1,3 +1,17 @@ +//===-- gen/classes.h - D class code generation -----------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functions for generating LLVM types and init/TypeInfo/etc. values from D +// class declarations and handling class instance values. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_CLASSES_H #define LDC_GEN_CLASSES_H diff --git a/gen/complex.cpp b/gen/complex.cpp index 948b617b..cc00afb8 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -1,3 +1,12 @@ +//===-- complex.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mtype.h" @@ -211,7 +220,7 @@ DValue* DtoComplexAdd(Loc& loc, Type* type, DValue* lhs, DValue* rhs) res_re = lhs_re; else // either rhs_re or no re at all (then use any) res_re = rhs_re; - + if(lhs_im && rhs_im) res_im = gIR->ir->CreateFAdd(lhs_im, rhs_im, "tmp"); else if(lhs_im) @@ -241,7 +250,7 @@ DValue* DtoComplexSub(Loc& loc, Type* type, DValue* lhs, DValue* rhs) res_re = lhs_re; else // either rhs_re or no re at all (then use any) res_re = gIR->ir->CreateFNeg(rhs_re, "neg"); - + if(lhs_im && rhs_im) res_im = gIR->ir->CreateFSub(lhs_im, rhs_im, "tmp"); else if(lhs_im) diff --git a/gen/complex.h b/gen/complex.h index a7533e35..abdffe6c 100644 --- a/gen/complex.h +++ b/gen/complex.h @@ -1,3 +1,16 @@ +//===-- gen/cl_helpers.h - Complex number code generation -------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functions for generating code for D complex number operations. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_COMPLEX_H #define LDC_GEN_COMPLEX_H diff --git a/gen/declarations.cpp b/gen/declarations.cpp index ff0c0476..b7d08ff0 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -1,3 +1,12 @@ +//===-- declarations.cpp --------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "aggregate.h" @@ -162,7 +171,7 @@ void VarDeclaration::codegen(Ir* p) #if LDC_LLVM_VER >= 302 // FIXME: clang uses a command line option for the thread model LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, _type, _isconst, - DtoLinkage(this), NULL, _name, 0, + DtoLinkage(this), NULL, _name, 0, isThreadlocal() ? LLGlobalVariable::GeneralDynamicTLSModel : LLGlobalVariable::NotThreadLocal); #else diff --git a/gen/dvalue.cpp b/gen/dvalue.cpp index e0057654..05ef76af 100644 --- a/gen/dvalue.cpp +++ b/gen/dvalue.cpp @@ -1,3 +1,12 @@ +//===-- dvalue.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "gen/tollvm.h" diff --git a/gen/dvalue.h b/gen/dvalue.h index 55255a5f..fa1982e2 100644 --- a/gen/dvalue.h +++ b/gen/dvalue.h @@ -1,12 +1,22 @@ +//===-- gen/dvalue.h - D value abstractions ---------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// These classes are used for generating the IR. They encapsulate an LLVM value +// together with a D type and provide an uniform interface for the most common +// operations. When more specialize handling is necessary, they hold enough +// information to do-the-right-thing (TM). +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_DVALUE_H #define LDC_GEN_DVALUE_H -/* -These classes are used for generating the IR. They encapsulate D values and -provide a common interface to the most common operations. When more specialized -handling is necessary, they hold enough information to do-the-right-thing (TM) -*/ - #include #include "root.h" diff --git a/gen/functions.cpp b/gen/functions.cpp index 9d54407e..ac339a7e 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -1,3 +1,12 @@ +//===-- functions.cpp -----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "llvm/Support/CFG.h" #include "llvm/Intrinsics.h" @@ -268,22 +277,22 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl) assert(tinst); Objects& objs = tinst->tdtypes; - assert(objs.dim == 3); + assert(objs.dim == 3); Expression* a0 = isExpression(objs[0]); assert(a0); StringExp* strexp = a0->toString(); assert(strexp); assert(strexp->sz == 1); - std::string code(static_cast(strexp->string), strexp->len); + std::string code(static_cast(strexp->string), strexp->len); Type* ret = isType(objs[1]); assert(ret); - + Tuple* a2 = isTuple(objs[2]); assert(a2); Objects& arg_types = a2->objects; - + std::string str; llvm::raw_string_ostream stream(str); stream << "define " << *DtoType(ret) << " @" << mangled_name << "("; @@ -294,34 +303,34 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl) //assert(ty); if(!ty) { - error(tinst->loc, + error(tinst->loc, "All parameters of a template defined with pragma llvm_inline_ir, except for the first one, should be types"); fatal(); } stream << *DtoType(ty); - + i++; if(i >= arg_types.dim) break; - + stream << ", "; } if(ret->ty == Tvoid) - code.append("\nret void"); - + code.append("\nret void"); + stream << ")\n{\n" << code << "\n}"; - + llvm::SMDiagnostic err; llvm::ParseAssemblyString(stream.str().c_str(), gIR->module, err, gIR->context()); std::string errstr = err.getMessage(); if(errstr != "") - error(tinst->loc, - "can't parse inline LLVM IR:\n%s\n%s\n%s\nThe input string was: \n%s", - err.getLineContents().c_str(), - (std::string(err.getColumnNo(), ' ') + '^').c_str(), + error(tinst->loc, + "can't parse inline LLVM IR:\n%s\n%s\n%s\nThe input string was: \n%s", + err.getLineContents().c_str(), + (std::string(err.getColumnNo(), ' ') + '^').c_str(), errstr.c_str(), stream.str().c_str()); - + LLFunction* fun = gIR->module->getFunction(mangled_name); fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage); #if LDC_LLVM_VER >= 302 @@ -580,7 +589,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati if (attrs[j].Index == curr.Index) { #if LDC_LLVM_VER >= 302 attrs[j].Attrs = llvm::Attributes::get( - gIR->context(), + gIR->context(), llvm::AttrBuilder(attrs[j].Attrs).addAttributes(curr.Attrs)); #else attrs[j].Attrs |= curr.Attrs; @@ -656,7 +665,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) LLFunction* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name); if (!func) { if(fdecl->llvmInternal == LLVMinline_ir) - func = DtoInlineIRFunction(fdecl); + func = DtoInlineIRFunction(fdecl); else func = LLFunction::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module); } else if (func->getFunctionType() != functype) { diff --git a/gen/functions.h b/gen/functions.h index 390422f1..0be3a73c 100644 --- a/gen/functions.h +++ b/gen/functions.h @@ -1,3 +1,16 @@ +//===-- gen/functions.h - D function codegen --------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Code generation for D function types and bodies. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_FUNCTIONS_H #define LDC_GEN_FUNCTIONS_H diff --git a/gen/irstate.cpp b/gen/irstate.cpp index ffd22751..94835a71 100644 --- a/gen/irstate.cpp +++ b/gen/irstate.cpp @@ -1,8 +1,11 @@ -/* DMDFE backend stubs - * This file contains the implementations of the backend routines. - * For dmdfe these do nothing but print a message saying the module - * has been parsed. Substitute your own behaviors for these routimes. - */ +//===-- irstate.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// #include diff --git a/gen/irstate.h b/gen/irstate.h index 2a19aaac..cde25f24 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -1,3 +1,17 @@ +//===-- gen/irstate.h - Global codegen state --------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the global state used and modified when generating the +// code (i.e. LLVM IR) for a given D module. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_IRSTATE_H #define LDC_GEN_IRSTATE_H @@ -58,7 +72,7 @@ struct IRScope IRScope(); IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); - + const IRScope& operator=(const IRScope& rhs); #if DMDV2 @@ -75,7 +89,7 @@ struct IRBuilderHelper struct IRAsmStmt { - IRAsmStmt() + IRAsmStmt() : isBranchToLabel(NULL) {} std::string code; @@ -188,7 +202,7 @@ struct IRState GatesList sharedGates; #endif FuncDeclList unitTests; - + // all template instances that had members emitted // currently only filled for singleobj // used to make sure the complete template instance gets emitted in the diff --git a/gen/linkage.cpp b/gen/linkage.cpp index ba77f90f..6f75a881 100644 --- a/gen/linkage.cpp +++ b/gen/linkage.cpp @@ -1,3 +1,12 @@ +//===-- linkage.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "linkage.h" LLGlobalValue::LinkageTypes templateLinkage; diff --git a/gen/linkage.h b/gen/linkage.h index ccd0eac0..7bbea3dc 100644 --- a/gen/linkage.h +++ b/gen/linkage.h @@ -1,3 +1,16 @@ +//===-- gen/linkage.h - Common linkage types --------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Linkage types used for certain constructs (templates, TypeInfo). +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_LINKAGE_H #define LDC_GEN_LINKAGE_H diff --git a/gen/llvm.h b/gen/llvm.h index aa137e1b..b6cc1a89 100644 --- a/gen/llvm.h +++ b/gen/llvm.h @@ -1,3 +1,20 @@ +//===-- gen/llvm.h - Common LLVM includes and aliases -----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Pulls in commonly used LLVM headers and provides shorthands for some LLVM +// types. +// +// TODO: Consider removing this file; the aliases mostly make code more +// cumbersome to read for people familiar with LLVM anyway. +// +//===----------------------------------------------------------------------===// + #ifndef GEN_LLVM_H #define GEN_LLVM_H diff --git a/gen/llvmcompat.cpp b/gen/llvmcompat.cpp index 0c48c3e5..96bd86f6 100644 --- a/gen/llvmcompat.cpp +++ b/gen/llvmcompat.cpp @@ -1,3 +1,11 @@ +//===-- llvmcompat.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// #include "gen/llvmcompat.h" #include "llvm/Config/llvm-config.h" @@ -85,7 +93,7 @@ Triple llvm::Triple__get64BitArchVariant(const std::string& triple) { return T; } -static void appendToGlobalArray(const char *Array, +static void appendToGlobalArray(const char *Array, Module &M, Function *F, int Priority) { IRBuilder<> IRB(M.getContext()); FunctionType *FnTy = FunctionType::get(IRB.getVoidTy(), false); diff --git a/gen/llvmcompat.h b/gen/llvmcompat.h index 161168c6..b73d346a 100644 --- a/gen/llvmcompat.h +++ b/gen/llvmcompat.h @@ -1,3 +1,18 @@ +//===-- gen/llvmcompat.h - LLVM API compatibilty shims ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Provides a central place to handle API changes between supported LLVM +// versions. +// +//===----------------------------------------------------------------------===// + + #ifdef _MSC_VER #pragma once #endif diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 114e2fd8..0852496a 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -1,3 +1,12 @@ +//===-- llvmhelpers.cpp ---------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvmhelpers.h" #include "gen/llvm.h" @@ -843,7 +852,7 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to) if (fromtype->ty == Tvector) { return DtoCastVector(loc, val, to); } - else + else #endif if (fromtype->isintegral()) { return DtoCastInt(loc, val, to); diff --git a/gen/llvmhelpers.h b/gen/llvmhelpers.h index e911aad3..a191adca 100644 --- a/gen/llvmhelpers.h +++ b/gen/llvmhelpers.h @@ -1,3 +1,18 @@ +//===-- gen/llvmhelpers.h - General LLVM codegen helpers --------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// General codegen helper constructs. +// +// TODO: Merge with gen/tollvm.h, then refactor into sensible parts. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_LLVMHELPERS_H #define LDC_GEN_LLVMHELPERS_H @@ -17,7 +32,7 @@ struct EnclosingTryFinally : EnclosingHandler TryFinallyStatement* tf; llvm::BasicBlock* landingPad; void emitCode(IRState* p); - EnclosingTryFinally(TryFinallyStatement* _tf, llvm::BasicBlock* _pad) + EnclosingTryFinally(TryFinallyStatement* _tf, llvm::BasicBlock* _pad) : tf(_tf), landingPad(_pad) {} }; struct EnclosingVolatile : EnclosingHandler diff --git a/gen/logger.cpp b/gen/logger.cpp index 6b4736f5..6f737c46 100644 --- a/gen/logger.cpp +++ b/gen/logger.cpp @@ -1,3 +1,12 @@ +//===-- logger.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include #include #include diff --git a/gen/logger.h b/gen/logger.h index 62069859..52c12a43 100644 --- a/gen/logger.h +++ b/gen/logger.h @@ -1,3 +1,17 @@ +//===-- gen/logger.h - Codegen debug logging --------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Defines a common interface for logging debug information during code +// generation. +// +//===----------------------------------------------------------------------===// + #ifndef _llvmd_gen_logger_h_ #define _llvmd_gen_logger_h_ diff --git a/gen/metadata.h b/gen/metadata.h index a9525ed2..6599a6a1 100644 --- a/gen/metadata.h +++ b/gen/metadata.h @@ -1,3 +1,16 @@ +//===-- gen/metadata.h - LDC-specific LLVM metadata definitions -*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Defines the types of LLVM metadata used for D-specific optimization passes. +// +//===----------------------------------------------------------------------===// + #if USE_METADATA #ifndef LDC_GEN_METADATA_H @@ -25,9 +38,9 @@ inline MDNodeField* MD_GetElement(llvm::MDNode* N, unsigned i) { /// (Its name will be TD_PREFIX ~ ) enum TypeDataFields { TD_Confirm, /// The TypeInfo this node is for. - + TD_Type, /// A value of the LLVM type corresponding to this D type - + // Must be kept last: TD_NumFields /// The number of fields in TypeInfo metadata }; @@ -42,7 +55,7 @@ enum ClassDataFields { CD_BodyType, /// A value of the LLVM type corresponding to the class body. CD_Finalize, /// True if this class (or a base class) has a destructor. CD_CustomDelete,/// True if this class has an overridden delete operator. - + // Must be kept last CD_NumFields /// The number of fields in ClassInfo metadata }; diff --git a/gen/module.cpp b/gen/module.cpp index da6e1a50..6a57a3b6 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -1,3 +1,12 @@ +//===-- module.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Module.h" diff --git a/gen/naked.cpp b/gen/naked.cpp index 3863afc0..fbe201ff 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -1,3 +1,12 @@ +//===-- naked.cpp ---------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "llvm/InlineAsm.h" diff --git a/gen/nested.cpp b/gen/nested.cpp index de5cbe8a..b8a12940 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -1,3 +1,12 @@ +//===-- nested.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/nested.h" #include "gen/dvalue.h" diff --git a/gen/nested.h b/gen/nested.h index 91f0a002..3eaa6fa9 100644 --- a/gen/nested.h +++ b/gen/nested.h @@ -1,3 +1,17 @@ +//===-- gen/nested.h - Nested context handling ------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functions for creating nested contexts for nested D types/functions and +// extracting the values from them. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_NESTED_H #define LDC_GEN_NESTED_H diff --git a/gen/optimizer.cpp b/gen/optimizer.cpp index 09976693..b98f5380 100644 --- a/gen/optimizer.cpp +++ b/gen/optimizer.cpp @@ -1,3 +1,12 @@ +//===-- optimizer.cpp -----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/optimizer.h" #include "gen/cl_helpers.h" #include "gen/logger.h" diff --git a/gen/optimizer.h b/gen/optimizer.h index a45d22f4..8f4950e1 100644 --- a/gen/optimizer.h +++ b/gen/optimizer.h @@ -1,3 +1,17 @@ +//===-- gen/optimizer.h - LLVM IR optimization ------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Handles the optimization of the generated LLVM modules according to the +// specified optimization level. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_OPTIMIZER_H #define LDC_GEN_OPTIMIZER_H diff --git a/gen/passes/GarbageCollect2Stack.cpp b/gen/passes/GarbageCollect2Stack.cpp index 9d6607e5..aa658a73 100644 --- a/gen/passes/GarbageCollect2Stack.cpp +++ b/gen/passes/GarbageCollect2Stack.cpp @@ -1,11 +1,11 @@ #if USE_METADATA -//===- GarbageCollect2Stack - Optimize calls to the D garbage collector ---===// +//===-- GarbageCollect2Stack.cpp - Promote or remove GC allocations -------===// // -// The LLVM D Compiler +// LDC – the LLVM D compiler // -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. // //===----------------------------------------------------------------------===// // @@ -52,7 +52,7 @@ namespace { const Module& M; CallGraph* CG; CallGraphNode* CGNode; - + const Type* getTypeFor(Value* typeinfo) const; }; } @@ -64,14 +64,14 @@ namespace { void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len, const Analysis& A) { Dst = B.CreateBitCast(Dst, PointerType::getUnqual(B.getInt8Ty())); - + Module *M = B.GetInsertBlock()->getParent()->getParent(); const Type* intTy = Len->getType(); const Type *VoidPtrTy = PointerType::getUnqual(B.getInt8Ty()); const Type *Tys[2] ={VoidPtrTy, intTy}; Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); Value *Align = ConstantInt::get(B.getInt32Ty(), 1); - + CallSite CS = B.CreateCall5(MemSet, Dst, Val, Len, Align, B.getFalse()); if (A.CGNode) A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet)); @@ -91,11 +91,11 @@ namespace { class FunctionInfo { protected: const Type* Ty; - + public: unsigned TypeInfoArgNr; bool SafeToDelete; - + // Analyze the current call, filling in some fields. Returns true if // this is an allocation we can stack-allocate. virtual bool analyze(CallSite CS, const Analysis& A) { @@ -103,25 +103,25 @@ namespace { Ty = A.getTypeFor(TypeInfo); return (Ty != NULL); } - + // Returns the alloca to replace this call. // It will always be inserted before the call. virtual AllocaInst* promote(CallSite CS, IRBuilder<>& B, const Analysis& A) { NumGcToStack++; - + Instruction* Begin = CS.getCaller()->getEntryBlock().begin(); return new AllocaInst(Ty, ".nongc_mem", Begin); // FIXME: align? } - + FunctionInfo(unsigned typeInfoArgNr, bool safeToDelete) : TypeInfoArgNr(typeInfoArgNr), SafeToDelete(safeToDelete) {} }; - + class ArrayFI : public FunctionInfo { Value* arrSize; int ArrSizeArgNr; bool Initialized; - + public: ArrayFI(unsigned tiArgNr, bool safeToDelete, bool initialized, unsigned arrSizeArgNr) @@ -129,11 +129,11 @@ namespace { ArrSizeArgNr(arrSizeArgNr), Initialized(initialized) {} - + virtual bool analyze(CallSite CS, const Analysis& A) { if (!FunctionInfo::analyze(CS, A)) return false; - + arrSize = CS.getArgument(ArrSizeArgNr); const IntegerType* SizeType = dyn_cast(arrSize->getType()); @@ -158,7 +158,7 @@ namespace { Ty = PtrTy->getElementType(); return true; } - + virtual AllocaInst* promote(CallSite CS, IRBuilder<>& B, const Analysis& A) { IRBuilder<> Builder = B; // If the allocation is of constant size it's best to put it in the @@ -174,11 +174,11 @@ namespace { } else { NumToDynSize++; } - + // Convert array size to 32 bits if necessary Value* count = Builder.CreateIntCast(arrSize, Builder.getInt32Ty(), false); AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem"); // FIXME: align? - + if (Initialized) { // For now, only zero-init is supported. uint64_t size = A.TD.getTypeStoreSize(Ty); @@ -188,11 +188,11 @@ namespace { Value* Size = B.CreateMul(TypeSize, arrSize); EmitMemZero(B, alloca, Size, A); } - + return alloca; } }; - + // FunctionInfo for _d_allocclass class AllocClassFI : public FunctionInfo { public: @@ -226,17 +226,17 @@ namespace { Constant* hasCustomDelete = dyn_cast(MD_GetElement(node, CD_CustomDelete)); if (hasDestructor == NULL || hasCustomDelete == NULL) return false; - + if (ConstantExpr::getOr(hasDestructor, hasCustomDelete) != ConstantInt::getFalse(A.M.getContext())) return false; - + Ty = MD_GetElement(node, CD_BodyType)->getType(); return true; } - + // The default promote() should be fine. - + AllocClassFI() : FunctionInfo(~0u, true) {} }; } @@ -252,27 +252,27 @@ namespace { class LLVM_LIBRARY_VISIBILITY GarbageCollect2Stack : public FunctionPass { StringMap KnownFunctions; Module* M; - + FunctionInfo AllocMemoryT; ArrayFI NewArrayVT; ArrayFI NewArrayT; AllocClassFI AllocClass; - + public: static char ID; // Pass identification GarbageCollect2Stack(); - + bool doInitialization(Module &M) { this->M = &M; return false; } - + bool runOnFunction(Function &F); - + virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); - + AU.addPreserved(); AU.addPreserved(); } @@ -285,7 +285,7 @@ X("dgc2stack", "Promote (GC'ed) heap allocations to stack"); // Public interface to the pass. FunctionPass *createGarbageCollect2Stack() { - return new GarbageCollect2Stack(); + return new GarbageCollect2Stack(); } GarbageCollect2Stack::GarbageCollect2Stack() @@ -305,7 +305,7 @@ static void RemoveCall(CallSite CS, const Analysis& A) { InvokeInst* Invoke = cast(CS.getInstruction()); // If this was an invoke instruction, we need to do some extra // work to preserve the control flow. - + // Create a "conditional" branch that -simplifycfg can clean up, so we // can keep using the DominatorTree without updating it. BranchInst::Create(Invoke->getNormalDest(), Invoke->getUnwindDest(), @@ -323,18 +323,18 @@ static bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT); /// bool GarbageCollect2Stack::runOnFunction(Function &F) { DEBUG(errs() << "\nRunning -dgc2stack on function " << F.getName() << '\n'); - + TargetData& TD = getAnalysis(); DominatorTree& DT = getAnalysis(); CallGraph* CG = getAnalysisIfAvailable(); CallGraphNode* CGNode = CG ? (*CG)[&F] : NULL; - + Analysis A = { TD, *M, CG, CGNode }; - + BasicBlock& Entry = F.getEntryBlock(); - + IRBuilder<> AllocaBuilder(&Entry, Entry.begin()); - + bool Changed = false; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { @@ -343,53 +343,53 @@ bool GarbageCollect2Stack::runOnFunction(Function &F) { CallSite CS = CallSite::get(Inst); if (!CS.getInstruction()) continue; - + // Ignore indirect calls and calls to non-external functions. Function *Callee = CS.getCalledFunction(); if (Callee == 0 || !Callee->isDeclaration() || !(Callee->hasExternalLinkage() || Callee->hasDLLImportLinkage())) continue; - + // Ignore unknown calls. StringMap::iterator OMI = KnownFunctions.find(Callee->getName()); if (OMI == KnownFunctions.end()) continue; - + assert(isa(Inst->getType()) && "GC function doesn't return a pointer?"); - + FunctionInfo* info = OMI->getValue(); - + if (Inst->use_empty() && info->SafeToDelete) { Changed = true; NumDeleted++; RemoveCall(CS, A); continue; } - + DEBUG(errs() << "GarbageCollect2Stack inspecting: " << *Inst); - + if (!info->analyze(CS, A) || !isSafeToStackAllocate(Inst, DT)) continue; - + // Let's alloca this! Changed = true; - + IRBuilder<> Builder(BB, Inst); Value* newVal = info->promote(CS, Builder, A); - + DEBUG(errs() << "Promoted to: " << *newVal); - + // Make sure the type is the same as it was before, and replace all // uses of the runtime call with the alloca. if (newVal->getType() != Inst->getType()) newVal = Builder.CreateBitCast(newVal, Inst->getType()); Inst->replaceAllUsesWith(newVal); - + RemoveCall(CS, A); } } - + return Changed; } @@ -397,7 +397,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const { GlobalVariable* ti_global = dyn_cast(typeinfo->stripPointerCasts()); if (!ti_global) return NULL; - + std::string metaname = TD_PREFIX; metaname += ti_global->getName(); @@ -414,7 +414,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const { if (TD_Confirm >= 0 && (!MD_GetElement(node, TD_Confirm) || MD_GetElement(node, TD_Confirm)->stripPointerCasts() != ti_global)) return NULL; - + return MD_GetElement(node, TD_Type)->getType(); } @@ -422,7 +422,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const { /// (without executing Def again). static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, DominatorTree& DT) { DEBUG(errs() << "### mayBeUsedAfterRealloc()\n" << *Def << *Alloc); - + // If the definition isn't used it obviously won't be used after the // allocation. // If it does not dominate the allocation, there's no way for it to be used @@ -432,12 +432,12 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato DEBUG(errs() << "### No uses or does not dominate allocation\n"); return false; } - + DEBUG(errs() << "### Def dominates Alloc\n"); - + BasicBlock* DefBlock = Def->getParent(); BasicBlock* AllocBlock = Alloc->getParent(); - + // Create a set of users and one of blocks containing users. SmallSet Users; SmallSet UserBlocks; @@ -446,7 +446,7 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato Instruction* User = cast(*UI); DEBUG(errs() << "USER: " << *User); BasicBlock* UserBlock = User->getParent(); - + // This dominance check is not performed if they're in the same block // because it will just walk the instruction list to figure it out. // We will instead do that ourselves in the first iteration (for all @@ -457,34 +457,34 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato DEBUG(errs() << "### Alloc dominates user " << *User); return true; } - + // Phi nodes are checked separately, so no need to enter them here. if (!isa(User)) { Users.insert(User); UserBlocks.insert(UserBlock); } } - + // Contains first instruction of block to inspect. typedef std::pair StartPoint; SmallVector Worklist; // Keeps track of successors that have been added to the work list. SmallSet Visited; - + // Start just after the allocation. // Note that we don't insert AllocBlock into the Visited set here so the // start of the block will get inspected if it's reachable. BasicBlock::iterator Start = Alloc; ++Start; Worklist.push_back(StartPoint(AllocBlock, Start)); - + while (!Worklist.empty()) { StartPoint sp = Worklist.pop_back_val(); BasicBlock* B = sp.first; BasicBlock::iterator BBI = sp.second; // BBI is either just after the allocation (in the first iteration) // or just after the last phi node in B (in subsequent iterations) here. - + // This whole 'if' is just a way to avoid performing the inner 'for' // loop when it can be determined not to be necessary, avoiding // potentially expensive walks of the instruction list. @@ -517,7 +517,7 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato // No users and no definition or allocation after the start point, // so just keep going. } - + // All instructions after the starting point in this block have been // accounted for. Look for successors to add to the work list. TerminatorInst* Term = B->getTerminator(); @@ -555,32 +555,32 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato /// escape from the function and no derived pointers are live at the call site /// (i.e. if it's in a loop then the function can't use any pointer returned /// from an earlier call after a new call has been made) -/// +/// /// This is currently conservative where loops are involved: it can handle /// simple loops, but returns false if any derived pointer is used in a /// subsequent iteration. -/// +/// /// Based on LLVM's PointerMayBeCaptured(), which only does escape analysis but /// doesn't care about loops. bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) { assert(isa(Alloc->getType()) && "Allocation is not a pointer?"); Value* V = Alloc; - + SmallVector Worklist; SmallSet Visited; - + for (Value::use_iterator UI = V->use_begin(), UE = V->use_end(); UI != UE; ++UI) { Use *U = &UI.getUse(); Visited.insert(U); Worklist.push_back(U); } - + while (!Worklist.empty()) { Use *U = Worklist.pop_back_val(); Instruction *I = cast(U->getUser()); V = U->get(); - + switch (I->getOpcode()) { case Instruction::Call: case Instruction::Invoke: { @@ -591,7 +591,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) { if (CS.onlyReadsMemory() && CS.doesNotThrow() && I->getType() == Type::getVoidTy(I->getContext())) break; - + // Not captured if only passed via 'nocapture' arguments. Note that // calling a function pointer does not in itself cause the pointer to // be captured. This is a subtle point considering that (for example) @@ -628,7 +628,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) { // the original allocation. if (mayBeUsedAfterRealloc(I, Alloc, DT)) return false; - + // The original value is not captured via this if the new value isn't. for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE; ++UI) { @@ -642,7 +642,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) { return false; } } - + // All uses examined - not captured or live across original allocation. return true; } diff --git a/gen/passes/Passes.h b/gen/passes/Passes.h index 5117fd40..16368762 100644 --- a/gen/passes/Passes.h +++ b/gen/passes/Passes.h @@ -1,3 +1,16 @@ +//===-- gen/passes/Passes.h - LDC-specific LLVM passes ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functions for creating the LDC-specific LLVM optimizer passes. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_PASSES_H #define LDC_PASSES_H diff --git a/gen/passes/SimplifyDRuntimeCalls.cpp b/gen/passes/SimplifyDRuntimeCalls.cpp index 98d7978a..ecf9f534 100644 --- a/gen/passes/SimplifyDRuntimeCalls.cpp +++ b/gen/passes/SimplifyDRuntimeCalls.cpp @@ -1,9 +1,9 @@ -//===- SimplifyDRuntimeCalls - Optimize calls to the D runtime library ----===// +//===-- SimplifyDRuntimeCalls.cpp - Optimize druntime calls ---------------===// // -// The LLVM D Compiler +// LDC – the LLVM D compiler // // This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// License. See the LICENSE file for details. // //===----------------------------------------------------------------------===// // diff --git a/gen/passes/StripExternals.cpp b/gen/passes/StripExternals.cpp index d971fcf5..fdd0dd85 100644 --- a/gen/passes/StripExternals.cpp +++ b/gen/passes/StripExternals.cpp @@ -1,9 +1,9 @@ //===-- StripExternals.cpp - Strip available_externally symbols -----------===// // -// The LLVM D Compiler +// LDC – the LLVM D compiler // -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. // //===----------------------------------------------------------------------===// // diff --git a/gen/pragma.cpp b/gen/pragma.cpp index fd1bcb6b..cff212a0 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -1,3 +1,12 @@ +//===-- pragma.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "pragma.h" #include "attrib.h" #include "id.h" diff --git a/gen/pragma.h b/gen/pragma.h index 8ff39401..a8b9631f 100644 --- a/gen/pragma.h +++ b/gen/pragma.h @@ -1,3 +1,16 @@ +//===-- gen/pragma.h - LDC-specific pragma handling -------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Code for handling the LDC-specific pragmas. +// +//===----------------------------------------------------------------------===// + #ifndef PRAGMA_H #define PRAGMA_H diff --git a/gen/programs.cpp b/gen/programs.cpp index 401ab193..b36d2c8b 100644 --- a/gen/programs.cpp +++ b/gen/programs.cpp @@ -1,3 +1,12 @@ +//===-- programs.cpp ------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/programs.h" #include "llvm/Support/CommandLine.h" diff --git a/gen/programs.h b/gen/programs.h index c0cc44a6..fda3f9de 100644 --- a/gen/programs.h +++ b/gen/programs.h @@ -1,3 +1,16 @@ +//===-- gen/programs.h - External tool discovery ----------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functions for discovering the external tools used for linking, etc. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_PROGRAMS_H #define LDC_GEN_PROGRAMS_H diff --git a/gen/rttibuilder.cpp b/gen/rttibuilder.cpp index 985dcc97..0aede9ff 100644 --- a/gen/rttibuilder.cpp +++ b/gen/rttibuilder.cpp @@ -1,3 +1,12 @@ +//===-- rttibuilder.cpp ---------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "aggregate.h" diff --git a/gen/rttibuilder.h b/gen/rttibuilder.h index 98f2598b..8bb47b29 100644 --- a/gen/rttibuilder.h +++ b/gen/rttibuilder.h @@ -1,3 +1,17 @@ +//===-- gen/rttibuilder.h - TypeInfo generation helper ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// This class is used to build the global TypeInfo/ClassInfo/... constants +// required for the D runtime type information system. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_GEN_RTTIBUILDER_H__ #define __LDC_GEN_RTTIBUILDER_H__ diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 0bf9d0e0..069f87fe 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -1,3 +1,12 @@ +//===-- runtime.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "llvm/Module.h" #include "llvm/Attributes.h" diff --git a/gen/runtime.h b/gen/runtime.h index 21c8841a..6d60c57d 100644 --- a/gen/runtime.h +++ b/gen/runtime.h @@ -1,3 +1,16 @@ +//===-- gen/runtime.h - D runtime function handlers -------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Code for handling the compiler support functions from the D runtime library. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_RUNTIME_H_ #define LDC_GEN_RUNTIME_H_ diff --git a/gen/statements.cpp b/gen/statements.cpp index 2d1072a4..00f5fb62 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -1,4 +1,12 @@ -// Statements: D -> LLVM glue +//===-- statements.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include #include diff --git a/gen/structs.cpp b/gen/structs.cpp index 96380838..44ec0dd1 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -1,3 +1,12 @@ +//===-- structs.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include #include "gen/llvm.h" @@ -178,7 +187,7 @@ std::vector DtoStructLiteralValues(const StructDeclaration* sd, const std::vector& inits, bool isConst) { - // get arrays + // get arrays size_t nvars = sd->fields.dim; VarDeclaration** vars = (VarDeclaration**)sd->fields.data; @@ -338,7 +347,7 @@ std::vector DtoStructLiteralValues(const StructDeclaration* sd, /// Union types will get expanded into a struct, with a type for each member. LLType* DtoUnpaddedStructType(Type* dty) { assert(dty->ty == Tstruct); - + typedef llvm::DenseMap CacheT; static llvm::ManagedStatic cache; CacheT::iterator it = cache->find(dty); @@ -374,9 +383,9 @@ LLValue* DtoUnpaddedStruct(Type* dty, LLValue* v) { assert(dty->ty == Tstruct); TypeStruct* sty = static_cast(dty); Array& fields = sty->sym->fields; - + LLValue* newval = llvm::UndefValue::get(DtoUnpaddedStructType(dty)); - + for (unsigned i = 0; i < fields.dim; i++) { VarDeclaration* vd = static_cast(fields.data[i]); LLValue* fieldptr = DtoIndexStruct(v, sty->sym, vd); @@ -397,7 +406,7 @@ void DtoPaddedStruct(Type* dty, LLValue* v, LLValue* lval) { assert(dty->ty == Tstruct); TypeStruct* sty = static_cast(dty); Array& fields = sty->sym->fields; - + for (unsigned i = 0; i < fields.dim; i++) { VarDeclaration* vd = static_cast(fields.data[i]); LLValue* fieldptr = DtoIndexStruct(lval, sty->sym, vd); diff --git a/gen/structs.h b/gen/structs.h index 8fc116fa..f0a77913 100644 --- a/gen/structs.h +++ b/gen/structs.h @@ -1,3 +1,16 @@ +//===-- gen/structs.h - D struct codegen ------------------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functions for D struct codegen. +// +//===----------------------------------------------------------------------===// + #ifndef LLVMD_GEN_STRUCTS_H #define LLVMD_GEN_STRUCTS_H diff --git a/gen/tocall.cpp b/gen/tocall.cpp index d5c6e8ca..bf3dc9ed 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -1,3 +1,12 @@ +//===-- tocall.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mtype.h" diff --git a/gen/todebug.cpp b/gen/todebug.cpp index fb981f33..e50f9b6c 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -1,3 +1,12 @@ +//===-- todebug.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/Support/Dwarf.h" diff --git a/gen/todebug.h b/gen/todebug.h index ec69bc2f..0e572bae 100644 --- a/gen/todebug.h +++ b/gen/todebug.h @@ -1,3 +1,16 @@ +//===-- gen/todebug.h - Symbolic debug information generation ---*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Handles generation of symbolic debug information using LLVM's DWARF support. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_TODEBUG_H #define LDC_GEN_TODEBUG_H diff --git a/gen/toir.cpp b/gen/toir.cpp index db0234be..8d68ded1 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -1,10 +1,11 @@ -// Backend stubs - -/* DMDFE backend stubs - * This file contains the implementations of the backend routines. - * For dmdfe these do nothing but print a message saying the module - * has been parsed. Substitute your own behaviors for these routimes. - */ +//===-- toir.cpp ----------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// #include #include diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 20fe312a..a3e9139a 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -1,3 +1,11 @@ +//===-- tollvm.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// #include "gen/llvm.h" diff --git a/gen/tollvm.h b/gen/tollvm.h index eb9cbce1..5e0530a9 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -1,3 +1,18 @@ +//===-- gen/tollvm.h - General LLVM codegen helpers -------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// General codegen helper constructs. +// +// TODO: Merge with gen/llvmhelpers.h, then refactor into sensible parts. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_TOLLVM_H #define LDC_GEN_TOLLVM_H diff --git a/gen/typeinf.h b/gen/typeinf.h index 7e688886..fe993a78 100644 --- a/gen/typeinf.h +++ b/gen/typeinf.h @@ -1,3 +1,17 @@ +//===-- gen/typinf.h - TypeInfo declaration codegen -------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Codegen for the TypeInfo types/constants required by the D run-time type +// information system. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_GEN_TYPEINF_H #define LDC_GEN_TYPEINF_H diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 1d1a17a1..02c375e3 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -1,4 +1,12 @@ - +//===-- typinf.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file mostly consists of code under the BSD-style LDC license, but some +// parts have been derived from DMD as noted below. See the LICENSE file for +// details. +// +//===----------------------------------------------------------------------===// // Copyright (c) 1999-2004 by Digital Mars // All Rights Reserved diff --git a/gen/utils.h b/gen/utils.h index b4a3b4b5..8d7c1e6e 100644 --- a/gen/utils.h +++ b/gen/utils.h @@ -1,3 +1,16 @@ +//===-- gen/utils.h - Utilities for handling frontend types -----*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Some utilities for handling front-end types in a more C++-like fashion. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_GEN_UTILS_H__ #define __LDC_GEN_UTILS_H__ diff --git a/gen/warnings.cpp b/gen/warnings.cpp index 450e43d8..f3b59846 100644 --- a/gen/warnings.cpp +++ b/gen/warnings.cpp @@ -1,3 +1,12 @@ +//===-- warnings.cpp ------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "mars.h" #include "mtype.h" #include "expression.h" diff --git a/gen/warnings.h b/gen/warnings.h index 13ed63c1..7367c6d2 100644 --- a/gen/warnings.h +++ b/gen/warnings.h @@ -1,3 +1,16 @@ +//===-- gen/warnings.h - LDC-specific warning handling ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Functionality for emitting additional warnings during codegen. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_GEN_WARNINGS_H__ #define __LDC_GEN_WARNINGS_H__ diff --git a/ir/ir.cpp b/ir/ir.cpp index 339b1a23..6dc953c0 100644 --- a/ir/ir.cpp +++ b/ir/ir.cpp @@ -1,3 +1,12 @@ +//===-- ir.cpp ------------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #if LDC_LLVM_VER >= 302 #include "llvm/DataLayout.h" #else diff --git a/ir/ir.h b/ir/ir.h index 3f60780c..dbca3572 100644 --- a/ir/ir.h +++ b/ir/ir.h @@ -1,4 +1,17 @@ -// this head contains stuff used by all the IR +//===-- ir/ir.h - Base definitions for codegen metadata ---------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Declares the base class for all codegen info classes and the top-level Ir +// class. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_IR_IR_H #define LDC_IR_IR_H diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 3d92881f..248d4e42 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -1,3 +1,12 @@ +//===-- irclass.cpp -------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" diff --git a/ir/irdsymbol.cpp b/ir/irdsymbol.cpp index e0480aa8..598001b9 100644 --- a/ir/irdsymbol.cpp +++ b/ir/irdsymbol.cpp @@ -1,3 +1,12 @@ +//===-- irdsymbol.cpp -----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "ir/ir.h" #include "ir/irdsymbol.h" diff --git a/ir/irdsymbol.h b/ir/irdsymbol.h index 94b0fd18..ca9a0124 100644 --- a/ir/irdsymbol.h +++ b/ir/irdsymbol.h @@ -1,3 +1,16 @@ +//===-- ir/irdsymbol.h - Codegen state for D symbols ------------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Represents the status of a D symbol on its way though the codegen process. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_IR_IRDSYMBOL_H #define LDC_IR_IRDSYMBOL_H diff --git a/ir/irforw.h b/ir/irforw.h index 720d2790..87b46330 100644 --- a/ir/irforw.h +++ b/ir/irforw.h @@ -1,3 +1,17 @@ +//===-- ir/irforw.h - Forward declarations used in ir/ code ----*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Some common forward declarations for use in ir/ headers. +// +//===----------------------------------------------------------------------===// + + #ifndef LDC_IR_IRFORW_H #define LDC_IR_IRFORW_H diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 99a59f69..ab0a834e 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -1,3 +1,11 @@ +//===-- irfunction.cpp ----------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// #include "gen/llvm.h" #include "gen/tollvm.h" @@ -150,7 +158,7 @@ IrFunction::IrFunction(FuncDeclaration* fd) frameType = NULL; depth = -1; nestedContextCreated = false; - + _arguments = NULL; _argptr = NULL; } diff --git a/ir/irfunction.h b/ir/irfunction.h index 03cb12cd..e167f47a 100644 --- a/ir/irfunction.h +++ b/ir/irfunction.h @@ -1,3 +1,18 @@ +//===-- ir/irfunction.h - Codegen state for D functions ---------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Represents the status of a D function/method/... on its way through the +// codegen process. +// +//===----------------------------------------------------------------------===// + + #ifndef LDC_IR_IRFUNCTION_H #define LDC_IR_IRFUNCTION_H @@ -18,10 +33,10 @@ struct IRTargetScope { // generating statement Statement* s; - + // the try of a TryFinally that encloses the loop EnclosingHandler* enclosinghandler; - + llvm::BasicBlock* breakTarget; llvm::BasicBlock* continueTarget; @@ -69,7 +84,7 @@ struct IrFunction : IrBase { // constructor IrFunction(FuncDeclaration* fd); - + // annotations void setNeverInline(); void setAlwaysInline(); @@ -83,21 +98,21 @@ struct IrFunction : IrBase bool queued; bool defined; - + llvm::Value* retArg; // return in ptr arg llvm::Value* thisArg; // class/struct 'this' arg llvm::Value* nestArg; // nested function 'this' arg - + llvm::Value* nestedVar; // nested var alloca llvm::StructType* frameType; // type of nested context (not for -nested-ctx=array) // number of enclosing functions with variables accessed by nested functions // (-1 if neither this function nor any enclosing ones access variables from enclosing functions) int depth; bool nestedContextCreated; // holds whether nested context is created - + llvm::Value* _arguments; llvm::Value* _argptr; - + llvm::DISubprogram diSubprogram; std::stack diLexicalBlocks; }; diff --git a/ir/irfuncty.h b/ir/irfuncty.h index 22fbdf2e..1ce0a0b8 100644 --- a/ir/irfuncty.h +++ b/ir/irfuncty.h @@ -1,3 +1,18 @@ +//===-- ir/irfuncty.h - Function type codegen metadata ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Additional information attached to a function type during codegen. Handles +// LLVM attributes attached to a function and its parameters, etc. +// +//===----------------------------------------------------------------------===// + + #ifndef LDC_IR_IRFUNCTY_H #define LDC_IR_IRFUNCTY_H diff --git a/ir/irlandingpad.cpp b/ir/irlandingpad.cpp index 491d5089..900ff773 100644 --- a/ir/irlandingpad.cpp +++ b/ir/irlandingpad.cpp @@ -1,3 +1,12 @@ +//===-- irlandingpad.cpp --------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "gen/tollvm.h" #include "gen/irstate.h" diff --git a/ir/irlandingpad.h b/ir/irlandingpad.h index 78e3f37f..e3789882 100644 --- a/ir/irlandingpad.h +++ b/ir/irlandingpad.h @@ -1,3 +1,17 @@ +//===-- ir/irlandingpad.h - Codegen state for EH blocks ---------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// State kept while doing codegen for a single "EH block" consisting of +// of several catch/finally/cleanup clauses. Handles nesting of these blocks. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_IR_IRLANDINGPADINFO_H #define LDC_IR_IRLANDINGPADINFO_H diff --git a/ir/irmodule.cpp b/ir/irmodule.cpp index 64bcd254..80d32a66 100644 --- a/ir/irmodule.cpp +++ b/ir/irmodule.cpp @@ -1,3 +1,12 @@ +//===-- irmodule.cpp ------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "gen/tollvm.h" #include "gen/irstate.h" diff --git a/ir/irmodule.h b/ir/irmodule.h index af12d904..8fcd2d6e 100644 --- a/ir/irmodule.h +++ b/ir/irmodule.h @@ -1,3 +1,17 @@ +//===-- ir/irmodule.h - Codegen state for top-level D modules ---*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Represents the state of a D module on its way through code generation. Also +// see the TODO in gen/module.cpp – parts of IRState really belong here. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_IR_IRMODULE_H #define LDC_IR_IRMODULE_H diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 9dc1a192..046e41b2 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -1,3 +1,12 @@ +//===-- irstruct.cpp ------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "mtype.h" diff --git a/ir/irstruct.h b/ir/irstruct.h index 49faf2c5..535f8807 100644 --- a/ir/irstruct.h +++ b/ir/irstruct.h @@ -1,3 +1,17 @@ +//===-- ir/irstruct.h - Codegen state for D aggregates ----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Represents the state of a D aggregate (struct/class) on its way through +// codegen, also managing the associated init and RTTI symbols. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_IR_IRSTRUCT_H #define LDC_IR_IRSTRUCT_H @@ -28,7 +42,7 @@ struct IrStruct : IrBase /// Aggregate D type. Type* type; - /// true only for: align(1) struct S { ... } + /// true only for: align(1) struct S { ... } bool packed; /// Composite type debug description. diff --git a/ir/irsymbol.cpp b/ir/irsymbol.cpp deleted file mode 100644 index 2df8f06e..00000000 --- a/ir/irsymbol.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "ir/irsymbol.h" diff --git a/ir/irsymbol.h b/ir/irsymbol.h deleted file mode 100644 index ffa609fa..00000000 --- a/ir/irsymbol.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __LDC_IR_IRSYMBOL_H__ -#define __LDC_IR_IRSYMBOL_H__ - -#include "ir/ir.h" - -/// Base class for all symbols. -class IrSymbol -{ -public: - /// - IrSymbol(Ir* ir) : ir(ir) {} - - /// Migrate symbols to current module if necessary. - virtual void migrate() = 0; - -protected: - /// - Ir* ir; -}; - -#endif diff --git a/ir/irtype.cpp b/ir/irtype.cpp index 45f60455..499e855d 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -1,3 +1,12 @@ +//===-- irtype.cpp --------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "llvm/DerivedTypes.h" #include "llvm/LLVMContext.h" #include "mars.h" diff --git a/ir/irtype.h b/ir/irtype.h index 743737b4..cb5dd090 100644 --- a/ir/irtype.h +++ b/ir/irtype.h @@ -1,3 +1,19 @@ +//===-- ir/irtype.h - IrType base and primitive types -----------*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// The types derived from IrType are used to attach LLVM type information and +// other codegen metadata (e.g. for vtbl resolution) to frontend Types. There +// is an 1:1 correspondence between Type and IrType instances. +// +//===----------------------------------------------------------------------===// + + #ifndef __LDC_IR_IRTYPE_H__ #define __LDC_IR_IRTYPE_H__ diff --git a/ir/irtypeclass.cpp b/ir/irtypeclass.cpp index ebe61715..c1d5435e 100644 --- a/ir/irtypeclass.cpp +++ b/ir/irtypeclass.cpp @@ -1,3 +1,12 @@ +//===-- irtypeclass.cpp ---------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "llvm/DerivedTypes.h" #include "aggregate.h" diff --git a/ir/irtypeclass.h b/ir/irtypeclass.h index 8459b6d8..6e6c5b43 100644 --- a/ir/irtypeclass.h +++ b/ir/irtypeclass.h @@ -1,3 +1,16 @@ +//===-- ir/irtypeclass.h - IrType implementation for D classes --*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Provides the IrType subclass used to represent D classes. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_IR_IRTYPECLASS_H__ #define __LDC_IR_IRTYPECLASS_H__ diff --git a/ir/irtypefunction.cpp b/ir/irtypefunction.cpp index 6707d0d8..7ffeaf7b 100644 --- a/ir/irtypefunction.cpp +++ b/ir/irtypefunction.cpp @@ -1,3 +1,12 @@ +//===-- irtypefunction.cpp ------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "llvm/DerivedTypes.h" #include "mtype.h" diff --git a/ir/irtypefunction.h b/ir/irtypefunction.h index 14bfda5c..528b07a3 100644 --- a/ir/irtypefunction.h +++ b/ir/irtypefunction.h @@ -1,3 +1,16 @@ +//===-- ir/irtypefunction.h - IrType subclasses for callables ---*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Provides the IrType subclasses used to represent D function/delegate types. +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_IR_IRTYPEFUNCTION_H__ #define __LDC_IR_IRTYPEFUNCTION_H__ diff --git a/ir/irtypestruct.cpp b/ir/irtypestruct.cpp index 2cd128ed..0990c2b9 100644 --- a/ir/irtypestruct.cpp +++ b/ir/irtypestruct.cpp @@ -1,3 +1,12 @@ +//===-- irtypestruct.cpp --------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "llvm/DerivedTypes.h" #include "aggregate.h" diff --git a/ir/irtypestruct.h b/ir/irtypestruct.h index 7417fc0c..d1ad3e72 100644 --- a/ir/irtypestruct.h +++ b/ir/irtypestruct.h @@ -1,3 +1,17 @@ +//===-- ir/irtypestruct.h - IrType subclasses for aggregates ----*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Provides the IrType subclasses used to represent D struct types +// (see irtypeclass.h for the class version). +// +//===----------------------------------------------------------------------===// + #ifndef __LDC_IR_IRTYPESTRUCT_H__ #define __LDC_IR_IRTYPESTRUCT_H__ diff --git a/ir/irvar.cpp b/ir/irvar.cpp index e338f123..5b8ec6b0 100644 --- a/ir/irvar.cpp +++ b/ir/irvar.cpp @@ -1,3 +1,12 @@ +//===-- irvar.cpp ---------------------------------------------------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// + #include "gen/llvm.h" #include "declaration.h" #include "gen/irstate.h" diff --git a/ir/irvar.h b/ir/irvar.h index 680c112b..dbd29dd2 100644 --- a/ir/irvar.h +++ b/ir/irvar.h @@ -1,3 +1,17 @@ +//===-- ir/irdsymbol.h - Codegen state for D vars/fields/params -*- C++ -*-===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// Classes for representing the status of D variables on their way though the +// codegen process. +// +//===----------------------------------------------------------------------===// + #ifndef LDC_IR_IRVAR_H #define LDC_IR_IRVAR_H diff --git a/tango-0.99.8.patch b/tango-0.99.8.patch deleted file mode 100644 index 8a90be2f..00000000 --- a/tango-0.99.8.patch +++ /dev/null @@ -1,121 +0,0 @@ -Index: object.di -=================================================================== ---- object.di (revision 4578) -+++ object.di (working copy) -@@ -35,15 +35,17 @@ - Interface[] interfaces; - ClassInfo base; - void* destructor; -- void(*classInvariant)(Object); -+ void* classInvariant; - uint flags; - // 1: // IUnknown - // 2: // has no possible pointers into GC memory - // 4: // has offTi[] member - // 8: // has constructors -+ // 32: // has typeinfo - void* deallocator; - OffsetTypeInfo[] offTi; - void* defaultConstructor; -+ TypeInfo typeinfo; - - static ClassInfo find(char[] classname); - Object create(); -@@ -127,10 +129,11 @@ - char[] name; - void[] m_init; - -- uint function(void*) xtoHash; -- int function(void*,void*) xopEquals; -- int function(void*,void*) xopCmp; -- char[] function(void*) xtoString; -+ // These are ONLY for use as a delegate.funcptr! -+ hash_t function() xtoHash; -+ int function(void*) xopEquals; -+ int function(void*) xopCmp; -+ char[] function() xtoString; - - uint m_flags; - } -Index: lib/common/tango/core/Thread.d -=================================================================== ---- lib/common/tango/core/Thread.d (revision 4578) -+++ lib/common/tango/core/Thread.d (working copy) -@@ -295,7 +295,7 @@ - } - else version (X86_64) - { -- ulong rax,rbx,rcx,rdx,rbp,rsi,rdi,rsp,r10,r11,r12,r13,r14,r15; -+ ulong rax,rbx,rcx,rdx,rbp,rsi,rdi,rsp,r8,r9,r10,r11,r12,r13,r14,r15; - asm - { - movq rax[RBP], RAX ; -@@ -306,6 +306,8 @@ - movq rsi[RBP], RSI ; - movq rdi[RBP], RDI ; - movq rsp[RBP], RSP ; -+ movq r8[RBP], R8 ; -+ movq r9[RBP], R9 ; - movq r10[RBP], R10 ; - movq r11[RBP], R11 ; - movq r12[RBP], R12 ; -Index: lib/gc/basic/gcx.d -=================================================================== ---- lib/gc/basic/gcx.d (revision 4578) -+++ lib/gc/basic/gcx.d (working copy) -@@ -2198,7 +2198,7 @@ - } - else version (X86_64) - { -- ulong rax,rbx,rcx,rdx,rbp,rsi,rdi,rsp,r10,r11,r12,r13,r14,r15; -+ ulong rax,rbx,rcx,rdx,rbp,rsi,rdi,rsp,r8,r9,r10,r11,r12,r13,r14,r15; - asm - { - movq rax[RBP], RAX ; -@@ -2209,6 +2209,8 @@ - movq rsi[RBP], RSI ; - movq rdi[RBP], RDI ; - movq rsp[RBP], RSP ; -+ movq r8[RBP], R8 ; -+ movq r9[RBP], R9 ; - movq r10[RBP], R10 ; - movq r11[RBP], R11 ; - movq r12[RBP], R12 ; -Index: tango/text/convert/Layout.d -=================================================================== ---- tango/text/convert/Layout.d (revision 4578) -+++ tango/text/convert/Layout.d (working copy) -@@ -660,8 +660,12 @@ - - case TypeCode.STRUCT: - auto s = cast(TypeInfo_Struct) type; -- if (s.xtoString) -- return Utf.fromString8 (s.xtoString(p), result); -+ if (s.xtoString) { -+ char[] delegate() toString; -+ toString.ptr = p; -+ toString.funcptr = cast(char[] function()) s.xtoString; -+ return Utf.fromString8 (toString(), result); -+ } - goto default; - - case TypeCode.INTERFACE: -Index: tango/net/Socket.d -=================================================================== ---- tango/net/Socket.d (revision 4578) -+++ tango/net/Socket.d (working copy) -@@ -1545,10 +1545,10 @@ - - abstract class Address - { -- protected sockaddr* name(); -- protected int nameLen(); -- AddressFamily addressFamily(); -- char[] toString(); -+ abstract protected sockaddr* name(); -+ abstract protected int nameLen(); -+ abstract AddressFamily addressFamily(); -+ abstract char[] toString(); - - /*********************************************************************** - diff --git a/tango-0.99.9.patch b/tango-0.99.9.patch deleted file mode 100644 index 5bcc69de..00000000 --- a/tango-0.99.9.patch +++ /dev/null @@ -1,948 +0,0 @@ -Index: tango/core/rt/compiler/ldc/ldc/intrinsics.di -=================================================================== ---- tango/core/rt/compiler/ldc/ldc/intrinsics.di (revision 5576) -+++ tango/core/rt/compiler/ldc/ldc/intrinsics.di (working copy) -@@ -101,8 +101,16 @@ - // Note that, unlike the standard libc function, the llvm.memcpy.* intrinsics do - // not return a value, and takes an extra alignment argument. - --pragma(intrinsic, "llvm.memcpy.i#") -- void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment); -+version(LDC_LLVMPre28) -+{ -+ pragma(intrinsic, "llvm.memcpy.i#") -+ void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment); -+} -+else -+{ -+ pragma(intrinsic, "llvm.memcpy.p0i8.p0i8.i#") -+ void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment, bool volatile_); -+} - - deprecated { - alias llvm_memcpy!(uint) llvm_memcpy_i32; -@@ -116,8 +124,16 @@ - // Note that, unlike the standard libc function, the llvm.memmove.* intrinsics - // do not return a value, and takes an extra alignment argument. - --pragma(intrinsic, "llvm.memmove.i#") -- void llvm_memmove(T)(void* dst, void* src, T len, uint alignment); -+version(LDC_LLVMPre28) -+{ -+ pragma(intrinsic, "llvm.memmove.i#") -+ void llvm_memmove(T)(void* dst, void* src, T len, uint alignment); -+} -+else -+{ -+ pragma(intrinsic, "llvm.memmove.p0i8.p0i8.i#") -+ void llvm_memmove(T)(void* dst, void* src, T len, uint alignment, bool volatile_); -+} - - deprecated { - alias llvm_memmove!(uint) llvm_memmove_i32; -@@ -130,8 +146,16 @@ - // Note that, unlike the standard libc function, the llvm.memset intrinsic does - // not return a value, and takes an extra alignment argument. - --pragma(intrinsic, "llvm.memset.i#") -- void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment); -+version(LDC_LLVMPre28) -+{ -+ pragma(intrinsic, "llvm.memset.i#") -+ void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment); -+} -+else -+{ -+ pragma(intrinsic, "llvm.memset.p0i8.i#") -+ void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment, bool volatile_); -+} - - deprecated { - alias llvm_memset!(uint) llvm_memset_i32; -Index: tango/core/rt/compiler/ldc/rt/lifetime.d -=================================================================== ---- tango/core/rt/compiler/ldc/rt/lifetime.d (revision 5576) -+++ tango/core/rt/compiler/ldc/rt/lifetime.d (working copy) -@@ -241,7 +241,7 @@ - } - - /** -- * As _d_newarrayT, but -+ * As _d_newarrayT, but - * for when the array has a non-zero initializer. - */ - extern (C) void* _d_newarrayiT(TypeInfo ti, size_t length) -@@ -359,7 +359,7 @@ - - - /** -- * As _d_newarraymT, but -+ * As _d_newarraymT, but - * for when the array has a non-zero initializer. - */ - extern (C) void* _d_newarraymiT(TypeInfo ti, int ndims, size_t* dims) -@@ -483,7 +483,7 @@ - // if (p) - // { - // This assert on array consistency may fail with casts or in unions. --// This function still does something sensible even if plength && !pdata. -+// This function still does something sensible even if plength && !pdata. - // assert(!plength || pdata); - - if (pdata) -@@ -505,9 +505,9 @@ - } - } - --/** -- * -- */ -+/** -+ * -+ */ - extern (C) void _d_callinterfacefinalizer(void *p) - { - if (p) -@@ -544,9 +544,9 @@ - - if (p) // not necessary if called from gc - { -- if (det) -- (cast(Object)p).dispose(); -- -+ if (det) -+ (cast(Object)p).dispose(); -+ - ClassInfo** pc = cast(ClassInfo**)p; - - if (*pc) -@@ -593,7 +593,7 @@ - { - assert(ti); - // This assert on array consistency may fail with casts or in unions. --// This function still does something sensible even if plength && !pdata. -+// This function still does something sensible even if plength && !pdata. - // assert(!plength || pdata); - } - body -@@ -651,7 +651,6 @@ - return newdata; - } - -- - /** - * Resize arrays for non-zero initializers. - * p pointer to array lvalue to be updated -@@ -664,7 +663,7 @@ - in - { - // This assert on array consistency may fail with casts or in unions. --// This function still does something sensible even if plength && !pdata. -+// This function still does something sensible even if plength && !pdata. - // assert(!plength || pdata); - } - body -@@ -786,6 +785,7 @@ - return *cast(long*)px; - } - -++/ - - /** - * -@@ -824,8 +824,8 @@ - const size_t b=0; // flatness factor, how fast the extra space decreases with array size - const size_t a=100; // allocate at most a% of the requested size as extra space (rounding will change this) - const size_t minBits=1; // minimum bit size -- - -+ - static size_t log2plusB(size_t c) - { - // could use the bsr bit op -@@ -847,12 +847,12 @@ - return newcap; - } - -- - /** -- * -+ * Appends a single element to an array. - */ --extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...) -+extern (C) byte[] _d_arrayappendcT(TypeInfo ti, void* array, void* element) - { -+ auto x = cast(byte[]*)array; - auto sizeelem = ti.next.tsize(); // array element size - auto info = gc_query(x.ptr); - auto length = x.length; -@@ -879,18 +879,19 @@ - assert(newcap >= newlength * sizeelem); - newdata = cast(byte *)gc_malloc(newcap + 1, info.attr); - memcpy(newdata, x.ptr, length * sizeelem); -- (cast(void**)(&x))[1] = newdata; -+ (cast(void**)x)[1] = newdata; - } - L1: -- byte *argp = cast(byte *)(&ti + 2); -+ byte *argp = cast(byte *)element; - -- *cast(size_t *)&x = newlength; -+ *cast(size_t *)x = newlength; - x.ptr[length * sizeelem .. newsize] = argp[0 .. sizeelem]; - assert((cast(size_t)x.ptr & 15) == 0); - assert(gc_sizeOf(x.ptr) > x.length * sizeelem); -- return x; -+ return *x; - } - -+/+ - - /** - * Append dchar to char[] -@@ -1128,7 +1129,6 @@ - return result; - } - -- - /** - * - */ -Index: tango/core/rt/compiler/ldc/rt/arrayInit.d -=================================================================== ---- tango/core/rt/compiler/ldc/rt/arrayInit.d (revision 5576) -+++ tango/core/rt/compiler/ldc/rt/arrayInit.d (working copy) -@@ -114,7 +114,10 @@ - auto p = a; - auto end = a + na*nv; - while (p !is end) { -- llvm_memcpy(p,v,nv,0); -+ version(LDC_LLVMPre28) -+ llvm_memcpy(p,v,nv,0); -+ else -+ llvm_memcpy(p,v,nv,1, false); - p += nv; - } - } -@@ -164,7 +167,12 @@ - if (dstlen != srclen) - throw new Exception("lengths don't match for array copy"); - else if (dst+dstlen <= src || src+srclen <= dst) -- llvm_memcpy(dst, src, dstlen, 0); -+ { -+ version(LDC_LLVMPre28) -+ llvm_memcpy(dst, src, dstlen, 0); -+ else -+ llvm_memcpy(dst, src, dstlen, 1, false); -+ } - else - throw new Exception("overlapping array copy"); - } -Index: tango/core/rt/compiler/ldc/rt/eh.d -=================================================================== ---- tango/core/rt/compiler/ldc/rt/eh.d (revision 5576) -+++ tango/core/rt/compiler/ldc/rt/eh.d (working copy) -@@ -1,38 +1,34 @@ - /** - * This module contains functions and structures required for -- * exception handling. -+ * dwarf exception handling with llvm - */ - module rt.eh; - --import ldc.cstdarg; --import rt.compiler.util.console; -+//debug = EH_personality; - --// debug = EH_personality; -- - // current EH implementation works on x86 - // if it has a working unwind runtime - version(X86) { - version(linux) version=X86_UNWIND; - version(darwin) version=X86_UNWIND; - version(solaris) version=X86_UNWIND; -- version(freebsd) version=X86_UNWIND; - } - version(X86_64) { - version(linux) version=X86_UNWIND; - version(darwin) version=X86_UNWIND; - version(solaris) version=X86_UNWIND; -- version(freebsd) version=X86_UNWIND; - } - - //version = HP_LIBUNWIND; - - private extern(C) void abort(); - private extern(C) int printf(char*, ...); --private extern(C) int vprintf(char*, va_list va); -+//private extern(C) int vprintf(char*, va_list va); - - // D runtime functions - extern(C) { -- int _d_isbaseof(ClassInfo oc, ClassInfo c); -+// int _d_isbaseof(ClassInfo oc, ClassInfo c); -+ Object _d_dynamic_cast(Object o, ClassInfo c); - } - - // libunwind headers -@@ -74,16 +70,19 @@ - // interface to HP's libunwind from http://www.nongnu.org/libunwind/ - version(HP_LIBUNWIND) - { -+ // Haven't checked whether and how it has _Unwind_Get{Text,Data}RelBase -+ pragma (msg, "HP_LIBUNWIND interface is out of date and untested"); -+ - void __libunwind_Unwind_Resume(_Unwind_Exception *); - _Unwind_Reason_Code __libunwind_Unwind_RaiseException(_Unwind_Exception *); - ptrdiff_t __libunwind_Unwind_GetLanguageSpecificData(_Unwind_Context_Ptr - context); -- ptrdiff_t __libunwind_Unwind_GetIP(_Unwind_Context_Ptr context); -+ size_t __libunwind_Unwind_GetIP(_Unwind_Context_Ptr context); - ptrdiff_t __libunwind_Unwind_SetIP(_Unwind_Context_Ptr context, - ptrdiff_t new_value); - ptrdiff_t __libunwind_Unwind_SetGR(_Unwind_Context_Ptr context, int index, - ptrdiff_t new_value); -- ptrdiff_t __libunwind_Unwind_GetRegionStart(_Unwind_Context_Ptr context); -+ size_t __libunwind_Unwind_GetRegionStart(_Unwind_Context_Ptr context); - - alias __libunwind_Unwind_Resume _Unwind_Resume; - alias __libunwind_Unwind_RaiseException _Unwind_RaiseException; -@@ -94,27 +93,30 @@ - alias __libunwind_Unwind_SetGR _Unwind_SetGR; - alias __libunwind_Unwind_GetRegionStart _Unwind_GetRegionStart; - } --else version(X86_UNWIND) -+else version(X86_UNWIND) - { - void _Unwind_Resume(_Unwind_Exception*); - _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception*); - ptrdiff_t _Unwind_GetLanguageSpecificData(_Unwind_Context_Ptr context); -- ptrdiff_t _Unwind_GetIP(_Unwind_Context_Ptr context); -+ size_t _Unwind_GetIP(_Unwind_Context_Ptr context); - ptrdiff_t _Unwind_SetIP(_Unwind_Context_Ptr context, ptrdiff_t new_value); - ptrdiff_t _Unwind_SetGR(_Unwind_Context_Ptr context, int index, - ptrdiff_t new_value); -- ptrdiff_t _Unwind_GetRegionStart(_Unwind_Context_Ptr context); -+ size_t _Unwind_GetRegionStart(_Unwind_Context_Ptr context); -+ -+ size_t _Unwind_GetTextRelBase(_Unwind_Context_Ptr); -+ size_t _Unwind_GetDataRelBase(_Unwind_Context_Ptr); - } - else - { - // runtime calls these directly - void _Unwind_Resume(_Unwind_Exception*) - { -- console("_Unwind_Resume is not implemented on this platform.\n"); -+ printf("_Unwind_Resume is not implemented on this platform.\n"); - } - _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception*) - { -- console("_Unwind_RaiseException is not implemented on this platform.\n"); -+ printf("_Unwind_RaiseException is not implemented on this platform.\n"); - return _Unwind_Reason_Code.FATAL_PHASE1_ERROR; - } - } -@@ -122,14 +124,161 @@ - } - - // error and exit --extern(C) private void fatalerror(char[] format) -+extern(C) private void fatalerror(char* format, ...) - { -- printf("Fatal error in EH code: %.*s\n", format.length, format.ptr); -+// va_list args; -+// va_start(args, format); -+ printf("Fatal error in EH code: "); -+// vprintf(format, args); -+ printf("\n"); - abort(); - } - - --// helpers for reading certain DWARF data -+// DWARF EH encoding enum -+// See e.g. http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/dwarfext.html -+private enum : ubyte { -+ DW_EH_PE_omit = 0xff, // value is not present -+ -+ // value format -+ DW_EH_PE_absptr = 0x00, // literal pointer -+ DW_EH_PE_uleb128 = 0x01, -+ DW_EH_PE_udata2 = 0x02, // unsigned 2-byte -+ DW_EH_PE_udata4 = 0x03, -+ DW_EH_PE_udata8 = 0x04, -+ DW_EH_PE_sleb128 = 0x09, -+ DW_EH_PE_sdata2 = 0x0a, -+ DW_EH_PE_sdata4 = 0x0b, -+ DW_EH_PE_sdata8 = 0x0c, -+ -+ // value meaning -+ DW_EH_PE_pcrel = 0x10, // relative to program counter -+ DW_EH_PE_textrel = 0x20, // relative to .text -+ DW_EH_PE_datarel = 0x30, // relative to .got or .eh_frame_hdr -+ DW_EH_PE_funcrel = 0x40, // relative to beginning of function -+ DW_EH_PE_aligned = 0x50, // is an aligned void* -+ -+ // value is a pointer to the actual value -+ // this is a mask on top of one of the above -+ DW_EH_PE_indirect = 0x80 -+} -+ -+// Helpers for reading DWARF data -+ -+// Given an encoding and a context, return the base to which the encoding is -+// relative -+private size_t base_of_encoded(_Unwind_Context_Ptr context, ubyte encoding) -+{ -+ if (encoding == DW_EH_PE_omit) -+ return 0; -+ -+ switch (encoding & 0x70) // ignore DW_EH_PE_indirect -+ { -+ case DW_EH_PE_absptr, DW_EH_PE_pcrel, DW_EH_PE_aligned: -+ return 0; -+ -+ case DW_EH_PE_textrel: return _Unwind_GetTextRelBase(context); -+ case DW_EH_PE_datarel: return _Unwind_GetDataRelBase(context); -+ case DW_EH_PE_funcrel: return _Unwind_GetRegionStart(context); -+ -+ default: fatalerror("Unrecognized base for DWARF value"); -+ } -+} -+ -+// Only defined for fixed-size encodings -+private size_t size_of_encoded(ubyte encoding) -+{ -+ if (encoding == DW_EH_PE_omit) -+ return 0; -+ -+ switch (encoding & 0x07) // ignore leb128 -+ { -+ case DW_EH_PE_absptr: return (void*).sizeof; -+ case DW_EH_PE_udata2: return 2; -+ case DW_EH_PE_udata4: return 4; -+ case DW_EH_PE_udata8: return 8; -+ -+ default: fatalerror("Unrecognized fixed-size DWARF value encoding"); -+ } -+} -+ -+// Actual value readers below: read a value from the given ubyte* into the -+// output parameter and return the pointer incremented past the value. -+ -+// Like read_encoded_with_base but gets the base from the given context -+private ubyte* read_encoded(_Unwind_Context_Ptr context, ubyte encoding, ubyte* p, out size_t val) -+{ -+ return read_encoded_with_base(encoding, base_of_encoded(context, encoding), p, val); -+} -+ -+private ubyte* read_encoded_with_base(ubyte encoding, size_t base, ubyte* p, out size_t val) -+{ -+ if (encoding == DW_EH_PE_aligned) -+ { -+ auto a = cast(size_t)p; -+ a = (a + (void*).sizeof - 1) & -(void*).sizeof; -+ val = *cast(size_t*)a; -+ return cast(ubyte*)(a + (void*).sizeof); -+ } -+ -+ union U -+ { -+ size_t ptr; -+ ushort udata2; -+ uint udata4; -+ ulong udata8; -+ short sdata2; -+ int sdata4; -+ long sdata8; -+ } -+ -+ auto u = cast(U*)p; -+ -+ size_t result; -+ -+ switch (encoding & 0x0f) -+ { -+ case DW_EH_PE_absptr: -+ result = u.ptr; -+ p += (void*).sizeof; -+ break; -+ -+ case DW_EH_PE_uleb128: -+ { -+ p = get_uleb128(p, result); -+ break; -+ } -+ case DW_EH_PE_sleb128: -+ { -+ ptrdiff_t sleb128; -+ p = get_sleb128(p, sleb128); -+ result = cast(size_t)sleb128; -+ break; -+ } -+ -+ case DW_EH_PE_udata2: result = cast(size_t)u.udata2; p += 2; break; -+ case DW_EH_PE_udata4: result = cast(size_t)u.udata4; p += 4; break; -+ case DW_EH_PE_udata8: result = cast(size_t)u.udata8; p += 8; break; -+ case DW_EH_PE_sdata2: result = cast(size_t)u.sdata2; p += 2; break; -+ case DW_EH_PE_sdata4: result = cast(size_t)u.sdata4; p += 4; break; -+ case DW_EH_PE_sdata8: result = cast(size_t)u.sdata8; p += 8; break; -+ -+ default: fatalerror("Unrecognized DWARF value encoding format"); -+ } -+ if (result) -+ { -+ if ((encoding & 0x70) == DW_EH_PE_pcrel) -+ result += cast(size_t)u; -+ else -+ result += base; -+ -+ if (encoding & DW_EH_PE_indirect) -+ result = *cast(size_t*)result; -+ } -+ val = result; -+ return p; -+} -+ - private ubyte* get_uleb128(ubyte* addr, ref size_t res) - { - res = 0; -@@ -137,7 +286,7 @@ - - // read as long as high bit is set - while(*addr & 0x80) { -- res |= (*addr & 0x7f) << bitsize; -+ res |= (*addr & 0x7fU) << bitsize; - bitsize += 7; - addr += 1; - if(bitsize >= size_t.sizeof*8) -@@ -153,12 +302,12 @@ - - private ubyte* get_sleb128(ubyte* addr, ref ptrdiff_t res) - { -- res = 0; -+ size_t tres = 0; - size_t bitsize = 0; - - // read as long as high bit is set - while(*addr & 0x80) { -- res |= (*addr & 0x7f) << bitsize; -+ tres |= (*addr & 0x7fU) << bitsize; - bitsize += 7; - addr += 1; - if(bitsize >= size_t.sizeof*8) -@@ -167,12 +316,14 @@ - // read last - if(bitsize != 0 && *addr >= 1 << size_t.sizeof*8 - bitsize) - fatalerror("tried to read sleb128 that exceeded size of size_t"); -- res |= (*addr) << bitsize; -+ tres |= (*addr) << bitsize; - - // take care of sign -- if(bitsize < size_t.sizeof*8 && ((*addr) & 0x40)) -- res |= cast(ptrdiff_t)(-1) ^ ((1 << (bitsize+7)) - 1); -+ if(bitsize < size_t.sizeof*8 && (*addr & 0x40U) != 0) -+ tres |= cast(size_t)(-1) ^ ((1 << (bitsize+7)) - 1); - -+ res = cast(ptrdiff_t)tres; -+ - return addr + 1; - } - -@@ -190,8 +341,7 @@ - - // the 8-byte string identifying the type of exception - // the first 4 are for vendor, the second 4 for language --//TODO: This may be the wrong way around --const char[8] _d_exception_class = "LLDCD1\0\0"; -+const char[8] _d_exception_class = "LDC_D_10"; - - - // -@@ -201,118 +351,174 @@ - version(X86_UNWIND) - { - -+// Various stuff we need -+struct Region -+{ -+ ubyte* callsite_table; -+ ubyte* action_table; -+ -+ // Note: classinfo_table points past the end of the table -+ ubyte* classinfo_table; -+ -+ size_t start; -+ size_t lpStart_base; // landing pad base -+ -+ ubyte ttypeEnc; -+ size_t ttype_base; // typeinfo base -+ -+ ubyte callSiteEnc; -+} -+ - // the personality routine gets called by the unwind handler and is responsible for - // reading the EH tables and deciding what to do - extern(C) _Unwind_Reason_Code _d_eh_personality(int ver, _Unwind_Action actions, ulong exception_class, _Unwind_Exception* exception_info, _Unwind_Context_Ptr context) - { -+ debug(EH_personality) printf("Entering personality routine, context=%p\n", context); - // check ver: the C++ Itanium ABI only allows ver == 1 - if(ver != 1) -+ { -+ debug(EH_personality) printf("eh version mismatch\n"); - return _Unwind_Reason_Code.FATAL_PHASE1_ERROR; -+ } - - // check exceptionClass - //TODO: Treat foreign exceptions with more respect -- if((cast(char*)&exception_class)[0..8] != _d_exception_class) -+ auto wanted_ec = *cast(ulong*)_d_exception_class.ptr; -+ if(exception_class != wanted_ec) -+ { -+ debug(EH_personality) printf("exception class mismatch %p vs %p\n", exception_class, wanted_ec); - return _Unwind_Reason_Code.FATAL_PHASE1_ERROR; -+ } - - // find call site table, action table and classinfo table - // Note: callsite and action tables do not contain static-length - // data and will be parsed as needed -- // Note: classinfo_table points past the end of the table -- ubyte* callsite_table; -- ubyte* action_table; -- ClassInfo* classinfo_table; -- _d_getLanguageSpecificTables(context, callsite_table, action_table, classinfo_table); -- if (!callsite_table) -+ -+ Region region; -+ -+ _d_getLanguageSpecificTables(context, region); -+ -+ // workaround. this should not happen -+ if (!region.callsite_table) -+ { -+ debug(EH_personality) printf("callsite_table is null\n"); - return _Unwind_Reason_Code.CONTINUE_UNWIND; -+ } - -+ debug(EH_personality) printf("yay, checking\n"); -+ debug(EH_personality) printf("region.start = %p\n", region.start); -+ - /* - find landing pad and action table index belonging to ip by walking - the callsite_table - */ -- ubyte* callsite_walker = callsite_table; -+ ubyte* callsite_walker = region.callsite_table; -+ debug(EH_personality) printf("callsite table at: %p\n", region.callsite_table); -+ debug(EH_personality) printf("action table at: %p\n", region.action_table); -+ debug(EH_personality) printf("rtti table at %p\n", region.classinfo_table); - - // get the instruction pointer - // will be used to find the right entry in the callsite_table - // -1 because it will point past the last instruction -- ptrdiff_t ip = _Unwind_GetIP(context) - 1; -+ debug(EH_personality) printf("check1\n"); -+ size_t ip = _Unwind_GetIP(context) - 1; -+ debug(EH_personality) printf("check2\n"); - -- // address block_start is relative to -- ptrdiff_t region_start = _Unwind_GetRegionStart(context); -- - // table entries -- uint block_start_offset, block_size; -- ptrdiff_t landing_pad; -+ size_t landing_pad; - size_t action_offset; - - while(true) { - // if we've gone through the list and found nothing... -- if(callsite_walker >= action_table) -+ if(callsite_walker >= region.action_table) -+ { -+ debug(EH_personality) printf("found nothing\n"); - return _Unwind_Reason_Code.CONTINUE_UNWIND; -+ } - -- block_start_offset = *cast(uint*)callsite_walker; -- block_size = *(cast(uint*)callsite_walker + 1); -- landing_pad = *(cast(uint*)callsite_walker + 2); -- if(landing_pad) -- landing_pad += region_start; -- callsite_walker = get_uleb128(callsite_walker + 3*uint.sizeof, action_offset); -+ size_t block_start, block_size; - -- debug(EH_personality_verbose) printf("ip=%llx %d %d %llx\n", ip, block_start_offset, block_size, landing_pad); -+ callsite_walker = read_encoded(null, region.callSiteEnc, callsite_walker, block_start); -+ callsite_walker = read_encoded(null, region.callSiteEnc, callsite_walker, block_size); -+ callsite_walker = read_encoded(null, region.callSiteEnc, callsite_walker, landing_pad); -+ callsite_walker = get_uleb128(callsite_walker, action_offset); - -+ debug(EH_personality) printf("*block start offset = %p\n", block_start); -+ debug(EH_personality) printf(" block size = %p\n", block_size); -+ debug(EH_personality) printf(" landing pad = %p\n", landing_pad); -+ debug(EH_personality) printf(" ip=%p %p %p %p\n", ip, block_start, block_size, landing_pad); -+ - // since the list is sorted, as soon as we're past the ip - // there's no handler to be found -- if(ip < region_start + block_start_offset) -+ if(ip < region.start + block_start) -+ { -+ debug(EH_personality) printf("found nothing2\n"); - return _Unwind_Reason_Code.CONTINUE_UNWIND; -+ } - -+ if(landing_pad) -+ landing_pad += region.lpStart_base; -+ - // if we've found our block, exit -- if(ip < region_start + block_start_offset + block_size) -+ if(ip < region.start + block_start + block_size) - break; - } - -- debug(EH_personality) printf("Found correct landing pad and actionOffset %d\n", action_offset); -+ debug(EH_personality) printf("Found correct landing pad %p and actionOffset %p\n", landing_pad, action_offset); - - // now we need the exception's classinfo to find a handler - // the exception_info is actually a member of a larger _d_exception struct - // the runtime allocated. get that now -- _d_exception* exception_struct = cast(_d_exception*)(cast(ubyte*)exception_info - _d_exception.unwind_info.offsetof); -+ _d_exception* exception_struct = cast(_d_exception*)(cast(ubyte*)exception_info - size_t.sizeof); //_d_exception.unwind_info.offsetof); - - // if there's no action offset and no landing pad, continue unwinding - if(!action_offset && !landing_pad) - return _Unwind_Reason_Code.CONTINUE_UNWIND; - - // if there's no action offset but a landing pad, this is a cleanup handler -- else if(!action_offset && landing_pad) -- return _d_eh_install_finally_context(actions, landing_pad, exception_struct, context); -+ else if(!action_offset && landing_pad != 0) -+ { -+ debug(EH_personality) printf("installing finally context\n"); -+ return _d_eh_install_finally_context(actions, cast(ptrdiff_t)landing_pad, exception_struct, context); -+ } - - /* - walk action table chain, comparing classinfos using _d_isbaseof - */ -- ubyte* action_walker = action_table + action_offset - 1; -+ ubyte* action_walker = region.action_table + action_offset - 1; - -- ptrdiff_t ti_offset, next_action_offset; - while(true) { -+ ptrdiff_t ti_offset, next_action_offset; -+ - action_walker = get_sleb128(action_walker, ti_offset); - // it is intentional that we not modify action_walker here - // next_action_offset is from current action_walker position - get_sleb128(action_walker, next_action_offset); - - // negative are 'filters' which we don't use -- if(!(ti_offset >= 0)) -+ if(ti_offset < 0) - fatalerror("Filter actions are unsupported"); - - // zero means cleanup, which we require to be the last action - if(ti_offset == 0) { -- if(!(next_action_offset == 0)) -+ if(next_action_offset != 0) - fatalerror("Cleanup action must be last in chain"); -- return _d_eh_install_finally_context(actions, landing_pad, exception_struct, context); -+ return _d_eh_install_finally_context(actions, cast(ptrdiff_t)landing_pad, exception_struct, context); - } - - // get classinfo for action and check if the one in the - // exception structure is a base -- ClassInfo catch_ci = *(classinfo_table - ti_offset); -- debug(EH_personality) printf("Comparing catch %s to exception %s\n", catch_ci.name.ptr, exception_struct.exception_object.classinfo.name.ptr); -- if(_d_isbaseof(exception_struct.exception_object.classinfo, catch_ci)) -- return _d_eh_install_catch_context(actions, ti_offset, landing_pad, exception_struct, context); -+ size_t typeinfo; -+ auto filter = cast(size_t)ti_offset * size_of_encoded(region.ttypeEnc); -+ read_encoded_with_base(region.ttypeEnc, region.ttype_base, region.classinfo_table - filter, typeinfo); - -+ debug(EH_personality) -+ printf("classinfo at %zx (enc %zx (size %zx) base %zx ptr %zx)\n", typeinfo, region.ttypeEnc, size_of_encoded(region.ttypeEnc), region.ttype_base, region.classinfo_table - filter); -+ -+ auto catch_ci = *cast(ClassInfo*)&typeinfo; -+ if(_d_dynamic_cast(exception_struct.exception_object, catch_ci) !is null) -+ return _d_eh_install_catch_context(actions, ti_offset, cast(ptrdiff_t)landing_pad, exception_struct, context); -+ - // we've walked through all actions and found nothing... - if(next_action_offset == 0) - return _Unwind_Reason_Code.CONTINUE_UNWIND; -@@ -356,6 +562,7 @@ - } - - fatalerror("reached unreachable"); -+ - return _Unwind_Reason_Code.FATAL_PHASE2_ERROR; - } - -@@ -370,56 +577,78 @@ - _Unwind_SetGR(context, eh_exception_regno, cast(ptrdiff_t)exception_struct); - _Unwind_SetGR(context, eh_selector_regno, 0); - _Unwind_SetIP(context, landing_pad); -+ - return _Unwind_Reason_Code.INSTALL_CONTEXT; - } - --private void _d_getLanguageSpecificTables(_Unwind_Context_Ptr context, ref ubyte* callsite, ref ubyte* action, ref ClassInfo* ci) -+private void _d_getLanguageSpecificTables(_Unwind_Context_Ptr context, out Region region) - { -- ubyte* data = cast(ubyte*)_Unwind_GetLanguageSpecificData(context); -+ auto data = cast(ubyte*)_Unwind_GetLanguageSpecificData(context); -+ -+ // workaround. this should not be 0... - if (!data) - { -- callsite = null; -- action = null; -- ci = null; -- return; -+ //printf("language specific data is null\n"); -+ return; - } - -- //TODO: Do proper DWARF reading here -- if(*data++ != 0xff) -- fatalerror("DWARF header has unexpected format 1"); -+ region.start = _Unwind_GetRegionStart(context); - -- if(*data++ != 0x00) -- fatalerror("DWARF header has unexpected format 2"); -- size_t cioffset; -- data = get_uleb128(data, cioffset); -- ci = cast(ClassInfo*)(data + cioffset); -+ // Read the C++-style LSDA: this is implementation-defined by GCC but LLVM -+ // outputs the same kind of table - -- if(*data++ != 0x03) -- fatalerror("DWARF header has unexpected format 3"); -- size_t callsitelength; -- data = get_uleb128(data, callsitelength); -- action = data + callsitelength; -+ // Get @LPStart: landing pad offsets are relative to it -+ auto lpStartEnc = *data++; -+ if (lpStartEnc == DW_EH_PE_omit) -+ region.lpStart_base = region.start; -+ else -+ data = read_encoded(context, lpStartEnc, data, region.lpStart_base); - -- callsite = data; -+ // Get @TType: the offset to the handler and typeinfo -+ region.ttypeEnc = *data++; -+ if (region.ttypeEnc == DW_EH_PE_omit) -+ // Not sure about this one... -+ fatalerror("@TType must not be omitted from DWARF header"); -+ -+ size_t ciOffset; -+ data = get_uleb128(data, ciOffset); -+ region.classinfo_table = data + ciOffset; -+ -+ region.ttype_base = base_of_encoded(context, region.ttypeEnc); -+ -+ // Get encoding and length of the call site table, which precedes the action -+ // table. -+ region.callSiteEnc = *data++; -+ if (region.callSiteEnc == DW_EH_PE_omit) -+ fatalerror("Call site table encoding must not be omitted from DWARF header"); -+ -+ size_t callSiteLength; -+ region.callsite_table = get_uleb128(data, callSiteLength); -+ region.action_table = region.callsite_table + callSiteLength; - } - - } // end of x86 Linux specific implementation - -- --extern(C) void _d_throw_exception(Object e) -+// called to throw object -+extern(C) -+void _d_throw_exception(Object e) - { -+ //printf("throwing %p, rtti = %p\n", e, **cast(ClassRTTI***)e); - if (e !is null) - { - _d_exception* exc_struct = new _d_exception; - exc_struct.unwind_info.exception_class = *cast(ulong*)_d_exception_class.ptr; - exc_struct.exception_object = e; - _Unwind_Reason_Code ret = _Unwind_RaiseException(&exc_struct.unwind_info); -- console("_Unwind_RaiseException failed with reason code: ")(ret)("\n"); -+ printf("Error: returned %d from raise exception.\n", ret); -+ //console("_Unwind_RaiseException failed with reason code: ")(ret)("\n"); - } - abort(); - } - --extern(C) void _d_eh_resume_unwind(_d_exception* exception_struct) -+// called to resume unwinding -+extern(C) -+void _d_eh_resume_unwind(void* exception_struct) - { -- _Unwind_Resume(&exception_struct.unwind_info); -+ _Unwind_Resume(&(cast(_d_exception*)exception_struct).unwind_info); - } -Index: tango/core/vendor/ldc/intrinsics.di -=================================================================== ---- tango/core/vendor/ldc/intrinsics.di (revision 5576) -+++ tango/core/vendor/ldc/intrinsics.di (working copy) -@@ -101,8 +101,16 @@ - // Note that, unlike the standard libc function, the llvm.memcpy.* intrinsics do - // not return a value, and takes an extra alignment argument. - --pragma(intrinsic, "llvm.memcpy.i#") -- void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment); -+version(LDC_LLVMPre28) -+{ -+ pragma(intrinsic, "llvm.memcpy.i#") -+ void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment); -+} -+else -+{ -+ pragma(intrinsic, "llvm.memcpy.p0i8.p0i8.i#") -+ void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment, bool volatile_); -+} - - deprecated { - alias llvm_memcpy!(uint) llvm_memcpy_i32; -@@ -116,8 +124,16 @@ - // Note that, unlike the standard libc function, the llvm.memmove.* intrinsics - // do not return a value, and takes an extra alignment argument. - --pragma(intrinsic, "llvm.memmove.i#") -- void llvm_memmove(T)(void* dst, void* src, T len, uint alignment); -+version(LDC_LLVMPre28) -+{ -+ pragma(intrinsic, "llvm.memmove.i#") -+ void llvm_memmove(T)(void* dst, void* src, T len, uint alignment); -+} -+else -+{ -+ pragma(intrinsic, "llvm.memmove.p0i8.p0i8.i#") -+ void llvm_memmove(T)(void* dst, void* src, T len, uint alignment, bool volatile_); -+} - - deprecated { - alias llvm_memmove!(uint) llvm_memmove_i32; -@@ -130,8 +146,16 @@ - // Note that, unlike the standard libc function, the llvm.memset intrinsic does - // not return a value, and takes an extra alignment argument. - --pragma(intrinsic, "llvm.memset.i#") -- void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment); -+version(LDC_LLVMPre28) -+{ -+ pragma(intrinsic, "llvm.memset.i#") -+ void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment); -+} -+else -+{ -+ pragma(intrinsic, "llvm.memset.p0i8.i#") -+ void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment, bool volatile_); -+} - - deprecated { - alias llvm_memset!(uint) llvm_memset_i32; diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index 96c48967..b92d9585 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -1,3 +1,18 @@ +//===-- gen_gccbuiltins.cpp - GCC builtin module generator ----------------===// +// +// LDC – the LLVM D compiler +// +// This file is distributed under the BSD-style LDC license. See the LICENSE +// file for details. +// +//===----------------------------------------------------------------------===// +// +// This tool reads the GCC builtin definitions from LLVM's Intrinsics.td for +// a given architecture and accordingly generates a ldc.gccbuiltins_ +// module for using them from D code. +// +//===----------------------------------------------------------------------===// + #include #include #include @@ -59,7 +74,7 @@ string dtype(Record* rec) string attributes(ListInit* propertyList) { - string prop = propertyList->getSize() ? + string prop = propertyList->getSize() ? propertyList->getElementAsRecord(0)->getName() : ""; return