From sabre at nondot.org Mon Feb 19 00:06:14 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:06:14 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190606.l1J66E9V025756@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.25 -> 1.26 --- Log message: incremental changes to own section, protosection on patents --- Diffs of the changes: (+27 -15) DeveloperPolicy.html | 42 +++++++++++++++++++++++++++--------------- 1 files changed, 27 insertions(+), 15 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.25 llvm/docs/DeveloperPolicy.html:1.26 --- llvm/docs/DeveloperPolicy.html:1.25 Sun Feb 18 23:59:30 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:05:58 2007 @@ -10,7 +10,7 @@
LLVM Developer Policy
  1. Introduction
  2. -
  3. General Policies +
  4. Developer Policies
    1. Stay Informed
    2. Making a Patch
    3. @@ -18,16 +18,15 @@
    4. Test Cases
    5. Quality
    6. Obtaining Commit Access
    7. -
    8. Making a Major Change -
        -
      1. Incremental Development
      2. -
    9. +
    10. Making a Major Change
    11. +
    12. Incremental Development
    13. Attribution of Changes
  5. Copyright and License
    1. Copyright
    2. License
    3. +
    4. Patents
    5. Developer Agreements
@@ -59,7 +58,7 @@ -
General Policies
+
Developer Policies

This section contains policies that pertain generally to regular LLVM @@ -103,16 +102,13 @@

  • Patches should be made with this command:
    cvs diff -Ntdup -5
    - or with the utility utils/mkpatch. to make it easy to read the + or with the utility utils/mkpatch, which makes it easy to read the diff.
  • Patches should not include differences in generated code such as the code generated by flex, bison or tblgen. The utils/mkpatch utility takes care of this for you.
  • -
  • Contributions must not knowingly infringe on any patents. To the best of - our knowledge, LLVM is free of any existing patent violations and it is our - intent to keep it that way.
  • @@ -265,15 +261,20 @@ a major new extension, it is a good idea to get consensus with the development community before you start working on it.

    +

    Once the design of the new feature is finalized, the work itself should be + done as a series of incremental changes, not as + a long-term development branch.

    + -
    Incremental Development +
    Incremental Development
    -

    Once the design of the new feature is finalized, the work itself should be - done as a series of incremental changes, not as a long-term development - branch. Long-term development branches have a number of drawbacks:

    +

    In the LLVM project, we do all significant changes as a series of + incremental patches. We have a strong dislike for huge changes or + long-term development branches. Long-term development branches have a + number of drawbacks:

    1. Branches must have mainline merged into them periodically. If the branch @@ -436,6 +437,17 @@ href="mailto:llvm-oversight at cs.uiuc.edu">LLVM Oversight Group.

    + + +
    Patents
    +
    + +

    Contributions must not knowingly infringe on any patents. To the best of + our knowledge, LLVM is free of any existing patent violations and it is our + intent to keep it that way.

    +
    + +
    Developer Agreements
    @@ -456,7 +468,7 @@ Written by: the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 05:59:30 $ + Last modified: $Date: 2007/02/19 06:05:58 $ From sabre at nondot.org Mon Feb 19 00:14:07 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:14:07 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190614.l1J6E76O025927@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.26 -> 1.27 --- Log message: add strong words about patents --- Diffs of the changes: (+14 -4) DeveloperPolicy.html | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.26 llvm/docs/DeveloperPolicy.html:1.27 --- llvm/docs/DeveloperPolicy.html:1.26 Mon Feb 19 00:05:58 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:13:50 2007 @@ -442,9 +442,19 @@
    -

    Contributions must not knowingly infringe on any patents. To the best of - our knowledge, LLVM is free of any existing patent violations and it is our - intent to keep it that way.

    +

    To the best of our knowledge, LLVM does not infringe on any patents (we have + actually removed code from LLVM in the past that was found to infringe). + Having code in LLVM that infringes on patents would violate the one of the + goals of the project by making it hard or impossible to reuse the code for + arbitrary purposes.

    + +

    When contributing code, we expect contributors to notify us of any potential + for patent-related trouble with their changes. If you own the rights to a + patent and would like to contribute code to LLVM that relies on it, we + require that you sign an agreement that allows any other user of LLVM to + freely use your patent. Please contact the oversight group for more + details.

    @@ -468,7 +478,7 @@ Written by: the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 06:05:58 $ + Last modified: $Date: 2007/02/19 06:13:50 $ From sabre at nondot.org Mon Feb 19 00:15:50 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:15:50 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190615.l1J6FoVZ025996@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.27 -> 1.28 --- Log message: wording changes --- Diffs of the changes: (+5 -5) DeveloperPolicy.html | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.27 llvm/docs/DeveloperPolicy.html:1.28 --- llvm/docs/DeveloperPolicy.html:1.27 Mon Feb 19 00:13:50 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:15:33 2007 @@ -444,9 +444,9 @@

    To the best of our knowledge, LLVM does not infringe on any patents (we have actually removed code from LLVM in the past that was found to infringe). - Having code in LLVM that infringes on patents would violate the one of the - goals of the project by making it hard or impossible to reuse the code for - arbitrary purposes.

    + Having code in LLVM that infringes on patents would violate an important + goal of the project by making it hard or impossible to reuse the code for + arbitrary purposes (including commercial use).

    When contributing code, we expect contributors to notify us of any potential for patent-related trouble with their changes. If you own the rights to a @@ -475,10 +475,10 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! - Written by: the + Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 06:13:50 $ + Last modified: $Date: 2007/02/19 06:15:33 $ From sabre at nondot.org Mon Feb 19 00:19:33 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:19:33 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190619.l1J6JXTL026091@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.28 -> 1.29 --- Log message: rename section to Copyright, License, and Patents --- Diffs of the changes: (+6 -4) DeveloperPolicy.html | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.28 llvm/docs/DeveloperPolicy.html:1.29 --- llvm/docs/DeveloperPolicy.html:1.28 Mon Feb 19 00:15:33 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:19:16 2007 @@ -22,7 +22,7 @@

  • Incremental Development
  • Attribution of Changes
  • -
  • Copyright and License +
  • Copyright, License, and Patents
    1. Copyright
    2. License
    3. @@ -341,7 +341,7 @@
    4. There should be only one name at the top of the file and it should be the person who created the file.
    5. Placing your name in the file does not imply copyright: it is only used to attribute the file to + href="#clp">copyright: it is only used to attribute the file to its original author.
    6. Developers should be aware that after some time has passed, the name at the top of a file may become meaningless as maintenance/ownership of files @@ -358,7 +358,9 @@ - +
      @@ -478,7 +480,7 @@ Written by the LLVM Oversight Group
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2007/02/19 06:15:33 $ + Last modified: $Date: 2007/02/19 06:19:16 $ From sabre at nondot.org Mon Feb 19 00:24:40 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:24:40 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190624.l1J6Oeav026217@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.29 -> 1.30 --- Log message: add the definite article --- Diffs of the changes: (+2 -2) DeveloperPolicy.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.29 llvm/docs/DeveloperPolicy.html:1.30 --- llvm/docs/DeveloperPolicy.html:1.29 Mon Feb 19 00:19:16 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:24:23 2007 @@ -30,7 +30,7 @@
    7. Developer Agreements
  • -
    Written by LLVM Oversight Team
    +
    Written by the LLVM Oversight Team
    @@ -480,7 +480,7 @@ Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 06:19:16 $ + Last modified: $Date: 2007/02/19 06:24:23 $ From sabre at nondot.org Mon Feb 19 00:57:32 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:57:32 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190657.l1J6vWaY026780@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.30 -> 1.31 --- Log message: more wording changes and some minor additions --- Diffs of the changes: (+61 -42) DeveloperPolicy.html | 103 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 61 insertions(+), 42 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.30 llvm/docs/DeveloperPolicy.html:1.31 --- llvm/docs/DeveloperPolicy.html:1.30 Mon Feb 19 00:24:23 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:57:16 2007 @@ -49,7 +49,7 @@
  • Keep the top of tree CVS/SVN trees as stable as possible.
  • -

    This policy is aimed at regular contributors to LLVM. People interested in +

    This policy is aimed at frequent contributors to LLVM. People interested in contributing one-off patches can do so in an informal way by sending them to the llvm-commits mailing list and engaging another developer to see it through @@ -61,11 +61,11 @@

    -

    This section contains policies that pertain generally to regular LLVM +

    This section contains policies that pertain to frequent LLVM developers. We always welcome random patches from - people who do not routinely contribute to LLVM, but expect more from regular + people who do not routinely contribute to LLVM, but expect more from frequent contributors to keep the system as efficient as possible for everyone. - Regular LLVM developers are expected to meet the following obligations in + Frequent LLVM contributors are expected to meet the following obligations in order for LLVM to maintain a high standard of quality.

    @@ -110,6 +110,11 @@ utils/mkpatch utility takes care of this for you. + +

    When sending a patch to a mailing list, it is a good idea to send it as an + attachment to the message, not embedded into the text of the + message. This ensures that your mailer will not mangle the patch when it + sends it (e.g. by making whitespace changes or by wrapping lines).

    @@ -128,22 +133,25 @@ reviewed after commit.
  • The developer responsible for a code change is also responsible for making all necessary review-related changes.
  • -
  • Code review can be an iterative process, which goes until all the patch +
  • Code review can be an iterative process, which goes until the patch is ready to be committed.
  • -
  • Developers should participate in code reviews as both a reviewer and - a reviewee. We don't have a dedicated team of reviewers. If someone is - kind enough to review your code, you should return the favor for someone - else.
  • + +

    Developers should participate in code reviews as both reviewers and + a reviewees. If someone is kind enough to review your code, you should + return the favor for someone else. Note that anyone is welcome to review + and give feedback on a patch, + but only people with CVS write access can approve it.

    +
    Test Cases

    Developers are required to create test cases for any bugs fixed and any new - features added. The following policies apply:

    + features added. Some tips for getting your testcase approved:

      -
    1. All feature and regression test cases must be added to the +
    2. All feature and regression test cases are added to the llvm/test directory. The appropriate sub-directory should be selected (see the Testing Guide for details).
    3. @@ -151,16 +159,19 @@ LLVM assembly language unless the feature or regression being tested requires another language (e.g. the bug being fixed or feature being implemented is in the llvm-gcc C++ - front-end). + front-end, in which case it must be written in C++).
    4. Test cases, especially for regressions, should be reduced as much as possible, by bugpoint or manually. It is unacceptable to place an entire failing program into llvm/test as this creates a time-to-test burden on all developers. Please keep them short.
    5. -
    6. More extensive test cases (applications, benchmarks, etc.) should be - added to the llvm-test test suite. This test suite is for - coverage: not features or regressions.
    + +

    Note that llvm/test is designed for regression and small feature tests + only. More extensive test cases (e.g., entire applications, benchmarks, + etc) should be added to the llvm-test test suite. The llvm-test + suite is for coverage (correctness, performance, etc) testing, not feature + or regression testing.

    @@ -176,7 +187,7 @@
  • Bug fixes and new features should include a testcase so we know if the fix/feature ever regresses in the future.
  • -
  • Code must pass the dejagnu (llvm/test) test suite.
  • +
  • Code must pass the dejagnu (llvm/test) test suite.
  • The code must not cause regressions on a reasonable subset of llvm-test, where "reasonable" depends on the contributor's judgement and the scope of the change (more invasive changes require more testing). A reasonable @@ -185,10 +196,10 @@

    Additionally, the committer is responsible for addressing any problems found in the future that the change is responsible for. For example:

    -

    We prefer for this to be handled before submission but understand that it's - not possible to test all of this for every submission. Our nightly testing +

    We prefer for this to be handled before submission but understand that it + isn't possible to test all of this for every submission. Our nightly + testing infrastructure normally finds these problems. A good rule of thumb is to check the nightly testers for regressions the day after your change.

    @@ -225,18 +237,23 @@ llvm-commits. When approved you may commit it yourself.
  • You are allowed to commit patches without approval which you think are - obvious. This is clearly a subjective decision. We simply expect you to - use good judgement. Examples include: fixing build breakage, reverting + obvious. This is clearly a subjective decision — we simply expect you + to use good judgement. Examples include: fixing build breakage, reverting obviously broken patches, documentation/comment changes, any other minor changes.
  • You are allowed to commit patches without approval to those portions - of LLVM that you have contributed or maintain (have been assigned + of LLVM that you have contributed or maintain (i.e., have been assigned responsibility for), with the proviso that such commits must not break the build. This is a "trust but verify" policy and commits of this nature are reviewed after they are committed.
  • Multiple violations of these policies or a single egregious violation may cause commit access to be revoked.
  • + +

    In any case, your changes are still subject to code +review (either before or after they are committed, depending on the nature +of the change). You are encouraged to review other peoples' patches as well, +but your aren't required to.

    @@ -245,20 +262,20 @@

    When a developer begins a major new project with the aim of contributing it back to LLVM, s/he should inform the community with an email to - the llvm-dev + the llvmdev email list, to the extent possible. The reason for this is to:

    1. keep the community informed about future changes to LLVM,
    2. -
    3. avoid duplication of effort by having multiple parties working on the - same thing and not knowing about it, and
    4. +
    5. avoid duplication of effort by preventing multiple parties working on + the same thing and not knowing about it, and
    6. ensure that any technical issues around the proposed work are discussed and resolved before any significant work is done.

    The design of LLVM is carefully controlled to ensure that all the pieces fit together well and are as consistent as possible. If you plan to make a - major change to the way LLVM works or - a major new extension, it is a good idea to get consensus with the development + major change to the way LLVM works or want to add a major new extension, it + is a good idea to get consensus with the development community before you start working on it.

    Once the design of the new feature is finalized, the work itself should be @@ -316,13 +333,14 @@

  • Often, an independent precursor to a big change is to add a new API and slowly migrate clients to use the new API. Each change to use the new API is often "obvious" and can be committed without review. Once the - new API is in place and used, it is often easy to replace the underlying - implementation of the API.
  • + new API is in place and used, it is much easier to replace the + underlying implementation of the API. This implementation change is + logically separate from the API change.

    If you are interested in making a large change, and this scares you, please make sure to first discuss the change/gather - consensus then feel free to ask about the best way to go about making + consensus then ask about the best way to go about making the change.

    @@ -345,7 +363,8 @@ its original author.
  • Developers should be aware that after some time has passed, the name at the top of a file may become meaningless as maintenance/ownership of files - changes. Revision control keeps an accurate history of contributions.
  • + changes. Despite this, once set, the attribution of a file never changes. + Revision control keeps an accurate history of contributions.
  • Developers should maintain their entry in the CREDITS.txt file to summarize their contributions.
  • @@ -364,13 +383,12 @@
    -

    We address here the issues of copyright and license for the LLVM project. - The object of the copyright and license is the LLVM source code and - documentation. +

    This section addresses the issues of copyright and license for the LLVM + project. Currently, the University of Illinois is the LLVM copyright holder and the terms of its license to LLVM users and developers is the University of - Illinois/NCSA Open Source License. + Illinois/NCSA Open Source License.

    NOTE: This section deals with legal matters but does not provide @@ -428,11 +446,12 @@ software (notably, llvm-gcc which is based on the GCC GPL source base). This means that anything "linked" into to llvm-gcc must itself be compatible with the GPL, and must be releasable under the terms of the GPL. This implies - that you any code linked into llvm-gcc and distributed may be subject to + that you any code linked into llvm-gcc and distributed to others may be + subject to the viral aspects of the GPL. This is not a problem for the main LLVM distribution (which is already licensed under a more liberal license), but may - be a problem if you intend to do commercial development without redistributing - your source code.

    + be a problem if you intend to base commercial development on llvm-gcc without + redistributing your source code.

    We have no plans to change the license of LLVM. If you have questions or comments about the license, please contact the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 06:24:23 $ + Last modified: $Date: 2007/02/19 06:57:16 $ From sabre at nondot.org Mon Feb 19 00:58:03 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 00:58:03 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702190658.l1J6w3W8026832@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.31 -> 1.32 --- Log message: fix validation --- Diffs of the changes: (+2 -2) DeveloperPolicy.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.31 llvm/docs/DeveloperPolicy.html:1.32 --- llvm/docs/DeveloperPolicy.html:1.31 Mon Feb 19 00:57:16 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 00:57:46 2007 @@ -171,7 +171,7 @@ only. More extensive test cases (e.g., entire applications, benchmarks, etc) should be added to the llvm-test test suite. The llvm-test suite is for coverage (correctness, performance, etc) testing, not feature - or regression testing. + or regression testing.

    @@ -499,7 +499,7 @@ Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 06:57:16 $ + Last modified: $Date: 2007/02/19 06:57:46 $ From sabre at nondot.org Mon Feb 19 01:23:40 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:23:40 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702190723.l1J7NeLM027320@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.124 -> 1.125 --- Log message: add alternate version of constant ctors that don't take a vector. For now this offers no performance advantage. --- Diffs of the changes: (+19 -3) Constants.h | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.124 llvm/include/llvm/Constants.h:1.125 --- llvm/include/llvm/Constants.h:1.124 Wed Feb 14 20:26:09 2007 +++ llvm/include/llvm/Constants.h Mon Feb 19 01:23:24 2007 @@ -248,6 +248,11 @@ public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const ArrayType *T, const std::vector &); + static Constant *get(const ArrayType *T, + Constant*const*Vals, unsigned NumVals) { + // FIXME: make this the primary ctor method. + return get(T, std::vector(Vals, Vals+NumVals)); + } /// This method constructs a ConstantArray and initializes it with a text /// string. The default behavior (AddNull==true) causes a null terminator to @@ -308,8 +313,13 @@ /// get() - Static factory methods - Return objects of the specified value /// static Constant *get(const StructType *T, const std::vector &V); - static Constant *get(const std::vector &V, bool packed = false); - + static Constant *get(const std::vector &V, bool Packed = false); + static Constant *get(Constant*const* Vals, unsigned NumVals, + bool Packed = false) { + // FIXME: make this the primary ctor method. + return get(std::vector(Vals, Vals+NumVals), Packed); + } + /// getType() specialization - Reduce amount of casting... /// inline const StructType *getType() const { @@ -347,7 +357,11 @@ /// get() - Static factory methods - Return objects of the specified value static Constant *get(const VectorType *T, const std::vector &); static Constant *get(const std::vector &V); - + static Constant *get(Constant*const* Vals, unsigned NumVals) { + // FIXME: make this the primary ctor method. + return get(std::vector(Vals, Vals+NumVals)); + } + /// getType - Specialize the getType() method to always return an VectorType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -578,6 +592,8 @@ Constant* const *IdxList, unsigned NumIdx); static Constant *getGetElementPtr(Constant *C, Value* const *IdxList, unsigned NumIdx); + + // FIXME: Remove these. static Constant *getGetElementPtr(Constant *C, const std::vector &IdxList) { return getGetElementPtr(C, &IdxList[0], IdxList.size()); From sabre at nondot.org Mon Feb 19 01:34:19 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:34:19 -0600 Subject: [llvm-commits] CVS: llvm/tools/llvm-upgrade/UpgradeParser.cpp.cvs UpgradeParser.h.cvs UpgradeParser.y UpgradeParser.y.cvs Message-ID: <200702190734.l1J7YJk1027548@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-upgrade: UpgradeParser.cpp.cvs updated: 1.63 -> 1.64 UpgradeParser.h.cvs updated: 1.47 -> 1.48 UpgradeParser.y updated: 1.67 -> 1.68 UpgradeParser.y.cvs updated: 1.62 -> 1.63 --- Log message: remove use of deprecated api --- Diffs of the changes: (+3317 -4443) UpgradeParser.cpp.cvs | 7249 +++++++++++++++++++++----------------------------- UpgradeParser.h.cvs | 499 +-- UpgradeParser.y | 2 UpgradeParser.y.cvs | 10 4 files changed, 3317 insertions(+), 4443 deletions(-) Index: llvm/tools/llvm-upgrade/UpgradeParser.cpp.cvs diff -u llvm/tools/llvm-upgrade/UpgradeParser.cpp.cvs:1.63 llvm/tools/llvm-upgrade/UpgradeParser.cpp.cvs:1.64 --- llvm/tools/llvm-upgrade/UpgradeParser.cpp.cvs:1.63 Wed Feb 14 20:26:10 2007 +++ llvm/tools/llvm-upgrade/UpgradeParser.cpp.cvs Mon Feb 19 01:34:02 2007 @@ -1,376 +1,167 @@ -/* A Bison parser, made by GNU Bison 2.1. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* A Bison parser, made from /Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y + by GNU Bison version 1.28 */ - 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 2, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.1" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 +#define YYBISON 1 /* Identify Bison output. */ -/* Substitute the variable and function names. */ #define yyparse Upgradeparse -#define yylex Upgradelex +#define yylex Upgradelex #define yyerror Upgradeerror -#define yylval Upgradelval -#define yychar Upgradechar +#define yylval Upgradelval +#define yychar Upgradechar #define yydebug Upgradedebug #define yynerrs Upgradenerrs +#define ESINT64VAL 257 +#define EUINT64VAL 258 +#define SINTVAL 259 +#define UINTVAL 260 +#define FPVAL 261 +#define VOID 262 +#define BOOL 263 +#define SBYTE 264 +#define UBYTE 265 +#define SHORT 266 +#define USHORT 267 +#define INT 268 +#define UINT 269 +#define LONG 270 +#define ULONG 271 +#define FLOAT 272 +#define DOUBLE 273 +#define TYPE 274 +#define LABEL 275 +#define VAR_ID 276 +#define LABELSTR 277 +#define STRINGCONSTANT 278 +#define IMPLEMENTATION 279 +#define ZEROINITIALIZER 280 +#define TRUETOK 281 +#define FALSETOK 282 +#define BEGINTOK 283 +#define ENDTOK 284 +#define DECLARE 285 +#define GLOBAL 286 +#define CONSTANT 287 +#define SECTION 288 +#define VOLATILE 289 +#define TO 290 +#define DOTDOTDOT 291 +#define NULL_TOK 292 +#define UNDEF 293 +#define CONST 294 +#define INTERNAL 295 +#define LINKONCE 296 +#define WEAK 297 +#define APPENDING 298 +#define DLLIMPORT 299 +#define DLLEXPORT 300 +#define EXTERN_WEAK 301 +#define OPAQUE 302 +#define NOT 303 +#define EXTERNAL 304 +#define TARGET 305 +#define TRIPLE 306 +#define ENDIAN 307 +#define POINTERSIZE 308 +#define LITTLE 309 +#define BIG 310 +#define ALIGN 311 +#define DEPLIBS 312 +#define CALL 313 +#define TAIL 314 +#define ASM_TOK 315 +#define MODULE 316 +#define SIDEEFFECT 317 +#define CC_TOK 318 +#define CCC_TOK 319 +#define CSRETCC_TOK 320 +#define FASTCC_TOK 321 +#define COLDCC_TOK 322 +#define X86_STDCALLCC_TOK 323 +#define X86_FASTCALLCC_TOK 324 +#define DATALAYOUT 325 +#define RET 326 +#define BR 327 +#define SWITCH 328 +#define INVOKE 329 +#define UNREACHABLE 330 +#define UNWIND 331 +#define EXCEPT 332 +#define ADD 333 +#define SUB 334 +#define MUL 335 +#define DIV 336 +#define UDIV 337 +#define SDIV 338 +#define FDIV 339 +#define REM 340 +#define UREM 341 +#define SREM 342 +#define FREM 343 +#define AND 344 +#define OR 345 +#define XOR 346 +#define SHL 347 +#define SHR 348 +#define ASHR 349 +#define LSHR 350 +#define SETLE 351 +#define SETGE 352 +#define SETLT 353 +#define SETGT 354 +#define SETEQ 355 +#define SETNE 356 +#define ICMP 357 +#define FCMP 358 +#define MALLOC 359 +#define ALLOCA 360 +#define FREE 361 +#define LOAD 362 +#define STORE 363 +#define GETELEMENTPTR 364 +#define PHI_TOK 365 +#define SELECT 366 +#define VAARG 367 +#define EXTRACTELEMENT 368 +#define INSERTELEMENT 369 +#define SHUFFLEVECTOR 370 +#define VAARG_old 371 +#define VANEXT_old 372 +#define EQ 373 +#define NE 374 +#define SLT 375 +#define SGT 376 +#define SLE 377 +#define SGE 378 +#define ULT 379 +#define UGT 380 +#define ULE 381 +#define UGE 382 +#define OEQ 383 +#define ONE 384 +#define OLT 385 +#define OGT 386 +#define OLE 387 +#define OGE 388 +#define ORD 389 +#define UNO 390 +#define UEQ 391 +#define UNE 392 +#define CAST 393 +#define TRUNC 394 +#define ZEXT 395 +#define SEXT 396 +#define FPTRUNC 397 +#define FPEXT 398 +#define FPTOUI 399 +#define FPTOSI 400 +#define UITOFP 401 +#define SITOFP 402 +#define PTRTOINT 403 +#define INTTOPTR 404 +#define BITCAST 405 - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ESINT64VAL = 258, - EUINT64VAL = 259, - SINTVAL = 260, - UINTVAL = 261, - FPVAL = 262, - VOID = 263, - BOOL = 264, - SBYTE = 265, - UBYTE = 266, - SHORT = 267, - USHORT = 268, - INT = 269, - UINT = 270, - LONG = 271, - ULONG = 272, - FLOAT = 273, - DOUBLE = 274, - TYPE = 275, - LABEL = 276, - VAR_ID = 277, - LABELSTR = 278, - STRINGCONSTANT = 279, - IMPLEMENTATION = 280, - ZEROINITIALIZER = 281, - TRUETOK = 282, - FALSETOK = 283, - BEGINTOK = 284, - ENDTOK = 285, - DECLARE = 286, - GLOBAL = 287, - CONSTANT = 288, - SECTION = 289, - VOLATILE = 290, - TO = 291, - DOTDOTDOT = 292, - NULL_TOK = 293, - UNDEF = 294, - CONST = 295, - INTERNAL = 296, - LINKONCE = 297, - WEAK = 298, - APPENDING = 299, - DLLIMPORT = 300, - DLLEXPORT = 301, - EXTERN_WEAK = 302, - OPAQUE = 303, - NOT = 304, - EXTERNAL = 305, - TARGET = 306, - TRIPLE = 307, - ENDIAN = 308, - POINTERSIZE = 309, - LITTLE = 310, - BIG = 311, - ALIGN = 312, - DEPLIBS = 313, - CALL = 314, - TAIL = 315, - ASM_TOK = 316, - MODULE = 317, - SIDEEFFECT = 318, - CC_TOK = 319, - CCC_TOK = 320, - CSRETCC_TOK = 321, - FASTCC_TOK = 322, - COLDCC_TOK = 323, - X86_STDCALLCC_TOK = 324, - X86_FASTCALLCC_TOK = 325, - DATALAYOUT = 326, - RET = 327, - BR = 328, - SWITCH = 329, - INVOKE = 330, - UNREACHABLE = 331, - UNWIND = 332, - EXCEPT = 333, - ADD = 334, - SUB = 335, - MUL = 336, - DIV = 337, - UDIV = 338, - SDIV = 339, - FDIV = 340, - REM = 341, - UREM = 342, - SREM = 343, - FREM = 344, - AND = 345, - OR = 346, - XOR = 347, - SHL = 348, - SHR = 349, - ASHR = 350, - LSHR = 351, - SETLE = 352, - SETGE = 353, - SETLT = 354, - SETGT = 355, - SETEQ = 356, - SETNE = 357, - ICMP = 358, - FCMP = 359, - MALLOC = 360, - ALLOCA = 361, - FREE = 362, - LOAD = 363, - STORE = 364, - GETELEMENTPTR = 365, - PHI_TOK = 366, - SELECT = 367, - VAARG = 368, - EXTRACTELEMENT = 369, - INSERTELEMENT = 370, - SHUFFLEVECTOR = 371, - VAARG_old = 372, - VANEXT_old = 373, - EQ = 374, - NE = 375, - SLT = 376, - SGT = 377, - SLE = 378, - SGE = 379, - ULT = 380, - UGT = 381, - ULE = 382, - UGE = 383, - OEQ = 384, - ONE = 385, - OLT = 386, - OGT = 387, - OLE = 388, - OGE = 389, - ORD = 390, - UNO = 391, - UEQ = 392, - UNE = 393, - CAST = 394, - TRUNC = 395, - ZEXT = 396, - SEXT = 397, - FPTRUNC = 398, - FPEXT = 399, - FPTOUI = 400, - FPTOSI = 401, - UITOFP = 402, - SITOFP = 403, - PTRTOINT = 404, - INTTOPTR = 405, - BITCAST = 406 - }; -#endif -/* Tokens. */ -#define ESINT64VAL 258 -#define EUINT64VAL 259 -#define SINTVAL 260 -#define UINTVAL 261 -#define FPVAL 262 -#define VOID 263 -#define BOOL 264 -#define SBYTE 265 -#define UBYTE 266 -#define SHORT 267 -#define USHORT 268 -#define INT 269 -#define UINT 270 -#define LONG 271 -#define ULONG 272 -#define FLOAT 273 -#define DOUBLE 274 -#define TYPE 275 -#define LABEL 276 -#define VAR_ID 277 -#define LABELSTR 278 -#define STRINGCONSTANT 279 -#define IMPLEMENTATION 280 -#define ZEROINITIALIZER 281 -#define TRUETOK 282 -#define FALSETOK 283 -#define BEGINTOK 284 -#define ENDTOK 285 -#define DECLARE 286 -#define GLOBAL 287 -#define CONSTANT 288 -#define SECTION 289 -#define VOLATILE 290 -#define TO 291 -#define DOTDOTDOT 292 -#define NULL_TOK 293 -#define UNDEF 294 -#define CONST 295 -#define INTERNAL 296 -#define LINKONCE 297 -#define WEAK 298 -#define APPENDING 299 -#define DLLIMPORT 300 -#define DLLEXPORT 301 -#define EXTERN_WEAK 302 -#define OPAQUE 303 -#define NOT 304 -#define EXTERNAL 305 -#define TARGET 306 -#define TRIPLE 307 -#define ENDIAN 308 -#define POINTERSIZE 309 -#define LITTLE 310 -#define BIG 311 -#define ALIGN 312 -#define DEPLIBS 313 -#define CALL 314 -#define TAIL 315 -#define ASM_TOK 316 -#define MODULE 317 -#define SIDEEFFECT 318 -#define CC_TOK 319 -#define CCC_TOK 320 -#define CSRETCC_TOK 321 -#define FASTCC_TOK 322 -#define COLDCC_TOK 323 -#define X86_STDCALLCC_TOK 324 -#define X86_FASTCALLCC_TOK 325 -#define DATALAYOUT 326 -#define RET 327 -#define BR 328 -#define SWITCH 329 -#define INVOKE 330 -#define UNREACHABLE 331 -#define UNWIND 332 -#define EXCEPT 333 -#define ADD 334 -#define SUB 335 -#define MUL 336 -#define DIV 337 -#define UDIV 338 -#define SDIV 339 -#define FDIV 340 -#define REM 341 -#define UREM 342 -#define SREM 343 -#define FREM 344 -#define AND 345 -#define OR 346 -#define XOR 347 -#define SHL 348 -#define SHR 349 -#define ASHR 350 -#define LSHR 351 -#define SETLE 352 -#define SETGE 353 -#define SETLT 354 -#define SETGT 355 -#define SETEQ 356 -#define SETNE 357 -#define ICMP 358 -#define FCMP 359 -#define MALLOC 360 -#define ALLOCA 361 -#define FREE 362 -#define LOAD 363 -#define STORE 364 -#define GETELEMENTPTR 365 -#define PHI_TOK 366 -#define SELECT 367 -#define VAARG 368 -#define EXTRACTELEMENT 369 -#define INSERTELEMENT 370 -#define SHUFFLEVECTOR 371 -#define VAARG_old 372 -#define VANEXT_old 373 -#define EQ 374 -#define NE 375 -#define SLT 376 -#define SGT 377 -#define SLE 378 -#define SGE 379 -#define ULT 380 -#define UGT 381 -#define ULE 382 -#define UGE 383 -#define OEQ 384 -#define ONE 385 -#define OLT 386 -#define OGT 387 -#define OLE 388 -#define OGE 389 -#define ORD 390 -#define UNO 391 -#define UEQ 392 -#define UNE 393 -#define CAST 394 -#define TRUNC 395 -#define ZEXT 396 -#define SEXT 397 -#define FPTRUNC 398 -#define FPEXT 399 -#define FPTOUI 400 -#define FPTOSI 401 -#define UITOFP 402 -#define SITOFP 403 -#define PTRTOINT 404 -#define INTTOPTR 405 -#define BITCAST 406 - - - - -/* Copy the first part of user declarations. */ -#line 14 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" +#line 14 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" #include "UpgradeInternals.h" #include "llvm/CallingConv.h" @@ -1359,7 +1150,7 @@ // types of its operands. bool isFP = Ty->isFloatingPoint(); if (const VectorType* PTy = dyn_cast(Ty)) - // If its a packed type we want to use the element type + // If its a vector type we want to use the element type isFP = PTy->getElementType()->isFloatingPoint(); if (isFP) return Instruction::FDiv; @@ -1375,7 +1166,7 @@ // types of its operands. bool isFP = Ty->isFloatingPoint(); if (const VectorType* PTy = dyn_cast(Ty)) - // If its a packed type we want to use the element type + // If its a vector type we want to use the element type isFP = PTy->getElementType()->isFloatingPoint(); // Select correct opcode if (isFP) @@ -1810,28 +1601,8 @@ using namespace llvm; - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 1454 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" -typedef union YYSTYPE { +#line 1454 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +typedef union { llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair *ArgVal; @@ -1872,1620 +1643,1151 @@ llvm::FCmpInst::Predicate FPred; llvm::Module::Endianness Endianness; } YYSTYPE; -/* Line 196 of yacc.c. */ -#line 1877 "UpgradeParser.tab.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 219 of yacc.c. */ -#line 1889 "UpgradeParser.tab.c" - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#ifndef YY_ -# if YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# else -# define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) -# endif -# ifdef __cplusplus -extern "C" { -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifdef __cplusplus -} -# endif -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#include +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short int yyss; - YYSTYPE yyvs; - }; -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +#define YYFINAL 605 +#define YYFLAG -32768 +#define YYNTBASE 166 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 405 ? yytranslate[x] : 245) + +static const short yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 155, + 156, 164, 2, 153, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 160, + 152, 161, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 157, 154, 159, 2, 2, 2, 2, 2, 165, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 158, + 2, 2, 162, 2, 163, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, + 147, 148, 149, 150, 151 +}; -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, + 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, + 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, + 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, + 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, + 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, + 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, + 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, + 161, 162, 164, 166, 168, 170, 172, 174, 176, 177, + 178, 180, 182, 184, 186, 188, 190, 193, 194, 197, + 198, 202, 205, 206, 208, 209, 213, 215, 218, 220, + 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, + 242, 244, 246, 248, 250, 252, 254, 256, 258, 261, + 266, 272, 278, 282, 285, 291, 296, 299, 301, 305, + 307, 311, 313, 314, 319, 323, 327, 332, 337, 341, + 348, 354, 357, 360, 363, 366, 369, 372, 375, 378, + 381, 384, 391, 397, 406, 413, 420, 427, 435, 443, + 450, 457, 466, 475, 479, 481, 483, 485, 487, 490, + 493, 498, 501, 503, 508, 511, 516, 517, 525, 526, + 534, 535, 543, 544, 552, 556, 561, 562, 564, 566, + 568, 572, 576, 580, 584, 588, 592, 594, 595, 597, + 599, 601, 602, 605, 609, 611, 613, 617, 619, 620, + 629, 631, 633, 637, 639, 641, 644, 645, 647, 649, + 650, 651, 657, 658, 660, 662, 664, 666, 668, 670, + 672, 674, 676, 680, 682, 688, 690, 692, 694, 696, + 699, 702, 705, 709, 712, 713, 715, 717, 719, 722, + 725, 729, 739, 749, 758, 772, 774, 776, 783, 789, + 792, 799, 807, 809, 813, 815, 816, 819, 821, 827, + 833, 839, 846, 853, 856, 861, 866, 873, 878, 883, + 888, 893, 900, 907, 910, 918, 920, 923, 924, 926, + 927, 931, 938, 942, 949, 952, 957, 964 +}; -#endif +static const short yyrhs[] = { 5, + 0, 6, 0, 3, 0, 4, 0, 79, 0, 80, + 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, + 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, + 0, 91, 0, 92, 0, 97, 0, 98, 0, 99, + 0, 100, 0, 101, 0, 102, 0, 119, 0, 120, + 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, + 0, 126, 0, 127, 0, 128, 0, 129, 0, 130, + 0, 131, 0, 132, 0, 133, 0, 134, 0, 135, + 0, 136, 0, 137, 0, 138, 0, 125, 0, 126, + 0, 127, 0, 128, 0, 27, 0, 28, 0, 93, + 0, 94, 0, 95, 0, 96, 0, 140, 0, 141, + 0, 142, 0, 143, 0, 144, 0, 145, 0, 146, + 0, 147, 0, 148, 0, 149, 0, 150, 0, 151, + 0, 139, 0, 16, 0, 14, 0, 12, 0, 10, + 0, 17, 0, 15, 0, 13, 0, 11, 0, 175, + 0, 176, 0, 18, 0, 19, 0, 211, 152, 0, + 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, + 0, 46, 0, 47, 0, 0, 0, 65, 0, 66, + 0, 67, 0, 68, 0, 69, 0, 70, 0, 64, + 4, 0, 0, 57, 4, 0, 0, 153, 57, 4, + 0, 34, 24, 0, 0, 184, 0, 0, 153, 187, + 186, 0, 184, 0, 57, 4, 0, 190, 0, 8, + 0, 192, 0, 8, 0, 192, 0, 9, 0, 10, + 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, + 0, 16, 0, 17, 0, 18, 0, 19, 0, 21, + 0, 191, 0, 48, 0, 227, 0, 154, 4, 0, + 189, 155, 194, 156, 0, 157, 4, 158, 192, 159, + 0, 160, 4, 158, 192, 161, 0, 162, 193, 163, + 0, 162, 163, 0, 160, 162, 193, 163, 161, 0, + 160, 162, 163, 161, 0, 192, 164, 0, 192, 0, + 193, 153, 192, 0, 193, 0, 193, 153, 37, 0, + 37, 0, 0, 190, 157, 197, 159, 0, 190, 157, + 159, 0, 190, 165, 24, 0, 190, 160, 197, 161, + 0, 190, 162, 197, 163, 0, 190, 162, 163, 0, + 190, 160, 162, 197, 163, 161, 0, 190, 160, 162, + 163, 161, 0, 190, 38, 0, 190, 39, 0, 190, + 227, 0, 190, 196, 0, 190, 26, 0, 175, 167, + 0, 176, 4, 0, 9, 27, 0, 9, 28, 0, + 178, 7, 0, 174, 155, 195, 36, 190, 156, 0, + 110, 155, 195, 242, 156, 0, 112, 155, 195, 153, + 195, 153, 195, 156, 0, 168, 155, 195, 153, 195, + 156, 0, 169, 155, 195, 153, 195, 156, 0, 170, + 155, 195, 153, 195, 156, 0, 103, 171, 155, 195, + 153, 195, 156, 0, 104, 172, 155, 195, 153, 195, + 156, 0, 173, 155, 195, 153, 195, 156, 0, 114, + 155, 195, 153, 195, 156, 0, 115, 155, 195, 153, + 195, 153, 195, 156, 0, 116, 155, 195, 153, 195, + 153, 195, 156, 0, 197, 153, 195, 0, 195, 0, + 32, 0, 33, 0, 200, 0, 200, 220, 0, 200, + 222, 0, 200, 62, 61, 206, 0, 200, 25, 0, + 201, 0, 201, 179, 20, 188, 0, 201, 222, 0, + 201, 62, 61, 206, 0, 0, 201, 179, 180, 198, + 195, 202, 186, 0, 0, 201, 179, 50, 198, 190, + 203, 186, 0, 0, 201, 179, 45, 198, 190, 204, + 186, 0, 0, 201, 179, 47, 198, 190, 205, 186, + 0, 201, 51, 208, 0, 201, 58, 152, 209, 0, + 0, 24, 0, 56, 0, 55, 0, 53, 152, 207, + 0, 54, 152, 4, 0, 52, 152, 24, 0, 71, + 152, 24, 0, 157, 210, 159, 0, 210, 153, 24, + 0, 24, 0, 0, 22, 0, 24, 0, 211, 0, + 0, 190, 212, 0, 214, 153, 213, 0, 213, 0, + 214, 0, 214, 153, 37, 0, 37, 0, 0, 181, + 188, 211, 155, 215, 156, 185, 182, 0, 29, 0, + 162, 0, 180, 216, 217, 0, 30, 0, 163, 0, + 230, 219, 0, 0, 45, 0, 47, 0, 0, 0, + 31, 223, 221, 224, 216, 0, 0, 63, 0, 3, + 0, 4, 0, 7, 0, 27, 0, 28, 0, 38, + 0, 39, 0, 26, 0, 160, 197, 161, 0, 196, + 0, 61, 225, 24, 153, 24, 0, 166, 0, 211, + 0, 227, 0, 226, 0, 190, 228, 0, 230, 231, + 0, 218, 231, 0, 232, 179, 234, 0, 232, 236, + 0, 0, 23, 0, 77, 0, 78, 0, 72, 229, + 0, 72, 8, 0, 73, 21, 228, 0, 73, 9, + 228, 153, 21, 228, 153, 21, 228, 0, 74, 177, + 228, 153, 21, 228, 157, 235, 159, 0, 74, 177, + 228, 153, 21, 228, 157, 159, 0, 75, 181, 188, + 228, 155, 239, 156, 36, 21, 228, 233, 21, 228, + 0, 233, 0, 76, 0, 235, 177, 226, 153, 21, + 228, 0, 177, 226, 153, 21, 228, 0, 179, 241, + 0, 190, 157, 228, 153, 228, 159, 0, 237, 153, + 157, 228, 153, 228, 159, 0, 229, 0, 238, 153, + 229, 0, 238, 0, 0, 60, 59, 0, 59, 0, + 168, 190, 228, 153, 228, 0, 169, 190, 228, 153, + 228, 0, 170, 190, 228, 153, 228, 0, 103, 171, + 190, 228, 153, 228, 0, 104, 172, 190, 228, 153, + 228, 0, 49, 229, 0, 173, 229, 153, 229, 0, + 174, 229, 36, 190, 0, 112, 229, 153, 229, 153, + 229, 0, 113, 229, 153, 190, 0, 117, 229, 153, + 190, 0, 118, 229, 153, 190, 0, 114, 229, 153, + 229, 0, 115, 229, 153, 229, 153, 229, 0, 116, + 229, 153, 229, 153, 229, 0, 111, 237, 0, 240, + 181, 188, 228, 155, 239, 156, 0, 244, 0, 153, + 238, 0, 0, 35, 0, 0, 105, 190, 183, 0, + 105, 190, 153, 15, 228, 183, 0, 106, 190, 183, + 0, 106, 190, 153, 15, 228, 183, 0, 107, 229, + 0, 243, 108, 190, 228, 0, 243, 109, 229, 153, + 190, 228, 0, 110, 190, 228, 242, 0 +}; -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; #endif -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 4 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1762 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 166 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 80 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 309 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 605 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 406 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 155, 156, 164, 2, 153, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 160, 152, 161, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 157, 154, 159, 2, 2, 2, 2, 2, 165, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 158, 2, 2, 162, 2, 163, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151 +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 1594, 1595, 1603, 1604, 1614, 1614, 1614, 1614, 1614, 1614, + 1614, 1614, 1614, 1614, 1614, 1618, 1618, 1618, 1622, 1622, + 1622, 1622, 1622, 1622, 1626, 1626, 1627, 1627, 1628, 1628, + 1629, 1629, 1630, 1630, 1634, 1634, 1635, 1635, 1636, 1636, + 1637, 1637, 1638, 1638, 1639, 1639, 1640, 1640, 1641, 1642, + 1645, 1645, 1645, 1645, 1649, 1649, 1649, 1649, 1649, 1649, + 1649, 1650, 1650, 1650, 1650, 1650, 1650, 1656, 1656, 1656, + 1656, 1660, 1660, 1660, 1660, 1664, 1664, 1668, 1668, 1673, + 1676, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1692, + 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1709, 1710, 1718, + 1719, 1727, 1736, 1737, 1744, 1745, 1749, 1753, 1769, 1770, + 1777, 1778, 1785, 1793, 1793, 1793, 1793, 1793, 1793, 1793, + 1794, 1794, 1794, 1794, 1794, 1799, 1803, 1807, 1812, 1821, + 1838, 1844, 1857, 1866, 1870, 1881, 1885, 1898, 1902, 1909, + 1910, 1916, 1923, 1935, 1965, 1978, 2001, 2029, 2051, 2062, + 2084, 2095, 2104, 2109, 2167, 2174, 2182, 2189, 2196, 2200, + 2204, 2213, 2228, 2241, 2250, 2278, 2291, 2300, 2306, 2312, + 2323, 2329, 2335, 2346, 2347, 2356, 2357, 2369, 2378, 2379, + 2380, 2381, 2382, 2398, 2418, 2420, 2422, 2426, 2429, 2433, + 2436, 2440, 2443, 2448, 2451, 2453, 2455, 2460, 2474, 2475, + 2479, 2482, 2490, 2494, 2501, 2505, 2509, 2513, 2521, 2521, + 2525, 2526, 2530, 2538, 2543, 2551, 2552, 2559, 2566, 2570, + 2746, 2746, 2750, 2760, 2760, 2764, 2769, 2770, 2771, 2775, + 2776, 2776, 2788, 2789, 2794, 2795, 2796, 2797, 2798, 2799, + 2800, 2801, 2802, 2823, 2826, 2841, 2842, 2847, 2847, 2855, + 2864, 2867, 2876, 2886, 2891, 2900, 2911, 2911, 2914, 2917, + 2920, 2924, 2930, 2945, 2951, 3007, 3010, 3016, 3026, 3039, + 3068, 3076, 3084, 3088, 3095, 3096, 3100, 3103, 3109, 3126, + 3142, 3156, 3168, 3180, 3191, 3209, 3218, 3227, 3234, 3255, + 3279, 3285, 3291, 3297, 3313, 3391, 3399, 3400, 3404, 3405, + 3409, 3415, 3421, 3427, 3433, 3440, 3452, 3477 }; +#endif -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short int yyprhs[] = -{ - 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, - 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, - 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, - 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, - 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, - 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, - 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, - 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, - 159, 161, 164, 165, 167, 169, 171, 173, 175, 177, - 179, 180, 181, 183, 185, 187, 189, 191, 193, 196, - 197, 200, 201, 205, 208, 209, 211, 212, 216, 218, - 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, - 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, - 261, 264, 269, 275, 281, 285, 288, 294, 299, 302, - 304, 308, 310, 314, 316, 317, 322, 326, 330, 335, - 340, 344, 351, 357, 360, 363, 366, 369, 372, 375, - 378, 381, 384, 387, 394, 400, 409, 416, 423, 430, - 438, 446, 453, 460, 469, 478, 482, 484, 486, 488, - 490, 493, 496, 501, 504, 506, 511, 514, 519, 520, - 528, 529, 537, 538, 546, 547, 555, 559, 564, 565, - 567, 569, 571, 575, 579, 583, 587, 591, 595, 597, - 598, 600, 602, 604, 605, 608, 612, 614, 616, 620, - 622, 623, 632, 634, 636, 640, 642, 644, 647, 648, - 650, 652, 653, 654, 660, 661, 663, 665, 667, 669, - 671, 673, 675, 677, 679, 683, 685, 691, 693, 695, - 697, 699, 702, 705, 708, 712, 715, 716, 718, 720, - 722, 725, 728, 732, 742, 752, 761, 775, 777, 779, - 786, 792, 795, 802, 810, 812, 816, 818, 819, 822, - 824, 830, 836, 842, 849, 856, 859, 864, 869, 876, - 881, 886, 891, 896, 903, 910, 913, 921, 923, 926, - 927, 929, 930, 934, 941, 945, 952, 955, 960, 967 -}; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short int yyrhs[] = -{ - 200, 0, -1, 5, -1, 6, -1, 3, -1, 4, - -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, - -1, 84, -1, 85, -1, 86, -1, 87, -1, 88, - -1, 89, -1, 90, -1, 91, -1, 92, -1, 97, - -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, - -1, 119, -1, 120, -1, 121, -1, 122, -1, 123, - -1, 124, -1, 125, -1, 126, -1, 127, -1, 128, - -1, 129, -1, 130, -1, 131, -1, 132, -1, 133, - -1, 134, -1, 135, -1, 136, -1, 137, -1, 138, - -1, 125, -1, 126, -1, 127, -1, 128, -1, 27, - -1, 28, -1, 93, -1, 94, -1, 95, -1, 96, - -1, 140, -1, 141, -1, 142, -1, 143, -1, 144, - -1, 145, -1, 146, -1, 147, -1, 148, -1, 149, - -1, 150, -1, 151, -1, 139, -1, 16, -1, 14, - -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, - -1, 11, -1, 176, -1, 177, -1, 18, -1, 19, - -1, 212, 152, -1, -1, 41, -1, 42, -1, 43, - -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, - -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, - -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, - -1, 153, 57, 4, -1, 34, 24, -1, -1, 185, - -1, -1, 153, 188, 187, -1, 185, -1, 57, 4, - -1, 191, -1, 8, -1, 193, -1, 8, -1, 193, - -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, - -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, - -1, 19, -1, 21, -1, 192, -1, 48, -1, 228, - -1, 154, 4, -1, 190, 155, 195, 156, -1, 157, - 4, 158, 193, 159, -1, 160, 4, 158, 193, 161, - -1, 162, 194, 163, -1, 162, 163, -1, 160, 162, - 194, 163, 161, -1, 160, 162, 163, 161, -1, 193, - 164, -1, 193, -1, 194, 153, 193, -1, 194, -1, - 194, 153, 37, -1, 37, -1, -1, 191, 157, 198, - 159, -1, 191, 157, 159, -1, 191, 165, 24, -1, - 191, 160, 198, 161, -1, 191, 162, 198, 163, -1, - 191, 162, 163, -1, 191, 160, 162, 198, 163, 161, - -1, 191, 160, 162, 163, 161, -1, 191, 38, -1, - 191, 39, -1, 191, 228, -1, 191, 197, -1, 191, - 26, -1, 176, 168, -1, 177, 4, -1, 9, 27, - -1, 9, 28, -1, 179, 7, -1, 175, 155, 196, - 36, 191, 156, -1, 110, 155, 196, 243, 156, -1, - 112, 155, 196, 153, 196, 153, 196, 156, -1, 169, - 155, 196, 153, 196, 156, -1, 170, 155, 196, 153, - 196, 156, -1, 171, 155, 196, 153, 196, 156, -1, - 103, 172, 155, 196, 153, 196, 156, -1, 104, 173, - 155, 196, 153, 196, 156, -1, 174, 155, 196, 153, - 196, 156, -1, 114, 155, 196, 153, 196, 156, -1, - 115, 155, 196, 153, 196, 153, 196, 156, -1, 116, - 155, 196, 153, 196, 153, 196, 156, -1, 198, 153, - 196, -1, 196, -1, 32, -1, 33, -1, 201, -1, - 201, 221, -1, 201, 223, -1, 201, 62, 61, 207, - -1, 201, 25, -1, 202, -1, 202, 180, 20, 189, - -1, 202, 223, -1, 202, 62, 61, 207, -1, -1, - 202, 180, 181, 199, 196, 203, 187, -1, -1, 202, - 180, 50, 199, 191, 204, 187, -1, -1, 202, 180, - 45, 199, 191, 205, 187, -1, -1, 202, 180, 47, - 199, 191, 206, 187, -1, 202, 51, 209, -1, 202, - 58, 152, 210, -1, -1, 24, -1, 56, -1, 55, - -1, 53, 152, 208, -1, 54, 152, 4, -1, 52, - 152, 24, -1, 71, 152, 24, -1, 157, 211, 159, - -1, 211, 153, 24, -1, 24, -1, -1, 22, -1, - 24, -1, 212, -1, -1, 191, 213, -1, 215, 153, - 214, -1, 214, -1, 215, -1, 215, 153, 37, -1, - 37, -1, -1, 182, 189, 212, 155, 216, 156, 186, - 183, -1, 29, -1, 162, -1, 181, 217, 218, -1, - 30, -1, 163, -1, 231, 220, -1, -1, 45, -1, - 47, -1, -1, -1, 31, 224, 222, 225, 217, -1, - -1, 63, -1, 3, -1, 4, -1, 7, -1, 27, - -1, 28, -1, 38, -1, 39, -1, 26, -1, 160, - 198, 161, -1, 197, -1, 61, 226, 24, 153, 24, - -1, 167, -1, 212, -1, 228, -1, 227, -1, 191, - 229, -1, 231, 232, -1, 219, 232, -1, 233, 180, - 235, -1, 233, 237, -1, -1, 23, -1, 77, -1, - 78, -1, 72, 230, -1, 72, 8, -1, 73, 21, - 229, -1, 73, 9, 229, 153, 21, 229, 153, 21, - 229, -1, 74, 178, 229, 153, 21, 229, 157, 236, - 159, -1, 74, 178, 229, 153, 21, 229, 157, 159, - -1, 75, 182, 189, 229, 155, 240, 156, 36, 21, - 229, 234, 21, 229, -1, 234, -1, 76, -1, 236, - 178, 227, 153, 21, 229, -1, 178, 227, 153, 21, - 229, -1, 180, 242, -1, 191, 157, 229, 153, 229, - 159, -1, 238, 153, 157, 229, 153, 229, 159, -1, - 230, -1, 239, 153, 230, -1, 239, -1, -1, 60, - 59, -1, 59, -1, 169, 191, 229, 153, 229, -1, - 170, 191, 229, 153, 229, -1, 171, 191, 229, 153, - 229, -1, 103, 172, 191, 229, 153, 229, -1, 104, - 173, 191, 229, 153, 229, -1, 49, 230, -1, 174, - 230, 153, 230, -1, 175, 230, 36, 191, -1, 112, - 230, 153, 230, 153, 230, -1, 113, 230, 153, 191, - -1, 117, 230, 153, 191, -1, 118, 230, 153, 191, - -1, 114, 230, 153, 230, -1, 115, 230, 153, 230, - 153, 230, -1, 116, 230, 153, 230, 153, 230, -1, - 111, 238, -1, 241, 182, 189, 229, 155, 240, 156, - -1, 245, -1, 153, 239, -1, -1, 35, -1, -1, - 105, 191, 184, -1, 105, 191, 153, 15, 229, 184, - -1, 106, 191, 184, -1, 106, 191, 153, 15, 229, - 184, -1, 107, 230, -1, 244, 108, 191, 229, -1, - 244, 109, 230, 153, 191, 229, -1, 110, 191, 229, - 243, -1 -}; +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = -{ - 0, 1594, 1594, 1595, 1603, 1604, 1614, 1614, 1614, 1614, - 1614, 1614, 1614, 1614, 1614, 1614, 1614, 1618, 1618, 1618, - 1622, 1622, 1622, 1622, 1622, 1622, 1626, 1626, 1627, 1627, - 1628, 1628, 1629, 1629, 1630, 1630, 1634, 1634, 1635, 1635, - 1636, 1636, 1637, 1637, 1638, 1638, 1639, 1639, 1640, 1640, - 1641, 1642, 1645, 1645, 1645, 1645, 1649, 1649, 1649, 1649, - 1649, 1649, 1649, 1650, 1650, 1650, 1650, 1650, 1650, 1656, - 1656, 1656, 1656, 1660, 1660, 1660, 1660, 1664, 1664, 1668, - 1668, 1673, 1676, 1681, 1682, 1683, 1684, 1685, 1686, 1687, - 1688, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1709, - 1710, 1718, 1719, 1727, 1736, 1737, 1744, 1745, 1749, 1753, - 1769, 1770, 1777, 1778, 1785, 1793, 1793, 1793, 1793, 1793, - 1793, 1793, 1794, 1794, 1794, 1794, 1794, 1799, 1803, 1807, - 1812, 1821, 1838, 1844, 1857, 1866, 1870, 1881, 1885, 1898, - 1902, 1909, 1910, 1916, 1923, 1935, 1965, 1978, 2001, 2029, - 2051, 2062, 2084, 2095, 2104, 2109, 2167, 2174, 2182, 2189, - 2196, 2200, 2204, 2213, 2228, 2241, 2250, 2278, 2291, 2300, - 2306, 2312, 2323, 2329, 2335, 2346, 2347, 2356, 2357, 2369, - 2378, 2379, 2380, 2381, 2382, 2398, 2418, 2420, 2422, 2422, - 2429, 2429, 2436, 2436, 2443, 2443, 2451, 2453, 2455, 2460, - 2474, 2475, 2479, 2482, 2490, 2494, 2501, 2505, 2509, 2513, - 2521, 2521, 2525, 2526, 2530, 2538, 2543, 2551, 2552, 2559, - 2566, 2570, 2746, 2746, 2750, 2760, 2760, 2764, 2769, 2770, - 2771, 2775, 2776, 2775, 2788, 2789, 2794, 2795, 2796, 2797, - 2798, 2799, 2800, 2801, 2802, 2823, 2826, 2841, 2842, 2847, - 2847, 2855, 2864, 2867, 2876, 2886, 2891, 2900, 2911, 2911, - 2914, 2917, 2920, 2924, 2930, 2945, 2951, 3007, 3010, 3016, - 3026, 3039, 3068, 3076, 3084, 3088, 3095, 3096, 3100, 3103, - 3109, 3126, 3142, 3156, 3168, 3180, 3191, 3209, 3218, 3227, - 3234, 3255, 3279, 3285, 3291, 3297, 3313, 3391, 3399, 3400, - 3404, 3405, 3409, 3415, 3421, 3427, 3433, 3440, 3452, 3477 +static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", +"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT", +"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID", +"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK", +"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO", +"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING", +"DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE", +"ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK", +"MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK", +"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE", +"UNREACHABLE","UNWIND","EXCEPT","ADD","SUB","MUL","DIV","UDIV","SDIV","FDIV", +"REM","UREM","SREM","FREM","AND","OR","XOR","SHL","SHR","ASHR","LSHR","SETLE", +"SETGE","SETLT","SETGT","SETEQ","SETNE","ICMP","FCMP","MALLOC","ALLOCA","FREE", +"LOAD","STORE","GETELEMENTPTR","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT", +"SHUFFLEVECTOR","VAARG_old","VANEXT_old","EQ","NE","SLT","SGT","SLE","SGE","ULT", +"UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE", +"CAST","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","FPTOUI","FPTOSI","UITOFP","SITOFP", +"PTRTOINT","INTTOPTR","BITCAST","'='","','","'\\\\'","'('","')'","'['","'x'", +"']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps", +"LogicalOps","SetCondOps","IPredicates","FPredicates","ShiftOps","CastOps","SIntType", +"UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign", +"OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute", +"TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI", +"ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool", +"@1","@2","@3","@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition", +"LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN", +"FunctionHeader","END","Function","FnDeclareLinkage","FunctionProto","@5","@6", +"OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal", +"BasicBlockList","BasicBlock","InstructionList","Unwind","BBTerminatorInst", +"JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal", +"IndexList","OptVolatile","MemoryInst", NULL }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", - "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", - "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", - "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", - "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", - "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", - "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", - "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", - "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", - "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", - "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", - "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", - "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT", - "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM", - "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR", - "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP", - "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", - "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", - "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", - "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", - "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", - "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR", - "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", - "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", - "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates", - "FPredicates", "ShiftOps", "CastOps", "SIntType", "UIntType", "IntType", - "FPType", "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", - "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", - "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", - "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", - "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", - "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", - "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", - "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", - "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", "@6", - "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", - "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", - "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList", - "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList", - "OptVolatile", "MemoryInst", 0 +static const short yyr1[] = { 0, + 166, 166, 167, 167, 168, 168, 168, 168, 168, 168, + 168, 168, 168, 168, 168, 169, 169, 169, 170, 170, + 170, 170, 170, 170, 171, 171, 171, 171, 171, 171, + 171, 171, 171, 171, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, + 174, 174, 174, 174, 174, 174, 174, 175, 175, 175, + 175, 176, 176, 176, 176, 177, 177, 178, 178, 179, + 179, 180, 180, 180, 180, 180, 180, 180, 180, 181, + 181, 181, 181, 181, 181, 181, 181, 182, 182, 183, + 183, 184, 185, 185, 186, 186, 187, 187, 188, 188, + 189, 189, 190, 191, 191, 191, 191, 191, 191, 191, + 191, 191, 191, 191, 191, 192, 192, 192, 192, 192, + 192, 192, 192, 192, 192, 192, 192, 193, 193, 194, + 194, 194, 194, 195, 195, 195, 195, 195, 195, 195, + 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 195, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 197, 197, 198, 198, 199, 200, 200, + 200, 200, 200, 201, 201, 201, 202, 201, 203, 201, + 204, 201, 205, 201, 201, 201, 201, 206, 207, 207, + 208, 208, 208, 208, 209, 210, 210, 210, 211, 211, + 212, 212, 213, 214, 214, 215, 215, 215, 215, 216, + 217, 217, 218, 219, 219, 220, 221, 221, 221, 223, + 224, 222, 225, 225, 226, 226, 226, 226, 226, 226, + 226, 226, 226, 226, 226, 227, 227, 228, 228, 229, + 230, 230, 231, 232, 232, 232, 233, 233, 234, 234, + 234, 234, 234, 234, 234, 234, 234, 235, 235, 236, + 237, 237, 238, 238, 239, 239, 240, 240, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 242, 242, 243, 243, + 244, 244, 244, 244, 244, 244, 244, 244 }; -#endif -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 61, 44, 92, 40, 41, 91, 120, 93, - 60, 62, 123, 125, 42, 99 +static const short yyr2[] = { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 1, 1, 1, 1, 1, 1, 2, 0, 2, 0, + 3, 2, 0, 1, 0, 3, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, + 5, 5, 3, 2, 5, 4, 2, 1, 3, 1, + 3, 1, 0, 4, 3, 3, 4, 4, 3, 6, + 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 6, 5, 8, 6, 6, 6, 7, 7, 6, + 6, 8, 8, 3, 1, 1, 1, 1, 2, 2, + 4, 2, 1, 4, 2, 4, 0, 7, 0, 7, + 0, 7, 0, 7, 3, 4, 0, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, + 1, 0, 2, 3, 1, 1, 3, 1, 0, 8, + 1, 1, 3, 1, 1, 2, 0, 1, 1, 0, + 0, 5, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 1, 5, 1, 1, 1, 1, 2, + 2, 2, 3, 2, 0, 1, 1, 1, 2, 2, + 3, 9, 9, 8, 13, 1, 1, 6, 5, 2, + 6, 7, 1, 3, 1, 0, 2, 1, 5, 5, + 5, 6, 6, 2, 4, 4, 6, 4, 4, 4, + 4, 6, 6, 2, 7, 1, 2, 0, 1, 0, + 3, 6, 3, 6, 2, 4, 6, 4 }; -# endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 166, 167, 167, 168, 168, 169, 169, 169, 169, - 169, 169, 169, 169, 169, 169, 169, 170, 170, 170, - 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, - 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, - 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, - 176, 176, 176, 177, 177, 177, 177, 178, 178, 179, - 179, 180, 180, 181, 181, 181, 181, 181, 181, 181, - 181, 182, 182, 182, 182, 182, 182, 182, 182, 183, - 183, 184, 184, 185, 186, 186, 187, 187, 188, 188, - 189, 189, 190, 190, 191, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 193, 193, 193, - 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, - 194, 195, 195, 195, 195, 196, 196, 196, 196, 196, - 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, - 196, 196, 196, 197, 197, 197, 197, 197, 197, 197, - 197, 197, 197, 197, 197, 198, 198, 199, 199, 200, - 201, 201, 201, 201, 201, 202, 202, 202, 203, 202, - 204, 202, 205, 202, 206, 202, 202, 202, 202, 207, - 208, 208, 209, 209, 209, 209, 210, 211, 211, 211, - 212, 212, 213, 213, 214, 215, 215, 216, 216, 216, - 216, 217, 218, 218, 219, 220, 220, 221, 222, 222, - 222, 224, 225, 223, 226, 226, 227, 227, 227, 227, - 227, 227, 227, 227, 227, 227, 227, 228, 228, 229, - 229, 230, 231, 231, 232, 233, 233, 233, 234, 234, - 235, 235, 235, 235, 235, 235, 235, 235, 235, 236, - 236, 237, 238, 238, 239, 239, 240, 240, 241, 241, - 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, - 242, 242, 242, 242, 242, 242, 242, 242, 243, 243, - 244, 244, 245, 245, 245, 245, 245, 245, 245, 245 +static const short yydefact[] = { 197, + 89, 183, 182, 230, 82, 83, 84, 85, 86, 87, + 88, 0, 90, 255, 179, 180, 255, 209, 210, 0, + 0, 0, 89, 0, 185, 227, 0, 0, 91, 92, + 93, 94, 95, 96, 0, 0, 256, 252, 81, 224, + 225, 226, 251, 0, 0, 0, 0, 195, 0, 0, + 0, 0, 0, 0, 0, 80, 228, 229, 231, 198, + 181, 97, 1, 2, 110, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 123, 124, 125, 127, 0, 0, + 0, 0, 246, 0, 0, 109, 126, 113, 247, 128, + 221, 222, 223, 300, 254, 0, 0, 0, 0, 208, + 196, 186, 184, 176, 177, 0, 0, 0, 0, 90, + 129, 0, 0, 0, 112, 134, 138, 0, 0, 143, + 137, 299, 0, 278, 0, 0, 0, 0, 90, 267, + 257, 258, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 51, 52, 53, 54, + 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 67, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 0, 0, 0, 0, 0, 266, 253, + 90, 270, 0, 296, 203, 200, 199, 201, 202, 204, + 207, 0, 191, 193, 189, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 123, 124, 0, 0, 0, 0, + 187, 232, 0, 0, 0, 0, 0, 133, 219, 142, + 140, 0, 0, 284, 277, 260, 259, 0, 0, 71, + 75, 70, 74, 69, 73, 68, 72, 76, 77, 0, + 0, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 0, 49, 50, 45, 46, 47, 48, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 0, 100, + 100, 305, 0, 0, 294, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 205, 105, 105, 105, 159, 160, 3, 4, 157, + 158, 161, 156, 152, 153, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 155, 154, 105, 111, 111, 136, 0, 139, 218, + 212, 215, 216, 0, 0, 130, 235, 236, 237, 242, + 238, 239, 240, 241, 233, 0, 244, 249, 248, 250, + 0, 261, 0, 0, 0, 0, 0, 301, 0, 303, + 298, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 206, 0, + 192, 194, 190, 0, 0, 0, 0, 0, 0, 0, + 145, 175, 0, 0, 0, 149, 0, 146, 0, 0, + 0, 0, 0, 188, 131, 132, 135, 211, 213, 0, + 103, 141, 234, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 308, 0, 0, 0, 288, 291, + 0, 0, 289, 290, 0, 0, 0, 285, 286, 0, + 306, 0, 0, 0, 107, 105, 0, 0, 298, 0, + 0, 0, 0, 0, 144, 134, 113, 0, 147, 148, + 0, 0, 0, 0, 0, 217, 214, 104, 98, 0, + 243, 0, 0, 276, 0, 0, 100, 101, 100, 273, + 297, 0, 0, 0, 0, 0, 279, 280, 281, 276, + 0, 102, 108, 106, 0, 0, 0, 0, 0, 0, + 0, 174, 151, 0, 0, 0, 0, 0, 0, 0, + 220, 0, 0, 0, 275, 0, 282, 283, 0, 302, + 304, 0, 0, 0, 287, 292, 293, 0, 307, 0, + 0, 163, 0, 0, 0, 0, 150, 0, 0, 0, + 0, 0, 99, 245, 0, 0, 0, 274, 271, 0, + 295, 0, 0, 0, 171, 0, 0, 165, 166, 167, + 170, 162, 0, 264, 0, 0, 0, 272, 168, 169, + 0, 0, 0, 262, 0, 263, 0, 0, 164, 172, + 173, 0, 0, 0, 0, 0, 0, 269, 0, 0, + 268, 265, 0, 0, 0 }; -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, - 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 4, 5, 5, 3, 2, 5, 4, 2, 1, - 3, 1, 3, 1, 0, 4, 3, 3, 4, 4, - 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 6, 5, 8, 6, 6, 6, 7, - 7, 6, 6, 8, 8, 3, 1, 1, 1, 1, - 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, - 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, - 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, - 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, - 0, 8, 1, 1, 3, 1, 1, 2, 0, 1, - 1, 0, 0, 5, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 1, 5, 1, 1, 1, - 1, 2, 2, 2, 3, 2, 0, 1, 1, 1, - 2, 2, 3, 9, 9, 8, 13, 1, 1, 6, - 5, 2, 6, 7, 1, 3, 1, 0, 2, 1, - 5, 5, 5, 6, 6, 2, 4, 4, 6, 4, - 4, 4, 4, 6, 6, 2, 7, 1, 2, 0, - 1, 0, 3, 6, 3, 6, 2, 4, 6, 4 +static const short yydefgoto[] = { 83, + 310, 327, 328, 329, 262, 279, 330, 331, 217, 218, + 250, 219, 23, 13, 35, 521, 368, 455, 479, 391, + 456, 84, 85, 220, 87, 88, 118, 232, 402, 357, + 403, 106, 603, 1, 2, 334, 305, 303, 304, 61, + 198, 48, 101, 202, 89, 419, 342, 343, 344, 36, + 93, 14, 42, 15, 59, 16, 26, 110, 424, 358, + 90, 360, 490, 17, 38, 39, 189, 190, 576, 95, + 285, 525, 526, 191, 192, 435, 193, 194 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned short int yydefact[] = -{ - 198, 0, 90, 184, 1, 183, 231, 83, 84, 85, - 86, 87, 88, 89, 0, 91, 256, 180, 181, 256, - 210, 211, 0, 0, 0, 90, 0, 186, 228, 0, - 0, 92, 93, 94, 95, 96, 97, 0, 0, 257, - 253, 82, 225, 226, 227, 252, 0, 0, 0, 0, - 196, 0, 0, 0, 0, 0, 0, 0, 81, 229, - 230, 232, 199, 182, 98, 2, 3, 111, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 128, 0, 0, 0, 0, 247, 0, 0, 110, 127, - 114, 248, 129, 222, 223, 224, 301, 255, 0, 0, - 0, 0, 209, 197, 187, 185, 177, 178, 0, 0, - 0, 0, 91, 130, 0, 0, 0, 113, 135, 139, - 0, 0, 144, 138, 300, 0, 279, 0, 0, 0, - 0, 91, 268, 258, 259, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 52, - 53, 54, 55, 20, 21, 22, 23, 24, 25, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 68, 56, 57, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 0, 0, 0, 0, - 0, 267, 254, 91, 271, 0, 297, 204, 201, 200, - 202, 203, 205, 208, 0, 192, 194, 190, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, - 0, 0, 0, 188, 233, 0, 0, 0, 0, 0, - 134, 220, 143, 141, 0, 0, 285, 278, 261, 260, - 0, 0, 72, 76, 71, 75, 70, 74, 69, 73, - 77, 78, 0, 0, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 0, 50, 51, 46, 47, 48, - 49, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 0, 101, 101, 306, 0, 0, 295, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 206, 106, 106, 106, 160, 161, - 4, 5, 158, 159, 162, 157, 153, 154, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 156, 155, 106, 112, 112, 137, - 0, 140, 219, 213, 216, 217, 0, 0, 131, 236, - 237, 238, 243, 239, 240, 241, 242, 234, 0, 245, - 250, 249, 251, 0, 262, 0, 0, 0, 0, 0, - 302, 0, 304, 299, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 207, 0, 193, 195, 191, 0, 0, 0, 0, - 0, 0, 0, 146, 176, 0, 0, 0, 150, 0, - 147, 0, 0, 0, 0, 0, 189, 132, 133, 136, - 212, 214, 0, 104, 142, 235, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 309, 0, 0, - 0, 289, 292, 0, 0, 290, 291, 0, 0, 0, - 286, 287, 0, 307, 0, 0, 0, 108, 106, 0, - 0, 299, 0, 0, 0, 0, 0, 145, 135, 114, - 0, 148, 149, 0, 0, 0, 0, 0, 218, 215, - 105, 99, 0, 244, 0, 0, 277, 0, 0, 101, - 102, 101, 274, 298, 0, 0, 0, 0, 0, 280, - 281, 282, 277, 0, 103, 109, 107, 0, 0, 0, - 0, 0, 0, 0, 175, 152, 0, 0, 0, 0, - 0, 0, 0, 221, 0, 0, 0, 276, 0, 283, - 284, 0, 303, 305, 0, 0, 0, 288, 293, 294, - 0, 308, 0, 0, 164, 0, 0, 0, 0, 151, - 0, 0, 0, 0, 0, 100, 246, 0, 0, 0, - 275, 272, 0, 296, 0, 0, 0, 172, 0, 0, - 166, 167, 168, 171, 163, 0, 265, 0, 0, 0, - 273, 169, 170, 0, 0, 0, 263, 0, 264, 0, - 0, 165, 173, 174, 0, 0, 0, 0, 0, 0, - 270, 0, 0, 269, 266 +static const short yypact[] = {-32768, + 58, 247,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, -44, 181, 69,-32768,-32768, 10,-32768,-32768, 16, + -116, 34, 65, -38,-32768, 112, 118, 144,-32768,-32768, +-32768,-32768,-32768,-32768, 1357, -19,-32768,-32768, 39,-32768, +-32768,-32768,-32768, 6, 12, 20, 23,-32768, 55, 118, + 1357, 86, 86, 86, 86,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768, 36,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 210, 218, + 1, 171,-32768, 39, 73,-32768,-32768, -42,-32768,-32768, +-32768,-32768,-32768, 1611,-32768, 215, 83, 236, 219, 233, +-32768,-32768,-32768,-32768,-32768, 1418, 1418, 1418, 1459, 181, +-32768, 84, 100, 737,-32768,-32768, -42, -99, 104, 803, +-32768,-32768, 1418,-32768, 201, 1479, 14, 221, 181,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768, 77, 377, 1418, 1418, + 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768, 1418, 1418, 1418, 1418, 1418,-32768,-32768, + 181,-32768, 53,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, -36,-32768,-32768,-32768, 140, 167, 257, 204, 262, + 206, 264, 214, 266, 265, 268, 217, 269, 270, 579, +-32768,-32768, 1418, 1418, 115, -96, 1418,-32768, 1199,-32768, + 128, 126, 920,-32768,-32768, 36,-32768, 920, 920,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 920, + 1357,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 1418,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1418, 130, + 142,-32768, 920, 139, 151, 153, 154, 155, 157, 158, + 164, 165, 920, 920, 920, 166, 284, 1357, 1418, 1418, + 297,-32768, 169, 169, 169,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768, 77, 377, 168, 172, 174, + 175, 177, 1240, 1520, 757, 300, 180, 182, 183, 192, + 193,-32768,-32768, 169, -43, -71,-32768, 190, -42,-32768, + 39,-32768, 173, 202, 1260,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768, 273, 1459,-32768,-32768,-32768,-32768, + 209,-32768, 212, 920, 920, 920, -4,-32768, -2,-32768, + 213, 920, 211, 1418, 1418, 1418, 1418, 1418, 1418, 1418, + 216, 222, 223, 1418, 1418, 920, 920, 226,-32768, -20, +-32768,-32768,-32768, 225, 227, 1459, 1459, 1459, 1459, 1459, +-32768,-32768, -13, 778, -17,-32768, -69,-32768, 1459, 1459, + 1459, 1459, 1459,-32768,-32768,-32768,-32768,-32768,-32768, 1301, + 325,-32768,-32768, 346, -16, 350, 360, 228, 231, 234, + 920, 382, 920, 1418,-32768, 235, 920, 237,-32768,-32768, + 238, 239,-32768,-32768, 920, 920, 920,-32768,-32768, 240, +-32768, 1418, 365, 389,-32768, 169, 1459, 1459, 213, 241, + 243, 245, 248, 1459,-32768, 242, -104, -67,-32768,-32768, + 249, 253, 263, 272, 364,-32768,-32768,-32768, 358, 274, +-32768, 920, 920, 1418, 920, 920, 276,-32768, 276,-32768, + 279, 920, 280, 1418, 1418, 1418,-32768,-32768,-32768, 1418, + 920,-32768,-32768,-32768, 281, 282, 267, 1459, 1459, 1459, + 1459,-32768,-32768, 278, 1459, 1459, 1459, 1459, 1418, 422, +-32768, 416, 288, 285, 279, 289,-32768,-32768, 390,-32768, +-32768, 1418, 287, 920,-32768,-32768,-32768, 292,-32768, 1459, + 1459,-32768, 299, 298, 302, 303,-32768, 301, 306, 307, + 308, 310,-32768,-32768, 432, 15, 435,-32768,-32768, 309, +-32768, 316, 319, 1459,-32768, 1459, 1459,-32768,-32768,-32768, +-32768,-32768, 920,-32768, 1046, 64, 437,-32768,-32768,-32768, + 326, 329, 331,-32768, 328,-32768, 1046, 920,-32768,-32768, +-32768, 467, 336, 148, 920, 469, 470,-32768, 920, 920, +-32768,-32768, 493, 494,-32768 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = -{ - -1, 85, 312, 329, 330, 331, 264, 281, 332, 333, - 219, 220, 252, 221, 25, 15, 37, 523, 370, 457, - 481, 393, 458, 86, 87, 222, 89, 90, 120, 234, - 404, 359, 405, 108, 1, 2, 3, 336, 307, 305, - 306, 63, 200, 50, 103, 204, 91, 421, 344, 345, - 346, 38, 95, 16, 44, 17, 61, 18, 28, 112, - 426, 360, 92, 362, 492, 19, 40, 41, 191, 192, - 578, 97, 287, 527, 528, 193, 194, 437, 195, 196 +static const short yypgoto[] = {-32768, +-32768, 401, 402, 404, 200, 203, 405, 423, -126, -125, + -535,-32768, 479, 496, -109,-32768, -274, 102,-32768, -296, +-32768, -45,-32768, -35,-32768, -58, 27,-32768, -97, 304, + -306, 101,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 471, +-32768,-32768,-32768,-32768, 13,-32768, 106,-32768,-32768, 412, +-32768,-32768,-32768,-32768,-32768, 525,-32768,-32768,-32768, -553, + -9, 114, -122,-32768, 511,-32768, -65,-32768,-32768,-32768, +-32768, 96, 31,-32768,-32768, 74,-32768,-32768 }; -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -555 -static const short int yypact[] = -{ - -555, 136, 58, 247, -555, -555, -555, -555, -555, -555, - -555, -555, -555, -555, 96, 181, 141, -555, -555, -9, - -555, -555, 16, 7, 114, 65, 39, -555, 50, 188, - 210, -555, -555, -555, -555, -555, -555, 1357, -19, -555, - -555, 134, -555, -555, -555, -555, 68, 69, 70, 73, - -555, 60, 188, 1357, 4, 4, 4, 4, -555, -555, - -555, -555, -555, -555, -555, -555, -555, 63, -555, -555, - -555, -555, -555, -555, -555, -555, -555, -555, -555, -555, - -555, 222, 224, 1, 171, -555, 134, 84, -555, -555, - -103, -555, -555, -555, -555, -555, 1611, -555, 216, 66, - 238, 219, 233, -555, -555, -555, -555, -555, 1418, 1418, - 1418, 1459, 181, -555, 100, 101, 737, -555, -555, -103, - -112, 105, 803, -555, -555, 1418, -555, 202, 1479, 13, - 221, 181, -555, -555, -555, -555, -555, -555, -555, -555, - -555, -555, -555, -555, -555, -555, -555, -555, -555, -555, - -555, -555, -555, -555, -555, -555, -555, -555, -555, 77, - 377, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, - 1418, 1418, 1418, -555, -555, -555, -555, -555, -555, -555, - -555, -555, -555, -555, -555, -555, 1418, 1418, 1418, 1418, - 1418, -555, -555, 181, -555, 33, -555, -555, -555, -555, - -555, -555, -555, -555, -15, -555, -555, -555, 36, 158, - 262, 164, 264, 167, 266, 169, 268, 269, 270, 204, - 271, 274, 579, -555, -555, 1418, 1418, 121, -67, 1418, - -555, 1199, -555, 120, 127, 920, -555, -555, 63, -555, - 920, 920, -555, -555, -555, -555, -555, -555, -555, -555, - -555, -555, 920, 1357, -555, -555, -555, -555, -555, -555, - -555, -555, -555, -555, 1418, -555, -555, -555, -555, -555, - -555, -555, -555, -555, -555, -555, -555, -555, -555, -555, - -555, 1418, 142, 143, -555, 920, 147, 153, 154, 155, - 157, 165, 166, 168, 170, 920, 920, 920, 173, 275, - 1357, 1418, 1418, 293, -555, 174, 174, 174, -555, -555, - -555, -555, -555, -555, -555, -555, -555, -555, 77, 377, - 175, 177, 180, 182, 183, 1240, 1520, 757, 296, 192, - 193, 199, 203, 207, -555, -555, 174, -45, -71, -555, - 161, -103, -555, 134, -555, 176, 209, 1260, -555, -555, - -555, -555, -555, -555, -555, -555, -555, 261, 1459, -555, - -555, -555, -555, 206, -555, 213, 920, 920, 920, -2, - -555, 0, -555, 215, 920, 179, 1418, 1418, 1418, 1418, - 1418, 1418, 1418, 217, 218, 223, 1418, 1418, 920, 920, - 226, -555, -17, -555, -555, -555, 214, 220, 1459, 1459, - 1459, 1459, 1459, -555, -555, -13, 778, -94, -555, -40, - -555, 1459, 1459, 1459, 1459, 1459, -555, -555, -555, -555, - -555, -555, 1301, 346, -555, -555, 357, -69, 361, 362, - 229, 234, 235, 920, 382, 920, 1418, -555, 236, 920, - 237, -555, -555, 239, 240, -555, -555, 920, 920, 920, - -555, -555, 241, -555, 1418, 367, 390, -555, 174, 1459, - 1459, 215, 242, 245, 248, 249, 1459, -555, 254, -16, - -8, -555, -555, 250, 253, 263, 272, 364, -555, -555, - -555, 366, 273, -555, 920, 920, 1418, 920, 920, 276, - -555, 276, -555, 279, 920, 280, 1418, 1418, 1418, -555, - -555, -555, 1418, 920, -555, -555, -555, 281, 282, 283, - 1459, 1459, 1459, 1459, -555, -555, 284, 1459, 1459, 1459, - 1459, 1418, 423, -555, 416, 288, 285, 279, 290, -555, - -555, 391, -555, -555, 1418, 294, 920, -555, -555, -555, - 291, -555, 1459, 1459, -555, 299, 298, 302, 303, -555, - 301, 306, 307, 308, 310, -555, -555, 437, 15, 432, - -555, -555, 312, -555, 316, 319, 1459, -555, 1459, 1459, - -555, -555, -555, -555, -555, 920, -555, 1046, 64, 460, - -555, -555, -555, 326, 329, 331, -555, 335, -555, 1046, - 920, -555, -555, -555, 468, 337, 132, 920, 470, 472, - -555, 920, 920, -555, -555 -}; -/* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = -{ - -555, -555, -555, 398, 399, 400, 198, 200, 402, 403, - -128, -127, -525, -555, 476, 493, -111, -555, -276, 97, - -555, -298, -555, -47, -555, -37, -555, -60, -62, -555, - -99, 300, -308, 61, -555, -555, -555, -555, -555, -555, - -555, 469, -555, -555, -555, -555, 8, -555, 102, -555, - -555, 411, -555, -555, -555, -555, -555, 523, -555, -555, - -555, -554, -11, 112, -124, -555, 508, -555, -68, -555, - -555, -555, -555, 93, 28, -555, -555, 71, -555, -555 -}; +#define YYLAST 1762 -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -180 -static const short int yytable[] = -{ - 88, 236, 250, 251, 239, 115, 105, 372, 394, 395, - 93, 26, 223, 433, 39, 435, 88, 455, 407, 409, - 253, 42, 240, 587, 119, 242, 243, 244, 245, 246, - 247, 248, 249, 577, 241, 595, 106, 107, 416, 284, - 456, 229, 288, 289, 290, 291, 292, 293, 294, 26, - 427, 230, -112, 589, 228, 434, 119, 434, -179, 466, - 233, 123, 119, 308, 309, 298, 299, 471, 46, 47, - 48, 205, 206, 207, 242, 243, 244, 245, 246, 247, - 248, 249, 300, 5, 466, 53, 229, 49, 235, 6, - 418, 235, 483, 123, 121, 59, 340, 60, 470, 7, - 8, 9, 10, 11, 12, 13, 7, 8, 9, 10, - 54, 12, 55, 466, 417, 56, 109, 110, 111, 123, - 14, 198, 199, 472, 282, 283, 235, 285, 286, 235, - 235, 235, 235, 235, 235, 235, 4, -139, 303, -112, - 466, 301, 302, 94, 304, 466, 467, -139, 123, 295, - 296, 297, 235, 235, 43, 516, 20, 29, 21, 51, - 506, -72, -72, 116, 39, 337, 338, -71, -71, 341, - -70, -70, -69, -69, 576, 52, 65, 66, 390, 117, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 58, 79, 20, 343, 21, 254, 255, 256, 257, - 258, 259, 260, 261, 262, 263, 366, 310, 311, 133, - 134, 335, 62, 532, 64, 533, 88, 102, -113, 80, - 98, 99, 100, 588, 361, 101, 113, 367, 114, 361, - 361, 242, 243, 244, 245, 246, 247, 248, 249, 122, - 197, 361, 201, 202, 368, 30, 31, 32, 33, 34, - 35, 36, 440, 388, 442, 443, 444, 203, 225, 226, - 231, 237, 450, 88, 389, 235, -76, -82, -75, 20, - -74, 21, -73, 347, 361, 313, -79, -80, 6, -82, - -82, 314, 339, 348, 361, 361, 361, 341, -82, -82, - -82, -82, -82, -82, -82, 369, 371, -82, 22, 461, - 462, 463, 464, 465, 374, 23, 375, 376, 377, 24, - 378, 387, 473, 474, 475, 476, 477, 391, 379, 380, - 410, 381, 419, 382, 425, 81, 386, 392, 82, 422, - 398, 83, 399, 84, 118, 400, 439, 401, 402, 235, - 441, 235, 235, 235, 445, 446, 469, 411, 412, 235, - 451, 420, 363, 364, 413, 361, 361, 361, 414, 428, - 507, 508, 415, 361, 365, 423, 429, 514, 436, 459, - 447, 448, 537, 538, 539, 460, 449, 361, 361, 454, - 455, 482, 484, 485, 486, 343, 490, 487, 488, 494, - 496, 504, 497, 498, 505, 510, 502, 373, 511, 235, - 521, 512, 513, 517, 265, 266, 518, 383, 384, 385, - 560, 545, 546, 547, 548, 515, 519, 503, 550, 551, - 552, 553, 361, 522, 361, 520, 524, 555, 361, 531, - 250, 251, 534, 536, 542, 543, 361, 361, 361, 544, - 556, 557, 558, 564, 565, 549, 559, 563, 434, 235, - 250, 251, 566, 561, 567, 568, 569, 570, 575, 235, - 235, 235, 571, 572, 573, 235, 574, 583, 579, 584, - 585, 580, 581, 361, 361, 582, 361, 361, 430, 431, - 432, 590, 591, 361, 554, 592, 438, 593, 594, 597, - 598, 601, 361, 602, 186, 187, 188, 235, 189, 190, - 452, 453, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 396, 96, 57, 397, - 480, 104, 334, 224, 479, 361, 27, 45, 599, 493, - 540, 0, 509, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 489, 0, 491, 0, 0, - 0, 495, 0, 0, 0, 0, 0, 0, 0, 499, - 500, 501, 0, 0, 361, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 361, - 0, 0, 0, 0, 65, 66, 361, 0, 0, 0, - 361, 361, 0, 0, 0, 0, 525, 526, 0, 529, - 530, 20, 0, 21, 0, 315, 535, 0, 0, 0, - 0, 0, 0, 0, 0, 541, 0, 316, 317, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 562, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 135, 136, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, - 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, - 157, 158, 318, 319, 0, 0, 0, 586, 0, 320, - 0, 321, 0, 322, 323, 324, 0, 0, 0, 0, - 0, 0, 596, 0, 0, 0, 0, 0, 0, 600, - 0, 0, 0, 603, 604, 0, 0, 0, 173, 174, - 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 0, 0, 0, 0, 0, 325, 0, 0, 326, - 0, 327, 65, 66, 328, 117, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 0, 79, 20, - 0, 21, 65, 66, 0, 117, 208, 209, 210, 211, - 212, 213, 214, 215, 216, 217, 218, 0, 79, 20, - 0, 21, 0, 65, 66, 80, 117, 208, 209, 210, - 211, 212, 213, 214, 215, 216, 217, 218, 0, 79, - 20, 0, 21, 0, 0, 80, 0, 0, 65, 66, - 0, 117, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 0, 79, 20, 80, 21, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 81, 0, 0, 82, 0, 0, 83, 0, 84, - 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 81, 0, 0, 82, 0, 0, 83, 0, 84, - 408, 0, 0, 349, 350, 65, 66, 351, 0, 0, - 0, 0, 81, 0, 0, 82, 0, 0, 83, 0, - 84, 468, 20, 0, 21, 0, 352, 353, 354, 0, - 0, 0, 0, 0, 0, 0, 0, 81, 355, 356, - 82, 0, 0, 83, 0, 84, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 357, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 318, 319, 0, 0, 0, 0, 0, - 320, 0, 321, 0, 322, 323, 324, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 349, - 350, 0, 0, 351, 0, 0, 0, 0, 0, 173, - 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 352, 353, 354, 0, 0, 0, 0, 0, - 358, 0, 0, 0, 355, 356, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 357, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, - 150, 151, 152, 153, 154, 155, 156, 157, 158, 318, - 319, 0, 0, 0, 0, 0, 320, 0, 321, 0, - 322, 323, 324, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 173, 174, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 0, 0, - 0, 0, 0, 0, 65, 66, 358, 117, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 0, - 79, 20, 0, 21, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 342, 0, 0, 0, - 0, 0, 0, 0, 0, 65, 66, 80, 117, 208, - 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, - 0, 79, 20, 0, 21, 65, 66, 0, 117, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 0, 79, 20, 0, 21, 0, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, 0, 424, 0, 0, - 0, 0, 0, 0, 0, 0, 65, 66, 80, 117, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 0, 79, 20, 0, 21, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 478, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, - 0, 0, 0, 81, 0, 0, 82, 0, 0, 83, - 0, 84, 65, 66, 0, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 0, 79, 20, - 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 81, 0, 0, 82, 0, 403, - 83, 0, 84, 0, 0, 80, 0, 0, 0, 0, - 0, 0, 0, 0, 81, 0, 0, 82, 0, 0, - 83, 0, 84, 65, 66, 0, 117, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 0, 79, - 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 81, 0, 0, 82, 0, - 0, 83, 0, 84, 65, 66, 80, 117, 208, 209, - 210, 211, 212, 213, 214, 215, 216, 217, 218, 0, - 79, 20, 0, 21, 65, 66, 0, 238, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 0, - 79, 20, 0, 21, 0, 0, 0, 80, 0, 0, - 0, 81, 0, 0, 82, 0, 0, 83, 0, 84, - 0, 0, 0, 0, 0, 65, 66, 80, 117, 208, - 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, - 0, 79, 20, 0, 21, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, - 0, 0, 81, 0, 0, 82, 0, 0, 83, 0, - 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 0, 82, 0, 0, 83, - 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 81, 0, 0, 82, 0, 0, 83, - 0, 84, 0, 0, 0, 0, 124, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 126, 127, 0, 0, 81, 0, 0, 82, 0, 0, - 83, 0, 406, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - 155, 156, 157, 158, 159, 160, 161, 162, 163, 0, - 0, 164, 165, 166, 167, 168, 169, 170, 171, 172, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, - 183, 184, 185 -}; -static const short int yycheck[] = -{ - 37, 125, 130, 130, 128, 4, 53, 283, 306, 307, - 29, 3, 111, 15, 23, 15, 53, 34, 326, 327, - 131, 30, 9, 577, 84, 10, 11, 12, 13, 14, - 15, 16, 17, 558, 21, 589, 32, 33, 336, 163, - 57, 153, 166, 167, 168, 169, 170, 171, 172, 41, - 358, 163, 155, 578, 116, 57, 116, 57, 0, 153, - 122, 164, 122, 27, 28, 189, 190, 161, 52, 53, - 54, 108, 109, 110, 10, 11, 12, 13, 14, 15, - 16, 17, 193, 25, 153, 20, 153, 71, 125, 31, - 161, 128, 161, 164, 86, 45, 163, 47, 406, 41, - 42, 43, 44, 45, 46, 47, 41, 42, 43, 44, - 45, 46, 47, 153, 159, 50, 55, 56, 57, 164, - 62, 55, 56, 163, 161, 162, 163, 164, 165, 166, - 167, 168, 169, 170, 171, 172, 0, 153, 153, 155, - 153, 108, 109, 162, 159, 153, 159, 163, 164, 186, - 187, 188, 189, 190, 163, 163, 22, 61, 24, 152, - 458, 3, 4, 162, 23, 225, 226, 3, 4, 229, - 3, 4, 3, 4, 159, 61, 5, 6, 302, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 152, 21, 22, 231, 24, 119, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 253, 3, 4, 77, - 78, 222, 24, 489, 4, 491, 253, 157, 155, 48, - 152, 152, 152, 159, 235, 152, 4, 264, 4, 240, - 241, 10, 11, 12, 13, 14, 15, 16, 17, 155, - 24, 252, 4, 24, 281, 64, 65, 66, 67, 68, - 69, 70, 376, 300, 378, 379, 380, 24, 158, 158, - 155, 59, 386, 300, 301, 302, 4, 20, 4, 22, - 4, 24, 4, 153, 285, 4, 7, 7, 31, 32, - 33, 7, 161, 156, 295, 296, 297, 347, 41, 42, - 43, 44, 45, 46, 47, 153, 153, 50, 51, 398, - 399, 400, 401, 402, 157, 58, 153, 153, 153, 62, - 153, 36, 411, 412, 413, 414, 415, 24, 153, 153, - 24, 153, 161, 153, 63, 154, 153, 153, 157, 153, - 155, 160, 155, 162, 163, 155, 157, 155, 155, 376, - 377, 378, 379, 380, 381, 382, 406, 155, 155, 386, - 387, 343, 240, 241, 155, 366, 367, 368, 155, 153, - 459, 460, 155, 374, 252, 156, 153, 466, 153, 155, - 153, 153, 496, 497, 498, 155, 153, 388, 389, 153, - 34, 24, 21, 21, 155, 422, 4, 153, 153, 153, - 153, 24, 153, 153, 4, 153, 155, 285, 153, 436, - 36, 153, 153, 153, 27, 28, 153, 295, 296, 297, - 534, 510, 511, 512, 513, 161, 153, 454, 517, 518, - 519, 520, 433, 57, 435, 153, 153, 4, 439, 153, - 558, 558, 153, 153, 153, 153, 447, 448, 449, 156, - 24, 153, 157, 542, 543, 161, 156, 156, 57, 486, - 578, 578, 153, 159, 156, 153, 153, 156, 21, 496, - 497, 498, 156, 156, 156, 502, 156, 566, 36, 568, - 569, 159, 156, 484, 485, 156, 487, 488, 366, 367, - 368, 21, 156, 494, 521, 156, 374, 156, 153, 21, - 153, 21, 503, 21, 96, 96, 96, 534, 96, 96, - 388, 389, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 134, 135, 136, 137, 138, 318, 41, 25, 319, - 423, 52, 222, 112, 422, 536, 3, 19, 596, 436, - 502, -1, 461, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 433, -1, 435, -1, -1, - -1, 439, -1, -1, -1, -1, -1, -1, -1, 447, - 448, 449, -1, -1, 575, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 590, - -1, -1, -1, -1, 5, 6, 597, -1, -1, -1, - 601, 602, -1, -1, -1, -1, 484, 485, -1, 487, - 488, 22, -1, 24, -1, 26, 494, -1, -1, -1, - -1, -1, -1, -1, -1, 503, -1, 38, 39, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 536, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, -1, -1, -1, 575, -1, 110, - -1, 112, -1, 114, 115, 116, -1, -1, -1, -1, - -1, -1, 590, -1, -1, -1, -1, -1, -1, 597, - -1, -1, -1, 601, 602, -1, -1, -1, 139, 140, - 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, - 151, -1, -1, -1, -1, -1, 157, -1, -1, 160, - -1, 162, 5, 6, 165, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, - -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, - -1, 24, -1, 5, 6, 48, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, - 22, -1, 24, -1, -1, 48, -1, -1, 5, 6, - -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, -1, 21, 22, 48, 24, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, - 163, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, - 163, -1, -1, 3, 4, 5, 6, 7, -1, -1, - -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, - 162, 163, 22, -1, 24, -1, 26, 27, 28, -1, - -1, -1, -1, -1, -1, -1, -1, 154, 38, 39, - 157, -1, -1, 160, -1, 162, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 61, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, -1, -1, -1, -1, -1, - 110, -1, 112, -1, 114, 115, 116, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, - 4, -1, -1, 7, -1, -1, -1, -1, -1, 139, - 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, - 150, 151, 26, 27, 28, -1, -1, -1, -1, -1, - 160, -1, -1, -1, 38, 39, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, -1, -1, -1, -1, -1, 110, -1, 112, -1, - 114, 115, 116, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, -1, -1, - -1, -1, -1, -1, 5, 6, 160, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, - 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - -1, 21, 22, -1, 24, 5, 6, -1, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - -1, 21, 22, -1, 24, -1, -1, -1, 48, -1, - -1, -1, -1, -1, -1, -1, -1, 37, -1, -1, - -1, -1, -1, -1, -1, -1, 5, 6, 48, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, -1, 21, 22, -1, 24, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 37, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 48, - -1, -1, -1, 154, -1, -1, 157, -1, -1, 160, - -1, 162, 5, 6, -1, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, - -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 154, -1, -1, 157, -1, 159, - 160, -1, 162, -1, -1, 48, -1, -1, -1, -1, - -1, -1, -1, -1, 154, -1, -1, 157, -1, -1, - 160, -1, 162, 5, 6, -1, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, - 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 154, -1, -1, 157, -1, - -1, 160, -1, 162, 5, 6, 48, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, - 21, 22, -1, 24, 5, 6, -1, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, - 21, 22, -1, 24, -1, -1, -1, 48, -1, -1, - -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, - -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - -1, 21, 22, -1, 24, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 48, -1, - -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, - 162, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, -1, 157, -1, -1, 160, - -1, 162, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 154, -1, -1, 157, -1, -1, 160, - -1, 162, -1, -1, -1, -1, 35, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 59, 60, -1, -1, 154, -1, -1, 157, -1, -1, - 160, -1, 162, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, -1, - -1, 110, 111, 112, 113, 114, 115, 116, 117, 118, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, - 149, 150, 151 +static const short yytable[] = { 86, + 234, 248, 249, 237, 113, 103, 370, 392, 393, 91, + 431, 221, 433, 453, 24, 86, 27, 405, 407, 251, + 575, 585, 238, 117, 240, 241, 242, 243, 244, 245, + 246, 247, 37, 593, 239, 49, 454, 414, 282, 40, + 587, 286, 287, 288, 289, 290, 291, 292, -138, 425, + -111, 24, 432, 227, 432, 117, 227, -178, -138, 121, + 18, 117, 19, 228, 296, 297, 338, 44, 45, 46, + 203, 204, 205, 240, 241, 242, 243, 244, 245, 246, + 247, 298, 3, 464, 51, 464, 47, 233, 4, 416, + 233, 37, 121, 470, 50, 514, 119, 468, 5, 6, + 7, 8, 9, 10, 11, 5, 6, 7, 8, 52, + 10, 53, -111, 56, 54, 415, 301, 104, 105, 12, + 121, 121, 302, 280, 281, 233, 283, 284, 233, 233, + 233, 233, 233, 233, 233, 464, 464, 196, 197, 464, + 226, 60, 92, 469, 481, 465, 231, 62, 293, 294, + 295, 233, 233, 107, 108, 109, 57, 96, 58, 504, + 299, 300, 114, 97, 335, 336, 306, 307, 339, -71, + -71, 98, 41, 574, 99, 63, 64, 388, 115, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + -112, 77, 18, 341, 19, 252, 253, 254, 255, 256, + 257, 258, 259, 260, 261, 364, -70, -70, -69, -69, + 333, 100, 530, 111, 531, 86, -68, -68, 78, 308, + 309, 112, 586, 359, 131, 132, 365, 120, 359, 359, + 240, 241, 242, 243, 244, 245, 246, 247, 195, 199, + 359, 223, 200, 366, 28, 29, 30, 31, 32, 33, + 34, 438, 386, 440, 441, 442, 201, 224, 229, 235, + -75, 448, 86, 387, 233, -74, -81, -73, 18, -72, + 19, -78, 311, 359, -79, 337, 312, 4, -81, -81, + 345, 346, 367, 359, 359, 359, 339, -81, -81, -81, + -81, -81, -81, -81, 369, 372, -81, 20, 459, 460, + 461, 462, 463, 373, 21, 374, 375, 376, 22, 377, + 378, 471, 472, 473, 474, 475, 379, 380, 384, 385, + 389, 390, 396, 408, 79, 420, 397, 80, 398, 399, + 81, 400, 82, 116, 409, 423, 410, 411, 233, 439, + 233, 233, 233, 443, 444, 467, 412, 413, 233, 449, + 417, 361, 362, 418, 359, 359, 359, 421, 453, 505, + 506, 426, 359, 363, 427, 434, 512, 437, 445, 480, + 482, 535, 536, 537, 446, 447, 359, 359, 452, 457, + 483, 458, 484, 485, 341, 488, 486, 492, 502, 494, + 495, 496, 503, 508, 500, 509, 371, 510, 233, 519, + 511, 515, 513, 263, 264, 516, 381, 382, 383, 558, + 543, 544, 545, 546, 520, 517, 501, 548, 549, 550, + 551, 359, 542, 359, 518, 553, 522, 359, 529, 248, + 249, 532, 534, 540, 541, 359, 359, 359, 547, 554, + 555, 556, 562, 563, 557, 559, 432, 561, 233, 248, + 249, 564, 573, 565, 566, 567, 568, 588, 233, 233, + 233, 569, 570, 571, 233, 572, 581, 578, 582, 583, + 577, 579, 359, 359, 580, 359, 359, 428, 429, 430, + 592, 589, 359, 552, 590, 436, 591, 595, 596, 599, + 600, 359, 604, 605, 184, 185, 233, 186, 187, 450, + 451, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 274, 275, 276, 277, 278, 394, 188, 94, 55, 395, + 102, 222, 478, 332, 359, 477, 25, 43, 597, 491, + 538, 0, 507, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 487, 0, 489, 0, 0, 0, + 493, 0, 0, 0, 0, 0, 0, 0, 497, 498, + 499, 0, 0, 359, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 359, 0, + 0, 0, 0, 63, 64, 359, 0, 0, 0, 359, + 359, 0, 0, 0, 0, 523, 524, 0, 527, 528, + 18, 0, 19, 0, 313, 533, 0, 0, 0, 0, + 0, 0, 0, 0, 539, 0, 314, 315, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 560, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, + 156, 316, 317, 0, 0, 0, 584, 0, 318, 0, + 319, 0, 320, 321, 322, 0, 0, 0, 0, 0, + 0, 594, 0, 0, 0, 0, 0, 0, 598, 0, + 0, 0, 601, 602, 0, 0, 0, 171, 172, 173, + 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, + 0, 0, 0, 0, 0, 323, 0, 0, 324, 0, + 325, 63, 64, 326, 115, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 0, 77, 18, 0, + 19, 63, 64, 0, 115, 206, 207, 208, 209, 210, + 211, 212, 213, 214, 215, 216, 0, 77, 18, 0, + 19, 0, 63, 64, 78, 115, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 0, 77, 18, + 0, 19, 0, 0, 78, 0, 0, 63, 64, 0, + 115, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 0, 77, 18, 78, 19, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 230, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 79, 0, 0, 80, 0, 0, 81, 0, 82, 225, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 79, 0, 0, 80, 0, 0, 81, 0, 82, 406, + 0, 0, 347, 348, 63, 64, 349, 0, 0, 0, + 0, 79, 0, 0, 80, 0, 0, 81, 0, 82, + 466, 18, 0, 19, 0, 350, 351, 352, 0, 0, + 0, 0, 0, 0, 0, 0, 79, 353, 354, 80, + 0, 0, 81, 0, 82, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, + 155, 156, 316, 317, 0, 0, 0, 0, 0, 318, + 0, 319, 0, 320, 321, 322, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 347, 348, + 0, 0, 349, 0, 0, 0, 0, 0, 171, 172, + 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, + 183, 350, 351, 352, 0, 0, 0, 0, 0, 356, + 0, 0, 0, 353, 354, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 355, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 155, 156, 316, 317, + 0, 0, 0, 0, 0, 318, 0, 319, 0, 320, + 321, 322, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 171, 172, 173, 174, 175, 176, + 177, 178, 179, 180, 181, 182, 183, 0, 0, 0, + 0, 0, 0, 63, 64, 356, 115, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 0, 77, + 18, 0, 19, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 340, 0, 0, 0, 0, + 0, 0, 0, 0, 63, 64, 78, 115, 206, 207, + 208, 209, 210, 211, 212, 213, 214, 215, 216, 0, + 77, 18, 0, 19, 63, 64, 0, 115, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 0, + 77, 18, 0, 19, 0, 0, 0, 78, 0, 0, + 0, 0, 0, 0, 0, 0, 422, 0, 0, 0, + 0, 0, 0, 0, 0, 63, 64, 78, 115, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 0, 77, 18, 0, 19, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 476, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, + 0, 0, 79, 0, 0, 80, 0, 0, 81, 0, + 82, 63, 64, 0, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 0, 77, 18, 0, + 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 0, 0, 80, 0, 401, 81, + 0, 82, 0, 0, 78, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 0, 0, 80, 0, 0, 81, + 0, 82, 63, 64, 0, 115, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 0, 77, 18, + 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 79, 0, 0, 80, 0, 0, + 81, 0, 82, 63, 64, 78, 115, 206, 207, 208, + 209, 210, 211, 212, 213, 214, 215, 216, 0, 77, + 18, 0, 19, 63, 64, 0, 236, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 0, 77, + 18, 0, 19, 0, 0, 0, 78, 0, 0, 0, + 79, 0, 0, 80, 0, 0, 81, 0, 82, 0, + 0, 0, 0, 0, 63, 64, 78, 115, 206, 207, + 208, 209, 210, 211, 212, 213, 214, 215, 216, 0, + 77, 18, 0, 19, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 78, 0, 0, + 0, 79, 0, 0, 80, 0, 0, 81, 0, 82, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 0, 0, 80, 0, 0, 81, 0, + 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 0, 0, 80, 0, 0, 81, 0, + 82, 0, 0, 0, 0, 122, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, + 125, 0, 0, 79, 0, 0, 80, 0, 0, 81, + 0, 404, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 161, 0, 0, + 162, 163, 164, 165, 166, 167, 168, 169, 170, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 171, + 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 200, 201, 202, 0, 25, 31, 41, 42, 43, - 44, 45, 46, 47, 62, 181, 219, 221, 223, 231, - 22, 24, 51, 58, 62, 180, 212, 223, 224, 61, - 64, 65, 66, 67, 68, 69, 70, 182, 217, 23, - 232, 233, 30, 163, 220, 232, 52, 53, 54, 71, - 209, 152, 61, 20, 45, 47, 50, 181, 152, 45, - 47, 222, 24, 207, 4, 5, 6, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, - 48, 154, 157, 160, 162, 167, 189, 190, 191, 192, - 193, 212, 228, 29, 162, 218, 180, 237, 152, 152, - 152, 152, 157, 210, 207, 189, 32, 33, 199, 199, - 199, 199, 225, 4, 4, 4, 162, 8, 163, 193, - 194, 212, 155, 164, 35, 49, 59, 60, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 139, 140, 141, 142, 143, 144, 145, - 146, 147, 148, 149, 150, 151, 169, 170, 171, 174, - 175, 234, 235, 241, 242, 244, 245, 24, 55, 56, - 208, 4, 24, 24, 211, 191, 191, 191, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 176, - 177, 179, 191, 196, 217, 158, 158, 163, 194, 153, - 163, 155, 37, 194, 195, 191, 230, 59, 8, 230, - 9, 21, 10, 11, 12, 13, 14, 15, 16, 17, - 176, 177, 178, 182, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 172, 27, 28, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 173, 191, 191, 230, 191, 191, 238, 230, 230, - 230, 230, 230, 230, 230, 191, 191, 191, 230, 230, - 182, 108, 109, 153, 159, 205, 206, 204, 27, 28, - 3, 4, 168, 4, 7, 26, 38, 39, 103, 104, - 110, 112, 114, 115, 116, 157, 160, 162, 165, 169, - 170, 171, 174, 175, 197, 228, 203, 193, 193, 161, - 163, 193, 37, 191, 214, 215, 216, 153, 156, 3, - 4, 7, 26, 27, 28, 38, 39, 61, 160, 197, - 227, 228, 229, 229, 229, 229, 189, 191, 191, 153, - 184, 153, 184, 229, 157, 153, 153, 153, 153, 153, - 153, 153, 153, 229, 229, 229, 153, 36, 189, 191, - 230, 24, 153, 187, 187, 187, 172, 173, 155, 155, - 155, 155, 155, 159, 196, 198, 162, 198, 163, 198, - 24, 155, 155, 155, 155, 155, 187, 159, 161, 161, - 212, 213, 153, 156, 37, 63, 226, 198, 153, 153, - 229, 229, 229, 15, 57, 15, 153, 243, 229, 157, - 230, 191, 230, 230, 230, 191, 191, 153, 153, 153, - 230, 191, 229, 229, 153, 34, 57, 185, 188, 155, - 155, 196, 196, 196, 196, 196, 153, 159, 163, 193, - 198, 161, 163, 196, 196, 196, 196, 196, 37, 214, - 185, 186, 24, 161, 21, 21, 155, 153, 153, 229, - 4, 229, 230, 239, 153, 229, 153, 153, 153, 229, - 229, 229, 155, 191, 24, 4, 187, 196, 196, 243, - 153, 153, 153, 153, 196, 161, 163, 153, 153, 153, - 153, 36, 57, 183, 153, 229, 229, 239, 240, 229, - 229, 153, 184, 184, 153, 229, 153, 230, 230, 230, - 240, 229, 153, 153, 156, 196, 196, 196, 196, 161, - 196, 196, 196, 196, 191, 4, 24, 153, 157, 156, - 230, 159, 229, 156, 196, 196, 153, 156, 153, 153, - 156, 156, 156, 156, 156, 21, 159, 178, 236, 36, - 159, 156, 156, 196, 196, 196, 229, 227, 159, 178, - 21, 156, 156, 156, 153, 227, 229, 21, 153, 234, - 229, 21, 21, 229, 229 +static const short yycheck[] = { 35, + 123, 128, 128, 126, 4, 51, 281, 304, 305, 29, + 15, 109, 15, 34, 2, 51, 61, 324, 325, 129, + 556, 575, 9, 82, 10, 11, 12, 13, 14, 15, + 16, 17, 23, 587, 21, 152, 57, 334, 161, 30, + 576, 164, 165, 166, 167, 168, 169, 170, 153, 356, + 155, 39, 57, 153, 57, 114, 153, 0, 163, 164, + 22, 120, 24, 163, 187, 188, 163, 52, 53, 54, + 106, 107, 108, 10, 11, 12, 13, 14, 15, 16, + 17, 191, 25, 153, 20, 153, 71, 123, 31, 161, + 126, 23, 164, 163, 61, 163, 84, 404, 41, 42, + 43, 44, 45, 46, 47, 41, 42, 43, 44, 45, + 46, 47, 155, 152, 50, 159, 153, 32, 33, 62, + 164, 164, 159, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 170, 153, 153, 55, 56, 153, + 114, 24, 162, 161, 161, 159, 120, 4, 184, 185, + 186, 187, 188, 53, 54, 55, 45, 152, 47, 456, + 108, 109, 162, 152, 223, 224, 27, 28, 227, 3, + 4, 152, 163, 159, 152, 5, 6, 300, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 155, 21, 22, 229, 24, 119, 120, 121, 122, 123, + 124, 125, 126, 127, 128, 251, 3, 4, 3, 4, + 220, 157, 487, 4, 489, 251, 3, 4, 48, 3, + 4, 4, 159, 233, 77, 78, 262, 155, 238, 239, + 10, 11, 12, 13, 14, 15, 16, 17, 24, 4, + 250, 158, 24, 279, 64, 65, 66, 67, 68, 69, + 70, 374, 298, 376, 377, 378, 24, 158, 155, 59, + 4, 384, 298, 299, 300, 4, 20, 4, 22, 4, + 24, 7, 4, 283, 7, 161, 7, 31, 32, 33, + 153, 156, 153, 293, 294, 295, 345, 41, 42, 43, + 44, 45, 46, 47, 153, 157, 50, 51, 396, 397, + 398, 399, 400, 153, 58, 153, 153, 153, 62, 153, + 153, 409, 410, 411, 412, 413, 153, 153, 153, 36, + 24, 153, 155, 24, 154, 153, 155, 157, 155, 155, + 160, 155, 162, 163, 155, 63, 155, 155, 374, 375, + 376, 377, 378, 379, 380, 404, 155, 155, 384, 385, + 161, 238, 239, 341, 364, 365, 366, 156, 34, 457, + 458, 153, 372, 250, 153, 153, 464, 157, 153, 24, + 21, 494, 495, 496, 153, 153, 386, 387, 153, 155, + 21, 155, 155, 153, 420, 4, 153, 153, 24, 153, + 153, 153, 4, 153, 155, 153, 283, 153, 434, 36, + 153, 153, 161, 27, 28, 153, 293, 294, 295, 532, + 508, 509, 510, 511, 57, 153, 452, 515, 516, 517, + 518, 431, 156, 433, 153, 4, 153, 437, 153, 556, + 556, 153, 153, 153, 153, 445, 446, 447, 161, 24, + 153, 157, 540, 541, 156, 159, 57, 156, 484, 576, + 576, 153, 21, 156, 153, 153, 156, 21, 494, 495, + 496, 156, 156, 156, 500, 156, 564, 159, 566, 567, + 36, 156, 482, 483, 156, 485, 486, 364, 365, 366, + 153, 156, 492, 519, 156, 372, 156, 21, 153, 21, + 21, 501, 0, 0, 94, 94, 532, 94, 94, 386, + 387, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 316, 94, 39, 23, 317, + 50, 110, 421, 220, 534, 420, 2, 17, 594, 434, + 500, -1, 459, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 431, -1, 433, -1, -1, -1, + 437, -1, -1, -1, -1, -1, -1, -1, 445, 446, + 447, -1, -1, 573, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 588, -1, + -1, -1, -1, 5, 6, 595, -1, -1, -1, 599, + 600, -1, -1, -1, -1, 482, 483, -1, 485, 486, + 22, -1, 24, -1, 26, 492, -1, -1, -1, -1, + -1, -1, -1, -1, 501, -1, 38, 39, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 534, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 104, -1, -1, -1, 573, -1, 110, -1, + 112, -1, 114, 115, 116, -1, -1, -1, -1, -1, + -1, 588, -1, -1, -1, -1, -1, -1, 595, -1, + -1, -1, 599, 600, -1, -1, -1, 139, 140, 141, + 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, + -1, -1, -1, -1, -1, 157, -1, -1, 160, -1, + 162, 5, 6, 165, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, + 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, + 24, -1, 5, 6, 48, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, + -1, 24, -1, -1, 48, -1, -1, 5, 6, -1, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, -1, 21, 22, 48, 24, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 154, -1, -1, 157, -1, -1, 160, -1, 162, 163, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 154, -1, -1, 157, -1, -1, 160, -1, 162, 163, + -1, -1, 3, 4, 5, 6, 7, -1, -1, -1, + -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, + 163, 22, -1, 24, -1, 26, 27, 28, -1, -1, + -1, -1, -1, -1, -1, -1, 154, 38, 39, 157, + -1, -1, 160, -1, 162, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 61, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 101, 102, 103, 104, -1, -1, -1, -1, -1, 110, + -1, 112, -1, 114, 115, 116, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, + -1, -1, 7, -1, -1, -1, -1, -1, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + 151, 26, 27, 28, -1, -1, -1, -1, -1, 160, + -1, -1, -1, 38, 39, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 61, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + -1, -1, -1, -1, -1, 110, -1, 112, -1, 114, + 115, 116, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 139, 140, 141, 142, 143, 144, + 145, 146, 147, 148, 149, 150, 151, -1, -1, -1, + -1, -1, -1, 5, 6, 160, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, + 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, + -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, + 21, 22, -1, 24, 5, 6, -1, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, + 21, 22, -1, 24, -1, -1, -1, 48, -1, -1, + -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, + -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + -1, 21, 22, -1, 24, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 37, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 48, -1, + -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, + 162, 5, 6, -1, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, + 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, -1, 157, -1, 159, 160, + -1, 162, -1, -1, 48, -1, -1, -1, -1, -1, + -1, -1, -1, 154, -1, -1, 157, -1, -1, 160, + -1, 162, 5, 6, -1, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, + -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 154, -1, -1, 157, -1, -1, + 160, -1, 162, 5, 6, 48, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, + 22, -1, 24, 5, 6, -1, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, + 22, -1, 24, -1, -1, -1, 48, -1, -1, -1, + 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, + -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, + 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 48, -1, -1, + -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, + 162, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, + 162, -1, -1, -1, -1, 35, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 49, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, + 60, -1, -1, 154, -1, -1, 157, -1, -1, 160, + -1, 162, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 101, 102, 103, 104, 105, 106, 107, -1, -1, + 110, 111, 112, 113, 114, 115, 116, 117, 118, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151 }; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + 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 2, 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. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible at ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) +#define YYEMPTY -2 #define YYEOF 0 - #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ - #define YYFAIL goto yyerrlab - #define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ +#define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) - #define YYTERROR 1 #define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (0) +#ifndef YYPURE +#define YYLEX yylex() #endif - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) #endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - +#else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) +#define YYLEX yylex(&yylval, YYLEX_PARAM) #else -# define YYLEX yylex () +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ #endif -/* Enable debugging if requested. */ -#if YYDEBUG +/* If nonreentrant, generate the variables here */ -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +#ifndef YYPURE -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short int *bottom, short int *top) -#else -static void -yy_stack_print (bottom, top) - short int *bottom; - short int *top; +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ #endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ #endif -{ - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); -} -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ +/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -/* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -# define YYINITDEPTH 200 +#define YYINITDEPTH 200 #endif -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 +#define YYMAXDEPTH 10000 #endif - +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; { - if (*yystr == '"') - { - size_t yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } + register char *f = from; + register char *t = to; + register int i = count; - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; + while (i-- > 0) + *t++ = *f++; } -# endif - -#endif /* YYERROR_VERBOSE */ - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +#else /* __cplusplus */ -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif +__yy_memcpy (char *to, char *from, unsigned int count) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + register char *t = to; + register char *f = from; + register int i = count; - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); + while (i-- > 0) + *t++ = *f++; } -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; #endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} +#endif +#line 217 "/usr/share/bison.simple" -/* Prevent warnings from -Wmissing-prototypes. */ +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) +int yyparse (void *); #else -int -yyparse () - +int yyparse (void); #endif #endif -{ - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else #define YYPOPSTACK (yyvsp--, yyssp--) +#endif - YYSIZE_T yystacksize = YYINITDEPTH; + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ int yylen; - YYDPRINTF ((stderr, "Starting parse\n")); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif yystate = 0; yyerrstatus = 0; @@ -3497,745 +2799,718 @@ so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; + yyssp = yyss - 1; yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif - if (yyss + yystacksize - 1 <= yyssp) - { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + int size = yyssp - yyss + 1; #ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif - yyss = yyss1; - yyvs = yyvs1; - } + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif #else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) + if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; - - { - short int *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif #endif /* no yyoverflow */ - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif - if (yyss + yystacksize - 1 <= yyssp) + if (yyssp >= yyss + yystacksize - 1) YYABORT; } - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: + yybackup: /* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ +/* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yyn == YYFLAG) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif yychar = YYLEX; } - if (yychar <= YYEOF) + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif } else { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif } - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; + yyn = yytable[yyn]; - if (yyn <= 0) + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) + if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } + else if (yyn == 0) + goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ +/* Do the default action for the current state. */ yydefault: + yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; - goto yyreduce; - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ +/* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: - /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 3: -#line 1595 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! - error("Value too large for type"); - (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); - ;} - break; - - case 5: -#line 1604 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" +#if YYDEBUG != 0 + if (yydebug) { - if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! - error("Value too large for type"); - (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); - ;} - break; - - case 26: -#line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_EQ; ;} - break; - - case 27: -#line 1626 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_NE; ;} - break; - - case 28: -#line 1627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_SLT; ;} - break; - - case 29: -#line 1627 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_SGT; ;} - break; + int i; - case 30: -#line 1628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_SLE; ;} - break; + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); - case 31: -#line 1628 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_SGE; ;} - break; + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif - case 32: -#line 1629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_ULT; ;} - break; - case 33: -#line 1629 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_UGT; ;} - break; + switch (yyn) { - case 34: -#line 1630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_ULE; ;} - break; - - case 35: -#line 1630 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.IPred) = ICmpInst::ICMP_UGE; ;} - break; - - case 36: -#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;} - break; - - case 37: -#line 1634 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_ONE; ;} - break; - - case 38: -#line 1635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_OLT; ;} - break; - - case 39: -#line 1635 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_OGT; ;} - break; - - case 40: -#line 1636 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_OLE; ;} - break; - - case 41: -#line 1636 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_OGE; ;} - break; - - case 42: -#line 1637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_ORD; ;} - break; - - case 43: -#line 1637 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_UNO; ;} - break; - - case 44: -#line 1638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;} - break; - - case 45: -#line 1638 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_UNE; ;} - break; - - case 46: -#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_ULT; ;} - break; - - case 47: -#line 1639 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_UGT; ;} - break; - - case 48: -#line 1640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_ULE; ;} - break; - - case 49: -#line 1640 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_UGE; ;} - break; - - case 50: -#line 1641 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;} - break; - - case 51: -#line 1642 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;} - break; - - case 81: -#line 1673 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.StrVal) = (yyvsp[-1].StrVal); - ;} - break; - - case 82: -#line 1676 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.StrVal) = 0; - ;} - break; - - case 83: -#line 1681 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} - break; - - case 84: -#line 1682 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} - break; - - case 85: -#line 1683 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} - break; - - case 86: -#line 1684 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} - break; - - case 87: -#line 1685 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} - break; - - case 88: -#line 1686 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} - break; - - case 89: -#line 1687 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} - break; - - case 90: -#line 1688 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} - break; - - case 91: -#line 1692 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::C; ;} - break; - - case 92: -#line 1693 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::C; ;} - break; - - case 93: -#line 1694 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::CSRet; ;} - break; - - case 94: -#line 1695 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::Fast; ;} - break; - - case 95: -#line 1696 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::Cold; ;} - break; - - case 96: -#line 1697 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::X86_StdCall; ;} - break; - - case 97: -#line 1698 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = OldCallingConv::X86_FastCall; ;} - break; - - case 98: -#line 1699 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) +case 2: +#line 1595 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! + error("Value too large for type"); + yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; + ; + break;} +case 4: +#line 1604 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! + error("Value too large for type"); + yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; + ; + break;} +case 25: +#line 1626 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_EQ; ; + break;} +case 26: +#line 1626 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_NE; ; + break;} +case 27: +#line 1627 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_SLT; ; + break;} +case 28: +#line 1627 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_SGT; ; + break;} +case 29: +#line 1628 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_SLE; ; + break;} +case 30: +#line 1628 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_SGE; ; + break;} +case 31: +#line 1629 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_ULT; ; + break;} +case 32: +#line 1629 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_UGT; ; + break;} +case 33: +#line 1630 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_ULE; ; + break;} +case 34: +#line 1630 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.IPred = ICmpInst::ICMP_UGE; ; + break;} +case 35: +#line 1634 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_OEQ; ; + break;} +case 36: +#line 1634 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_ONE; ; + break;} +case 37: +#line 1635 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_OLT; ; + break;} +case 38: +#line 1635 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_OGT; ; + break;} +case 39: +#line 1636 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_OLE; ; + break;} +case 40: +#line 1636 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_OGE; ; + break;} +case 41: +#line 1637 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_ORD; ; + break;} +case 42: +#line 1637 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_UNO; ; + break;} +case 43: +#line 1638 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_UEQ; ; + break;} +case 44: +#line 1638 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_UNE; ; + break;} +case 45: +#line 1639 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_ULT; ; + break;} +case 46: +#line 1639 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_UGT; ; + break;} +case 47: +#line 1640 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_ULE; ; + break;} +case 48: +#line 1640 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_UGE; ; + break;} +case 49: +#line 1641 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_TRUE; ; + break;} +case 50: +#line 1642 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.FPred = FCmpInst::FCMP_FALSE; ; + break;} +case 80: +#line 1673 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.StrVal = yyvsp[-1].StrVal; + ; + break;} +case 81: +#line 1676 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.StrVal = 0; + ; + break;} +case 82: +#line 1681 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::InternalLinkage; ; + break;} +case 83: +#line 1682 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ; + break;} +case 84: +#line 1683 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::WeakLinkage; ; + break;} +case 85: +#line 1684 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::AppendingLinkage; ; + break;} +case 86: +#line 1685 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::DLLImportLinkage; ; + break;} +case 87: +#line 1686 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::DLLExportLinkage; ; + break;} +case 88: +#line 1687 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; + break;} +case 89: +#line 1688 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::ExternalLinkage; ; + break;} +case 90: +#line 1692 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::C; ; + break;} +case 91: +#line 1693 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::C; ; + break;} +case 92: +#line 1694 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::CSRet; ; + break;} +case 93: +#line 1695 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::Fast; ; + break;} +case 94: +#line 1696 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::Cold; ; + break;} +case 95: +#line 1697 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::X86_StdCall; ; + break;} +case 96: +#line 1698 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = OldCallingConv::X86_FastCall; ; + break;} +case 97: +#line 1699 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) error("Calling conv too large"); - (yyval.UIntVal) = (yyvsp[0].UInt64Val); - ;} - break; - - case 99: -#line 1709 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = 0; ;} - break; - - case 100: -#line 1710 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.UIntVal) = (yyvsp[0].UInt64Val); - if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) + yyval.UIntVal = yyvsp[0].UInt64Val; + ; + break;} +case 98: +#line 1709 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = 0; ; + break;} +case 99: +#line 1710 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.UIntVal = yyvsp[0].UInt64Val; + if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) error("Alignment must be a power of two"); - ;} - break; - - case 101: -#line 1718 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.UIntVal) = 0; ;} - break; - - case 102: -#line 1719 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.UIntVal) = (yyvsp[0].UInt64Val); - if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) + ; + break;} +case 100: +#line 1718 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.UIntVal = 0; ; + break;} +case 101: +#line 1719 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.UIntVal = yyvsp[0].UInt64Val; + if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) error("Alignment must be a power of two"); - ;} - break; - - case 103: -#line 1727 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) - if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') + ; + break;} +case 102: +#line 1727 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) + if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') error("Invalid character in section name"); - (yyval.StrVal) = (yyvsp[0].StrVal); - ;} - break; - - case 104: -#line 1736 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.StrVal) = 0; ;} - break; - - case 105: -#line 1737 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.StrVal) = (yyvsp[0].StrVal); ;} - break; - - case 106: -#line 1744 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - {;} - break; - - case 107: -#line 1745 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - {;} - break; - - case 108: -#line 1749 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - CurGV->setSection((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 109: -#line 1753 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) + yyval.StrVal = yyvsp[0].StrVal; + ; + break;} +case 103: +#line 1736 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.StrVal = 0; ; + break;} +case 104: +#line 1737 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.StrVal = yyvsp[0].StrVal; ; + break;} +case 105: +#line 1744 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{; + break;} +case 106: +#line 1745 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{; + break;} +case 107: +#line 1749 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + CurGV->setSection(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 108: +#line 1753 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) error("Alignment must be a power of two"); - CurGV->setAlignment((yyvsp[0].UInt64Val)); + CurGV->setAlignment(yyvsp[0].UInt64Val); - ;} - break; - - case 111: -#line 1770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); - (yyval.TypeVal).S = Signless; - ;} - break; - - case 113: -#line 1778 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); - (yyval.TypeVal).S = Signless; - ;} - break; - - case 114: -#line 1785 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + ; + break;} +case 110: +#line 1770 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); + yyval.TypeVal.S = Signless; + ; + break;} +case 112: +#line 1778 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); + yyval.TypeVal.S = Signless; + ; + break;} +case 113: +#line 1785 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ if (!UpRefs.empty()) - error("Invalid upreference in type: " + (*(yyvsp[0].TypeVal).PAT)->getDescription()); - (yyval.TypeVal) = (yyvsp[0].TypeVal); - ;} - break; - - case 127: -#line 1799 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[0].PrimType).T); - (yyval.TypeVal).S = (yyvsp[0].PrimType).S; - ;} - break; - - case 128: -#line 1803 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get()); - (yyval.TypeVal).S = Signless; - ;} - break; - - case 129: -#line 1807 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Named types are also simple types... - const Type* tmp = getType((yyvsp[0].ValIDVal)); - (yyval.TypeVal).PAT = new PATypeHolder(tmp); - (yyval.TypeVal).S = Signless; // FIXME: what if its signed? - ;} - break; - - case 130: -#line 1812 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Type UpReference - if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) + error("Invalid upreference in type: " + (*yyvsp[0].TypeVal.PAT)->getDescription()); + yyval.TypeVal = yyvsp[0].TypeVal; + ; + break;} +case 126: +#line 1799 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); + yyval.TypeVal.S = yyvsp[0].PrimType.S; + ; + break;} +case 127: +#line 1803 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeVal.PAT = new PATypeHolder(OpaqueType::get()); + yyval.TypeVal.S = Signless; + ; + break;} +case 128: +#line 1807 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Named types are also simple types... + const Type* tmp = getType(yyvsp[0].ValIDVal); + yyval.TypeVal.PAT = new PATypeHolder(tmp); + yyval.TypeVal.S = Signless; // FIXME: what if its signed? + ; + break;} +case 129: +#line 1812 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Type UpReference + if (yyvsp[0].UInt64Val > (uint64_t)~0U) error("Value out of range"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder - UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... - (yyval.TypeVal).PAT = new PATypeHolder(OT); - (yyval.TypeVal).S = Signless; + UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... + yyval.TypeVal.PAT = new PATypeHolder(OT); + yyval.TypeVal.S = Signless; UR_OUT("New Upreference!\n"); - ;} - break; - - case 131: -#line 1821 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Function derived type? + ; + break;} +case 130: +#line 1821 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Function derived type? std::vector Params; - for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), - E = (yyvsp[-1].TypeList)->end(); I != E; ++I) { + for (std::list::iterator I = yyvsp[-1].TypeList->begin(), + E = yyvsp[-1].TypeList->end(); I != E; ++I) { Params.push_back(I->PAT->get()); } FunctionType::ParamAttrsList ParamAttrs; bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); - (yyval.TypeVal).PAT = new PATypeHolder( - HandleUpRefs(FunctionType::get((yyvsp[-3].TypeVal).PAT->get(), Params, isVarArg, + yyval.TypeVal.PAT = new PATypeHolder( + HandleUpRefs(FunctionType::get(yyvsp[-3].TypeVal.PAT->get(), Params, isVarArg, ParamAttrs))); - (yyval.TypeVal).S = (yyvsp[-3].TypeVal).S; - delete (yyvsp[-3].TypeVal).PAT; // Delete the return type handle - delete (yyvsp[-1].TypeList); // Delete the argument list - ;} - break; - - case 132: -#line 1838 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Sized array type? - (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[-1].TypeVal).PAT->get(), - (unsigned)(yyvsp[-3].UInt64Val)))); - (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 133: -#line 1844 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Packed array type? - const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).PAT->get(); - if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) + yyval.TypeVal.S = yyvsp[-3].TypeVal.S; + delete yyvsp[-3].TypeVal.PAT; // Delete the return type handle + delete yyvsp[-1].TypeList; // Delete the argument list + ; + break;} +case 131: +#line 1838 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Sized array type? + yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get(yyvsp[-1].TypeVal.PAT->get(), + (unsigned)yyvsp[-3].UInt64Val))); + yyval.TypeVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 132: +#line 1844 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Vector type? + const llvm::Type* ElemTy = yyvsp[-1].TypeVal.PAT->get(); + if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) error("Unsigned result not equal to signed result"); if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) error("Elements of a VectorType must be integer or floating point"); - if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) + if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) error("VectorType length should be a power of 2"); - (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, - (unsigned)(yyvsp[-3].UInt64Val)))); - (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 134: -#line 1857 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Structure type? + yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, + (unsigned)yyvsp[-3].UInt64Val))); + yyval.TypeVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 133: +#line 1857 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Structure type? std::vector Elements; - for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), - E = (yyvsp[-1].TypeList)->end(); I != E; ++I) + for (std::list::iterator I = yyvsp[-1].TypeList->begin(), + E = yyvsp[-1].TypeList->end(); I != E; ++I) Elements.push_back(I->PAT->get()); - (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); - (yyval.TypeVal).S = Signless; - delete (yyvsp[-1].TypeList); - ;} - break; - - case 135: -#line 1866 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Empty structure type? - (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector())); - (yyval.TypeVal).S = Signless; - ;} - break; - - case 136: -#line 1870 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Packed Structure type? + yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); + yyval.TypeVal.S = Signless; + delete yyvsp[-1].TypeList; + ; + break;} +case 134: +#line 1866 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Empty structure type? + yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector())); + yyval.TypeVal.S = Signless; + ; + break;} +case 135: +#line 1870 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Packed Structure type? std::vector Elements; - for (std::list::iterator I = (yyvsp[-2].TypeList)->begin(), - E = (yyvsp[-2].TypeList)->end(); I != E; ++I) { + for (std::list::iterator I = yyvsp[-2].TypeList->begin(), + E = yyvsp[-2].TypeList->end(); I != E; ++I) { Elements.push_back(I->PAT->get()); delete I->PAT; } - (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); - (yyval.TypeVal).S = Signless; - delete (yyvsp[-2].TypeList); - ;} - break; - - case 137: -#line 1881 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Empty packed structure type? - (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector(),true)); - (yyval.TypeVal).S = Signless; - ;} - break; - - case 138: -#line 1885 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Pointer type? - if ((yyvsp[-1].TypeVal).PAT->get() == Type::LabelTy) + yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); + yyval.TypeVal.S = Signless; + delete yyvsp[-2].TypeList; + ; + break;} +case 136: +#line 1881 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Empty packed structure type? + yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector(),true)); + yyval.TypeVal.S = Signless; + ; + break;} +case 137: +#line 1885 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Pointer type? + if (yyvsp[-1].TypeVal.PAT->get() == Type::LabelTy) error("Cannot form a pointer to a basic block"); - (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).PAT->get()))); - (yyval.TypeVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 139: -#line 1898 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeList) = new std::list(); - (yyval.TypeList)->push_back((yyvsp[0].TypeVal)); - ;} - break; - - case 140: -#line 1902 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal)); - ;} - break; - - case 142: -#line 1910 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(PointerType::get(yyvsp[-1].TypeVal.PAT->get()))); + yyval.TypeVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 138: +#line 1898 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeList = new std::list(); + yyval.TypeList->push_back(yyvsp[0].TypeVal); + ; + break;} +case 139: +#line 1902 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal); + ; + break;} +case 141: +#line 1910 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ PATypeInfo VoidTI; VoidTI.PAT = new PATypeHolder(Type::VoidTy); VoidTI.S = Signless; - ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(VoidTI); - ;} - break; - - case 143: -#line 1916 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeList) = new std::list(); + (yyval.TypeList=yyvsp[-2].TypeList)->push_back(VoidTI); + ; + break;} +case 142: +#line 1916 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeList = new std::list(); PATypeInfo VoidTI; VoidTI.PAT = new PATypeHolder(Type::VoidTy); VoidTI.S = Signless; - (yyval.TypeList)->push_back(VoidTI); - ;} - break; - - case 144: -#line 1923 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TypeList) = new std::list(); - ;} - break; - - case 145: -#line 1935 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Nonempty unsized arr - const ArrayType *ATy = dyn_cast((yyvsp[-3].TypeVal).PAT->get()); + yyval.TypeList->push_back(VoidTI); + ; + break;} +case 143: +#line 1923 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TypeList = new std::list(); + ; + break;} +case 144: +#line 1935 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Nonempty unsized arr + const ArrayType *ATy = dyn_cast(yyvsp[-3].TypeVal.PAT->get()); if (ATy == 0) error("Cannot make array constant with type: '" + - (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); + yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); const Type *ETy = ATy->getElementType(); int NumElements = ATy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) + if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) error("Type mismatch: constant sized array initialized with " + - utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + + utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + itostr(NumElements) + ""); // Verify all elements are correct type! std::vector Elems; - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - Constant *C = (*(yyvsp[-1].ConstVector))[i].C; + for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { + Constant *C = (*yyvsp[-1].ConstVector)[i].C; const Type* ValTy = C->getType(); if (ETy != ValTy) error("Element #" + utostr(i) + " is not of type '" + @@ -4243,75 +3518,72 @@ ValTy->getDescription() + "'"); Elems.push_back(C); } - (yyval.ConstVal).C = ConstantArray::get(ATy, Elems); - (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S; - delete (yyvsp[-3].TypeVal).PAT; - delete (yyvsp[-1].ConstVector); - ;} - break; - - case 146: -#line 1965 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantArray::get(ATy, Elems); + yyval.ConstVal.S = yyvsp[-3].TypeVal.S; + delete yyvsp[-3].TypeVal.PAT; + delete yyvsp[-1].ConstVector; + ; + break;} +case 145: +#line 1965 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const ArrayType *ATy = dyn_cast(yyvsp[-2].TypeVal.PAT->get()); if (ATy == 0) error("Cannot make array constant with type: '" + - (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); + yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); int NumElements = ATy->getNumElements(); if (NumElements != -1 && NumElements != 0) error("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +""); - (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector()); - (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S; - delete (yyvsp[-2].TypeVal).PAT; - ;} - break; - - case 147: -#line 1978 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantArray::get(ATy, std::vector()); + yyval.ConstVal.S = yyvsp[-2].TypeVal.S; + delete yyvsp[-2].TypeVal.PAT; + ; + break;} +case 146: +#line 1978 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const ArrayType *ATy = dyn_cast(yyvsp[-2].TypeVal.PAT->get()); if (ATy == 0) error("Cannot make array constant with type: '" + - (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); + yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); int NumElements = ATy->getNumElements(); const Type *ETy = dyn_cast(ATy->getElementType()); if (!ETy || cast(ETy)->getBitWidth() != 8) error("String arrays require type i8, not '" + ETy->getDescription() + "'"); - char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); - if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) + char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); + if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) error("Can't build string constant of size " + - itostr((int)(EndStr-(yyvsp[0].StrVal))) + " when array has size " + + itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + itostr(NumElements) + ""); std::vector Vals; - for (char *C = (char *)(yyvsp[0].StrVal); C != (char *)EndStr; ++C) + for (char *C = (char *)yyvsp[0].StrVal; C != (char *)EndStr; ++C) Vals.push_back(ConstantInt::get(ETy, *C)); - free((yyvsp[0].StrVal)); - (yyval.ConstVal).C = ConstantArray::get(ATy, Vals); - (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S; - delete (yyvsp[-2].TypeVal).PAT; - ;} - break; - - case 148: -#line 2001 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Nonempty unsized arr - const VectorType *PTy = dyn_cast((yyvsp[-3].TypeVal).PAT->get()); + free(yyvsp[0].StrVal); + yyval.ConstVal.C = ConstantArray::get(ATy, Vals); + yyval.ConstVal.S = yyvsp[-2].TypeVal.S; + delete yyvsp[-2].TypeVal.PAT; + ; + break;} +case 147: +#line 2001 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Nonempty unsized arr + const VectorType *PTy = dyn_cast(yyvsp[-3].TypeVal.PAT->get()); if (PTy == 0) error("Cannot make packed constant with type: '" + - (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); + yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); const Type *ETy = PTy->getElementType(); int NumElements = PTy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) + if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) error("Type mismatch: constant sized packed initialized with " + - utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + + utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + itostr(NumElements) + ""); // Verify all elements are correct type! std::vector Elems; - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - Constant *C = (*(yyvsp[-1].ConstVector))[i].C; + for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { + Constant *C = (*yyvsp[-1].ConstVector)[i].C; const Type* ValTy = C->getType(); if (ETy != ValTy) error("Element #" + utostr(i) + " is not of type '" + @@ -4319,124 +3591,117 @@ ValTy->getDescription() + "'"); Elems.push_back(C); } - (yyval.ConstVal).C = ConstantVector::get(PTy, Elems); - (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S; - delete (yyvsp[-3].TypeVal).PAT; - delete (yyvsp[-1].ConstVector); - ;} - break; - - case 149: -#line 2029 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const StructType *STy = dyn_cast((yyvsp[-3].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantVector::get(PTy, Elems); + yyval.ConstVal.S = yyvsp[-3].TypeVal.S; + delete yyvsp[-3].TypeVal.PAT; + delete yyvsp[-1].ConstVector; + ; + break;} +case 148: +#line 2029 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const StructType *STy = dyn_cast(yyvsp[-3].TypeVal.PAT->get()); if (STy == 0) error("Cannot make struct constant with type: '" + - (yyvsp[-3].TypeVal).PAT->get()->getDescription() + "'"); - if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) + yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); + if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) error("Illegal number of initializers for structure type"); // Check to ensure that constants are compatible with the type initializer! std::vector Fields; - for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) { - Constant *C = (*(yyvsp[-1].ConstVector))[i].C; + for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) { + Constant *C = (*yyvsp[-1].ConstVector)[i].C; if (C->getType() != STy->getElementType(i)) error("Expected type '" + STy->getElementType(i)->getDescription() + "' for element #" + utostr(i) + " of structure initializer"); Fields.push_back(C); } - (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); - (yyval.ConstVal).S = (yyvsp[-3].TypeVal).S; - delete (yyvsp[-3].TypeVal).PAT; - delete (yyvsp[-1].ConstVector); - ;} - break; - - case 150: -#line 2051 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const StructType *STy = dyn_cast((yyvsp[-2].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantStruct::get(STy, Fields); + yyval.ConstVal.S = yyvsp[-3].TypeVal.S; + delete yyvsp[-3].TypeVal.PAT; + delete yyvsp[-1].ConstVector; + ; + break;} +case 149: +#line 2051 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const StructType *STy = dyn_cast(yyvsp[-2].TypeVal.PAT->get()); if (STy == 0) error("Cannot make struct constant with type: '" + - (yyvsp[-2].TypeVal).PAT->get()->getDescription() + "'"); + yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); if (STy->getNumContainedTypes() != 0) error("Illegal number of initializers for structure type"); - (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector()); - (yyval.ConstVal).S = (yyvsp[-2].TypeVal).S; - delete (yyvsp[-2].TypeVal).PAT; - ;} - break; - - case 151: -#line 2062 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const StructType *STy = dyn_cast((yyvsp[-5].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantStruct::get(STy, std::vector()); + yyval.ConstVal.S = yyvsp[-2].TypeVal.S; + delete yyvsp[-2].TypeVal.PAT; + ; + break;} +case 150: +#line 2062 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const StructType *STy = dyn_cast(yyvsp[-5].TypeVal.PAT->get()); if (STy == 0) error("Cannot make packed struct constant with type: '" + - (yyvsp[-5].TypeVal).PAT->get()->getDescription() + "'"); - if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) + yyvsp[-5].TypeVal.PAT->get()->getDescription() + "'"); + if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) error("Illegal number of initializers for packed structure type"); // Check to ensure that constants are compatible with the type initializer! std::vector Fields; - for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) { - Constant *C = (*(yyvsp[-2].ConstVector))[i].C; + for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) { + Constant *C = (*yyvsp[-2].ConstVector)[i].C; if (C->getType() != STy->getElementType(i)) error("Expected type '" + STy->getElementType(i)->getDescription() + "' for element #" + utostr(i) + " of packed struct initializer"); Fields.push_back(C); } - (yyval.ConstVal).C = ConstantStruct::get(STy, Fields); - (yyval.ConstVal).S = (yyvsp[-5].TypeVal).S; - delete (yyvsp[-5].TypeVal).PAT; - delete (yyvsp[-2].ConstVector); - ;} - break; - - case 152: -#line 2084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const StructType *STy = dyn_cast((yyvsp[-4].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantStruct::get(STy, Fields); + yyval.ConstVal.S = yyvsp[-5].TypeVal.S; + delete yyvsp[-5].TypeVal.PAT; + delete yyvsp[-2].ConstVector; + ; + break;} +case 151: +#line 2084 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const StructType *STy = dyn_cast(yyvsp[-4].TypeVal.PAT->get()); if (STy == 0) error("Cannot make packed struct constant with type: '" + - (yyvsp[-4].TypeVal).PAT->get()->getDescription() + "'"); + yyvsp[-4].TypeVal.PAT->get()->getDescription() + "'"); if (STy->getNumContainedTypes() != 0) error("Illegal number of initializers for packed structure type"); - (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector()); - (yyval.ConstVal).S = (yyvsp[-4].TypeVal).S; - delete (yyvsp[-4].TypeVal).PAT; - ;} - break; - - case 153: -#line 2095 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const PointerType *PTy = dyn_cast((yyvsp[-1].TypeVal).PAT->get()); + yyval.ConstVal.C = ConstantStruct::get(STy, std::vector()); + yyval.ConstVal.S = yyvsp[-4].TypeVal.S; + delete yyvsp[-4].TypeVal.PAT; + ; + break;} +case 152: +#line 2095 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const PointerType *PTy = dyn_cast(yyvsp[-1].TypeVal.PAT->get()); if (PTy == 0) error("Cannot make null pointer constant with type: '" + - (yyvsp[-1].TypeVal).PAT->get()->getDescription() + "'"); - (yyval.ConstVal).C = ConstantPointerNull::get(PTy); - (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 154: -#line 2104 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ConstVal).C = UndefValue::get((yyvsp[-1].TypeVal).PAT->get()); - (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 155: -#line 2109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const PointerType *Ty = dyn_cast((yyvsp[-1].TypeVal).PAT->get()); + yyvsp[-1].TypeVal.PAT->get()->getDescription() + "'"); + yyval.ConstVal.C = ConstantPointerNull::get(PTy); + yyval.ConstVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 153: +#line 2104 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ConstVal.C = UndefValue::get(yyvsp[-1].TypeVal.PAT->get()); + yyval.ConstVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 154: +#line 2109 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const PointerType *Ty = dyn_cast(yyvsp[-1].TypeVal.PAT->get()); if (Ty == 0) error("Global const reference must be a pointer type, not" + - (yyvsp[-1].TypeVal).PAT->get()->getDescription()); + yyvsp[-1].TypeVal.PAT->get()->getDescription()); // ConstExprs can exist in the body of a function, thus creating // GlobalValues whenever they refer to a variable. Because we are in @@ -4447,7 +3712,7 @@ // Function *SavedCurFn = CurFun.CurrentFunction; CurFun.CurrentFunction = 0; - Value *V = getExistingValue(Ty, (yyvsp[0].ValIDVal)); + Value *V = getExistingValue(Ty, yyvsp[0].ValIDVal); CurFun.CurrentFunction = SavedCurFn; // If this is an initializer for a constant pointer, which is referencing a @@ -4460,14 +3725,14 @@ // First check to see if the forward references value is already created! PerModuleInfo::GlobalRefsType::iterator I = - CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); + CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); if (I != CurModule.GlobalRefs.end()) { V = I->second; // Placeholder already exists, use it... - (yyvsp[0].ValIDVal).destroy(); + yyvsp[0].ValIDVal.destroy(); } else { std::string Name; - if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; + if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; // Create the forward referenced global. GlobalValue *GV; @@ -4482,152 +3747,141 @@ } // Keep track of the fact that we have a forward ref to recycle it - CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); + CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); V = GV; } } - (yyval.ConstVal).C = cast(V); - (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; // Free the type handle - ;} - break; - - case 156: -#line 2167 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[-1].TypeVal).PAT->get() != (yyvsp[0].ConstVal).C->getType()) + yyval.ConstVal.C = cast(V); + yyval.ConstVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; // Free the type handle + ; + break;} +case 155: +#line 2167 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[-1].TypeVal.PAT->get() != yyvsp[0].ConstVal.C->getType()) error("Mismatched types for constant expression"); - (yyval.ConstVal) = (yyvsp[0].ConstVal); - (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 157: -#line 2174 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); + yyval.ConstVal = yyvsp[0].ConstVal; + yyval.ConstVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 156: +#line 2174 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); if (isa(Ty) || Ty == Type::LabelTy || isa(Ty)) error("Cannot create a null initialized value of this type"); - (yyval.ConstVal).C = Constant::getNullValue(Ty); - (yyval.ConstVal).S = (yyvsp[-1].TypeVal).S; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 158: -#line 2182 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // integral constants - const Type *Ty = (yyvsp[-1].PrimType).T; - if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].SInt64Val))) + yyval.ConstVal.C = Constant::getNullValue(Ty); + yyval.ConstVal.S = yyvsp[-1].TypeVal.S; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 157: +#line 2182 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // integral constants + const Type *Ty = yyvsp[-1].PrimType.T; + if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].SInt64Val)) error("Constant value doesn't fit in type"); - (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].SInt64Val)); - (yyval.ConstVal).S = Signed; - ;} - break; - - case 159: -#line 2189 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // integral constants - const Type *Ty = (yyvsp[-1].PrimType).T; - if (!ConstantInt::isValueValidForType(Ty, (yyvsp[0].UInt64Val))) + yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].SInt64Val); + yyval.ConstVal.S = Signed; + ; + break;} +case 158: +#line 2189 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // integral constants + const Type *Ty = yyvsp[-1].PrimType.T; + if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].UInt64Val)) error("Constant value doesn't fit in type"); - (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[0].UInt64Val)); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 160: -#line 2196 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Boolean constants - (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 161: -#line 2200 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Boolean constants - (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 162: -#line 2204 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Float & Double constants - if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal))) + yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].UInt64Val); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 159: +#line 2196 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Boolean constants + yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, true); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 160: +#line 2200 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Boolean constants + yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, false); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 161: +#line 2204 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Float & Double constants + if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType.T, yyvsp[0].FPVal)) error("Floating point constant invalid for type"); - (yyval.ConstVal).C = ConstantFP::get((yyvsp[-1].PrimType).T, (yyvsp[0].FPVal)); - (yyval.ConstVal).S = Signless; - ;} - break; - - case 163: -#line 2213 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* SrcTy = (yyvsp[-3].ConstVal).C->getType(); - const Type* DstTy = (yyvsp[-1].TypeVal).PAT->get(); - Signedness SrcSign = (yyvsp[-3].ConstVal).S; - Signedness DstSign = (yyvsp[-1].TypeVal).S; + yyval.ConstVal.C = ConstantFP::get(yyvsp[-1].PrimType.T, yyvsp[0].FPVal); + yyval.ConstVal.S = Signless; + ; + break;} +case 162: +#line 2213 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* SrcTy = yyvsp[-3].ConstVal.C->getType(); + const Type* DstTy = yyvsp[-1].TypeVal.PAT->get(); + Signedness SrcSign = yyvsp[-3].ConstVal.S; + Signedness DstSign = yyvsp[-1].TypeVal.S; if (!SrcTy->isFirstClassType()) error("cast constant expression from a non-primitive type: '" + SrcTy->getDescription() + "'"); if (!DstTy->isFirstClassType()) error("cast constant expression to a non-primitive type: '" + DstTy->getDescription() + "'"); - (yyval.ConstVal).C = cast(getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal).C, SrcSign, DstTy, DstSign)); - (yyval.ConstVal).S = DstSign; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 164: -#line 2228 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-2].ConstVal).C->getType(); + yyval.ConstVal.C = cast(getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal.C, SrcSign, DstTy, DstSign)); + yyval.ConstVal.S = DstSign; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 163: +#line 2228 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-2].ConstVal.C->getType(); if (!isa(Ty)) error("GetElementPtr requires a pointer operand"); std::vector VIndices; std::vector CIndices; - upgradeGEPIndices((yyvsp[-2].ConstVal).C->getType(), (yyvsp[-1].ValueList), VIndices, &CIndices); + upgradeGEPIndices(yyvsp[-2].ConstVal.C->getType(), yyvsp[-1].ValueList, VIndices, &CIndices); - delete (yyvsp[-1].ValueList); - (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal).C, CIndices); - (yyval.ConstVal).S = Signless; - ;} - break; - - case 165: -#line 2241 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!(yyvsp[-5].ConstVal).C->getType()->isInteger() || - cast((yyvsp[-5].ConstVal).C->getType())->getBitWidth() != 1) + delete yyvsp[-1].ValueList; + yyval.ConstVal.C = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal.C, &CIndices[0], CIndices.size()); + yyval.ConstVal.S = Signless; + ; + break;} +case 164: +#line 2241 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!yyvsp[-5].ConstVal.C->getType()->isInteger() || + cast(yyvsp[-5].ConstVal.C->getType())->getBitWidth() != 1) error("Select condition must be bool type"); - if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) + if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) error("Select operand types must match"); - (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 166: -#line 2250 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-3].ConstVal).C->getType(); - if (Ty != (yyvsp[-1].ConstVal).C->getType()) + yyval.ConstVal.C = ConstantExpr::getSelect(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 165: +#line 2250 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-3].ConstVal.C->getType(); + if (Ty != yyvsp[-1].ConstVal.C->getType()) error("Binary operator types must match"); // First, make sure we're dealing with the right opcode by upgrading from // obsolete versions. - Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); + Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. // To retain backward compatibility with these early compilers, we emit a // cast to the appropriate integer type automatically if we are in the // broken case. See PR424 for more information. if (!isa(Ty)) { - (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); + yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); } else { const Type *IntPtrTy = 0; switch (CurModule.CurrentModule->getPointerSize()) { @@ -4635,165 +3889,147 @@ case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; default: error("invalid pointer binary constant expr"); } - (yyval.ConstVal).C = ConstantExpr::get(Opcode, - ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-3].ConstVal).C, IntPtrTy), - ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[-1].ConstVal).C, IntPtrTy)); - (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty); - } - (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S; - ;} - break; - - case 167: -#line 2278 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); - if (Ty != (yyvsp[-1].ConstVal).C->getType()) + yyval.ConstVal.C = ConstantExpr::get(Opcode, + ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-3].ConstVal.C, IntPtrTy), + ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-1].ConstVal.C, IntPtrTy)); + yyval.ConstVal.C = ConstantExpr::getCast(Instruction::IntToPtr, yyval.ConstVal.C, Ty); + } + yyval.ConstVal.S = yyvsp[-3].ConstVal.S; + ; + break;} +case 166: +#line 2278 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* Ty = yyvsp[-3].ConstVal.C->getType(); + if (Ty != yyvsp[-1].ConstVal.C->getType()) error("Logical operator types must match"); if (!Ty->isInteger()) { if (!isa(Ty) || !cast(Ty)->getElementType()->isInteger()) error("Logical operator requires integer operands"); } - Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S); - (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S; - ;} - break; - - case 168: -#line 2291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); - if (Ty != (yyvsp[-1].ConstVal).C->getType()) + Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); + yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = yyvsp[-3].ConstVal.S; + ; + break;} +case 167: +#line 2291 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* Ty = yyvsp[-3].ConstVal.C->getType(); + if (Ty != yyvsp[-1].ConstVal.C->getType()) error("setcc operand types must match"); unsigned short pred; - Instruction::OtherOps Opcode = getCompareOp((yyvsp[-5].BinaryOpVal), pred, Ty, (yyvsp[-3].ConstVal).S); - (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 169: -#line 2300 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) + Instruction::OtherOps Opcode = getCompareOp(yyvsp[-5].BinaryOpVal, pred, Ty, yyvsp[-3].ConstVal.S); + yyval.ConstVal.C = ConstantExpr::getCompare(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 168: +#line 2300 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) error("icmp operand types must match"); - (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].IPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 170: -#line 2306 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[-3].ConstVal).C->getType() != (yyvsp[-1].ConstVal).C->getType()) + yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].IPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 169: +#line 2306 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) error("fcmp operand types must match"); - (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[-5].FPred), (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = Unsigned; - ;} - break; - - case 171: -#line 2312 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!(yyvsp[-1].ConstVal).C->getType()->isInteger() || - cast((yyvsp[-1].ConstVal).C->getType())->getBitWidth() != 8) + yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].FPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = Unsigned; + ; + break;} +case 170: +#line 2312 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!yyvsp[-1].ConstVal.C->getType()->isInteger() || + cast(yyvsp[-1].ConstVal.C->getType())->getBitWidth() != 8) error("Shift count for shift constant must be unsigned byte"); - const Type* Ty = (yyvsp[-3].ConstVal).C->getType(); - if (!(yyvsp[-3].ConstVal).C->getType()->isInteger()) + const Type* Ty = yyvsp[-3].ConstVal.C->getType(); + if (!yyvsp[-3].ConstVal.C->getType()->isInteger()) error("Shift constant expression requires integer operand"); - Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[-1].ConstVal).C, Ty); - (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[-5].BinaryOpVal), Ty, (yyvsp[-3].ConstVal).S), (yyvsp[-3].ConstVal).C, ShiftAmt); - (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S; - ;} - break; - - case 172: -#line 2323 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) + Constant *ShiftAmt = ConstantExpr::getZExt(yyvsp[-1].ConstVal.C, Ty); + yyval.ConstVal.C = ConstantExpr::get(getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S), yyvsp[-3].ConstVal.C, ShiftAmt); + yyval.ConstVal.S = yyvsp[-3].ConstVal.S; + ; + break;} +case 171: +#line 2323 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) error("Invalid extractelement operands"); - (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = (yyvsp[-3].ConstVal).S; - ;} - break; - - case 173: -#line 2329 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) + yyval.ConstVal.C = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = yyvsp[-3].ConstVal.S; + ; + break;} +case 172: +#line 2329 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) error("Invalid insertelement operands"); - (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S; - ;} - break; - - case 174: -#line 2335 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C)) + yyval.ConstVal.C = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = yyvsp[-5].ConstVal.S; + ; + break;} +case 173: +#line 2335 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) error("Invalid shufflevector operands"); - (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal).C, (yyvsp[-3].ConstVal).C, (yyvsp[-1].ConstVal).C); - (yyval.ConstVal).S = (yyvsp[-5].ConstVal).S; - ;} - break; - - case 175: -#line 2346 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); ;} - break; - - case 176: -#line 2347 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ConstVector) = new std::vector(); - (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); - ;} - break; - - case 177: -#line 2356 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.BoolVal) = false; ;} - break; - - case 178: -#line 2357 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.BoolVal) = true; ;} - break; - - case 179: -#line 2369 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); + yyval.ConstVal.C = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); + yyval.ConstVal.S = yyvsp[-5].ConstVal.S; + ; + break;} +case 174: +#line 2346 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); ; + break;} +case 175: +#line 2347 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ConstVector = new std::vector(); + yyval.ConstVector->push_back(yyvsp[0].ConstVal); + ; + break;} +case 176: +#line 2356 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.BoolVal = false; ; + break;} +case 177: +#line 2357 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.BoolVal = true; ; + break;} +case 178: +#line 2369 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; CurModule.ModuleDone(); - ;} - break; - - case 180: -#line 2378 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); ;} - break; - - case 181: -#line 2379 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} - break; - - case 182: -#line 2380 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); ;} - break; - - case 183: -#line 2381 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); ;} - break; - - case 184: -#line 2382 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ModuleVal) = CurModule.CurrentModule; + ; + break;} +case 179: +#line 2378 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ModuleVal = yyvsp[-1].ModuleVal; CurFun.FunctionDone(); ; + break;} +case 180: +#line 2379 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ModuleVal = yyvsp[-1].ModuleVal; ; + break;} +case 181: +#line 2380 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ModuleVal = yyvsp[-3].ModuleVal; ; + break;} +case 182: +#line 2381 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ModuleVal = yyvsp[-1].ModuleVal; ; + break;} +case 183: +#line 2382 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ModuleVal = CurModule.CurrentModule; // Emit an error if there are any unresolved types left. if (!CurModule.LateResolveTypes.empty()) { const ValID &DID = CurModule.LateResolveTypes.begin()->first; @@ -4803,12 +4039,11 @@ error("Reference to an undefined type: #" + itostr(DID.Num)); } } - ;} - break; - - case 185: -#line 2398 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + ; + break;} +case 184: +#line 2398 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Eagerly resolve types. This is not an optimization, this is a // requirement that is due to the fact that we could have this: // @@ -4818,266 +4053,234 @@ // If types are not resolved eagerly, then the two types will not be // determined to be the same type! // - const Type* Ty = (yyvsp[0].TypeVal).PAT->get(); - ResolveTypeTo((yyvsp[-2].StrVal), Ty); + const Type* Ty = yyvsp[0].TypeVal.PAT->get(); + ResolveTypeTo(yyvsp[-2].StrVal, Ty); - if (!setTypeName(Ty, (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { + if (!setTypeName(Ty, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { // If this is a named type that is not a redefinition, add it to the slot // table. CurModule.Types.push_back(Ty); } - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 186: -#line 2418 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Function prototypes can be in const pool - ;} - break; - - case 187: -#line 2420 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Asm blocks can be in the const pool - ;} - break; - - case 188: -#line 2422 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[0].ConstVal).C == 0) + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 185: +#line 2418 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Function prototypes can be in const pool + ; + break;} +case 186: +#line 2420 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Asm blocks can be in the const pool + ; + break;} +case 187: +#line 2422 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[0].ConstVal.C == 0) error("Global value initializer is not a constant"); - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal).C->getType(), (yyvsp[0].ConstVal).C); - ;} - break; - - case 189: -#line 2426 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal.C->getType(), yyvsp[0].ConstVal.C); + ; + break;} +case 188: +#line 2426 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ CurGV = 0; - ;} - break; - - case 190: -#line 2429 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), Ty, 0); - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 191: -#line 2433 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + ; + break;} +case 189: +#line 2429 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[0].TypeVal.PAT->get(); + CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, Ty, 0); + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 190: +#line 2433 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ CurGV = 0; - ;} - break; - - case 192: -#line 2436 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), Ty, 0); - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 193: -#line 2440 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + ; + break;} +case 191: +#line 2436 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[0].TypeVal.PAT->get(); + CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, Ty, 0); + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 192: +#line 2440 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ CurGV = 0; - ;} - break; - - case 194: -#line 2443 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); + ; + break;} +case 193: +#line 2443 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[0].TypeVal.PAT->get(); CurGV = - ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), Ty, 0); - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 195: -#line 2448 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, Ty, 0); + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 194: +#line 2448 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ CurGV = 0; - ;} - break; - - case 196: -#line 2451 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - ;} - break; - - case 197: -#line 2453 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - ;} - break; - - case 198: -#line 2455 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - ;} - break; - - case 199: -#line 2460 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + ; + break;} +case 195: +#line 2451 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + ; + break;} +case 196: +#line 2453 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + ; + break;} +case 197: +#line 2455 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + ; + break;} +case 198: +#line 2460 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); - char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); - std::string NewAsm((yyvsp[0].StrVal), EndStr); - free((yyvsp[0].StrVal)); + char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); + std::string NewAsm(yyvsp[0].StrVal, EndStr); + free(yyvsp[0].StrVal); if (AsmSoFar.empty()) CurModule.CurrentModule->setModuleInlineAsm(NewAsm); else CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); - ;} - break; - - case 200: -#line 2474 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Endianness) = Module::BigEndian; ;} - break; - - case 201: -#line 2475 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Endianness) = Module::LittleEndian; ;} - break; - - case 202: -#line 2479 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - CurModule.setEndianness((yyvsp[0].Endianness)); - ;} - break; - - case 203: -#line 2482 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[0].UInt64Val) == 32) + ; + break;} +case 199: +#line 2474 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Endianness = Module::BigEndian; ; + break;} +case 200: +#line 2475 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Endianness = Module::LittleEndian; ; + break;} +case 201: +#line 2479 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + CurModule.setEndianness(yyvsp[0].Endianness); + ; + break;} +case 202: +#line 2482 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[0].UInt64Val == 32) CurModule.setPointerSize(Module::Pointer32); - else if ((yyvsp[0].UInt64Val) == 64) + else if (yyvsp[0].UInt64Val == 64) CurModule.setPointerSize(Module::Pointer64); else - error("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'"); - ;} - break; - - case 204: -#line 2490 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 205: -#line 2494 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 207: -#line 2505 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 208: -#line 2509 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 209: -#line 2513 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { ;} - break; - - case 213: -#line 2526 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.StrVal) = 0; ;} - break; - - case 214: -#line 2530 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[-1].TypeVal).PAT->get() == Type::VoidTy) + error("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'"); + ; + break;} +case 203: +#line 2490 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 204: +#line 2494 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 206: +#line 2505 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 207: +#line 2509 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 208: +#line 2513 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ ; + break;} +case 212: +#line 2526 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.StrVal = 0; ; + break;} +case 213: +#line 2530 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[-1].TypeVal.PAT->get() == Type::VoidTy) error("void typed arguments are invalid"); - (yyval.ArgVal) = new std::pair((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); - ;} - break; - - case 215: -#line 2538 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ArgList) = (yyvsp[-2].ArgList); - (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); - delete (yyvsp[0].ArgVal); - ;} - break; - - case 216: -#line 2543 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ArgList) = new std::vector >(); - (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); - delete (yyvsp[0].ArgVal); - ;} - break; - - case 217: -#line 2551 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ArgList) = (yyvsp[0].ArgList); ;} - break; - - case 218: -#line 2552 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ArgList) = (yyvsp[-2].ArgList); + yyval.ArgVal = new std::pair(yyvsp[-1].TypeVal, yyvsp[0].StrVal); + ; + break;} +case 214: +#line 2538 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ArgList = yyvsp[-2].ArgList; + yyval.ArgList->push_back(*yyvsp[0].ArgVal); + delete yyvsp[0].ArgVal; + ; + break;} +case 215: +#line 2543 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ArgList = new std::vector >(); + yyval.ArgList->push_back(*yyvsp[0].ArgVal); + delete yyvsp[0].ArgVal; + ; + break;} +case 216: +#line 2551 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ArgList = yyvsp[0].ArgList; ; + break;} +case 217: +#line 2552 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ArgList = yyvsp[-2].ArgList; PATypeInfo VoidTI; VoidTI.PAT = new PATypeHolder(Type::VoidTy); VoidTI.S = Signless; - (yyval.ArgList)->push_back(std::pair(VoidTI, 0)); - ;} - break; - - case 219: -#line 2559 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ArgList) = new std::vector >(); + yyval.ArgList->push_back(std::pair(VoidTI, 0)); + ; + break;} +case 218: +#line 2559 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ArgList = new std::vector >(); PATypeInfo VoidTI; VoidTI.PAT = new PATypeHolder(Type::VoidTy); VoidTI.S = Signless; - (yyval.ArgList)->push_back(std::pair(VoidTI, 0)); - ;} - break; - - case 220: -#line 2566 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ArgList) = 0; ;} - break; - - case 221: -#line 2570 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - UnEscapeLexed((yyvsp[-5].StrVal)); - std::string FunctionName((yyvsp[-5].StrVal)); - free((yyvsp[-5].StrVal)); // Free strdup'd memory! + yyval.ArgList->push_back(std::pair(VoidTI, 0)); + ; + break;} +case 219: +#line 2566 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ArgList = 0; ; + break;} +case 220: +#line 2570 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + UnEscapeLexed(yyvsp[-5].StrVal); + std::string FunctionName(yyvsp[-5].StrVal); + free(yyvsp[-5].StrVal); // Free strdup'd memory! - const Type* RetTy = (yyvsp[-6].TypeVal).PAT->get(); + const Type* RetTy = yyvsp[-6].TypeVal.PAT->get(); if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) error("LLVM functions cannot return aggregate types"); @@ -5092,9 +4295,9 @@ } else if (FunctionName == "llvm.va_copy") { ParamTyList.push_back(PointerType::get(Type::Int8Ty)); ParamTyList.push_back(PointerType::get(Type::Int8Ty)); - } else if ((yyvsp[-3].ArgList)) { // If there are arguments... + } else if (yyvsp[-3].ArgList) { // If there are arguments... for (std::vector >::iterator - I = (yyvsp[-3].ArgList)->begin(), E = (yyvsp[-3].ArgList)->end(); I != E; ++I) { + I = yyvsp[-3].ArgList->begin(), E = yyvsp[-3].ArgList->end(); I != E; ++I) { const Type *Ty = I->first.PAT->get(); ParamTyList.push_back(Ty); } @@ -5107,7 +4310,7 @@ // Convert the CSRet calling convention into the corresponding parameter // attribute. FunctionType::ParamAttrsList ParamAttrs; - if ((yyvsp[-7].UIntVal) == OldCallingConv::CSRet) { + if (yyvsp[-7].UIntVal == OldCallingConv::CSRet) { ParamAttrs.push_back(FunctionType::NoAttributeSet); // result ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg } @@ -5115,7 +4318,7 @@ const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg, ParamAttrs); const PointerType *PFT = PointerType::get(FT); - delete (yyvsp[-6].TypeVal).PAT; + delete yyvsp[-6].TypeVal.PAT; ValID ID; if (!FunctionName.empty()) { @@ -5218,362 +4421,325 @@ // argument to another function. Fn->setLinkage(CurFun.Linkage); } - Fn->setCallingConv(upgradeCallingConv((yyvsp[-7].UIntVal))); - Fn->setAlignment((yyvsp[0].UIntVal)); - if ((yyvsp[-1].StrVal)) { - Fn->setSection((yyvsp[-1].StrVal)); - free((yyvsp[-1].StrVal)); + Fn->setCallingConv(upgradeCallingConv(yyvsp[-7].UIntVal)); + Fn->setAlignment(yyvsp[0].UIntVal); + if (yyvsp[-1].StrVal) { + Fn->setSection(yyvsp[-1].StrVal); + free(yyvsp[-1].StrVal); } // Add all of the arguments we parsed to the function... - if ((yyvsp[-3].ArgList)) { // Is null if empty... + if (yyvsp[-3].ArgList) { // Is null if empty... if (isVarArg) { // Nuke the last entry - assert((yyvsp[-3].ArgList)->back().first.PAT->get() == Type::VoidTy && - (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker"); - delete (yyvsp[-3].ArgList)->back().first.PAT; - (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry + assert(yyvsp[-3].ArgList->back().first.PAT->get() == Type::VoidTy && + yyvsp[-3].ArgList->back().second == 0 && "Not a varargs marker"); + delete yyvsp[-3].ArgList->back().first.PAT; + yyvsp[-3].ArgList->pop_back(); // Delete the last entry } Function::arg_iterator ArgIt = Fn->arg_begin(); Function::arg_iterator ArgEnd = Fn->arg_end(); - std::vector >::iterator I = (yyvsp[-3].ArgList)->begin(); - std::vector >::iterator E = (yyvsp[-3].ArgList)->end(); + std::vector >::iterator I = yyvsp[-3].ArgList->begin(); + std::vector >::iterator E = yyvsp[-3].ArgList->end(); for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { delete I->first.PAT; // Delete the typeholder... setValueName(ArgIt, I->second); // Insert arg into symtab... InsertValue(ArgIt); } - delete (yyvsp[-3].ArgList); // We're now done with the argument list + delete yyvsp[-3].ArgList; // We're now done with the argument list } - ;} - break; - - case 224: -#line 2750 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.FunctionVal) = CurFun.CurrentFunction; + ; + break;} +case 223: +#line 2750 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.FunctionVal = CurFun.CurrentFunction; // Make sure that we keep track of the linkage type even if there was a // previous "declare". - (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage)); - ;} - break; - - case 227: -#line 2764 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); - ;} - break; - - case 228: -#line 2769 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} - break; - - case 229: -#line 2770 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} - break; - - case 230: -#line 2771 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} - break; - - case 231: -#line 2775 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { CurFun.isDeclare = true; ;} - break; - - case 232: -#line 2776 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { CurFun.Linkage = (yyvsp[0].Linkage); ;} - break; - - case 233: -#line 2776 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.FunctionVal) = CurFun.CurrentFunction; + yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage); + ; + break;} +case 226: +#line 2764 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.FunctionVal = yyvsp[-1].FunctionVal; + ; + break;} +case 227: +#line 2769 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::ExternalLinkage; ; + break;} +case 228: +#line 2770 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::DLLImportLinkage; ; + break;} +case 229: +#line 2771 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; + break;} +case 230: +#line 2775 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ CurFun.isDeclare = true; ; + break;} +case 231: +#line 2776 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ CurFun.Linkage = yyvsp[0].Linkage; ; + break;} +case 232: +#line 2776 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.FunctionVal = CurFun.CurrentFunction; CurFun.FunctionDone(); - ;} - break; - - case 234: -#line 2788 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.BoolVal) = false; ;} - break; - - case 235: -#line 2789 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.BoolVal) = true; ;} - break; - - case 236: -#line 2794 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); ;} - break; - - case 237: -#line 2795 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); ;} - break; - - case 238: -#line 2796 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); ;} - break; - - case 239: -#line 2797 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ;} - break; - - case 240: -#line 2798 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ;} - break; - - case 241: -#line 2799 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::createNull(); ;} - break; - - case 242: -#line 2800 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::createUndef(); ;} - break; - - case 243: -#line 2801 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::createZeroInit(); ;} - break; - - case 244: -#line 2802 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Nonempty unsized packed vector - const Type *ETy = (*(yyvsp[-1].ConstVector))[0].C->getType(); - int NumElements = (yyvsp[-1].ConstVector)->size(); + ; + break;} +case 233: +#line 2788 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.BoolVal = false; ; + break;} +case 234: +#line 2789 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.BoolVal = true; ; + break;} +case 235: +#line 2794 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); ; + break;} +case 236: +#line 2795 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); ; + break;} +case 237: +#line 2796 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); ; + break;} +case 238: +#line 2797 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ; + break;} +case 239: +#line 2798 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ; + break;} +case 240: +#line 2799 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::createNull(); ; + break;} +case 241: +#line 2800 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::createUndef(); ; + break;} +case 242: +#line 2801 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::createZeroInit(); ; + break;} +case 243: +#line 2802 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Nonempty unsized packed vector + const Type *ETy = (*yyvsp[-1].ConstVector)[0].C->getType(); + int NumElements = yyvsp[-1].ConstVector->size(); VectorType* pt = VectorType::get(ETy, NumElements); PATypeHolder* PTy = new PATypeHolder( HandleUpRefs(VectorType::get(ETy, NumElements))); // Verify all elements are correct type! std::vector Elems; - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - Constant *C = (*(yyvsp[-1].ConstVector))[i].C; + for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { + Constant *C = (*yyvsp[-1].ConstVector)[i].C; const Type *CTy = C->getType(); if (ETy != CTy) error("Element #" + utostr(i) + " is not of type '" + - ETy->getDescription() +"' as required!\nIt is of type '" + - CTy->getDescription() + "'"); - Elems.push_back(C); - } - (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems)); - delete PTy; delete (yyvsp[-1].ConstVector); - ;} - break; - - case 245: -#line 2823 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal).C); - ;} - break; - - case 246: -#line 2826 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); - std::string AsmStr = std::string((yyvsp[-2].StrVal), End); - End = UnEscapeLexed((yyvsp[0].StrVal), true); - std::string Constraints = std::string((yyvsp[0].StrVal), End); - (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); - free((yyvsp[-2].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 247: -#line 2841 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); ;} - break; - - case 248: -#line 2842 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); ;} - break; - - case 251: -#line 2855 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); - (yyval.ValueVal).S = (yyvsp[-1].TypeVal).S; - (yyval.ValueVal).V = getVal(Ty, (yyvsp[0].ValIDVal)); - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 252: -#line 2864 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); - ;} - break; - - case 253: -#line 2867 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Do not allow functions with 0 basic blocks - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); - ;} - break; - - case 254: -#line 2876 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); - InsertValue((yyvsp[0].TermInstVal)); - (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); - InsertValue((yyvsp[-2].BasicBlockVal)); - (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); - ;} - break; - - case 255: -#line 2886 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if ((yyvsp[0].InstVal).I) - (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal).I); - (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); - ;} - break; - - case 256: -#line 2891 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); + ETy->getDescription() +"' as required!\nIt is of type '" + + CTy->getDescription() + "'"); + Elems.push_back(C); + } + yyval.ValIDVal = ValID::create(ConstantVector::get(pt, Elems)); + delete PTy; delete yyvsp[-1].ConstVector; + ; + break;} +case 244: +#line 2823 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal.C); + ; + break;} +case 245: +#line 2826 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); + std::string AsmStr = std::string(yyvsp[-2].StrVal, End); + End = UnEscapeLexed(yyvsp[0].StrVal, true); + std::string Constraints = std::string(yyvsp[0].StrVal, End); + yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); + free(yyvsp[-2].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 246: +#line 2841 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); ; + break;} +case 247: +#line 2842 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); ; + break;} +case 250: +#line 2855 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); + yyval.ValueVal.S = yyvsp[-1].TypeVal.S; + yyval.ValueVal.V = getVal(Ty, yyvsp[0].ValIDVal); + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 251: +#line 2864 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.FunctionVal = yyvsp[-1].FunctionVal; + ; + break;} +case 252: +#line 2867 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Do not allow functions with 0 basic blocks + yyval.FunctionVal = yyvsp[-1].FunctionVal; + ; + break;} +case 253: +#line 2876 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); + InsertValue(yyvsp[0].TermInstVal); + yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); + InsertValue(yyvsp[-2].BasicBlockVal); + yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; + ; + break;} +case 254: +#line 2886 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (yyvsp[0].InstVal.I) + yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal.I); + yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; + ; + break;} +case 255: +#line 2891 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); // Make sure to move the basic block to the correct location in the // function, instead of leaving it inserted wherever it was first // referenced. Function::BasicBlockListType &BBL = CurFun.CurrentFunction->getBasicBlockList(); - BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); - ;} - break; - - case 257: -#line 2900 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); + BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); + ; + break;} +case 256: +#line 2900 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); // Make sure to move the basic block to the correct location in the // function, instead of leaving it inserted wherever it was first // referenced. Function::BasicBlockListType &BBL = CurFun.CurrentFunction->getBasicBlockList(); - BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); - ;} - break; - - case 260: -#line 2914 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Return with a result... - (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal).V); - ;} - break; - - case 261: -#line 2917 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Return with no result... - (yyval.TermInstVal) = new ReturnInst(); - ;} - break; - - case 262: -#line 2920 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Unconditional Branch... - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); - (yyval.TermInstVal) = new BranchInst(tmpBB); - ;} - break; - - case 263: -#line 2924 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); - BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); - Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); - (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); - ;} - break; - - case 264: -#line 2930 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - Value* tmpVal = getVal((yyvsp[-7].PrimType).T, (yyvsp[-6].ValIDVal)); - BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); - SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); - (yyval.TermInstVal) = S; - std::vector >::iterator I = (yyvsp[-1].JumpTable)->begin(), - E = (yyvsp[-1].JumpTable)->end(); + BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); + ; + break;} +case 259: +#line 2914 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Return with a result... + yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal.V); + ; + break;} +case 260: +#line 2917 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Return with no result... + yyval.TermInstVal = new ReturnInst(); + ; + break;} +case 261: +#line 2920 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Unconditional Branch... + BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); + yyval.TermInstVal = new BranchInst(tmpBB); + ; + break;} +case 262: +#line 2924 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); + BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); + Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); + yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); + ; + break;} +case 263: +#line 2930 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + Value* tmpVal = getVal(yyvsp[-7].PrimType.T, yyvsp[-6].ValIDVal); + BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); + SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); + yyval.TermInstVal = S; + std::vector >::iterator I = yyvsp[-1].JumpTable->begin(), + E = yyvsp[-1].JumpTable->end(); for (; I != E; ++I) { if (ConstantInt *CI = dyn_cast(I->first)) S->addCase(CI, I->second); else error("Switch case is constant, but not a simple integer"); } - delete (yyvsp[-1].JumpTable); - ;} - break; - - case 265: -#line 2945 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - Value* tmpVal = getVal((yyvsp[-6].PrimType).T, (yyvsp[-5].ValIDVal)); - BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); + delete yyvsp[-1].JumpTable; + ; + break;} +case 264: +#line 2945 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + Value* tmpVal = getVal(yyvsp[-6].PrimType.T, yyvsp[-5].ValIDVal); + BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); - (yyval.TermInstVal) = S; - ;} - break; - - case 266: -#line 2952 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + yyval.TermInstVal = S; + ; + break;} +case 265: +#line 2952 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ const PointerType *PFTy; const FunctionType *Ty; - if (!(PFTy = dyn_cast((yyvsp[-10].TypeVal).PAT->get())) || + if (!(PFTy = dyn_cast(yyvsp[-10].TypeVal.PAT->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; - if ((yyvsp[-7].ValueList)) { - for (std::vector::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end(); + if (yyvsp[-7].ValueList) { + for (std::vector::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end(); I != E; ++I) ParamTypes.push_back((*I).V->getType()); } FunctionType::ParamAttrsList ParamAttrs; - if ((yyvsp[-11].UIntVal) == OldCallingConv::CSRet) { + if (yyvsp[-11].UIntVal == OldCallingConv::CSRet) { ParamAttrs.push_back(FunctionType::NoAttributeSet); ParamAttrs.push_back(FunctionType::StructRetAttribute); } bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - Ty = FunctionType::get((yyvsp[-10].TypeVal).PAT->get(), ParamTypes, isVarArg, ParamAttrs); + Ty = FunctionType::get(yyvsp[-10].TypeVal.PAT->get(), ParamTypes, isVarArg, ParamAttrs); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... - BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); - BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); + Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... + BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); + BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); // Create the call node... - if (!(yyvsp[-7].ValueList)) { // Has no arguments? - (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, 0, 0); + if (!yyvsp[-7].ValueList) { // Has no arguments? + yyval.TermInstVal = new InvokeInst(V, Normal, Except, 0, 0); } else { // Has arguments? // Loop through FunctionType's arguments and ensure they are specified // correctly! // FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - std::vector::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end(); + std::vector::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end(); std::vector Args; for (; ArgI != ArgE && I != E; ++ArgI, ++I) { @@ -5586,64 +4752,59 @@ if (I != E || (ArgI != ArgE && !Ty->isVarArg())) error("Invalid number of parameters detected"); - (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); + yyval.TermInstVal = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); } - cast((yyval.TermInstVal))->setCallingConv(upgradeCallingConv((yyvsp[-11].UIntVal))); - delete (yyvsp[-10].TypeVal).PAT; - delete (yyvsp[-7].ValueList); - ;} - break; - - case 267: -#line 3007 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TermInstVal) = new UnwindInst(); - ;} - break; - - case 268: -#line 3010 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.TermInstVal) = new UnreachableInst(); - ;} - break; - - case 269: -#line 3016 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.JumpTable) = (yyvsp[-5].JumpTable); - Constant *V = cast(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); + cast(yyval.TermInstVal)->setCallingConv(upgradeCallingConv(yyvsp[-11].UIntVal)); + delete yyvsp[-10].TypeVal.PAT; + delete yyvsp[-7].ValueList; + ; + break;} +case 266: +#line 3007 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TermInstVal = new UnwindInst(); + ; + break;} +case 267: +#line 3010 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.TermInstVal = new UnreachableInst(); + ; + break;} +case 268: +#line 3016 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.JumpTable = yyvsp[-5].JumpTable; + Constant *V = cast(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); if (V == 0) error("May only switch on a constant pool value"); - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); - (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); - ;} - break; - - case 270: -#line 3026 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.JumpTable) = new std::vector >(); - Constant *V = cast(getExistingValue((yyvsp[-4].PrimType).T, (yyvsp[-3].ValIDVal))); + BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); + yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); + ; + break;} +case 269: +#line 3026 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.JumpTable = new std::vector >(); + Constant *V = cast(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); if (V == 0) error("May only switch on a constant pool value"); - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); - (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); - ;} - break; - - case 271: -#line 3039 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); + yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); + ; + break;} +case 270: +#line 3039 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ bool omit = false; - if ((yyvsp[-1].StrVal)) - if (BitCastInst *BCI = dyn_cast((yyvsp[0].InstVal).I)) + if (yyvsp[-1].StrVal) + if (BitCastInst *BCI = dyn_cast(yyvsp[0].InstVal.I)) if (BCI->getSrcTy() == BCI->getDestTy() && - BCI->getOperand(0)->getName() == (yyvsp[-1].StrVal)) + BCI->getOperand(0)->getName() == yyvsp[-1].StrVal) // This is a useless bit cast causing a name redefinition. It is // a bit cast from a type to the same type of an operand with the // same name as the name we would give this instruction. Since this @@ -5658,243 +4819,225 @@ // The bitcast is clearly useless so we omit it. omit = true; if (omit) { - (yyval.InstVal).I = 0; - (yyval.InstVal).S = Signless; + yyval.InstVal.I = 0; + yyval.InstVal.S = Signless; } else { - setValueName((yyvsp[0].InstVal).I, (yyvsp[-1].StrVal)); - InsertValue((yyvsp[0].InstVal).I); - (yyval.InstVal) = (yyvsp[0].InstVal); - } - ;} - break; - - case 272: -#line 3068 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Used for PHI nodes - (yyval.PHIList).P = new std::list >(); - (yyval.PHIList).S = (yyvsp[-5].TypeVal).S; - Value* tmpVal = getVal((yyvsp[-5].TypeVal).PAT->get(), (yyvsp[-3].ValIDVal)); - BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); - (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); - delete (yyvsp[-5].TypeVal).PAT; - ;} - break; - - case 273: -#line 3076 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.PHIList) = (yyvsp[-6].PHIList); - Value* tmpVal = getVal((yyvsp[-6].PHIList).P->front().first->getType(), (yyvsp[-3].ValIDVal)); - BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); - (yyvsp[-6].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB)); - ;} - break; - - case 274: -#line 3084 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { // Used for call statements, and memory insts... - (yyval.ValueList) = new std::vector(); - (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); - ;} - break; - - case 275: -#line 3088 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.ValueList) = (yyvsp[-2].ValueList); - (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); - ;} - break; - - case 277: -#line 3096 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValueList) = 0; ;} - break; - - case 278: -#line 3100 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.BoolVal) = true; - ;} - break; - - case 279: -#line 3103 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.BoolVal) = false; - ;} - break; - - case 280: -#line 3109 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); + setValueName(yyvsp[0].InstVal.I, yyvsp[-1].StrVal); + InsertValue(yyvsp[0].InstVal.I); + yyval.InstVal = yyvsp[0].InstVal; + } + ; + break;} +case 271: +#line 3068 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Used for PHI nodes + yyval.PHIList.P = new std::list >(); + yyval.PHIList.S = yyvsp[-5].TypeVal.S; + Value* tmpVal = getVal(yyvsp[-5].TypeVal.PAT->get(), yyvsp[-3].ValIDVal); + BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); + yyval.PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); + delete yyvsp[-5].TypeVal.PAT; + ; + break;} +case 272: +#line 3076 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.PHIList = yyvsp[-6].PHIList; + Value* tmpVal = getVal(yyvsp[-6].PHIList.P->front().first->getType(), yyvsp[-3].ValIDVal); + BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); + yyvsp[-6].PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); + ; + break;} +case 273: +#line 3084 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Used for call statements, and memory insts... + yyval.ValueList = new std::vector(); + yyval.ValueList->push_back(yyvsp[0].ValueVal); + ; + break;} +case 274: +#line 3088 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.ValueList = yyvsp[-2].ValueList; + yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); + ; + break;} +case 276: +#line 3096 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValueList = 0; ; + break;} +case 277: +#line 3100 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.BoolVal = true; + ; + break;} +case 278: +#line 3103 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.BoolVal = false; + ; + break;} +case 279: +#line 3109 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa(Ty)) error("Arithmetic operator requires integer, FP, or packed operands"); if (isa(Ty) && - ((yyvsp[-4].BinaryOpVal) == URemOp || (yyvsp[-4].BinaryOpVal) == SRemOp || (yyvsp[-4].BinaryOpVal) == FRemOp || (yyvsp[-4].BinaryOpVal) == RemOp)) - error("Remainder not supported on packed types"); + (yyvsp[-4].BinaryOpVal == URemOp || yyvsp[-4].BinaryOpVal == SRemOp || yyvsp[-4].BinaryOpVal == FRemOp || yyvsp[-4].BinaryOpVal == RemOp)) + error("Remainder not supported on vector types"); // Upgrade the opcode from obsolete versions before we do anything with it. - Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); - Value* val1 = getVal(Ty, (yyvsp[-2].ValIDVal)); - Value* val2 = getVal(Ty, (yyvsp[0].ValIDVal)); - (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2); - if ((yyval.InstVal).I == 0) + Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); + Value* val1 = getVal(Ty, yyvsp[-2].ValIDVal); + Value* val2 = getVal(Ty, yyvsp[0].ValIDVal); + yyval.InstVal.I = BinaryOperator::create(Opcode, val1, val2); + if (yyval.InstVal.I == 0) error("binary operator returned null"); - (yyval.InstVal).S = (yyvsp[-3].TypeVal).S; - delete (yyvsp[-3].TypeVal).PAT; - ;} - break; - - case 281: -#line 3126 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); + yyval.InstVal.S = yyvsp[-3].TypeVal.S; + delete yyvsp[-3].TypeVal.PAT; + ; + break;} +case 280: +#line 3126 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); if (!Ty->isInteger()) { if (!isa(Ty) || !cast(Ty)->getElementType()->isInteger()) error("Logical operator requires integral operands"); } - Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[-4].BinaryOpVal), Ty, (yyvsp[-3].TypeVal).S); - Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); - Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); - (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); - if ((yyval.InstVal).I == 0) + Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); + Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); + Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); + yyval.InstVal.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); + if (yyval.InstVal.I == 0) error("binary operator returned null"); - (yyval.InstVal).S = (yyvsp[-3].TypeVal).S; - delete (yyvsp[-3].TypeVal).PAT; - ;} - break; - - case 282: -#line 3142 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* Ty = (yyvsp[-3].TypeVal).PAT->get(); + yyval.InstVal.S = yyvsp[-3].TypeVal.S; + delete yyvsp[-3].TypeVal.PAT; + ; + break;} +case 281: +#line 3142 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); if(isa(Ty)) error("VectorTypes currently not supported in setcc instructions"); unsigned short pred; - Instruction::OtherOps Opcode = getCompareOp((yyvsp[-4].BinaryOpVal), pred, Ty, (yyvsp[-3].TypeVal).S); - Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); - Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); - (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); - if ((yyval.InstVal).I == 0) + Instruction::OtherOps Opcode = getCompareOp(yyvsp[-4].BinaryOpVal, pred, Ty, yyvsp[-3].TypeVal.S); + Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); + Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); + yyval.InstVal.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); + if (yyval.InstVal.I == 0) error("binary operator returned null"); - (yyval.InstVal).S = Unsigned; - delete (yyvsp[-3].TypeVal).PAT; - ;} - break; - - case 283: -#line 3156 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); + yyval.InstVal.S = Unsigned; + delete yyvsp[-3].TypeVal.PAT; + ; + break;} +case 282: +#line 3156 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); if (isa(Ty)) error("VectorTypes currently not supported in icmp instructions"); else if (!Ty->isInteger() && !isa(Ty)) error("icmp requires integer or pointer typed operands"); - Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); - Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); - (yyval.InstVal).I = new ICmpInst((yyvsp[-4].IPred), tmpVal1, tmpVal2); - (yyval.InstVal).S = Unsigned; - delete (yyvsp[-3].TypeVal).PAT; - ;} - break; - - case 284: -#line 3168 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-3].TypeVal).PAT->get(); + Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); + Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); + yyval.InstVal.I = new ICmpInst(yyvsp[-4].IPred, tmpVal1, tmpVal2); + yyval.InstVal.S = Unsigned; + delete yyvsp[-3].TypeVal.PAT; + ; + break;} +case 283: +#line 3168 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); if (isa(Ty)) error("VectorTypes currently not supported in fcmp instructions"); else if (!Ty->isFloatingPoint()) error("fcmp instruction requires floating point operands"); - Value* tmpVal1 = getVal(Ty, (yyvsp[-2].ValIDVal)); - Value* tmpVal2 = getVal(Ty, (yyvsp[0].ValIDVal)); - (yyval.InstVal).I = new FCmpInst((yyvsp[-4].FPred), tmpVal1, tmpVal2); - (yyval.InstVal).S = Unsigned; - delete (yyvsp[-3].TypeVal).PAT; - ;} - break; - - case 285: -#line 3180 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); + Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); + yyval.InstVal.I = new FCmpInst(yyvsp[-4].FPred, tmpVal1, tmpVal2); + yyval.InstVal.S = Unsigned; + delete yyvsp[-3].TypeVal.PAT; + ; + break;} +case 284: +#line 3180 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ warning("Use of obsolete 'not' instruction: Replacing with 'xor"); - const Type *Ty = (yyvsp[0].ValueVal).V->getType(); + const Type *Ty = yyvsp[0].ValueVal.V->getType(); Value *Ones = ConstantInt::getAllOnesValue(Ty); if (Ones == 0) error("Expected integral type for not instruction"); - (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal).V, Ones); - if ((yyval.InstVal).I == 0) + yyval.InstVal.I = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal.V, Ones); + if (yyval.InstVal.I == 0) error("Could not create a xor instruction"); - (yyval.InstVal).S = (yyvsp[0].ValueVal).S - ;} - break; - - case 286: -#line 3191 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!(yyvsp[0].ValueVal).V->getType()->isInteger() || - cast((yyvsp[0].ValueVal).V->getType())->getBitWidth() != 8) + yyval.InstVal.S = yyvsp[0].ValueVal.S + ; + break;} +case 285: +#line 3191 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!yyvsp[0].ValueVal.V->getType()->isInteger() || + cast(yyvsp[0].ValueVal.V->getType())->getBitWidth() != 8) error("Shift amount must be int8"); - const Type* Ty = (yyvsp[-2].ValueVal).V->getType(); + const Type* Ty = yyvsp[-2].ValueVal.V->getType(); if (!Ty->isInteger()) error("Shift constant expression requires integer operand"); Value* ShiftAmt = 0; if (cast(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) - if (Constant *C = dyn_cast((yyvsp[0].ValueVal).V)) + if (Constant *C = dyn_cast(yyvsp[0].ValueVal.V)) ShiftAmt = ConstantExpr::getZExt(C, Ty); else - ShiftAmt = new ZExtInst((yyvsp[0].ValueVal).V, Ty, makeNameUnique("shift"), CurBB); + ShiftAmt = new ZExtInst(yyvsp[0].ValueVal.V, Ty, makeNameUnique("shift"), CurBB); else - ShiftAmt = (yyvsp[0].ValueVal).V; - (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[-3].BinaryOpVal), Ty, (yyvsp[-2].ValueVal).S), (yyvsp[-2].ValueVal).V, ShiftAmt); - (yyval.InstVal).S = (yyvsp[-2].ValueVal).S; - ;} - break; - - case 287: -#line 3209 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *DstTy = (yyvsp[0].TypeVal).PAT->get(); + ShiftAmt = yyvsp[0].ValueVal.V; + yyval.InstVal.I = BinaryOperator::create(getBinaryOp(yyvsp[-3].BinaryOpVal, Ty, yyvsp[-2].ValueVal.S), yyvsp[-2].ValueVal.V, ShiftAmt); + yyval.InstVal.S = yyvsp[-2].ValueVal.S; + ; + break;} +case 286: +#line 3209 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *DstTy = yyvsp[0].TypeVal.PAT->get(); if (!DstTy->isFirstClassType()) error("cast instruction to a non-primitive type: '" + DstTy->getDescription() + "'"); - (yyval.InstVal).I = cast(getCast((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal).V, (yyvsp[-2].ValueVal).S, DstTy, (yyvsp[0].TypeVal).S, true)); - (yyval.InstVal).S = (yyvsp[0].TypeVal).S; - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 288: -#line 3218 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!(yyvsp[-4].ValueVal).V->getType()->isInteger() || - cast((yyvsp[-4].ValueVal).V->getType())->getBitWidth() != 1) + yyval.InstVal.I = cast(getCast(yyvsp[-3].CastOpVal, yyvsp[-2].ValueVal.V, yyvsp[-2].ValueVal.S, DstTy, yyvsp[0].TypeVal.S, true)); + yyval.InstVal.S = yyvsp[0].TypeVal.S; + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 287: +#line 3218 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!yyvsp[-4].ValueVal.V->getType()->isInteger() || + cast(yyvsp[-4].ValueVal.V->getType())->getBitWidth() != 1) error("select condition must be bool"); - if ((yyvsp[-2].ValueVal).V->getType() != (yyvsp[0].ValueVal).V->getType()) + if (yyvsp[-2].ValueVal.V->getType() != yyvsp[0].ValueVal.V->getType()) error("select value types should match"); - (yyval.InstVal).I = new SelectInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); - (yyval.InstVal).S = (yyvsp[-4].ValueVal).S; - ;} - break; - - case 289: -#line 3227 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[0].TypeVal).PAT->get(); + yyval.InstVal.I = new SelectInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); + yyval.InstVal.S = yyvsp[-4].ValueVal.S; + ; + break;} +case 288: +#line 3227 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[0].TypeVal.PAT->get(); NewVarArgs = true; - (yyval.InstVal).I = new VAArgInst((yyvsp[-2].ValueVal).V, Ty); - (yyval.InstVal).S = (yyvsp[0].TypeVal).S; - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 290: -#line 3234 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); - const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); + yyval.InstVal.I = new VAArgInst(yyvsp[-2].ValueVal.V, Ty); + yyval.InstVal.S = yyvsp[0].TypeVal.S; + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 289: +#line 3234 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); + const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); ObsoleteVarArgs = true; Function* NF = cast(CurModule.CurrentModule-> getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); @@ -5906,20 +5049,19 @@ //b = vaarg foo, t AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); CurBB->getInstList().push_back(foo); - CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); + CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); CurBB->getInstList().push_back(bar); CurBB->getInstList().push_back(new StoreInst(bar, foo)); - (yyval.InstVal).I = new VAArgInst(foo, DstTy); - (yyval.InstVal).S = (yyvsp[0].TypeVal).S; - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 291: -#line 3255 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* ArgTy = (yyvsp[-2].ValueVal).V->getType(); - const Type* DstTy = (yyvsp[0].TypeVal).PAT->get(); + yyval.InstVal.I = new VAArgInst(foo, DstTy); + yyval.InstVal.S = yyvsp[0].TypeVal.S; + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 290: +#line 3255 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); + const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); ObsoleteVarArgs = true; Function* NF = cast(CurModule.CurrentModule-> getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); @@ -5932,93 +5074,88 @@ //b = load foo AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); CurBB->getInstList().push_back(foo); - CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal).V); + CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); CurBB->getInstList().push_back(bar); CurBB->getInstList().push_back(new StoreInst(bar, foo)); Instruction* tmp = new VAArgInst(foo, DstTy); CurBB->getInstList().push_back(tmp); - (yyval.InstVal).I = new LoadInst(foo); - (yyval.InstVal).S = (yyvsp[0].TypeVal).S; - delete (yyvsp[0].TypeVal).PAT; - ;} - break; - - case 292: -#line 3279 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) + yyval.InstVal.I = new LoadInst(foo); + yyval.InstVal.S = yyvsp[0].TypeVal.S; + delete yyvsp[0].TypeVal.PAT; + ; + break;} +case 291: +#line 3279 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) error("Invalid extractelement operands"); - (yyval.InstVal).I = new ExtractElementInst((yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); - (yyval.InstVal).S = (yyvsp[-2].ValueVal).S; - ;} - break; - - case 293: -#line 3285 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) + yyval.InstVal.I = new ExtractElementInst(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); + yyval.InstVal.S = yyvsp[-2].ValueVal.S; + ; + break;} +case 292: +#line 3285 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) error("Invalid insertelement operands"); - (yyval.InstVal).I = new InsertElementInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); - (yyval.InstVal).S = (yyvsp[-4].ValueVal).S; - ;} - break; - - case 294: -#line 3291 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V)) + yyval.InstVal.I = new InsertElementInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); + yyval.InstVal.S = yyvsp[-4].ValueVal.S; + ; + break;} +case 293: +#line 3291 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) error("Invalid shufflevector operands"); - (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[-4].ValueVal).V, (yyvsp[-2].ValueVal).V, (yyvsp[0].ValueVal).V); - (yyval.InstVal).S = (yyvsp[-4].ValueVal).S; - ;} - break; - - case 295: -#line 3297 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[0].PHIList).P->front().first->getType(); + yyval.InstVal.I = new ShuffleVectorInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); + yyval.InstVal.S = yyvsp[-4].ValueVal.S; + ; + break;} +case 294: +#line 3297 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[0].PHIList.P->front().first->getType(); if (!Ty->isFirstClassType()) error("PHI node operands must be of first class type"); PHINode *PHI = new PHINode(Ty); - PHI->reserveOperandSpace((yyvsp[0].PHIList).P->size()); - while ((yyvsp[0].PHIList).P->begin() != (yyvsp[0].PHIList).P->end()) { - if ((yyvsp[0].PHIList).P->front().first->getType() != Ty) + PHI->reserveOperandSpace(yyvsp[0].PHIList.P->size()); + while (yyvsp[0].PHIList.P->begin() != yyvsp[0].PHIList.P->end()) { + if (yyvsp[0].PHIList.P->front().first->getType() != Ty) error("All elements of a PHI node must be of the same type"); - PHI->addIncoming((yyvsp[0].PHIList).P->front().first, (yyvsp[0].PHIList).P->front().second); - (yyvsp[0].PHIList).P->pop_front(); + PHI->addIncoming(yyvsp[0].PHIList.P->front().first, yyvsp[0].PHIList.P->front().second); + yyvsp[0].PHIList.P->pop_front(); } - (yyval.InstVal).I = PHI; - (yyval.InstVal).S = (yyvsp[0].PHIList).S; - delete (yyvsp[0].PHIList).P; // Free the list... - ;} - break; - - case 296: -#line 3313 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { + yyval.InstVal.I = PHI; + yyval.InstVal.S = yyvsp[0].PHIList.S; + delete yyvsp[0].PHIList.P; // Free the list... + ; + break;} +case 295: +#line 3313 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ // Handle the short call syntax const PointerType *PFTy; const FunctionType *FTy; - if (!(PFTy = dyn_cast((yyvsp[-4].TypeVal).PAT->get())) || + if (!(PFTy = dyn_cast(yyvsp[-4].TypeVal.PAT->get())) || !(FTy = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; - if ((yyvsp[-1].ValueList)) { - for (std::vector::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end(); + if (yyvsp[-1].ValueList) { + for (std::vector::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end(); I != E; ++I) ParamTypes.push_back((*I).V->getType()); } FunctionType::ParamAttrsList ParamAttrs; - if ((yyvsp[-5].UIntVal) == OldCallingConv::CSRet) { + if (yyvsp[-5].UIntVal == OldCallingConv::CSRet) { ParamAttrs.push_back(FunctionType::NoAttributeSet); ParamAttrs.push_back(FunctionType::StructRetAttribute); } bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - const Type *RetTy = (yyvsp[-4].TypeVal).PAT->get(); + const Type *RetTy = yyvsp[-4].TypeVal.PAT->get(); if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) error("Functions cannot return aggregate types"); @@ -6028,21 +5165,21 @@ // First upgrade any intrinsic calls. std::vector Args; - if ((yyvsp[-1].ValueList)) - for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i < e; ++i) - Args.push_back((*(yyvsp[-1].ValueList))[i].V); - Instruction *Inst = upgradeIntrinsicCall(FTy, (yyvsp[-3].ValIDVal), Args); + if (yyvsp[-1].ValueList) + for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i < e; ++i) + Args.push_back((*yyvsp[-1].ValueList)[i].V); + Instruction *Inst = upgradeIntrinsicCall(FTy, yyvsp[-3].ValIDVal, Args); // If we got an upgraded intrinsic if (Inst) { - (yyval.InstVal).I = Inst; - (yyval.InstVal).S = Signless; + yyval.InstVal.I = Inst; + yyval.InstVal.S = Signless; } else { // Get the function we're calling - Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); + Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Check the argument values match - if (!(yyvsp[-1].ValueList)) { // Has no arguments? + if (!yyvsp[-1].ValueList) { // Has no arguments? // Make sure no arguments is a good thing! if (FTy->getNumParams() != 0) error("No arguments passed to a function that expects arguments"); @@ -6052,7 +5189,7 @@ // FunctionType::param_iterator I = FTy->param_begin(); FunctionType::param_iterator E = FTy->param_end(); - std::vector::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end(); + std::vector::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI).V->getType() != *I) @@ -6065,124 +5202,112 @@ // Create the call instruction CallInst *CI = new CallInst(V, &Args[0], Args.size()); - CI->setTailCall((yyvsp[-6].BoolVal)); - CI->setCallingConv(upgradeCallingConv((yyvsp[-5].UIntVal))); - (yyval.InstVal).I = CI; - (yyval.InstVal).S = (yyvsp[-4].TypeVal).S; - } - delete (yyvsp[-4].TypeVal).PAT; - delete (yyvsp[-1].ValueList); - ;} - break; - - case 297: -#line 3391 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - (yyval.InstVal) = (yyvsp[0].InstVal); - ;} - break; - - case 298: -#line 3399 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValueList) = (yyvsp[0].ValueList); ;} - break; - - case 299: -#line 3400 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.ValueList) = new std::vector(); ;} - break; - - case 300: -#line 3404 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.BoolVal) = true; ;} - break; - - case 301: -#line 3405 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { (yyval.BoolVal) = false; ;} - break; - - case 302: -#line 3409 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); - (yyval.InstVal).S = (yyvsp[-1].TypeVal).S; - (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[0].UIntVal)); - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 303: -#line 3415 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); - (yyval.InstVal).S = (yyvsp[-4].TypeVal).S; - (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); - delete (yyvsp[-4].TypeVal).PAT; - ;} - break; - - case 304: -#line 3421 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-1].TypeVal).PAT->get(); - (yyval.InstVal).S = (yyvsp[-1].TypeVal).S; - (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[0].UIntVal)); - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 305: -#line 3427 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *Ty = (yyvsp[-4].TypeVal).PAT->get(); - (yyval.InstVal).S = (yyvsp[-4].TypeVal).S; - (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[-2].PrimType).T, (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal)); - delete (yyvsp[-4].TypeVal).PAT; - ;} - break; - - case 306: -#line 3433 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type *PTy = (yyvsp[0].ValueVal).V->getType(); + CI->setTailCall(yyvsp[-6].BoolVal); + CI->setCallingConv(upgradeCallingConv(yyvsp[-5].UIntVal)); + yyval.InstVal.I = CI; + yyval.InstVal.S = yyvsp[-4].TypeVal.S; + } + delete yyvsp[-4].TypeVal.PAT; + delete yyvsp[-1].ValueList; + ; + break;} +case 296: +#line 3391 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + yyval.InstVal = yyvsp[0].InstVal; + ; + break;} +case 297: +#line 3399 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValueList = yyvsp[0].ValueList; ; + break;} +case 298: +#line 3400 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.ValueList = new std::vector(); ; + break;} +case 299: +#line 3404 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.BoolVal = true; ; + break;} +case 300: +#line 3405 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ yyval.BoolVal = false; ; + break;} +case 301: +#line 3409 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); + yyval.InstVal.S = yyvsp[-1].TypeVal.S; + yyval.InstVal.I = new MallocInst(Ty, 0, yyvsp[0].UIntVal); + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 302: +#line 3415 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); + yyval.InstVal.S = yyvsp[-4].TypeVal.S; + yyval.InstVal.I = new MallocInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); + delete yyvsp[-4].TypeVal.PAT; + ; + break;} +case 303: +#line 3421 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); + yyval.InstVal.S = yyvsp[-1].TypeVal.S; + yyval.InstVal.I = new AllocaInst(Ty, 0, yyvsp[0].UIntVal); + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 304: +#line 3427 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); + yyval.InstVal.S = yyvsp[-4].TypeVal.S; + yyval.InstVal.I = new AllocaInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); + delete yyvsp[-4].TypeVal.PAT; + ; + break;} +case 305: +#line 3433 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type *PTy = yyvsp[0].ValueVal.V->getType(); if (!isa(PTy)) error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); - (yyval.InstVal).I = new FreeInst((yyvsp[0].ValueVal).V); - (yyval.InstVal).S = Signless; - ;} - break; - - case 307: -#line 3440 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* Ty = (yyvsp[-1].TypeVal).PAT->get(); - (yyval.InstVal).S = (yyvsp[-1].TypeVal).S; + yyval.InstVal.I = new FreeInst(yyvsp[0].ValueVal.V); + yyval.InstVal.S = Signless; + ; + break;} +case 306: +#line 3440 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* Ty = yyvsp[-1].TypeVal.PAT->get(); + yyval.InstVal.S = yyvsp[-1].TypeVal.S; if (!isa(Ty)) error("Can't load from nonpointer type: " + Ty->getDescription()); if (!cast(Ty)->getElementType()->isFirstClassType()) error("Can't load from pointer of non-first-class type: " + Ty->getDescription()); - Value* tmpVal = getVal(Ty, (yyvsp[0].ValIDVal)); - (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 308: -#line 3452 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const PointerType *PTy = dyn_cast((yyvsp[-1].TypeVal).PAT->get()); + Value* tmpVal = getVal(Ty, yyvsp[0].ValIDVal); + yyval.InstVal.I = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 307: +#line 3452 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const PointerType *PTy = dyn_cast(yyvsp[-1].TypeVal.PAT->get()); if (!PTy) error("Can't store to a nonpointer type: " + - (yyvsp[-1].TypeVal).PAT->get()->getDescription()); + yyvsp[-1].TypeVal.PAT->get()->getDescription()); const Type *ElTy = PTy->getElementType(); - Value *StoreVal = (yyvsp[-3].ValueVal).V; - Value* tmpVal = getVal(PTy, (yyvsp[0].ValIDVal)); - if (ElTy != (yyvsp[-3].ValueVal).V->getType()) { - StoreVal = handleSRetFuncTypeMerge((yyvsp[-3].ValueVal).V, ElTy); + Value *StoreVal = yyvsp[-3].ValueVal.V; + Value* tmpVal = getVal(PTy, yyvsp[0].ValIDVal); + if (ElTy != yyvsp[-3].ValueVal.V->getType()) { + StoreVal = handleSRetFuncTypeMerge(yyvsp[-3].ValueVal.V, ElTy); if (!StoreVal) - error("Can't store '" + (yyvsp[-3].ValueVal).V->getType()->getDescription() + + error("Can't store '" + yyvsp[-3].ValueVal.V->getType()->getDescription() + "' into space of type '" + ElTy->getDescription() + "'"); else { PTy = PointerType::get(StoreVal->getType()); @@ -6192,304 +5317,251 @@ tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); } } - (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[-5].BoolVal)); - (yyval.InstVal).S = Signless; - delete (yyvsp[-1].TypeVal).PAT; - ;} - break; - - case 309: -#line 3477 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" - { - const Type* Ty = (yyvsp[-2].TypeVal).PAT->get(); + yyval.InstVal.I = new StoreInst(StoreVal, tmpVal, yyvsp[-5].BoolVal); + yyval.InstVal.S = Signless; + delete yyvsp[-1].TypeVal.PAT; + ; + break;} +case 308: +#line 3477 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" +{ + const Type* Ty = yyvsp[-2].TypeVal.PAT->get(); if (!isa(Ty)) error("getelementptr insn requires pointer operand"); std::vector VIndices; - upgradeGEPIndices(Ty, (yyvsp[0].ValueList), VIndices); - - Value* tmpVal = getVal(Ty, (yyvsp[-1].ValIDVal)); - (yyval.InstVal).I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); - (yyval.InstVal).S = Signless; - delete (yyvsp[-2].TypeVal).PAT; - delete (yyvsp[0].ValueList); - ;} - break; - + upgradeGEPIndices(Ty, yyvsp[0].ValueList, VIndices); - default: break; - } - -/* Line 1126 of yacc.c. */ -#line 6225 "UpgradeParser.tab.c" + Value* tmpVal = getVal(Ty, yyvsp[-1].ValIDVal); + yyval.InstVal.I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); + yyval.InstVal.S = Signless; + delete yyvsp[-2].TypeVal.PAT; + delete yyvsp[0].ValueList; + ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/share/bison.simple" yyvsp -= yylen; yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif - - YY_STACK_PRINT (yyss, yyssp); +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif *++yyvsp = yyval; +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTOKENS]; + yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; +yyerrlab: /* here on detecting error */ -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ { ++yynerrs; -#if YYERROR_VERBOSE + +#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; - if (YYPACT_NINF < yyn && yyn < YYLAST) + if (yyn > YYFLAG && yyn < YYLAST) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - char *yymsg = 0; -# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - - if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg) + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yymsg; - int yyi = 0; - while ((*yyp = *yyf)) + strcpy(msg, "parse error"); + + if (count < 5) { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } } - yyerror (yymsg); - YYSTACK_FREE (yymsg); + yyerror(msg); + free(msg); } else - { - yyerror (YY_("syntax error")); - goto yyexhaustedlab; - } + yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ - yyerror (YY_("syntax error")); + yyerror("parse error"); } - + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ + /* if just tried and failed to reuse lookahead token after an error, discard it. */ - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", yytoken, &yylval); - yychar = YYEMPTY; - } + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; } - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; + /* Else will try to reuse lookahead token + after shifting the error token. */ + yyerrstatus = 3; /* Each real token shifted decrements this */ -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (0) - goto yyerrorlab; + goto yyerrhandle; -yyvsp -= yylen; - yyssp -= yylen; - yystate = *yyssp; - goto yyerrlab1; +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif +yyerrpop: /* pop the current state because it cannot handle the error token */ -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif - for (;;) +#if YYDEBUG != 0 + if (yydebug) { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; - yydestruct ("Error: popping", yystos[yystate], yyvsp); - YYPOPSTACK; - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; } + else if (yyn == 0) + goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; - *++yyvsp = yylval; - +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif yystate = yyn; goto yynewstate; + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK; - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); #endif - return yyresult; + } + return 1; } - - -#line 3493 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" +#line 3493 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" int yyerror(const char *ErrorMsg) { @@ -6522,4 +5594,3 @@ yyerror(ErrorMsg.c_str()); } - Index: llvm/tools/llvm-upgrade/UpgradeParser.h.cvs diff -u llvm/tools/llvm-upgrade/UpgradeParser.h.cvs:1.47 llvm/tools/llvm-upgrade/UpgradeParser.h.cvs:1.48 --- llvm/tools/llvm-upgrade/UpgradeParser.h.cvs:1.47 Wed Feb 14 20:26:10 2007 +++ llvm/tools/llvm-upgrade/UpgradeParser.h.cvs Mon Feb 19 01:34:02 2007 @@ -1,342 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.1. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - - 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 2, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ESINT64VAL = 258, - EUINT64VAL = 259, - SINTVAL = 260, - UINTVAL = 261, - FPVAL = 262, - VOID = 263, - BOOL = 264, - SBYTE = 265, - UBYTE = 266, - SHORT = 267, - USHORT = 268, - INT = 269, - UINT = 270, - LONG = 271, - ULONG = 272, - FLOAT = 273, - DOUBLE = 274, - TYPE = 275, - LABEL = 276, - VAR_ID = 277, - LABELSTR = 278, - STRINGCONSTANT = 279, - IMPLEMENTATION = 280, - ZEROINITIALIZER = 281, - TRUETOK = 282, - FALSETOK = 283, - BEGINTOK = 284, - ENDTOK = 285, - DECLARE = 286, - GLOBAL = 287, - CONSTANT = 288, - SECTION = 289, - VOLATILE = 290, - TO = 291, - DOTDOTDOT = 292, - NULL_TOK = 293, - UNDEF = 294, - CONST = 295, - INTERNAL = 296, - LINKONCE = 297, - WEAK = 298, - APPENDING = 299, - DLLIMPORT = 300, - DLLEXPORT = 301, - EXTERN_WEAK = 302, - OPAQUE = 303, - NOT = 304, - EXTERNAL = 305, - TARGET = 306, - TRIPLE = 307, - ENDIAN = 308, - POINTERSIZE = 309, - LITTLE = 310, - BIG = 311, - ALIGN = 312, - DEPLIBS = 313, - CALL = 314, - TAIL = 315, - ASM_TOK = 316, - MODULE = 317, - SIDEEFFECT = 318, - CC_TOK = 319, - CCC_TOK = 320, - CSRETCC_TOK = 321, - FASTCC_TOK = 322, - COLDCC_TOK = 323, - X86_STDCALLCC_TOK = 324, - X86_FASTCALLCC_TOK = 325, - DATALAYOUT = 326, - RET = 327, - BR = 328, - SWITCH = 329, - INVOKE = 330, - UNREACHABLE = 331, - UNWIND = 332, - EXCEPT = 333, - ADD = 334, - SUB = 335, - MUL = 336, - DIV = 337, - UDIV = 338, - SDIV = 339, - FDIV = 340, - REM = 341, - UREM = 342, - SREM = 343, - FREM = 344, - AND = 345, - OR = 346, - XOR = 347, - SHL = 348, - SHR = 349, - ASHR = 350, - LSHR = 351, - SETLE = 352, - SETGE = 353, - SETLT = 354, - SETGT = 355, - SETEQ = 356, - SETNE = 357, - ICMP = 358, - FCMP = 359, - MALLOC = 360, - ALLOCA = 361, - FREE = 362, - LOAD = 363, - STORE = 364, - GETELEMENTPTR = 365, - PHI_TOK = 366, - SELECT = 367, - VAARG = 368, - EXTRACTELEMENT = 369, - INSERTELEMENT = 370, - SHUFFLEVECTOR = 371, - VAARG_old = 372, - VANEXT_old = 373, - EQ = 374, - NE = 375, - SLT = 376, - SGT = 377, - SLE = 378, - SGE = 379, - ULT = 380, - UGT = 381, - ULE = 382, - UGE = 383, - OEQ = 384, - ONE = 385, - OLT = 386, - OGT = 387, - OLE = 388, - OGE = 389, - ORD = 390, - UNO = 391, - UEQ = 392, - UNE = 393, - CAST = 394, - TRUNC = 395, - ZEXT = 396, - SEXT = 397, - FPTRUNC = 398, - FPEXT = 399, - FPTOUI = 400, - FPTOSI = 401, - UITOFP = 402, - SITOFP = 403, - PTRTOINT = 404, - INTTOPTR = 405, - BITCAST = 406 - }; -#endif -/* Tokens. */ -#define ESINT64VAL 258 -#define EUINT64VAL 259 -#define SINTVAL 260 -#define UINTVAL 261 -#define FPVAL 262 -#define VOID 263 -#define BOOL 264 -#define SBYTE 265 -#define UBYTE 266 -#define SHORT 267 -#define USHORT 268 -#define INT 269 -#define UINT 270 -#define LONG 271 -#define ULONG 272 -#define FLOAT 273 -#define DOUBLE 274 -#define TYPE 275 -#define LABEL 276 -#define VAR_ID 277 -#define LABELSTR 278 -#define STRINGCONSTANT 279 -#define IMPLEMENTATION 280 -#define ZEROINITIALIZER 281 -#define TRUETOK 282 -#define FALSETOK 283 -#define BEGINTOK 284 -#define ENDTOK 285 -#define DECLARE 286 -#define GLOBAL 287 -#define CONSTANT 288 -#define SECTION 289 -#define VOLATILE 290 -#define TO 291 -#define DOTDOTDOT 292 -#define NULL_TOK 293 -#define UNDEF 294 -#define CONST 295 -#define INTERNAL 296 -#define LINKONCE 297 -#define WEAK 298 -#define APPENDING 299 -#define DLLIMPORT 300 -#define DLLEXPORT 301 -#define EXTERN_WEAK 302 -#define OPAQUE 303 -#define NOT 304 -#define EXTERNAL 305 -#define TARGET 306 -#define TRIPLE 307 -#define ENDIAN 308 -#define POINTERSIZE 309 -#define LITTLE 310 -#define BIG 311 -#define ALIGN 312 -#define DEPLIBS 313 -#define CALL 314 -#define TAIL 315 -#define ASM_TOK 316 -#define MODULE 317 -#define SIDEEFFECT 318 -#define CC_TOK 319 -#define CCC_TOK 320 -#define CSRETCC_TOK 321 -#define FASTCC_TOK 322 -#define COLDCC_TOK 323 -#define X86_STDCALLCC_TOK 324 -#define X86_FASTCALLCC_TOK 325 -#define DATALAYOUT 326 -#define RET 327 -#define BR 328 -#define SWITCH 329 -#define INVOKE 330 -#define UNREACHABLE 331 -#define UNWIND 332 -#define EXCEPT 333 -#define ADD 334 -#define SUB 335 -#define MUL 336 -#define DIV 337 -#define UDIV 338 -#define SDIV 339 -#define FDIV 340 -#define REM 341 -#define UREM 342 -#define SREM 343 -#define FREM 344 -#define AND 345 -#define OR 346 -#define XOR 347 -#define SHL 348 -#define SHR 349 -#define ASHR 350 -#define LSHR 351 -#define SETLE 352 -#define SETGE 353 -#define SETLT 354 -#define SETGT 355 -#define SETEQ 356 -#define SETNE 357 -#define ICMP 358 -#define FCMP 359 -#define MALLOC 360 -#define ALLOCA 361 -#define FREE 362 -#define LOAD 363 -#define STORE 364 -#define GETELEMENTPTR 365 -#define PHI_TOK 366 -#define SELECT 367 -#define VAARG 368 -#define EXTRACTELEMENT 369 -#define INSERTELEMENT 370 -#define SHUFFLEVECTOR 371 -#define VAARG_old 372 -#define VANEXT_old 373 -#define EQ 374 -#define NE 375 -#define SLT 376 -#define SGT 377 -#define SLE 378 -#define SGE 379 -#define ULT 380 -#define UGT 381 -#define ULE 382 -#define UGE 383 -#define OEQ 384 -#define ONE 385 -#define OLT 386 -#define OGT 387 -#define OLE 388 -#define OGE 389 -#define ORD 390 -#define UNO 391 -#define UEQ 392 -#define UNE 393 -#define CAST 394 -#define TRUNC 395 -#define ZEXT 396 -#define SEXT 397 -#define FPTRUNC 398 -#define FPEXT 399 -#define FPTOUI 400 -#define FPTOSI 401 -#define UITOFP 402 -#define SITOFP 403 -#define PTRTOINT 404 -#define INTTOPTR 405 -#define BITCAST 406 - - - - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 1454 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y" -typedef union YYSTYPE { +typedef union { llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair *ArgVal; @@ -377,14 +39,155 @@ llvm::FCmpInst::Predicate FPred; llvm::Module::Endianness Endianness; } YYSTYPE; -/* Line 1447 of yacc.c. */ -#line 382 "UpgradeParser.tab.h" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE Upgradelval; - +#define ESINT64VAL 257 +#define EUINT64VAL 258 +#define SINTVAL 259 +#define UINTVAL 260 +#define FPVAL 261 +#define VOID 262 +#define BOOL 263 +#define SBYTE 264 +#define UBYTE 265 +#define SHORT 266 +#define USHORT 267 +#define INT 268 +#define UINT 269 +#define LONG 270 +#define ULONG 271 +#define FLOAT 272 +#define DOUBLE 273 +#define TYPE 274 +#define LABEL 275 +#define VAR_ID 276 +#define LABELSTR 277 +#define STRINGCONSTANT 278 +#define IMPLEMENTATION 279 +#define ZEROINITIALIZER 280 +#define TRUETOK 281 +#define FALSETOK 282 +#define BEGINTOK 283 +#define ENDTOK 284 +#define DECLARE 285 +#define GLOBAL 286 +#define CONSTANT 287 +#define SECTION 288 +#define VOLATILE 289 +#define TO 290 +#define DOTDOTDOT 291 +#define NULL_TOK 292 +#define UNDEF 293 +#define CONST 294 +#define INTERNAL 295 +#define LINKONCE 296 +#define WEAK 297 +#define APPENDING 298 +#define DLLIMPORT 299 +#define DLLEXPORT 300 +#define EXTERN_WEAK 301 +#define OPAQUE 302 +#define NOT 303 +#define EXTERNAL 304 +#define TARGET 305 +#define TRIPLE 306 +#define ENDIAN 307 +#define POINTERSIZE 308 +#define LITTLE 309 +#define BIG 310 +#define ALIGN 311 +#define DEPLIBS 312 +#define CALL 313 +#define TAIL 314 +#define ASM_TOK 315 +#define MODULE 316 +#define SIDEEFFECT 317 +#define CC_TOK 318 +#define CCC_TOK 319 +#define CSRETCC_TOK 320 +#define FASTCC_TOK 321 +#define COLDCC_TOK 322 +#define X86_STDCALLCC_TOK 323 +#define X86_FASTCALLCC_TOK 324 +#define DATALAYOUT 325 +#define RET 326 +#define BR 327 +#define SWITCH 328 +#define INVOKE 329 +#define UNREACHABLE 330 +#define UNWIND 331 +#define EXCEPT 332 +#define ADD 333 +#define SUB 334 +#define MUL 335 +#define DIV 336 +#define UDIV 337 +#define SDIV 338 +#define FDIV 339 +#define REM 340 +#define UREM 341 +#define SREM 342 +#define FREM 343 +#define AND 344 +#define OR 345 +#define XOR 346 +#define SHL 347 +#define SHR 348 +#define ASHR 349 +#define LSHR 350 +#define SETLE 351 +#define SETGE 352 +#define SETLT 353 +#define SETGT 354 +#define SETEQ 355 +#define SETNE 356 +#define ICMP 357 +#define FCMP 358 +#define MALLOC 359 +#define ALLOCA 360 +#define FREE 361 +#define LOAD 362 +#define STORE 363 +#define GETELEMENTPTR 364 +#define PHI_TOK 365 +#define SELECT 366 +#define VAARG 367 +#define EXTRACTELEMENT 368 +#define INSERTELEMENT 369 +#define SHUFFLEVECTOR 370 +#define VAARG_old 371 +#define VANEXT_old 372 +#define EQ 373 +#define NE 374 +#define SLT 375 +#define SGT 376 +#define SLE 377 +#define SGE 378 +#define ULT 379 +#define UGT 380 +#define ULE 381 +#define UGE 382 +#define OEQ 383 +#define ONE 384 +#define OLT 385 +#define OGT 386 +#define OLE 387 +#define OGE 388 +#define ORD 389 +#define UNO 390 +#define UEQ 391 +#define UNE 392 +#define CAST 393 +#define TRUNC 394 +#define ZEXT 395 +#define SEXT 396 +#define FPTRUNC 397 +#define FPEXT 398 +#define FPTOUI 399 +#define FPTOSI 400 +#define UITOFP 401 +#define SITOFP 402 +#define PTRTOINT 403 +#define INTTOPTR 404 +#define BITCAST 405 +extern YYSTYPE Upgradelval; Index: llvm/tools/llvm-upgrade/UpgradeParser.y diff -u llvm/tools/llvm-upgrade/UpgradeParser.y:1.67 llvm/tools/llvm-upgrade/UpgradeParser.y:1.68 --- llvm/tools/llvm-upgrade/UpgradeParser.y:1.67 Wed Feb 14 21:39:18 2007 +++ llvm/tools/llvm-upgrade/UpgradeParser.y Mon Feb 19 01:34:02 2007 @@ -2235,7 +2235,7 @@ upgradeGEPIndices($3.C->getType(), $4, VIndices, &CIndices); delete $4; - $$.C = ConstantExpr::getGetElementPtr($3.C, CIndices); + $$.C = ConstantExpr::getGetElementPtr($3.C, &CIndices[0], CIndices.size()); $$.S = Signless; } | SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' { Index: llvm/tools/llvm-upgrade/UpgradeParser.y.cvs diff -u llvm/tools/llvm-upgrade/UpgradeParser.y.cvs:1.62 llvm/tools/llvm-upgrade/UpgradeParser.y.cvs:1.63 --- llvm/tools/llvm-upgrade/UpgradeParser.y.cvs:1.62 Wed Feb 14 20:26:10 2007 +++ llvm/tools/llvm-upgrade/UpgradeParser.y.cvs Mon Feb 19 01:34:02 2007 @@ -999,7 +999,7 @@ // types of its operands. bool isFP = Ty->isFloatingPoint(); if (const VectorType* PTy = dyn_cast(Ty)) - // If its a packed type we want to use the element type + // If its a vector type we want to use the element type isFP = PTy->getElementType()->isFloatingPoint(); if (isFP) return Instruction::FDiv; @@ -1015,7 +1015,7 @@ // types of its operands. bool isFP = Ty->isFloatingPoint(); if (const VectorType* PTy = dyn_cast(Ty)) - // If its a packed type we want to use the element type + // If its a vector type we want to use the element type isFP = PTy->getElementType()->isFloatingPoint(); // Select correct opcode if (isFP) @@ -1841,7 +1841,7 @@ $$.S = $4.S; delete $4.PAT; } - | '<' EUINT64VAL 'x' UpRTypes '>' { // Packed array type? + | '<' EUINT64VAL 'x' UpRTypes '>' { // Vector type? const llvm::Type* ElemTy = $4.PAT->get(); if ((unsigned)$2 != $2) error("Unsigned result not equal to signed result"); @@ -2235,7 +2235,7 @@ upgradeGEPIndices($3.C->getType(), $4, VIndices, &CIndices); delete $4; - $$.C = ConstantExpr::getGetElementPtr($3.C, CIndices); + $$.C = ConstantExpr::getGetElementPtr($3.C, &CIndices[0], CIndices.size()); $$.S = Signless; } | SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' { @@ -3112,7 +3112,7 @@ error("Arithmetic operator requires integer, FP, or packed operands"); if (isa(Ty) && ($1 == URemOp || $1 == SRemOp || $1 == FRemOp || $1 == RemOp)) - error("Remainder not supported on packed types"); + error("Remainder not supported on vector types"); // Upgrade the opcode from obsolete versions before we do anything with it. Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $2.S); Value* val1 = getVal(Ty, $3); From sabre at nondot.org Mon Feb 19 01:35:04 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:35:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp RSProfiling.cpp Message-ID: <200702190735.l1J7Z434027616@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: ProfilingUtils.cpp updated: 1.15 -> 1.16 RSProfiling.cpp updated: 1.19 -> 1.20 --- Log message: eliminate use of deprecated apis --- Diffs of the changes: (+6 -3) ProfilingUtils.cpp | 6 ++++-- RSProfiling.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp diff -u llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp:1.15 llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp:1.16 --- llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp:1.15 Mon Feb 12 20:10:56 2007 +++ llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Feb 19 01:34:47 2007 @@ -43,7 +43,8 @@ std::vector GEPIndices(2, Constant::getNullValue(Type::Int32Ty)); unsigned NumElements = 0; if (Array) { - Args[2] = ConstantExpr::getGetElementPtr(Array, GEPIndices); + Args[2] = ConstantExpr::getGetElementPtr(Array, &GEPIndices[0], + GEPIndices.size()); NumElements = cast(Array->getType()->getElementType())->getNumElements(); } else { @@ -106,7 +107,8 @@ std::vector Indices(2); Indices[0] = Constant::getNullValue(Type::Int32Ty); Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum); - Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices); + Constant *ElementPtr = + ConstantExpr::getGetElementPtr(CounterArray, &Indices[0], Indices.size()); // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos); Index: llvm/lib/Transforms/Instrumentation/RSProfiling.cpp diff -u llvm/lib/Transforms/Instrumentation/RSProfiling.cpp:1.19 llvm/lib/Transforms/Instrumentation/RSProfiling.cpp:1.20 --- llvm/lib/Transforms/Instrumentation/RSProfiling.cpp:1.19 Mon Feb 5 17:32:05 2007 +++ llvm/lib/Transforms/Instrumentation/RSProfiling.cpp Mon Feb 19 01:34:47 2007 @@ -335,7 +335,8 @@ std::vector Indices(2); Indices[0] = Constant::getNullValue(Type::Int32Ty); Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum); - Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices); + Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, + &Indices[0], 2); // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos); From sabre at nondot.org Mon Feb 19 01:35:06 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:35:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerInvoke.cpp Message-ID: <200702190735.l1J7Z68o027621@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: LowerInvoke.cpp updated: 1.54 -> 1.55 --- Log message: eliminate use of deprecated apis --- Diffs of the changes: (+2 -2) LowerInvoke.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.54 llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.55 --- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.54 Mon Feb 12 20:10:56 2007 +++ llvm/lib/Transforms/Utils/LowerInvoke.cpp Mon Feb 19 01:34:47 2007 @@ -166,7 +166,7 @@ GlobalValue::InternalLinkage, Msg, "abortmsg", M); std::vector GEPIdx(2, Constant::getNullValue(Type::Int32Ty)); - AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx); + AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); } else { // The abort message for cheap EH support tells the user that EH is not // enabled. @@ -179,7 +179,7 @@ GlobalValue::InternalLinkage, Msg, "abortmsg", M); std::vector GEPIdx(2, Constant::getNullValue(Type::Int32Ty)); - AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx); + AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); } } From sabre at nondot.org Mon Feb 19 01:41:47 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:41:47 -0600 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200702190741.l1J7flBN027780@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.88 -> 1.89 --- Log message: remove use of deprecated apis --- Diffs of the changes: (+1 -2) Miscompilation.cpp | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.88 llvm/tools/bugpoint/Miscompilation.cpp:1.89 --- llvm/tools/bugpoint/Miscompilation.cpp:1.88 Tue Feb 13 00:05:43 2007 +++ llvm/tools/bugpoint/Miscompilation.cpp Mon Feb 19 01:41:31 2007 @@ -702,8 +702,7 @@ // GetElementPtr *funcName, ulong 0, ulong 0 std::vector GEPargs(2,Constant::getNullValue(Type::Int32Ty)); - Value *GEP = - ConstantExpr::getGetElementPtr(funcName, GEPargs); + Value *GEP = ConstantExpr::getGetElementPtr(funcName, &GEPargs[0], 2); std::vector ResolverArgs; ResolverArgs.push_back(GEP); From sabre at nondot.org Mon Feb 19 01:44:45 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:44:45 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702190744.l1J7ij34027911@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.125 -> 1.126 --- Log message: remove dead methods --- Diffs of the changes: (+0 -14) Constants.h | 14 -------------- 1 files changed, 14 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.125 llvm/include/llvm/Constants.h:1.126 --- llvm/include/llvm/Constants.h:1.125 Mon Feb 19 01:23:24 2007 +++ llvm/include/llvm/Constants.h Mon Feb 19 01:44:24 2007 @@ -550,10 +550,6 @@ /// static Constant *getSizeOf(const Type *Ty); - /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant array, - /// return a pointer to a pointer of the array element type. - static Constant *getPtrPtrFromArrayPtr(Constant *C); - /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// @@ -593,16 +589,6 @@ static Constant *getGetElementPtr(Constant *C, Value* const *IdxList, unsigned NumIdx); - // FIXME: Remove these. - static Constant *getGetElementPtr(Constant *C, - const std::vector &IdxList) { - return getGetElementPtr(C, &IdxList[0], IdxList.size()); - } - static Constant *getGetElementPtr(Constant *C, - const std::vector &IdxList) { - return getGetElementPtr(C, &IdxList[0], IdxList.size()); - } - static Constant *getExtractElement(Constant *Vec, Constant *Idx); static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx); static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask); From sabre at nondot.org Mon Feb 19 01:44:46 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:44:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702190744.l1J7ik5T027916@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.211 -> 1.212 --- Log message: remove dead methods --- Diffs of the changes: (+15 -20) Constants.cpp | 35 +++++++++++++++-------------------- 1 files changed, 15 insertions(+), 20 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.211 llvm/lib/VMCore/Constants.cpp:1.212 --- llvm/lib/VMCore/Constants.cpp:1.211 Wed Feb 14 21:39:18 2007 +++ llvm/lib/VMCore/Constants.cpp Mon Feb 19 01:44:24 2007 @@ -22,6 +22,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" +#include "llvm/ADT/SmallVector.h" #include #include using namespace llvm; @@ -482,13 +483,14 @@ Op2 = (OpNo == 2) ? Op : getOperand(2); return ConstantExpr::getShuffleVector(Op0, Op1, Op2); case Instruction::GetElementPtr: { - std::vector Ops; + SmallVector Ops; + Ops.resize(getNumOperands()); for (unsigned i = 1, e = getNumOperands(); i != e; ++i) - Ops.push_back(getOperand(i)); + Ops[i] = getOperand(i); if (OpNo == 0) - return ConstantExpr::getGetElementPtr(Op, Ops); + return ConstantExpr::getGetElementPtr(Op, &Ops[0], Ops.size()); Ops[OpNo-1] = Op; - return ConstantExpr::getGetElementPtr(getOperand(0), Ops); + return ConstantExpr::getGetElementPtr(getOperand(0), &Ops[0], Ops.size()); } default: assert(getNumOperands() == 2 && "Must be binary operator?"); @@ -535,10 +537,8 @@ return ConstantExpr::getExtractElement(Ops[0], Ops[1]); case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); - case Instruction::GetElementPtr: { - std::vector ActualOps(Ops.begin()+1, Ops.end()); - return ConstantExpr::getGetElementPtr(Ops[0], ActualOps); - } + case Instruction::GetElementPtr: + return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1); case Instruction::ICmp: case Instruction::FCmp: return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]); @@ -1578,16 +1578,10 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) { // sizeof is implemented as: (ulong) gep (Ty*)null, 1 - return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue( - PointerType::get(Ty)), std::vector(1, - ConstantInt::get(Type::Int32Ty, 1))), Type::Int64Ty); -} - -Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { - // pointer from array is implemented as: getelementptr arr ptr, 0, 0 - static std::vector Indices(2, ConstantInt::get(Type::Int32Ty, 0)); - - return ConstantExpr::getGetElementPtr(C, Indices); + Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1); + Constant *GEP = + getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1); + return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty); } Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, @@ -2029,7 +2023,7 @@ Constant *Replacement = 0; if (getOpcode() == Instruction::GetElementPtr) { - std::vector Indices; + SmallVector Indices; Constant *Pointer = getOperand(0); Indices.reserve(getNumOperands()-1); if (Pointer == From) Pointer = To; @@ -2039,7 +2033,8 @@ if (Val == From) Val = To; Indices.push_back(Val); } - Replacement = ConstantExpr::getGetElementPtr(Pointer, Indices); + Replacement = ConstantExpr::getGetElementPtr(Pointer, + &Indices[0], Indices.size()); } else if (isCast()) { assert(getOperand(0) == From && "Cast only has one use!"); Replacement = ConstantExpr::getCast(getOpcode(), To, getType()); From sabre at nondot.org Mon Feb 19 01:44:44 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 01:44:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.cpp.cvs llvmAsmParser.h.cvs llvmAsmParser.y.cvs Message-ID: <200702190744.l1J7iixE027905@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.cpp.cvs updated: 1.69 -> 1.70 llvmAsmParser.h.cvs updated: 1.55 -> 1.56 llvmAsmParser.y.cvs updated: 1.70 -> 1.71 --- Log message: remove dead methods --- Diffs of the changes: (+3204 -4279) llvmAsmParser.cpp.cvs | 7026 +++++++++++++++++++++----------------------------- llvmAsmParser.h.cvs | 439 --- llvmAsmParser.y.cvs | 18 3 files changed, 3204 insertions(+), 4279 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.cpp.cvs diff -u llvm/lib/AsmParser/llvmAsmParser.cpp.cvs:1.69 llvm/lib/AsmParser/llvmAsmParser.cpp.cvs:1.70 --- llvm/lib/AsmParser/llvmAsmParser.cpp.cvs:1.69 Wed Feb 14 20:26:09 2007 +++ llvm/lib/AsmParser/llvmAsmParser.cpp.cvs Mon Feb 19 01:44:24 2007 @@ -1,336 +1,147 @@ -/* A Bison parser, made by GNU Bison 2.1. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y + by GNU Bison version 1.28 */ - 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 2, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.1" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Using locations. */ -#define YYLSP_NEEDED 0 +#define YYBISON 1 /* Identify Bison output. */ -/* Substitute the variable and function names. */ #define yyparse llvmAsmparse -#define yylex llvmAsmlex +#define yylex llvmAsmlex #define yyerror llvmAsmerror -#define yylval llvmAsmlval -#define yychar llvmAsmchar +#define yylval llvmAsmlval +#define yychar llvmAsmchar #define yydebug llvmAsmdebug #define yynerrs llvmAsmnerrs +#define ESINT64VAL 257 +#define EUINT64VAL 258 +#define LOCALVAL_ID 259 +#define GLOBALVAL_ID 260 +#define FPVAL 261 +#define VOID 262 +#define INTTYPE 263 +#define FLOAT 264 +#define DOUBLE 265 +#define LABEL 266 +#define TYPE 267 +#define LOCALVAR 268 +#define GLOBALVAR 269 +#define LABELSTR 270 +#define STRINGCONSTANT 271 +#define ATSTRINGCONSTANT 272 +#define IMPLEMENTATION 273 +#define ZEROINITIALIZER 274 +#define TRUETOK 275 +#define FALSETOK 276 +#define BEGINTOK 277 +#define ENDTOK 278 +#define DECLARE 279 +#define DEFINE 280 +#define GLOBAL 281 +#define CONSTANT 282 +#define SECTION 283 +#define VOLATILE 284 +#define TO 285 +#define DOTDOTDOT 286 +#define NULL_TOK 287 +#define UNDEF 288 +#define INTERNAL 289 +#define LINKONCE 290 +#define WEAK 291 +#define APPENDING 292 +#define DLLIMPORT 293 +#define DLLEXPORT 294 +#define EXTERN_WEAK 295 +#define OPAQUE 296 +#define EXTERNAL 297 +#define TARGET 298 +#define TRIPLE 299 +#define ALIGN 300 +#define DEPLIBS 301 +#define CALL 302 +#define TAIL 303 +#define ASM_TOK 304 +#define MODULE 305 +#define SIDEEFFECT 306 +#define CC_TOK 307 +#define CCC_TOK 308 +#define FASTCC_TOK 309 +#define COLDCC_TOK 310 +#define X86_STDCALLCC_TOK 311 +#define X86_FASTCALLCC_TOK 312 +#define DATALAYOUT 313 +#define RET 314 +#define BR 315 +#define SWITCH 316 +#define INVOKE 317 +#define UNWIND 318 +#define UNREACHABLE 319 +#define ADD 320 +#define SUB 321 +#define MUL 322 +#define UDIV 323 +#define SDIV 324 +#define FDIV 325 +#define UREM 326 +#define SREM 327 +#define FREM 328 +#define AND 329 +#define OR 330 +#define XOR 331 +#define SHL 332 +#define LSHR 333 +#define ASHR 334 +#define ICMP 335 +#define FCMP 336 +#define EQ 337 +#define NE 338 +#define SLT 339 +#define SGT 340 +#define SLE 341 +#define SGE 342 +#define ULT 343 +#define UGT 344 +#define ULE 345 +#define UGE 346 +#define OEQ 347 +#define ONE 348 +#define OLT 349 +#define OGT 350 +#define OLE 351 +#define OGE 352 +#define ORD 353 +#define UNO 354 +#define UEQ 355 +#define UNE 356 +#define MALLOC 357 +#define ALLOCA 358 +#define FREE 359 +#define LOAD 360 +#define STORE 361 +#define GETELEMENTPTR 362 +#define TRUNC 363 +#define ZEXT 364 +#define SEXT 365 +#define FPTRUNC 366 +#define FPEXT 367 +#define BITCAST 368 +#define UITOFP 369 +#define SITOFP 370 +#define FPTOUI 371 +#define FPTOSI 372 +#define INTTOPTR 373 +#define PTRTOINT 374 +#define PHI_TOK 375 +#define SELECT 376 +#define VAARG 377 +#define EXTRACTELEMENT 378 +#define INSERTELEMENT 379 +#define SHUFFLEVECTOR 380 +#define NORETURN 381 +#define INREG 382 +#define SRET 383 +#define DEFAULT 384 +#define HIDDEN 385 - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ESINT64VAL = 258, - EUINT64VAL = 259, - LOCALVAL_ID = 260, - GLOBALVAL_ID = 261, - FPVAL = 262, - VOID = 263, - INTTYPE = 264, - FLOAT = 265, - DOUBLE = 266, - LABEL = 267, - TYPE = 268, - LOCALVAR = 269, - GLOBALVAR = 270, - LABELSTR = 271, - STRINGCONSTANT = 272, - ATSTRINGCONSTANT = 273, - IMPLEMENTATION = 274, - ZEROINITIALIZER = 275, - TRUETOK = 276, - FALSETOK = 277, - BEGINTOK = 278, - ENDTOK = 279, - DECLARE = 280, - DEFINE = 281, - GLOBAL = 282, - CONSTANT = 283, - SECTION = 284, - VOLATILE = 285, - TO = 286, - DOTDOTDOT = 287, - NULL_TOK = 288, - UNDEF = 289, - INTERNAL = 290, - LINKONCE = 291, - WEAK = 292, - APPENDING = 293, - DLLIMPORT = 294, - DLLEXPORT = 295, - EXTERN_WEAK = 296, - OPAQUE = 297, - EXTERNAL = 298, - TARGET = 299, - TRIPLE = 300, - ALIGN = 301, - DEPLIBS = 302, - CALL = 303, - TAIL = 304, - ASM_TOK = 305, - MODULE = 306, - SIDEEFFECT = 307, - CC_TOK = 308, - CCC_TOK = 309, - FASTCC_TOK = 310, - COLDCC_TOK = 311, - X86_STDCALLCC_TOK = 312, - X86_FASTCALLCC_TOK = 313, - DATALAYOUT = 314, - RET = 315, - BR = 316, - SWITCH = 317, - INVOKE = 318, - UNWIND = 319, - UNREACHABLE = 320, - ADD = 321, - SUB = 322, - MUL = 323, - UDIV = 324, - SDIV = 325, - FDIV = 326, - UREM = 327, - SREM = 328, - FREM = 329, - AND = 330, - OR = 331, - XOR = 332, - SHL = 333, - LSHR = 334, - ASHR = 335, - ICMP = 336, - FCMP = 337, - EQ = 338, - NE = 339, - SLT = 340, - SGT = 341, - SLE = 342, - SGE = 343, - ULT = 344, - UGT = 345, - ULE = 346, - UGE = 347, - OEQ = 348, - ONE = 349, - OLT = 350, - OGT = 351, - OLE = 352, - OGE = 353, - ORD = 354, - UNO = 355, - UEQ = 356, - UNE = 357, - MALLOC = 358, - ALLOCA = 359, - FREE = 360, - LOAD = 361, - STORE = 362, - GETELEMENTPTR = 363, - TRUNC = 364, - ZEXT = 365, - SEXT = 366, - FPTRUNC = 367, - FPEXT = 368, - BITCAST = 369, - UITOFP = 370, - SITOFP = 371, - FPTOUI = 372, - FPTOSI = 373, - INTTOPTR = 374, - PTRTOINT = 375, - PHI_TOK = 376, - SELECT = 377, - VAARG = 378, - EXTRACTELEMENT = 379, - INSERTELEMENT = 380, - SHUFFLEVECTOR = 381, - NORETURN = 382, - INREG = 383, - SRET = 384, - DEFAULT = 385, - HIDDEN = 386 - }; -#endif -/* Tokens. */ -#define ESINT64VAL 258 -#define EUINT64VAL 259 -#define LOCALVAL_ID 260 -#define GLOBALVAL_ID 261 -#define FPVAL 262 -#define VOID 263 -#define INTTYPE 264 -#define FLOAT 265 -#define DOUBLE 266 -#define LABEL 267 -#define TYPE 268 -#define LOCALVAR 269 -#define GLOBALVAR 270 -#define LABELSTR 271 -#define STRINGCONSTANT 272 -#define ATSTRINGCONSTANT 273 -#define IMPLEMENTATION 274 -#define ZEROINITIALIZER 275 -#define TRUETOK 276 -#define FALSETOK 277 -#define BEGINTOK 278 -#define ENDTOK 279 -#define DECLARE 280 -#define DEFINE 281 -#define GLOBAL 282 -#define CONSTANT 283 -#define SECTION 284 -#define VOLATILE 285 -#define TO 286 -#define DOTDOTDOT 287 -#define NULL_TOK 288 -#define UNDEF 289 -#define INTERNAL 290 -#define LINKONCE 291 -#define WEAK 292 -#define APPENDING 293 -#define DLLIMPORT 294 -#define DLLEXPORT 295 -#define EXTERN_WEAK 296 -#define OPAQUE 297 -#define EXTERNAL 298 -#define TARGET 299 -#define TRIPLE 300 -#define ALIGN 301 -#define DEPLIBS 302 -#define CALL 303 -#define TAIL 304 -#define ASM_TOK 305 -#define MODULE 306 -#define SIDEEFFECT 307 -#define CC_TOK 308 -#define CCC_TOK 309 -#define FASTCC_TOK 310 -#define COLDCC_TOK 311 -#define X86_STDCALLCC_TOK 312 -#define X86_FASTCALLCC_TOK 313 -#define DATALAYOUT 314 -#define RET 315 -#define BR 316 -#define SWITCH 317 -#define INVOKE 318 -#define UNWIND 319 -#define UNREACHABLE 320 -#define ADD 321 -#define SUB 322 -#define MUL 323 -#define UDIV 324 -#define SDIV 325 -#define FDIV 326 -#define UREM 327 -#define SREM 328 -#define FREM 329 -#define AND 330 -#define OR 331 -#define XOR 332 -#define SHL 333 -#define LSHR 334 -#define ASHR 335 -#define ICMP 336 -#define FCMP 337 -#define EQ 338 -#define NE 339 -#define SLT 340 -#define SGT 341 -#define SLE 342 -#define SGE 343 -#define ULT 344 -#define UGT 345 -#define ULE 346 -#define UGE 347 -#define OEQ 348 -#define ONE 349 -#define OLT 350 -#define OGT 351 -#define OLE 352 -#define OGE 353 -#define ORD 354 -#define UNO 355 -#define UEQ 356 -#define UNE 357 -#define MALLOC 358 -#define ALLOCA 359 -#define FREE 360 -#define LOAD 361 -#define STORE 362 -#define GETELEMENTPTR 363 -#define TRUNC 364 -#define ZEXT 365 -#define SEXT 366 -#define FPTRUNC 367 -#define FPEXT 368 -#define BITCAST 369 -#define UITOFP 370 -#define SITOFP 371 -#define FPTOUI 372 -#define FPTOSI 373 -#define INTTOPTR 374 -#define PTRTOINT 375 -#define PHI_TOK 376 -#define SELECT 377 -#define VAARG 378 -#define EXTRACTELEMENT 379 -#define INSERTELEMENT 380 -#define SHUFFLEVECTOR 381 -#define NORETURN 382 -#define INREG 383 -#define SRET 384 -#define DEFAULT 385 -#define HIDDEN 386 - - - - -/* Copy the first part of user declarations. */ -#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" #include "ParserInternals.h" #include "llvm/CallingConv.h" @@ -1217,28 +1028,8 @@ } - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" -typedef union YYSTYPE { +#line 901 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +typedef union { llvm::Module *ModuleVal; llvm::Function *FunctionVal; llvm::BasicBlock *BasicBlockVal; @@ -1283,1519 +1074,1061 @@ llvm::ICmpInst::Predicate IPredicate; llvm::FCmpInst::Predicate FPredicate; } YYSTYPE; -/* Line 196 of yacc.c. */ -#line 1288 "llvmAsmParser.tab.c" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -/* Copy the second part of user declarations. */ - - -/* Line 219 of yacc.c. */ -#line 1300 "llvmAsmParser.tab.c" - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#ifndef YY_ -# if YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -#if ! defined (yyoverflow) || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# else -# define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) -# endif -# ifdef __cplusplus -extern "C" { -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifdef __cplusplus -} -# endif -# endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#include +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short int yyss; - YYSTYPE yyvs; - }; -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +#define YYFINAL 557 +#define YYFLAG -32768 +#define YYNTBASE 146 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 385 ? yytranslate[x] : 223) + +static const short yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 136, + 137, 134, 2, 133, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 141, + 132, 142, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 138, 135, 140, 2, 2, 2, 2, 2, 145, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 139, + 2, 2, 143, 2, 144, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131 +}; -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, + 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, + 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, + 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, + 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, + 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, + 119, 122, 123, 125, 127, 130, 131, 133, 135, 137, + 139, 141, 143, 145, 147, 148, 150, 151, 153, 155, + 156, 158, 160, 162, 164, 165, 167, 169, 171, 173, + 175, 178, 180, 182, 184, 186, 187, 190, 192, 194, + 195, 198, 199, 202, 203, 207, 210, 211, 213, 214, + 218, 220, 223, 225, 227, 229, 231, 233, 235, 238, + 240, 243, 249, 255, 261, 267, 271, 274, 280, 285, + 288, 290, 292, 294, 298, 300, 304, 306, 307, 309, + 313, 318, 322, 326, 331, 336, 340, 347, 353, 356, + 359, 362, 365, 368, 371, 374, 377, 380, 383, 390, + 396, 405, 412, 419, 427, 435, 442, 451, 460, 464, + 466, 468, 470, 472, 473, 475, 478, 479, 483, 484, + 488, 492, 494, 498, 502, 503, 510, 511, 519, 520, + 528, 531, 535, 537, 541, 545, 549, 553, 555, 556, + 562, 566, 568, 572, 574, 575, 585, 587, 589, 594, + 596, 598, 601, 605, 606, 608, 610, 612, 614, 616, + 618, 620, 622, 624, 628, 630, 636, 638, 640, 642, + 644, 646, 648, 651, 654, 657, 661, 664, 665, 667, + 670, 673, 677, 687, 697, 706, 721, 723, 725, 732, + 738, 741, 748, 756, 760, 766, 767, 768, 772, 775, + 777, 783, 789, 796, 803, 808, 815, 820, 825, 832, + 839, 842, 851, 853, 855, 856, 860, 867, 871, 878, + 881, 886, 893 +}; -#endif +static const short yyrhs[] = { 66, + 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, + 0, 72, 0, 73, 0, 74, 0, 78, 0, 79, + 0, 80, 0, 75, 0, 76, 0, 77, 0, 109, + 0, 110, 0, 111, 0, 112, 0, 113, 0, 114, + 0, 115, 0, 116, 0, 117, 0, 118, 0, 119, + 0, 120, 0, 83, 0, 84, 0, 85, 0, 86, + 0, 87, 0, 88, 0, 89, 0, 90, 0, 91, + 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, + 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, + 0, 102, 0, 89, 0, 90, 0, 91, 0, 92, + 0, 21, 0, 22, 0, 9, 0, 10, 0, 11, + 0, 14, 0, 17, 0, 153, 0, 0, 153, 132, + 0, 0, 15, 0, 18, 0, 156, 132, 0, 0, + 35, 0, 37, 0, 36, 0, 38, 0, 40, 0, + 39, 0, 41, 0, 43, 0, 0, 131, 0, 0, + 39, 0, 41, 0, 0, 35, 0, 36, 0, 37, + 0, 40, 0, 0, 54, 0, 55, 0, 56, 0, + 57, 0, 58, 0, 53, 4, 0, 110, 0, 111, + 0, 128, 0, 129, 0, 0, 165, 164, 0, 127, + 0, 164, 0, 0, 167, 166, 0, 0, 46, 4, + 0, 0, 133, 46, 4, 0, 29, 17, 0, 0, + 170, 0, 0, 133, 173, 172, 0, 170, 0, 46, + 4, 0, 9, 0, 10, 0, 11, 0, 12, 0, + 42, 0, 174, 0, 175, 134, 0, 207, 0, 135, + 4, 0, 175, 136, 179, 137, 167, 0, 8, 136, + 179, 137, 167, 0, 138, 4, 139, 175, 140, 0, + 141, 4, 139, 175, 142, 0, 143, 180, 144, 0, + 143, 144, 0, 141, 143, 180, 144, 142, 0, 141, + 143, 144, 142, 0, 175, 165, 0, 175, 0, 8, + 0, 176, 0, 178, 133, 176, 0, 178, 0, 178, + 133, 32, 0, 32, 0, 0, 175, 0, 180, 133, + 175, 0, 175, 138, 183, 140, 0, 175, 138, 140, + 0, 175, 145, 17, 0, 175, 141, 183, 142, 0, + 175, 143, 183, 144, 0, 175, 143, 144, 0, 175, + 141, 143, 183, 144, 142, 0, 175, 141, 143, 144, + 142, 0, 175, 33, 0, 175, 34, 0, 175, 207, + 0, 175, 182, 0, 175, 20, 0, 151, 3, 0, + 151, 4, 0, 9, 21, 0, 9, 22, 0, 152, + 7, 0, 148, 136, 181, 31, 175, 137, 0, 108, + 136, 181, 218, 137, 0, 122, 136, 181, 133, 181, + 133, 181, 137, 0, 146, 136, 181, 133, 181, 137, + 0, 147, 136, 181, 133, 181, 137, 0, 81, 149, + 136, 181, 133, 181, 137, 0, 82, 150, 136, 181, + 133, 181, 137, 0, 124, 136, 181, 133, 181, 137, + 0, 125, 136, 181, 133, 181, 133, 181, 137, 0, + 126, 136, 181, 133, 181, 133, 181, 137, 0, 183, + 133, 181, 0, 181, 0, 27, 0, 28, 0, 186, + 0, 0, 187, 0, 186, 187, 0, 0, 26, 188, + 203, 0, 0, 25, 189, 204, 0, 51, 50, 193, + 0, 19, 0, 155, 13, 175, 0, 155, 13, 8, + 0, 0, 157, 160, 184, 181, 190, 172, 0, 0, + 157, 158, 160, 184, 181, 191, 172, 0, 0, 157, + 159, 160, 184, 175, 192, 172, 0, 44, 194, 0, + 47, 132, 195, 0, 17, 0, 45, 132, 17, 0, + 59, 132, 17, 0, 138, 196, 140, 0, 196, 133, + 17, 0, 17, 0, 0, 197, 133, 175, 165, 154, + 0, 175, 165, 154, 0, 197, 0, 197, 133, 32, + 0, 32, 0, 0, 163, 177, 156, 136, 198, 137, + 167, 171, 168, 0, 23, 0, 143, 0, 162, 160, + 199, 200, 0, 24, 0, 144, 0, 210, 202, 0, + 161, 160, 199, 0, 0, 52, 0, 3, 0, 4, + 0, 7, 0, 21, 0, 22, 0, 33, 0, 34, + 0, 20, 0, 141, 183, 142, 0, 182, 0, 50, + 205, 17, 133, 17, 0, 5, 0, 6, 0, 153, + 0, 156, 0, 207, 0, 206, 0, 175, 208, 0, + 210, 211, 0, 201, 211, 0, 212, 155, 213, 0, + 212, 215, 0, 0, 16, 0, 60, 209, 0, 60, + 8, 0, 61, 12, 208, 0, 61, 9, 208, 133, + 12, 208, 133, 12, 208, 0, 62, 151, 208, 133, + 12, 208, 138, 214, 140, 0, 62, 151, 208, 133, + 12, 208, 138, 140, 0, 63, 163, 177, 208, 136, + 217, 137, 167, 31, 12, 208, 64, 12, 208, 0, + 64, 0, 65, 0, 214, 151, 206, 133, 12, 208, + 0, 151, 206, 133, 12, 208, 0, 155, 220, 0, + 175, 138, 208, 133, 208, 140, 0, 216, 133, 138, + 208, 133, 208, 140, 0, 175, 208, 165, 0, 217, + 133, 175, 208, 165, 0, 0, 0, 218, 133, 209, + 0, 49, 48, 0, 48, 0, 146, 175, 208, 133, + 208, 0, 147, 175, 208, 133, 208, 0, 81, 149, + 175, 208, 133, 208, 0, 82, 150, 175, 208, 133, + 208, 0, 148, 209, 31, 175, 0, 122, 209, 133, + 209, 133, 209, 0, 123, 209, 133, 175, 0, 124, + 209, 133, 209, 0, 125, 209, 133, 209, 133, 209, + 0, 126, 209, 133, 209, 133, 209, 0, 121, 216, + 0, 219, 163, 177, 208, 136, 217, 137, 167, 0, + 222, 0, 30, 0, 0, 103, 175, 169, 0, 103, + 175, 133, 9, 208, 169, 0, 104, 175, 169, 0, + 104, 175, 133, 9, 208, 169, 0, 105, 209, 0, + 221, 106, 175, 208, 0, 221, 107, 209, 133, 175, + 208, 0, 108, 175, 208, 218, 0 +}; -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; #endif -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 40 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1439 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 146 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 78 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 284 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 557 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 386 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 136, 137, 134, 2, 133, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 141, 132, 142, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 138, 135, 140, 2, 2, 2, 2, 2, 145, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 139, 2, 2, 143, 2, 144, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131 +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1049, + 1049, 1049, 1049, 1049, 1049, 1050, 1050, 1050, 1050, 1050, + 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1054, 1054, 1055, + 1055, 1056, 1056, 1057, 1057, 1058, 1058, 1062, 1062, 1063, + 1063, 1064, 1064, 1065, 1065, 1066, 1066, 1067, 1067, 1068, + 1068, 1069, 1070, 1075, 1076, 1076, 1078, 1078, 1079, 1079, + 1083, 1087, 1092, 1092, 1094, 1098, 1104, 1105, 1106, 1107, + 1108, 1112, 1113, 1114, 1118, 1119, 1123, 1124, 1125, 1129, + 1130, 1131, 1132, 1133, 1136, 1136, 1137, 1138, 1139, 1140, + 1141, 1149, 1150, 1151, 1152, 1155, 1156, 1161, 1162, 1165, + 1166, 1173, 1173, 1180, 1180, 1189, 1197, 1197, 1203, 1203, + 1205, 1210, 1223, 1223, 1223, 1223, 1226, 1230, 1234, 1241, + 1246, 1254, 1272, 1290, 1295, 1307, 1317, 1321, 1331, 1338, + 1345, 1352, 1357, 1362, 1369, 1370, 1377, 1384, 1392, 1397, + 1408, 1436, 1452, 1481, 1509, 1534, 1553, 1579, 1599, 1611, + 1618, 1684, 1694, 1704, 1710, 1716, 1721, 1726, 1734, 1746, + 1768, 1776, 1782, 1793, 1798, 1803, 1809, 1815, 1824, 1828, + 1836, 1836, 1847, 1852, 1860, 1861, 1865, 1865, 1869, 1869, + 1872, 1875, 1887, 1911, 1922, 1929, 1932, 1937, 1940, 1946, + 1950, 1953, 1959, 1972, 1976, 1981, 1983, 1988, 1993, 2002, + 2012, 2023, 2027, 2036, 2045, 2050, 2162, 2162, 2164, 2173, + 2173, 2175, 2180, 2192, 2196, 2201, 2205, 2209, 2213, 2217, + 2221, 2225, 2229, 2233, 2258, 2262, 2276, 2280, 2284, 2288, + 2294, 2294, 2300, 2309, 2313, 2322, 2332, 2341, 2353, 2366, + 2370, 2374, 2379, 2389, 2408, 2417, 2484, 2488, 2495, 2506, + 2519, 2529, 2540, 2550, 2558, 2566, 2569, 2570, 2577, 2581, + 2586, 2607, 2624, 2637, 2650, 2662, 2670, 2677, 2683, 2689, + 2695, 2710, 2774, 2779, 2783, 2790, 2797, 2805, 2812, 2820, + 2828, 2842, 2859 }; +#endif -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const unsigned short int yyprhs[] = -{ - 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, - 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, - 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, - 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, - 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, - 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, - 119, 121, 122, 125, 126, 128, 130, 133, 134, 136, - 138, 140, 142, 144, 146, 148, 150, 151, 153, 154, - 156, 158, 159, 161, 163, 165, 167, 168, 170, 172, - 174, 176, 178, 181, 183, 185, 187, 189, 190, 193, - 195, 197, 198, 201, 202, 205, 206, 210, 213, 214, - 216, 217, 221, 223, 226, 228, 230, 232, 234, 236, - 238, 241, 243, 246, 252, 258, 264, 270, 274, 277, - 283, 288, 291, 293, 295, 297, 301, 303, 307, 309, - 310, 312, 316, 321, 325, 329, 334, 339, 343, 350, - 356, 359, 362, 365, 368, 371, 374, 377, 380, 383, - 386, 393, 399, 408, 415, 422, 430, 438, 445, 454, - 463, 467, 469, 471, 473, 475, 476, 478, 481, 482, - 486, 487, 491, 495, 497, 501, 505, 506, 513, 514, - 522, 523, 531, 534, 538, 540, 544, 548, 552, 556, - 558, 559, 565, 569, 571, 575, 577, 578, 588, 590, - 592, 597, 599, 601, 604, 608, 609, 611, 613, 615, - 617, 619, 621, 623, 625, 627, 631, 633, 639, 641, - 643, 645, 647, 649, 651, 654, 657, 660, 664, 667, - 668, 670, 673, 676, 680, 690, 700, 709, 724, 726, - 728, 735, 741, 744, 751, 759, 763, 769, 770, 771, - 775, 778, 780, 786, 792, 799, 806, 811, 818, 823, - 828, 835, 842, 845, 854, 856, 858, 859, 863, 870, - 874, 881, 884, 889, 896 -}; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short int yyrhs[] = -{ - 186, 0, -1, 66, -1, 67, -1, 68, -1, 69, - -1, 70, -1, 71, -1, 72, -1, 73, -1, 74, - -1, 78, -1, 79, -1, 80, -1, 75, -1, 76, - -1, 77, -1, 109, -1, 110, -1, 111, -1, 112, - -1, 113, -1, 114, -1, 115, -1, 116, -1, 117, - -1, 118, -1, 119, -1, 120, -1, 83, -1, 84, - -1, 85, -1, 86, -1, 87, -1, 88, -1, 89, - -1, 90, -1, 91, -1, 92, -1, 93, -1, 94, - -1, 95, -1, 96, -1, 97, -1, 98, -1, 99, - -1, 100, -1, 101, -1, 102, -1, 89, -1, 90, - -1, 91, -1, 92, -1, 21, -1, 22, -1, 9, - -1, 10, -1, 11, -1, 14, -1, 17, -1, 154, - -1, -1, 154, 132, -1, -1, 15, -1, 18, -1, - 157, 132, -1, -1, 35, -1, 37, -1, 36, -1, - 38, -1, 40, -1, 39, -1, 41, -1, 43, -1, - -1, 131, -1, -1, 39, -1, 41, -1, -1, 35, - -1, 36, -1, 37, -1, 40, -1, -1, 54, -1, - 55, -1, 56, -1, 57, -1, 58, -1, 53, 4, - -1, 110, -1, 111, -1, 128, -1, 129, -1, -1, - 166, 165, -1, 127, -1, 165, -1, -1, 168, 167, - -1, -1, 46, 4, -1, -1, 133, 46, 4, -1, - 29, 17, -1, -1, 171, -1, -1, 133, 174, 173, - -1, 171, -1, 46, 4, -1, 9, -1, 10, -1, - 11, -1, 12, -1, 42, -1, 175, -1, 176, 134, - -1, 208, -1, 135, 4, -1, 176, 136, 180, 137, - 168, -1, 8, 136, 180, 137, 168, -1, 138, 4, - 139, 176, 140, -1, 141, 4, 139, 176, 142, -1, - 143, 181, 144, -1, 143, 144, -1, 141, 143, 181, - 144, 142, -1, 141, 143, 144, 142, -1, 176, 166, - -1, 176, -1, 8, -1, 177, -1, 179, 133, 177, - -1, 179, -1, 179, 133, 32, -1, 32, -1, -1, - 176, -1, 181, 133, 176, -1, 176, 138, 184, 140, - -1, 176, 138, 140, -1, 176, 145, 17, -1, 176, - 141, 184, 142, -1, 176, 143, 184, 144, -1, 176, - 143, 144, -1, 176, 141, 143, 184, 144, 142, -1, - 176, 141, 143, 144, 142, -1, 176, 33, -1, 176, - 34, -1, 176, 208, -1, 176, 183, -1, 176, 20, - -1, 152, 3, -1, 152, 4, -1, 9, 21, -1, - 9, 22, -1, 153, 7, -1, 149, 136, 182, 31, - 176, 137, -1, 108, 136, 182, 219, 137, -1, 122, - 136, 182, 133, 182, 133, 182, 137, -1, 147, 136, - 182, 133, 182, 137, -1, 148, 136, 182, 133, 182, - 137, -1, 81, 150, 136, 182, 133, 182, 137, -1, - 82, 151, 136, 182, 133, 182, 137, -1, 124, 136, - 182, 133, 182, 137, -1, 125, 136, 182, 133, 182, - 133, 182, 137, -1, 126, 136, 182, 133, 182, 133, - 182, 137, -1, 184, 133, 182, -1, 182, -1, 27, - -1, 28, -1, 187, -1, -1, 188, -1, 187, 188, - -1, -1, 26, 189, 204, -1, -1, 25, 190, 205, - -1, 51, 50, 194, -1, 19, -1, 156, 13, 176, - -1, 156, 13, 8, -1, -1, 158, 161, 185, 182, - 191, 173, -1, -1, 158, 159, 161, 185, 182, 192, - 173, -1, -1, 158, 160, 161, 185, 176, 193, 173, - -1, 44, 195, -1, 47, 132, 196, -1, 17, -1, - 45, 132, 17, -1, 59, 132, 17, -1, 138, 197, - 140, -1, 197, 133, 17, -1, 17, -1, -1, 198, - 133, 176, 166, 155, -1, 176, 166, 155, -1, 198, - -1, 198, 133, 32, -1, 32, -1, -1, 164, 178, - 157, 136, 199, 137, 168, 172, 169, -1, 23, -1, - 143, -1, 163, 161, 200, 201, -1, 24, -1, 144, - -1, 211, 203, -1, 162, 161, 200, -1, -1, 52, - -1, 3, -1, 4, -1, 7, -1, 21, -1, 22, - -1, 33, -1, 34, -1, 20, -1, 141, 184, 142, - -1, 183, -1, 50, 206, 17, 133, 17, -1, 5, - -1, 6, -1, 154, -1, 157, -1, 208, -1, 207, - -1, 176, 209, -1, 211, 212, -1, 202, 212, -1, - 213, 156, 214, -1, 213, 216, -1, -1, 16, -1, - 60, 210, -1, 60, 8, -1, 61, 12, 209, -1, - 61, 9, 209, 133, 12, 209, 133, 12, 209, -1, - 62, 152, 209, 133, 12, 209, 138, 215, 140, -1, - 62, 152, 209, 133, 12, 209, 138, 140, -1, 63, - 164, 178, 209, 136, 218, 137, 168, 31, 12, 209, - 64, 12, 209, -1, 64, -1, 65, -1, 215, 152, - 207, 133, 12, 209, -1, 152, 207, 133, 12, 209, - -1, 156, 221, -1, 176, 138, 209, 133, 209, 140, - -1, 217, 133, 138, 209, 133, 209, 140, -1, 176, - 209, 166, -1, 218, 133, 176, 209, 166, -1, -1, - -1, 219, 133, 210, -1, 49, 48, -1, 48, -1, - 147, 176, 209, 133, 209, -1, 148, 176, 209, 133, - 209, -1, 81, 150, 176, 209, 133, 209, -1, 82, - 151, 176, 209, 133, 209, -1, 149, 210, 31, 176, - -1, 122, 210, 133, 210, 133, 210, -1, 123, 210, - 133, 176, -1, 124, 210, 133, 210, -1, 125, 210, - 133, 210, 133, 210, -1, 126, 210, 133, 210, 133, - 210, -1, 121, 217, -1, 220, 164, 178, 209, 136, - 218, 137, 168, -1, 223, -1, 30, -1, -1, 103, - 176, 170, -1, 103, 176, 133, 9, 209, 170, -1, - 104, 176, 170, -1, 104, 176, 133, 9, 209, 170, - -1, 105, 210, -1, 222, 106, 176, 209, -1, 222, - 107, 210, 133, 176, 209, -1, 108, 176, 209, 219, - -1 -}; +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = -{ - 0, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1049, 1049, 1049, 1049, 1049, 1049, 1050, 1050, 1050, - 1050, 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1051, 1054, - 1054, 1055, 1055, 1056, 1056, 1057, 1057, 1058, 1058, 1062, - 1062, 1063, 1063, 1064, 1064, 1065, 1065, 1066, 1066, 1067, - 1067, 1068, 1068, 1069, 1070, 1075, 1076, 1076, 1078, 1078, - 1079, 1079, 1083, 1087, 1092, 1092, 1094, 1098, 1104, 1105, - 1106, 1107, 1108, 1112, 1113, 1114, 1118, 1119, 1123, 1124, - 1125, 1129, 1130, 1131, 1132, 1133, 1136, 1137, 1138, 1139, - 1140, 1141, 1142, 1149, 1150, 1151, 1152, 1155, 1156, 1161, - 1162, 1165, 1166, 1173, 1174, 1180, 1181, 1189, 1197, 1198, - 1203, 1204, 1205, 1210, 1223, 1223, 1223, 1223, 1226, 1230, - 1234, 1241, 1246, 1254, 1272, 1290, 1295, 1307, 1317, 1321, - 1331, 1338, 1345, 1352, 1357, 1362, 1369, 1370, 1377, 1384, - 1392, 1397, 1408, 1436, 1452, 1481, 1509, 1534, 1553, 1578, - 1597, 1609, 1616, 1682, 1692, 1702, 1708, 1714, 1719, 1724, - 1732, 1744, 1766, 1774, 1780, 1791, 1796, 1801, 1807, 1813, - 1822, 1826, 1834, 1834, 1845, 1850, 1858, 1859, 1863, 1863, - 1867, 1867, 1870, 1873, 1885, 1909, 1920, 1920, 1930, 1930, - 1938, 1938, 1948, 1951, 1957, 1970, 1974, 1979, 1981, 1986, - 1991, 2000, 2010, 2021, 2025, 2034, 2043, 2048, 2160, 2160, - 2162, 2171, 2171, 2173, 2178, 2190, 2194, 2199, 2203, 2207, - 2211, 2215, 2219, 2223, 2227, 2231, 2256, 2260, 2274, 2278, - 2282, 2286, 2292, 2292, 2298, 2307, 2311, 2320, 2330, 2339, - 2351, 2364, 2368, 2372, 2377, 2387, 2406, 2415, 2482, 2486, - 2493, 2504, 2517, 2527, 2538, 2548, 2556, 2564, 2567, 2568, - 2575, 2579, 2584, 2605, 2622, 2635, 2648, 2660, 2668, 2675, - 2681, 2687, 2693, 2708, 2772, 2777, 2781, 2788, 2795, 2803, - 2810, 2818, 2826, 2840, 2857 +static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", +"EUINT64VAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL","VOID","INTTYPE","FLOAT","DOUBLE", +"LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT", +"IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK", +"DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO","DOTDOTDOT", +"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT", +"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL", +"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK", +"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE", +"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM", +"FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT", +"SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD", +"UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC", +"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI", +"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT", +"SHUFFLEVECTOR","NORETURN","INREG","SRET","DEFAULT","HIDDEN","'='","','","'*'", +"'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps", +"LogicalOps","CastOps","IPredicates","FPredicates","IntType","FPType","LocalName", +"OptLocalName","OptLocalAssign","GlobalName","OptGlobalAssign","GVInternalLinkage", +"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage", +"OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs","OptAlign", +"OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute", +"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI", +"ConstVal","ConstExpr","ConstVector","GlobalType","Module","DefinitionList", +"Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition", +"LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END", +"Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", +"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", +"JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", +"OptVolatile","MemoryInst", NULL }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", - "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", "FLOAT", - "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR", - "STRINGCONSTANT", "ATSTRINGCONSTANT", "IMPLEMENTATION", - "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", - "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", - "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", - "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", - "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", - "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", - "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", - "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", - "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", - "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", - "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", - "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", - "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", - "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", - "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", - "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "DEFAULT", - "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", - "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", - "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType", - "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName", - "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage", - "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage", - "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr", - "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection", - "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types", - "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI", - "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module", - "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", - "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH", - "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", - "Function", "FunctionProto", "OptSideEffect", "ConstValueRef", - "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList", - "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", - "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal", - "OptVolatile", "MemoryInst", 0 +static const short yyr1[] = { 0, + 146, 146, 146, 146, 146, 146, 146, 146, 146, 147, + 147, 147, 147, 147, 147, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 148, 148, 148, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 151, 152, 152, 153, 153, 154, 154, + 155, 155, 156, 156, 157, 157, 158, 158, 158, 158, + 158, 159, 159, 159, 160, 160, 161, 161, 161, 162, + 162, 162, 162, 162, 163, 163, 163, 163, 163, 163, + 163, 164, 164, 164, 164, 165, 165, 166, 166, 167, + 167, 168, 168, 169, 169, 170, 171, 171, 172, 172, + 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, + 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, + 177, 177, 178, 178, 179, 179, 179, 179, 180, 180, + 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, + 181, 181, 181, 181, 181, 181, 181, 181, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 183, 183, + 184, 184, 185, 185, 186, 186, 188, 187, 189, 187, + 187, 187, 187, 187, 190, 187, 191, 187, 192, 187, + 187, 187, 193, 194, 194, 195, 196, 196, 196, 197, + 197, 198, 198, 198, 198, 199, 200, 200, 201, 202, + 202, 203, 204, 205, 205, 206, 206, 206, 206, 206, + 206, 206, 206, 206, 206, 206, 207, 207, 207, 207, + 208, 208, 209, 210, 210, 211, 212, 212, 212, 213, + 213, 213, 213, 213, 213, 213, 213, 213, 214, 214, + 215, 216, 216, 217, 217, 217, 218, 218, 219, 219, + 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + 220, 220, 220, 221, 221, 222, 222, 222, 222, 222, + 222, 222, 222 }; -#endif -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, - 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, - 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, - 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 61, 44, 42, 92, 40, 41, 91, 120, - 93, 60, 62, 123, 125, 99 +static const short yyr2[] = { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 2, 0, 1, 1, 2, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, + 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, + 2, 1, 1, 1, 1, 0, 2, 1, 1, 0, + 2, 0, 2, 0, 3, 2, 0, 1, 0, 3, + 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, + 2, 5, 5, 5, 5, 3, 2, 5, 4, 2, + 1, 1, 1, 3, 1, 3, 1, 0, 1, 3, + 4, 3, 3, 4, 4, 3, 6, 5, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, + 8, 6, 6, 7, 7, 6, 8, 8, 3, 1, + 1, 1, 1, 0, 1, 2, 0, 3, 0, 3, + 3, 1, 3, 3, 0, 6, 0, 7, 0, 7, + 2, 3, 1, 3, 3, 3, 3, 1, 0, 5, + 3, 1, 3, 1, 0, 9, 1, 1, 4, 1, + 1, 2, 3, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 3, 2, 0, 1, 2, + 2, 3, 9, 9, 8, 14, 1, 1, 6, 5, + 2, 6, 7, 3, 5, 0, 0, 3, 2, 1, + 5, 5, 6, 6, 4, 6, 4, 4, 6, 6, + 2, 8, 1, 1, 0, 3, 6, 3, 6, 2, + 4, 6, 4 }; -# endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = -{ - 0, 146, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 148, 148, 148, 148, 148, 148, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 152, 153, 153, 154, 154, - 155, 155, 156, 156, 157, 157, 158, 158, 159, 159, - 159, 159, 159, 160, 160, 160, 161, 161, 162, 162, - 162, 163, 163, 163, 163, 163, 164, 164, 164, 164, - 164, 164, 164, 165, 165, 165, 165, 166, 166, 167, - 167, 168, 168, 169, 169, 170, 170, 171, 172, 172, - 173, 173, 174, 174, 175, 175, 175, 175, 176, 176, - 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, - 176, 177, 178, 178, 179, 179, 180, 180, 180, 180, - 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, - 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, - 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, - 184, 184, 185, 185, 186, 186, 187, 187, 189, 188, - 190, 188, 188, 188, 188, 188, 191, 188, 192, 188, - 193, 188, 188, 188, 194, 195, 195, 196, 197, 197, - 197, 198, 198, 199, 199, 199, 199, 200, 201, 201, - 202, 203, 203, 204, 205, 206, 206, 207, 207, 207, - 207, 207, 207, 207, 207, 207, 207, 207, 208, 208, - 208, 208, 209, 209, 210, 211, 211, 212, 213, 213, - 213, 214, 214, 214, 214, 214, 214, 214, 214, 214, - 215, 215, 216, 217, 217, 218, 218, 218, 219, 219, - 220, 220, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 222, 222, 223, 223, 223, - 223, 223, 223, 223, 223 +static const short yydefact[] = { 66, + 57, 63, 58, 64, 182, 179, 177, 0, 0, 0, + 0, 0, 0, 75, 66, 175, 77, 80, 0, 0, + 191, 0, 0, 61, 0, 65, 67, 69, 68, 70, + 72, 71, 73, 74, 76, 75, 75, 0, 176, 78, + 79, 75, 180, 81, 82, 83, 84, 75, 238, 178, + 238, 0, 0, 199, 192, 193, 181, 227, 228, 184, + 113, 114, 115, 116, 117, 0, 0, 0, 0, 229, + 230, 118, 183, 120, 0, 0, 171, 172, 0, 85, + 85, 239, 235, 62, 210, 211, 212, 234, 194, 195, + 198, 0, 138, 121, 0, 0, 0, 0, 127, 139, + 0, 119, 138, 0, 0, 113, 114, 115, 0, 0, + 0, 185, 0, 86, 87, 88, 89, 90, 0, 213, + 0, 275, 237, 0, 196, 137, 96, 133, 135, 0, + 0, 0, 0, 0, 0, 126, 0, 187, 189, 156, + 157, 154, 155, 158, 153, 149, 150, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 13, 14, 15, 10, + 11, 12, 0, 0, 0, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 152, 151, + 109, 91, 132, 131, 0, 207, 208, 209, 274, 260, + 0, 0, 0, 0, 85, 247, 248, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 236, 85, 251, 0, 273, 197, 130, 0, + 100, 0, 0, 129, 0, 140, 100, 109, 109, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 0, + 52, 53, 48, 49, 50, 51, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 0, 0, 0, 0, + 0, 0, 142, 170, 0, 0, 0, 146, 0, 143, + 0, 0, 0, 0, 186, 0, 259, 241, 0, 240, + 0, 0, 54, 0, 0, 0, 0, 104, 104, 280, + 0, 0, 271, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 92, 93, 94, 95, 97, 136, + 134, 123, 124, 125, 128, 122, 188, 190, 0, 0, + 257, 0, 0, 0, 0, 0, 141, 127, 139, 0, + 144, 145, 0, 0, 0, 0, 0, 111, 109, 205, + 216, 217, 218, 223, 219, 220, 221, 222, 214, 0, + 225, 232, 231, 233, 0, 242, 0, 0, 0, 0, + 0, 276, 0, 278, 257, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 98, 99, + 101, 0, 0, 0, 0, 0, 0, 0, 169, 148, + 0, 0, 0, 0, 106, 112, 110, 204, 96, 202, + 0, 215, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 283, 0, 0, 0, 267, 268, 0, 0, + 0, 0, 265, 0, 281, 0, 0, 0, 0, 160, + 0, 0, 0, 0, 147, 0, 0, 0, 60, 0, + 100, 0, 224, 0, 0, 256, 0, 0, 104, 105, + 104, 0, 0, 0, 0, 0, 261, 262, 256, 0, + 0, 0, 258, 0, 166, 0, 0, 162, 163, 159, + 59, 201, 203, 96, 107, 0, 0, 0, 0, 0, + 263, 264, 0, 277, 279, 0, 0, 266, 269, 270, + 0, 282, 164, 165, 0, 0, 0, 60, 108, 102, + 226, 0, 0, 96, 0, 100, 252, 0, 100, 161, + 167, 168, 200, 0, 206, 0, 245, 0, 0, 254, + 0, 0, 253, 272, 103, 243, 0, 244, 0, 96, + 0, 0, 0, 255, 0, 0, 0, 0, 250, 0, + 0, 249, 0, 246, 0, 0, 0 }; -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = -{ - 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 2, 0, 1, 1, 2, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, - 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, - 1, 1, 2, 1, 1, 1, 1, 0, 2, 1, - 1, 0, 2, 0, 2, 0, 3, 2, 0, 1, - 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, - 2, 1, 2, 5, 5, 5, 5, 3, 2, 5, - 4, 2, 1, 1, 1, 3, 1, 3, 1, 0, - 1, 3, 4, 3, 3, 4, 4, 3, 6, 5, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 6, 5, 8, 6, 6, 7, 7, 6, 8, 8, - 3, 1, 1, 1, 1, 0, 1, 2, 0, 3, - 0, 3, 3, 1, 3, 3, 0, 6, 0, 7, - 0, 7, 2, 3, 1, 3, 3, 3, 3, 1, - 0, 5, 3, 1, 3, 1, 0, 9, 1, 1, - 4, 1, 1, 2, 3, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, - 1, 1, 1, 1, 2, 2, 2, 3, 2, 0, - 1, 2, 2, 3, 9, 9, 8, 14, 1, 1, - 6, 5, 2, 6, 7, 3, 5, 0, 0, 3, - 2, 1, 5, 5, 6, 6, 4, 6, 4, 4, - 6, 6, 2, 8, 1, 1, 0, 3, 6, 3, - 6, 2, 4, 6, 4 +static const short yydefgoto[] = { 186, + 187, 188, 250, 267, 109, 110, 70, 482, 12, 71, + 14, 36, 37, 38, 42, 48, 119, 319, 229, 391, + 322, 525, 372, 348, 510, 285, 349, 72, 111, 128, + 195, 129, 130, 101, 274, 361, 275, 79, 555, 15, + 16, 18, 17, 191, 238, 239, 57, 21, 55, 92, + 410, 411, 120, 198, 49, 87, 50, 43, 413, 362, + 74, 364, 290, 51, 83, 84, 223, 529, 123, 303, + 490, 394, 224, 225, 226, 227 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const unsigned short int yydefact[] = -{ - 67, 58, 64, 59, 65, 183, 180, 178, 0, 0, - 0, 0, 0, 0, 76, 0, 67, 176, 78, 81, - 0, 0, 192, 0, 0, 62, 0, 66, 68, 70, - 69, 71, 73, 72, 74, 75, 77, 76, 76, 0, - 1, 177, 79, 80, 76, 181, 82, 83, 84, 85, - 76, 239, 179, 239, 0, 0, 200, 193, 194, 182, - 228, 229, 185, 114, 115, 116, 117, 118, 0, 0, - 0, 0, 230, 231, 119, 184, 121, 0, 0, 172, - 173, 0, 86, 86, 240, 236, 63, 211, 212, 213, - 235, 195, 196, 199, 0, 139, 122, 0, 0, 0, - 0, 128, 140, 0, 120, 139, 0, 0, 114, 115, - 116, 0, 0, 0, 186, 0, 87, 88, 89, 90, - 91, 0, 214, 0, 276, 238, 0, 197, 138, 97, - 134, 136, 0, 0, 0, 0, 0, 0, 127, 0, - 188, 190, 157, 158, 155, 156, 159, 154, 150, 151, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, - 15, 16, 11, 12, 13, 0, 0, 0, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 153, 152, 110, 92, 133, 132, 0, 208, 209, - 210, 275, 261, 0, 0, 0, 0, 86, 248, 249, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 237, 86, 252, 0, 274, - 198, 131, 0, 101, 0, 0, 130, 0, 141, 101, - 110, 110, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 0, 53, 54, 49, 50, 51, 52, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, - 0, 0, 0, 0, 0, 143, 171, 0, 0, 0, - 147, 0, 144, 0, 0, 0, 0, 187, 0, 260, - 242, 0, 241, 0, 0, 55, 0, 0, 0, 0, - 105, 105, 281, 0, 0, 272, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 93, 94, 95, - 96, 98, 137, 135, 124, 125, 126, 129, 123, 189, - 191, 0, 0, 258, 0, 0, 0, 0, 0, 142, - 128, 140, 0, 145, 146, 0, 0, 0, 0, 0, - 112, 110, 206, 217, 218, 219, 224, 220, 221, 222, - 223, 215, 0, 226, 233, 232, 234, 0, 243, 0, - 0, 0, 0, 0, 277, 0, 279, 258, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 99, 100, 102, 0, 0, 0, 0, 0, 0, - 0, 170, 149, 0, 0, 0, 0, 107, 113, 111, - 205, 97, 203, 0, 216, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 284, 0, 0, 0, 268, - 269, 0, 0, 0, 0, 266, 0, 282, 0, 0, - 0, 0, 161, 0, 0, 0, 0, 148, 0, 0, - 0, 61, 0, 101, 0, 225, 0, 0, 257, 0, - 0, 105, 106, 105, 0, 0, 0, 0, 0, 262, - 263, 257, 0, 0, 0, 259, 0, 167, 0, 0, - 163, 164, 160, 60, 202, 204, 97, 108, 0, 0, - 0, 0, 0, 264, 265, 0, 278, 280, 0, 0, - 267, 270, 271, 0, 283, 165, 166, 0, 0, 0, - 61, 109, 103, 227, 0, 0, 97, 0, 101, 253, - 0, 101, 162, 168, 169, 201, 0, 207, 0, 246, - 0, 0, 255, 0, 0, 254, 273, 104, 244, 0, - 245, 0, 97, 0, 0, 0, 256, 0, 0, 0, - 0, 251, 0, 0, 250, 0, 247 +static const short yypact[] = { 438, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 27, -119, -29, + -84, 43, -57, -6, 525,-32768, 195, 140, -38, -27, +-32768, -39, 112,-32768, 828,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768, 32, 32, 227,-32768,-32768, +-32768, 32,-32768,-32768,-32768,-32768,-32768, 32, 119,-32768, + -2, 188, 210, 213,-32768,-32768,-32768,-32768,-32768, 49, +-32768,-32768,-32768,-32768,-32768, 214, 245, 5, 104,-32768, +-32768,-32768, 110,-32768, 227, 227,-32768,-32768, 1043, 154, + 154,-32768,-32768, 109,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, -89, 1085,-32768, 125, 139, 122, 49,-32768, 110, + -55,-32768, 1085, 1043, 1188, 46, 249, 272, 266, 273, + 589,-32768, 279,-32768,-32768,-32768,-32768,-32768, 1204,-32768, + 2, 1327,-32768, 268,-32768,-32768, 110,-32768, 153, 150, + 1188, 1188, 149, -53, 1188,-32768, 155,-32768, 110,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768, 494, 943, 157,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 158, 159, 163, + 164, 790, 1226, 495, 284, 166, 167, 169,-32768,-32768, + 173,-32768, 49, 110, 28,-32768,-32768,-32768,-32768,-32768, + 262, 1243, 142, 302, 154,-32768,-32768, 494, 943, 1188, + 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, + 1188, 1188,-32768, 154,-32768, 168,-32768,-32768, -58, 1124, +-32768, 25, 16,-32768, 170, 110,-32768, 173, 173,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 177, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768,-32768,-32768,-32768, 181, 1043, 1043, 1043, + 1043, 1043,-32768,-32768, 20, 668, -40,-32768, -48,-32768, + 1043, 1043, 1043, 18,-32768, 182,-32768, 49, 747,-32768, + 872, 872,-32768, 872, 1204, 1188, 1188, 99, 117,-32768, + 747, 33, 186, 187, 191, 192, 198, 200, 747, 747, + 290, 1204, 1188, 1188,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, -87,-32768,-32768,-32768, -87,-32768,-32768, 1043, 1043, +-32768, 203, 204, 205, 209, 1043,-32768, 202, 589, -43, +-32768,-32768, 216, 218, 312, 328, 342,-32768, 173, 1140, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 295, 1043, +-32768,-32768,-32768,-32768, 219,-32768, 229, 872, 747, 747, + 8,-32768, 17,-32768,-32768, 872, 225, 1188, 1188, 1188, + 1188, 1188, 231, 232, 1188, 872, 747, 233,-32768,-32768, +-32768, 234, 235, -33, 1043, 1043, 1043, 1043,-32768,-32768, + 230, 1043, 1043, 1188,-32768,-32768,-32768,-32768, 110, 238, + 236,-32768, 357, -36, 363, 364, 241, 246, 248, 872, + 374, 872, 251, 254, 872, 255, 110,-32768, 256, 258, + 872, 872, 110, 260,-32768, 1188, 1043, 1043, 1188,-32768, + 261, 263, 264, 270,-32768, 267, 276, 47, 130, 1159, +-32768, 274,-32768, 872, 872, 1188, 872, 872, 281,-32768, + 281, 872, 283, 1188, 1188, 1188,-32768,-32768, 1188, 747, + 282, 285,-32768, 1043,-32768, 1043, 1043,-32768,-32768,-32768, +-32768,-32768,-32768, 110, 45, 382, 287, 280, 747, -13, +-32768,-32768, 355,-32768,-32768, 265, 872,-32768,-32768,-32768, + 29,-32768,-32768,-32768, 286, 291, 292, 130,-32768, 375, +-32768, 412, 1,-32768, 1188,-32768,-32768, 293,-32768,-32768, +-32768,-32768,-32768, 423,-32768, 872,-32768, 996, 9, -58, + 747, 212,-32768, -87,-32768,-32768, 297,-32768, 996,-32768, + 419, 422, 303, -58, 872, 872, 425, 371,-32768, 872, + 427,-32768, 872,-32768, 443, 444,-32768 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = -{ - -1, 188, 189, 190, 252, 269, 111, 112, 72, 484, - 12, 73, 14, 37, 38, 39, 44, 50, 121, 321, - 231, 393, 324, 527, 374, 350, 512, 287, 351, 74, - 113, 130, 197, 131, 132, 103, 276, 363, 277, 81, - 15, 16, 17, 19, 18, 193, 240, 241, 59, 22, - 57, 94, 412, 413, 122, 200, 51, 89, 52, 45, - 415, 364, 76, 366, 292, 53, 85, 86, 225, 531, - 125, 305, 492, 396, 226, 227, 228, 229 +static const short yypgoto[] = { 324, + 325, 326, 242, 252, -197,-32768, 0, -50, 376, 4, +-32768,-32768,-32768, 40,-32768,-32768, -167, -306, -397,-32768, + -235,-32768, -291, -23,-32768, -211,-32768,-32768, -24, 237, + -229,-32768, 362, 369, -68, -108, -178, 201,-32768,-32768, + 453,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768, 391,-32768,-32768,-32768,-32768,-32768,-32768, -436, + -72, 101, -157,-32768, 424,-32768,-32768,-32768,-32768,-32768, + 7, 105,-32768,-32768,-32768,-32768 }; -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -399 -static const short int yypact[] = -{ - 406, -399, -399, -399, -399, -399, -399, -399, -26, -114, - -16, -53, 92, -11, 54, 136, 526, -399, 247, 173, - 43, 49, -399, 62, 194, -399, 814, -399, -399, -399, - -399, -399, -399, -399, -399, -399, -399, 134, 134, 99, - -399, -399, -399, -399, 134, -399, -399, -399, -399, -399, - 134, 212, -399, -1, 219, 225, 253, -399, -399, -399, - -399, -399, 135, -399, -399, -399, -399, -399, 271, 275, - 3, 33, -399, -399, -399, 160, -399, 99, 99, -399, - -399, 1029, 287, 287, -399, -399, 220, -399, -399, -399, - -399, -399, -399, -399, 20, 1071, -399, 141, 148, 105, - 135, -399, 160, -75, -399, 1071, 1029, 1174, 32, 286, - 293, 151, 294, 590, -399, 298, -399, -399, -399, -399, - -399, 1190, -399, -13, 1313, -399, 289, -399, -399, 160, - -399, 170, 167, 1174, 1174, 165, -68, 1174, -399, 174, - -399, 160, -399, -399, -399, -399, -399, -399, -399, -399, - -399, -399, -399, -399, -399, -399, -399, -399, -399, -399, - -399, -399, -399, -399, -399, 495, 591, 176, -399, -399, - -399, -399, -399, -399, -399, -399, -399, -399, -399, -399, - 177, 178, 182, 183, 776, 1212, 123, 305, 187, 188, - 189, -399, -399, 193, -399, 135, 160, 266, -399, -399, - -399, -399, -399, 284, 1229, 283, 325, 287, -399, -399, - 495, 591, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, - 1174, 1174, 1174, 1174, 1174, -399, 287, -399, 144, -399, - -399, -4, 1110, -399, -63, -110, -399, 204, 160, -399, - 193, 193, -399, -399, -399, -399, -399, -399, -399, -399, - -399, -399, 211, -399, -399, -399, -399, -399, -399, -399, - -399, -399, -399, -399, -399, -399, -399, -399, -399, 214, - 1029, 1029, 1029, 1029, 1029, -399, -399, 79, 494, -111, - -399, -66, -399, 1029, 1029, 1029, 39, -399, 216, -399, - 135, 733, -399, 858, 858, -399, 858, 1190, 1174, 1174, - 50, 111, -399, 733, 97, 215, 230, 231, 232, 233, - 234, 733, 733, 322, 1190, 1174, 1174, -399, -399, -399, - -399, -399, -399, -399, -27, -399, -399, -399, -27, -399, - -399, 1029, 1029, -399, 235, 236, 239, 240, 1029, -399, - 237, 590, 26, -399, -399, 241, 242, 345, 360, 374, - -399, 193, 1126, -399, -399, -399, -399, -399, -399, -399, - -399, 328, 1029, -399, -399, -399, -399, 249, -399, 252, - 858, 733, 733, 11, -399, 18, -399, -399, 858, 250, - 1174, 1174, 1174, 1174, 1174, 256, 257, 1174, 858, 733, - 259, -399, -399, -399, 262, 264, -34, 1029, 1029, 1029, - 1029, -399, -399, 258, 1029, 1029, 1174, -399, -399, -399, - -399, 160, 265, 267, -399, 384, -61, 390, 393, 272, - 281, 282, 858, 413, 858, 295, 296, 858, 297, 160, - -399, 301, 302, 858, 858, 160, 300, -399, 1174, 1029, - 1029, 1174, -399, 304, 285, 306, 307, -399, 308, 310, - 118, 38, 1145, -399, 311, -399, 858, 858, 1174, 858, - 858, 315, -399, 315, 858, 316, 1174, 1174, 1174, -399, - -399, 1174, 733, 317, 319, -399, 1029, -399, 1029, 1029, - -399, -399, -399, -399, -399, -399, 160, 149, 421, 326, - 314, 733, 19, -399, -399, 412, -399, -399, 321, 858, - -399, -399, -399, 36, -399, -399, -399, 327, 329, 330, - 38, -399, 416, -399, 451, 2, -399, 1174, -399, -399, - 333, -399, -399, -399, -399, -399, 461, -399, 858, -399, - 982, 5, -4, 733, 210, -399, -27, -399, -399, 335, - -399, 982, -399, 457, 464, 344, -4, 858, 858, 468, - 417, -399, 858, 471, -399, 858, -399 -}; -/* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = -{ - -399, 361, 362, 363, 274, 279, -198, -399, 0, -19, - 407, 9, -399, -399, -399, 113, -399, -399, -177, -307, - -398, -399, -236, -399, -299, 7, -399, -212, -399, -399, - -25, 263, -210, -399, 391, 398, -69, -109, -180, 179, - -399, -399, 482, -399, -399, -399, -399, -399, -399, -399, - -399, -399, -399, -399, 418, -399, -399, -399, -399, -399, - -399, -369, -73, 100, -158, -399, 454, -399, -399, -399, - -399, -399, 42, 137, -399, -399, -399, -399 -}; +#define YYLAST 1453 -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -176 -static const short int yytable[] = -{ - 11, 75, 376, 328, 191, 279, 281, 98, 296, 13, - 198, 295, 114, 451, 295, 84, 11, 392, 23, 20, - 422, 392, 338, 87, 104, 13, 105, 424, 329, 330, - 297, 343, 326, 21, 24, -55, -55, 140, 60, 61, - 192, 100, 63, 64, 65, 66, 102, 1, 2, 314, - 3, 4, 1, 142, 143, 3, 302, 423, 137, 306, - 307, 308, 309, 310, 423, 137, 313, 338, 348, 138, - 129, 104, 338, 105, 102, 67, 237, 325, 344, 25, - 129, 455, 141, 317, 318, 349, 11, 370, 510, 28, - 29, 30, 31, 32, 33, 34, 196, 35, 342, 441, - 391, 319, 320, 442, 388, 26, 317, 318, 234, 235, - 60, 61, 238, 100, 63, 64, 65, 66, 532, 1, - 2, 27, 3, 4, 319, 320, 79, 80, 60, 61, - 199, 100, 108, 109, 110, 66, 40, 1, 2, 409, - 3, 4, 529, 88, 546, 540, 99, 67, 317, 318, - 77, 78, 517, 126, 144, 145, 518, 82, 390, 338, - 127, 539, 496, 83, 497, 67, 319, 320, 68, 517, - 403, 69, 545, 521, 70, 54, 71, 101, 348, 291, - 392, 55, 416, 373, 104, 36, 105, 300, 301, 291, - 303, 304, 291, 291, 291, 291, 291, 311, 312, 291, - 56, 333, 334, 335, 336, 337, 288, 129, 46, 47, - 48, 58, 338, 49, 345, 346, 347, 487, 365, 339, - 365, 365, 428, 365, 430, 431, 432, 392, 84, 392, - 365, 104, 191, 105, 1, 378, 91, 3, 365, 365, - 68, 543, 92, 69, 375, 104, 70, 105, 71, 135, - 315, 316, 104, 341, 105, 482, 106, 107, 68, 317, - 318, 69, 394, 395, 70, 36, 71, 280, 192, 401, - 93, 95, 196, 371, 372, 96, 391, 319, 320, 97, - 133, 2, 534, 475, 4, 536, 42, 134, 43, 196, - 389, 291, 293, -56, 104, 294, 105, 365, 365, 365, - -57, 146, 194, 232, 233, 365, 230, 236, 500, 501, - 502, 239, 270, 271, 272, 365, 365, 530, 273, 274, - 317, 318, 282, 283, 284, 285, 286, 411, 443, 444, - 445, 446, 289, 541, 295, 448, 449, 391, 319, 320, - 115, 116, 117, 118, 119, 120, 327, 331, 379, 365, - 332, 365, 352, 387, 365, 291, 429, 291, 291, 291, - 365, 365, 435, 380, 381, 382, 383, 384, 397, 398, - 473, 474, 399, 400, 404, 405, 406, 407, 408, 402, - 414, 450, 417, 365, 365, 418, 365, 365, 427, 433, - 434, 365, 438, 367, 368, 439, 369, 440, 452, 365, - 447, 454, 456, 377, 453, 457, -175, 507, 458, 508, - 509, 385, 386, 472, 459, 460, 291, 462, 365, -63, - 1, 2, 477, 3, 4, 5, 365, 486, 441, 464, - 466, 6, 7, 491, 467, 468, 471, 476, 513, 478, - 479, 291, 291, 291, 488, 480, 491, 481, 495, 499, - 8, 483, 515, 9, 505, 365, 506, 10, 423, 514, - 365, 519, 526, 528, 522, 537, 523, 524, 544, 547, - 419, 420, 421, 535, 365, 365, 548, 549, 426, 365, - 552, 553, 365, 555, 298, 222, 223, 224, 436, 437, - 299, 525, 533, 124, 511, 323, 139, 136, 41, 60, - 61, 123, 100, 108, 109, 110, 66, 90, 1, 2, - 483, 3, 4, 503, 425, 0, 0, 0, 0, 0, - 0, 0, 461, 0, 463, 0, -174, 465, 0, 0, - 0, 0, 0, 469, 470, 0, 67, 0, 0, -63, - 1, 2, 0, 3, 4, 5, 0, 0, 0, 0, - 0, 6, 7, 0, 0, 0, 489, 490, 0, 493, - 494, 0, 0, 0, 498, 0, 0, 0, 0, 0, - 8, 0, 504, 9, 0, 0, 0, 10, 242, 243, - 244, 245, 246, 247, 248, 249, 250, 251, 0, 0, - 0, 516, 0, 0, 0, 60, 61, 0, 0, 520, - 0, 0, 0, 0, 1, 2, 0, 3, 4, 0, - 147, 0, 253, 254, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 148, 149, 0, 0, 0, 538, 68, - 0, 0, 69, 542, 0, 70, 0, 71, 340, 0, - 0, 0, 0, 0, 0, 0, 0, 550, 551, 0, - 0, 0, 554, 0, 0, 556, 150, 151, 152, 153, - 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, - 164, 165, 166, 0, 0, 0, 0, 0, 0, 0, - 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 0, 0, 0, 0, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, - 179, 0, 180, 0, 181, 182, 183, 0, 0, 0, - 0, 0, 0, 0, 104, 0, 105, 0, 184, 0, - 0, 185, 0, 186, 0, 187, 353, 354, 60, 61, - 355, 0, 0, 0, 0, 0, 0, 1, 2, 0, - 3, 4, 0, 356, 357, 358, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 359, 360, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 60, 61, 361, 100, 108, 109, 110, 66, 0, - 1, 2, 0, 3, 4, 0, 0, 0, 0, 150, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 163, 164, 165, 166, 0, 0, 67, 60, - 61, 0, 62, 63, 64, 65, 66, 0, 1, 2, - 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 0, 180, 67, 181, 182, 183, - 0, 353, 354, 60, 61, 355, 0, 104, 0, 105, - 0, 0, 1, 2, 362, 3, 4, 0, 356, 357, - 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 359, 360, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 361, 0, - 0, 68, 0, 0, 69, 0, 275, 70, 0, 71, - 0, 0, 0, 0, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, - 166, 0, 0, 0, 0, 0, 0, 0, 0, 68, - 0, 0, 69, 0, 0, 70, 0, 71, 0, 0, - 0, 0, 0, 0, 0, 0, 167, 168, 169, 170, - 171, 172, 173, 174, 175, 176, 177, 178, 179, 0, - 180, 0, 181, 182, 183, 353, 354, 0, 0, 355, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, - 0, 0, 356, 357, 358, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 359, 360, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 361, 0, 60, 61, 0, 100, 108, 109, - 110, 66, 0, 1, 2, 0, 3, 4, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, - 162, 163, 164, 165, 166, 0, 0, 0, 0, 0, - 0, 67, 0, 0, 0, 0, 60, 61, 0, 100, - 63, 64, 65, 66, 0, 1, 2, 0, 3, 4, - 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, - 177, 178, 179, 128, 180, 0, 181, 182, 183, 0, - 0, 0, 0, 67, 0, 60, 61, 0, 100, 63, - 64, 65, 66, 362, 1, 2, 0, 3, 4, 0, - 0, 60, 61, 0, 100, 63, 64, 65, 66, 0, - 1, 2, 322, 3, 4, 0, 0, 0, 0, 0, - 60, 61, 67, 100, 63, 64, 65, 66, 410, 1, - 2, 0, 3, 4, 68, 0, 0, 69, 67, 0, - 70, 0, 71, 0, 0, 0, 0, 485, 0, 60, - 61, 0, 100, 63, 64, 65, 66, 67, 1, 2, - 0, 3, 4, 0, 0, 60, 61, 0, 195, 63, - 64, 65, 66, 0, 1, 2, 68, 3, 4, 69, - 0, 0, 70, 0, 71, 0, 67, 60, 61, 0, - 100, 108, 109, 110, 66, 0, 1, 2, 0, 3, - 4, 0, 67, 0, 60, 61, 0, 290, 63, 64, - 65, 66, 0, 1, 2, 68, 3, 4, 69, 0, - 0, 70, 0, 71, 67, 0, 0, 0, 0, 0, - 0, 68, 0, 0, 69, 0, 0, 70, 0, 71, - 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, - 68, 0, 0, 69, 0, 0, 70, 0, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, - 0, 0, 69, 0, 0, 70, 0, 71, 0, 0, - 0, 0, 0, 0, 0, 68, 0, 0, 69, 0, - 0, 70, 0, 71, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 201, 0, 0, 0, 68, 0, 0, - 69, 0, 0, 70, 0, 278, 0, 0, 0, 0, - 0, 202, 203, 0, 68, 0, 0, 69, 0, 0, - 70, 0, 71, 204, 205, 206, 207, 208, 209, 150, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 163, 164, 210, 211, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 212, 213, 214, 0, - 0, 215, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 216, 217, 218, 219, 220, 221 -}; -static const short int yycheck[] = -{ - 0, 26, 301, 239, 113, 185, 186, 4, 206, 0, - 23, 9, 81, 411, 9, 16, 16, 324, 132, 45, - 9, 328, 133, 24, 134, 16, 136, 9, 240, 241, - 207, 142, 142, 59, 50, 3, 4, 106, 5, 6, - 113, 8, 9, 10, 11, 12, 71, 14, 15, 226, - 17, 18, 14, 21, 22, 17, 214, 46, 133, 217, - 218, 219, 220, 221, 46, 133, 224, 133, 29, 144, - 95, 134, 133, 136, 99, 42, 144, 140, 144, 132, - 105, 142, 107, 110, 111, 46, 86, 297, 486, 35, - 36, 37, 38, 39, 40, 41, 121, 43, 278, 133, - 127, 128, 129, 137, 314, 13, 110, 111, 133, 134, - 5, 6, 137, 8, 9, 10, 11, 12, 516, 14, - 15, 132, 17, 18, 128, 129, 27, 28, 5, 6, - 143, 8, 9, 10, 11, 12, 0, 14, 15, 351, - 17, 18, 140, 144, 542, 140, 143, 42, 110, 111, - 37, 38, 133, 133, 3, 4, 137, 44, 316, 133, - 140, 530, 461, 50, 463, 42, 128, 129, 135, 133, - 144, 138, 541, 137, 141, 132, 143, 144, 29, 204, - 487, 132, 362, 133, 134, 131, 136, 212, 213, 214, - 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, - 138, 270, 271, 272, 273, 274, 197, 232, 35, 36, - 37, 17, 133, 40, 283, 284, 285, 453, 291, 140, - 293, 294, 380, 296, 382, 383, 384, 534, 16, 536, - 303, 134, 341, 136, 14, 138, 17, 17, 311, 312, - 135, 31, 17, 138, 133, 134, 141, 136, 143, 144, - 106, 107, 134, 278, 136, 137, 77, 78, 135, 110, - 111, 138, 331, 332, 141, 131, 143, 144, 341, 338, - 17, 136, 297, 298, 299, 4, 127, 128, 129, 4, - 139, 15, 518, 441, 18, 521, 39, 139, 41, 314, - 315, 316, 9, 7, 134, 12, 136, 370, 371, 372, - 7, 7, 4, 133, 137, 378, 17, 142, 466, 467, - 468, 137, 136, 136, 136, 388, 389, 515, 136, 136, - 110, 111, 17, 136, 136, 136, 133, 352, 397, 398, - 399, 400, 48, 531, 9, 404, 405, 127, 128, 129, - 53, 54, 55, 56, 57, 58, 142, 136, 133, 422, - 136, 424, 136, 31, 427, 380, 381, 382, 383, 384, - 433, 434, 387, 133, 133, 133, 133, 133, 133, 133, - 439, 440, 133, 133, 133, 133, 31, 17, 4, 142, - 52, 406, 133, 456, 457, 133, 459, 460, 138, 133, - 133, 464, 133, 293, 294, 133, 296, 133, 133, 472, - 142, 17, 12, 303, 137, 12, 0, 476, 136, 478, - 479, 311, 312, 438, 133, 133, 441, 4, 491, 13, - 14, 15, 137, 17, 18, 19, 499, 452, 133, 133, - 133, 25, 26, 458, 133, 133, 136, 133, 17, 133, - 133, 466, 467, 468, 133, 137, 471, 137, 133, 133, - 44, 451, 138, 47, 137, 528, 137, 51, 46, 133, - 533, 140, 46, 12, 137, 4, 137, 137, 133, 12, - 370, 371, 372, 140, 547, 548, 12, 133, 378, 552, - 12, 64, 555, 12, 210, 124, 124, 124, 388, 389, - 211, 510, 517, 86, 487, 232, 105, 99, 16, 5, - 6, 83, 8, 9, 10, 11, 12, 53, 14, 15, - 510, 17, 18, 471, 377, -1, -1, -1, -1, -1, - -1, -1, 422, -1, 424, -1, 0, 427, -1, -1, - -1, -1, -1, 433, 434, -1, 42, -1, -1, 13, - 14, 15, -1, 17, 18, 19, -1, -1, -1, -1, - -1, 25, 26, -1, -1, -1, 456, 457, -1, 459, - 460, -1, -1, -1, 464, -1, -1, -1, -1, -1, - 44, -1, 472, 47, -1, -1, -1, 51, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, - -1, 491, -1, -1, -1, 5, 6, -1, -1, 499, - -1, -1, -1, -1, 14, 15, -1, 17, 18, -1, - 20, -1, 21, 22, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 33, 34, -1, -1, -1, 528, 135, - -1, -1, 138, 533, -1, 141, -1, 143, 144, -1, - -1, -1, -1, -1, -1, -1, -1, 547, 548, -1, - -1, -1, 552, -1, -1, 555, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 100, 101, 102, -1, -1, -1, -1, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, -1, 122, -1, 124, 125, 126, -1, -1, -1, - -1, -1, -1, -1, 134, -1, 136, -1, 138, -1, - -1, 141, -1, 143, -1, 145, 3, 4, 5, 6, - 7, -1, -1, -1, -1, -1, -1, 14, 15, -1, - 17, 18, -1, 20, 21, 22, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 33, 34, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 5, 6, 50, 8, 9, 10, 11, 12, -1, - 14, 15, -1, 17, 18, -1, -1, -1, -1, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, -1, -1, 42, 5, - 6, -1, 8, 9, 10, 11, 12, -1, 14, 15, - -1, 17, 18, -1, -1, -1, -1, -1, -1, -1, - -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, -1, 122, 42, 124, 125, 126, - -1, 3, 4, 5, 6, 7, -1, 134, -1, 136, - -1, -1, 14, 15, 141, 17, 18, -1, 20, 21, - 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 33, 34, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 50, -1, - -1, 135, -1, -1, 138, -1, 140, 141, -1, 143, - -1, -1, -1, -1, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, -1, -1, -1, -1, -1, -1, -1, -1, 135, - -1, -1, 138, -1, -1, 141, -1, 143, -1, -1, - -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, -1, - 122, -1, 124, 125, 126, 3, 4, -1, -1, 7, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, - -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 33, 34, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 50, -1, 5, 6, -1, 8, 9, 10, - 11, 12, -1, 14, 15, -1, 17, 18, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, - -1, 42, -1, -1, -1, -1, 5, 6, -1, 8, - 9, 10, 11, 12, -1, 14, 15, -1, 17, 18, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 32, 122, -1, 124, 125, 126, -1, - -1, -1, -1, 42, -1, 5, 6, -1, 8, 9, - 10, 11, 12, 141, 14, 15, -1, 17, 18, -1, - -1, 5, 6, -1, 8, 9, 10, 11, 12, -1, - 14, 15, 32, 17, 18, -1, -1, -1, -1, -1, - 5, 6, 42, 8, 9, 10, 11, 12, 32, 14, - 15, -1, 17, 18, 135, -1, -1, 138, 42, -1, - 141, -1, 143, -1, -1, -1, -1, 32, -1, 5, - 6, -1, 8, 9, 10, 11, 12, 42, 14, 15, - -1, 17, 18, -1, -1, 5, 6, -1, 8, 9, - 10, 11, 12, -1, 14, 15, 135, 17, 18, 138, - -1, -1, 141, -1, 143, -1, 42, 5, 6, -1, - 8, 9, 10, 11, 12, -1, 14, 15, -1, 17, - 18, -1, 42, -1, 5, 6, -1, 8, 9, 10, - 11, 12, -1, 14, 15, 135, 17, 18, 138, -1, - -1, 141, -1, 143, 42, -1, -1, -1, -1, -1, - -1, 135, -1, -1, 138, -1, -1, 141, -1, 143, - -1, 42, -1, -1, -1, -1, -1, -1, -1, -1, - 135, -1, -1, 138, -1, -1, 141, -1, 143, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 135, - -1, -1, 138, -1, -1, 141, -1, 143, -1, -1, - -1, -1, -1, -1, -1, 135, -1, -1, 138, -1, - -1, 141, -1, 143, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 30, -1, -1, -1, 135, -1, -1, - 138, -1, -1, 141, -1, 143, -1, -1, -1, -1, - -1, 48, 49, -1, 135, -1, -1, 138, -1, -1, - 141, -1, 143, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 103, 104, 105, -1, - -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126 +static const short yytable[] = { 11, + 73, 326, 189, 13, 277, 279, 294, 374, 96, 293, + 112, 449, 22, 82, 11, 390, 420, 293, 13, 390, + 23, 85, 315, 316, 196, 422, 327, 328, 27, 28, + 29, 30, 31, 32, 33, 138, 34, 295, 190, 389, + 317, 318, 2, 124, 100, 4, 346, 24, -54, -54, + 125, 315, 316, 421, 300, 25, 312, 304, 305, 306, + 307, 308, 421, 347, 311, 368, 140, 141, 127, 317, + 318, 19, 100, 346, 26, 75, 76, 135, 127, 135, + 139, 80, 386, 11, 336, 20, 508, 81, 136, 336, + 235, 537, 336, 52, 194, 342, 336, 340, 54, 439, + 401, 341, 543, 440, 53, 453, 232, 233, 58, 59, + 236, 98, 61, 62, 63, 64, 530, 1, 2, 515, + 3, 4, 1, 516, 35, 3, 58, 59, 56, 98, + 61, 62, 63, 64, 82, 1, 2, 407, 3, 4, + 527, 86, 544, 1, 197, 65, 3, 97, 538, 102, + 291, 103, 336, 292, 315, 316, 388, 324, 102, 337, + 103, 515, 35, 65, 323, 519, 102, 494, 103, 495, + 376, 389, 317, 318, 44, 45, 46, 289, 390, 47, + 102, 414, 103, 480, 93, 298, 299, 289, 301, 302, + 289, 289, 289, 289, 289, 309, 310, 289, 286, 331, + 332, 333, 334, 335, 89, 127, 113, 114, 115, 116, + 117, 118, 343, 344, 345, 485, 363, 94, 363, 363, + 426, 363, 428, 429, 430, 390, 90, 390, 363, 91, + 189, 371, 102, 40, 103, 41, 363, 363, 66, 315, + 316, 67, 541, 102, 68, 103, 69, 99, 95, 373, + 102, 339, 103, 77, 78, -55, 66, 317, 318, 67, + 392, 393, 68, 131, 69, 133, 190, 399, 142, 143, + 194, 369, 370, 313, 314, 104, 105, 132, -56, 144, + 532, 473, 192, 534, 228, 230, 231, 194, 387, 289, + 234, 237, 268, 269, 270, 363, 363, 363, 271, 272, + 280, 281, 282, 363, 283, 284, 498, 499, 500, 287, + 293, 325, 329, 363, 363, 528, 330, 350, 377, 378, + 385, 315, 316, 379, 380, 409, 441, 442, 443, 444, + 381, 539, 382, 446, 447, 395, 396, 397, 389, 317, + 318, 398, 404, 400, 405, 406, 412, 363, 402, 363, + 403, 415, 363, 289, 427, 289, 289, 289, 363, 363, + 433, 416, 425, 431, 432, 436, 437, 438, 471, 472, + 450, 445, 451, 452, 454, 455, 456, 460, 457, 448, + 458, 363, 363, 439, 363, 363, 462, 464, 465, 363, + 466, 365, 366, 474, 367, 469, 476, 363, 511, 475, + 421, 375, 477, 478, 517, 505, 486, 506, 507, 383, + 384, 470, 479, 493, 289, 497, 363, 513, 503, 512, + 524, 504, 520, 526, 363, 484, 535, 521, 522, 542, + 545, 489, 533, 546, 551, 547, 550, -174, 553, 289, + 289, 289, 556, 557, 489, 220, 221, 222, 481, 296, + -62, 1, 2, 363, 3, 4, 5, 523, 363, 122, + 297, 509, 6, 7, 137, 134, 321, 39, 417, 418, + 419, 121, 363, 363, 88, 501, 424, 363, 0, 423, + 363, 8, 0, 0, 9, 0, 434, 435, 10, 0, + 531, 0, 0, 0, 0, 0, 0, 0, 0, 58, + 59, 0, 98, 106, 107, 108, 64, 481, 1, 2, + 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, + 459, 0, 461, 0, -173, 463, 0, 0, 0, 0, + 0, 467, 468, 0, 0, 0, 65, -62, 1, 2, + 0, 3, 4, 5, 0, 0, 0, 0, 0, 6, + 7, 0, 0, 0, 487, 488, 0, 491, 492, 0, + 0, 0, 496, 0, 0, 0, 0, 0, 8, 0, + 502, 9, 0, 0, 0, 10, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 0, 0, 0, 514, + 0, 0, 0, 58, 59, 0, 0, 518, 0, 0, + 0, 0, 1, 2, 0, 3, 4, 0, 145, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 146, 147, 0, 0, 0, 536, 0, 0, 66, + 0, 540, 67, 0, 0, 68, 0, 69, 278, 0, + 0, 0, 0, 0, 0, 548, 549, 0, 0, 0, + 552, 0, 0, 554, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, + 164, 0, 58, 59, 0, 98, 106, 107, 108, 64, + 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 165, 166, 167, 168, + 169, 170, 171, 172, 173, 174, 175, 176, 177, 65, + 178, 0, 179, 180, 181, 0, 0, 0, 0, 0, + 0, 0, 102, 0, 103, 0, 182, 0, 0, 183, + 0, 184, 0, 185, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 351, + 352, 58, 59, 353, 0, 0, 0, 0, 0, 0, + 1, 2, 0, 3, 4, 0, 354, 355, 356, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 357, + 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 58, 59, 359, 98, 106, 107, + 108, 64, 66, 1, 2, 67, 3, 4, 68, 0, + 69, 338, 148, 149, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 0, + 0, 65, 58, 59, 0, 60, 61, 62, 63, 64, + 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, + 0, 0, 0, 0, 165, 166, 167, 168, 169, 170, + 171, 172, 173, 174, 175, 176, 177, 0, 178, 65, + 179, 180, 181, 0, 351, 352, 58, 59, 353, 0, + 102, 0, 103, 0, 0, 1, 2, 360, 3, 4, + 0, 354, 355, 356, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 357, 358, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 359, 0, 0, 66, 0, 0, 67, 0, 273, + 68, 0, 69, 0, 0, 0, 0, 148, 149, 150, + 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, + 161, 162, 163, 164, 0, 0, 0, 0, 0, 0, + 0, 0, 66, 251, 252, 67, 0, 0, 68, 0, + 69, 0, 0, 0, 0, 0, 0, 0, 0, 165, + 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, 0, 178, 0, 179, 180, 181, 351, 352, + 0, 0, 353, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 360, 0, 0, 354, 355, 356, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 357, 358, + 0, 253, 254, 255, 256, 257, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 359, 0, 58, 59, 0, + 98, 106, 107, 108, 64, 0, 1, 2, 0, 3, + 4, 148, 149, 150, 151, 152, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, 163, 164, 0, 0, + 0, 0, 0, 0, 65, 0, 0, 0, 0, 58, + 59, 0, 98, 61, 62, 63, 64, 0, 1, 2, + 0, 3, 4, 165, 166, 167, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 177, 126, 178, 0, 179, + 180, 181, 0, 0, 0, 0, 65, 0, 58, 59, + 0, 98, 61, 62, 63, 64, 360, 1, 2, 0, + 3, 4, 0, 0, 58, 59, 0, 98, 61, 62, + 63, 64, 0, 1, 2, 320, 3, 4, 0, 0, + 0, 0, 0, 58, 59, 65, 98, 61, 62, 63, + 64, 408, 1, 2, 0, 3, 4, 66, 0, 0, + 67, 65, 0, 68, 0, 69, 0, 0, 0, 0, + 483, 0, 58, 59, 0, 98, 61, 62, 63, 64, + 65, 1, 2, 0, 3, 4, 0, 0, 58, 59, + 0, 193, 61, 62, 63, 64, 0, 1, 2, 66, + 3, 4, 67, 0, 0, 68, 0, 69, 0, 65, + 58, 59, 0, 98, 106, 107, 108, 64, 0, 1, + 2, 0, 3, 4, 0, 65, 0, 58, 59, 0, + 288, 61, 62, 63, 64, 0, 1, 2, 66, 3, + 4, 67, 0, 0, 68, 0, 69, 65, 0, 0, + 0, 0, 0, 0, 66, 0, 0, 67, 0, 0, + 68, 0, 69, 0, 65, 0, 0, 0, 0, 0, + 0, 0, 0, 66, 0, 0, 67, 0, 0, 68, + 0, 69, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 66, 0, 0, 67, 0, 0, 68, 0, + 69, 0, 0, 0, 0, 0, 0, 0, 66, 0, + 0, 67, 0, 0, 68, 0, 69, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 199, 0, 0, 0, + 66, 0, 0, 67, 0, 0, 68, 0, 276, 0, + 0, 0, 0, 0, 200, 201, 0, 66, 0, 0, + 67, 0, 0, 68, 0, 69, 202, 203, 204, 205, + 206, 207, 148, 149, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 208, 209, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 210, + 211, 212, 0, 0, 213, 166, 167, 168, 169, 170, + 171, 172, 173, 174, 175, 176, 177, 214, 215, 216, + 217, 218, 219 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const unsigned char yystos[] = -{ - 0, 14, 15, 17, 18, 19, 25, 26, 44, 47, - 51, 154, 156, 157, 158, 186, 187, 188, 190, 189, - 45, 59, 195, 132, 50, 132, 13, 132, 35, 36, - 37, 38, 39, 40, 41, 43, 131, 159, 160, 161, - 0, 188, 39, 41, 162, 205, 35, 36, 37, 40, - 163, 202, 204, 211, 132, 132, 138, 196, 17, 194, - 5, 6, 8, 9, 10, 11, 12, 42, 135, 138, - 141, 143, 154, 157, 175, 176, 208, 161, 161, 27, - 28, 185, 161, 161, 16, 212, 213, 24, 144, 203, - 212, 17, 17, 17, 197, 136, 4, 4, 4, 143, - 8, 144, 176, 181, 134, 136, 185, 185, 9, 10, - 11, 152, 153, 176, 182, 53, 54, 55, 56, 57, - 58, 164, 200, 200, 156, 216, 133, 140, 32, 176, - 177, 179, 180, 139, 139, 144, 181, 133, 144, 180, - 182, 176, 21, 22, 3, 4, 7, 20, 33, 34, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 81, 82, 108, 109, 110, - 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, - 122, 124, 125, 126, 138, 141, 143, 145, 147, 148, - 149, 183, 208, 191, 4, 8, 176, 178, 23, 143, - 201, 30, 48, 49, 60, 61, 62, 63, 64, 65, - 81, 82, 103, 104, 105, 108, 121, 122, 123, 124, - 125, 126, 147, 148, 149, 214, 220, 221, 222, 223, - 17, 166, 133, 137, 176, 176, 142, 144, 176, 137, - 192, 193, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 150, 21, 22, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 151, - 136, 136, 136, 136, 136, 140, 182, 184, 143, 184, - 144, 184, 17, 136, 136, 136, 133, 173, 157, 48, - 8, 176, 210, 9, 12, 9, 152, 164, 150, 151, - 176, 176, 210, 176, 176, 217, 210, 210, 210, 210, - 210, 176, 176, 210, 164, 106, 107, 110, 111, 128, - 129, 165, 32, 177, 168, 140, 142, 142, 168, 173, - 173, 136, 136, 182, 182, 182, 182, 182, 133, 140, - 144, 176, 184, 142, 144, 182, 182, 182, 29, 46, - 171, 174, 136, 3, 4, 7, 20, 21, 22, 33, - 34, 50, 141, 183, 207, 208, 209, 209, 209, 209, - 178, 176, 176, 133, 170, 133, 170, 209, 138, 133, - 133, 133, 133, 133, 133, 209, 209, 31, 178, 176, - 210, 127, 165, 167, 182, 182, 219, 133, 133, 133, - 133, 182, 142, 144, 133, 133, 31, 17, 4, 173, - 32, 176, 198, 199, 52, 206, 184, 133, 133, 209, - 209, 209, 9, 46, 9, 219, 209, 138, 210, 176, - 210, 210, 210, 133, 133, 176, 209, 209, 133, 133, - 133, 133, 137, 182, 182, 182, 182, 142, 182, 182, - 176, 166, 133, 137, 17, 142, 12, 12, 136, 133, - 133, 209, 4, 209, 133, 209, 133, 133, 133, 209, - 209, 136, 176, 182, 182, 210, 133, 137, 133, 133, - 137, 137, 137, 154, 155, 32, 176, 168, 133, 209, - 209, 176, 218, 209, 209, 133, 170, 170, 209, 133, - 210, 210, 210, 218, 209, 137, 137, 182, 182, 182, - 166, 171, 172, 17, 133, 138, 209, 133, 137, 140, - 209, 137, 137, 137, 137, 155, 46, 169, 12, 140, - 152, 215, 166, 176, 168, 140, 168, 4, 209, 207, - 140, 152, 209, 31, 133, 207, 166, 12, 12, 133, - 209, 209, 12, 64, 209, 12, 209 +static const short yycheck[] = { 0, + 25, 237, 111, 0, 183, 184, 204, 299, 4, 9, + 79, 409, 132, 16, 15, 322, 9, 9, 15, 326, + 50, 24, 110, 111, 23, 9, 238, 239, 35, 36, + 37, 38, 39, 40, 41, 104, 43, 205, 111, 127, + 128, 129, 15, 133, 69, 18, 29, 132, 3, 4, + 140, 110, 111, 46, 212, 13, 224, 215, 216, 217, + 218, 219, 46, 46, 222, 295, 21, 22, 93, 128, + 129, 45, 97, 29, 132, 36, 37, 133, 103, 133, + 105, 42, 312, 84, 133, 59, 484, 48, 144, 133, + 144, 528, 133, 132, 119, 144, 133, 276, 138, 133, + 144, 142, 539, 137, 132, 142, 131, 132, 5, 6, + 135, 8, 9, 10, 11, 12, 514, 14, 15, 133, + 17, 18, 14, 137, 131, 17, 5, 6, 17, 8, + 9, 10, 11, 12, 16, 14, 15, 349, 17, 18, + 140, 144, 540, 14, 143, 42, 17, 143, 140, 134, + 9, 136, 133, 12, 110, 111, 314, 142, 134, 140, + 136, 133, 131, 42, 140, 137, 134, 459, 136, 461, + 138, 127, 128, 129, 35, 36, 37, 202, 485, 40, + 134, 360, 136, 137, 136, 210, 211, 212, 213, 214, + 215, 216, 217, 218, 219, 220, 221, 222, 195, 268, + 269, 270, 271, 272, 17, 230, 53, 54, 55, 56, + 57, 58, 281, 282, 283, 451, 289, 4, 291, 292, + 378, 294, 380, 381, 382, 532, 17, 534, 301, 17, + 339, 133, 134, 39, 136, 41, 309, 310, 135, 110, + 111, 138, 31, 134, 141, 136, 143, 144, 4, 133, + 134, 276, 136, 27, 28, 7, 135, 128, 129, 138, + 329, 330, 141, 139, 143, 144, 339, 336, 3, 4, + 295, 296, 297, 106, 107, 75, 76, 139, 7, 7, + 516, 439, 4, 519, 17, 133, 137, 312, 313, 314, + 142, 137, 136, 136, 136, 368, 369, 370, 136, 136, + 17, 136, 136, 376, 136, 133, 464, 465, 466, 48, + 9, 142, 136, 386, 387, 513, 136, 136, 133, 133, + 31, 110, 111, 133, 133, 350, 395, 396, 397, 398, + 133, 529, 133, 402, 403, 133, 133, 133, 127, 128, + 129, 133, 31, 142, 17, 4, 52, 420, 133, 422, + 133, 133, 425, 378, 379, 380, 381, 382, 431, 432, + 385, 133, 138, 133, 133, 133, 133, 133, 437, 438, + 133, 142, 137, 17, 12, 12, 136, 4, 133, 404, + 133, 454, 455, 133, 457, 458, 133, 133, 133, 462, + 133, 291, 292, 133, 294, 136, 133, 470, 17, 137, + 46, 301, 133, 137, 140, 474, 133, 476, 477, 309, + 310, 436, 137, 133, 439, 133, 489, 138, 137, 133, + 46, 137, 137, 12, 497, 450, 4, 137, 137, 133, + 12, 456, 140, 12, 64, 133, 12, 0, 12, 464, + 465, 466, 0, 0, 469, 122, 122, 122, 449, 208, + 13, 14, 15, 526, 17, 18, 19, 508, 531, 84, + 209, 485, 25, 26, 103, 97, 230, 15, 368, 369, + 370, 81, 545, 546, 51, 469, 376, 550, -1, 375, + 553, 44, -1, -1, 47, -1, 386, 387, 51, -1, + 515, -1, -1, -1, -1, -1, -1, -1, -1, 5, + 6, -1, 8, 9, 10, 11, 12, 508, 14, 15, + -1, 17, 18, -1, -1, -1, -1, -1, -1, -1, + 420, -1, 422, -1, 0, 425, -1, -1, -1, -1, + -1, 431, 432, -1, -1, -1, 42, 13, 14, 15, + -1, 17, 18, 19, -1, -1, -1, -1, -1, 25, + 26, -1, -1, -1, 454, 455, -1, 457, 458, -1, + -1, -1, 462, -1, -1, -1, -1, -1, 44, -1, + 470, 47, -1, -1, -1, 51, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, -1, -1, -1, 489, + -1, -1, -1, 5, 6, -1, -1, 497, -1, -1, + -1, -1, 14, 15, -1, 17, 18, -1, 20, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 33, 34, -1, -1, -1, 526, -1, -1, 135, + -1, 531, 138, -1, -1, 141, -1, 143, 144, -1, + -1, -1, -1, -1, -1, 545, 546, -1, -1, -1, + 550, -1, -1, 553, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, -1, 5, 6, -1, 8, 9, 10, 11, 12, + -1, 14, 15, -1, 17, 18, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 42, + 122, -1, 124, 125, 126, -1, -1, -1, -1, -1, + -1, -1, 134, -1, 136, -1, 138, -1, -1, 141, + -1, 143, -1, 145, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, + 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, + 14, 15, -1, 17, 18, -1, 20, 21, 22, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, + 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 5, 6, 50, 8, 9, 10, + 11, 12, 135, 14, 15, 138, 17, 18, 141, -1, + 143, 144, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, + -1, 42, 5, 6, -1, 8, 9, 10, 11, 12, + -1, 14, 15, -1, 17, 18, -1, -1, -1, -1, + -1, -1, -1, -1, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, -1, 122, 42, + 124, 125, 126, -1, 3, 4, 5, 6, 7, -1, + 134, -1, 136, -1, -1, 14, 15, 141, 17, 18, + -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 33, 34, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 50, -1, -1, 135, -1, -1, 138, -1, 140, + 141, -1, 143, -1, -1, -1, -1, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, + -1, -1, 135, 21, 22, 138, -1, -1, 141, -1, + 143, -1, -1, -1, -1, -1, -1, -1, -1, 108, + 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, + 119, 120, -1, 122, -1, 124, 125, 126, 3, 4, + -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 141, -1, -1, 20, 21, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 33, 34, + -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 50, -1, 5, 6, -1, + 8, 9, 10, 11, 12, -1, 14, 15, -1, 17, + 18, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, + -1, -1, -1, -1, 42, -1, -1, -1, -1, 5, + 6, -1, 8, 9, 10, 11, 12, -1, 14, 15, + -1, 17, 18, 108, 109, 110, 111, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 32, 122, -1, 124, + 125, 126, -1, -1, -1, -1, 42, -1, 5, 6, + -1, 8, 9, 10, 11, 12, 141, 14, 15, -1, + 17, 18, -1, -1, 5, 6, -1, 8, 9, 10, + 11, 12, -1, 14, 15, 32, 17, 18, -1, -1, + -1, -1, -1, 5, 6, 42, 8, 9, 10, 11, + 12, 32, 14, 15, -1, 17, 18, 135, -1, -1, + 138, 42, -1, 141, -1, 143, -1, -1, -1, -1, + 32, -1, 5, 6, -1, 8, 9, 10, 11, 12, + 42, 14, 15, -1, 17, 18, -1, -1, 5, 6, + -1, 8, 9, 10, 11, 12, -1, 14, 15, 135, + 17, 18, 138, -1, -1, 141, -1, 143, -1, 42, + 5, 6, -1, 8, 9, 10, 11, 12, -1, 14, + 15, -1, 17, 18, -1, 42, -1, 5, 6, -1, + 8, 9, 10, 11, 12, -1, 14, 15, 135, 17, + 18, 138, -1, -1, 141, -1, 143, 42, -1, -1, + -1, -1, -1, -1, 135, -1, -1, 138, -1, -1, + 141, -1, 143, -1, 42, -1, -1, -1, -1, -1, + -1, -1, -1, 135, -1, -1, 138, -1, -1, 141, + -1, 143, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 135, -1, -1, 138, -1, -1, 141, -1, + 143, -1, -1, -1, -1, -1, -1, -1, 135, -1, + -1, 138, -1, -1, 141, -1, 143, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, + 135, -1, -1, 138, -1, -1, 141, -1, 143, -1, + -1, -1, -1, -1, 48, 49, -1, 135, -1, -1, + 138, -1, -1, 141, -1, 143, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, + 104, 105, -1, -1, 108, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126 }; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + 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 2, 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. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible at ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) +#define YYEMPTY -2 #define YYEOF 0 - #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ - #define YYFAIL goto yyerrlab - #define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ +#define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) - #define YYTERROR 1 #define YYERRCODE 256 - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (0) +#ifndef YYPURE +#define YYLEX yylex() #endif - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) #endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - +#else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) +#define YYLEX yylex(&yylval, YYLEX_PARAM) #else -# define YYLEX yylex () +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ #endif -/* Enable debugging if requested. */ -#if YYDEBUG +/* If nonreentrant, generate the variables here */ -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +#ifndef YYPURE -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_stack_print (short int *bottom, short int *top) -#else -static void -yy_stack_print (bottom, top) - short int *bottom; - short int *top; +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ #endif -{ - YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yy_reduce_print (int yyrule) -#else -static void -yy_reduce_print (yyrule) - int yyrule; +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ #endif -{ - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); -} -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ +/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -/* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -# define YYINITDEPTH 200 +#define YYINITDEPTH 200 #endif -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif #ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 +#define YYMAXDEPTH 10000 #endif - +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; { - if (*yystr == '"') - { - size_t yyn = 0; - char const *yyp = yystr; + register char *f = from; + register char *t = to; + register int i = count; - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; + while (i-- > 0) + *t++ = *f++; } -# endif - -#endif /* YYERROR_VERBOSE */ - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +#else /* __cplusplus */ -#if defined (__STDC__) || defined (__cplusplus) +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif +__yy_memcpy (char *to, char *from, unsigned int count) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - + register char *t = to; + register char *f = from; + register int i = count; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - switch (yytype) - { - default: - break; - } - YYFPRINTF (yyoutput, ")"); + while (i-- > 0) + *t++ = *f++; } -#endif /* ! YYDEBUG */ -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; #endif -{ - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } -} +#endif +#line 217 "/usr/share/bison.simple" -/* Prevent warnings from -Wmissing-prototypes. */ +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM); -# else -int yyparse (); -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - -/* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - - -/*----------. -| yyparse. | -`----------*/ +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif -#else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) -int -yyparse (void) +int yyparse (void *); #else -int -yyparse () - +int yyparse (void); #endif #endif -{ - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else #define YYPOPSTACK (yyvsp--, yyssp--) +#endif - YYSIZE_T yystacksize = YYINITDEPTH; + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ int yylen; - YYDPRINTF ((stderr, "Starting parse\n")); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif yystate = 0; yyerrstatus = 0; @@ -2807,675 +2140,644 @@ so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; + yyssp = yyss - 1; yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif - if (yyss + yystacksize - 1 <= yyssp) - { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + int size = yyssp - yyss + 1; #ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - - &yystacksize); + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif - yyss = yyss1; - yyvs = yyvs1; - } + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif #else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) + if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; - - { - short int *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif #endif /* no yyoverflow */ - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif - if (yyss + yystacksize - 1 <= yyssp) + if (yyssp >= yyss + yystacksize - 1) YYABORT; } - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: + yybackup: /* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ +/* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yyn == YYFLAG) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif yychar = YYLEX; } - if (yychar <= YYEOF) + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif } else { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif } - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; + yyn = yytable[yyn]; - if (yyn <= 0) + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) + if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } + else if (yyn == 0) + goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ +/* Do the default action for the current state. */ yydefault: + yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; - goto yyreduce; - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ +/* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: - /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) +#if YYDEBUG != 0 + if (yydebug) { - case 29: -#line 1054 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} - break; - - case 30: -#line 1054 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} - break; + int i; - case 31: -#line 1055 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} - break; - - case 32: -#line 1055 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} - break; - - case 33: -#line 1056 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} - break; - - case 34: -#line 1056 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} - break; - - case 35: -#line 1057 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} - break; - - case 36: -#line 1057 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} - break; + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); - case 37: -#line 1058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} - break; + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif - case 38: -#line 1058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} - break; - case 39: -#line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} - break; + switch (yyn) { - case 40: -#line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} - break; - - case 41: -#line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} - break; - - case 42: -#line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} - break; - - case 43: -#line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} - break; - - case 44: -#line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} - break; - - case 45: -#line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} - break; - - case 46: -#line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} - break; - - case 47: -#line 1066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} - break; - - case 48: -#line 1066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} - break; - - case 49: -#line 1067 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} - break; - - case 50: -#line 1067 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} - break; - - case 51: -#line 1068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} - break; - - case 52: -#line 1068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} - break; - - case 53: -#line 1069 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} - break; - - case 54: -#line 1070 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} - break; - - case 61: -#line 1079 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.StrVal) = 0; ;} - break; - - case 62: -#line 1083 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.StrVal) = (yyvsp[-1].StrVal); +case 28: +#line 1054 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_EQ; ; + break;} +case 29: +#line 1054 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_NE; ; + break;} +case 30: +#line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_SLT; ; + break;} +case 31: +#line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_SGT; ; + break;} +case 32: +#line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_SLE; ; + break;} +case 33: +#line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_SGE; ; + break;} +case 34: +#line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_ULT; ; + break;} +case 35: +#line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_UGT; ; + break;} +case 36: +#line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_ULE; ; + break;} +case 37: +#line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.IPredicate = ICmpInst::ICMP_UGE; ; + break;} +case 38: +#line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ; + break;} +case 39: +#line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_ONE; ; + break;} +case 40: +#line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_OLT; ; + break;} +case 41: +#line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_OGT; ; + break;} +case 42: +#line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_OLE; ; + break;} +case 43: +#line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_OGE; ; + break;} +case 44: +#line 1065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_ORD; ; + break;} +case 45: +#line 1065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_UNO; ; + break;} +case 46: +#line 1066 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ; + break;} +case 47: +#line 1066 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_UNE; ; + break;} +case 48: +#line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_ULT; ; + break;} +case 49: +#line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_UGT; ; + break;} +case 50: +#line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_ULE; ; + break;} +case 51: +#line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_UGE; ; + break;} +case 52: +#line 1069 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ; + break;} +case 53: +#line 1070 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ; + break;} +case 60: +#line 1079 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.StrVal = 0; ; + break;} +case 61: +#line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.StrVal = yyvsp[-1].StrVal; CHECK_FOR_ERROR - ;} - break; - - case 63: -#line 1087 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.StrVal) = 0; + ; + break;} +case 62: +#line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.StrVal = 0; CHECK_FOR_ERROR - ;} - break; - - case 66: -#line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.StrVal) = (yyvsp[-1].StrVal); + ; + break;} +case 65: +#line 1094 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.StrVal = yyvsp[-1].StrVal; CHECK_FOR_ERROR - ;} - break; - - case 67: -#line 1098 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.StrVal) = 0; + ; + break;} +case 66: +#line 1098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.StrVal = 0; CHECK_FOR_ERROR - ;} - break; - - case 68: -#line 1104 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} - break; - - case 69: -#line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} - break; - - case 70: -#line 1106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} - break; - - case 71: -#line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} - break; - - case 72: -#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} - break; - - case 73: -#line 1112 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} - break; - - case 74: -#line 1113 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} - break; - - case 75: -#line 1114 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} - break; - - case 76: -#line 1118 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} - break; - - case 77: -#line 1119 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} - break; - - case 78: -#line 1123 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} - break; - - case 79: -#line 1124 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} - break; - - case 80: -#line 1125 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} - break; - - case 81: -#line 1129 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} - break; - - case 82: -#line 1130 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} - break; - - case 83: -#line 1131 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} - break; - - case 84: -#line 1132 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} - break; - - case 85: -#line 1133 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} - break; - - case 86: -#line 1136 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = CallingConv::C; ;} - break; - - case 87: -#line 1137 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = CallingConv::C; ;} - break; - - case 88: -#line 1138 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = CallingConv::Fast; ;} - break; - - case 89: -#line 1139 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = CallingConv::Cold; ;} - break; - - case 90: -#line 1140 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} - break; - - case 91: -#line 1141 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} - break; - - case 92: -#line 1142 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) + ; + break;} +case 67: +#line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::InternalLinkage; ; + break;} +case 68: +#line 1105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::WeakLinkage; ; + break;} +case 69: +#line 1106 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ; + break;} +case 70: +#line 1107 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::AppendingLinkage; ; + break;} +case 71: +#line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::DLLExportLinkage; ; + break;} +case 72: +#line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::DLLImportLinkage; ; + break;} +case 73: +#line 1113 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; + break;} +case 74: +#line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::ExternalLinkage; ; + break;} +case 75: +#line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Visibility = GlobalValue::DefaultVisibility; ; + break;} +case 76: +#line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Visibility = GlobalValue::HiddenVisibility; ; + break;} +case 77: +#line 1123 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::ExternalLinkage; ; + break;} +case 78: +#line 1124 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::DLLImportLinkage; ; + break;} +case 79: +#line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; + break;} +case 80: +#line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::ExternalLinkage; ; + break;} +case 81: +#line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::InternalLinkage; ; + break;} +case 82: +#line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ; + break;} +case 83: +#line 1132 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::WeakLinkage; ; + break;} +case 84: +#line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.Linkage = GlobalValue::DLLExportLinkage; ; + break;} +case 85: +#line 1136 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = CallingConv::C; ; + break;} +case 86: +#line 1137 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = CallingConv::C; ; + break;} +case 87: +#line 1138 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = CallingConv::Fast; ; + break;} +case 88: +#line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = CallingConv::Cold; ; + break;} +case 89: +#line 1140 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = CallingConv::X86_StdCall; ; + break;} +case 90: +#line 1141 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = CallingConv::X86_FastCall; ; + break;} +case 91: +#line 1142 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) GEN_ERROR("Calling conv too large"); - (yyval.UIntVal) = (yyvsp[0].UInt64Val); + yyval.UIntVal = yyvsp[0].UInt64Val; CHECK_FOR_ERROR - ;} - break; - - case 93: -#line 1149 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;} - break; - - case 94: -#line 1150 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;} - break; - - case 95: -#line 1151 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;} - break; - - case 96: -#line 1152 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;} - break; - - case 97: -#line 1155 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} - break; - - case 98: -#line 1156 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); - ;} - break; - - case 99: -#line 1161 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;} - break; - - case 101: -#line 1165 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} - break; - - case 102: -#line 1166 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); - ;} - break; - - case 103: -#line 1173 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = 0; ;} - break; - - case 104: -#line 1174 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.UIntVal) = (yyvsp[0].UInt64Val); - if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) + ; + break;} +case 92: +#line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::ZExtAttribute; ; + break;} +case 93: +#line 1150 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::SExtAttribute; ; + break;} +case 94: +#line 1151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::InRegAttribute; ; + break;} +case 95: +#line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::StructRetAttribute; ; + break;} +case 96: +#line 1155 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::NoAttributeSet; ; + break;} +case 97: +#line 1156 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs); + ; + break;} +case 98: +#line 1161 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::NoReturnAttribute; ; + break;} +case 100: +#line 1165 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ParamAttrs = FunctionType::NoAttributeSet; ; + break;} +case 101: +#line 1166 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs); + ; + break;} +case 102: +#line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = 0; ; + break;} +case 103: +#line 1174 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.UIntVal = yyvsp[0].UInt64Val; + if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) GEN_ERROR("Alignment must be a power of two"); CHECK_FOR_ERROR -;} - break; - - case 105: -#line 1180 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.UIntVal) = 0; ;} - break; - - case 106: -#line 1181 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.UIntVal) = (yyvsp[0].UInt64Val); - if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) +; + break;} +case 104: +#line 1180 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.UIntVal = 0; ; + break;} +case 105: +#line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.UIntVal = yyvsp[0].UInt64Val; + if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) GEN_ERROR("Alignment must be a power of two"); CHECK_FOR_ERROR -;} - break; - - case 107: -#line 1189 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) - if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') +; + break;} +case 106: +#line 1189 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) + if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') GEN_ERROR("Invalid character in section name"); - (yyval.StrVal) = (yyvsp[0].StrVal); + yyval.StrVal = yyvsp[0].StrVal; CHECK_FOR_ERROR -;} - break; - - case 108: -#line 1197 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.StrVal) = 0; ;} - break; - - case 109: -#line 1198 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.StrVal) = (yyvsp[0].StrVal); ;} - break; - - case 110: -#line 1203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - {;} - break; - - case 111: -#line 1204 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - {;} - break; - - case 112: -#line 1205 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CurGV->setSection((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); +; + break;} +case 107: +#line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.StrVal = 0; ; + break;} +case 108: +#line 1198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.StrVal = yyvsp[0].StrVal; ; + break;} +case 109: +#line 1203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{; + break;} +case 110: +#line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{; + break;} +case 111: +#line 1205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CurGV->setSection(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); CHECK_FOR_ERROR - ;} - break; - - case 113: -#line 1210 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) + ; + break;} +case 112: +#line 1210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) GEN_ERROR("Alignment must be a power of two"); - CurGV->setAlignment((yyvsp[0].UInt64Val)); + CurGV->setAlignment(yyvsp[0].UInt64Val); CHECK_FOR_ERROR - ;} - break; - - case 118: -#line 1226 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); + ; + break;} +case 117: +#line 1226 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeVal = new PATypeHolder(OpaqueType::get()); CHECK_FOR_ERROR - ;} - break; - - case 119: -#line 1230 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); + ; + break;} +case 118: +#line 1230 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); CHECK_FOR_ERROR - ;} - break; - - case 120: -#line 1234 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Pointer type? - if (*(yyvsp[-1].TypeVal) == Type::LabelTy) + ; + break;} +case 119: +#line 1234 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Pointer type? + if (*yyvsp[-1].TypeVal == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); - delete (yyvsp[-1].TypeVal); + yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); + delete yyvsp[-1].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 121: -#line 1241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Named types are also simple types... - const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); - CHECK_FOR_ERROR - (yyval.TypeVal) = new PATypeHolder(tmp); - ;} - break; - - case 122: -#line 1246 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Type UpReference - if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range"); + ; + break;} +case 120: +#line 1241 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Named types are also simple types... + const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); + CHECK_FOR_ERROR + yyval.TypeVal = new PATypeHolder(tmp); + ; + break;} +case 121: +#line 1246 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Type UpReference + if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder - UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... - (yyval.TypeVal) = new PATypeHolder(OT); + UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... + yyval.TypeVal = new PATypeHolder(OT); UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR - ;} - break; - - case 123: -#line 1254 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 122: +#line 1254 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ std::vector Params; std::vector Attrs; - Attrs.push_back((yyvsp[0].ParamAttrs)); - for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { + Attrs.push_back(yyvsp[0].ParamAttrs); + for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) { Params.push_back(I->Ty->get()); if (I->Ty->get() != Type::VoidTy) Attrs.push_back(I->Attrs); @@ -3483,21 +2785,20 @@ bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); - FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs); - delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list - delete (yyvsp[-4].TypeVal); // Delete the return type handle - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); - CHECK_FOR_ERROR - ;} - break; - - case 124: -#line 1272 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs); + delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list + delete yyvsp[-4].TypeVal; // Delete the return type handle + yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); + CHECK_FOR_ERROR + ; + break;} +case 123: +#line 1272 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ std::vector Params; std::vector Attrs; - Attrs.push_back((yyvsp[0].ParamAttrs)); - for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { + Attrs.push_back(yyvsp[0].ParamAttrs); + for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) { Params.push_back(I->Ty->get()); if (I->Ty->get() != Type::VoidTy) Attrs.push_back(I->Attrs); @@ -3505,303 +2806,282 @@ bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); - FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs); - delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); - CHECK_FOR_ERROR - ;} - break; - - case 125: -#line 1290 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Sized array type? - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); - delete (yyvsp[-1].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 126: -#line 1295 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Packed array type? - const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); - if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) + FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs); + delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list + yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); + CHECK_FOR_ERROR + ; + break;} +case 124: +#line 1290 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Sized array type? + yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); + delete yyvsp[-1].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 125: +#line 1295 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Vector type? + const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); + if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) GEN_ERROR("Unsigned result not equal to signed result"); if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) GEN_ERROR("Element type of a VectorType must be primitive"); - if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) + if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) GEN_ERROR("Vector length should be a power of 2"); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); - delete (yyvsp[-1].TypeVal); + yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); + delete yyvsp[-1].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 127: -#line 1307 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Structure type? + ; + break;} +case 126: +#line 1307 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Structure type? std::vector Elements; - for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), - E = (yyvsp[-1].TypeList)->end(); I != E; ++I) + for (std::list::iterator I = yyvsp[-1].TypeList->begin(), + E = yyvsp[-1].TypeList->end(); I != E; ++I) Elements.push_back(*I); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); - delete (yyvsp[-1].TypeList); - CHECK_FOR_ERROR - ;} - break; - - case 128: -#line 1317 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Empty structure type? - (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector())); + yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); + delete yyvsp[-1].TypeList; CHECK_FOR_ERROR - ;} - break; - - case 129: -#line 1321 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 127: +#line 1317 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Empty structure type? + yyval.TypeVal = new PATypeHolder(StructType::get(std::vector())); + CHECK_FOR_ERROR + ; + break;} +case 128: +#line 1321 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ std::vector Elements; - for (std::list::iterator I = (yyvsp[-2].TypeList)->begin(), - E = (yyvsp[-2].TypeList)->end(); I != E; ++I) + for (std::list::iterator I = yyvsp[-2].TypeList->begin(), + E = yyvsp[-2].TypeList->end(); I != E; ++I) Elements.push_back(*I); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); - delete (yyvsp[-2].TypeList); - CHECK_FOR_ERROR - ;} - break; - - case 130: -#line 1331 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Empty structure type? - (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector(), true)); + yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); + delete yyvsp[-2].TypeList; CHECK_FOR_ERROR - ;} - break; - - case 131: -#line 1338 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal); - (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs); - ;} - break; - - case 132: -#line 1345 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 129: +#line 1331 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Empty structure type? + yyval.TypeVal = new PATypeHolder(StructType::get(std::vector(), true)); + CHECK_FOR_ERROR + ; + break;} +case 130: +#line 1338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; + yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; + ; + break;} +case 131: +#line 1345 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); - if (!(*(yyvsp[0].TypeVal))->isFirstClassType()) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); + if (!(*yyvsp[0].TypeVal)->isFirstClassType()) GEN_ERROR("LLVM functions cannot return aggregate types"); - (yyval.TypeVal) = (yyvsp[0].TypeVal); - ;} - break; - - case 133: -#line 1352 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); - ;} - break; - - case 134: -#line 1357 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); - (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs)); + yyval.TypeVal = yyvsp[0].TypeVal; + ; + break;} +case 132: +#line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeVal = new PATypeHolder(Type::VoidTy); + ; + break;} +case 133: +#line 1357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeWithAttrsList = new TypeWithAttrsList(); + yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); CHECK_FOR_ERROR - ;} - break; - - case 135: -#line 1362 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs)); + ; + break;} +case 134: +#line 1362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); CHECK_FOR_ERROR - ;} - break; - - case 137: -#line 1370 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList); + ; + break;} +case 136: +#line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; TWA.Ty = new PATypeHolder(Type::VoidTy); - (yyval.TypeWithAttrsList)->push_back(TWA); + yyval.TypeWithAttrsList->push_back(TWA); CHECK_FOR_ERROR - ;} - break; - - case 138: -#line 1377 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeWithAttrsList) = new TypeWithAttrsList; + ; + break;} +case 137: +#line 1377 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeWithAttrsList = new TypeWithAttrsList; TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; TWA.Ty = new PATypeHolder(Type::VoidTy); - (yyval.TypeWithAttrsList)->push_back(TWA); + yyval.TypeWithAttrsList->push_back(TWA); CHECK_FOR_ERROR - ;} - break; - - case 139: -#line 1384 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); + ; + break;} +case 138: +#line 1384 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeWithAttrsList = new TypeWithAttrsList(); CHECK_FOR_ERROR - ;} - break; - - case 140: -#line 1392 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TypeList) = new std::list(); - (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); + ; + break;} +case 139: +#line 1392 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TypeList = new std::list(); + yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 141: -#line 1397 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); + ; + break;} +case 140: +#line 1397 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 142: -#line 1408 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Nonempty unsized arr + ; + break;} +case 141: +#line 1408 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Nonempty unsized arr if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); - const ArrayType *ATy = dyn_cast((yyvsp[-3].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); + const ArrayType *ATy = dyn_cast(yyvsp[-3].TypeVal->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*(yyvsp[-3].TypeVal))->getDescription() + "'"); + (*yyvsp[-3].TypeVal)->getDescription() + "'"); const Type *ETy = ATy->getElementType(); int NumElements = ATy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) + if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) GEN_ERROR("Type mismatch: constant sized array initialized with " + - utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + + utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + itostr(NumElements) + ""); // Verify all elements are correct type! - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) + for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { + if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '"+ - (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); + (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); } - (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); - delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); + yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); + delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; CHECK_FOR_ERROR - ;} - break; - - case 143: -#line 1436 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 142: +#line 1436 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + const ArrayType *ATy = dyn_cast(yyvsp[-2].TypeVal->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*(yyvsp[-2].TypeVal))->getDescription() + "'"); + (*yyvsp[-2].TypeVal)->getDescription() + "'"); int NumElements = ATy->getNumElements(); if (NumElements != -1 && NumElements != 0) GEN_ERROR("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +""); - (yyval.ConstVal) = ConstantArray::get(ATy, std::vector()); - delete (yyvsp[-2].TypeVal); + yyval.ConstVal = ConstantArray::get(ATy, std::vector()); + delete yyvsp[-2].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 144: -#line 1452 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 143: +#line 1452 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + const ArrayType *ATy = dyn_cast(yyvsp[-2].TypeVal->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*(yyvsp[-2].TypeVal))->getDescription() + "'"); + (*yyvsp[-2].TypeVal)->getDescription() + "'"); int NumElements = ATy->getNumElements(); const Type *ETy = ATy->getElementType(); - char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); - if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) + char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); + if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) GEN_ERROR("Can't build string constant of size " + - itostr((int)(EndStr-(yyvsp[0].StrVal))) + + itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + itostr(NumElements) + ""); std::vector Vals; if (ETy == Type::Int8Ty) { - for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); + for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; C != (unsigned char*)EndStr; ++C) Vals.push_back(ConstantInt::get(ETy, *C)); } else { - free((yyvsp[0].StrVal)); + free(yyvsp[0].StrVal); GEN_ERROR("Cannot build string arrays of non byte sized elements"); } - free((yyvsp[0].StrVal)); - (yyval.ConstVal) = ConstantArray::get(ATy, Vals); - delete (yyvsp[-2].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 145: -#line 1481 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Nonempty unsized arr + free(yyvsp[0].StrVal); + yyval.ConstVal = ConstantArray::get(ATy, Vals); + delete yyvsp[-2].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 144: +#line 1481 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Nonempty unsized arr if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); - const VectorType *PTy = dyn_cast((yyvsp[-3].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); + const VectorType *PTy = dyn_cast(yyvsp[-3].TypeVal->get()); if (PTy == 0) GEN_ERROR("Cannot make packed constant with type: '" + - (*(yyvsp[-3].TypeVal))->getDescription() + "'"); + (*yyvsp[-3].TypeVal)->getDescription() + "'"); const Type *ETy = PTy->getElementType(); int NumElements = PTy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) + if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) GEN_ERROR("Type mismatch: constant sized packed initialized with " + - utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + + utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + itostr(NumElements) + ""); // Verify all elements are correct type! - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) + for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { + if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '"+ - (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); + (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); } - (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector)); - delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); + yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector); + delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; CHECK_FOR_ERROR - ;} - break; - - case 146: -#line 1509 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - const StructType *STy = dyn_cast((yyvsp[-3].TypeVal)->get()); + ; + break;} +case 145: +#line 1509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + const StructType *STy = dyn_cast(yyvsp[-3].TypeVal->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*(yyvsp[-3].TypeVal))->getDescription() + "'"); + (*yyvsp[-3].TypeVal)->getDescription() + "'"); - if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) + if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) GEN_ERROR("Illegal number of initializers for structure type"); // Check to ensure that constants are compatible with the type initializer! - for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) - if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) + for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) + if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) GEN_ERROR("Expected type '" + STy->getElementType(i)->getDescription() + "' for element #" + utostr(i) + @@ -3809,51 +3089,49 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); - (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); - delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); + yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); + delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; CHECK_FOR_ERROR - ;} - break; - - case 147: -#line 1534 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 146: +#line 1534 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - const StructType *STy = dyn_cast((yyvsp[-2].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + const StructType *STy = dyn_cast(yyvsp[-2].TypeVal->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*(yyvsp[-2].TypeVal))->getDescription() + "'"); + (*yyvsp[-2].TypeVal)->getDescription() + "'"); if (STy->getNumContainedTypes() != 0) GEN_ERROR("Illegal number of initializers for structure type"); // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); - (yyval.ConstVal) = ConstantStruct::get(STy, std::vector()); - delete (yyvsp[-2].TypeVal); + yyval.ConstVal = ConstantStruct::get(STy, std::vector()); + delete yyvsp[-2].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 148: -#line 1553 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - const StructType *STy = dyn_cast((yyvsp[-5].TypeVal)->get()); + ; + break;} +case 147: +#line 1553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + const StructType *STy = dyn_cast(yyvsp[-5].TypeVal->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*(yyvsp[-5].TypeVal))->getDescription() + "'"); + (*yyvsp[-5].TypeVal)->getDescription() + "'"); - if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) + if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) GEN_ERROR("Illegal number of initializers for structure type"); // Check to ensure that constants are compatible with the type initializer! - for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) - if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i)) + for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) + if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) GEN_ERROR("Expected type '" + STy->getElementType(i)->getDescription() + "' for element #" + utostr(i) + @@ -3861,70 +3139,68 @@ // Check to ensure that Type is packed if (!STy->isPacked()) - GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + GEN_ERROR("Vector initializer to non-vector type '" + + STy->getDescription() + "'"); - (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector)); - delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector); + yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); + delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; CHECK_FOR_ERROR - ;} - break; - - case 149: -#line 1578 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 148: +#line 1579 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); - const StructType *STy = dyn_cast((yyvsp[-4].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); + const StructType *STy = dyn_cast(yyvsp[-4].TypeVal->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*(yyvsp[-4].TypeVal))->getDescription() + "'"); + (*yyvsp[-4].TypeVal)->getDescription() + "'"); if (STy->getNumContainedTypes() != 0) GEN_ERROR("Illegal number of initializers for structure type"); // Check to ensure that Type is packed if (!STy->isPacked()) - GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + GEN_ERROR("Vector initializer to non-vector type '" + + STy->getDescription() + "'"); - (yyval.ConstVal) = ConstantStruct::get(STy, std::vector()); - delete (yyvsp[-4].TypeVal); + yyval.ConstVal = ConstantStruct::get(STy, std::vector()); + delete yyvsp[-4].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 150: -#line 1597 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 149: +#line 1599 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - const PointerType *PTy = dyn_cast((yyvsp[-1].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + const PointerType *PTy = dyn_cast(yyvsp[-1].TypeVal->get()); if (PTy == 0) GEN_ERROR("Cannot make null pointer constant with type: '" + - (*(yyvsp[-1].TypeVal))->getDescription() + "'"); + (*yyvsp[-1].TypeVal)->getDescription() + "'"); - (yyval.ConstVal) = ConstantPointerNull::get(PTy); - delete (yyvsp[-1].TypeVal); + yyval.ConstVal = ConstantPointerNull::get(PTy); + delete yyvsp[-1].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 151: -#line 1609 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 150: +#line 1611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); - delete (yyvsp[-1].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 152: -#line 1616 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); + delete yyvsp[-1].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 151: +#line 1618 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - const PointerType *Ty = dyn_cast((yyvsp[-1].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + const PointerType *Ty = dyn_cast(yyvsp[-1].TypeVal->get()); if (Ty == 0) GEN_ERROR("Global const reference must be a pointer type"); @@ -3938,7 +3214,7 @@ Function *SavedCurFn = CurFun.CurrentFunction; CurFun.CurrentFunction = 0; - Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); + Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal); CHECK_FOR_ERROR CurFun.CurrentFunction = SavedCurFn; @@ -3953,16 +3229,16 @@ // First check to see if the forward references value is already created! PerModuleInfo::GlobalRefsType::iterator I = - CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); + CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); if (I != CurModule.GlobalRefs.end()) { V = I->second; // Placeholder already exists, use it... - (yyvsp[0].ValIDVal).destroy(); + yyvsp[0].ValIDVal.destroy(); } else { std::string Name; - if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName) - Name = (yyvsp[0].ValIDVal).Name; - else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID) + if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) + Name = yyvsp[0].ValIDVal.Name; + else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) GEN_ERROR("Invalid reference to global"); // Create the forward referenced global. @@ -3978,300 +3254,271 @@ } // Keep track of the fact that we have a forward ref to recycle it - CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); + CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); V = GV; } } - (yyval.ConstVal) = cast(V); - delete (yyvsp[-1].TypeVal); // Free the type handle + yyval.ConstVal = cast(V); + delete yyvsp[-1].TypeVal; // Free the type handle CHECK_FOR_ERROR - ;} - break; - - case 153: -#line 1682 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 152: +#line 1684 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) GEN_ERROR("Mismatched types for constant expression: " + - (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription()); - (yyval.ConstVal) = (yyvsp[0].ConstVal); - delete (yyvsp[-1].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 154: -#line 1692 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); + yyval.ConstVal = yyvsp[0].ConstVal; + delete yyvsp[-1].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 153: +#line 1694 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - const Type *Ty = (yyvsp[-1].TypeVal)->get(); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + const Type *Ty = yyvsp[-1].TypeVal->get(); if (isa(Ty) || Ty == Type::LabelTy || isa(Ty)) GEN_ERROR("Cannot create a null initialized value of this type"); - (yyval.ConstVal) = Constant::getNullValue(Ty); - delete (yyvsp[-1].TypeVal); + yyval.ConstVal = Constant::getNullValue(Ty); + delete yyvsp[-1].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 155: -#line 1702 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // integral constants - if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) + ; + break;} +case 154: +#line 1704 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // integral constants + if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) GEN_ERROR("Constant value doesn't fit in type"); - (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); + yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val); CHECK_FOR_ERROR - ;} - break; - - case 156: -#line 1708 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // integral constants - if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) + ; + break;} +case 155: +#line 1710 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // integral constants + if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) GEN_ERROR("Constant value doesn't fit in type"); - (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); - CHECK_FOR_ERROR - ;} - break; - - case 157: -#line 1714 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Boolean constants - assert(cast((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); - (yyval.ConstVal) = ConstantInt::getTrue(); + yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val); CHECK_FOR_ERROR - ;} - break; - - case 158: -#line 1719 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Boolean constants - assert(cast((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); - (yyval.ConstVal) = ConstantInt::getFalse(); - CHECK_FOR_ERROR - ;} - break; - - case 159: -#line 1724 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Float & Double constants - if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) + ; + break;} +case 156: +#line 1716 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Boolean constants + assert(cast(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); + yyval.ConstVal = ConstantInt::getTrue(); + CHECK_FOR_ERROR + ; + break;} +case 157: +#line 1721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Boolean constants + assert(cast(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); + yyval.ConstVal = ConstantInt::getFalse(); + CHECK_FOR_ERROR + ; + break;} +case 158: +#line 1726 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Float & Double constants + if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) GEN_ERROR("Floating point constant invalid for type"); - (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); + yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); CHECK_FOR_ERROR - ;} - break; - - case 160: -#line 1732 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 159: +#line 1734 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - Constant *Val = (yyvsp[-3].ConstVal); - const Type *DestTy = (yyvsp[-1].TypeVal)->get(); - if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy)) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + Constant *Val = yyvsp[-3].ConstVal; + const Type *DestTy = yyvsp[-1].TypeVal->get(); + if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) GEN_ERROR("invalid cast opcode for cast from '" + Val->getType()->getDescription() + "' to '" + DestTy->getDescription() + "'"); - (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy); - delete (yyvsp[-1].TypeVal); - ;} - break; - - case 161: -#line 1744 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!isa((yyvsp[-2].ConstVal)->getType())) + yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); + delete yyvsp[-1].TypeVal; + ; + break;} +case 160: +#line 1746 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!isa(yyvsp[-2].ConstVal->getType())) GEN_ERROR("GetElementPtr requires a pointer operand"); const Type *IdxTy = - GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(), + GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(), true); if (!IdxTy) GEN_ERROR("Index list invalid for constant getelementptr"); SmallVector IdxVec; - for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) - if (Constant *C = dyn_cast((*(yyvsp[-1].ValueList))[i])) + for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) + if (Constant *C = dyn_cast((*yyvsp[-1].ValueList)[i])) IdxVec.push_back(C); else GEN_ERROR("Indices to constant getelementptr must be constants"); - delete (yyvsp[-1].ValueList); + delete yyvsp[-1].ValueList; - (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size()); + yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); CHECK_FOR_ERROR - ;} - break; - - case 162: -#line 1766 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty) + ; + break;} +case 161: +#line 1768 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) GEN_ERROR("Select condition must be of boolean type"); - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) GEN_ERROR("Select operand types must match"); - (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 163: -#line 1774 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + ; + break;} +case 162: +#line 1776 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) GEN_ERROR("Binary operator types must match"); CHECK_FOR_ERROR; - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); - ;} - break; - - case 164: -#line 1780 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + ; + break;} +case 163: +#line 1782 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) GEN_ERROR("Logical operator types must match"); - if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) { - if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa((yyvsp[-3].ConstVal)->getType()) || - !cast((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger()) + if (!yyvsp[-3].ConstVal->getType()->isInteger()) { + if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa(yyvsp[-3].ConstVal->getType()) || + !cast(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) GEN_ERROR("Logical operator requires integral operands"); } - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 165: -#line 1791 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + ; + break;} +case 164: +#line 1793 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) GEN_ERROR("icmp operand types must match"); - (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); - ;} - break; - - case 166: -#line 1796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + ; + break;} +case 165: +#line 1798 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) GEN_ERROR("fcmp operand types must match"); - (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); - ;} - break; - - case 167: -#line 1801 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) + yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); + ; + break;} +case 166: +#line 1803 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) GEN_ERROR("Invalid extractelement operands"); - (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 168: -#line 1807 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) + ; + break;} +case 167: +#line 1809 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) GEN_ERROR("Invalid insertelement operands"); - (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 169: -#line 1813 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) + ; + break;} +case 168: +#line 1815 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) GEN_ERROR("Invalid shufflevector operands"); - (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 170: -#line 1822 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); + ; + break;} +case 169: +#line 1824 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 171: -#line 1826 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ConstVector) = new std::vector(); - (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); + ; + break;} +case 170: +#line 1828 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ConstVector = new std::vector(); + yyval.ConstVector->push_back(yyvsp[0].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 172: -#line 1834 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.BoolVal) = false; ;} - break; - - case 173: -#line 1834 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.BoolVal) = true; ;} - break; - - case 174: -#line 1845 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; + ; + break;} +case 171: +#line 1836 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.BoolVal = false; ; + break;} +case 172: +#line 1836 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.BoolVal = true; ; + break;} +case 173: +#line 1847 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ModuleVal = ParserResult = CurModule.CurrentModule; CurModule.ModuleDone(); CHECK_FOR_ERROR; - ;} - break; - - case 175: -#line 1850 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; + ; + break;} +case 174: +#line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ModuleVal = ParserResult = CurModule.CurrentModule; CurModule.ModuleDone(); CHECK_FOR_ERROR; - ;} - break; - - case 178: -#line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { CurFun.isDeclare = false; ;} - break; - - case 179: -#line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 177: +#line 1865 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CurFun.isDeclare = false; ; + break;} +case 178: +#line 1865 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CurFun.FunctionDone(); CHECK_FOR_ERROR - ;} - break; - - case 180: -#line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { CurFun.isDeclare = true; ;} - break; - - case 181: -#line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 179: +#line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CurFun.isDeclare = true; ; + break;} +case 180: +#line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CHECK_FOR_ERROR - ;} - break; - - case 182: -#line 1870 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 181: +#line 1872 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CHECK_FOR_ERROR - ;} - break; - - case 183: -#line 1873 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 182: +#line 1875 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Emit an error if there are any unresolved types left. if (!CurModule.LateResolveTypes.empty()) { const ValID &DID = CurModule.LateResolveTypes.begin()->first; @@ -4282,14 +3529,13 @@ } } CHECK_FOR_ERROR - ;} - break; - - case 184: -#line 1885 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 183: +#line 1887 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); // Eagerly resolve types. This is not an optimization, this is a // requirement that is due to the fact that we could have this: // @@ -4299,248 +3545,226 @@ // If types are not resolved eagerly, then the two types will not be // determined to be the same type! // - ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); + ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); - if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { + if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { CHECK_FOR_ERROR // If this is a named type that is not a redefinition, add it to the slot // table. - CurModule.Types.push_back(*(yyvsp[0].TypeVal)); + CurModule.Types.push_back(*yyvsp[0].TypeVal); } - delete (yyvsp[0].TypeVal); + delete yyvsp[0].TypeVal; CHECK_FOR_ERROR - ;} - break; - - case 185: -#line 1909 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType)); + ; + break;} +case 184: +#line 1911 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); - if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { + if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { CHECK_FOR_ERROR // If this is a named type that is not a redefinition, add it to the slot // table. - CurModule.Types.push_back((yyvsp[0].PrimType)); + CurModule.Types.push_back(yyvsp[0].PrimType); } CHECK_FOR_ERROR - ;} - break; - - case 186: -#line 1920 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 185: +#line 1922 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ /* "Externally Visible" Linkage */ - if ((yyvsp[0].ConstVal) == 0) + if (yyvsp[0].ConstVal == 0) GEN_ERROR("Global value initializer is not a constant"); - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, - (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); + CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, + yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 187: -#line 1927 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 186: +#line 1929 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CurGV = 0; - ;} - break; - - case 188: -#line 1930 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[0].ConstVal) == 0) + ; + break;} +case 187: +#line 1932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[0].ConstVal == 0) GEN_ERROR("Global value initializer is not a constant"); - CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); + CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 189: -#line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 188: +#line 1937 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CurGV = 0; - ;} - break; - - case 190: -#line 1938 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 189: +#line 1940 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); - CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); + CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); CHECK_FOR_ERROR - delete (yyvsp[0].TypeVal); - ;} - break; - - case 191: -#line 1944 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + delete yyvsp[0].TypeVal; + ; + break;} +case 190: +#line 1946 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CurGV = 0; CHECK_FOR_ERROR - ;} - break; - - case 192: -#line 1948 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CHECK_FOR_ERROR - ;} - break; - - case 193: -#line 1951 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 191: +#line 1950 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CHECK_FOR_ERROR + ; + break;} +case 192: +#line 1953 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CHECK_FOR_ERROR - ;} - break; - - case 194: -#line 1957 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 193: +#line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); - char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); - std::string NewAsm((yyvsp[0].StrVal), EndStr); - free((yyvsp[0].StrVal)); + char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); + std::string NewAsm(yyvsp[0].StrVal, EndStr); + free(yyvsp[0].StrVal); if (AsmSoFar.empty()) CurModule.CurrentModule->setModuleInlineAsm(NewAsm); else CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); CHECK_FOR_ERROR -;} - break; - - case 195: -#line 1970 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 196: -#line 1974 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); - ;} - break; - - case 198: -#line 1981 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); +; + break;} +case 194: +#line 1972 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 195: +#line 1976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); + ; + break;} +case 197: +#line 1983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); CHECK_FOR_ERROR - ;} - break; - - case 199: -#line 1986 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); + ; + break;} +case 198: +#line 1988 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); + free(yyvsp[0].StrVal); CHECK_FOR_ERROR - ;} - break; - - case 200: -#line 1991 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 199: +#line 1993 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ CHECK_FOR_ERROR - ;} - break; - - case 201: -#line 2000 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 200: +#line 2002 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - if (*(yyvsp[-2].TypeVal) == Type::VoidTy) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + if (*yyvsp[-2].TypeVal == Type::VoidTy) GEN_ERROR("void typed arguments are invalid"); - ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal); - (yyval.ArgList) = (yyvsp[-4].ArgList); - (yyvsp[-4].ArgList)->push_back(E); - CHECK_FOR_ERROR - ;} - break; - - case 202: -#line 2010 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; + yyval.ArgList = yyvsp[-4].ArgList; + yyvsp[-4].ArgList->push_back(E); + CHECK_FOR_ERROR + ; + break;} +case 201: +#line 2012 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - if (*(yyvsp[-2].TypeVal) == Type::VoidTy) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + if (*yyvsp[-2].TypeVal == Type::VoidTy) GEN_ERROR("void typed arguments are invalid"); - ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal); - (yyval.ArgList) = new ArgListType; - (yyval.ArgList)->push_back(E); - CHECK_FOR_ERROR - ;} - break; - - case 203: -#line 2021 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ArgList) = (yyvsp[0].ArgList); + ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; + yyval.ArgList = new ArgListType; + yyval.ArgList->push_back(E); + CHECK_FOR_ERROR + ; + break;} +case 202: +#line 2023 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ArgList = yyvsp[0].ArgList; CHECK_FOR_ERROR - ;} - break; - - case 204: -#line 2025 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ArgList) = (yyvsp[-2].ArgList); + ; + break;} +case 203: +#line 2027 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ArgList = yyvsp[-2].ArgList; struct ArgListEntry E; E.Ty = new PATypeHolder(Type::VoidTy); E.Name = 0; E.Attrs = FunctionType::NoAttributeSet; - (yyval.ArgList)->push_back(E); + yyval.ArgList->push_back(E); CHECK_FOR_ERROR - ;} - break; - - case 205: -#line 2034 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ArgList) = new ArgListType; + ; + break;} +case 204: +#line 2036 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ArgList = new ArgListType; struct ArgListEntry E; E.Ty = new PATypeHolder(Type::VoidTy); E.Name = 0; E.Attrs = FunctionType::NoAttributeSet; - (yyval.ArgList)->push_back(E); + yyval.ArgList->push_back(E); CHECK_FOR_ERROR - ;} - break; - - case 206: -#line 2043 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ArgList) = 0; + ; + break;} +case 205: +#line 2045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ArgList = 0; CHECK_FOR_ERROR - ;} - break; - - case 207: -#line 2049 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - UnEscapeLexed((yyvsp[-6].StrVal)); - std::string FunctionName((yyvsp[-6].StrVal)); - free((yyvsp[-6].StrVal)); // Free strdup'd memory! + ; + break;} +case 206: +#line 2051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + UnEscapeLexed(yyvsp[-6].StrVal); + std::string FunctionName(yyvsp[-6].StrVal); + free(yyvsp[-6].StrVal); // Free strdup'd memory! // Check the function result for abstractness if this is a define. We should // have no abstract types at this point - if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal))) - GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription()); + if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) + GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); std::vector ParamTypeList; std::vector ParamAttrs; - ParamAttrs.push_back((yyvsp[-2].ParamAttrs)); - if ((yyvsp[-4].ArgList)) { // If there are arguments... - for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) { + ParamAttrs.push_back(yyvsp[-2].ParamAttrs); + if (yyvsp[-4].ArgList) { // If there are arguments... + for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) { const Type* Ty = I->Ty->get(); if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); @@ -4553,10 +3777,10 @@ bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; if (isVarArg) ParamTypeList.pop_back(); - FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg, + FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, ParamAttrs); const PointerType *PFT = PointerType::get(FT); - delete (yyvsp[-7].TypeVal); + delete yyvsp[-7].TypeVal; ValID ID; if (!FunctionName.empty()) { @@ -4605,26 +3829,26 @@ Fn->setLinkage(CurFun.Linkage); Fn->setVisibility(CurFun.Visibility); } - Fn->setCallingConv((yyvsp[-8].UIntVal)); - Fn->setAlignment((yyvsp[0].UIntVal)); - if ((yyvsp[-1].StrVal)) { - Fn->setSection((yyvsp[-1].StrVal)); - free((yyvsp[-1].StrVal)); + Fn->setCallingConv(yyvsp[-8].UIntVal); + Fn->setAlignment(yyvsp[0].UIntVal); + if (yyvsp[-1].StrVal) { + Fn->setSection(yyvsp[-1].StrVal); + free(yyvsp[-1].StrVal); } // Add all of the arguments we parsed to the function... - if ((yyvsp[-4].ArgList)) { // Is null if empty... + if (yyvsp[-4].ArgList) { // Is null if empty... if (isVarArg) { // Nuke the last entry - assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 && + assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 && "Not a varargs marker!"); - delete (yyvsp[-4].ArgList)->back().Ty; - (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry + delete yyvsp[-4].ArgList->back().Ty; + yyvsp[-4].ArgList->pop_back(); // Delete the last entry } Function::arg_iterator ArgIt = Fn->arg_begin(); Function::arg_iterator ArgEnd = Fn->arg_end(); unsigned Idx = 1; - for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); - I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { + for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); + I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { delete I->Ty; // Delete the typeholder... setValueName(ArgIt, I->Name); // Insert arg into symtab... CHECK_FOR_ERROR @@ -4632,128 +3856,114 @@ Idx++; } - delete (yyvsp[-4].ArgList); // We're now done with the argument list + delete yyvsp[-4].ArgList; // We're now done with the argument list } CHECK_FOR_ERROR -;} - break; - - case 210: -#line 2162 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.FunctionVal) = CurFun.CurrentFunction; +; + break;} +case 209: +#line 2164 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.FunctionVal = CurFun.CurrentFunction; // Make sure that we keep track of the linkage type even if there was a // previous "declare". - (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); - (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility)); -;} - break; - - case 213: -#line 2173 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); + yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); +; + break;} +case 212: +#line 2175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.FunctionVal = yyvsp[-1].FunctionVal; CHECK_FOR_ERROR -;} - break; - - case 214: -#line 2178 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage)); - CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility)); - (yyval.FunctionVal) = CurFun.CurrentFunction; +; + break;} +case 213: +#line 2180 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); + CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); + yyval.FunctionVal = CurFun.CurrentFunction; CurFun.FunctionDone(); CHECK_FOR_ERROR - ;} - break; - - case 215: -#line 2190 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BoolVal) = false; - CHECK_FOR_ERROR - ;} - break; - - case 216: -#line 2194 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BoolVal) = true; - CHECK_FOR_ERROR - ;} - break; - - case 217: -#line 2199 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // A reference to a direct constant - (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); - CHECK_FOR_ERROR - ;} - break; - - case 218: -#line 2203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); + ; + break;} +case 214: +#line 2192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BoolVal = false; CHECK_FOR_ERROR - ;} - break; - - case 219: -#line 2207 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Perhaps it's an FP constant? - (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); + ; + break;} +case 215: +#line 2196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BoolVal = true; CHECK_FOR_ERROR - ;} - break; - - case 220: -#line 2211 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); + ; + break;} +case 216: +#line 2201 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // A reference to a direct constant + yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); + CHECK_FOR_ERROR + ; + break;} +case 217: +#line 2205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); CHECK_FOR_ERROR - ;} - break; - - case 221: -#line 2215 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); + ; + break;} +case 218: +#line 2209 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Perhaps it's an FP constant? + yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); + CHECK_FOR_ERROR + ; + break;} +case 219: +#line 2213 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); CHECK_FOR_ERROR - ;} - break; - - case 222: -#line 2219 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::createNull(); + ; + break;} +case 220: +#line 2217 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); CHECK_FOR_ERROR - ;} - break; - - case 223: -#line 2223 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::createUndef(); + ; + break;} +case 221: +#line 2221 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::createNull(); CHECK_FOR_ERROR - ;} - break; - - case 224: -#line 2227 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // A vector zero constant. - (yyval.ValIDVal) = ValID::createZeroInit(); + ; + break;} +case 222: +#line 2225 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::createUndef(); CHECK_FOR_ERROR - ;} - break; - - case 225: -#line 2231 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Nonempty unsized packed vector - const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); - int NumElements = (yyvsp[-1].ConstVector)->size(); + ; + break;} +case 223: +#line 2229 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // A vector zero constant. + yyval.ValIDVal = ValID::createZeroInit(); + CHECK_FOR_ERROR + ; + break;} +case 224: +#line 2233 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Nonempty unsized packed vector + const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); + int NumElements = yyvsp[-1].ConstVector->size(); VectorType* pt = VectorType::get(ETy, NumElements); PATypeHolder* PTy = new PATypeHolder( @@ -4765,130 +3975,118 @@ ); // Verify all elements are correct type! - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) + for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { + if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '" + - (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); + (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); } - (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector))); - delete PTy; delete (yyvsp[-1].ConstVector); - CHECK_FOR_ERROR - ;} - break; - - case 226: -#line 2256 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); - CHECK_FOR_ERROR - ;} - break; - - case 227: -#line 2260 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); - std::string AsmStr = std::string((yyvsp[-2].StrVal), End); - End = UnEscapeLexed((yyvsp[0].StrVal), true); - std::string Constraints = std::string((yyvsp[0].StrVal), End); - (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); - free((yyvsp[-2].StrVal)); - free((yyvsp[0].StrVal)); - CHECK_FOR_ERROR - ;} - break; - - case 228: -#line 2274 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Is it an integer reference...? - (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal)); - CHECK_FOR_ERROR - ;} - break; - - case 229: -#line 2278 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal)); - CHECK_FOR_ERROR - ;} - break; - - case 230: -#line 2282 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Is it a named reference...? - (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal)); - CHECK_FOR_ERROR - ;} - break; - - case 231: -#line 2286 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Is it a named reference...? - (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal)); + yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector)); + delete PTy; delete yyvsp[-1].ConstVector; CHECK_FOR_ERROR - ;} - break; - - case 234: -#line 2298 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); - delete (yyvsp[-1].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 235: -#line 2307 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + ; + break;} +case 225: +#line 2258 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); CHECK_FOR_ERROR - ;} - break; - - case 236: -#line 2311 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Do not allow functions with 0 basic blocks - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + ; + break;} +case 226: +#line 2262 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); + std::string AsmStr = std::string(yyvsp[-2].StrVal, End); + End = UnEscapeLexed(yyvsp[0].StrVal, true); + std::string Constraints = std::string(yyvsp[0].StrVal, End); + yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); + free(yyvsp[-2].StrVal); + free(yyvsp[0].StrVal); + CHECK_FOR_ERROR + ; + break;} +case 227: +#line 2276 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Is it an integer reference...? + yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); + CHECK_FOR_ERROR + ; + break;} +case 228: +#line 2280 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); CHECK_FOR_ERROR - ;} - break; - - case 237: -#line 2320 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); + ; + break;} +case 229: +#line 2284 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Is it a named reference...? + yyval.ValIDVal = ValID::createLocalName(yyvsp[0].StrVal); + CHECK_FOR_ERROR + ; + break;} +case 230: +#line 2288 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Is it a named reference...? + yyval.ValIDVal = ValID::createGlobalName(yyvsp[0].StrVal); + CHECK_FOR_ERROR + ; + break;} +case 233: +#line 2300 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!UpRefs.empty()) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); + delete yyvsp[-1].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 234: +#line 2309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.FunctionVal = yyvsp[-1].FunctionVal; CHECK_FOR_ERROR - InsertValue((yyvsp[0].TermInstVal)); - (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); - InsertValue((yyvsp[-2].BasicBlockVal)); - (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); + ; + break;} +case 235: +#line 2313 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Do not allow functions with 0 basic blocks + yyval.FunctionVal = yyvsp[-1].FunctionVal; + CHECK_FOR_ERROR + ; + break;} +case 236: +#line 2322 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); CHECK_FOR_ERROR - ;} - break; - - case 238: -#line 2330 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (CastInst *CI1 = dyn_cast((yyvsp[0].InstVal))) + InsertValue(yyvsp[0].TermInstVal); + yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); + InsertValue(yyvsp[-2].BasicBlockVal); + yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; + CHECK_FOR_ERROR + ; + break;} +case 237: +#line 2332 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (CastInst *CI1 = dyn_cast(yyvsp[0].InstVal)) if (CastInst *CI2 = dyn_cast(CI1->getOperand(0))) if (CI2->getParent() == 0) - (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2); - (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); - (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); - CHECK_FOR_ERROR - ;} - break; - - case 239: -#line 2339 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BasicBlockVal) = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true); + yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); + yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); + yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; + CHECK_FOR_ERROR + ; + break;} +case 238: +#line 2341 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BasicBlockVal = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true); CHECK_FOR_ERROR // Make sure to move the basic block to the correct location in the @@ -4896,15 +4094,14 @@ // referenced. Function::BasicBlockListType &BBL = CurFun.CurrentFunction->getBasicBlockList(); - BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); + BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); CHECK_FOR_ERROR - ;} - break; - - case 240: -#line 2351 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BasicBlockVal) = getBBVal(ValID::createLocalName((yyvsp[0].StrVal)), true); + ; + break;} +case 239: +#line 2353 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BasicBlockVal = getBBVal(ValID::createLocalName(yyvsp[0].StrVal), true); CHECK_FOR_ERROR // Make sure to move the basic block to the correct location in the @@ -4912,100 +4109,93 @@ // referenced. Function::BasicBlockListType &BBL = CurFun.CurrentFunction->getBasicBlockList(); - BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); - CHECK_FOR_ERROR - ;} - break; - - case 241: -#line 2364 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Return with a result... - (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); - CHECK_FOR_ERROR - ;} - break; - - case 242: -#line 2368 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Return with no result... - (yyval.TermInstVal) = new ReturnInst(); - CHECK_FOR_ERROR - ;} - break; - - case 243: -#line 2372 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Unconditional Branch... - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); - CHECK_FOR_ERROR - (yyval.TermInstVal) = new BranchInst(tmpBB); - ;} - break; - - case 244: -#line 2377 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - assert(cast((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?"); - BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); - CHECK_FOR_ERROR - BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); + BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); CHECK_FOR_ERROR - Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); - CHECK_FOR_ERROR - (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); - ;} - break; - - case 245: -#line 2387 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); + ; + break;} +case 240: +#line 2366 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Return with a result... + yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); + CHECK_FOR_ERROR + ; + break;} +case 241: +#line 2370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Return with no result... + yyval.TermInstVal = new ReturnInst(); + CHECK_FOR_ERROR + ; + break;} +case 242: +#line 2374 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Unconditional Branch... + BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); + CHECK_FOR_ERROR + yyval.TermInstVal = new BranchInst(tmpBB); + ; + break;} +case 243: +#line 2379 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + assert(cast(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); + BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); + CHECK_FOR_ERROR + BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); + CHECK_FOR_ERROR + Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); + CHECK_FOR_ERROR + yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); + ; + break;} +case 244: +#line 2389 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); + BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); CHECK_FOR_ERROR - SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); - (yyval.TermInstVal) = S; + SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); + yyval.TermInstVal = S; - std::vector >::iterator I = (yyvsp[-1].JumpTable)->begin(), - E = (yyvsp[-1].JumpTable)->end(); + std::vector >::iterator I = yyvsp[-1].JumpTable->begin(), + E = yyvsp[-1].JumpTable->end(); for (; I != E; ++I) { if (ConstantInt *CI = dyn_cast(I->first)) S->addCase(CI, I->second); else GEN_ERROR("Switch case is constant, but not a simple integer"); } - delete (yyvsp[-1].JumpTable); + delete yyvsp[-1].JumpTable; CHECK_FOR_ERROR - ;} - break; - - case 246: -#line 2406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); + ; + break;} +case 245: +#line 2408 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); + BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); CHECK_FOR_ERROR SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); - (yyval.TermInstVal) = S; + yyval.TermInstVal = S; CHECK_FOR_ERROR - ;} - break; - - case 247: -#line 2416 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 246: +#line 2418 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Handle the short syntax const PointerType *PFTy = 0; const FunctionType *Ty = 0; - if (!(PFTy = dyn_cast((yyvsp[-11].TypeVal)->get())) || + if (!(PFTy = dyn_cast(yyvsp[-11].TypeVal->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; FunctionType::ParamAttrsList ParamAttrs; - ParamAttrs.push_back((yyvsp[-6].ParamAttrs)); - for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) { + ParamAttrs.push_back(yyvsp[-6].ParamAttrs); + for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) { const Type *Ty = I->Val->getType(); if (Ty == Type::VoidTy) GEN_ERROR("Short call syntax cannot be used with varargs"); @@ -5013,20 +4203,20 @@ ParamAttrs.push_back(I->Attrs); } - Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs); + Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling... + Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling... CHECK_FOR_ERROR - BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); + BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); CHECK_FOR_ERROR - BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); CHECK_FOR_ERROR // Check the arguments ValueList Args; - if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments? + if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? // Make sure no arguments is a good thing! if (Ty->getNumParams() != 0) GEN_ERROR("No arguments passed to a function that " @@ -5036,7 +4226,7 @@ // correctly! FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end(); + ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) { if (ArgI->Val->getType() != *I) @@ -5055,340 +4245,314 @@ // Create the InvokeInst InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); - II->setCallingConv((yyvsp[-12].UIntVal)); - (yyval.TermInstVal) = II; - delete (yyvsp[-8].ValueRefList); - CHECK_FOR_ERROR - ;} - break; - - case 248: -#line 2482 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TermInstVal) = new UnwindInst(); + II->setCallingConv(yyvsp[-12].UIntVal); + yyval.TermInstVal = II; + delete yyvsp[-8].ValueRefList; + CHECK_FOR_ERROR + ; + break;} +case 247: +#line 2484 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TermInstVal = new UnwindInst(); CHECK_FOR_ERROR - ;} - break; - - case 249: -#line 2486 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.TermInstVal) = new UnreachableInst(); + ; + break;} +case 248: +#line 2488 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.TermInstVal = new UnreachableInst(); CHECK_FOR_ERROR - ;} - break; - - case 250: -#line 2493 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.JumpTable) = (yyvsp[-5].JumpTable); - Constant *V = cast(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); + ; + break;} +case 249: +#line 2495 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.JumpTable = yyvsp[-5].JumpTable; + Constant *V = cast(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value"); - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); - ;} - break; - - case 251: -#line 2504 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.JumpTable) = new std::vector >(); - Constant *V = cast(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); + yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); + ; + break;} +case 250: +#line 2506 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.JumpTable = new std::vector >(); + Constant *V = cast(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value"); - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); - ;} - break; - - case 252: -#line 2517 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); + ; + break;} +case 251: +#line 2519 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Is this definition named?? if so, assign the name... - setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); + setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); CHECK_FOR_ERROR - InsertValue((yyvsp[0].InstVal)); - (yyval.InstVal) = (yyvsp[0].InstVal); + InsertValue(yyvsp[0].InstVal); + yyval.InstVal = yyvsp[0].InstVal; CHECK_FOR_ERROR - ;} - break; - - case 253: -#line 2527 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { // Used for PHI nodes + ; + break;} +case 252: +#line 2529 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Used for PHI nodes if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription()); - (yyval.PHIList) = new std::list >(); - Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); - CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); - CHECK_FOR_ERROR - (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); - delete (yyvsp[-5].TypeVal); - ;} - break; - - case 254: -#line 2538 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.PHIList) = (yyvsp[-6].PHIList); - Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); + yyval.PHIList = new std::list >(); + Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); + CHECK_FOR_ERROR + BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); + CHECK_FOR_ERROR + yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); + delete yyvsp[-5].TypeVal; + ; + break;} +case 253: +#line 2540 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.PHIList = yyvsp[-6].PHIList; + Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); + BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); CHECK_FOR_ERROR - (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); - ;} - break; - - case 255: -#line 2548 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); + ; + break;} +case 254: +#line 2550 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); // Used for call and invoke instructions - (yyval.ValueRefList) = new ValueRefList(); - ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); - (yyval.ValueRefList)->push_back(E); - ;} - break; - - case 256: -#line 2556 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + yyval.ValueRefList = new ValueRefList(); + ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); + yyval.ValueRefList->push_back(E); + ; + break;} +case 255: +#line 2558 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - (yyval.ValueRefList) = (yyvsp[-4].ValueRefList); - ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); - (yyval.ValueRefList)->push_back(E); - CHECK_FOR_ERROR - ;} - break; - - case 257: -#line 2564 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ValueRefList) = new ValueRefList(); ;} - break; - - case 258: -#line 2567 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.ValueList) = new std::vector(); ;} - break; - - case 259: -#line 2568 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.ValueList) = (yyvsp[-2].ValueList); - (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + yyval.ValueRefList = yyvsp[-4].ValueRefList; + ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); + yyval.ValueRefList->push_back(E); + CHECK_FOR_ERROR + ; + break;} +case 256: +#line 2566 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ValueRefList = new ValueRefList(); ; + break;} +case 257: +#line 2569 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ yyval.ValueList = new std::vector(); ; + break;} +case 258: +#line 2570 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.ValueList = yyvsp[-2].ValueList; + yyval.ValueList->push_back(yyvsp[0].ValueVal); CHECK_FOR_ERROR - ;} - break; - - case 260: -#line 2575 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BoolVal) = true; + ; + break;} +case 259: +#line 2577 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BoolVal = true; CHECK_FOR_ERROR - ;} - break; - - case 261: -#line 2579 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BoolVal) = false; + ; + break;} +case 260: +#line 2581 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BoolVal = false; CHECK_FOR_ERROR - ;} - break; - - case 262: -#line 2584 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 261: +#line 2586 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); - if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && - !isa((*(yyvsp[-3].TypeVal)).get())) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); + if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && + !isa((*yyvsp[-3].TypeVal).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands"); - if (isa((*(yyvsp[-3].TypeVal)).get()) && - ((yyvsp[-4].BinaryOpVal) == Instruction::URem || - (yyvsp[-4].BinaryOpVal) == Instruction::SRem || - (yyvsp[-4].BinaryOpVal) == Instruction::FRem)) - GEN_ERROR("Remainder not supported on packed types"); - Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + if (isa((*yyvsp[-3].TypeVal).get()) && + (yyvsp[-4].BinaryOpVal == Instruction::URem || + yyvsp[-4].BinaryOpVal == Instruction::SRem || + yyvsp[-4].BinaryOpVal == Instruction::FRem)) + GEN_ERROR("Remainder not supported on vector types"); + Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); CHECK_FOR_ERROR - Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); - if ((yyval.InstVal) == 0) + yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); + if (yyval.InstVal == 0) GEN_ERROR("binary operator returned null"); - delete (yyvsp[-3].TypeVal); - ;} - break; - - case 263: -#line 2605 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + delete yyvsp[-3].TypeVal; + ; + break;} +case 262: +#line 2607 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); - if (!(*(yyvsp[-3].TypeVal))->isInteger()) { - if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa((yyvsp[-3].TypeVal)->get()) || - !cast((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger()) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); + if (!(*yyvsp[-3].TypeVal)->isInteger()) { + if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa(yyvsp[-3].TypeVal->get()) || + !cast(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) GEN_ERROR("Logical operator requires integral operands"); } - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); - if ((yyval.InstVal) == 0) + yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); + if (yyval.InstVal == 0) GEN_ERROR("binary operator returned null"); - delete (yyvsp[-3].TypeVal); - ;} - break; - - case 264: -#line 2622 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + delete yyvsp[-3].TypeVal; + ; + break;} +case 263: +#line 2624 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); - if (isa((*(yyvsp[-3].TypeVal)).get())) - GEN_ERROR("Packed types not supported by icmp instruction"); - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); + if (isa((*yyvsp[-3].TypeVal).get())) + GEN_ERROR("Vector types not supported by icmp instruction"); + Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2); - if ((yyval.InstVal) == 0) + yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); + if (yyval.InstVal == 0) GEN_ERROR("icmp operator returned null"); - ;} - break; - - case 265: -#line 2635 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 264: +#line 2637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); - if (isa((*(yyvsp[-3].TypeVal)).get())) - GEN_ERROR("Packed types not supported by fcmp instruction"); - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); + if (isa((*yyvsp[-3].TypeVal).get())) + GEN_ERROR("Vector types not supported by fcmp instruction"); + Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2); - if ((yyval.InstVal) == 0) + yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); + if (yyval.InstVal == 0) GEN_ERROR("fcmp operator returned null"); - ;} - break; - - case 266: -#line 2648 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 265: +#line 2650 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); - Value* Val = (yyvsp[-2].ValueVal); - const Type* DestTy = (yyvsp[0].TypeVal)->get(); - if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy)) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); + Value* Val = yyvsp[-2].ValueVal; + const Type* DestTy = yyvsp[0].TypeVal->get(); + if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) GEN_ERROR("invalid cast opcode for cast from '" + Val->getType()->getDescription() + "' to '" + DestTy->getDescription() + "'"); - (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy); - delete (yyvsp[0].TypeVal); - ;} - break; - - case 267: -#line 2660 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty) + yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); + delete yyvsp[0].TypeVal; + ; + break;} +case 266: +#line 2662 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) GEN_ERROR("select condition must be boolean"); - if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) + if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) GEN_ERROR("select value types should match"); - (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); CHECK_FOR_ERROR - ;} - break; - - case 268: -#line 2668 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 267: +#line 2670 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); - (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); - delete (yyvsp[0].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 269: -#line 2675 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); + yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); + delete yyvsp[0].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 268: +#line 2677 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) GEN_ERROR("Invalid extractelement operands"); - (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); CHECK_FOR_ERROR - ;} - break; - - case 270: -#line 2681 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) + ; + break;} +case 269: +#line 2683 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) GEN_ERROR("Invalid insertelement operands"); - (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); CHECK_FOR_ERROR - ;} - break; - - case 271: -#line 2687 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) + ; + break;} +case 270: +#line 2689 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) GEN_ERROR("Invalid shufflevector operands"); - (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); CHECK_FOR_ERROR - ;} - break; - - case 272: -#line 2693 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); + ; + break;} +case 271: +#line 2695 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + const Type *Ty = yyvsp[0].PHIList->front().first->getType(); if (!Ty->isFirstClassType()) GEN_ERROR("PHI node operands must be of first class type"); - (yyval.InstVal) = new PHINode(Ty); - ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); - while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { - if ((yyvsp[0].PHIList)->front().first->getType() != Ty) + yyval.InstVal = new PHINode(Ty); + ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); + while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { + if (yyvsp[0].PHIList->front().first->getType() != Ty) GEN_ERROR("All elements of a PHI node must be of the same type"); - cast((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); - (yyvsp[0].PHIList)->pop_front(); + cast(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); + yyvsp[0].PHIList->pop_front(); } - delete (yyvsp[0].PHIList); // Free the list... + delete yyvsp[0].PHIList; // Free the list... CHECK_FOR_ERROR - ;} - break; - - case 273: -#line 2709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 272: +#line 2711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ // Handle the short syntax const PointerType *PFTy = 0; const FunctionType *Ty = 0; - if (!(PFTy = dyn_cast((yyvsp[-5].TypeVal)->get())) || + if (!(PFTy = dyn_cast(yyvsp[-5].TypeVal->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; FunctionType::ParamAttrsList ParamAttrs; - ParamAttrs.push_back((yyvsp[0].ParamAttrs)); - for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) { + ParamAttrs.push_back(yyvsp[0].ParamAttrs); + for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) { const Type *Ty = I->Val->getType(); if (Ty == Type::VoidTy) GEN_ERROR("Short call syntax cannot be used with varargs"); @@ -5396,16 +4560,16 @@ ParamAttrs.push_back(I->Attrs); } - Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs); + Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling... + Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling... CHECK_FOR_ERROR // Check the arguments ValueList Args; - if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments? + if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? // Make sure no arguments is a good thing! if (Ty->getNumParams() != 0) GEN_ERROR("No arguments passed to a function that " @@ -5416,7 +4580,7 @@ // FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end(); + ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) { if (ArgI->Val->getType() != *I) @@ -5433,428 +4597,365 @@ } // Create the call node CallInst *CI = new CallInst(V, &Args[0], Args.size()); - CI->setTailCall((yyvsp[-7].BoolVal)); - CI->setCallingConv((yyvsp[-6].UIntVal)); - (yyval.InstVal) = CI; - delete (yyvsp[-2].ValueRefList); - delete (yyvsp[-5].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 274: -#line 2772 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.InstVal) = (yyvsp[0].InstVal); + CI->setTailCall(yyvsp[-7].BoolVal); + CI->setCallingConv(yyvsp[-6].UIntVal); + yyval.InstVal = CI; + delete yyvsp[-2].ValueRefList; + delete yyvsp[-5].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 273: +#line 2774 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.InstVal = yyvsp[0].InstVal; CHECK_FOR_ERROR - ;} - break; - - case 275: -#line 2777 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BoolVal) = true; + ; + break;} +case 274: +#line 2779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BoolVal = true; CHECK_FOR_ERROR - ;} - break; - - case 276: -#line 2781 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - (yyval.BoolVal) = false; + ; + break;} +case 275: +#line 2783 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + yyval.BoolVal = false; CHECK_FOR_ERROR - ;} - break; - - case 277: -#line 2788 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 276: +#line 2790 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); - delete (yyvsp[-1].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 278: -#line 2795 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); + delete yyvsp[-1].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 277: +#line 2797 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); - Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); + Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); - delete (yyvsp[-4].TypeVal); - ;} - break; - - case 279: -#line 2803 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); + delete yyvsp[-4].TypeVal; + ; + break;} +case 278: +#line 2805 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); - delete (yyvsp[-1].TypeVal); - CHECK_FOR_ERROR - ;} - break; - - case 280: -#line 2810 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); + delete yyvsp[-1].TypeVal; + CHECK_FOR_ERROR + ; + break;} +case 279: +#line 2812 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); - Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); + Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); - delete (yyvsp[-4].TypeVal); - ;} - break; - - case 281: -#line 2818 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { - if (!isa((yyvsp[0].ValueVal)->getType())) + yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); + delete yyvsp[-4].TypeVal; + ; + break;} +case 280: +#line 2820 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ + if (!isa(yyvsp[0].ValueVal->getType())) GEN_ERROR("Trying to free nonpointer type " + - (yyvsp[0].ValueVal)->getType()->getDescription() + ""); - (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); + yyvsp[0].ValueVal->getType()->getDescription() + ""); + yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); CHECK_FOR_ERROR - ;} - break; - - case 282: -#line 2826 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + ; + break;} +case 281: +#line 2828 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - if (!isa((yyvsp[-1].TypeVal)->get())) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + if (!isa(yyvsp[-1].TypeVal->get())) GEN_ERROR("Can't load from nonpointer type: " + - (*(yyvsp[-1].TypeVal))->getDescription()); - if (!cast((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) + (*yyvsp[-1].TypeVal)->getDescription()); + if (!cast(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType()) GEN_ERROR("Can't load from pointer of non-first-class type: " + - (*(yyvsp[-1].TypeVal))->getDescription()); - Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); + (*yyvsp[-1].TypeVal)->getDescription()); + Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); - delete (yyvsp[-1].TypeVal); - ;} - break; - - case 283: -#line 2840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); + delete yyvsp[-1].TypeVal; + ; + break;} +case 282: +#line 2842 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); - const PointerType *PT = dyn_cast((yyvsp[-1].TypeVal)->get()); + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); + const PointerType *PT = dyn_cast(yyvsp[-1].TypeVal->get()); if (!PT) GEN_ERROR("Can't store to a nonpointer type: " + - (*(yyvsp[-1].TypeVal))->getDescription()); + (*yyvsp[-1].TypeVal)->getDescription()); const Type *ElTy = PT->getElementType(); - if (ElTy != (yyvsp[-3].ValueVal)->getType()) - GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + + if (ElTy != yyvsp[-3].ValueVal->getType()) + GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() + "' into space of type '" + ElTy->getDescription() + "'"); - Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); - delete (yyvsp[-1].TypeVal); - ;} - break; - - case 284: -#line 2857 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { + yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal); + delete yyvsp[-1].TypeVal; + ; + break;} +case 283: +#line 2859 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" +{ if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); - if (!isa((yyvsp[-2].TypeVal)->get())) + GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); + if (!isa(yyvsp[-2].TypeVal->get())) GEN_ERROR("getelementptr insn requires pointer operand"); - if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true)) + if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true)) GEN_ERROR("Invalid getelementptr indices for type '" + - (*(yyvsp[-2].TypeVal))->getDescription()+ "'"); - Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); + (*yyvsp[-2].TypeVal)->getDescription()+ "'"); + Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); CHECK_FOR_ERROR - (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size()); - delete (yyvsp[-2].TypeVal); - delete (yyvsp[0].ValueList); - ;} - break; - - - default: break; - } - -/* Line 1126 of yacc.c. */ -#line 5590 "llvmAsmParser.tab.c" + yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size()); + delete yyvsp[-2].TypeVal; + delete yyvsp[0].ValueList; + ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/share/bison.simple" yyvsp -= yylen; yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif - - YY_STACK_PRINT (yyss, yyssp); +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif *++yyvsp = yyval; +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTOKENS]; + yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; +yyerrlab: /* here on detecting error */ -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ { ++yynerrs; -#if YYERROR_VERBOSE + +#ifdef YYERROR_VERBOSE yyn = yypact[yystate]; - if (YYPACT_NINF < yyn && yyn < YYLAST) + if (yyn > YYFLAG && yyn < YYLAST) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - char *yymsg = 0; -# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - - if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg) + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yymsg; - int yyi = 0; - while ((*yyp = *yyf)) + strcpy(msg, "parse error"); + + if (count < 5) { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } } - yyerror (yymsg); - YYSTACK_FREE (yymsg); + yyerror(msg); + free(msg); } else - { - yyerror (YY_("syntax error")); - goto yyexhaustedlab; - } + yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ - yyerror (YY_("syntax error")); + yyerror("parse error"); } - + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ + /* if just tried and failed to reuse lookahead token after an error, discard it. */ - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", yytoken, &yylval); - yychar = YYEMPTY; - } + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; } - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; + /* Else will try to reuse lookahead token + after shifting the error token. */ + yyerrstatus = 3; /* Each real token shifted decrements this */ -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (0) - goto yyerrorlab; + goto yyerrhandle; -yyvsp -= yylen; - yyssp -= yylen; - yystate = *yyssp; - goto yyerrlab1; +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif +yyerrpop: /* pop the current state because it cannot handle the error token */ -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif - for (;;) +#if YYDEBUG != 0 + if (yydebug) { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; - yydestruct ("Error: popping", yystos[yystate], yyvsp); - YYPOPSTACK; - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; } + else if (yyn == 0) + goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; - *++yyvsp = yylval; - +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif yystate = yyn; goto yynewstate; + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK; - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); #endif - return yyresult; + } + return 1; } - - -#line 2874 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2876 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" // common code from the two 'RunVMAsmParser' functions @@ -5903,4 +5004,3 @@ GenerateError(errMsg); return 0; } - Index: llvm/lib/AsmParser/llvmAsmParser.h.cvs diff -u llvm/lib/AsmParser/llvmAsmParser.h.cvs:1.55 llvm/lib/AsmParser/llvmAsmParser.h.cvs:1.56 --- llvm/lib/AsmParser/llvmAsmParser.h.cvs:1.55 Wed Feb 14 20:26:09 2007 +++ llvm/lib/AsmParser/llvmAsmParser.h.cvs Mon Feb 19 01:44:24 2007 @@ -1,302 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.1. */ - -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - - 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 2, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ESINT64VAL = 258, - EUINT64VAL = 259, - LOCALVAL_ID = 260, - GLOBALVAL_ID = 261, - FPVAL = 262, - VOID = 263, - INTTYPE = 264, - FLOAT = 265, - DOUBLE = 266, - LABEL = 267, - TYPE = 268, - LOCALVAR = 269, - GLOBALVAR = 270, - LABELSTR = 271, - STRINGCONSTANT = 272, - ATSTRINGCONSTANT = 273, - IMPLEMENTATION = 274, - ZEROINITIALIZER = 275, - TRUETOK = 276, - FALSETOK = 277, - BEGINTOK = 278, - ENDTOK = 279, - DECLARE = 280, - DEFINE = 281, - GLOBAL = 282, - CONSTANT = 283, - SECTION = 284, - VOLATILE = 285, - TO = 286, - DOTDOTDOT = 287, - NULL_TOK = 288, - UNDEF = 289, - INTERNAL = 290, - LINKONCE = 291, - WEAK = 292, - APPENDING = 293, - DLLIMPORT = 294, - DLLEXPORT = 295, - EXTERN_WEAK = 296, - OPAQUE = 297, - EXTERNAL = 298, - TARGET = 299, - TRIPLE = 300, - ALIGN = 301, - DEPLIBS = 302, - CALL = 303, - TAIL = 304, - ASM_TOK = 305, - MODULE = 306, - SIDEEFFECT = 307, - CC_TOK = 308, - CCC_TOK = 309, - FASTCC_TOK = 310, - COLDCC_TOK = 311, - X86_STDCALLCC_TOK = 312, - X86_FASTCALLCC_TOK = 313, - DATALAYOUT = 314, - RET = 315, - BR = 316, - SWITCH = 317, - INVOKE = 318, - UNWIND = 319, - UNREACHABLE = 320, - ADD = 321, - SUB = 322, - MUL = 323, - UDIV = 324, - SDIV = 325, - FDIV = 326, - UREM = 327, - SREM = 328, - FREM = 329, - AND = 330, - OR = 331, - XOR = 332, - SHL = 333, - LSHR = 334, - ASHR = 335, - ICMP = 336, - FCMP = 337, - EQ = 338, - NE = 339, - SLT = 340, - SGT = 341, - SLE = 342, - SGE = 343, - ULT = 344, - UGT = 345, - ULE = 346, - UGE = 347, - OEQ = 348, - ONE = 349, - OLT = 350, - OGT = 351, - OLE = 352, - OGE = 353, - ORD = 354, - UNO = 355, - UEQ = 356, - UNE = 357, - MALLOC = 358, - ALLOCA = 359, - FREE = 360, - LOAD = 361, - STORE = 362, - GETELEMENTPTR = 363, - TRUNC = 364, - ZEXT = 365, - SEXT = 366, - FPTRUNC = 367, - FPEXT = 368, - BITCAST = 369, - UITOFP = 370, - SITOFP = 371, - FPTOUI = 372, - FPTOSI = 373, - INTTOPTR = 374, - PTRTOINT = 375, - PHI_TOK = 376, - SELECT = 377, - VAARG = 378, - EXTRACTELEMENT = 379, - INSERTELEMENT = 380, - SHUFFLEVECTOR = 381, - NORETURN = 382, - INREG = 383, - SRET = 384, - DEFAULT = 385, - HIDDEN = 386 - }; -#endif -/* Tokens. */ -#define ESINT64VAL 258 -#define EUINT64VAL 259 -#define LOCALVAL_ID 260 -#define GLOBALVAL_ID 261 -#define FPVAL 262 -#define VOID 263 -#define INTTYPE 264 -#define FLOAT 265 -#define DOUBLE 266 -#define LABEL 267 -#define TYPE 268 -#define LOCALVAR 269 -#define GLOBALVAR 270 -#define LABELSTR 271 -#define STRINGCONSTANT 272 -#define ATSTRINGCONSTANT 273 -#define IMPLEMENTATION 274 -#define ZEROINITIALIZER 275 -#define TRUETOK 276 -#define FALSETOK 277 -#define BEGINTOK 278 -#define ENDTOK 279 -#define DECLARE 280 -#define DEFINE 281 -#define GLOBAL 282 -#define CONSTANT 283 -#define SECTION 284 -#define VOLATILE 285 -#define TO 286 -#define DOTDOTDOT 287 -#define NULL_TOK 288 -#define UNDEF 289 -#define INTERNAL 290 -#define LINKONCE 291 -#define WEAK 292 -#define APPENDING 293 -#define DLLIMPORT 294 -#define DLLEXPORT 295 -#define EXTERN_WEAK 296 -#define OPAQUE 297 -#define EXTERNAL 298 -#define TARGET 299 -#define TRIPLE 300 -#define ALIGN 301 -#define DEPLIBS 302 -#define CALL 303 -#define TAIL 304 -#define ASM_TOK 305 -#define MODULE 306 -#define SIDEEFFECT 307 -#define CC_TOK 308 -#define CCC_TOK 309 -#define FASTCC_TOK 310 -#define COLDCC_TOK 311 -#define X86_STDCALLCC_TOK 312 -#define X86_FASTCALLCC_TOK 313 -#define DATALAYOUT 314 -#define RET 315 -#define BR 316 -#define SWITCH 317 -#define INVOKE 318 -#define UNWIND 319 -#define UNREACHABLE 320 -#define ADD 321 -#define SUB 322 -#define MUL 323 -#define UDIV 324 -#define SDIV 325 -#define FDIV 326 -#define UREM 327 -#define SREM 328 -#define FREM 329 -#define AND 330 -#define OR 331 -#define XOR 332 -#define SHL 333 -#define LSHR 334 -#define ASHR 335 -#define ICMP 336 -#define FCMP 337 -#define EQ 338 -#define NE 339 -#define SLT 340 -#define SGT 341 -#define SLE 342 -#define SGE 343 -#define ULT 344 -#define UGT 345 -#define ULE 346 -#define UGE 347 -#define OEQ 348 -#define ONE 349 -#define OLT 350 -#define OGT 351 -#define OLE 352 -#define OGE 353 -#define ORD 354 -#define UNO 355 -#define UEQ 356 -#define UNE 357 -#define MALLOC 358 -#define ALLOCA 359 -#define FREE 360 -#define LOAD 361 -#define STORE 362 -#define GETELEMENTPTR 363 -#define TRUNC 364 -#define ZEXT 365 -#define SEXT 366 -#define FPTRUNC 367 -#define FPEXT 368 -#define BITCAST 369 -#define UITOFP 370 -#define SITOFP 371 -#define FPTOUI 372 -#define FPTOSI 373 -#define INTTOPTR 374 -#define PTRTOINT 375 -#define PHI_TOK 376 -#define SELECT 377 -#define VAARG 378 -#define EXTRACTELEMENT 379 -#define INSERTELEMENT 380 -#define SHUFFLEVECTOR 381 -#define NORETURN 382 -#define INREG 383 -#define SRET 384 -#define DEFAULT 385 -#define HIDDEN 386 - - - - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" -typedef union YYSTYPE { +typedef union { llvm::Module *ModuleVal; llvm::Function *FunctionVal; llvm::BasicBlock *BasicBlockVal; @@ -341,14 +43,135 @@ llvm::ICmpInst::Predicate IPredicate; llvm::FCmpInst::Predicate FPredicate; } YYSTYPE; -/* Line 1447 of yacc.c. */ -#line 346 "llvmAsmParser.tab.h" -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -extern YYSTYPE llvmAsmlval; - +#define ESINT64VAL 257 +#define EUINT64VAL 258 +#define LOCALVAL_ID 259 +#define GLOBALVAL_ID 260 +#define FPVAL 261 +#define VOID 262 +#define INTTYPE 263 +#define FLOAT 264 +#define DOUBLE 265 +#define LABEL 266 +#define TYPE 267 +#define LOCALVAR 268 +#define GLOBALVAR 269 +#define LABELSTR 270 +#define STRINGCONSTANT 271 +#define ATSTRINGCONSTANT 272 +#define IMPLEMENTATION 273 +#define ZEROINITIALIZER 274 +#define TRUETOK 275 +#define FALSETOK 276 +#define BEGINTOK 277 +#define ENDTOK 278 +#define DECLARE 279 +#define DEFINE 280 +#define GLOBAL 281 +#define CONSTANT 282 +#define SECTION 283 +#define VOLATILE 284 +#define TO 285 +#define DOTDOTDOT 286 +#define NULL_TOK 287 +#define UNDEF 288 +#define INTERNAL 289 +#define LINKONCE 290 +#define WEAK 291 +#define APPENDING 292 +#define DLLIMPORT 293 +#define DLLEXPORT 294 +#define EXTERN_WEAK 295 +#define OPAQUE 296 +#define EXTERNAL 297 +#define TARGET 298 +#define TRIPLE 299 +#define ALIGN 300 +#define DEPLIBS 301 +#define CALL 302 +#define TAIL 303 +#define ASM_TOK 304 +#define MODULE 305 +#define SIDEEFFECT 306 +#define CC_TOK 307 +#define CCC_TOK 308 +#define FASTCC_TOK 309 +#define COLDCC_TOK 310 +#define X86_STDCALLCC_TOK 311 +#define X86_FASTCALLCC_TOK 312 +#define DATALAYOUT 313 +#define RET 314 +#define BR 315 +#define SWITCH 316 +#define INVOKE 317 +#define UNWIND 318 +#define UNREACHABLE 319 +#define ADD 320 +#define SUB 321 +#define MUL 322 +#define UDIV 323 +#define SDIV 324 +#define FDIV 325 +#define UREM 326 +#define SREM 327 +#define FREM 328 +#define AND 329 +#define OR 330 +#define XOR 331 +#define SHL 332 +#define LSHR 333 +#define ASHR 334 +#define ICMP 335 +#define FCMP 336 +#define EQ 337 +#define NE 338 +#define SLT 339 +#define SGT 340 +#define SLE 341 +#define SGE 342 +#define ULT 343 +#define UGT 344 +#define ULE 345 +#define UGE 346 +#define OEQ 347 +#define ONE 348 +#define OLT 349 +#define OGT 350 +#define OLE 351 +#define OGE 352 +#define ORD 353 +#define UNO 354 +#define UEQ 355 +#define UNE 356 +#define MALLOC 357 +#define ALLOCA 358 +#define FREE 359 +#define LOAD 360 +#define STORE 361 +#define GETELEMENTPTR 362 +#define TRUNC 363 +#define ZEXT 364 +#define SEXT 365 +#define FPTRUNC 366 +#define FPEXT 367 +#define BITCAST 368 +#define UITOFP 369 +#define SITOFP 370 +#define FPTOUI 371 +#define FPTOSI 372 +#define INTTOPTR 373 +#define PTRTOINT 374 +#define PHI_TOK 375 +#define SELECT 376 +#define VAARG 377 +#define EXTRACTELEMENT 378 +#define INSERTELEMENT 379 +#define SHUFFLEVECTOR 380 +#define NORETURN 381 +#define INREG 382 +#define SRET 383 +#define DEFAULT 384 +#define HIDDEN 385 +extern YYSTYPE llvmAsmlval; Index: llvm/lib/AsmParser/llvmAsmParser.y.cvs diff -u llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.70 llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.71 --- llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.70 Wed Feb 14 20:26:09 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y.cvs Mon Feb 19 01:44:24 2007 @@ -1292,7 +1292,7 @@ delete $4; CHECK_FOR_ERROR } - | '<' EUINT64VAL 'x' Types '>' { // Packed array type? + | '<' EUINT64VAL 'x' Types '>' { // Vector type? const llvm::Type* ElemTy = $4->get(); if ((unsigned)$2 != $2) GEN_ERROR("Unsigned result not equal to signed result"); @@ -1525,7 +1525,7 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, *$3); delete $1; delete $3; @@ -1544,7 +1544,7 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, std::vector()); delete $1; @@ -1569,7 +1569,8 @@ // Check to ensure that Type is packed if (!STy->isPacked()) - GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + GEN_ERROR("Vector initializer to non-vector type '" + + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, *$4); delete $1; delete $4; @@ -1588,7 +1589,8 @@ // Check to ensure that Type is packed if (!STy->isPacked()) - GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + GEN_ERROR("Vector initializer to non-vector type '" + + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, std::vector()); delete $1; @@ -2592,7 +2594,7 @@ ($1 == Instruction::URem || $1 == Instruction::SRem || $1 == Instruction::FRem)) - GEN_ERROR("Remainder not supported on packed types"); + GEN_ERROR("Remainder not supported on vector types"); Value* val1 = getVal(*$2, $3); CHECK_FOR_ERROR Value* val2 = getVal(*$2, $5); @@ -2623,7 +2625,7 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); if (isa((*$3).get())) - GEN_ERROR("Packed types not supported by icmp instruction"); + GEN_ERROR("Vector types not supported by icmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); @@ -2636,7 +2638,7 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); if (isa((*$3).get())) - GEN_ERROR("Packed types not supported by fcmp instruction"); + GEN_ERROR("Vector types not supported by fcmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); From baldrick at free.fr Mon Feb 19 08:39:29 2007 From: baldrick at free.fr (Duncan Sands) Date: Mon, 19 Feb 2007 15:39:29 +0100 Subject: [llvm-commits] llvm-gcc4: display the LLVM type when printing type trees In-Reply-To: <770A82A0-7372-4F6E-B25E-26B7366955D1@apple.com> References: <200702152245.30629.baldrick@free.fr> <770A82A0-7372-4F6E-B25E-26B7366955D1@apple.com> Message-ID: <200702191539.30519.baldrick@free.fr> > Very cool. However, it doesn't apply to CVS right. GET_TYPE_LLVM > needs to go through the LTypes vector now, can you plz update the patch? Here you go. I put GET_TYPE_LLVM back into tree.h (it was moved into llvm-types.cpp recently) so that print-tree.c can get at it. I only made a C version available, to discourage use outside of llvm-types.cpp. Ciao, Duncan. -------------- next part -------------- A non-text attachment was scrubbed... Name: print_type.diff Type: text/x-diff Size: 3497 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20070219/868d5c82/attachment.bin From reid at x10sys.com Mon Feb 19 11:38:56 2007 From: reid at x10sys.com (Reid Spencer) Date: Mon, 19 Feb 2007 11:38:56 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702191738.l1JHcunv014866@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.32 -> 1.33 --- Log message: Some minor tweaks and grammar cleanup. --- Diffs of the changes: (+14 -14) DeveloperPolicy.html | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.32 llvm/docs/DeveloperPolicy.html:1.33 --- llvm/docs/DeveloperPolicy.html:1.32 Mon Feb 19 00:57:46 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 11:38:38 2007 @@ -62,10 +62,11 @@

    This section contains policies that pertain to frequent LLVM - developers. We always welcome random patches from - people who do not routinely contribute to LLVM, but expect more from frequent - contributors to keep the system as efficient as possible for everyone. - Frequent LLVM contributors are expected to meet the following obligations in + developers. We always welcome one-off patches from + people who do not routinely contribute to LLVM, but we expect more from + frequent contributors to keep the system as efficient as possible for + everyone. + Frequent LLVM contributors are expected to meet the following requirements in order for LLVM to maintain a high standard of quality.

    @@ -133,15 +134,15 @@ reviewed after commit.
  • The developer responsible for a code change is also responsible for making all necessary review-related changes.
  • -
  • Code review can be an iterative process, which goes until the patch +
  • Code review can be an iterative process, which continues until the patch is ready to be committed.
  • Developers should participate in code reviews as both reviewers and - a reviewees. If someone is kind enough to review your code, you should + reviewees. If someone is kind enough to review your code, you should return the favor for someone else. Note that anyone is welcome to review - and give feedback on a patch, - but only people with CVS write access can approve it.

    + and give feedback on a patch, but only people with CVS write access can + approve it.

    @@ -383,8 +384,8 @@
    -

    This section addresses the issues of copyright and license for the LLVM - project. +

    This section addresses the issues of copyright, license and patents for + the LLVM project. Currently, the University of Illinois is the LLVM copyright holder and the terms of its license to LLVM users and developers is the University of @@ -392,10 +393,9 @@

    -
    @@ -446,7 +446,7 @@ software (notably, llvm-gcc which is based on the GCC GPL source base). This means that anything "linked" into to llvm-gcc must itself be compatible with the GPL, and must be releasable under the terms of the GPL. This implies - that you any code linked into llvm-gcc and distributed to others may be + that any code linked into llvm-gcc and distributed to others may be subject to the viral aspects of the GPL. This is not a problem for the main LLVM distribution (which is already licensed under a more liberal license), but may @@ -499,7 +499,7 @@ Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 06:57:46 $ + Last modified: $Date: 2007/02/19 17:38:38 $ From isanbard at gmail.com Mon Feb 19 12:33:00 2007 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 19 Feb 2007 12:33:00 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702191833.l1JIX01d015856@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.33 -> 1.34 --- Log message: Corrected typo. --- Diffs of the changes: (+2 -2) DeveloperPolicy.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.33 llvm/docs/DeveloperPolicy.html:1.34 --- llvm/docs/DeveloperPolicy.html:1.33 Mon Feb 19 11:38:38 2007 +++ llvm/docs/DeveloperPolicy.html Mon Feb 19 12:32:40 2007 @@ -444,7 +444,7 @@

    Note that the LLVM Project does distribute some code that includes GPL software (notably, llvm-gcc which is based on the GCC GPL source base). - This means that anything "linked" into to llvm-gcc must itself be compatible + This means that anything "linked" into llvm-gcc must itself be compatible with the GPL, and must be releasable under the terms of the GPL. This implies that any code linked into llvm-gcc and distributed to others may be subject to @@ -499,7 +499,7 @@ Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 17:38:38 $ + Last modified: $Date: 2007/02/19 18:32:40 $ From reid at x10sys.com Mon Feb 19 13:00:46 2007 From: reid at x10sys.com (Reid Spencer) Date: Mon, 19 Feb 2007 13:00:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Message-ID: <200702191900.l1JJ0kgI016701@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.67 -> 1.68 --- Log message: Add a FIXME for unwritten code. --- Diffs of the changes: (+2 -0) Instruction.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.67 llvm/lib/VMCore/Instruction.cpp:1.68 --- llvm/lib/VMCore/Instruction.cpp:1.67 Thu Feb 15 20:25:55 2007 +++ llvm/lib/VMCore/Instruction.cpp Mon Feb 19 13:00:29 2007 @@ -239,6 +239,8 @@ case Instruction::Call: if (const IntrinsicInst *II = dyn_cast(this)) { // If the intrinsic doesn't write memory, it is safe. + // FIXME: this is obviously supposed to determine which intrinsics + // don't write to memory, but hasn't been implemented yet. } return true; case Instruction::Load: From evan.cheng at apple.com Mon Feb 19 13:23:10 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 13:23:10 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702191923.l1JJNA7T017378@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.126 -> 1.127 --- Log message: Temporarily reverting the patch. It's breaking llvm-gcc build. --- Diffs of the changes: (+14 -0) Constants.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.126 llvm/include/llvm/Constants.h:1.127 --- llvm/include/llvm/Constants.h:1.126 Mon Feb 19 01:44:24 2007 +++ llvm/include/llvm/Constants.h Mon Feb 19 13:22:52 2007 @@ -550,6 +550,10 @@ /// static Constant *getSizeOf(const Type *Ty); + /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant array, + /// return a pointer to a pointer of the array element type. + static Constant *getPtrPtrFromArrayPtr(Constant *C); + /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// @@ -589,6 +593,16 @@ static Constant *getGetElementPtr(Constant *C, Value* const *IdxList, unsigned NumIdx); + // FIXME: Remove these. + static Constant *getGetElementPtr(Constant *C, + const std::vector &IdxList) { + return getGetElementPtr(C, &IdxList[0], IdxList.size()); + } + static Constant *getGetElementPtr(Constant *C, + const std::vector &IdxList) { + return getGetElementPtr(C, &IdxList[0], IdxList.size()); + } + static Constant *getExtractElement(Constant *Vec, Constant *Idx); static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx); static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask); From evan.cheng at apple.com Mon Feb 19 13:23:58 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 13:23:58 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702191923.l1JJNwp5017407@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.212 -> 1.213 --- Log message: Temporarily reverting the patch. It's breaking llvm-gcc build. --- Diffs of the changes: (+20 -15) Constants.cpp | 35 ++++++++++++++++++++--------------- 1 files changed, 20 insertions(+), 15 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.212 llvm/lib/VMCore/Constants.cpp:1.213 --- llvm/lib/VMCore/Constants.cpp:1.212 Mon Feb 19 01:44:24 2007 +++ llvm/lib/VMCore/Constants.cpp Mon Feb 19 13:23:41 2007 @@ -22,7 +22,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" -#include "llvm/ADT/SmallVector.h" #include #include using namespace llvm; @@ -483,14 +482,13 @@ Op2 = (OpNo == 2) ? Op : getOperand(2); return ConstantExpr::getShuffleVector(Op0, Op1, Op2); case Instruction::GetElementPtr: { - SmallVector Ops; - Ops.resize(getNumOperands()); + std::vector Ops; for (unsigned i = 1, e = getNumOperands(); i != e; ++i) - Ops[i] = getOperand(i); + Ops.push_back(getOperand(i)); if (OpNo == 0) - return ConstantExpr::getGetElementPtr(Op, &Ops[0], Ops.size()); + return ConstantExpr::getGetElementPtr(Op, Ops); Ops[OpNo-1] = Op; - return ConstantExpr::getGetElementPtr(getOperand(0), &Ops[0], Ops.size()); + return ConstantExpr::getGetElementPtr(getOperand(0), Ops); } default: assert(getNumOperands() == 2 && "Must be binary operator?"); @@ -537,8 +535,10 @@ return ConstantExpr::getExtractElement(Ops[0], Ops[1]); case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); - case Instruction::GetElementPtr: - return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1); + case Instruction::GetElementPtr: { + std::vector ActualOps(Ops.begin()+1, Ops.end()); + return ConstantExpr::getGetElementPtr(Ops[0], ActualOps); + } case Instruction::ICmp: case Instruction::FCmp: return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]); @@ -1578,10 +1578,16 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) { // sizeof is implemented as: (ulong) gep (Ty*)null, 1 - Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1); - Constant *GEP = - getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1); - return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty); + return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue( + PointerType::get(Ty)), std::vector(1, + ConstantInt::get(Type::Int32Ty, 1))), Type::Int64Ty); +} + +Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { + // pointer from array is implemented as: getelementptr arr ptr, 0, 0 + static std::vector Indices(2, ConstantInt::get(Type::Int32Ty, 0)); + + return ConstantExpr::getGetElementPtr(C, Indices); } Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, @@ -2023,7 +2029,7 @@ Constant *Replacement = 0; if (getOpcode() == Instruction::GetElementPtr) { - SmallVector Indices; + std::vector Indices; Constant *Pointer = getOperand(0); Indices.reserve(getNumOperands()-1); if (Pointer == From) Pointer = To; @@ -2033,8 +2039,7 @@ if (Val == From) Val = To; Indices.push_back(Val); } - Replacement = ConstantExpr::getGetElementPtr(Pointer, - &Indices[0], Indices.size()); + Replacement = ConstantExpr::getGetElementPtr(Pointer, Indices); } else if (isCast()) { assert(getOperand(0) == From && "Cast only has one use!"); Replacement = ConstantExpr::getCast(getOpcode(), To, getType()); From sabre at nondot.org Mon Feb 19 13:46:34 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 13:46:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Message-ID: <200702191946.l1JJkYNo017931@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.68 -> 1.69 --- Log message: remove warning --- Diffs of the changes: (+2 -2) Instruction.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.68 llvm/lib/VMCore/Instruction.cpp:1.69 --- llvm/lib/VMCore/Instruction.cpp:1.68 Mon Feb 19 13:00:29 2007 +++ llvm/lib/VMCore/Instruction.cpp Mon Feb 19 13:46:17 2007 @@ -237,11 +237,11 @@ case Instruction::VAArg: return true; case Instruction::Call: - if (const IntrinsicInst *II = dyn_cast(this)) { + //if (const IntrinsicInst *II = dyn_cast(this)) { // If the intrinsic doesn't write memory, it is safe. // FIXME: this is obviously supposed to determine which intrinsics // don't write to memory, but hasn't been implemented yet. - } + //} return true; case Instruction::Load: return cast(this)->isVolatile(); From clattner at apple.com Mon Feb 19 13:51:57 2007 From: clattner at apple.com (clattner at apple.com) Date: Mon, 19 Feb 2007 11:51:57 -0800 (PST) Subject: [llvm-commits] [124085] adjust to new ConstantExpr API. Message-ID: <20070219195157.D6AAA52703A8@src> Revision: 124085 Author: clattner Date: 2007-02-19 11:51:56 -0800 (Mon, 19 Feb 2007) Log Message: ----------- adjust to new ConstantExpr API. Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-convert.cpp Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-19 08:46:45 UTC (rev 124084) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-19 19:51:56 UTC (rev 124085) @@ -5345,7 +5345,7 @@ if (TREE_CODE (TREE_TYPE(Array)) == ARRAY_TYPE) Idx.push_back(ConstantInt::get(Type::Int32Ty, 0)); Idx.push_back(IndexVal); - return ConstantExpr::getGetElementPtr(ArrayAddr, Idx); + return ConstantExpr::getGetElementPtr(ArrayAddr, &Idx[0], Idx.size()); } Constant *TreeConstantToLLVM::EmitLV_COMPONENT_REF(tree exp) { @@ -5378,7 +5378,8 @@ std::vector Idxs; Idxs.push_back(Constant::getNullValue(Type::Int32Ty)); Idxs.push_back(CI); - FieldPtr = ConstantExpr::getGetElementPtr(StructAddrLV, Idxs); + FieldPtr = ConstantExpr::getGetElementPtr(StructAddrLV, &Idxs[0], + Idxs.size()); // Now that we did an offset from the start of the struct, subtract off // the offset from BitStart. From sabre at nondot.org Mon Feb 19 14:01:44 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 14:01:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702192001.l1JK1i4S018314@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.213 -> 1.214 --- Log message: llvm-gcc issue fixed, revert reversal :) --- Diffs of the changes: (+15 -20) Constants.cpp | 35 +++++++++++++++-------------------- 1 files changed, 15 insertions(+), 20 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.213 llvm/lib/VMCore/Constants.cpp:1.214 --- llvm/lib/VMCore/Constants.cpp:1.213 Mon Feb 19 13:23:41 2007 +++ llvm/lib/VMCore/Constants.cpp Mon Feb 19 14:01:23 2007 @@ -22,6 +22,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" +#include "llvm/ADT/SmallVector.h" #include #include using namespace llvm; @@ -482,13 +483,14 @@ Op2 = (OpNo == 2) ? Op : getOperand(2); return ConstantExpr::getShuffleVector(Op0, Op1, Op2); case Instruction::GetElementPtr: { - std::vector Ops; + SmallVector Ops; + Ops.resize(getNumOperands()); for (unsigned i = 1, e = getNumOperands(); i != e; ++i) - Ops.push_back(getOperand(i)); + Ops[i] = getOperand(i); if (OpNo == 0) - return ConstantExpr::getGetElementPtr(Op, Ops); + return ConstantExpr::getGetElementPtr(Op, &Ops[0], Ops.size()); Ops[OpNo-1] = Op; - return ConstantExpr::getGetElementPtr(getOperand(0), Ops); + return ConstantExpr::getGetElementPtr(getOperand(0), &Ops[0], Ops.size()); } default: assert(getNumOperands() == 2 && "Must be binary operator?"); @@ -535,10 +537,8 @@ return ConstantExpr::getExtractElement(Ops[0], Ops[1]); case Instruction::ShuffleVector: return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]); - case Instruction::GetElementPtr: { - std::vector ActualOps(Ops.begin()+1, Ops.end()); - return ConstantExpr::getGetElementPtr(Ops[0], ActualOps); - } + case Instruction::GetElementPtr: + return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1); case Instruction::ICmp: case Instruction::FCmp: return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]); @@ -1578,16 +1578,10 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) { // sizeof is implemented as: (ulong) gep (Ty*)null, 1 - return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue( - PointerType::get(Ty)), std::vector(1, - ConstantInt::get(Type::Int32Ty, 1))), Type::Int64Ty); -} - -Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) { - // pointer from array is implemented as: getelementptr arr ptr, 0, 0 - static std::vector Indices(2, ConstantInt::get(Type::Int32Ty, 0)); - - return ConstantExpr::getGetElementPtr(C, Indices); + Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1); + Constant *GEP = + getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1); + return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty); } Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, @@ -2029,7 +2023,7 @@ Constant *Replacement = 0; if (getOpcode() == Instruction::GetElementPtr) { - std::vector Indices; + SmallVector Indices; Constant *Pointer = getOperand(0); Indices.reserve(getNumOperands()-1); if (Pointer == From) Pointer = To; @@ -2039,7 +2033,8 @@ if (Val == From) Val = To; Indices.push_back(Val); } - Replacement = ConstantExpr::getGetElementPtr(Pointer, Indices); + Replacement = ConstantExpr::getGetElementPtr(Pointer, + &Indices[0], Indices.size()); } else if (isCast()) { assert(getOperand(0) == From && "Cast only has one use!"); Replacement = ConstantExpr::getCast(getOpcode(), To, getType()); From sabre at nondot.org Mon Feb 19 14:01:44 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 14:01:44 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702192001.l1JK1ijn018309@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.127 -> 1.128 --- Log message: llvm-gcc issue fixed, revert reversal :) --- Diffs of the changes: (+0 -14) Constants.h | 14 -------------- 1 files changed, 14 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.127 llvm/include/llvm/Constants.h:1.128 --- llvm/include/llvm/Constants.h:1.127 Mon Feb 19 13:22:52 2007 +++ llvm/include/llvm/Constants.h Mon Feb 19 14:01:23 2007 @@ -550,10 +550,6 @@ /// static Constant *getSizeOf(const Type *Ty); - /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant array, - /// return a pointer to a pointer of the array element type. - static Constant *getPtrPtrFromArrayPtr(Constant *C); - /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// @@ -593,16 +589,6 @@ static Constant *getGetElementPtr(Constant *C, Value* const *IdxList, unsigned NumIdx); - // FIXME: Remove these. - static Constant *getGetElementPtr(Constant *C, - const std::vector &IdxList) { - return getGetElementPtr(C, &IdxList[0], IdxList.size()); - } - static Constant *getGetElementPtr(Constant *C, - const std::vector &IdxList) { - return getGetElementPtr(C, &IdxList[0], IdxList.size()); - } - static Constant *getExtractElement(Constant *Vec, Constant *Idx); static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx); static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask); From clattner at apple.com Mon Feb 19 14:15:15 2007 From: clattner at apple.com (clattner at apple.com) Date: Mon, 19 Feb 2007 12:15:15 -0800 (PST) Subject: [llvm-commits] [124086] don't dereference a null type-size field. Message-ID: <20070219201515.B25AB52A19C9@src> Revision: 124086 Author: clattner Date: 2007-02-19 12:15:12 -0800 (Mon, 19 Feb 2007) Log Message: ----------- don't dereference a null type-size field. Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-types.cpp Modified: apple-local/branches/llvm/gcc/llvm-types.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-19 19:51:56 UTC (rev 124085) +++ apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-19 20:15:12 UTC (rev 124086) @@ -212,7 +212,8 @@ bool isPassedByInvisibleReference(tree Type) { // FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there are other // cases that make arguments automatically passed in by reference. - return TREE_ADDRESSABLE(Type) || TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST; + return TREE_ADDRESSABLE(Type) || TYPE_SIZE(Type) == 0 || + TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST; } /// GetTypeName - Return a fully qualified (with namespace prefixes) name for From sabre at nondot.org Mon Feb 19 14:20:20 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 14:20:20 -0600 Subject: [llvm-commits] CVS: llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c Message-ID: <200702192020.l1JKKKvI018868@zion.cs.uiuc.edu> Changes in directory llvm/test/CFrontend: 2007-02-04-WITH_SIZE_EXPR.c updated: 1.1 -> 1.2 --- Log message: this passes now --- Diffs of the changes: (+0 -1) 2007-02-04-WITH_SIZE_EXPR.c | 1 - 1 files changed, 1 deletion(-) Index: llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c diff -u llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c:1.1 llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c:1.2 --- llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c:1.1 Sun Feb 4 21:56:59 2007 +++ llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c Mon Feb 19 14:20:04 2007 @@ -1,6 +1,5 @@ // RUN: %llvmgcc %s -O3 -S -o - -emit-llvm // PR1174 -// XFAIL: * void zzz (char *s1, char *s2, int len, int *q) { From rspencer at reidspencer.com Mon Feb 19 14:37:20 2007 From: rspencer at reidspencer.com (Reid Spencer) Date: Mon, 19 Feb 2007 12:37:20 -0800 Subject: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support Message-ID: <1171917440.25169.107.camel@bashful.x10sys.com> Devang / Jim / Chris, The attached patch has been reviewed by Devang and provides the "bitwidth" attribute and 3 builtin functions for arbitrary precision integers (concat, bit select, part select). This is the same as the last version except it has an additional check for a null pointer that produced a failure in bootstrap. That problem is now gone and this patch passes the Integer test suite as well as MultiSource/Benchmarks. I would appreciate it if you could commit this one or indicate why it could not be committed. Thanks, Reid. P.S. There's likely to be two merge conflicts as this patch includes the changes to fix the getGetElementPtr interface change as well as Chris' version of the change to llvm-types.cpp that I suggested today. Fortunately these should be easy to resolve: just take the llvm-gcc version in each case .. hopefully svn is smart enough to recognize the changes as being equivalent. -------------- next part -------------- A non-text attachment was scrubbed... Name: BITWIDTH11.patch Type: text/x-patch Size: 36974 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20070219/a646bbd2/attachment.bin From evan.cheng at apple.com Mon Feb 19 15:47:18 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:47:18 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll Message-ID: <200702192147.l1JLlIgx020482@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/PowerPC: LargeAbsoluteAddr.ll updated: 1.2 -> 1.3 --- Log message: Fix test case. --- Diffs of the changes: (+3 -3) LargeAbsoluteAddr.ll | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll diff -u llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll:1.2 llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll:1.3 --- llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll:1.2 Sat Feb 17 00:57:11 2007 +++ llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll Mon Feb 19 15:47:02 2007 @@ -1,6 +1,6 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stw r3, 32751' && -; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stw r3, 32751' && -; RUN: llvm-as < %s | llc -march=ppc64 | grep 'std r2, 9024' && +; RUN: llvm-as < %s | llc -march=ppc32 -mtriple=powerpc-apple-darwin | grep 'stw r3, 32751' && +; RUN: llvm-as < %s | llc -march=ppc64 -mtriple=powerpc-apple-darwin | grep 'stw r3, 32751' && +; RUN: llvm-as < %s | llc -march=ppc64 -mtriple=powerpc-apple-darwin | grep 'std r2, 9024' && ; RUN: llvm-as < %s | llc define void @test() { From evan.cheng at apple.com Mon Feb 19 15:50:29 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp LiveVariables.cpp MachineBasicBlock.cpp MachineInstr.cpp RegAllocLinearScan.cpp Message-ID: <200702192150.l1JLoTfQ020623@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.208 -> 1.209 LiveVariables.cpp updated: 1.67 -> 1.68 MachineBasicBlock.cpp updated: 1.41 -> 1.42 MachineInstr.cpp updated: 1.143 -> 1.144 RegAllocLinearScan.cpp updated: 1.139 -> 1.140 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+164 -85) LiveIntervalAnalysis.cpp | 189 +++++++++++++++++++++++++++++++++-------------- LiveVariables.cpp | 36 +------- MachineBasicBlock.cpp | 8 + MachineInstr.cpp | 11 ++ RegAllocLinearScan.cpp | 5 - 5 files changed, 164 insertions(+), 85 deletions(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.208 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.209 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.208 Sun Feb 18 21:20:00 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Feb 19 15:49:53 2007 @@ -98,28 +98,6 @@ // Set the MBB2IdxMap entry for this MBB. MBB2IdxMap[MBB->getNumber()] = MIIndex; - // If this BB has any live ins, insert a dummy instruction at the - // beginning of the function that we will pretend "defines" the values. This - // is to make the interval analysis simpler by providing a number. - if (MBB->livein_begin() != MBB->livein_end()) { - unsigned FirstLiveIn = *MBB->livein_begin(); - - // Find a reg class that contains this live in. - const TargetRegisterClass *RC = 0; - for (MRegisterInfo::regclass_iterator RCI = mri_->regclass_begin(), - RCE = mri_->regclass_end(); RCI != RCE; ++RCI) - if ((*RCI)->contains(FirstLiveIn)) { - RC = *RCI; - break; - } - - MachineInstr *OldFirstMI = MBB->begin(); - mri_->copyRegToReg(*MBB, MBB->begin(), - FirstLiveIn, FirstLiveIn, RC); - assert(OldFirstMI != MBB->begin() && - "copyRetToReg didn't insert anything!"); - } - for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; ++I) { bool inserted = mi2iMap_.insert(std::make_pair(I, MIIndex)).second; @@ -161,7 +139,17 @@ if (tii_->isMoveInstr(*mii, srcReg, dstReg) && (RegRep = rep(srcReg)) == rep(dstReg)) { // remove from def list - getOrCreateInterval(RegRep); + LiveInterval &RegInt = getOrCreateInterval(RegRep); + MachineOperand *MO = mii->findRegisterDefOperand(dstReg); + // If def of this move instruction is dead, remove its live range from + // the dstination register's live interval. + if (MO->isDead()) { + unsigned MoveIdx = getDefIndex(getInstructionIndex(mii)); + LiveInterval::iterator MLR = RegInt.FindLiveRangeContaining(MoveIdx); + RegInt.removeRange(MLR->start, MoveIdx+1); + if (RegInt.empty()) + removeInterval(RegRep); + } RemoveMachineInstrFromMaps(mii); mii = mbbi->erase(mii); ++numPeep; @@ -185,7 +173,6 @@ } } - for (iterator I = begin(), E = end(); I != E; ++I) { LiveInterval &LI = I->second; if (MRegisterInfo::isVirtualRegister(LI.reg)) { @@ -670,6 +657,43 @@ } } +void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB, + LiveInterval &interval) { + DOUT << "\t\tlivein register: "; DEBUG(printRegName(interval.reg)); + + // Look for kills, if it reaches a def before it's killed, then it shouldn't + // be considered a livein. + MachineBasicBlock::iterator mi = MBB->begin(); + unsigned baseIndex = 0; + unsigned start = 0; + unsigned end = start; + while (mi != MBB->end()) { + if (lv_->KillsRegister(mi, interval.reg)) { + DOUT << " killed"; + end = getUseIndex(baseIndex) + 1; + goto exit; + } else if (lv_->ModifiesRegister(mi, interval.reg)) { + // Another instruction redefines the register before it is ever read. + // Then the register is essentially dead at the instruction that defines + // it. Hence its interval is: + // [defSlot(def), defSlot(def)+1) + DOUT << " dead"; + end = getDefIndex(start) + 1; + goto exit; + } + + baseIndex += InstrSlots::NUM; + ++mi; + } + +exit: + assert(start < end && "did not find end of interval?"); + + LiveRange LR(start, end, interval.getNextValue(~0U, 0)); + interval.addRange(LR); + DOUT << " +" << LR << '\n'; +} + /// computeIntervals - computes the live intervals for virtual /// registers. for some ordering of the machine instructions [1,N] a /// live interval is an interval [i, j) where 1 <= i <= j < N for @@ -688,17 +712,13 @@ MachineBasicBlock::iterator MI = MBB->begin(), miEnd = MBB->end(); if (MBB->livein_begin() != MBB->livein_end()) { - // Process live-ins to this BB first. - for (MachineBasicBlock::livein_iterator LI = MBB->livein_begin(), + // Create intervals for live-ins to this BB first. + for (MachineBasicBlock::const_livein_iterator LI = MBB->livein_begin(), LE = MBB->livein_end(); LI != LE; ++LI) { - handlePhysicalRegisterDef(MBB, MBB->begin(), MIIndex, - getOrCreateInterval(*LI), 0); + handleLiveInRegister(MBB, getOrCreateInterval(*LI)); for (const unsigned* AS = mri_->getAliasSet(*LI); *AS; ++AS) - handlePhysicalRegisterDef(MBB, MBB->begin(), MIIndex, - getOrCreateInterval(*AS), 0); + handleLiveInRegister(MBB, getOrCreateInterval(*AS)); } - ++MI; - MIIndex += InstrSlots::NUM; } for (; MI != miEnd; ++MI) { @@ -815,7 +835,6 @@ return true; } - /// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg, /// which are the src/dst of the copy instruction CopyMI. This returns true /// if the copy was successfully coallesced away, or if it is never possible @@ -825,54 +844,93 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI, unsigned SrcReg, unsigned DstReg) { DOUT << getInstructionIndex(CopyMI) << '\t' << *CopyMI; - + // Get representative registers. - SrcReg = rep(SrcReg); - DstReg = rep(DstReg); + unsigned repSrcReg = rep(SrcReg); + unsigned repDstReg = rep(DstReg); // If they are already joined we continue. - if (SrcReg == DstReg) { + if (repSrcReg == repDstReg) { DOUT << "\tCopy already coallesced.\n"; return true; // Not coallescable. } // If they are both physical registers, we cannot join them. - if (MRegisterInfo::isPhysicalRegister(SrcReg) && - MRegisterInfo::isPhysicalRegister(DstReg)) { + if (MRegisterInfo::isPhysicalRegister(repSrcReg) && + MRegisterInfo::isPhysicalRegister(repDstReg)) { DOUT << "\tCan not coallesce physregs.\n"; return true; // Not coallescable. } // We only join virtual registers with allocatable physical registers. - if (MRegisterInfo::isPhysicalRegister(SrcReg) && !allocatableRegs_[SrcReg]){ + if (MRegisterInfo::isPhysicalRegister(repSrcReg) && + !allocatableRegs_[repSrcReg]) { DOUT << "\tSrc reg is unallocatable physreg.\n"; return true; // Not coallescable. } - if (MRegisterInfo::isPhysicalRegister(DstReg) && !allocatableRegs_[DstReg]){ + if (MRegisterInfo::isPhysicalRegister(repDstReg) && + !allocatableRegs_[repDstReg]) { DOUT << "\tDst reg is unallocatable physreg.\n"; return true; // Not coallescable. } // If they are not of the same register class, we cannot join them. - if (differingRegisterClasses(SrcReg, DstReg)) { + if (differingRegisterClasses(repSrcReg, repDstReg)) { DOUT << "\tSrc/Dest are different register classes.\n"; return true; // Not coallescable. } - LiveInterval &SrcInt = getInterval(SrcReg); - LiveInterval &DestInt = getInterval(DstReg); - assert(SrcInt.reg == SrcReg && DestInt.reg == DstReg && + LiveInterval &SrcInt = getInterval(repSrcReg); + LiveInterval &DestInt = getInterval(repDstReg); + assert(SrcInt.reg == repSrcReg && DestInt.reg == repDstReg && "Register mapping is horribly broken!"); DOUT << "\t\tInspecting "; SrcInt.print(DOUT, mri_); DOUT << " and "; DestInt.print(DOUT, mri_); DOUT << ": "; - + + // Check if it is necessary to propagate "isDead" property before intervals + // are joined. + MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg); + bool isDead = mopd->isDead(); + unsigned SrcStart = 0; + unsigned SrcEnd = 0; + if (isDead) { + unsigned CopyIdx = getDefIndex(getInstructionIndex(CopyMI)); + LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(CopyIdx-1); + SrcStart = SrcLR->start; + SrcEnd = SrcLR->end; + if (hasRegisterUse(repSrcReg, SrcStart, SrcEnd)) + isDead = false; + } + // Okay, attempt to join these two intervals. On failure, this returns false. // Otherwise, if one of the intervals being joined is a physreg, this method // always canonicalizes DestInt to be it. The output "SrcInt" will not have // been modified, so we can use this information below to update aliases. - if (!JoinIntervals(DestInt, SrcInt)) { + if (JoinIntervals(DestInt, SrcInt)) { + if (isDead) { + // Result of the copy is dead. Propagate this property. + if (SrcStart == 0) { + // Live-in to the function but dead. Remove it from MBB live-in set. + // JoinIntervals may end up swapping the two intervals. + LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt:SrcInt; + LiveInInt.removeRange(SrcStart, SrcEnd); + MachineBasicBlock *MBB = CopyMI->getParent(); + MBB->removeLiveIn(SrcReg); + } else { + MachineInstr *SrcMI = getInstructionFromIndex(SrcStart); + if (SrcMI) { + // FIXME: SrcMI == NULL means the register is livein to a non-entry + // MBB. Remove the range from its live interval? + MachineOperand *mops = SrcMI->findRegisterDefOperand(SrcReg); + if (mops) + // FIXME: mops == NULL means SrcMI defines a subregister? + mops->setIsDead(); + } + } + } + } else { // Coallescing failed. // If we can eliminate the copy without merging the live ranges, do so now. @@ -884,17 +942,17 @@ return false; } - bool Swapped = SrcReg == DestInt.reg; + bool Swapped = repSrcReg == DestInt.reg; if (Swapped) - std::swap(SrcReg, DstReg); - assert(MRegisterInfo::isVirtualRegister(SrcReg) && + std::swap(repSrcReg, repDstReg); + assert(MRegisterInfo::isVirtualRegister(repSrcReg) && "LiveInterval::join didn't work right!"); // If we're about to merge live ranges into a physical register live range, // we have to update any aliased register's live ranges to indicate that they // have clobbered values for this range. - if (MRegisterInfo::isPhysicalRegister(DstReg)) { - for (const unsigned *AS = mri_->getAliasSet(DstReg); *AS; ++AS) + if (MRegisterInfo::isPhysicalRegister(repDstReg)) { + for (const unsigned *AS = mri_->getAliasSet(repDstReg); *AS; ++AS) getInterval(*AS).MergeInClobberRanges(SrcInt); } @@ -904,8 +962,8 @@ // If the intervals were swapped by Join, swap them back so that the register // mapping (in the r2i map) is correct. if (Swapped) SrcInt.swap(DestInt); - r2iMap_.erase(SrcReg); - r2rMap_[SrcReg] = DstReg; + removeInterval(repSrcReg); + r2rMap_[repSrcReg] = repDstReg; // Finally, delete the copy instruction. RemoveMachineInstrFromMaps(CopyMI); @@ -1389,6 +1447,29 @@ return !RegClass->contains(RegB); } +/// hasRegisterUse - Returns true if there is any use of the specific +/// reg between indexes Start and End. +bool +LiveIntervals::hasRegisterUse(unsigned Reg, unsigned Start, unsigned End) { + for (unsigned Index = Start+InstrSlots::NUM; Index != End; + Index += InstrSlots::NUM) { + // Skip deleted instructions + while (Index != End && !getInstructionFromIndex(Index)) + Index += InstrSlots::NUM; + if (Index >= End) break; + + MachineInstr *MI = getInstructionFromIndex(Index); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isUse() && MO.getReg() && + mri_->regsOverlap(rep(MO.getReg()), Reg)) + return true; + } + } + + return false; +} + LiveInterval LiveIntervals::createInterval(unsigned reg) { float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VALF : 0.0F; Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.67 llvm/lib/CodeGen/LiveVariables.cpp:1.68 --- llvm/lib/CodeGen/LiveVariables.cpp:1.67 Sun Feb 18 21:20:00 2007 +++ llvm/lib/CodeGen/LiveVariables.cpp Mon Feb 19 15:49:53 2007 @@ -71,31 +71,11 @@ return VirtRegInfo[RegIdx]; } -/// registerOverlap - Returns true if register 1 is equal to register 2 -/// or if register 1 is equal to any of alias of register 2. -static bool registerOverlap(unsigned Reg1, unsigned Reg2, - const MRegisterInfo *RegInfo) { - bool isVirt1 = MRegisterInfo::isVirtualRegister(Reg1); - bool isVirt2 = MRegisterInfo::isVirtualRegister(Reg2); - if (isVirt1 != isVirt2) - return false; - if (Reg1 == Reg2) - return true; - else if (isVirt1) - return false; - for (const unsigned *AliasSet = RegInfo->getAliasSet(Reg2); - unsigned Alias = *AliasSet; ++AliasSet) { - if (Reg1 == Alias) - return true; - } - return false; -} - bool LiveVariables::KillsRegister(MachineInstr *MI, unsigned Reg) const { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.isKill()) { - if (registerOverlap(Reg, MO.getReg(), RegInfo)) + if (RegInfo->regsOverlap(Reg, MO.getReg())) return true; } } @@ -106,7 +86,7 @@ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.isDead()) - if (registerOverlap(Reg, MO.getReg(), RegInfo)) + if (RegInfo->regsOverlap(Reg, MO.getReg())) return true; } return false; @@ -116,7 +96,7 @@ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.isDef()) { - if (registerOverlap(Reg, MO.getReg(), RegInfo)) + if (RegInfo->regsOverlap(Reg, MO.getReg())) return true; } } @@ -240,7 +220,7 @@ RegInfo = MF.getTarget().getRegisterInfo(); assert(RegInfo && "Target doesn't have register information?"); - AllocatablePhysicalRegisters = RegInfo->getAllocatableSet(MF); + ReservedRegisters = RegInfo->getReservedRegs(MF); // PhysRegInfo - Keep track of which instruction was the last use of a // physical register. This is a purely local property, because all physical @@ -267,8 +247,8 @@ E = df_ext_end(Entry, Visited); DFI != E; ++DFI) { MachineBasicBlock *MBB = *DFI; - // Mark live-in registers as live-in. - for (MachineBasicBlock::livein_iterator II = MBB->livein_begin(), + // Mark live-in registers as live-in. + for (MachineBasicBlock::const_livein_iterator II = MBB->livein_begin(), EE = MBB->livein_end(); II != EE; ++II) { assert(MRegisterInfo::isPhysicalRegister(*II) && "Cannot have a live-in virtual register!"); @@ -295,7 +275,7 @@ if (MRegisterInfo::isVirtualRegister(MO.getReg())){ HandleVirtRegUse(getVarInfo(MO.getReg()), MBB, MI); } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && - AllocatablePhysicalRegisters[MO.getReg()]) { + !ReservedRegisters[MO.getReg()]) { HandlePhysRegUse(MO.getReg(), MI); } } @@ -313,7 +293,7 @@ // Defaults to dead VRInfo.Kills.push_back(MI); } else if (MRegisterInfo::isPhysicalRegister(MO.getReg()) && - AllocatablePhysicalRegisters[MO.getReg()]) { + !ReservedRegisters[MO.getReg()]) { HandlePhysRegDef(MO.getReg(), MI); } } Index: llvm/lib/CodeGen/MachineBasicBlock.cpp diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.41 llvm/lib/CodeGen/MachineBasicBlock.cpp:1.42 --- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.41 Sun Feb 18 21:20:00 2007 +++ llvm/lib/CodeGen/MachineBasicBlock.cpp Mon Feb 19 15:49:53 2007 @@ -118,7 +118,7 @@ const MRegisterInfo *MRI = MF->getTarget().getRegisterInfo(); if (livein_begin() != livein_end()) { OS << "Live Ins:"; - for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I) + for (const_livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I) OutputReg(OS, *I, MRI); OS << "\n"; } @@ -144,6 +144,12 @@ } } +void MachineBasicBlock::removeLiveIn(unsigned Reg) { + livein_iterator I = std::find(livein_begin(), livein_end(), Reg); + assert(I != livein_end() && "Not a live in!"); + LiveIns.erase(I); +} + void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) { MachineFunction::BasicBlockListType &BBList =getParent()->getBasicBlockList(); getParent()->getBasicBlockList().splice(NewAfter, BBList, this); Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.143 llvm/lib/CodeGen/MachineInstr.cpp:1.144 --- llvm/lib/CodeGen/MachineInstr.cpp:1.143 Sun Feb 18 21:20:00 2007 +++ llvm/lib/CodeGen/MachineInstr.cpp Mon Feb 19 15:49:53 2007 @@ -180,6 +180,17 @@ return NULL; } +/// findRegisterDefOperand() - Returns the MachineOperand that is a def of +/// the specific register or NULL if it is not found. +MachineOperand *MachineInstr::findRegisterDefOperand(unsigned Reg) { + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { + MachineOperand &MO = getOperand(i); + if (MO.isReg() && MO.isDef() && MO.getReg() == Reg) + return &MO; + } + return NULL; +} + /// copyKillDeadInfo - Copies kill / dead operand properties from MI. /// void MachineInstr::copyKillDeadInfo(const MachineInstr *MI) { Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.139 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.140 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.139 Sun Feb 18 21:20:00 2007 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Feb 19 15:49:53 2007 @@ -292,8 +292,9 @@ } // A brute force way of adding live-ins to every BB. - for (MachineFunction::iterator MBB = mf_->begin(), E = mf_->end(); - MBB != E; ++MBB) { + MachineFunction::iterator MBB = mf_->begin(); + ++MBB; // Skip entry MBB. + for (MachineFunction::iterator E = mf_->end(); MBB != E; ++MBB) { unsigned StartIdx = li_->getMBBStartIdx(MBB->getNumber()); for (IntervalPtrs::iterator i = fixed_.begin(), e = fixed_.end(); i != e; ++i) From evan.cheng at apple.com Mon Feb 19 15:50:31 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp SparcRegisterInfo.h Message-ID: <200702192150.l1JLoVM8020630@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegisterInfo.cpp updated: 1.53 -> 1.54 SparcRegisterInfo.h updated: 1.19 -> 1.20 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+19 -0) SparcRegisterInfo.cpp | 17 +++++++++++++++++ SparcRegisterInfo.h | 2 ++ 2 files changed, 19 insertions(+) Index: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.53 llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.54 --- llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.53 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Mon Feb 19 15:49:54 2007 @@ -20,6 +20,7 @@ #include "llvm/CodeGen/MachineLocation.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Type.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; @@ -116,6 +117,22 @@ return CalleeSavedRegs; } +BitVector SparcRegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(SP::G2); + Reserved.set(SP::G3); + Reserved.set(SP::G4); + Reserved.set(SP::O6); + Reserved.set(SP::I6); + Reserved.set(SP::I7); + Reserved.set(SP::G0); + Reserved.set(SP::G5); + Reserved.set(SP::G6); + Reserved.set(SP::G7); + return Reserved; +} + + const TargetRegisterClass* const* SparcRegisterInfo::getCalleeSavedRegClasses() const { static const TargetRegisterClass * const CalleeSavedRegClasses[] = { 0 }; Index: llvm/lib/Target/Sparc/SparcRegisterInfo.h diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.19 llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.20 --- llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.19 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.h Mon Feb 19 15:49:54 2007 @@ -52,6 +52,8 @@ const TargetRegisterClass* const* getCalleeSavedRegClasses() const; + BitVector getReservedRegs(const MachineFunction &MF) const; + bool hasFP(const MachineFunction &MF) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, From evan.cheng at apple.com Mon Feb 19 15:50:32 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMRegisterInfo.cpp ARMRegisterInfo.h Message-ID: <200702192150.l1JLoW71020637@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMRegisterInfo.cpp updated: 1.68 -> 1.69 ARMRegisterInfo.h updated: 1.9 -> 1.10 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+17 -0) ARMRegisterInfo.cpp | 15 +++++++++++++++ ARMRegisterInfo.h | 2 ++ 2 files changed, 17 insertions(+) Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.68 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.69 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.68 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Mon Feb 19 15:49:53 2007 @@ -28,6 +28,7 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include @@ -297,6 +298,20 @@ return CalleeSavedRegClasses; } +BitVector ARMRegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(ARM::SP); + if (STI.isTargetDarwin() || hasFP(MF)) + Reserved.set(FramePtr); + // Some targets reserve R9. + if (STI.isR9Reserved()) + Reserved.set(ARM::R9); + // At PEI time, if LR is used, it will be spilled upon entry. + if (MF.getUsedPhysregs() && !MF.isPhysRegUsed((unsigned)ARM::LR)) + Reserved.set(ARM::LR); + return Reserved; +} + /// hasFP - Return true if the specified function should have a dedicated frame /// pointer register. This is true if the function has variable sized allocas /// or if frame pointer elimination is disabled. Index: llvm/lib/Target/ARM/ARMRegisterInfo.h diff -u llvm/lib/Target/ARM/ARMRegisterInfo.h:1.9 llvm/lib/Target/ARM/ARMRegisterInfo.h:1.10 --- llvm/lib/Target/ARM/ARMRegisterInfo.h:1.9 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.h Mon Feb 19 15:49:53 2007 @@ -67,6 +67,8 @@ const TargetRegisterClass* const* getCalleeSavedRegClasses() const; + BitVector getReservedRegs(const MachineFunction &MF) const; + bool hasFP(const MachineFunction &MF) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, From evan.cheng at apple.com Mon Feb 19 15:50:35 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:35 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h LiveVariables.h MachineBasicBlock.h MachineInstr.h Message-ID: <200702192150.l1JLoZQO020650@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervalAnalysis.h updated: 1.70 -> 1.71 LiveVariables.h updated: 1.34 -> 1.35 MachineBasicBlock.h updated: 1.57 -> 1.58 MachineInstr.h updated: 1.211 -> 1.212 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+35 -9) LiveIntervalAnalysis.h | 18 ++++++++++++++++-- LiveVariables.h | 9 +++++---- MachineBasicBlock.h | 13 ++++++++++--- MachineInstr.h | 4 ++++ 4 files changed, 35 insertions(+), 9 deletions(-) Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.70 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.71 --- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.70 Sun Feb 18 21:20:00 2007 +++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Feb 19 15:49:53 2007 @@ -118,6 +118,11 @@ return I->second; } + bool hasInterval(unsigned reg) const { + Reg2IntervalMap::const_iterator I = r2iMap_.find(reg); + return I != r2iMap_.end(); + } + /// getMBBStartIdx - Return the base index of the first instruction in the /// specified MachineBasicBlock. unsigned getMBBStartIdx(MachineBasicBlock *MBB) const { @@ -189,6 +194,7 @@ /// copies that cannot yet be coallesced into the "TryAgain" list. void CopyCoallesceInMBB(MachineBasicBlock *MBB, std::vector &TryAgain); + /// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg, /// which are the src/dst of the copy instruction CopyMI. This returns true /// if the copy was successfully coallesced away, or if it is never possible @@ -233,6 +239,9 @@ LiveInterval &interval, unsigned SrcReg); + /// handleLiveInRegister - Create interval for a livein register. + void handleLiveInRegister(MachineBasicBlock* mbb, LiveInterval &interval); + /// Return true if the two specified registers belong to different /// register classes. The registers may be either phys or virt regs. bool differingRegisterClasses(unsigned RegA, unsigned RegB) const; @@ -241,11 +250,16 @@ bool AdjustCopiesBackFrom(LiveInterval &IntA, LiveInterval &IntB, MachineInstr *CopyMI); - bool overlapsAliases(const LiveInterval *lhs, - const LiveInterval *rhs) const; + /// hasRegisterUse - Returns true if there is any use of the specific + /// reg between indexes Start and End. + bool hasRegisterUse(unsigned Reg, unsigned Start, unsigned End); static LiveInterval createInterval(unsigned Reg); + void removeInterval(unsigned Reg) { + r2iMap_.erase(Reg); + } + LiveInterval &getOrCreateInterval(unsigned reg) { Reg2IntervalMap::iterator I = r2iMap_.find(reg); if (I == r2iMap_.end()) Index: llvm/include/llvm/CodeGen/LiveVariables.h diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.34 llvm/include/llvm/CodeGen/LiveVariables.h:1.35 --- llvm/include/llvm/CodeGen/LiveVariables.h:1.34 Sun Feb 18 21:20:00 2007 +++ llvm/include/llvm/CodeGen/LiveVariables.h Mon Feb 19 15:49:53 2007 @@ -36,6 +36,7 @@ namespace llvm { class MRegisterInfo; +class BitVector; class LiveVariables : public MachineFunctionPass { public: @@ -108,11 +109,11 @@ /// std::vector VirtRegInfo; - /// AllocatablePhysicalRegisters - This vector keeps track of which registers - /// are actually register allocatable by the target machine. We can not track - /// liveness for values that are not in this set. + /// ReservedRegisters - This vector keeps track of which registers + /// are reserved register which are not allocatable by the target machine. + /// We can not track liveness for values that are in this set. /// - BitVector AllocatablePhysicalRegisters; + BitVector ReservedRegisters; private: // Intermediate data structures const MRegisterInfo *RegInfo; Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.57 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.58 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.57 Sun Feb 18 21:20:00 2007 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Mon Feb 19 15:49:53 2007 @@ -138,11 +138,18 @@ /// is an error to add the same register to the same set more than once. void addLiveIn(unsigned Reg) { LiveIns.push_back(Reg); } + /// removeLiveIn - Remove the specified register from the live in set. + /// + void removeLiveIn(unsigned Reg); + // Iteration support for live in sets. These sets are kept in sorted // order by their register number. - typedef std::vector::const_iterator livein_iterator; - livein_iterator livein_begin() const { return LiveIns.begin(); } - livein_iterator livein_end() const { return LiveIns.end(); } + typedef std::vector::iterator livein_iterator; + typedef std::vector::const_iterator const_livein_iterator; + livein_iterator livein_begin() { return LiveIns.begin(); } + const_livein_iterator livein_begin() const { return LiveIns.begin(); } + livein_iterator livein_end() { return LiveIns.end(); } + const_livein_iterator livein_end() const { return LiveIns.end(); } bool livein_empty() const { return LiveIns.empty(); } // Code Layout methods. Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.211 llvm/include/llvm/CodeGen/MachineInstr.h:1.212 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.211 Sun Feb 18 21:20:00 2007 +++ llvm/include/llvm/CodeGen/MachineInstr.h Mon Feb 19 15:49:53 2007 @@ -393,6 +393,10 @@ /// the specific register or NULL if it is not found. MachineOperand *findRegisterUseOperand(unsigned Reg); + /// findRegisterDefOperand() - Returns the MachineOperand that is a def of + /// the specific register or NULL if it is not found. + MachineOperand *findRegisterDefOperand(unsigned Reg); + /// copyKillDeadInfo - Copies kill / dead operand properties from MI. /// void copyKillDeadInfo(const MachineInstr *MI); From evan.cheng at apple.com Mon Feb 19 15:50:35 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64RegisterInfo.cpp IA64RegisterInfo.h Message-ID: <200702192150.l1JLoZia020669@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64RegisterInfo.cpp updated: 1.30 -> 1.31 IA64RegisterInfo.h updated: 1.13 -> 1.14 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+16 -0) IA64RegisterInfo.cpp | 14 ++++++++++++++ IA64RegisterInfo.h | 2 ++ 2 files changed, 16 insertions(+) Index: llvm/lib/Target/IA64/IA64RegisterInfo.cpp diff -u llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.30 llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.31 --- llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.30 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/IA64/IA64RegisterInfo.cpp Mon Feb 19 15:49:54 2007 @@ -28,6 +28,7 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CommandLine.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; @@ -106,6 +107,19 @@ return CalleeSavedRegClasses; } +BitVector IA64RegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(IA64::r0); + Reserved.set(IA64::r1); + Reserved.set(IA64::r2); + Reserved.set(IA64::r5); + Reserved.set(IA64::r12); + Reserved.set(IA64::r13); + Reserved.set(IA64::r22); + Reserved.set(IA64::rp); + return Reserved; +} + //===----------------------------------------------------------------------===// // Stack Frame Processing methods //===----------------------------------------------------------------------===// Index: llvm/lib/Target/IA64/IA64RegisterInfo.h diff -u llvm/lib/Target/IA64/IA64RegisterInfo.h:1.13 llvm/lib/Target/IA64/IA64RegisterInfo.h:1.14 --- llvm/lib/Target/IA64/IA64RegisterInfo.h:1.13 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/IA64/IA64RegisterInfo.h Mon Feb 19 15:49:54 2007 @@ -48,6 +48,8 @@ const TargetRegisterClass* const* getCalleeSavedRegClasses() const; + BitVector getReservedRegs(const MachineFunction &MF) const; + bool hasFP(const MachineFunction &MF) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, From evan.cheng at apple.com Mon Feb 19 15:50:35 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/MRegisterInfo.cpp Message-ID: <200702192150.l1JLoZsl020674@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: MRegisterInfo.cpp updated: 1.21 -> 1.22 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+1 -1) MRegisterInfo.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/MRegisterInfo.cpp diff -u llvm/lib/Target/MRegisterInfo.cpp:1.21 llvm/lib/Target/MRegisterInfo.cpp:1.22 --- llvm/lib/Target/MRegisterInfo.cpp:1.21 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/MRegisterInfo.cpp Mon Feb 19 15:49:53 2007 @@ -41,7 +41,7 @@ const TargetRegisterClass *RC = *I; for (TargetRegisterClass::iterator I = RC->allocation_order_begin(MF), E = RC->allocation_order_end(MF); I != E; ++I) - Allocatable[*I] = true; + Allocatable.set(*I); } return Allocatable; } From evan.cheng at apple.com Mon Feb 19 15:50:35 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp PPCRegisterInfo.h Message-ID: <200702192150.l1JLoZ41020681@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.cpp updated: 1.107 -> 1.108 PPCRegisterInfo.h updated: 1.26 -> 1.27 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+32 -9) PPCRegisterInfo.cpp | 39 ++++++++++++++++++++++++++++++--------- PPCRegisterInfo.h | 2 ++ 2 files changed, 32 insertions(+), 9 deletions(-) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.107 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.107 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Feb 19 15:49:54 2007 @@ -34,6 +34,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include using namespace llvm; @@ -338,6 +339,35 @@ Darwin32_CalleeSavedRegClasses; } +// needsFP - Return true if the specified function should have a dedicated frame +// pointer register. This is true if the function has variable sized allocas or +// if frame pointer elimination is disabled. +// +static bool needsFP(const MachineFunction &MF) { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + return NoFramePointerElim || MFI->hasVarSizedObjects(); +} + +BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(PPC::R0); + Reserved.set(PPC::R1); + Reserved.set(PPC::LR); + // In Linux, r2 is reserved for the OS. + if (!Subtarget.isDarwin()) + Reserved.set(PPC::R2); + // On PPC64, r13 is the thread pointer. Never allocate this register. + // Note that this is overconservative, as it also prevents allocation of + // R31 when the FP is not needed. + if (Subtarget.isPPC64()) { + Reserved.set(PPC::R13); + Reserved.set(PPC::R31); + } + if (needsFP(MF)) + Reserved.set(PPC::R31); + return Reserved; +} + /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into /// copy instructions, turning them into load/store instructions. MachineInstr *PPCRegisterInfo::foldMemoryOperand(MachineInstr *MI, @@ -398,15 +428,6 @@ // Stack Frame Processing methods //===----------------------------------------------------------------------===// -// needsFP - Return true if the specified function should have a dedicated frame -// pointer register. This is true if the function has variable sized allocas or -// if frame pointer elimination is disabled. -// -static bool needsFP(const MachineFunction &MF) { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects(); -} - // hasFP - Return true if the specified function actually has a dedicated frame // pointer register. This is true if the function needs a frame pointer and has // a non-zero stack size. Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.26 llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.26 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Mon Feb 19 15:49:54 2007 @@ -58,6 +58,8 @@ const TargetRegisterClass* const* getCalleeSavedRegClasses() const; + BitVector getReservedRegs(const MachineFunction &MF) const; + /// targetHandlesStackFrameRounding - Returns true if the target is /// responsible for rounding up the stack frame (probably at emitPrologue /// time). From evan.cheng at apple.com Mon Feb 19 15:50:35 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp X86RegisterInfo.h Message-ID: <200702192150.l1JLoZVY020659@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.202 -> 1.203 X86RegisterInfo.h updated: 1.47 -> 1.48 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+22 -0) X86RegisterInfo.cpp | 16 ++++++++++++++++ X86RegisterInfo.h | 6 ++++++ 2 files changed, 22 insertions(+) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.202 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.203 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.202 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Mon Feb 19 15:49:54 2007 @@ -31,6 +31,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Support/CommandLine.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; @@ -883,6 +884,21 @@ return Is64Bit ? CalleeSavedRegClasses64Bit : CalleeSavedRegClasses32Bit; } +BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(X86::RSP); + Reserved.set(X86::ESP); + Reserved.set(X86::SP); + Reserved.set(X86::SPL); + if (hasFP(MF)) { + Reserved.set(X86::RBP); + Reserved.set(X86::EBP); + Reserved.set(X86::BP); + Reserved.set(X86::BPL); + } + return Reserved; +} + //===----------------------------------------------------------------------===// // Stack Frame Processing methods //===----------------------------------------------------------------------===// Index: llvm/lib/Target/X86/X86RegisterInfo.h diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.47 llvm/lib/Target/X86/X86RegisterInfo.h:1.48 --- llvm/lib/Target/X86/X86RegisterInfo.h:1.47 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/X86/X86RegisterInfo.h Mon Feb 19 15:49:54 2007 @@ -78,6 +78,12 @@ /// length of this list match the getCalleeSavedRegs() list. const TargetRegisterClass* const* getCalleeSavedRegClasses() const; + /// getReservedRegs - Returns a bitset indexed by physical register number + /// indicating if a register is a special register that has particular uses and + /// should be considered unavailable at all times, e.g. SP, RA. This is used by + /// register scavenger to determine what registers are free. + BitVector getReservedRegs(const MachineFunction &MF) const; + bool hasFP(const MachineFunction &MF) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, From evan.cheng at apple.com Mon Feb 19 15:50:35 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:35 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200702192150.l1JLoZmQ020657@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.93 -> 1.94 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+17 -0) MRegisterInfo.h | 17 +++++++++++++++++ 1 files changed, 17 insertions(+) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.93 llvm/include/llvm/Target/MRegisterInfo.h:1.94 --- llvm/include/llvm/Target/MRegisterInfo.h:1.93 Sun Feb 18 21:20:00 2007 +++ llvm/include/llvm/Target/MRegisterInfo.h Mon Feb 19 15:49:53 2007 @@ -284,6 +284,17 @@ return false; } + /// regsOverlap - Returns true if the two registers are equal or alias + /// each other. The registers may be virtual register. + bool regsOverlap(unsigned regA, unsigned regB) const { + if (regA == regB) + return true; + + if (isVirtualRegister(regA) || isVirtualRegister(regB)) + return false; + return areAliases(regA, regB); + } + /// getCalleeSavedRegs - Return a null-terminated list of all of the /// callee saved registers on this target. The register should be in the /// order of desired callee-save stack frame offset. The first register is @@ -295,6 +306,12 @@ /// length of this list match the getCalleeSaveRegs() list. virtual const TargetRegisterClass* const *getCalleeSavedRegClasses() const =0; + /// getReservedRegs - Returns a bitset indexed by physical register number + /// indicating if a register is a special register that has particular uses and + /// should be considered unavailable at all times, e.g. SP, RA. This is used by + /// register scavenger to determine what registers are free. + virtual BitVector getReservedRegs(const MachineFunction &MF) const = 0; + //===--------------------------------------------------------------------===// // Register Class Information // From evan.cheng at apple.com Mon Feb 19 15:50:36 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:50:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp AlphaRegisterInfo.h Message-ID: <200702192150.l1JLoakT020688@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.59 -> 1.60 AlphaRegisterInfo.h updated: 1.19 -> 1.20 --- Log message: Re-apply my liveintervalanalysis changes. Now with PR1207: http://llvm.org/PR1207 fixes. --- Diffs of the changes: (+11 -0) AlphaRegisterInfo.cpp | 9 +++++++++ AlphaRegisterInfo.h | 2 ++ 2 files changed, 11 insertions(+) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.59 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.60 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.59 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Mon Feb 19 15:49:54 2007 @@ -28,6 +28,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include using namespace llvm; @@ -178,6 +179,14 @@ return CalleeSavedRegClasses; } +BitVector AlphaRegisterInfo::getReservedRegs(const MachineFunction &MF) const { + BitVector Reserved(getNumRegs()); + Reserved.set(Alpha::R15); + Reserved.set(Alpha::R30); + Reserved.set(Alpha::R31); + return Reserved; +} + //===----------------------------------------------------------------------===// // Stack Frame Processing methods //===----------------------------------------------------------------------===// Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.h diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.19 llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.20 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.19 Sun Feb 18 21:20:00 2007 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.h Mon Feb 19 15:49:54 2007 @@ -49,6 +49,8 @@ const TargetRegisterClass* const* getCalleeSavedRegClasses() const; + BitVector getReservedRegs(const MachineFunction &MF) const; + bool hasFP(const MachineFunction &MF) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, From evan.cheng at apple.com Mon Feb 19 15:54:19 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 15:54:19 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp Message-ID: <200702192154.l1JLsJT6020786@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: 2007-02-19-LiveIntervalAssert.cpp added (r1.1) --- Log message: Added test case for PR1207: http://llvm.org/PR1207 . --- Diffs of the changes: (+21 -0) 2007-02-19-LiveIntervalAssert.cpp | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+) Index: llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp diff -c /dev/null llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp:1.1 *** /dev/null Mon Feb 19 15:54:09 2007 --- llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp Mon Feb 19 15:53:59 2007 *************** *** 0 **** --- 1,21 ---- + ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-pc-linux-gnu -relocation-model=pic + ; PR1027 + + %struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] } + %struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 } + @stderr = external global %struct._IO_FILE* + + define void @__eprintf(i8* %string, i8* %expression, i32 %line, i8* %filename) { + %tmp = load %struct._IO_FILE** @stderr + %tmp5 = tail call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( %struct._IO_FILE* %tmp, i8* %string, i8* %expression, i32 %line, i8* %filename ) + %tmp6 = load %struct._IO_FILE** @stderr + %tmp7 = tail call i32 @fflush( %struct._IO_FILE* %tmp6 ) + tail call void @abort( ) + unreachable + } + + declare i32 @fprintf(%struct._IO_FILE*, i8*, ...) + + declare i32 @fflush(%struct._IO_FILE*) + + declare void @abort() From dpatel at apple.com Mon Feb 19 15:55:10 2007 From: dpatel at apple.com (Devang Patel) Date: Mon, 19 Feb 2007 13:55:10 -0800 Subject: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support In-Reply-To: <1171917440.25169.107.camel@bashful.x10sys.com> References: <1171917440.25169.107.camel@bashful.x10sys.com> Message-ID: <2DCA8336-CC66-4D3E-8059-209550C89922@apple.com> On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote: > Devang / Jim / Chris, > > The attached patch has been reviewed by Devang and provides the > "bitwidth" attribute and 3 builtin functions for arbitrary precision > integers (concat, bit select, part select). This is the same as the > last > version except it has an additional check for a null pointer that > produced a failure in bootstrap. That problem is now gone and this > patch passes the Integer test suite as well as MultiSource/Benchmarks. > > I would appreciate it if you could commit this one or indicate why it > could not be committed. Where you able to complete bootstrap successfully ? Chris, do you want to take a look at this patch, specially C++ FE changes? - Devang > > Thanks, > > Reid. > > P.S. There's likely to be two merge conflicts as this patch includes > the > changes to fix the getGetElementPtr interface change as well as Chris' > version of the change to llvm-types.cpp that I suggested today. > Fortunately these should be easy to resolve: just take the llvm-gcc > version in each case .. hopefully svn is smart enough to recognize the > changes as being equivalent. > > > From evan.cheng at apple.com Mon Feb 19 16:03:30 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 16:03:30 -0600 Subject: [llvm-commits] CVS: llvm-test/MultiSource/Applications/SIBsim4/Makefile Message-ID: <200702192203.l1JM3ULO020974@zion.cs.uiuc.edu> Changes in directory llvm-test/MultiSource/Applications/SIBsim4: Makefile updated: 1.1 -> 1.2 --- Log message: Fix RUN_OPTIONS. --- Diffs of the changes: (+1 -1) Makefile | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-test/MultiSource/Applications/SIBsim4/Makefile diff -u llvm-test/MultiSource/Applications/SIBsim4/Makefile:1.1 llvm-test/MultiSource/Applications/SIBsim4/Makefile:1.2 --- llvm-test/MultiSource/Applications/SIBsim4/Makefile:1.1 Thu Feb 15 17:46:09 2007 +++ llvm-test/MultiSource/Applications/SIBsim4/Makefile Mon Feb 19 16:03:13 2007 @@ -4,6 +4,6 @@ CPPFLAGS = LDFLAGS = -RUN_OPTIONS="$(PROJ_SRC_DIR)/x.fa $(PROJ_SRC_DIR)/y.fa -A4" +RUN_OPTIONS= -A4 $(PROJ_SRC_DIR)/x.fa $(PROJ_SRC_DIR)/y.fa include ../../Makefile.multisrc From bwendlin at apple.com Mon Feb 19 16:14:15 2007 From: bwendlin at apple.com (bwendlin at apple.com) Date: Mon, 19 Feb 2007 14:14:15 -0800 (PST) Subject: [llvm-commits] [124087] The buildit command on X86 was failing because the gcse. o file was being Message-ID: <20070219221415.E0FD0533A816@src> Revision: 124087 Author: bwendlin Date: 2007-02-19 14:14:13 -0800 (Mon, 19 Feb 2007) Log Message: ----------- The buildit command on X86 was failing because the gcse.o file was being included in the garbage collection when LLVM was built into a dylib. (Thanks to Chris for discovering this.) We need to not include gcse.c in the gty stuff when building as dylib. Modified Paths: -------------- apple-local/branches/llvm/gcc/Makefile.in Modified: apple-local/branches/llvm/gcc/Makefile.in =================================================================== --- apple-local/branches/llvm/gcc/Makefile.in 2007-02-19 20:15:12 UTC (rev 124086) +++ apple-local/branches/llvm/gcc/Makefile.in 2007-02-19 22:14:13 UTC (rev 124087) @@ -1098,6 +1098,13 @@ OBJS-common := $(filter-out bt-load.o caller-save.o combine.o cse.o ifcvt.o \ simplify-rtx.o, $(OBJS-common)) +# APPLE LOCAL begin LLVM - Remove gcse.o +# Remove RTL optimization that requires a function we don't link in. +ifdef BUILD_LLVM_INTO_A_DYLIB +OBJS-common := $(filter-out gcse.o, $(OBJS-common)) +endif +# APPLE LOCAL end LLVM - Remove gcse.o + # Remove generated files. OBJS-common := $(filter-out insn-attrtab.o insn-recog.o insn-extract.o, \ $(OBJS-common)) @@ -2762,6 +2769,12 @@ $(out_file) \ @all_gtfiles@ +# APPLE LOCAL begin LLVM - Remove gcse.c +ifdef BUILD_LLVM_INTO_A_DYLIB +GTFILES := $(filter-out $(srcdir)/gcse.c, $(GTFILES)) +endif +# APPLE LOCAL end LLVM - Remove gcse.c + GTFILES_FILES_LANGS = @all_gtfiles_files_langs@ GTFILES_FILES_FILES = @all_gtfiles_files_files@ GTFILES_LANG_DIR_NAMES = @subdirs@ From rspencer at reidspencer.com Mon Feb 19 16:16:01 2007 From: rspencer at reidspencer.com (Reid Spencer) Date: Mon, 19 Feb 2007 14:16:01 -0800 Subject: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support In-Reply-To: <2DCA8336-CC66-4D3E-8059-209550C89922@apple.com> References: <1171917440.25169.107.camel@bashful.x10sys.com> <2DCA8336-CC66-4D3E-8059-209550C89922@apple.com> Message-ID: <1171923361.25169.118.camel@bashful.x10sys.com> On Mon, 2007-02-19 at 13:55 -0800, Devang Patel wrote: > On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote: > > > Devang / Jim / Chris, > > > > The attached patch has been reviewed by Devang and provides the > > "bitwidth" attribute and 3 builtin functions for arbitrary precision > > integers (concat, bit select, part select). This is the same as the > > last > > version except it has an additional check for a null pointer that > > produced a failure in bootstrap. That problem is now gone and this > > patch passes the Integer test suite as well as MultiSource/Benchmarks. > > > > I would appreciate it if you could commit this one or indicate why it > > could not be committed. > > Where you able to complete bootstrap successfully ? "make bootstrap" from clean directory worked. > Chris, do you want to take a look at this patch, specially C++ FE > changes? > > - > Devang > > > > > > > Thanks, > > > > Reid. > > > > P.S. There's likely to be two merge conflicts as this patch includes > > the > > changes to fix the getGetElementPtr interface change as well as Chris' > > version of the change to llvm-types.cpp that I suggested today. > > Fortunately these should be easy to resolve: just take the llvm-gcc > > version in each case .. hopefully svn is smart enough to recognize the > > changes as being equivalent. > > > > > > > From reid at x10sys.com Mon Feb 19 16:35:23 2007 From: reid at x10sys.com (Reid Spencer) Date: Mon, 19 Feb 2007 16:35:23 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h Message-ID: <200702192235.l1JMZNFG021639@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetData.h updated: 1.57 -> 1.58 --- Log message: Implement support for non-standard integer bit widths of any size. The rules alignment is to pick the alignment that corresponds to the smallest specified alignment that is larger than the bit width of the type or the largest specified integer alignment if none are larger than the bitwidth of the type. For the byte size, the size returned is the next larger multiple of the alignment for that type (using the above rule). This patch also changes bit widths from "short" to "uint32_t" to ensure there are enough bits to specify any bit width that LLVM can handle (currently 2^23); 16-bits isn't enough. --- Diffs of the changes: (+6 -6) TargetData.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Target/TargetData.h diff -u llvm/include/llvm/Target/TargetData.h:1.57 llvm/include/llvm/Target/TargetData.h:1.58 --- llvm/include/llvm/Target/TargetData.h:1.57 Fri Feb 16 18:41:42 2007 +++ llvm/include/llvm/Target/TargetData.h Mon Feb 19 16:35:00 2007 @@ -51,11 +51,11 @@ AlignTypeEnum AlignType : 8; //< Alignment type (AlignTypeEnum) unsigned char ABIAlign; //< ABI alignment for this type/bitw unsigned char PrefAlign; //< Pref. alignment for this type/bitw - short TypeBitWidth; //< Type bit width + uint32_t TypeBitWidth; //< Type bit width /// Initializer static TargetAlignElem get(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, short bit_width); + unsigned char pref_align, uint32_t bit_width); /// Equality predicate bool operator==(const TargetAlignElem &rhs) const; /// output stream operator @@ -89,8 +89,8 @@ //! Set/initialize target alignments void setAlignment(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, short bit_width); - unsigned getAlignmentInfo(AlignTypeEnum align_type, short bit_width, + unsigned char pref_align, uint32_t bit_width); + unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width, bool ABIAlign) const; //! Internal helper method that returns requested alignment for type. unsigned char getAlignment(const Type *Ty, bool abi_or_pref) const; @@ -161,11 +161,11 @@ /// specified type. uint64_t getTypeSizeInBits(const Type* Ty) const; - /// getTypeAlignmentABI - Return the minimum ABI-required alignment for the + /// getABITypeAlignment - Return the minimum ABI-required alignment for the /// specified type. unsigned char getABITypeAlignment(const Type *Ty) const; - /// getTypeAlignmentPref - Return the preferred stack/global alignment for + /// getPrefTypeAlignment - Return the preferred stack/global alignment for /// the specified type. unsigned char getPrefTypeAlignment(const Type *Ty) const; From reid at x10sys.com Mon Feb 19 16:35:22 2007 From: reid at x10sys.com (Reid Spencer) Date: Mon, 19 Feb 2007 16:35:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200702192235.l1JMZMKd021634@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.101 -> 1.102 --- Log message: Implement support for non-standard integer bit widths of any size. The rules alignment is to pick the alignment that corresponds to the smallest specified alignment that is larger than the bit width of the type or the largest specified integer alignment if none are larger than the bitwidth of the type. For the byte size, the size returned is the next larger multiple of the alignment for that type (using the above rule). This patch also changes bit widths from "short" to "uint32_t" to ensure there are enough bits to specify any bit width that LLVM can handle (currently 2^23); 16-bits isn't enough. --- Diffs of the changes: (+33 -10) TargetData.cpp | 43 +++++++++++++++++++++++++++++++++---------- 1 files changed, 33 insertions(+), 10 deletions(-) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.101 llvm/lib/Target/TargetData.cpp:1.102 --- llvm/lib/Target/TargetData.cpp:1.101 Fri Feb 16 18:41:42 2007 +++ llvm/lib/Target/TargetData.cpp Mon Feb 19 16:35:00 2007 @@ -94,7 +94,7 @@ TargetAlignElem TargetAlignElem::get(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, short bit_width) { + unsigned char pref_align, uint32_t bit_width) { TargetAlignElem retval; retval.AlignType = align_type; retval.ABIAlign = abi_align; @@ -188,7 +188,7 @@ std::string arg0 = getToken(token, ":"); const char *p = arg0.c_str(); AlignTypeEnum align_type; - short size; + uint32_t size; unsigned char abi_align; unsigned char pref_align; @@ -213,7 +213,7 @@ align_type = (*p == 'i' ? INTEGER_ALIGN : (*p == 'f' ? FLOAT_ALIGN : (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN))); - size = (short) atoi(++p); + size = (uint32_t) atoi(++p); abi_align = atoi(getToken(token, ":").c_str()) / 8; pref_align = atoi(getToken(token, ":").c_str()) / 8; if (pref_align == 0) @@ -233,7 +233,7 @@ void TargetData::setAlignment(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, short bit_width) { + unsigned char pref_align, uint32_t bit_width) { for (unsigned i = 0, e = Alignments.size(); i != e; ++i) { if (Alignments[i].AlignType == align_type && Alignments[i].TypeBitWidth == bit_width) { @@ -250,10 +250,11 @@ /// getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or /// preferred if ABIInfo = false) the target wants for the specified datatype. -unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, short BitWidth, - bool ABIInfo) const { +unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, + uint32_t BitWidth, bool ABIInfo) const { // Check to see if we have an exact match and remember the best match we see. int BestMatchIdx = -1; + int LargestInt = -1; for (unsigned i = 0, e = Alignments.size(); i != e; ++i) { if (Alignments[i].AlignType == AlignType && Alignments[i].TypeBitWidth == BitWidth) @@ -271,14 +272,30 @@ Alignments[BestMatchIdx].TypeBitWidth < BitWidth) BestMatchIdx = i; } + } else if (AlignType == INTEGER_ALIGN && + Alignments[i].AlignType == INTEGER_ALIGN) { + // The "best match" for integers is the smallest size that is larger than + // the BitWidth requested. + if (Alignments[i].TypeBitWidth > BitWidth && (BestMatchIdx == -1 || + Alignments[i].TypeBitWidth < Alignments[BestMatchIdx].TypeBitWidth)) + BestMatchIdx = i; + // However, if there isn't one that's larger, then we must use the + // largest one we have (see below) + if (LargestInt == -1 || + Alignments[i].TypeBitWidth > Alignments[LargestInt].TypeBitWidth) + LargestInt = i; } - - // FIXME: handle things like i37. } + // For integers, if we didn't find a best match, use the largest one found. + if (BestMatchIdx == -1) + BestMatchIdx = LargestInt; + // Okay, we didn't find an exact solution. Fall back here depending on what // is being looked for. assert(BestMatchIdx != -1 && "Didn't find alignment info for this datatype!"); + + // Since we got a "best match" index, just return it. return ABIInfo ? Alignments[BestMatchIdx].ABIAlign : Alignments[BestMatchIdx].PrefAlign; } @@ -407,8 +424,14 @@ return 4; } else if (BitWidth <= 64) { return 8; - } else - assert(0 && "Integer types > 64 bits not supported."); + } else { + // The size of this > 64 bit type is chosen as a multiple of the + // preferred alignment of the largest "native" size the target supports. + // We first obtain the the alignment info for this type and then compute + // the next largest multiple of that size. + uint64_t size = getAlignmentInfo(INTEGER_ALIGN, BitWidth, false) * 8; + return (((BitWidth / (size)) + (BitWidth % size != 0)) * size) / 8; + } break; } case Type::VoidTyID: From clattner at apple.com Mon Feb 19 16:41:03 2007 From: clattner at apple.com (Chris Lattner) Date: Mon, 19 Feb 2007 14:41:03 -0800 Subject: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support In-Reply-To: <1171917440.25169.107.camel@bashful.x10sys.com> References: <1171917440.25169.107.camel@bashful.x10sys.com> Message-ID: <1AD2A04B-7733-48C3-81AC-0B4597F46C80@apple.com> On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote: > Devang / Jim / Chris, > > The attached patch has been reviewed by Devang and provides the > "bitwidth" attribute and 3 builtin functions for arbitrary precision > integers (concat, bit select, part select). This is the same as the > last > version except it has an additional check for a null pointer that > produced a failure in bootstrap. That problem is now gone and this > patch passes the Integer test suite as well as MultiSource/Benchmarks. > > I would appreciate it if you could commit this one or indicate why it > could not be committed. Problems: @@ -1741,6 +1756,10 @@ unsigned lang_flag_5 : 1; unsigned lang_flag_6 : 1; unsigned user_align : 1; + /* APPLE LOCAL begin LLVM bit accurate integer types - ras */ + unsigned user_bitwidth : 1; + unsigned bitwidth : 23; + /* APPLE LOCAL end LLVM bit accurate integer types - ras */ This increases the size of tree_type by an extra word. Can you find a place to store this that doesn't penalize the non-bitwidth-aware case (e.g. a hash table on the side)? The changes around llvm_get_pseudo_builtin_index are quite invasive, disabling many places in the compiler. I don't know that there is a better solution, but have you tried treating the builtins as if they were varargs? Alternatively, why not lazily create specific builtins as you hit them. For example if the user writes: myint13 A, B; ... __builtin_bit_concat(A, B); the CFE would synthesize "__builtin_bit_concat13", with i13 arguments. This seems like a simpler and more-local change than the various pieces you have now. BTW, bsearch is totally overkill (i.e. much slower than a linear search) if you have an array of 3 entries to search. + if (Callee) { + // Handle arbitrary precision integer bit manipulation builtins + Value* Res = 0; + Function* Func = 0; + if (ConstantExpr* CE = dyn_cast(Callee)) { + if (CE->getOpcode() == Instruction::BitCast) + Func = dyn_cast(CE->getOperand(0)); + } else + Func = dyn_cast(Callee); + if (Func) { + switch (llvm_get_pseudo_builtin_index(Func->getName().c_str())) { + default: assert(0 && "Unexpected pseudo-builtin index"); This significantly slows down codegen (by calling llvm_get_pseudo_builtin_index, which is implemented in terms of string compares) of every single direct call compiled. This isn't acceptable. Instead, do by-pointer comparisons (of decls), and only after you first see one of the builtins being used. + // Set the result type on the expression since it might be != i32. + llvm_set_type(TREE_TYPE(exp), Result->getType()); Why are you doing this? Setting the type of an expression needs to be done in the FE, now at expansion to llvm time. + // FIXME: For some reason if we set the type of this expression, the type of + // "main" and all its variables become i1 too. This is a complete mystery. In + // the bit_concat.c test case, this function is called from a function that + // main calls. There's no way that "exp" refers to "main". How could it? + // ***BOGGLE*** I believe this is an artifact of the above: you're modifying the GLOBAL, SHARED, INT TYPE! Don't do this. Please figure out the right solution in the F.E. + /* The tree_type structure (tree.h) reserves 23 bits for the bitwidth field. + * Consequently we must ensure that the value provided fits within 23 bits. + * The number 23 is an artifact of LLVM's implementation of arbitrary + * precision integer types as there were 23 bits left over in the Type class. + * (see include/llvm/Type.h). 2^23 > 8 million which should be sufficient + * for any foreseeable application. + */ The GCC F.E. should allow any bitwidth (i.e. up to 2^32), the GCC- >LLVM converter should check for and reject anything greater than 2^23 bits. nitpick: * markers like "- ras" (which I assume is you) shouldn't exist. -Chris From rspencer at reidspencer.com Mon Feb 19 17:06:26 2007 From: rspencer at reidspencer.com (Reid Spencer) Date: Mon, 19 Feb 2007 15:06:26 -0800 Subject: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support In-Reply-To: <1AD2A04B-7733-48C3-81AC-0B4597F46C80@apple.com> References: <1171917440.25169.107.camel@bashful.x10sys.com> <1AD2A04B-7733-48C3-81AC-0B4597F46C80@apple.com> Message-ID: <1171926386.25169.138.camel@bashful.x10sys.com> On Mon, 2007-02-19 at 14:41 -0800, Chris Lattner wrote: > On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote: > > > Devang / Jim / Chris, > > > > The attached patch has been reviewed by Devang and provides the > > "bitwidth" attribute and 3 builtin functions for arbitrary precision > > integers (concat, bit select, part select). This is the same as the > > last > > version except it has an additional check for a null pointer that > > produced a failure in bootstrap. That problem is now gone and this > > patch passes the Integer test suite as well as MultiSource/Benchmarks. > > > > I would appreciate it if you could commit this one or indicate why it > > could not be committed. > > Problems: > > @@ -1741,6 +1756,10 @@ > unsigned lang_flag_5 : 1; > unsigned lang_flag_6 : 1; > unsigned user_align : 1; > + /* APPLE LOCAL begin LLVM bit accurate integer types - ras */ > + unsigned user_bitwidth : 1; > + unsigned bitwidth : 23; > + /* APPLE LOCAL end LLVM bit accurate integer types - ras */ > > This increases the size of tree_type by an extra word. Can you find > a place to store this that doesn't penalize the non-bitwidth-aware > case (e.g. a hash table on the side)? No. Been down that road. Every attribute uses its own field, bitwidth is no different. Given the huge size of these tree nodes, this isn't a huge increment. I understand the impact, but there's just no other way to do it. I tried using precision at one time but that just breaks 98% of the gcc code. > The changes around llvm_get_pseudo_builtin_index are quite invasive, > disabling many places in the compiler. I don't know that there is a > better solution, I don't like it either, but its either that or the gcc code gets nearly totally rewritten (modes are useless, many assumptions about sizes of things are useless, etc. etc.) > but have you tried treating the builtins as if they > were varargs? that's how they are being treated. I originally thought I could get away with a varargs solution using regular builtins. Unfortunately, there's nothing in C or GCC that allows the result of the function to be "any bit width". So, the result type is i32 through gcc processing and then fixed up by llvm-convert.cpp when it emits. Not great, but I can't find another way to do this without re-writting 1/2 of gcc. > Alternatively, why not lazily create specific builtins > as you hit them. For example if the user writes: > > myint13 A, B; > ... > __builtin_bit_concat(A, B); > > the CFE would synthesize "__builtin_bit_concat13", with i13 > arguments. This seems like a simpler and more-local change than the > various pieces you have now. Because gcc just can't do that. You can't define builtin functions "on the fly". They have to be in the builtins.def file, for a variety of reasons. If I've missed something, please enlighten me, but I went down this road too while trying to come up with a solution. Furthermore, for the intended use case (chip design), there could be a lot of different prototypes create (100s to 1000s). > > BTW, bsearch is totally overkill (i.e. much slower than a linear > search) if you have an array of 3 entries to search. There were originally 9, but we got rid of 6. There could be more in the future. I'll know more about this in 2-3 weeks. I left it in as bsearch to facilitate easy extension. If there isn't any more in the future, I'll turn this into linear scan, but not yet. > > + if (Callee) { > + // Handle arbitrary precision integer bit manipulation builtins > + Value* Res = 0; > + Function* Func = 0; > + if (ConstantExpr* CE = dyn_cast(Callee)) { > + if (CE->getOpcode() == Instruction::BitCast) > + Func = dyn_cast(CE->getOperand(0)); > + } else > + Func = dyn_cast(Callee); > + if (Func) { > + switch (llvm_get_pseudo_builtin_index(Func->getName().c_str())) { > + default: assert(0 && "Unexpected pseudo-builtin index"); > > This significantly slows down codegen (by calling > llvm_get_pseudo_builtin_index, which is implemented in terms of > string compares) of every single direct call compiled. This isn't > acceptable. Instead, do by-pointer comparisons (of decls), and only > after you first see one of the builtins being used. There's no "decl" that corresponds to these pseudo-builtin functions, just an identifier node. > > + // Set the result type on the expression since it might be != i32. > + llvm_set_type(TREE_TYPE(exp), Result->getType()); > > Why are you doing this? Setting the type of an expression needs to > be done in the FE, now at expansion to llvm time. How do you say in GCC tree parlance, "this type is any bit width and use the actual bit width returned". Unfortunately, you can't. I don't have a good solution for this. The problem is that the result gets truncated/extended to what gcc thinks the expression is and gcc has no way of dealing with integers > 64-bits (no applicable mode). Attempting to make gcc deal with them is many man years of work in my opinion and affects nearly everyting in GCC (I started down this road and quickly found out the task was "huge"). > > > + // FIXME: For some reason if we set the type of this expression, > the type of > + // "main" and all its variables become i1 too. This is a complete > mystery. In > + // the bit_concat.c test case, this function is called from a > function that > + // main calls. There's no way that "exp" refers to "main". How > could it? > + // ***BOGGLE*** > > I believe this is an artifact of the above: you're modifying the > GLOBAL, SHARED, INT TYPE! Don't do this. > Please figure out the right solution in the F.E. The right solution is to re-write the F.E. I don't have that luxury in the time allotment given to me. > > > > + /* The tree_type structure (tree.h) reserves 23 bits for the > bitwidth field. > + * Consequently we must ensure that the value provided fits within > 23 bits. > + * The number 23 is an artifact of LLVM's implementation of arbitrary > + * precision integer types as there were 23 bits left over in the > Type class. > + * (see include/llvm/Type.h). 2^23 > 8 million which should be > sufficient > + * for any foreseeable application. > + */ > > The GCC F.E. should allow any bitwidth (i.e. up to 2^32), the GCC- > >LLVM converter should check for and reject anything greater than > 2^23 bits. This feature is only enabled for LLVM anyway, so what's the diff? > > nitpick: > > * markers like "- ras" (which I assume is you) shouldn't exist. Just following the pattern used elsewhere in llvm-gcc. > > -Chris From reid at x10sys.com Mon Feb 19 17:30:27 2007 From: reid at x10sys.com (Reid Spencer) Date: Mon, 19 Feb 2007 17:30:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200702192330.l1JNURiU022626@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.102 -> 1.103 --- Log message: Simplify some code by moving variable declarations into the only block that uses them. --- Diffs of the changes: (+6 -12) TargetData.cpp | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.102 llvm/lib/Target/TargetData.cpp:1.103 --- llvm/lib/Target/TargetData.cpp:1.102 Mon Feb 19 16:35:00 2007 +++ llvm/lib/Target/TargetData.cpp Mon Feb 19 17:30:10 2007 @@ -184,14 +184,8 @@ while (!temp.empty()) { std::string token = getToken(temp, "-"); - std::string arg0 = getToken(token, ":"); const char *p = arg0.c_str(); - AlignTypeEnum align_type; - uint32_t size; - unsigned char abi_align; - unsigned char pref_align; - switch(*p) { case 'E': LittleEndian = false; @@ -210,12 +204,12 @@ case 'v': case 'f': case 'a': { - align_type = (*p == 'i' ? INTEGER_ALIGN : - (*p == 'f' ? FLOAT_ALIGN : - (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN))); - size = (uint32_t) atoi(++p); - abi_align = atoi(getToken(token, ":").c_str()) / 8; - pref_align = atoi(getToken(token, ":").c_str()) / 8; + AlignTypeEnum align_type = + (*p == 'i' ? INTEGER_ALIGN : (*p == 'f' ? FLOAT_ALIGN : + (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN))); + uint32_t size = (uint32_t) atoi(++p); + unsigned char abi_align = atoi(getToken(token, ":").c_str()) / 8; + unsigned char pref_align = atoi(getToken(token, ":").c_str()) / 8; if (pref_align == 0) pref_align = abi_align; setAlignment(align_type, abi_align, pref_align, size); From evan.cheng at apple.com Mon Feb 19 18:39:25 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 18:39:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrSSE.td Message-ID: <200702200039.l1K0dP6s023918@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86InstrSSE.td updated: 1.176 -> 1.177 --- Log message: How the heck did I forget patterns for llvm.x86.sse2.cmp.sd? --- Diffs of the changes: (+6 -2) X86InstrSSE.td | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) Index: llvm/lib/Target/X86/X86InstrSSE.td diff -u llvm/lib/Target/X86/X86InstrSSE.td:1.176 llvm/lib/Target/X86/X86InstrSSE.td:1.177 --- llvm/lib/Target/X86/X86InstrSSE.td:1.176 Fri Jan 5 15:37:56 2007 +++ llvm/lib/Target/X86/X86InstrSSE.td Mon Feb 19 18:39:09 2007 @@ -544,10 +544,14 @@ (load addr:$src), imm:$cc))]>; def Int_CMPSDrr : SDI<0xC2, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src, SSECC:$cc), - "cmp${cc}sd {$src, $dst|$dst, $src}", []>; + "cmp${cc}sd {$src, $dst|$dst, $src}", + [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1, + VR128:$src, imm:$cc))]>; def Int_CMPSDrm : SDI<0xC2, MRMSrcMem, (ops VR128:$dst, VR128:$src1, f64mem:$src, SSECC:$cc), - "cmp${cc}sd {$src, $dst|$dst, $src}", []>; + "cmp${cc}sd {$src, $dst|$dst, $src}", + [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1, + (load addr:$src), imm:$cc))]>; } def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (ops VR128:$src1, VR128:$src2), From baldrick at free.fr Mon Feb 19 16:55:35 2007 From: baldrick at free.fr (Duncan Sands) Date: Mon, 19 Feb 2007 23:55:35 +0100 Subject: [llvm-commits] [123995] Fix PR1170 and test/CFrontend/2007-02-16-VariableSizeStructArg.c Message-ID: <200702192355.36322.baldrick@free.fr> > @@ -108,7 +112,8 @@ > tree Domain = TYPE_DOMAIN(type); > if (!Domain || !TYPE_MIN_VALUE(Domain) || !TYPE_MAX_VALUE(Domain)) > return 0; > - if (TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST || > + if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST || > + TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST || > TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST) > return 0; > if (TREE_INT_CST_LOW(TYPE_MAX_VALUE(Domain)) != Is this bit of the patch actually needed? I can see how it might be an optimization, in that you detect early if the array component has non-constant size, and avoid a call to isSingleElementStructOrArray. But is it really needed for correctness? Thanks, Duncan. From evan.cheng at apple.com Mon Feb 19 19:29:26 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 19 Feb 2007 19:29:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp Message-ID: <200702200129.l1K1TQji024704@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.95 -> 1.96 --- Log message: Dead code. --- Diffs of the changes: (+0 -6) VirtRegMap.cpp | 6 ------ 1 files changed, 6 deletions(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.95 llvm/lib/CodeGen/VirtRegMap.cpp:1.96 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.95 Thu Feb 8 00:04:54 2007 +++ llvm/lib/CodeGen/VirtRegMap.cpp Mon Feb 19 19:29:10 2007 @@ -233,12 +233,6 @@ } private: void RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM); - void ClobberPhysReg(unsigned PR, std::map &SpillSlots, - std::multimap &PhysRegs); - void ClobberPhysRegOnly(unsigned PR, std::map &SpillSlots, - std::multimap &PhysRegs); - void ModifyStackSlot(int Slot, std::map &SpillSlots, - std::multimap &PhysRegs); }; } From sabre at nondot.org Mon Feb 19 23:30:04 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 23:30:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200702200530.l1K5U49e028665@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.174 -> 1.175 --- Log message: remove dead method --- Diffs of the changes: (+1 -9) Type.cpp | 10 +--------- 1 files changed, 1 insertion(+), 9 deletions(-) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.174 llvm/lib/VMCore/Type.cpp:1.175 --- llvm/lib/VMCore/Type.cpp:1.174 Wed Feb 14 21:39:18 2007 +++ llvm/lib/VMCore/Type.cpp Mon Feb 19 23:29:47 2007 @@ -783,15 +783,7 @@ print("add"); } - void clear(std::vector &DerivedTypes) { - for (typename std::map::iterator I = Map.begin(), - E = Map.end(); I != E; ++I) - DerivedTypes.push_back(I->second.get()); - TypesByHash.clear(); - Map.clear(); - } - - /// RefineAbstractType - This method is called after we have merged a type + /// RefineAbstractType - This method is called after we have merged a type /// with another one. We must now either merge the type away with /// some other type or reinstall it in the map with it's new configuration. void RefineAbstractType(TypeClass *Ty, const DerivedType *OldType, From sabre at nondot.org Mon Feb 19 23:31:21 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 23:31:21 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/LinkAllPasses.h Message-ID: <200702200531.l1K5VLMf028734@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: LinkAllPasses.h updated: 1.9 -> 1.10 --- Log message: remove some passes --- Diffs of the changes: (+0 -2) LinkAllPasses.h | 2 -- 1 files changed, 2 deletions(-) Index: llvm/include/llvm/LinkAllPasses.h diff -u llvm/include/llvm/LinkAllPasses.h:1.9 llvm/include/llvm/LinkAllPasses.h:1.10 --- llvm/include/llvm/LinkAllPasses.h:1.9 Mon Feb 5 14:47:19 2007 +++ llvm/include/llvm/LinkAllPasses.h Mon Feb 19 23:31:04 2007 @@ -61,7 +61,6 @@ (void) llvm::createDeadStoreEliminationPass(); (void) llvm::createDeadTypeEliminationPass(); (void) llvm::createEdgeProfilerPass(); - (void) llvm::createEmitFunctionTablePass(); (void) llvm::createFunctionInliningPass(); (void) llvm::createFunctionProfilerPass(); (void) llvm::createGCSEPass(); @@ -103,7 +102,6 @@ (void) llvm::createStripSymbolsPass(); (void) llvm::createTailCallEliminationPass(); (void) llvm::createTailDuplicationPass(); - (void) llvm::createTraceBasicBlockPass(); (void) llvm::createUnifyFunctionExitNodesPass(); (void) llvm::createCondPropagationPass(); (void) llvm::createNullProfilerRSPass(); From sabre at nondot.org Mon Feb 19 23:31:52 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 23:31:52 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Instrumentation.h Message-ID: <200702200531.l1K5VqpM028793@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Instrumentation.h updated: 1.11 -> 1.12 --- Log message: remove some dead passes and stuff specific to the reoptimizer. --- Diffs of the changes: (+3 -18) Instrumentation.h | 21 +++------------------ 1 files changed, 3 insertions(+), 18 deletions(-) Index: llvm/include/llvm/Transforms/Instrumentation.h diff -u llvm/include/llvm/Transforms/Instrumentation.h:1.11 llvm/include/llvm/Transforms/Instrumentation.h:1.12 --- llvm/include/llvm/Transforms/Instrumentation.h:1.11 Sun Jan 7 12:12:13 2007 +++ llvm/include/llvm/Transforms/Instrumentation.h Mon Feb 19 23:31:35 2007 @@ -19,30 +19,15 @@ class ModulePass; class FunctionPass; -// Reoptimizer support pass: add instrumentation calls to back-edges of loops -FunctionPass *createLoopInstrumentationPass (); - -// Reoptimizer support pass: combine multiple back-edges w/ same target into one -FunctionPass *createCombineBranchesPass(); - -// Reoptimizer support pass: emit table of global functions -ModulePass *createEmitFunctionTablePass (); - -// Reoptimizer support pass: insert function profiling instrumentation +// Insert function profiling instrumentation ModulePass *createFunctionProfilerPass(); -// Reoptimizer support pass: insert block profiling instrumentation +// Insert block profiling instrumentation ModulePass *createBlockProfilerPass(); -// Reoptimizer support pass: insert edge profiling instrumentation +// Insert edge profiling instrumentation ModulePass *createEdgeProfilerPass(); -// Reoptimizer support pass: insert basic block tracing instrumentation -ModulePass *createTraceBasicBlockPass(); - -// Reoptimizer support pass: insert counting of execute paths instrumentation -FunctionPass *createProfilePathsPass(); - // Random Sampling Profiling Framework ModulePass* createNullProfilerRSPass(); FunctionPass* createRSProfilingPass(); From lattner at cs.uiuc.edu Mon Feb 19 23:32:12 2007 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 19 Feb 2007 23:32:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp TraceBasicBlocks.cpp Message-ID: <200702200532.l1K5WCG6028804@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: EmitFunctions.cpp (r1.29) removed TraceBasicBlocks.cpp (r1.23) removed --- Log message: remove reoptimizer-specific passes --- Diffs of the changes: (+0 -0) 0 files changed From sabre at nondot.org Mon Feb 19 23:46:56 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 23:46:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702200546.l1K5kuEG029253@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.214 -> 1.215 --- Log message: simplify some code that was not llvm_shutdown safe --- Diffs of the changes: (+5 -36) Constants.cpp | 41 +++++------------------------------------ 1 files changed, 5 insertions(+), 36 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.214 llvm/lib/VMCore/Constants.cpp:1.215 --- llvm/lib/VMCore/Constants.cpp:1.214 Mon Feb 19 14:01:23 2007 +++ llvm/lib/VMCore/Constants.cpp Mon Feb 19 23:46:39 2007 @@ -89,45 +89,14 @@ } } - // Static constructor to create a '0' constant of arbitrary type... Constant *Constant::getNullValue(const Type *Ty) { switch (Ty->getTypeID()) { - case Type::IntegerTyID: { - const IntegerType *ITy = dyn_cast(Ty); - switch (ITy->getBitWidth()) { - case 1: { - static Constant *NullBool = ConstantInt::get(Ty, false); - return NullBool; - } - case 8: { - static Constant *NullInt8 = ConstantInt::get(Ty, 0); - return NullInt8; - } - case 16: { - static Constant *NullInt16 = ConstantInt::get(Ty, 0); - return NullInt16; - } - case 32: { - static Constant *NullInt32 = ConstantInt::get(Ty, 0); - return NullInt32; - } - case 64: { - static Constant *NullInt64 = ConstantInt::get(Ty, 0); - return NullInt64; - } - default: - return ConstantInt::get(Ty, 0); - } - } - case Type::FloatTyID: { - static Constant *NullFloat = ConstantFP::get(Type::FloatTy, 0); - return NullFloat; - } - case Type::DoubleTyID: { - static Constant *NullDouble = ConstantFP::get(Type::DoubleTy, 0); - return NullDouble; - } + case Type::IntegerTyID: + return ConstantInt::get(Ty, 0); + case Type::FloatTyID: + case Type::DoubleTyID: + return ConstantFP::get(Ty, 0.0); case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: From sabre at nondot.org Mon Feb 19 23:56:02 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 23:56:02 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702200556.l1K5u2jk029480@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.128 -> 1.129 --- Log message: Clean up the internals of the ConstantInt machinery --- Diffs of the changes: (+4 -6) Constants.h | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.128 llvm/include/llvm/Constants.h:1.129 --- llvm/include/llvm/Constants.h:1.128 Mon Feb 19 14:01:23 2007 +++ llvm/include/llvm/Constants.h Mon Feb 19 23:55:46 2007 @@ -44,10 +44,8 @@ uint64_t Val; protected: ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT - ConstantInt(const Type *Ty, uint64_t V); - ConstantInt(const Type *Ty, int64_t V); - ConstantInt(bool V); - friend struct ConstantCreator; + ConstantInt(const IntegerType *Ty, uint64_t V); + friend struct ConstantCreator; public: /// Return the constant as a 64-bit unsigned integer value after it /// has been zero extended as appropriate for the type of this constant. @@ -77,12 +75,12 @@ static inline ConstantInt *getTrue() { static ConstantInt *T = 0; if (T) return T; - return T = new ConstantInt(true); + return T = new ConstantInt(Type::Int1Ty, 1); } static inline ConstantInt *getFalse() { static ConstantInt *F = 0; if (F) return F; - return F = new ConstantInt(false); + return F = new ConstantInt(Type::Int1Ty, 0); } /// Return a ConstantInt with the specified value for the specified type. The From sabre at nondot.org Mon Feb 19 23:56:05 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 19 Feb 2007 23:56:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702200556.l1K5u5ME029485@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.215 -> 1.216 --- Log message: Clean up the internals of the ConstantInt machinery --- Diffs of the changes: (+6 -9) Constants.cpp | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.215 llvm/lib/VMCore/Constants.cpp:1.216 --- llvm/lib/VMCore/Constants.cpp:1.215 Mon Feb 19 23:46:39 2007 +++ llvm/lib/VMCore/Constants.cpp Mon Feb 19 23:55:46 2007 @@ -140,12 +140,8 @@ //===----------------------------------------------------------------------===// // Normal Constructors -ConstantInt::ConstantInt(bool V) - : Constant(Type::Int1Ty, ConstantIntVal, 0, 0), Val(uint64_t(V)) { -} - -ConstantInt::ConstantInt(const Type *Ty, uint64_t V) - : Constant(Ty, ConstantIntVal, 0, 0), Val(Ty == Type::Int1Ty ? bool(V) : V) { +ConstantInt::ConstantInt(const IntegerType *Ty, uint64_t V) + : Constant(Ty, ConstantIntVal, 0, 0), Val(V) { } ConstantFP::ConstantFP(const Type *Ty, double V) @@ -802,7 +798,7 @@ //---- ConstantInt::get() implementations... // -static ManagedStatic > IntConstants; +static ManagedStatic >IntConstants; // Get a ConstantInt from an int64_t. Note here that we canoncialize the value // to a uint64_t value that has been zero extended down to the size of the @@ -810,12 +806,13 @@ // just return the stored value while getSExtValue has to convert back to sign // extended. getZExtValue is more common in LLVM than getSExtValue(). ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) { - if (Ty == Type::Int1Ty) + const IntegerType *ITy = cast(Ty); + if (Ty == Type::Int1Ty) if (V & 1) return getTrue(); else return getFalse(); - return IntConstants->getOrCreate(Ty, V & cast(Ty)->getBitMask()); + return IntConstants->getOrCreate(ITy, V & ITy->getBitMask()); } //---- ConstantFP::get() implementation... From sabre at nondot.org Tue Feb 20 00:08:54 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 00:08:54 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/ManagedStatic.h Message-ID: <200702200608.l1K68sTx029791@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: ManagedStatic.h updated: 1.3 -> 1.4 --- Log message: add a way to register an arbitrary cleanup function. --- Diffs of the changes: (+6 -0) ManagedStatic.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/Support/ManagedStatic.h diff -u llvm/include/llvm/Support/ManagedStatic.h:1.3 llvm/include/llvm/Support/ManagedStatic.h:1.4 --- llvm/include/llvm/Support/ManagedStatic.h:1.3 Sat Feb 10 13:54:24 2007 +++ llvm/include/llvm/Support/ManagedStatic.h Tue Feb 20 00:08:37 2007 @@ -73,6 +73,12 @@ } }; +template +class ManagedCleanup : public ManagedStaticBase { +public: + void Register() { RegisterManagedStatic(0, CleanupFn); } +}; + /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm_shutdown(); From sabre at nondot.org Tue Feb 20 00:11:58 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 00:11:58 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702200611.l1K6BwLD029897@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.129 -> 1.130 --- Log message: Make ConstantInt::getTrue/getFalse be llvm_shutdown safe. --- Diffs of the changes: (+8 -6) Constants.h | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.129 llvm/include/llvm/Constants.h:1.130 --- llvm/include/llvm/Constants.h:1.129 Mon Feb 19 23:55:46 2007 +++ llvm/include/llvm/Constants.h Tue Feb 20 00:11:36 2007 @@ -40,6 +40,7 @@ /// represents both boolean and integral constants. /// @brief Class for constant integers. class ConstantInt : public Constant { + static ConstantInt *TheTrueVal, *TheFalseVal; protected: uint64_t Val; protected: @@ -73,14 +74,12 @@ /// getTrue/getFalse - Return the singleton true/false values. static inline ConstantInt *getTrue() { - static ConstantInt *T = 0; - if (T) return T; - return T = new ConstantInt(Type::Int1Ty, 1); + if (TheTrueVal) return TheTrueVal; + return CreateTrueFalseVals(true); } static inline ConstantInt *getFalse() { - static ConstantInt *F = 0; - if (F) return F; - return F = new ConstantInt(Type::Int1Ty, 0); + if (TheFalseVal) return TheFalseVal; + return CreateTrueFalseVals(false); } /// Return a ConstantInt with the specified value for the specified type. The @@ -165,6 +164,9 @@ static bool classof(const Value *V) { return V->getValueType() == ConstantIntVal; } + static void ResetTrueFalse() { TheTrueVal = TheFalseVal = 0; } +private: + static ConstantInt *CreateTrueFalseVals(bool WhichOne); }; From sabre at nondot.org Tue Feb 20 00:11:59 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 00:11:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702200611.l1K6Bx1e029902@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.216 -> 1.217 --- Log message: Make ConstantInt::getTrue/getFalse be llvm_shutdown safe. --- Diffs of the changes: (+24 -5) Constants.cpp | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.216 llvm/lib/VMCore/Constants.cpp:1.217 --- llvm/lib/VMCore/Constants.cpp:1.216 Mon Feb 19 23:55:46 2007 +++ llvm/lib/VMCore/Constants.cpp Tue Feb 20 00:11:36 2007 @@ -800,6 +800,7 @@ // static ManagedStatic >IntConstants; + // Get a ConstantInt from an int64_t. Note here that we canoncialize the value // to a uint64_t value that has been zero extended down to the size of the // integer type of the ConstantInt. This allows the getZExtValue method to @@ -807,14 +808,32 @@ // extended. getZExtValue is more common in LLVM than getSExtValue(). ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) { const IntegerType *ITy = cast(Ty); - if (Ty == Type::Int1Ty) - if (V & 1) - return getTrue(); - else - return getFalse(); return IntConstants->getOrCreate(ITy, V & ITy->getBitMask()); } +ConstantInt *ConstantInt::TheTrueVal = 0; +ConstantInt *ConstantInt::TheFalseVal = 0; + +void CleanupTrueFalse(void *) { + ConstantInt::ResetTrueFalse(); +} + +static ManagedCleanup TrueFalseCleanup; + +ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) { + assert(TheTrueVal == 0 && TheFalseVal == 0); + TheTrueVal = get(Type::Int1Ty, 1); + TheFalseVal = get(Type::Int1Ty, 0); + + // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal. + TrueFalseCleanup.Register(); + + return WhichOne ? TheTrueVal : TheFalseVal; +} + + + + //---- ConstantFP::get() implementation... // namespace llvm { From sabre at nondot.org Tue Feb 20 00:19:14 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 00:19:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/ManagedStatic.cpp Message-ID: <200702200619.l1K6JEDw030049@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: ManagedStatic.cpp updated: 1.2 -> 1.3 --- Log message: Not all managedstatics need object pointers. --- Diffs of the changes: (+1 -1) ManagedStatic.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Support/ManagedStatic.cpp diff -u llvm/lib/Support/ManagedStatic.cpp:1.2 llvm/lib/Support/ManagedStatic.cpp:1.3 --- llvm/lib/Support/ManagedStatic.cpp:1.2 Fri Sep 29 13:43:14 2006 +++ llvm/lib/Support/ManagedStatic.cpp Tue Feb 20 00:18:57 2007 @@ -30,7 +30,7 @@ } void ManagedStaticBase::destroy() const { - assert(Ptr && DeleterFn && "ManagedStatic not initialized correctly!"); + assert(DeleterFn && "ManagedStatic not initialized correctly!"); assert(StaticList == this && "Not destroyed in reverse order of construction?"); // Unlink from list. From sabre at nondot.org Tue Feb 20 00:40:14 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 00:40:14 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702200640.l1K6eEqq030469@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.130 -> 1.131 --- Log message: cleanup ConstantInt to use a single DenseMap for uniquing instead of the heavy-weight ValueMap class. This reduces mem usage bc reading kc++ by 29K, even though it only creates 2955 constant ints! --- Diffs of the changes: (+1 -4) Constants.h | 5 +---- 1 files changed, 1 insertion(+), 4 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.130 llvm/include/llvm/Constants.h:1.131 --- llvm/include/llvm/Constants.h:1.130 Tue Feb 20 00:11:36 2007 +++ llvm/include/llvm/Constants.h Tue Feb 20 00:39:57 2007 @@ -41,12 +41,9 @@ /// @brief Class for constant integers. class ConstantInt : public Constant { static ConstantInt *TheTrueVal, *TheFalseVal; -protected: - uint64_t Val; -protected: ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT ConstantInt(const IntegerType *Ty, uint64_t V); - friend struct ConstantCreator; + uint64_t Val; public: /// Return the constant as a 64-bit unsigned integer value after it /// has been zero extended as appropriate for the type of this constant. From sabre at nondot.org Tue Feb 20 00:40:16 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 00:40:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702200640.l1K6eGFQ030474@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.217 -> 1.218 --- Log message: cleanup ConstantInt to use a single DenseMap for uniquing instead of the heavy-weight ValueMap class. This reduces mem usage bc reading kc++ by 29K, even though it only creates 2955 constant ints! --- Diffs of the changes: (+63 -50) Constants.cpp | 113 ++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 63 insertions(+), 50 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.217 llvm/lib/VMCore/Constants.cpp:1.218 --- llvm/lib/VMCore/Constants.cpp:1.217 Tue Feb 20 00:11:36 2007 +++ llvm/lib/VMCore/Constants.cpp Tue Feb 20 00:39:57 2007 @@ -22,6 +22,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include #include @@ -134,16 +135,74 @@ //===----------------------------------------------------------------------===// -// ConstantXXX Classes -//===----------------------------------------------------------------------===// - +// ConstantInt //===----------------------------------------------------------------------===// -// Normal Constructors ConstantInt::ConstantInt(const IntegerType *Ty, uint64_t V) : Constant(Ty, ConstantIntVal, 0, 0), Val(V) { } +ConstantInt *ConstantInt::TheTrueVal = 0; +ConstantInt *ConstantInt::TheFalseVal = 0; + +namespace llvm { + void CleanupTrueFalse(void *) { + ConstantInt::ResetTrueFalse(); + } +} + +static ManagedCleanup TrueFalseCleanup; + +ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) { + assert(TheTrueVal == 0 && TheFalseVal == 0); + TheTrueVal = get(Type::Int1Ty, 1); + TheFalseVal = get(Type::Int1Ty, 0); + + // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal. + TrueFalseCleanup.Register(); + + return WhichOne ? TheTrueVal : TheFalseVal; +} + + +//---- ConstantInt::get() implementations... +// +// Provide DenseMapKeyInfo for all pointers. +namespace { + struct DenseMapIntegerKeyInfo { + typedef std::pair KeyTy; + static inline KeyTy getEmptyKey() { return KeyTy(0, 0); } + static inline KeyTy getTombstoneKey() { return KeyTy(1, 0); } + static unsigned getHashValue(const KeyTy &Key) { + return DenseMapKeyInfo::getHashValue(Key.second) ^ Key.first; + } + static bool isPod() { return true; } + }; +} + + +typedef DenseMap IntMapTy; +static ManagedStatic IntConstants; + +// Get a ConstantInt from an int64_t. Note here that we canoncialize the value +// to a uint64_t value that has been zero extended down to the size of the +// integer type of the ConstantInt. This allows the getZExtValue method to +// just return the stored value while getSExtValue has to convert back to sign +// extended. getZExtValue is more common in LLVM than getSExtValue(). +ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) { + const IntegerType *ITy = cast(Ty); + V &= ITy->getBitMask(); + ConstantInt *&Slot = (*IntConstants)[std::make_pair(uint64_t(V), ITy)]; + if (Slot) return Slot; + return Slot = new ConstantInt(ITy, V); +} + +//===----------------------------------------------------------------------===// +// ConstantXXX Classes +//===----------------------------------------------------------------------===// + + ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty, ConstantFPVal, 0, 0) { assert(isValueValidForType(Ty, V) && "Value too large for type!"); @@ -598,15 +657,6 @@ /// AbstractTypeMapTy AbstractTypeMap; - private: - void clear(std::vector &Constants) { - for(typename MapTy::iterator I = Map.begin(); I != Map.end(); ++I) - Constants.push_back(I->second); - Map.clear(); - AbstractTypeMap.clear(); - InverseMap.clear(); - } - public: typename MapTy::iterator map_end() { return Map.end(); } @@ -796,43 +846,6 @@ } -//---- ConstantInt::get() implementations... -// -static ManagedStatic >IntConstants; - - -// Get a ConstantInt from an int64_t. Note here that we canoncialize the value -// to a uint64_t value that has been zero extended down to the size of the -// integer type of the ConstantInt. This allows the getZExtValue method to -// just return the stored value while getSExtValue has to convert back to sign -// extended. getZExtValue is more common in LLVM than getSExtValue(). -ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) { - const IntegerType *ITy = cast(Ty); - return IntConstants->getOrCreate(ITy, V & ITy->getBitMask()); -} - -ConstantInt *ConstantInt::TheTrueVal = 0; -ConstantInt *ConstantInt::TheFalseVal = 0; - -void CleanupTrueFalse(void *) { - ConstantInt::ResetTrueFalse(); -} - -static ManagedCleanup TrueFalseCleanup; - -ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) { - assert(TheTrueVal == 0 && TheFalseVal == 0); - TheTrueVal = get(Type::Int1Ty, 1); - TheFalseVal = get(Type::Int1Ty, 0); - - // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal. - TrueFalseCleanup.Register(); - - return WhichOne ? TheTrueVal : TheFalseVal; -} - - - //---- ConstantFP::get() implementation... // From sabre at nondot.org Tue Feb 20 01:17:34 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 01:17:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702200717.l1K7HYwW031099@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.218 -> 1.219 --- Log message: switch ConstantFP's from ValueMap to DenseMap, which is much faster to query and is more memory efficient. --- Diffs of the changes: (+59 -51) Constants.cpp | 110 +++++++++++++++++++++++++++++++--------------------------- 1 files changed, 59 insertions(+), 51 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.218 llvm/lib/VMCore/Constants.cpp:1.219 --- llvm/lib/VMCore/Constants.cpp:1.218 Tue Feb 20 00:39:57 2007 +++ llvm/lib/VMCore/Constants.cpp Tue Feb 20 01:17:17 2007 @@ -165,12 +165,9 @@ } -//---- ConstantInt::get() implementations... -// -// Provide DenseMapKeyInfo for all pointers. namespace { - struct DenseMapIntegerKeyInfo { - typedef std::pair KeyTy; + struct DenseMapInt64KeyInfo { + typedef std::pair KeyTy; static inline KeyTy getEmptyKey() { return KeyTy(0, 0); } static inline KeyTy getTombstoneKey() { return KeyTy(1, 0); } static unsigned getHashValue(const KeyTy &Key) { @@ -181,8 +178,8 @@ } -typedef DenseMap IntMapTy; +typedef DenseMap IntMapTy; static ManagedStatic IntConstants; // Get a ConstantInt from an int64_t. Note here that we canoncialize the value @@ -193,22 +190,74 @@ ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) { const IntegerType *ITy = cast(Ty); V &= ITy->getBitMask(); - ConstantInt *&Slot = (*IntConstants)[std::make_pair(uint64_t(V), ITy)]; + ConstantInt *&Slot = (*IntConstants)[std::make_pair(uint64_t(V), Ty)]; if (Slot) return Slot; return Slot = new ConstantInt(ITy, V); } //===----------------------------------------------------------------------===// -// ConstantXXX Classes +// ConstantFP //===----------------------------------------------------------------------===// ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty, ConstantFPVal, 0, 0) { - assert(isValueValidForType(Ty, V) && "Value too large for type!"); Val = V; } +bool ConstantFP::isNullValue() const { + return DoubleToBits(Val) == 0; +} + +bool ConstantFP::isExactlyValue(double V) const { + return DoubleToBits(V) == DoubleToBits(Val); +} + + +namespace { + struct DenseMapInt32KeyInfo { + typedef std::pair KeyTy; + static inline KeyTy getEmptyKey() { return KeyTy(0, 0); } + static inline KeyTy getTombstoneKey() { return KeyTy(1, 0); } + static unsigned getHashValue(const KeyTy &Key) { + return DenseMapKeyInfo::getHashValue(Key.second) ^ Key.first; + } + static bool isPod() { return true; } + }; +} + +//---- ConstantFP::get() implementation... +// +typedef DenseMap FloatMapTy; +typedef DenseMap DoubleMapTy; + +static ManagedStatic FloatConstants; +static ManagedStatic DoubleConstants; + +ConstantFP *ConstantFP::get(const Type *Ty, double V) { + if (Ty == Type::FloatTy) { + uint32_t IntVal = FloatToBits((float)V); + + ConstantFP *&Slot = (*FloatConstants)[std::make_pair(IntVal, Ty)]; + if (Slot) return Slot; + return Slot = new ConstantFP(Ty, (float)V); + } else { + assert(Ty == Type::DoubleTy); + uint64_t IntVal = DoubleToBits(V); + ConstantFP *&Slot = (*DoubleConstants)[std::make_pair(IntVal, Ty)]; + if (Slot) return Slot; + return Slot = new ConstantFP(Ty, (float)V); + } +} + + +//===----------------------------------------------------------------------===// +// ConstantXXX Classes +//===----------------------------------------------------------------------===// + + ConstantArray::ConstantArray(const ArrayType *T, const std::vector &V) : Constant(T, ConstantArrayVal, new Use[V.size()], V.size()) { @@ -847,47 +896,6 @@ -//---- ConstantFP::get() implementation... -// -namespace llvm { - template<> - struct ConstantCreator { - static ConstantFP *create(const Type *Ty, uint64_t V) { - assert(Ty == Type::DoubleTy); - return new ConstantFP(Ty, BitsToDouble(V)); - } - }; - template<> - struct ConstantCreator { - static ConstantFP *create(const Type *Ty, uint32_t V) { - assert(Ty == Type::FloatTy); - return new ConstantFP(Ty, BitsToFloat(V)); - } - }; -} - -static ManagedStatic > DoubleConstants; -static ManagedStatic > FloatConstants; - -bool ConstantFP::isNullValue() const { - return DoubleToBits(Val) == 0; -} - -bool ConstantFP::isExactlyValue(double V) const { - return DoubleToBits(V) == DoubleToBits(Val); -} - - -ConstantFP *ConstantFP::get(const Type *Ty, double V) { - if (Ty == Type::FloatTy) { - // Force the value through memory to normalize it. - return FloatConstants->getOrCreate(Ty, FloatToBits(V)); - } else { - assert(Ty == Type::DoubleTy); - return DoubleConstants->getOrCreate(Ty, DoubleToBits(V)); - } -} - //---- ConstantAggregateZero::get() implementation... // namespace llvm { From sabre at nondot.org Tue Feb 20 01:18:17 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 20 Feb 2007 01:18:17 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200702200718.l1K7IHmd031158@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.131 -> 1.132 --- Log message: eliminate some dead friends. --- Diffs of the changes: (+0 -2) Constants.h | 2 -- 1 files changed, 2 deletions(-) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.131 llvm/include/llvm/Constants.h:1.132 --- llvm/include/llvm/Constants.h:1.131 Tue Feb 20 00:39:57 2007 +++ llvm/include/llvm/Constants.h Tue Feb 20 01:18:01 2007 @@ -172,8 +172,6 @@ /// class ConstantFP : public Constant { double Val; - friend struct ConstantCreator; - friend struct ConstantCreator; ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT protected: ConstantFP(const Type *Ty, double V); From reid at x10sys.com Tue Feb 20 02:43:59 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 02:43:59 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h Message-ID: <200702200843.l1K8hxc6008942@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.14 -> 1.15 --- Log message: Add an internal convenience method for division that urem and udiv use. --- Diffs of the changes: (+5 -0) APInt.h | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.14 llvm/include/llvm/ADT/APInt.h:1.15 --- llvm/include/llvm/ADT/APInt.h:1.14 Sun Feb 18 21:18:22 2007 +++ llvm/include/llvm/ADT/APInt.h Tue Feb 20 02:43:42 2007 @@ -128,6 +128,11 @@ void fromString(uint32_t numBits, const char *StrStart, uint32_t slen, uint8_t radix); + /// @brief An internal division function for dividing APInts. + static void divide(const APInt LHS, uint32_t lhsWords, + const APInt &RHS, uint32_t rhsWords, + APInt *Quotient, APInt *Remainder); + public: /// @brief Create a new APInt of numBits bit-width, and initialized as val. APInt(uint32_t numBits, uint64_t val); From reid at x10sys.com Tue Feb 20 02:51:20 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 02:51:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702200851.l1K8pKeW009078@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.21 -> 1.22 --- Log message: First version that can process arith.cpp test case up to 1024 bits: 1. Ensure pVal is set to 0 in each constructor. 2. Fix roundToDouble to make correct calculations and not read beyond the end of allocated memory. 3. Implement Knuth's "classical algorithm" for division from scratch and eliminate buffer overflows and uninitialized mememory reads. Document it properly too. 4. Implement a wrapper function for KnuthDiv which handles the 64-bit to 32-bit conversion and back. It also implement short division for the n == 1 case that Knuth's algorithm can't handle. 5. Simplify the logic of udiv and urem a little, make them exit early, and have them use the "divide" wrapper function to perform the division or remainder operation. 6. Move the toString function to the end of the file, closer to where the division functions are located. Note: division is still broken for some > 64 bit values, but at least it doesn't crash any more. --- Diffs of the changes: (+424 -172) APInt.cpp | 596 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 424 insertions(+), 172 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.21 llvm/lib/Support/APInt.cpp:1.22 --- llvm/lib/Support/APInt.cpp:1.21 Sun Feb 18 16:29:05 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 02:51:03 2007 @@ -36,7 +36,7 @@ } APInt::APInt(uint32_t numBits, uint64_t val) - : BitWidth(numBits) { + : BitWidth(numBits), pVal(0) { assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); if (isSingleWord()) @@ -48,7 +48,7 @@ } APInt::APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[]) - : BitWidth(numBits) { + : BitWidth(numBits), pVal(0) { assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); assert(bigVal && "Null pointer detected!"); @@ -71,20 +71,22 @@ /// @brief Create a new APInt by translating the char array represented /// integer value. APInt::APInt(uint32_t numbits, const char StrStart[], uint32_t slen, - uint8_t radix) { + uint8_t radix) + : BitWidth(numbits), pVal(0) { fromString(numbits, StrStart, slen, radix); } /// @brief Create a new APInt by translating the string represented /// integer value. -APInt::APInt(uint32_t numbits, const std::string& Val, uint8_t radix) { +APInt::APInt(uint32_t numbits, const std::string& Val, uint8_t radix) + : BitWidth(numbits), pVal(0) { assert(!Val.empty() && "String empty?"); fromString(numbits, Val.c_str(), Val.size(), radix); } /// @brief Copy constructor APInt::APInt(const APInt& APIVal) - : BitWidth(APIVal.BitWidth) { + : BitWidth(APIVal.BitWidth), pVal(0) { if (isSingleWord()) VAL = APIVal.VAL; else { @@ -94,7 +96,8 @@ } APInt::~APInt() { - if (!isSingleWord() && pVal) delete[] pVal; + if (!isSingleWord() && pVal) + delete[] pVal; } /// @brief Copy assignment operator. Create a new object from the given @@ -641,80 +644,6 @@ return *this; } -/// to_string - This function translates the APInt into a string. -std::string APInt::toString(uint8_t radix, bool wantSigned) const { - assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && - "Radix should be 2, 8, 10, or 16!"); - static const char *digits[] = { - "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F" - }; - std::string result; - uint32_t bits_used = getActiveBits(); - if (isSingleWord()) { - char buf[65]; - const char *format = (radix == 10 ? (wantSigned ? "%lld" : "%llu") : - (radix == 16 ? "%llX" : (radix == 8 ? "%llo" : 0))); - if (format) { - if (wantSigned) { - int64_t sextVal = (int64_t(VAL) << (APINT_BITS_PER_WORD-BitWidth)) >> - (APINT_BITS_PER_WORD-BitWidth); - sprintf(buf, format, sextVal); - } else - sprintf(buf, format, VAL); - } else { - memset(buf, 0, 65); - uint64_t v = VAL; - while (bits_used) { - uint32_t bit = v & 1; - bits_used--; - buf[bits_used] = digits[bit][0]; - v >>=1; - } - } - result = buf; - return result; - } - - if (radix != 10) { - uint64_t mask = radix - 1; - uint32_t shift = (radix == 16 ? 4 : radix == 8 ? 3 : 1); - uint32_t nibbles = APINT_BITS_PER_WORD / shift; - for (uint32_t i = 0; i < getNumWords(); ++i) { - uint64_t value = pVal[i]; - for (uint32_t j = 0; j < nibbles; ++j) { - result.insert(0, digits[ value & mask ]); - value >>= shift; - } - } - return result; - } - - APInt tmp(*this); - APInt divisor(tmp.getBitWidth(), 10); - APInt zero(tmp.getBitWidth(), 0); - size_t insert_at = 0; - if (wantSigned && tmp[BitWidth-1]) { - // They want to print the signed version and it is a negative value - // Flip the bits and add one to turn it into the equivalent positive - // value and put a '-' in the result. - tmp.flip(); - tmp++; - result = "-"; - insert_at = 1; - } - if (tmp == 0) - result = "0"; - else while (tmp.ne(zero)) { - APInt APdigit = APIntOps::urem(tmp,divisor); - uint32_t digit = APdigit.getValue(); - assert(digit < radix && "urem failed"); - result.insert(insert_at,digits[digit]); - tmp = APIntOps::udiv(tmp, divisor); - } - - return result; -} - /// getMaxValue - This function returns the largest value /// for an APInt of the specified bit-width and if isSign == true, /// it should be largest signed value, otherwise unsigned value. @@ -881,6 +810,8 @@ /// | 1[63] 11[62-52] 52[51-00] 1023 | /// -------------------------------------- double APInt::roundToDouble(bool isSigned) const { + + // Handle the simple case where the value is contained in one uint64_t. if (isSingleWord() || getActiveBits() <= APINT_BITS_PER_WORD) { if (isSigned) { int64_t sext = (int64_t(VAL) << (64-BitWidth)) >> (64-BitWidth); @@ -889,29 +820,46 @@ return double(VAL); } + // Determine if the value is negative. bool isNeg = isSigned ? (*this)[BitWidth-1] : false; + + // Construct the absolute value if we're negative. APInt Tmp(isNeg ? -(*this) : (*this)); + + // Figure out how many bits we're using. uint32_t n = Tmp.getActiveBits(); - // Exponent when normalized to have decimal point directly after - // leading one. This is stored excess 1023 in the exponent bit field. - uint64_t exp = n - 1; - // Gross overflow. - assert(exp <= 1023 && "Infinity value!"); + // The exponent (without bias normalization) is just the number of bits + // we are using. Note that the sign bit is gone since we constructed the + // absolute value. + uint64_t exp = n; + + // Return infinity for exponent overflow + if (exp > 1023) { + if (!isSigned || !isNeg) + return double(0x0.0p2047L); // positive infinity + else + return double(-0x0.0p2047L); // negative infinity + } + exp += 1023; // Increment for 1023 bias - // Number of bits in mantissa including the leading one - // equals to 53. + // Number of bits in mantissa is 52. To obtain the mantissa value, we must + // extract the high 52 bits from the correct words in pVal. uint64_t mantissa; - if (n % APINT_BITS_PER_WORD >= 53) - mantissa = Tmp.pVal[whichWord(n - 1)] >> (n % APINT_BITS_PER_WORD - 53); - else - mantissa = (Tmp.pVal[whichWord(n - 1)] << (53 - n % APINT_BITS_PER_WORD)) | - (Tmp.pVal[whichWord(n - 1) - 1] >> - (11 + n % APINT_BITS_PER_WORD)); + unsigned hiWord = whichWord(n-1); + if (hiWord == 0) { + mantissa = Tmp.pVal[0]; + if (n > 52) + mantissa >>= n - 52; // shift down, we want the top 52 bits. + } else { + assert(hiWord > 0 && "huh?"); + uint64_t hibits = Tmp.pVal[hiWord] << (52 - n % APINT_BITS_PER_WORD); + uint64_t lobits = Tmp.pVal[hiWord-1] >> (11 + n % APINT_BITS_PER_WORD); + mantissa = hibits | lobits; + } + // The leading bit of mantissa is implicit, so get rid of it. - mantissa &= ~(1ULL << 52); uint64_t sign = isNeg ? (1ULL << (APINT_BITS_PER_WORD - 1)) : 0; - exp += 1023; union { double D; uint64_t I; @@ -1011,6 +959,7 @@ return API; } +#if 0 /// subMul - This function substracts x[len-1:0] * y from /// dest[offset+len-1:offset], and returns the most significant /// word of the product, minus the borrow-out from the subtraction. @@ -1057,6 +1006,8 @@ return (r << 32) | (q & 0xFFFFFFFFl); } +#endif + /// div - This is basically Knuth's formulation of the classical algorithm. /// Correspondance with Knuth's notation: /// Knuth's u[0:m+n] == zds[nx:0]. @@ -1066,39 +1017,281 @@ /// Our nx == Knuth's m+n. /// Could be re-implemented using gmp's mpn_divrem: /// zds[nx] = mpn_divrem (&zds[ny], 0, zds, nx, y, ny). -static void div(uint32_t zds[], uint32_t nx, uint32_t y[], uint32_t ny) { - uint32_t j = nx; - do { // loop over digits of quotient - // Knuth's j == our nx-j. - // Knuth's u[j:j+n] == our zds[j:j-ny]. - uint32_t qhat; // treated as unsigned - if (zds[j] == y[ny-1]) - qhat = -1U; // 0xffffffff - else { - uint64_t w = (((uint64_t)(zds[j])) << 32) + - ((uint64_t)zds[j-1] & 0xffffffffL); - qhat = (uint32_t) unitDiv(w, y[ny-1]); - } - if (qhat) { - uint32_t borrow = subMul(zds, j - ny, y, ny, qhat); - uint32_t save = zds[j]; - uint64_t num = ((uint64_t)save&0xffffffffL) - - ((uint64_t)borrow&0xffffffffL); - while (num) { - qhat--; - uint64_t carry = 0; - for (uint32_t i = 0; i < ny; i++) { - carry += ((uint64_t) zds[j-ny+i] & 0xffffffffL) - + ((uint64_t) y[i] & 0xffffffffL); - zds[j-ny+i] = (uint32_t) carry; - carry >>= 32; - } - zds[j] += carry; - num = carry - 1; + +/// Implementation of Knuth's Algorithm D (Division of nonnegative integers) +/// from "Art of Computer Programming, Volume 2", section 4.3.1, p. 272. The +/// variables here have the same names as in the algorithm. Comments explain +/// the algorithm and any deviation from it. +static void KnuthDiv(uint32_t *u, uint32_t *v, uint32_t *q, uint32_t* r, + uint32_t m, uint32_t n) { + assert(u && "Must provide dividend"); + assert(v && "Must provide divisor"); + assert(q && "Must provide quotient"); + assert(n>1 && "n must be > 1"); + + // Knuth uses the value b as the base of the number system. In our case b + // is 2^31 so we just set it to -1u. + uint64_t b = uint64_t(1) << 32; + + // D1. [Normalize.] Set d = b / (v[n-1] + 1) and multiply all the digits of + // u and v by d. Note that we have taken Knuth's advice here to use a power + // of 2 value for d such that d * v[n-1] >= b/2 (b is the base). A power of + // 2 allows us to shift instead of multiply and it is easy to determine the + // shift amount from the leading zeros. We are basically normalizing the u + // and v so that its high bits are shifted to the top of v's range without + // overflow. Note that this can require an extra word in u so that u must + // be of length m+n+1. + uint32_t shift = CountLeadingZeros_32(v[n-1]); + uint32_t v_carry = 0; + uint32_t u_carry = 0; + if (shift) { + for (uint32_t i = 0; i < m+n; ++i) { + uint32_t u_tmp = u[i] >> (32 - shift); + u[i] = (u[i] << shift) | u_carry; + u_carry = u_tmp; + } + for (uint32_t i = 0; i < n; ++i) { + uint32_t v_tmp = v[i] >> (32 - shift); + v[i] = (v[i] << shift) | v_carry; + v_carry = v_tmp; + } + } + u[m+n] = u_carry; + + // D2. [Initialize j.] Set j to m. This is the loop counter over the places. + int j = m; + do { + // D3. [Calculate q'.]. + // Set qp = (u[j+n]*b + u[j+n-1]) / v[n-1]. (qp=qprime=q') + // Set rp = (u[j+n]*b + u[j+n-1]) % v[n-1]. (rp=rprime=r') + // Now test if qp == b or qp*v[n-2] > b*rp + u[j+n-2]; if so, decrease + // qp by 1, inrease rp by v[n-1], and repeat this test if rp < b. The test + // on v[n-2] determines at high speed most of the cases in which the trial + // value qp is one too large, and it eliminates all cases where qp is two + // too large. + uint64_t qp = ((uint64_t(u[j+n]) << 32) | uint64_t(u[j+n-1])) / v[n-1]; + uint64_t rp = ((uint64_t(u[j+n]) << 32) | uint64_t(u[j+n-1])) % v[n-1]; + if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { + qp--; + rp += v[n-1]; + } + if (rp < b) + if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { + qp--; + rp += v[n-1]; } + + // D4. [Multiply and subtract.] Replace u with u - q*v (for each word). + uint32_t borrow = 0; + for (uint32_t i = 0; i < n; i++) { + uint32_t save = u[j+i]; + u[j+i] = uint64_t(u[j+i]) - (qp * v[i]) - borrow; + if (u[j+i] > save) { + borrow = 1; + u[j+i+1] += b; + } else { + borrow = 0; + } + } + if (borrow) + u[j+n] += 1; + + // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was + // negative, go to step D6; otherwise go on to step D7. + q[j] = qp; + if (borrow) { + // D6. [Add back]. The probability that this step is necessary is very + // small, on the order of only 2/b. Make sure that test data accounts for + // this possibility. Decreate qj by 1 and add v[...] to u[...]. A carry + // will occur to the left of u[j+n], and it should be ignored since it + // cancels with the borrow that occurred in D4. + uint32_t carry = 0; + for (uint32_t i = 0; i < n; i++) { + uint32_t save = u[j+i]; + u[j+i] += v[i] + carry; + carry = u[j+i] < save; + } + } + + // D7. [Loop on j.] Decreate j by one. Now if j >= 0, go back to D3. + j--; + } while (j >= 0); + + // D8. [Unnormalize]. Now q[...] is the desired quotient, and the desired + // remainder may be obtained by dividing u[...] by d. If r is non-null we + // compute the remainder (urem uses this). + if (r) { + // The value d is expressed by the "shift" value above since we avoided + // multiplication by d by using a shift left. So, all we have to do is + // shift right here. In order to mak + uint32_t mask = ~0u >> (32 - shift); + uint32_t carry = 0; + for (int i = n-1; i >= 0; i--) { + uint32_t save = u[i] & mask; + r[i] = (u[i] >> shift) | carry; + carry = save; } - zds[j] = qhat; - } while (--j >= ny); + } +} + +// This function makes calling KnuthDiv a little more convenient. It uses +// APInt parameters instead of uint32_t* parameters. It can also divide APInt +// values of different widths. +void APInt::divide(const APInt LHS, uint32_t lhsWords, + const APInt &RHS, uint32_t rhsWords, + APInt *Quotient, APInt *Remainder) +{ + assert(lhsWords >= rhsWords && "Fractional result"); + + // First, compose the values into an array of 32-bit words instead of + // 64-bit words. This is a necessity of both the "short division" algorithm + // and the the Knuth "classical algorithm" which requires there to be native + // operations for +, -, and * on an m bit value with an m*2 bit result. We + // can't use 64-bit operands here because we don't have native results of + // 128-bits. Furthremore, casting the 64-bit values to 32-bit values won't + // work on large-endian machines. + uint64_t mask = ~0ull >> (sizeof(uint32_t)*8); + uint32_t n = rhsWords * 2; + uint32_t m = (lhsWords * 2) - n; + // FIXME: allocate space on stack if m and n are sufficiently small. + uint32_t *U = new uint32_t[m + n + 1]; + memset(U, 0, (m+n+1)*sizeof(uint32_t)); + for (unsigned i = 0; i < lhsWords; ++i) { + uint64_t tmp = (lhsWords == 1 ? LHS.VAL : LHS.pVal[i]); + U[i * 2] = tmp & mask; + U[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); + } + U[m+n] = 0; // this extra word is for "spill" in the Knuth algorithm. + + uint32_t *V = new uint32_t[n]; + memset(V, 0, (n)*sizeof(uint32_t)); + for (unsigned i = 0; i < rhsWords; ++i) { + uint64_t tmp = (rhsWords == 1 ? RHS.VAL : RHS.pVal[i]); + V[i * 2] = tmp & mask; + V[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); + } + + // Set up the quotient and remainder + uint32_t *Q = new uint32_t[m+n]; + memset(Q, 0, (m+n) * sizeof(uint32_t)); + uint32_t *R = 0; + if (Remainder) { + R = new uint32_t[n]; + memset(R, 0, n * sizeof(uint32_t)); + } + + // Now, adjust m and n for the Knuth division. n is the number of words in + // the divisor. m is the number of words by which the dividend exceeds the + // divisor (i.e. m+n is the length of the dividend). These sizes must not + // contain any zero words or the Knuth algorithm fails. + for (unsigned i = n; i > 0 && V[i-1] == 0; i--) { + n--; + m++; + } + for (unsigned i = m+n; i > 0 && U[i-1] == 0; i--) + m--; + + // If we're left with only a single word for the divisor, Knuth doesn't work + // so we implement the short division algorithm here. This is much simpler + // and faster because we are certain that we can divide a 64-bit quantity + // by a 32-bit quantity at hardware speed and short division is simply a + // series of such operations. This is just like doing short division but we + // are using base 2^32 instead of base 10. + assert(n != 0 && "Divide by zero?"); + if (n == 1) { + uint32_t divisor = V[0]; + uint32_t remainder = 0; + for (int i = m+n-1; i >= 0; i--) { + uint64_t partial_dividend = uint64_t(remainder) << 32 | U[i]; + if (partial_dividend == 0) { + Q[i] = 0; + remainder = 0; + } else if (partial_dividend < divisor) { + Q[i] = 0; + remainder = partial_dividend; + } else if (partial_dividend == divisor) { + Q[i] = 1; + remainder = 0; + } else { + Q[i] = partial_dividend / divisor; + remainder = partial_dividend - (Q[i] * divisor); + } + } + if (R) + R[0] = remainder; + } else { + // Now we're ready to invoke the Knuth classical divide algorithm. In this + // case n > 1. + KnuthDiv(U, V, Q, R, m, n); + } + + // If the caller wants the quotient + if (Quotient) { + // Set up the Quotient value's memory. + if (Quotient->BitWidth != LHS.BitWidth) { + if (Quotient->isSingleWord()) + Quotient->VAL = 0; + else + delete Quotient->pVal; + Quotient->BitWidth = LHS.BitWidth; + if (!Quotient->isSingleWord()) + Quotient->pVal = getClearedMemory(lhsWords); + } else + Quotient->clear(); + + // The quotient is in Q. Reconstitute the quotient into Quotient's low + // order words. + if (lhsWords == 1) { + uint64_t tmp = + uint64_t(Q[0]) | (uint64_t(Q[1]) << (APINT_BITS_PER_WORD / 2)); + if (Quotient->isSingleWord()) + Quotient->VAL = tmp; + else + Quotient->pVal[0] = tmp; + } else { + assert(!Quotient->isSingleWord() && "Quotient APInt not large enough"); + for (unsigned i = 0; i < lhsWords; ++i) + Quotient->pVal[i] = + uint64_t(Q[i*2]) | (uint64_t(Q[i*2+1]) << (APINT_BITS_PER_WORD / 2)); + } + } + + // If the caller wants the remainder + if (Remainder) { + // Set up the Remainder value's memory. + if (Remainder->BitWidth != RHS.BitWidth) { + if (Remainder->isSingleWord()) + Remainder->VAL = 0; + else + delete Remainder->pVal; + Remainder->BitWidth = RHS.BitWidth; + if (!Remainder->isSingleWord()) + Remainder->pVal = getClearedMemory(rhsWords); + } else + Remainder->clear(); + + // The remainder is in R. Reconstitute the remainder into Remainder's low + // order words. + if (rhsWords == 1) { + uint64_t tmp = + uint64_t(R[0]) | (uint64_t(R[1]) << (APINT_BITS_PER_WORD / 2)); + if (Remainder->isSingleWord()) + Remainder->VAL = tmp; + else + Remainder->pVal[0] = tmp; + } else { + assert(!Remainder->isSingleWord() && "Remainder APInt not large enough"); + for (unsigned i = 0; i < rhsWords; ++i) + Remainder->pVal[i] = + uint64_t(R[i*2]) | (uint64_t(R[i*2+1]) << (APINT_BITS_PER_WORD / 2)); + } + } + + // Clean up the memory we allocated. + delete [] U; + delete [] V; + delete [] Q; + delete [] R; } /// Unsigned divide this APInt by APInt RHS. @@ -1112,47 +1305,38 @@ return APInt(BitWidth, VAL / RHS.VAL); } - // Make a temporary to hold the result - APInt Result(*this); - // Get some facts about the LHS and RHS number of bits and words uint32_t rhsBits = RHS.getActiveBits(); uint32_t rhsWords = !rhsBits ? 0 : (APInt::whichWord(rhsBits - 1) + 1); assert(rhsWords && "Divided by zero???"); - uint32_t lhsBits = Result.getActiveBits(); + uint32_t lhsBits = this->getActiveBits(); uint32_t lhsWords = !lhsBits ? 0 : (APInt::whichWord(lhsBits - 1) + 1); + // Make a temporary to hold the result + APInt Result(*this); + // Deal with some degenerate cases if (!lhsWords) return Result; // 0 / X == 0 - else if (lhsWords < rhsWords || Result.ult(RHS)) + else if (lhsWords < rhsWords || Result.ult(RHS)) { // X / Y with X < Y == 0 memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - else if (Result == RHS) { + return Result; + } else if (Result == RHS) { // X / X == 1 memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); Result.pVal[0] = 1; - } else if (lhsWords == 1) + return Result; + } else if (lhsWords == 1 && rhsWords == 1) { // All high words are zero, just use native divide Result.pVal[0] /= RHS.pVal[0]; - else { - // Compute it the hard way .. - APInt X(BitWidth, 0); - APInt Y(BitWidth, 0); - uint32_t nshift = - (APINT_BITS_PER_WORD - 1) - ((rhsBits - 1) % APINT_BITS_PER_WORD ); - if (nshift) { - Y = APIntOps::shl(RHS, nshift); - X = APIntOps::shl(Result, nshift); - ++lhsWords; - } - div((uint32_t*)X.pVal, lhsWords * 2 - 1, - (uint32_t*)(Y.isSingleWord()? &Y.VAL : Y.pVal), rhsWords*2); - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - memcpy(Result.pVal, X.pVal + rhsWords, - (lhsWords - rhsWords) * APINT_WORD_SIZE); + return Result; } - return Result; + + // We have to compute it the hard way. Invoke the Knuth divide algorithm. + APInt Quotient(1,0); // to hold result. + divide(*this, lhsWords, RHS, rhsWords, &Quotient, 0); + return Quotient; } /// Unsigned remainder operation on APInt. @@ -1177,37 +1361,27 @@ uint32_t lhsWords = !lhsBits ? 0 : (Result.whichWord(lhsBits - 1) + 1); // Check the degenerate cases - if (lhsWords == 0) + if (lhsWords == 0) { // 0 % Y == 0 memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - else if (lhsWords < rhsWords || Result.ult(RHS)) + return Result; + } else if (lhsWords < rhsWords || Result.ult(RHS)) { // X % Y == X iff X < Y return Result; - else if (Result == RHS) + } else if (Result == RHS) { // X % X == 0; memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - else if (lhsWords == 1) + return Result; + } else if (lhsWords == 1) { // All high words are zero, just use native remainder Result.pVal[0] %= RHS.pVal[0]; - else { - // Do it the hard way - APInt X((lhsWords+1)*APINT_BITS_PER_WORD, 0); - APInt Y(rhsWords*APINT_BITS_PER_WORD, 0); - uint32_t nshift = - (APINT_BITS_PER_WORD - 1) - (rhsBits - 1) % APINT_BITS_PER_WORD; - if (nshift) { - APIntOps::shl(Y, nshift); - APIntOps::shl(X, nshift); - } - div((uint32_t*)X.pVal, rhsWords*2-1, - (uint32_t*)(Y.isSingleWord()? &Y.VAL : Y.pVal), rhsWords*2); - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - for (uint32_t i = 0; i < rhsWords-1; ++i) - Result.pVal[i] = (X.pVal[i] >> nshift) | - (X.pVal[i+1] << (APINT_BITS_PER_WORD - nshift)); - Result.pVal[rhsWords-1] = X.pVal[rhsWords-1] >> nshift; + return Result; } - return Result; + + // We have to compute it the hard way. Invoke the Knute divide algorithm. + APInt Remainder(1,0); + divide(*this, lhsWords, RHS, rhsWords, 0, &Remainder); + return Remainder; } /// @brief Converts a char array into an integer. @@ -1279,3 +1453,81 @@ } } } + +/// to_string - This function translates the APInt into a string. +std::string APInt::toString(uint8_t radix, bool wantSigned) const { + assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && + "Radix should be 2, 8, 10, or 16!"); + static const char *digits[] = { + "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F" + }; + std::string result; + uint32_t bits_used = getActiveBits(); + if (isSingleWord()) { + char buf[65]; + const char *format = (radix == 10 ? (wantSigned ? "%lld" : "%llu") : + (radix == 16 ? "%llX" : (radix == 8 ? "%llo" : 0))); + if (format) { + if (wantSigned) { + int64_t sextVal = (int64_t(VAL) << (APINT_BITS_PER_WORD-BitWidth)) >> + (APINT_BITS_PER_WORD-BitWidth); + sprintf(buf, format, sextVal); + } else + sprintf(buf, format, VAL); + } else { + memset(buf, 0, 65); + uint64_t v = VAL; + while (bits_used) { + uint32_t bit = v & 1; + bits_used--; + buf[bits_used] = digits[bit][0]; + v >>=1; + } + } + result = buf; + return result; + } + + if (radix != 10) { + uint64_t mask = radix - 1; + uint32_t shift = (radix == 16 ? 4 : radix == 8 ? 3 : 1); + uint32_t nibbles = APINT_BITS_PER_WORD / shift; + for (uint32_t i = 0; i < getNumWords(); ++i) { + uint64_t value = pVal[i]; + for (uint32_t j = 0; j < nibbles; ++j) { + result.insert(0, digits[ value & mask ]); + value >>= shift; + } + } + return result; + } + + APInt tmp(*this); + APInt divisor(4, radix); + APInt zero(tmp.getBitWidth(), 0); + size_t insert_at = 0; + if (wantSigned && tmp[BitWidth-1]) { + // They want to print the signed version and it is a negative value + // Flip the bits and add one to turn it into the equivalent positive + // value and put a '-' in the result. + tmp.flip(); + tmp++; + result = "-"; + insert_at = 1; + } + if (tmp == 0) + result = "0"; + else while (tmp.ne(zero)) { + APInt APdigit(1,0); + divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), 0, &APdigit); + uint32_t digit = APdigit.getValue(); + assert(digit < radix && "urem failed"); + result.insert(insert_at,digits[digit]); + APInt tmp2(tmp.getBitWidth(), 0); + divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), &tmp2, 0); + tmp = tmp2; + } + + return result; +} + From alenhar2 at cs.uiuc.edu Tue Feb 20 12:20:34 2007 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 20 Feb 2007 12:20:34 -0600 Subject: [llvm-commits] [see] CVS: llvm/lib/Target/X86/X86TargetAsmInfo.cpp Message-ID: <200702201820.l1KIKYr7003846@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetAsmInfo.cpp updated: 1.7 -> 1.7.4.1 --- Log message: Backport fix to [see] --- Diffs of the changes: (+1 -1) X86TargetAsmInfo.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.7 llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.7.4.1 --- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.7 Tue Oct 31 02:31:24 2006 +++ llvm/lib/Target/X86/X86TargetAsmInfo.cpp Tue Feb 20 12:19:58 2007 @@ -69,7 +69,7 @@ // bool HasDotLoc; // Defaults to false. // HasDotFile - True if target asm supports .file directives. // bool HasDotFile; // Defaults to false. - PrivateGlobalPrefix = "."; // Prefix for private global symbols + PrivateGlobalPrefix = ".L"; // Prefix for private global symbols DwarfRequiresFrameSection = false; DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\", at progbits"; DwarfInfoSection = "\t.section\t.debug_info,\"\", at progbits"; From alenhar2 at cs.uiuc.edu Tue Feb 20 12:21:55 2007 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 20 Feb 2007 12:21:55 -0600 Subject: [llvm-commits] [see] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200702201821.l1KILthe003883@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.280 -> 1.280.4.1 --- Log message: section support for CBE, may want to port this to head --- Diffs of the changes: (+2 -0) Writer.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.280 llvm/lib/Target/CBackend/Writer.cpp:1.280.4.1 --- llvm/lib/Target/CBackend/Writer.cpp:1.280 Sun Nov 5 13:26:37 2006 +++ llvm/lib/Target/CBackend/Writer.cpp Tue Feb 20 12:21:25 2007 @@ -1273,6 +1273,8 @@ Out << " __attribute__((common))"; else if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__"; + if (I->hasSection()) + Out << " __attribute__ ((__section__ (\"" << I->getSection() << "\")))"; Out << ";\n"; } } From reid at x10sys.com Tue Feb 20 12:29:29 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 12:29:29 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702201829.l1KITTid019098@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.22 -> 1.23 --- Log message: Use INFINITY macro from math.h instead of constructing hex floating point constants (avoids warnings). --- Diffs of the changes: (+3 -2) APInt.cpp | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.22 llvm/lib/Support/APInt.cpp:1.23 --- llvm/lib/Support/APInt.cpp:1.22 Tue Feb 20 02:51:03 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 12:29:12 2007 @@ -17,6 +17,7 @@ #include "llvm/Support/MathExtras.h" #include #include +#include using namespace llvm; // A utility function for allocating memory, checking for allocation failures, @@ -837,9 +838,9 @@ // Return infinity for exponent overflow if (exp > 1023) { if (!isSigned || !isNeg) - return double(0x0.0p2047L); // positive infinity + return double(INFINITY); // positive infinity else - return double(-0x0.0p2047L); // negative infinity + return double(-INFINITY); // negative infinity } exp += 1023; // Increment for 1023 bias From evan.cheng at apple.com Tue Feb 20 13:13:26 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 20 Feb 2007 11:13:26 -0800 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp In-Reply-To: <200702201829.l1KITTid019098@zion.cs.uiuc.edu> References: <200702201829.l1KITTid019098@zion.cs.uiuc.edu> Message-ID: Hi Reid, This breaks the build for me. $ make ENABLE_OPTIMIZED=1 -j2 make[1]: Nothing to be done for `all'. llvm[1]: Compiling Annotation.cpp for Release build llvm[1]: Compiling APInt.cpp for Release build APInt.cpp:841: error: floating constant exceeds range of 'float' APInt.cpp:843: error: floating constant exceeds range of 'float' Evan On Feb 20, 2007, at 10:29 AM, Reid Spencer wrote: > > > Changes in directory llvm/lib/Support: > > APInt.cpp updated: 1.22 -> 1.23 > --- > Log message: > > Use INFINITY macro from math.h instead of constructing hex floating > point > constants (avoids warnings). > > > --- > Diffs of the changes: (+3 -2) > > APInt.cpp | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > > Index: llvm/lib/Support/APInt.cpp > diff -u llvm/lib/Support/APInt.cpp:1.22 llvm/lib/Support/APInt.cpp: > 1.23 > --- llvm/lib/Support/APInt.cpp:1.22 Tue Feb 20 02:51:03 2007 > +++ llvm/lib/Support/APInt.cpp Tue Feb 20 12:29:12 2007 > @@ -17,6 +17,7 @@ > #include "llvm/Support/MathExtras.h" > #include > #include > +#include > using namespace llvm; > > // A utility function for allocating memory, checking for > allocation failures, > @@ -837,9 +838,9 @@ > // Return infinity for exponent overflow > if (exp > 1023) { > if (!isSigned || !isNeg) > - return double(0x0.0p2047L); // positive infinity > + return double(INFINITY); // positive infinity > else > - return double(-0x0.0p2047L); // negative infinity > + return double(-INFINITY); // negative infinity > } > exp += 1023; // Increment for 1023 bias > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Tue Feb 20 13:38:37 2007 From: clattner at apple.com (Chris Lattner) Date: Tue, 20 Feb 2007 11:38:37 -0800 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp In-Reply-To: References: <200702201829.l1KITTid019098@zion.cs.uiuc.edu> Message-ID: <2C5C6A8E-718E-4F20-A981-3FB936944CFD@apple.com> On Feb 20, 2007, at 11:13 AM, Evan Cheng wrote: > Hi Reid, > This breaks the build for me. > > $ make ENABLE_OPTIMIZED=1 -j2 > make[1]: Nothing to be done for `all'. > llvm[1]: Compiling Annotation.cpp for Release build > llvm[1]: Compiling APInt.cpp for Release build > APInt.cpp:841: error: floating constant exceeds range of 'float' > APInt.cpp:843: error: floating constant exceeds range of 'float' Okay, how about just using something like (1e300 * 1e300), which will constant fold to inf? -Chris > Evan > > On Feb 20, 2007, at 10:29 AM, Reid Spencer wrote: > >> >> >> Changes in directory llvm/lib/Support: >> >> APInt.cpp updated: 1.22 -> 1.23 >> --- >> Log message: >> >> Use INFINITY macro from math.h instead of constructing hex floating >> point >> constants (avoids warnings). >> >> >> --- >> Diffs of the changes: (+3 -2) >> >> APInt.cpp | 5 +++-- >> 1 files changed, 3 insertions(+), 2 deletions(-) >> >> >> Index: llvm/lib/Support/APInt.cpp >> diff -u llvm/lib/Support/APInt.cpp:1.22 llvm/lib/Support/APInt.cpp: >> 1.23 >> --- llvm/lib/Support/APInt.cpp:1.22 Tue Feb 20 02:51:03 2007 >> +++ llvm/lib/Support/APInt.cpp Tue Feb 20 12:29:12 2007 >> @@ -17,6 +17,7 @@ >> #include "llvm/Support/MathExtras.h" >> #include >> #include >> +#include >> using namespace llvm; >> >> // A utility function for allocating memory, checking for >> allocation failures, >> @@ -837,9 +838,9 @@ >> // Return infinity for exponent overflow >> if (exp > 1023) { >> if (!isSigned || !isNeg) >> - return double(0x0.0p2047L); // positive infinity >> + return double(INFINITY); // positive infinity >> else >> - return double(-0x0.0p2047L); // negative infinity >> + return double(-INFINITY); // negative infinity >> } >> exp += 1023; // Increment for 1023 bias >> >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From reid at x10sys.com Tue Feb 20 14:39:51 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 14:39:51 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp Message-ID: <200702202039.l1KKdpWF021421@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt: arith.cpp updated: 1.10 -> 1.11 --- Log message: Consolidate code, expand testing to more values. --- Diffs of the changes: (+55 -18) arith.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 55 insertions(+), 18 deletions(-) Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.10 llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.11 --- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.10 Sun Feb 18 16:29:58 2007 +++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp Tue Feb 20 14:39:34 2007 @@ -26,6 +26,16 @@ printf("\n"); } +APInt randomAPInt(unsigned bits) { + APInt val(bits, 0u); + for (unsigned i = 0; i < bits; ++i) { + unsigned bit = rand() % 2; + val = val.shl(1); + val |= APInt(bits, bit); + } + return val; +} + void test_interface(const APInt &val) { printf("INTERFACE TEST: val = "); print(val); unsigned bitwidth = val.getBitWidth(); @@ -104,8 +114,8 @@ } void test_binops(const APInt &v1, const APInt &v2) { - printf("BINARY OPERATORS TEST: vl = "); print(v1,false,false); - printf(", v2 = "); print(v2); + printf("BINARY OPERATORS TEST: \n vl: "); print(v1,false,false); + printf("\n v2: "); print(v2); APInt result(v1); result &= v2; printf("v1 &= v2: "); print(result); @@ -157,7 +167,7 @@ printf("lshr(v1,%d) = ", shiftAmt); print(result); result = shl(v1,shiftAmt); printf("shl(v1,%d) = ", shiftAmt); print(result); - if (v2 == 0) + if (v2 == APInt(v2.getBitWidth(), 0)) printf("sdiv/udiv/srem/urem not tested, v2 == 0\n"); else { result = sdiv(v1,v2); @@ -174,28 +184,55 @@ void test_multiple() { srand(0); - for (unsigned bits = 1; bits <= 1024; ++bits) { - APInt v1(bits, 0u); - APInt v2(bits, 0u); - for (unsigned i = 0; i < bits; ++i) { - unsigned bit = rand() % 2; - v1 = v1.shl(1); - v1 |= APInt(bits, bit); + for (unsigned bits = 1; bits <= 256; ++bits) { + printf("\nTEST CASE: %d BITS\n\n", bits); + APInt zero(bits,0); + APInt one(bits,1); + if (bits == 1) { + test_interface(zero); + test_interface(one); + test_unops(zero); + test_unops(one); + test_binops(zero,one); + test_binops(one,zero); + continue; + } + APInt two(bits,1); + APInt three(bits,1); + APInt min = APInt::getMinValue(bits, true); + APInt max = APInt::getMaxValue(bits, true); + APInt mid = APIntOps::lshr(max, bits/2); + APInt r1 = randomAPInt(bits); + APInt r2 = randomAPInt(bits); + APInt *list[9]; + list[0] = &zero; + list[1] = &one; + list[2] = &two; + list[3] = &three; + list[4] = &min; + list[5] = &r1; + list[6] = ∣ + list[7] = &r2; + list[8] = &max; + for (unsigned i = 0; i < 9; ++i) { + test_interface(*(list[i])); + test_unops(*(list[i])); } - for (unsigned i = 0; i < bits; ++i) { - unsigned bit = rand() % 2; - v2 = v2.shl(1); - v2 |= APInt(bits, bit); + for (unsigned i = 0; i < 9; ++i) { + for (unsigned j = 0; j < 9; ++j) { + test_binops(*(list[i]), *(list[j])); + } } - printf("\nTEST CASE: %d bits\n\n", bits); - test_interface(v1); - test_unops(v2); - test_binops(v1,v2); } } int main() { + APInt X(48, 100); + APInt Y(48, 10); + APInt Q(1,0); + APInt R(1,0); + APInt::divide(X, 1, Y, 1, &Q, &R); test_multiple(); return 0; } From reid at x10sys.com Tue Feb 20 14:42:26 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 14:42:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702202042.l1KKgQMh021475@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.23 -> 1.24 --- Log message: Clean up variable names in operator*. Attempt #3 for getting a portable INFINITY value. --- Diffs of the changes: (+8 -8) APInt.cpp | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.23 llvm/lib/Support/APInt.cpp:1.24 --- llvm/lib/Support/APInt.cpp:1.23 Tue Feb 20 12:29:12 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 14:42:10 2007 @@ -17,7 +17,6 @@ #include "llvm/Support/MathExtras.h" #include #include -#include using namespace llvm; // A utility function for allocating memory, checking for allocation failures, @@ -331,7 +330,8 @@ /// given APInt& RHS and assigns the result to this APInt. APInt& APInt::operator*=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) VAL *= RHS.isSingleWord() ? RHS.VAL : RHS.pVal[0]; + if (isSingleWord()) + VAL *= RHS.VAL; else { // one-based first non-zero bit position. uint32_t first = getActiveBits(); @@ -456,10 +456,10 @@ /// RHS. APInt APInt::operator*(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - APInt API(RHS); - API *= *this; - API.clearUnusedBits(); - return API; + APInt Result(*this); + Result *= RHS; + Result.clearUnusedBits(); + return Result; } /// @brief Addition operator. Adds this APInt by the given APInt& RHS. @@ -838,9 +838,9 @@ // Return infinity for exponent overflow if (exp > 1023) { if (!isSigned || !isNeg) - return double(INFINITY); // positive infinity + return double(1.0E300 * 1.0E300); // positive infinity else - return double(-INFINITY); // negative infinity + return double(-1.0E300 * 1.0E300); // negative infinity } exp += 1023; // Increment for 1023 bias From reid at x10sys.com Tue Feb 20 14:44:17 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 14:44:17 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Message-ID: <200702202044.l1KKiHKq021512@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt: gptest.cpp added (r1.1) --- Log message: A test program to test APInt against the results produced by pari/gp. If there's no output other than the bit size banners, everything is fine. If outputs vary from pari/gp, they are printed. Program requires "gp" to be in the user's path. --- Diffs of the changes: (+380 -0) gptest.cpp | 380 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 380 insertions(+) Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.1 *** /dev/null Tue Feb 20 14:44:11 2007 --- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Tue Feb 20 14:44:00 2007 *************** *** 0 **** --- 1,380 ---- + //===--- gptest.cpp --- Test Cases for Bit Accurate Types -----------------===// + // + // This file was developed by Guoling Han and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This is a validating test for arithmetic operations that uses the gp (pari) + // calculator to validate APInt's computations. + // + //===----------------------------------------------------------------------===// + + #include "llvm/ADT/APInt.h" + #include + #include + #include + #include + #include "llvm/System/Signals.h" + + using namespace llvm; + + APInt x(21, 0x1fffff); + APInt y(21, 0x0fffff); + + void print(const APInt& X, bool wantSigned = false, bool withNL = true) { + std::string decstr = X.toString(10,wantSigned); + printf("%s", decstr.c_str()); + if (withNL) + printf("\n"); + } + + APInt randomAPInt(unsigned bits) { + APInt val(bits, 0u); + for (unsigned i = 0; i < bits; ++i) { + unsigned bit = rand() % 2; + val = val.shl(1); + val |= APInt(bits, bit); + } + return val; + } + + void test_interface(const APInt &val) { + printf("INTERFACE TEST: val = "); print(val); + unsigned bitwidth = val.getBitWidth(); + unsigned pos = rand() % bitwidth; + printf("val[%u] = %d\n", pos, val[pos]); + APInt smax(APInt::getMaxValue(bitwidth, true)); + APInt umax(APInt::getMaxValue(bitwidth, false)); + APInt smin(APInt::getMinValue(bitwidth, true)); + APInt umin(APInt::getMinValue(bitwidth, false)); + printf("APInt::getMinValue(%d, true) = ", bitwidth); print(smin,true); + printf("APInt::getMaxValue(%d, true) = ", bitwidth); print(smax,true); + printf("APInt::getMinValue(%d, false) = ", bitwidth); print(umin); + printf("APInt::getMaxValue(%d, false) = ", bitwidth); print(umax); + APInt null = APInt::getNullValue(bitwidth); + APInt allone = APInt::getAllOnesValue(bitwidth); + printf("APInt::getNullValue(%d) = ", bitwidth); print(null); + printf("APInt::getAllOnesValue(%d) = ", bitwidth); print(allone); + APInt x(val); + x.set(pos); + printf("val.set(%d) = ", pos); print(x); + x.set(); + printf("val.set() = "); print(x); + x = val; + x.clear(pos); + printf("val.clear(%d) = ", pos); print(x); + x.clear(); + printf("val.clear() = "); print(x); + x = val; + x.flip(pos); + printf("val.flip(%d) = ", pos); print(x); + x = val; + x.flip(); + printf("val.flip() = "); print(x); + unsigned bitsize = bitwidth / 2; + printf("val.getHiBits(%d) = ", bitsize); print(val.getHiBits(bitsize)); + printf("val.getLoBits(%d) = ", bitsize); print(val.getLoBits(bitsize)); + printf("val.isIntN(%d) = %d\n", bitwidth, val.isIntN(bitwidth)); + } + + void test_unops(const APInt &val) { + printf("UNARY OPERATORS TEST: val = "); print(val); + APInt x(val); + x++; + printf("val++ = "); print(x); + x = val; + ++x; + printf("++val = "); print(x); + x = val; + x--; + printf("val-- = "); print(x); + x = val; + --x; + printf("--val = "); print(x); + x = -val; + printf("-val = "); print(x); + x = ~val; + printf("~val = "); print(x); + printf("!val = %d\n", !val); + printf("val.isPowerOf2() = %d\n", val.isPowerOf2()); + printf("val.logBase2() = %d\n", val.logBase2()); + printf("val.countLeadingZeros() = %d\n", val.countLeadingZeros()); + printf("val.countTrailingZeros() = %d\n", val.countTrailingZeros()); + printf("val.countPopulation() = %d\n", val.countPopulation()); + printf("val.getBitWidth() = %d\n", val.getBitWidth()); + if (val.getBitWidth() >= 16 && val.getBitWidth() % 16 == 0) { + x = val.byteSwap(); + printf("val.byteSwap() = "); print(x); + } + printf("val.roundToDouble(false) = %f\n", val.roundToDouble(false)); + printf("val.roundToDouble(true) = %f\n", val.roundToDouble(true)); + printf("val.getValue() = "); + if (val.getBitWidth() > 64) + printf("too wide\n"); + else + printf("%lu\n", val.getValue()); + } + + void old_test_binops(const APInt &v1, const APInt &v2) { + printf("BINARY OPERATORS TEST: \n vl: "); print(v1,false,false); + printf("\n v2: "); print(v2); + APInt result(v1); + result &= v2; + printf("v1 &= v2: "); print(result); + result = v1; + result |= v2; + printf("v1 |= v2: "); print(result); + result = v1; + result ^= v2; + printf("v1 ^= v2: "); print(result); + result = v1; + result *= v2; + printf("v1 *= v2: "); print(result); + result = v1; + result += v2; + printf("v1 += v2: "); print(result); + result = v1; + result -= v2; + printf("v1 -= v2: "); print(result); + result = v1 & v2; + printf("v1 & v2: "); print(result); + result = v1 | v2; + printf("v1 | v2: "); print(result); + result = v1 ^ v2; + printf("v1 ^ v2: "); print(result); + result = v1 * v2; + printf("v1 * v2: "); print(result); + result = v1 + v2; + printf("v1 + v2: "); print(result); + result = v1 - v2; + printf("v1 - v2: "); print(result); + printf("v1 == v2: %d\n", v1 == v2); + printf("v1 != v2: %d\n", v1 != v2); + printf("v1.eq(v2): %d\n", v1.eq(v2)); + printf("v1.ne(v2): %d\n", v1.ne(v2)); + printf("v1.ult(v2): %d\n", v1.ult(v2)); + printf("v1.slt(v2): %d\n", v1.slt(v2)); + printf("v1.ule(v2): %d\n", v1.ule(v2)); + printf("v1.sle(v2): %d\n", v1.sle(v2)); + printf("v1.ugt(v2): %d\n", v1.ugt(v2)); + printf("v1.sgt(v2): %d\n", v1.sgt(v2)); + printf("v1.uge(v2): %d\n", v1.uge(v2)); + printf("v1.sge(v2): %d\n", v1.sge(v2)); + { + using namespace APIntOps; + unsigned shiftAmt = rand() % v1.getBitWidth(); + result = ashr(v1,shiftAmt); + printf("ashr(v1,%d) = ", shiftAmt); print(result); + result = lshr(v1,shiftAmt); + printf("lshr(v1,%d) = ", shiftAmt); print(result); + result = shl(v1,shiftAmt); + printf("shl(v1,%d) = ", shiftAmt); print(result); + if (v2 == APInt(v2.getBitWidth(), 0)) + printf("sdiv/udiv/srem/urem not tested, v2 == 0\n"); + else { + result = sdiv(v1,v2); + printf("sdiv(v1,v2) = "); print(result); + result = udiv(v1,v2); + printf("udiv(v1,v2) = "); print(result); + result = srem(v1,v2); + printf("srem(v1,v2) = "); print(result); + result = urem(v1,v2); + printf("urem(v1,v2) = "); print(result); + } + } + } + + static int input = 0, output = 0; + + std::string getBinopCmd(const APInt &v1, std::string op, const APInt &v2, + bool wantSigned = false) { + std::string Result; + Result += "truncate("; + Result += v1.toString(10,wantSigned); + Result += " " + op + " "; + Result += v2.toString(10,wantSigned); + Result += ")\n"; + return Result; + } + + std::string getResult(const std::string& cmd) { + const char *command = cmd.c_str(); + if (-1 == write(output, command, cmd.size())) { + std::string msg = "write: " + cmd; + perror(msg.c_str()); + exit(1); + } + usleep(1000); // try to switch contexts + char buf[1024]; + int len = read(input, buf, 1024); + if (-1 == len) { + std::string msg = "read: " + cmd; + perror(msg.c_str()); + exit(1); + } + // We're only interested in the last line. + if (char * nl = strrchr(buf, '\n')) { + *nl = 0; + if (char *nnl = strrchr(nl, '\n')) + return std::string(nnl+1); + } + return std::string(buf); + } + + void doMultiply(const APInt &v1, const APInt &v2) { + std::string cmd = getBinopCmd(v1, "*", v2); + std::string result = getResult(cmd); + APInt r = v1 * v2; + std::string apresult = r.toString(10, false); + if (result != apresult) { + printf("ERROR: "); + print(v1, false, false); + printf(" * "); + print(v2, false, false); + printf(" = %s (not %s)\n", result.c_str(), apresult.c_str()); + } + } + + void test_binops(const APInt &v1, const APInt &v2) { + doMultiply(v1, v2); + } + + void Shutdown() { + close(input); + close(output); + } + + /* function executed by the user-interacting process. */ + void test_driver(int input_pipe[], int output_pipe[]) { + + int c; /* user input - must be 'int', to recognize EOF (= -1). */ + char ch; /* the same - as a char. */ + int rc; /* return values of functions. */ + + /* first, close unnecessary file descriptors */ + close(input_pipe[1]); /* we don't need to write to this pipe. */ + close(output_pipe[0]); /* we don't need to read from this pipe. */ + + // Simplify input/output file descriptors + input = input_pipe[0]; + output = output_pipe[1]; + + // Make sure we close these to give gp an eof and terminate it + sys::SetInterruptFunction(Shutdown); + + // Initialize random number generator + srand(0); + + // Start loop over the range of bits of interest + for (unsigned bits = 1; bits <= 256; ++bits) { + // Indicate which test case we are running + printf("\nTEST CASE: %d BITS\n\n", bits); + // Gather some test data + APInt zero(bits,0); + APInt one(bits,1); + APInt two(bits,2); + APInt three(bits,3); + APInt min = APInt::getMinValue(bits, true); + APInt max = APInt::getMaxValue(bits, true); + APInt mid = APIntOps::lshr(max, bits/2); + APInt r1 = randomAPInt(bits); + APInt r2 = randomAPInt(bits); + APInt *list[9]; + list[0] = &zero; + list[1] = &one; + list[2] = &two; + list[3] = &three; + list[4] = &min; + list[5] = &r1; + list[6] = ∣ + list[7] = &r2; + list[8] = &max; + + // Generate and issue commands to calculator for + // all combinations of pairs of values. + for (unsigned i = 0; i < 9; ++i) { + for (unsigned j = 0; j < 9; ++j) { + test_binops(*(list[i]), *(list[j])); + } + } + } + + /* close pipes and exit. */ + Shutdown(); + exit(0); + } + + /* now comes the function executed by the translator process. */ + void calculator(int input_pipe[], int output_pipe[]) + { + int c; /* user input - must be 'int', to recognize EOF (= -1). */ + char ch; /* the same - as a char. */ + int rc; /* return values of functions. */ + + printf("In translator\n"); + + /* first, close unnecessary file descriptors */ + close(input_pipe[1]); /* we don't need to write to this pipe. */ + close(output_pipe[0]); /* we don't need to read from this pipe. */ + + /* set up the stdin/stdout */ + if (-1 == dup2(input_pipe[0], STDIN_FILENO)) { + perror("dup2 for stdin"); + exit(1); + } + if (-1 == dup2(output_pipe[1], STDOUT_FILENO)) { + perror("dup2 for stdout"); + exit(1); + } + + // exec gp with modes: + // --quiet (don't print banner), + // --fast (don't read init files) + // --test (no history, wrap long lines) + execlp("gp", "gp", "--quiet", "--fast", "--test", (char*)NULL); + perror("execlp"); + exit(1); + } + + /* and finally, the main function: spawn off two processes, */ + /* and let each of them execute its function. */ + int main(int argc, char* argv[]) + { + /* 2 arrays to contain file descriptors, for two pipes. */ + int user_to_translator[2]; + int translator_to_user[2]; + int pid; /* pid of child process, or 0, as returned via fork. */ + int rc; /* stores return values of various routines. */ + + /* first, create one pipe. */ + rc = pipe(user_to_translator); + if (rc == -1) { + perror("main: pipe user_to_translator"); + exit(1); + } + /* then, create another pipe. */ + rc = pipe(translator_to_user); + if (rc == -1) { + perror("main: pipe translator_to_user"); + exit(1); + } + + /* now fork off a child process, and set their handling routines. */ + pid = fork(); + + switch (pid) { + case -1: /* fork failed. */ + perror("main: fork"); + exit(1); + case 0: /* inside child process. */ + calculator(user_to_translator, translator_to_user); /* line 'A' */ + /* NOT REACHED */ + default: /* inside parent process. */ + test_driver(translator_to_user, user_to_translator); /* line 'B' */ + /* NOT REACHED */ + } + + return 0; /* NOT REACHED */ + } + From djg at cray.com Tue Feb 20 14:52:20 2007 From: djg at cray.com (Dan Gohman) Date: Tue, 20 Feb 2007 14:52:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200702202052.l1KKqKOE021678@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: InlineFunction.cpp updated: 1.53 -> 1.54 --- Log message: Fix typos in comments. --- Diffs of the changes: (+1 -1) InlineFunction.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/Utils/InlineFunction.cpp diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.53 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.54 --- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.53 Mon Feb 12 20:10:56 2007 +++ llvm/lib/Transforms/Utils/InlineFunction.cpp Tue Feb 20 14:52:03 2007 @@ -263,7 +263,7 @@ ++I; // Transfer all of the allocas over in a block. Using splice means - // that they instructions aren't removed from the symbol table, then + // that the instructions aren't removed from the symbol table, then // reinserted. Caller->front().getInstList().splice(InsertPoint, FirstNewBlock->getInstList(), From djg at cray.com Tue Feb 20 14:52:21 2007 From: djg at cray.com (Dan Gohman) Date: Tue, 20 Feb 2007 14:52:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Target.td Message-ID: <200702202052.l1KKqL54021683@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: Target.td updated: 1.92 -> 1.93 --- Log message: Fix typos in comments. --- Diffs of the changes: (+1 -1) Target.td | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/Target.td diff -u llvm/lib/Target/Target.td:1.92 llvm/lib/Target/Target.td:1.93 --- llvm/lib/Target/Target.td:1.92 Fri Jan 26 08:34:51 2007 +++ llvm/lib/Target/Target.td Tue Feb 20 14:52:03 2007 @@ -39,7 +39,7 @@ int SpillAlignment = 0; // Aliases - A list of registers that this register overlaps with. A read or - // modification of this register can potentially read or modifie the aliased + // modification of this register can potentially read or modify the aliased // registers. // list Aliases = []; From evan.cheng at apple.com Tue Feb 20 15:31:13 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 20 Feb 2007 15:31:13 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200702202131.l1KLVDMt022462@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.219 -> 1.220 --- Log message: This cast broke lots of tests. --- Diffs of the changes: (+1 -1) Constants.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.219 llvm/lib/VMCore/Constants.cpp:1.220 --- llvm/lib/VMCore/Constants.cpp:1.219 Tue Feb 20 01:17:17 2007 +++ llvm/lib/VMCore/Constants.cpp Tue Feb 20 15:30:56 2007 @@ -248,7 +248,7 @@ uint64_t IntVal = DoubleToBits(V); ConstantFP *&Slot = (*DoubleConstants)[std::make_pair(IntVal, Ty)]; if (Slot) return Slot; - return Slot = new ConstantFP(Ty, (float)V); + return Slot = new ConstantFP(Ty, V); } } From reid at x10sys.com Tue Feb 20 17:40:42 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 17:40:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702202340.l1KNeguK024803@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.24 -> 1.25 --- Log message: Make long addition and subtraction work. Speed things up by using internal functions more. --- Diffs of the changes: (+69 -72) APInt.cpp | 141 ++++++++++++++++++++++++++++++-------------------------------- 1 files changed, 69 insertions(+), 72 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.24 llvm/lib/Support/APInt.cpp:1.25 --- llvm/lib/Support/APInt.cpp:1.24 Tue Feb 20 14:42:10 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 17:40:25 2007 @@ -85,13 +85,13 @@ } /// @brief Copy constructor -APInt::APInt(const APInt& APIVal) - : BitWidth(APIVal.BitWidth), pVal(0) { +APInt::APInt(const APInt& that) + : BitWidth(that.BitWidth), pVal(0) { if (isSingleWord()) - VAL = APIVal.VAL; + VAL = that.VAL; else { pVal = getMemory(getNumWords()); - memcpy(pVal, APIVal.pVal, getNumWords() * APINT_WORD_SIZE); + memcpy(pVal, that.pVal, getNumWords() * APINT_WORD_SIZE); } } @@ -186,11 +186,11 @@ /// y[] and returns the carry. static uint64_t add(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) { - uint32_t carry = 0; + uint64_t carry = 0; for (uint32_t i = 0; i< len; ++i) { - carry += x[i]; - dest[i] = carry + y[i]; - carry = carry < x[i] ? 1 : (dest[i] < carry ? 1 : 0); + uint64_t save = x[i]; + dest[i] = x[i] + y[i] + carry; + carry = dest[i] < save ? 1 : 0; } return carry; } @@ -199,18 +199,10 @@ /// RHS and assigns the result to this APInt. APInt& APInt::operator+=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) VAL += RHS.isSingleWord() ? RHS.VAL : RHS.pVal[0]; + if (isSingleWord()) + VAL += RHS.VAL; else { - if (RHS.isSingleWord()) add_1(pVal, pVal, getNumWords(), RHS.VAL); - else { - if (getNumWords() <= RHS.getNumWords()) - add(pVal, pVal, RHS.pVal, getNumWords()); - else { - uint64_t carry = add(pVal, pVal, RHS.pVal, RHS.getNumWords()); - add_1(pVal + RHS.getNumWords(), pVal + RHS.getNumWords(), - getNumWords() - RHS.getNumWords(), carry); - } - } + add(pVal, pVal, RHS.pVal, getNumWords()); } clearUnusedBits(); return *this; @@ -220,19 +212,13 @@ /// integer array y[], and returns the borrow-out carry. static uint64_t sub(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) { - // Carry indicator. - uint64_t cy = 0; - + uint64_t borrow = 0; for (uint32_t i = 0; i < len; ++i) { - uint64_t Y = y[i], X = x[i]; - Y += cy; - - cy = Y < cy ? 1 : 0; - Y = X - Y; - cy += Y > X ? 1 : 0; - dest[i] = Y; + uint64_t save = x[i]; + dest[i] = x[i] - borrow - y[i]; + borrow = save < dest[i] ? 1 : 0; } - return cy; + return borrow; } /// @brief Subtraction assignment operator. Subtracts this APInt by the given @@ -240,20 +226,9 @@ APInt& APInt::operator-=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) - VAL -= RHS.isSingleWord() ? RHS.VAL : RHS.pVal[0]; - else { - if (RHS.isSingleWord()) - sub_1(pVal, getNumWords(), RHS.VAL); - else { - if (RHS.getNumWords() < getNumWords()) { - uint64_t carry = sub(pVal, pVal, RHS.pVal, RHS.getNumWords()); - sub_1(pVal + RHS.getNumWords(), getNumWords() - RHS.getNumWords(), - carry); - } - else - sub(pVal, pVal, RHS.pVal, getNumWords()); - } - } + VAL -= RHS.VAL; + else + sub(pVal, pVal, RHS.pVal, getNumWords()); clearUnusedBits(); return *this; } @@ -330,7 +305,7 @@ /// given APInt& RHS and assigns the result to this APInt. APInt& APInt::operator*=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) + if (isSingleWord()) VAL *= RHS.VAL; else { // one-based first non-zero bit position. @@ -338,8 +313,6 @@ uint32_t xlen = !first ? 0 : whichWord(first - 1) + 1; if (!xlen) return *this; - else if (RHS.isSingleWord()) - mul_1(pVal, pVal, xlen, RHS.VAL); else { first = RHS.getActiveBits(); uint32_t ylen = !first ? 0 : whichWord(first - 1) + 1; @@ -392,11 +365,13 @@ assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) { VAL ^= RHS.VAL; + this->clearUnusedBits(); return *this; } uint32_t numWords = getNumWords(); for (uint32_t i = 0; i < numWords; ++i) pVal[i] ^= RHS.pVal[i]; + this->clearUnusedBits(); return *this; } @@ -420,6 +395,7 @@ assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) return APInt(getBitWidth(), VAL | RHS.VAL); + APInt Result(*this); uint32_t numWords = getNumWords(); for (uint32_t i = 0; i < numWords; ++i) @@ -431,8 +407,11 @@ /// and the given APInt& RHS. APInt APInt::operator^(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) - return APInt(getBitWidth(), VAL ^ RHS.VAL); + if (isSingleWord()) { + APInt Result(BitWidth, VAL ^ RHS.VAL); + Result.clearUnusedBits(); + return Result; + } APInt Result(*this); uint32_t numWords = getNumWords(); for (uint32_t i = 0; i < numWords; ++i) @@ -456,6 +435,11 @@ /// RHS. APInt APInt::operator*(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); + if (isSingleWord()) { + APInt Result(BitWidth, VAL * RHS.VAL); + Result.clearUnusedBits(); + return Result; + } APInt Result(*this); Result *= RHS; Result.clearUnusedBits(); @@ -465,18 +449,29 @@ /// @brief Addition operator. Adds this APInt by the given APInt& RHS. APInt APInt::operator+(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - APInt API(*this); - API += RHS; - API.clearUnusedBits(); - return API; + if (isSingleWord()) { + APInt Result(BitWidth, VAL + RHS.VAL); + Result.clearUnusedBits(); + return Result; + } + APInt Result(BitWidth, 0); + add(Result.pVal, this->pVal, RHS.pVal, getNumWords()); + Result.clearUnusedBits(); + return Result; } /// @brief Subtraction operator. Subtracts this APInt by the given APInt& RHS APInt APInt::operator-(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - APInt API(*this); - API -= RHS; - return API; + if (isSingleWord()) { + APInt Result(BitWidth, VAL - RHS.VAL); + Result.clearUnusedBits(); + return Result; + } + APInt Result(BitWidth, 0); + sub(Result.pVal, this->pVal, RHS.pVal, getNumWords()); + Result.clearUnusedBits(); + return Result; } /// @brief Array-indexing support. @@ -488,17 +483,20 @@ /// @brief Equality operator. Compare this APInt with the given APInt& RHS /// for the validity of the equality relationship. bool APInt::operator==(const APInt& RHS) const { + if (isSingleWord()) + return VAL == RHS.VAL; + uint32_t n1 = getActiveBits(); uint32_t n2 = RHS.getActiveBits(); - if (n1 != n2) return false; - else if (isSingleWord()) - return VAL == (RHS.isSingleWord() ? RHS.VAL : RHS.pVal[0]); - else { - if (n1 <= APINT_BITS_PER_WORD) - return pVal[0] == (RHS.isSingleWord() ? RHS.VAL : RHS.pVal[0]); - for (int i = whichWord(n1 - 1); i >= 0; --i) - if (pVal[i] != RHS.pVal[i]) return false; - } + if (n1 != n2) + return false; + + if (n1 <= APINT_BITS_PER_WORD) + return pVal[0] == RHS.pVal[0]; + + for (int i = whichWord(n1 - 1); i >= 0; --i) + if (pVal[i] != RHS.pVal[i]) + return false; return true; } @@ -507,13 +505,12 @@ bool APInt::operator==(uint64_t Val) const { if (isSingleWord()) return VAL == Val; - else { - uint32_t n = getActiveBits(); - if (n <= APINT_BITS_PER_WORD) - return pVal[0] == Val; - else - return false; - } + + uint32_t n = getActiveBits(); + if (n <= APINT_BITS_PER_WORD) + return pVal[0] == Val; + else + return false; } /// @brief Unsigned less than comparison From reid at x10sys.com Tue Feb 20 18:30:05 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 18:30:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702210030.l1L0U518025690@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.25 -> 1.26 --- Log message: Fix countLeadingZeros to actually return the correct number. Fix toString to correctly return "0" for zero valued APInts over 128 bits. --- Diffs of the changes: (+13 -11) APInt.cpp | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.25 llvm/lib/Support/APInt.cpp:1.26 --- llvm/lib/Support/APInt.cpp:1.25 Tue Feb 20 17:40:25 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 18:29:48 2007 @@ -696,18 +696,20 @@ /// the number of zeros from the most significant bit to the first one bit. /// @returns numWord() * 64 if the value is zero. uint32_t APInt::countLeadingZeros() const { - if (isSingleWord()) - return CountLeadingZeros_64(VAL) - (APINT_BITS_PER_WORD - BitWidth); uint32_t Count = 0; - for (uint32_t i = getNumWords(); i > 0u; --i) { - uint32_t tmp = CountLeadingZeros_64(pVal[i-1]); - Count += tmp; - if (tmp != APINT_BITS_PER_WORD) - if (i == getNumWords()) - Count -= (APINT_BITS_PER_WORD - whichBit(BitWidth)); - break; + if (isSingleWord()) + Count = CountLeadingZeros_64(VAL); + else { + for (uint32_t i = getNumWords(); i > 0u; --i) { + if (pVal[i-1] == 0) + Count += APINT_BITS_PER_WORD; + else { + Count += CountLeadingZeros_64(pVal[i-1]); + break; + } + } } - return Count; + return Count - (APINT_BITS_PER_WORD - (BitWidth % APINT_BITS_PER_WORD)); } /// countTrailingZeros - This function is a APInt version corresponding to @@ -1513,7 +1515,7 @@ result = "-"; insert_at = 1; } - if (tmp == 0) + if (tmp == APInt(tmp.getBitWidth(), 0)) result = "0"; else while (tmp.ne(zero)) { APInt APdigit(1,0); From bwendlin at apple.com Tue Feb 20 18:46:00 2007 From: bwendlin at apple.com (bwendlin at apple.com) Date: Tue, 20 Feb 2007 16:46:00 -0800 (PST) Subject: [llvm-commits] [124123] Converts "getOrInsertFunction" calls to "Intrinsic::getDeclaration " calls for Message-ID: <20070221004600.6FF12570B823@src> Revision: 124123 Author: bwendlin Date: 2007-02-20 16:45:58 -0800 (Tue, 20 Feb 2007) Log Message: ----------- Converts "getOrInsertFunction" calls to "Intrinsic::getDeclaration" calls for PR1189. It also gets rid of the function caching mechanism, so that it's multi-module safe. Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-convert.cpp apple-local/branches/llvm/gcc/llvm-internal.h Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-20 21:42:10 UTC (rev 124122) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-21 00:45:58 UTC (rev 124123) @@ -33,7 +33,6 @@ #include "llvm/DerivedTypes.h" #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" -#include "llvm/Intrinsics.h" #include "llvm/Module.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" @@ -1118,63 +1117,55 @@ void TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { const Type *SBP = PointerType::get(Type::Int8Ty); - static Constant *MemCpy = 0; const Type *IntPtr = TD.getIntPtrType(); - if (!MemCpy) { - const char *Name = IntPtr == Type::Int32Ty ? - "llvm.memcpy.i32" : "llvm.memcpy.i64"; - MemCpy = TheModule->getOrInsertFunction(Name, Type::VoidTy, SBP, - SBP, IntPtr, Type::Int32Ty, - NULL); - } Value *Ops[4] = { CastToType(Instruction::BitCast, DestPtr, SBP), CastToType(Instruction::BitCast, SrcPtr, SBP), CastToSIntType(Size, IntPtr), ConstantInt::get(Type::Int32Ty, Align) }; - new CallInst(MemCpy, Ops, 4, "", CurBB); + + new CallInst(Intrinsic::getDeclaration(TheModule, + (IntPtr == Type::Int32Ty) ? + Intrinsic::memcpy_i32 : + Intrinsic::memcpy_i64), + Ops, 4, "", CurBB); } void TreeToLLVM::EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { const Type *SBP = PointerType::get(Type::Int8Ty); - static Constant *MemMove = 0; const Type *IntPtr = TD.getIntPtrType(); - if (!MemMove) { - const char *Name = IntPtr == Type::Int32Ty ? - "llvm.memmove.i32" : "llvm.memmove.i64"; - MemMove = TheModule->getOrInsertFunction(Name, Type::VoidTy, SBP, SBP, - IntPtr, Type::Int32Ty, NULL); - } Value *Ops[4] = { CastToType(Instruction::BitCast, DestPtr, SBP), CastToType(Instruction::BitCast, SrcPtr, SBP), CastToSIntType(Size, IntPtr), ConstantInt::get(Type::Int32Ty, Align) }; - new CallInst(MemMove, Ops, 4, "", CurBB); + + new CallInst(Intrinsic::getDeclaration(TheModule, + (IntPtr == Type::Int32Ty) ? + Intrinsic::memmove_i32 : + Intrinsic::memmove_i64), + Ops, 4, "", CurBB); } void TreeToLLVM::EmitMemSet(Value *DestPtr, Value *SrcVal, Value *Size, unsigned Align) { const Type *SBP = PointerType::get(Type::Int8Ty); - static Constant *MemSet = 0; const Type *IntPtr = TD.getIntPtrType(); - if (!MemSet) { - const char *Name = IntPtr == Type::Int32Ty ? - "llvm.memset.i32" : "llvm.memset.i64"; - MemSet = TheModule->getOrInsertFunction(Name, Type::VoidTy, SBP, - Type::Int8Ty, IntPtr, - Type::Int32Ty, NULL); - } Value *Ops[4] = { CastToType(Instruction::BitCast, DestPtr, SBP), CastToSIntType(SrcVal, Type::Int8Ty), CastToSIntType(Size, IntPtr), ConstantInt::get(Type::Int32Ty, Align) }; - new CallInst(MemSet, Ops, 4, "", CurBB); + + new CallInst(Intrinsic::getDeclaration(TheModule, + (IntPtr == Type::Int32Ty) ? + Intrinsic::memset_i32 : + Intrinsic::memset_i64), + Ops, 4, "", CurBB); } @@ -2561,8 +2552,7 @@ return new SelectInst(Cmp, Op, OpN, "abs", CurBB); } else { // Turn FP abs into fabs/fabsf. - static Function *fabsf_cache = 0, *fabs_cache = 0; - return EmitBuiltinUnaryFPOp(Op, "fabsf", fabsf_cache, "fabs", fabs_cache); + return EmitBuiltinUnaryFPOp(Op, "fabsf", "fabs"); } } @@ -3504,17 +3494,8 @@ } // Finally, map the intrinsic ID back to a name. - static const char * const IntrinsicNames[] = { -#define GET_INTRINSIC_NAME_TABLE -#include "llvm/Intrinsics.gen" -#undef GET_INTRINSIC_NAME_TABLE - 0 - }; - const char *IntrinsicName = IntrinsicNames[IntrinsicID-1]; - const FunctionType *FTy = - cast(ConvertType(TREE_TYPE(fndecl))); TargetBuiltinCache[FnCode] = - TheModule->getOrInsertFunction(IntrinsicName, cast(FTy)); + Intrinsic::getDeclaration(TheModule, IntrinsicID); } Result = EmitCallOf(TargetBuiltinCache[FnCode], exp, DestLoc); @@ -3543,12 +3524,13 @@ case BUILT_IN_STACK_RESTORE: return EmitBuiltinStackRestore(exp); #define HANDLE_UNARY_INT(I8, I16, I32, I64, V) \ - { static Function *Fn8, *Fn16, *Fn32, *Fn64 = 0; \ EmitBuiltinUnaryIntOp(V, Result, \ - I8, Fn8, I16, Fn16, I32, Fn32, I64, Fn64); } + Intrinsic::I8, Intrinsic::I16, \ + Intrinsic::I32, Intrinsic::I64) + #define HANDLE_UNARY_FP(F32, F64, V) \ - { static Function *Fn32, *Fn64 = 0; \ - Result = EmitBuiltinUnaryFPOp(V, F32, Fn32, F64, Fn64); } + Result = EmitBuiltinUnaryFPOp(V, Intrinsic::F32, Intrinsic::F64) + // Unary bit counting intrinsics. // NOTE: do not merge these case statements. That will cause the memoized // Function* to be incorrectly shared across the different typed functions. @@ -3556,24 +3538,24 @@ case BUILT_IN_CLZL: case BUILT_IN_CLZLL: { Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - HANDLE_UNARY_INT("llvm.ctlz.i8", "llvm.ctlz.i16", - "llvm.ctlz.i32", "llvm.ctlz.i64", Amt); + HANDLE_UNARY_INT(ctlz_i8, ctlz_i16, + ctlz_i32, ctlz_i64, Amt); return true; } case BUILT_IN_CTZ: // These GCC builtins always return int. case BUILT_IN_CTZL: case BUILT_IN_CTZLL: { Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - HANDLE_UNARY_INT("llvm.cttz.i8", "llvm.cttz.i16", - "llvm.cttz.i32", "llvm.cttz.i64", Amt); + HANDLE_UNARY_INT(cttz_i8, cttz_i16, + cttz_i32, cttz_i64, Amt); return true; } case BUILT_IN_POPCOUNT: // These GCC builtins always return int. case BUILT_IN_POPCOUNTL: case BUILT_IN_POPCOUNTLL: { Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - HANDLE_UNARY_INT("llvm.ctpop.i8", "llvm.ctpop.i16", - "llvm.ctpop.i32", "llvm.ctpop.i64", Amt); + HANDLE_UNARY_INT(ctpop_i8, ctpop_i16, + ctpop_i32, ctpop_i64, Amt); return true; } case BUILT_IN_SQRT: @@ -3582,7 +3564,7 @@ // If errno math has been disabled, expand these to llvm.sqrt calls. if (!flag_errno_math) { Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - HANDLE_UNARY_FP("llvm.sqrt.f32", "llvm.sqrt.f64", Amt); + HANDLE_UNARY_FP(sqrt_f32, sqrt_f64, Amt); Result = CastToFPType(Result, ConvertType(TREE_TYPE(exp))); return true; } @@ -3598,8 +3580,8 @@ // The argument and return type of cttz should match the argument type of // the ffs, but should ignore the return type of ffs. Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - HANDLE_UNARY_INT("llvm.cttz.i8", "llvm.cttz.i16", - "llvm.cttz.i32", "llvm.cttz.i64", Amt); + HANDLE_UNARY_INT(cttz_i8, cttz_i16, + cttz_i32, cttz_i64, Amt); Result = BinaryOperator::createAdd(Result, ConstantInt::get(Type::Int32Ty, 1), "tmp", CurBB); @@ -3657,55 +3639,61 @@ } bool TreeToLLVM::EmitBuiltinUnaryIntOp(Value *InVal, Value *&Result, - const char *I8Name, Function *&I8Cache, - const char *I16Name, Function *&I16Cache, - const char *I32Name, Function *&I32Cache, - const char *I64Name,Function *&I64Cache){ - const char *Name; - Function **FCache; + Intrinsic::ID I8ID, Intrinsic::ID I16ID, + Intrinsic::ID I32ID, + Intrinsic::ID I64ID) { + Intrinsic::ID Id = Intrinsic::not_intrinsic; const IntegerType *ITy = cast(InVal->getType()); switch (ITy->getBitWidth()) { default: assert(0 && "Unknown Integer type!"); - case 8 : Name = I8Name; FCache = &I8Cache ; break; - case 16: Name = I16Name; FCache = &I16Cache; break; - case 32: Name = I32Name; FCache = &I32Cache; break; - case 64: Name = I64Name; FCache = &I64Cache; break; + case 8 : Id = I8ID; break; + case 16: Id = I16ID; break; + case 32: Id = I32ID; break; + case 64: Id = I64ID; break; } - if (*FCache == 0) - *FCache = cast(TheModule->getOrInsertFunction(Name, - InVal->getType(), - InVal->getType(), - NULL)); - Result = new CallInst(*FCache, InVal, "tmp", CurBB); + Result = new CallInst(Intrinsic::getDeclaration(TheModule, Id), + InVal, "tmp", CurBB); // The LLVM intrinsics for these return the same type as their operands. The // GCC version of these functions always returns int. Cast to int for GCC. Result = CastToSIntType(Result, Type::Int32Ty); - return true; + return true; } -Value *TreeToLLVM::EmitBuiltinUnaryFPOp(Value *Amt, - const char *F32Name, Function *&F32Cache, - const char *F64Name, Function *&F64Cache){ - const char *Name; - Function **FCache; +Value *TreeToLLVM::EmitBuiltinUnaryFPOp(Value *Amt, const char *F32Name, + const char *F64Name) { + const char *Name = 0; switch (Amt->getType()->getTypeID()) { default: assert(0 && "Unknown FP type!"); - case Type::FloatTyID: Name = F32Name; FCache = &F32Cache; break; - case Type::DoubleTyID: Name = F64Name; FCache = &F64Cache; break; + case Type::FloatTyID: Name = F32Name; break; + case Type::DoubleTyID: Name = F64Name; break; } - if (*FCache == 0) - *FCache = cast(TheModule->getOrInsertFunction(Name,Amt->getType(), - Amt->getType(), - NULL)); - return new CallInst(*FCache, Amt, "tmp", CurBB); + return new CallInst(cast( + TheModule->getOrInsertFunction(Name,Amt->getType(), + Amt->getType(), + NULL)), Amt, "tmp", CurBB); } +Value *TreeToLLVM::EmitBuiltinUnaryFPOp(Value *Amt, + Intrinsic::ID F32ID, + Intrinsic::ID F64ID) { + Intrinsic::ID Id = Intrinsic::not_intrinsic; + + switch (Amt->getType()->getTypeID()) { + default: assert(0 && "Unknown FP type!"); + case Type::FloatTyID: Id = F32ID; break; + case Type::DoubleTyID: Id = F64ID; break; + } + + return new CallInst(Intrinsic::getDeclaration(TheModule, Id), + Amt, "tmp", CurBB); +} + Value *TreeToLLVM::EmitBuiltinPOWI(tree exp) { tree ArgList = TREE_OPERAND (exp, 1); if (!validate_arglist(ArgList, REAL_TYPE, INTEGER_TYPE, VOID_TYPE)) @@ -3715,21 +3703,16 @@ Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0); Pow = CastToSIntType(Pow, Type::Int32Ty); - static Constant *Fn32 = 0, *Fn64 = 0; - const char *Name; - Constant **FCache; + Intrinsic::ID Id = Intrinsic::not_intrinsic; + switch (Val->getType()->getTypeID()) { default: assert(0 && "Unknown FP type!"); - case Type::FloatTyID: Name = "llvm.powi.f32"; FCache = &Fn32; break; - case Type::DoubleTyID: Name = "llvm.powi.f64"; FCache = &Fn64; break; + case Type::FloatTyID: Id = Intrinsic::powi_f32; break; + case Type::DoubleTyID: Id = Intrinsic::powi_f64; break; } - // First time we used this intrinsic? - if (*FCache == 0) - *FCache = TheModule->getOrInsertFunction(Name, Val->getType(), - Val->getType(), Type::Int32Ty, - NULL); - return new CallInst(*FCache, Val, Pow, "tmp", CurBB); + return new CallInst(Intrinsic::getDeclaration(TheModule, Id), + Val, Pow, "tmp", CurBB); } @@ -3860,15 +3843,9 @@ Ptr = CastToType(Instruction::BitCast, Ptr, PointerType::get(Type::Int8Ty)); - static Constant *llvm_prefetch_fn = 0; - if (!llvm_prefetch_fn) - llvm_prefetch_fn = - TheModule->getOrInsertFunction("llvm.prefetch", Type::VoidTy, - Ptr->getType(), Type::Int32Ty, - Type::Int32Ty, NULL); - Value *Ops[3] = { Ptr, ReadWrite, Locality }; - new CallInst(llvm_prefetch_fn, Ops, 3, "", CurBB); + new CallInst(Intrinsic::getDeclaration(TheModule, Intrinsic::prefetch), + Ops, 3, "", CurBB); return true; } @@ -3888,25 +3865,11 @@ return false; } - Value *Fn; - static Constant *llvm_retaddr = 0, *llvm_frameaddr; - if (!isFrame) { - if (!llvm_retaddr) - llvm_retaddr = - TheModule->getOrInsertFunction("llvm.returnaddress", - PointerType::get(Type::Int8Ty), - Type::Int32Ty, NULL); - Fn = llvm_retaddr; - } else { - if (!llvm_frameaddr) - llvm_frameaddr = - TheModule->getOrInsertFunction("llvm.frameaddress", - PointerType::get(Type::Int8Ty), - Type::Int32Ty, NULL); - Fn = llvm_frameaddr; - } - - Result = new CallInst(Fn, Level, "tmp", CurBB); + Result = new CallInst(Intrinsic::getDeclaration(TheModule, + !isFrame ? + Intrinsic::returnaddress : + Intrinsic::frameaddress), + Level, "tmp", CurBB); Result = CastToType(Instruction::BitCast, Result, TREE_TYPE(exp)); return true; } @@ -3916,11 +3879,9 @@ if (!validate_arglist(arglist, VOID_TYPE)) return false; - static Constant *Fn = 0; - if (!Fn) - Fn = TheModule->getOrInsertFunction("llvm.stacksave", - PointerType::get(Type::Int8Ty), NULL); - Result = new CallInst(Fn, "tmp", CurBB); + Result = new CallInst(Intrinsic::getDeclaration(TheModule, + Intrinsic::stacksave), + "tmp", CurBB); return true; } @@ -3929,14 +3890,11 @@ if (!validate_arglist(arglist, POINTER_TYPE, VOID_TYPE)) return false; - static Constant *Fn = 0; - if (!Fn) - Fn = TheModule->getOrInsertFunction("llvm.stackrestore", Type::VoidTy, - PointerType::get(Type::Int8Ty), NULL); Value *Ptr = Emit(TREE_VALUE(arglist), 0); Ptr = CastToType(Instruction::BitCast, Ptr, PointerType::get(Type::Int8Ty)); - new CallInst(Fn, Ptr, "", CurBB); + new CallInst(Intrinsic::getDeclaration(TheModule, Intrinsic::stackrestore), + Ptr, "", CurBB); return true; } @@ -3965,13 +3923,6 @@ tree arglist = TREE_OPERAND(exp, 1); tree fntype = TREE_TYPE(current_function_decl); - static Constant *llvm_va_start_fn = 0; - static const Type *VPTy = PointerType::get(Type::Int8Ty); - - if (!llvm_va_start_fn) - llvm_va_start_fn = TheModule->getOrInsertFunction("llvm.va_start", - Type::VoidTy, VPTy, NULL); - if (TYPE_ARG_TYPES(fntype) == 0 || (TREE_VALUE(tree_last(TYPE_ARG_TYPES(fntype))) == void_type_node)) { error("`va_start' used in function with fixed args"); @@ -3989,36 +3940,26 @@ Value *ArgVal = Emit(TREE_VALUE(arglist), 0); + Constant *llvm_va_start_fn = Intrinsic::getDeclaration(TheModule, + Intrinsic::vastart); const Type *FTy = cast(llvm_va_start_fn->getType())->getElementType(); - ArgVal = CastToType(Instruction::BitCast, ArgVal, VPTy); + ArgVal = CastToType(Instruction::BitCast, ArgVal, + PointerType::get(Type::Int8Ty)); new CallInst(llvm_va_start_fn, ArgVal, "", CurBB); return true; } bool TreeToLLVM::EmitBuiltinVAEnd(tree exp) { - static Constant *llvm_va_end_fn = 0; - static const Type *VPTy = PointerType::get(Type::Int8Ty); - - if (!llvm_va_end_fn) - llvm_va_end_fn = TheModule->getOrInsertFunction("llvm.va_end", Type::VoidTy, - VPTy, NULL); - Value *Arg = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - Arg = CastToType(Instruction::BitCast, Arg, VPTy); - new CallInst(llvm_va_end_fn, Arg, "", CurBB); + Arg = CastToType(Instruction::BitCast, Arg, + PointerType::get(Type::Int8Ty)); + new CallInst(Intrinsic::getDeclaration(TheModule, Intrinsic::vaend), + Arg, "", CurBB); return true; } bool TreeToLLVM::EmitBuiltinVACopy(tree exp) { - static Constant *llvm_va_copy_fn = 0; - static const Type *VPTy = PointerType::get(Type::Int8Ty); - - if (!llvm_va_copy_fn) - llvm_va_copy_fn = - TheModule->getOrInsertFunction("llvm.va_copy", Type::VoidTy, - VPTy, VPTy, NULL); - tree Arg1T = TREE_VALUE(TREE_OPERAND(exp, 1)); tree Arg2T = TREE_VALUE(TREE_CHAIN(TREE_OPERAND(exp, 1))); @@ -4038,10 +3979,13 @@ Emit(Arg2T, Arg2); } + static const Type *VPTy = PointerType::get(Type::Int8Ty); + Arg1 = CastToType(Instruction::BitCast, Arg1, VPTy); Arg2 = CastToType(Instruction::BitCast, Arg2, VPTy); - new CallInst(llvm_va_copy_fn, Arg1, Arg2, "", CurBB); + new CallInst(Intrinsic::getDeclaration(TheModule, Intrinsic::vacopy), + Arg1, Arg2, "", CurBB); return true; } Modified: apple-local/branches/llvm/gcc/llvm-internal.h =================================================================== --- apple-local/branches/llvm/gcc/llvm-internal.h 2007-02-20 21:42:10 UTC (rev 124122) +++ apple-local/branches/llvm/gcc/llvm-internal.h 2007-02-21 00:45:58 UTC (rev 124123) @@ -32,6 +32,7 @@ #include #include #include +#include "llvm/Intrinsics.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Streams.h" @@ -426,13 +427,12 @@ bool EmitFrontendExpandedBuiltinCall(tree_node *exp, tree_node *fndecl, Value *DestLoc, Value *&Result); bool EmitBuiltinUnaryIntOp(Value *InVal, Value *&Result, - const char *I8Name , Function *&I8Cache, - const char *I16Name, Function *&I16Cache, - const char *I32Name, Function *&I32Cache, - const char *I64Name, Function *&I64Cache); - Value *EmitBuiltinUnaryFPOp(Value *InVal, - const char *F32Name, Function *&F32Cache, - const char *F64Name, Function *&F64Cache); + Intrinsic::ID I8ID, Intrinsic::ID I16ID, + Intrinsic::ID I32ID, Intrinsic::ID I64ID); + Value *EmitBuiltinUnaryFPOp(Value *Amt, Intrinsic::ID F32ID, + Intrinsic::ID F64ID); + Value *EmitBuiltinUnaryFPOp(Value *InVal, const char *F32Name, + const char *F64Name); Value *EmitBuiltinPOWI(tree_node *exp); bool EmitBuiltinConstantP(tree_node *exp, Value *&Result); From evan.cheng at apple.com Tue Feb 20 20:22:19 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 20 Feb 2007 20:22:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp Message-ID: <200702210222.l1L2MJg8027741@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.96 -> 1.97 --- Log message: Use BitVector instead. No functionality change. --- Diffs of the changes: (+5 -8) VirtRegMap.cpp | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.96 llvm/lib/CodeGen/VirtRegMap.cpp:1.97 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.96 Mon Feb 19 19:29:10 2007 +++ llvm/lib/CodeGen/VirtRegMap.cpp Tue Feb 20 20:22:03 2007 @@ -27,6 +27,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Compiler.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallSet.h" @@ -423,14 +424,10 @@ class VISIBILITY_HIDDEN ReuseInfo { MachineInstr &MI; std::vector Reuses; - bool *PhysRegsClobbered; + BitVector PhysRegsClobbered; public: ReuseInfo(MachineInstr &mi, const MRegisterInfo *mri) : MI(mi) { - PhysRegsClobbered = new bool[mri->getNumRegs()]; - std::fill(PhysRegsClobbered, PhysRegsClobbered+mri->getNumRegs(), false); - } - ~ReuseInfo() { - delete[] PhysRegsClobbered; + PhysRegsClobbered.resize(mri->getNumRegs()); } bool hasReuses() const { @@ -452,11 +449,11 @@ } void markClobbered(unsigned PhysReg) { - PhysRegsClobbered[PhysReg] = true; + PhysRegsClobbered.set(PhysReg); } bool isClobbered(unsigned PhysReg) const { - return PhysRegsClobbered[PhysReg]; + return PhysRegsClobbered.test(PhysReg); } /// GetRegForReload - We are about to emit a reload into PhysReg. If there From evan.cheng at apple.com Tue Feb 20 20:27:57 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 20 Feb 2007 20:27:57 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200702210227.l1L2RvMG027832@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.209 -> 1.210 --- Log message: Out of bound reference. --- Diffs of the changes: (+2 -2) LiveIntervalAnalysis.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.209 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.210 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.209 Mon Feb 19 15:49:53 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Feb 20 20:27:39 2007 @@ -1451,10 +1451,10 @@ /// reg between indexes Start and End. bool LiveIntervals::hasRegisterUse(unsigned Reg, unsigned Start, unsigned End) { - for (unsigned Index = Start+InstrSlots::NUM; Index != End; + for (unsigned Index = Start+InstrSlots::NUM; Index < End; Index += InstrSlots::NUM) { // Skip deleted instructions - while (Index != End && !getInstructionFromIndex(Index)) + while (Index < End && !getInstructionFromIndex(Index)) Index += InstrSlots::NUM; if (Index >= End) break; From dpatel at apple.com Tue Feb 20 20:36:48 2007 From: dpatel at apple.com (Devang Patel) Date: Tue, 20 Feb 2007 20:36:48 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ET-Forest.h Message-ID: <200702210236.l1L2amv9027993@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ET-Forest.h updated: 1.7 -> 1.8 --- Log message: Fix memory leak (PR 775: http://llvm.org/PR775 ). --- Diffs of the changes: (+2 -0) ET-Forest.h | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/include/llvm/Analysis/ET-Forest.h diff -u llvm/include/llvm/Analysis/ET-Forest.h:1.7 llvm/include/llvm/Analysis/ET-Forest.h:1.8 --- llvm/include/llvm/Analysis/ET-Forest.h:1.7 Thu Sep 21 20:05:33 2006 +++ llvm/include/llvm/Analysis/ET-Forest.h Tue Feb 20 20:36:31 2007 @@ -141,6 +141,8 @@ // removeFromForest() ~ETNode() { delete RightmostOcc; + if (ParentOcc) + delete ParentOcc; } void removeFromForest() { From reid at x10sys.com Tue Feb 20 21:56:01 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 21:56:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702210356.l1L3u1VJ029173@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.26 -> 1.27 --- Log message: 1. Add a dump() method for faster debugging. 2. Change 0 initialization of union to larger component so all is zeroed. 3. Fix the borrow logic in subtraction so it works for > 128 bits. 4. Rewrite fromString to use a simpler but correct algorithm and also to not set the bit width contrary to the user's request. 5. Optimize toString a bit by making it only do one Knuth divide per iteration instead of two. With these changes, all arithmetic passes (verified by pari/GP) up to 1024 bits except for certain division cases. --- Diffs of the changes: (+80 -81) APInt.cpp | 161 ++++++++++++++++++++++++++++++-------------------------------- 1 files changed, 80 insertions(+), 81 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.26 llvm/lib/Support/APInt.cpp:1.27 --- llvm/lib/Support/APInt.cpp:1.26 Tue Feb 20 18:29:48 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 21:55:44 2007 @@ -17,6 +17,11 @@ #include "llvm/Support/MathExtras.h" #include #include +#ifndef NDEBUG +#include +#include +#endif + using namespace llvm; // A utility function for allocating memory, checking for allocation failures, @@ -36,7 +41,7 @@ } APInt::APInt(uint32_t numBits, uint64_t val) - : BitWidth(numBits), pVal(0) { + : BitWidth(numBits), VAL(0) { assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); if (isSingleWord()) @@ -48,7 +53,7 @@ } APInt::APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[]) - : BitWidth(numBits), pVal(0) { + : BitWidth(numBits), VAL(0) { assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); assert(bigVal && "Null pointer detected!"); @@ -72,21 +77,21 @@ /// integer value. APInt::APInt(uint32_t numbits, const char StrStart[], uint32_t slen, uint8_t radix) - : BitWidth(numbits), pVal(0) { + : BitWidth(numbits), VAL(0) { fromString(numbits, StrStart, slen, radix); } /// @brief Create a new APInt by translating the string represented /// integer value. APInt::APInt(uint32_t numbits, const std::string& Val, uint8_t radix) - : BitWidth(numbits), pVal(0) { + : BitWidth(numbits), VAL(0) { assert(!Val.empty() && "String empty?"); fromString(numbits, Val.c_str(), Val.size(), radix); } /// @brief Copy constructor APInt::APInt(const APInt& that) - : BitWidth(that.BitWidth), pVal(0) { + : BitWidth(that.BitWidth), VAL(0) { if (isSingleWord()) VAL = that.VAL; else { @@ -184,11 +189,10 @@ /// add - This function adds the integer array x[] by integer array /// y[] and returns the carry. -static uint64_t add(uint64_t dest[], uint64_t x[], - uint64_t y[], uint32_t len) { +static uint64_t add(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) { uint64_t carry = 0; for (uint32_t i = 0; i< len; ++i) { - uint64_t save = x[i]; + uint64_t save = std::max(x[i],y[i]); dest[i] = x[i] + y[i] + carry; carry = dest[i] < save ? 1 : 0; } @@ -210,13 +214,13 @@ /// sub - This function subtracts the integer array x[] by /// integer array y[], and returns the borrow-out carry. -static uint64_t sub(uint64_t dest[], uint64_t x[], - uint64_t y[], uint32_t len) { - uint64_t borrow = 0; +static uint64_t sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, + uint32_t len) { + bool borrow = false; for (uint32_t i = 0; i < len; ++i) { - uint64_t save = x[i]; - dest[i] = x[i] - borrow - y[i]; - borrow = save < dest[i] ? 1 : 0; + uint64_t x_tmp = borrow ? x[i] - 1 : x[i]; + borrow = y[i] > x_tmp || (borrow && x[i] == 0); + dest[i] = x_tmp - y[i]; } return borrow; } @@ -1385,72 +1389,55 @@ } /// @brief Converts a char array into an integer. -void APInt::fromString(uint32_t numbits, const char *StrStart, uint32_t slen, +void APInt::fromString(uint32_t numbits, const char *str, uint32_t slen, uint8_t radix) { + // Check our assumptions here assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); - assert(StrStart && "String is null?"); - uint32_t size = 0; - // If the radix is a power of 2, read the input - // from most significant to least significant. - if ((radix & (radix - 1)) == 0) { - uint32_t nextBitPos = 0; - uint32_t bits_per_digit = radix / 8 + 2; - uint64_t resDigit = 0; - BitWidth = slen * bits_per_digit; - if (getNumWords() > 1) - pVal = getMemory(getNumWords()); - for (int i = slen - 1; i >= 0; --i) { - uint64_t digit = StrStart[i] - '0'; - resDigit |= digit << nextBitPos; - nextBitPos += bits_per_digit; - if (nextBitPos >= APINT_BITS_PER_WORD) { - if (isSingleWord()) { - VAL = resDigit; - break; - } - pVal[size++] = resDigit; - nextBitPos -= APINT_BITS_PER_WORD; - resDigit = digit >> (bits_per_digit - nextBitPos); - } - } - if (!isSingleWord() && size <= getNumWords()) - pVal[size] = resDigit; - } else { // General case. The radix is not a power of 2. - // For 10-radix, the max value of 64-bit integer is 18446744073709551615, - // and its digits number is 20. - const uint32_t chars_per_word = 20; - if (slen < chars_per_word || - (slen == chars_per_word && // In case the value <= 2^64 - 1 - strcmp(StrStart, "18446744073709551615") <= 0)) { - BitWidth = APINT_BITS_PER_WORD; - VAL = strtoull(StrStart, 0, 10); - } else { // In case the value > 2^64 - 1 - BitWidth = (slen / chars_per_word + 1) * APINT_BITS_PER_WORD; - pVal = getClearedMemory(getNumWords()); - uint32_t str_pos = 0; - while (str_pos < slen) { - uint32_t chunk = slen - str_pos; - if (chunk > chars_per_word - 1) - chunk = chars_per_word - 1; - uint64_t resDigit = StrStart[str_pos++] - '0'; - uint64_t big_base = radix; - while (--chunk > 0) { - resDigit = resDigit * radix + StrStart[str_pos++] - '0'; - big_base *= radix; - } - - uint64_t carry; - if (!size) - carry = resDigit; - else { - carry = mul_1(pVal, pVal, size, big_base); - carry += add_1(pVal, pVal, size, resDigit); - } - - if (carry) pVal[size++] = carry; - } - } + assert(str && "String is null?"); + assert(slen <= numbits || radix != 2 && "Insufficient bit width"); + assert(slen*3 <= numbits || radix != 8 && "Insufficient bit width"); + assert(slen*4 <= numbits || radix != 16 && "Insufficient bit width"); + assert((slen*64)/20 <= numbits || radix != 10 && "Insufficient bit width"); + + // Allocate memory + if (!isSingleWord()) + pVal = getClearedMemory(getNumWords()); + + // Figure out if we can shift instead of multiply + uint32_t shift = (radix == 16 ? 4 : radix == 8 ? 3 : radix == 2 ? 1 : 0); + + // Set up an APInt for the digit to add outside the loop so we don't + // constantly construct/destruct it. + APInt apdigit(getBitWidth(), 0); + APInt apradix(getBitWidth(), radix); + + // Enter digit traversal loop + for (unsigned i = 0; i < slen; i++) { + // Get a digit + uint32_t digit = 0; + char cdigit = str[i]; + if (isdigit(cdigit)) + digit = cdigit - '0'; + else if (isxdigit(cdigit)) + if (cdigit >= 'a') + digit = cdigit - 'a' + 10; + else if (cdigit >= 'A') + digit = cdigit - 'A' + 10; + else + assert(0 && "huh?"); + else + assert(0 && "Invalid character in digit string"); + + // Shift or multiple the value by the radix + if (shift) + this->shl(shift); + else + *this *= apradix; + + // Add in the digit we just interpreted + apdigit.pVal[0] = digit; + *this += apdigit; } } @@ -1519,15 +1506,27 @@ result = "0"; else while (tmp.ne(zero)) { APInt APdigit(1,0); - divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), 0, &APdigit); + APInt tmp2(tmp.getBitWidth(), 0); + divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), &tmp2, + &APdigit); uint32_t digit = APdigit.getValue(); - assert(digit < radix && "urem failed"); + assert(digit < radix && "divide failed"); result.insert(insert_at,digits[digit]); - APInt tmp2(tmp.getBitWidth(), 0); - divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), &tmp2, 0); tmp = tmp2; } return result; } +#ifndef NDEBUG +void APInt::dump() const +{ + std::cerr << "APInt(" << BitWidth << ")=" << std::setbase(16); + if (isSingleWord()) + std::cerr << VAL; + else for (unsigned i = getNumWords(); i > 0; i--) { + std::cerr << pVal[i-1] << " "; + } + std::cerr << " (" << this->toString(10, false) << ")\n" << std::setbase(10); +} +#endif From reid at x10sys.com Tue Feb 20 21:56:30 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 21:56:30 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h Message-ID: <200702210356.l1L3uUMo029192@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.15 -> 1.16 --- Log message: Add a dump() method for debugging. --- Diffs of the changes: (+7 -2) APInt.h | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.15 llvm/include/llvm/ADT/APInt.h:1.16 --- llvm/include/llvm/ADT/APInt.h:1.15 Tue Feb 20 02:43:42 2007 +++ llvm/include/llvm/ADT/APInt.h Tue Feb 20 21:56:12 2007 @@ -128,12 +128,17 @@ void fromString(uint32_t numBits, const char *StrStart, uint32_t slen, uint8_t radix); +#ifndef NDEBUG + /// @brief debug method + void dump() const; +#endif + +public: /// @brief An internal division function for dividing APInts. static void divide(const APInt LHS, uint32_t lhsWords, const APInt &RHS, uint32_t rhsWords, APInt *Quotient, APInt *Remainder); -public: /// @brief Create a new APInt of numBits bit-width, and initialized as val. APInt(uint32_t numBits, uint64_t val); @@ -412,7 +417,7 @@ /// computations to see how "wide" the value is. /// @brief Compute the number of active bits in the value inline uint32_t getActiveBits() const { - return getNumWords() * APINT_BITS_PER_WORD - countLeadingZeros(); + return BitWidth - countLeadingZeros(); } /// @returns a uint64_t value from this APInt. If this APInt contains a single From reid at x10sys.com Tue Feb 20 23:45:13 2007 From: reid at x10sys.com (Reid Spencer) Date: Tue, 20 Feb 2007 23:45:13 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702210545.l1L5jDNx030979@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.27 -> 1.28 --- Log message: Fix the carry in addition. --- Diffs of the changes: (+2 -2) APInt.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.27 llvm/lib/Support/APInt.cpp:1.28 --- llvm/lib/Support/APInt.cpp:1.27 Tue Feb 20 21:55:44 2007 +++ llvm/lib/Support/APInt.cpp Tue Feb 20 23:44:56 2007 @@ -192,9 +192,9 @@ static uint64_t add(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) { uint64_t carry = 0; for (uint32_t i = 0; i< len; ++i) { - uint64_t save = std::max(x[i],y[i]); dest[i] = x[i] + y[i] + carry; - carry = dest[i] < save ? 1 : 0; + uint64_t limit = std::min(x[i],y[i]); + carry = dest[i] < limit || (carry && dest[i] == limit); } return carry; } From sabre at nondot.org Wed Feb 21 00:23:37 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 21 Feb 2007 00:23:37 -0600 Subject: [llvm-commits] CVS: llvm/Makefile Message-ID: <200702210623.l1L6NbY8031700@zion.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.69 -> 1.70 --- Log message: revert r1.68. This breaks 'make install' without doing 'make' first, but fixes PR1208: http://llvm.org/PR1208 . --- Diffs of the changes: (+7 -0) Makefile | 7 +++++++ 1 files changed, 7 insertions(+) Index: llvm/Makefile diff -u llvm/Makefile:1.69 llvm/Makefile:1.70 --- llvm/Makefile:1.69 Mon Feb 5 17:18:58 2007 +++ llvm/Makefile Wed Feb 21 00:23:20 2007 @@ -40,6 +40,13 @@ OPTIONAL_DIRS := endif +# Don't install utils, examples, or projects they are only used to +# build LLVM. +ifeq ($(MAKECMDGOALS),install) + DIRS := $(filter-out utils, $(DIRS)) + OPTIONAL_DIRS := +endif + # Include the main makefile machinery. include $(LLVM_SRC_ROOT)/Makefile.rules From rspencer at reidspencer.com Wed Feb 21 00:53:30 2007 From: rspencer at reidspencer.com (Reid Spencer) Date: Tue, 20 Feb 2007 22:53:30 -0800 Subject: [llvm-commits] CVS: llvm/Makefile In-Reply-To: <200702210623.l1L6NbY8031700@zion.cs.uiuc.edu> References: <200702210623.l1L6NbY8031700@zion.cs.uiuc.edu> Message-ID: <1172040810.25169.155.camel@bashful.x10sys.com> On Wed, 2007-02-21 at 00:23 -0600, Chris Lattner wrote: > > Changes in directory llvm: > > Makefile updated: 1.69 -> 1.70 > --- > Log message: > > revert r1.68. This breaks 'make install' without doing 'make' first, but > fixes PR1208: http://llvm.org/PR1208 . This isn't correct. I implemented the NO_INSTALL keyword specifically to prevent installation of a directory's build products. This is what utils/TableGen does. Please revert this patch (1.70) and edit the examples directory's makefiles to include: NO_INSTALL := 1 That will prevent installation of the examples while still fixing the PR for allowing "make install" to build everything and install only that which is installable. >From the makefile guide: > NO_INSTALL > Specifies that the build products of the directory should not > be installed but should be built even if the install target is > given. This is handy for directories that build libraries or > tools that are only used as part of the build process, such as > code generators (e.g. tblgen). Thanks, Reid. > > > --- > Diffs of the changes: (+7 -0) > > Makefile | 7 +++++++ > 1 files changed, 7 insertions(+) > > > Index: llvm/Makefile > diff -u llvm/Makefile:1.69 llvm/Makefile:1.70 > --- llvm/Makefile:1.69 Mon Feb 5 17:18:58 2007 > +++ llvm/Makefile Wed Feb 21 00:23:20 2007 > @@ -40,6 +40,13 @@ > OPTIONAL_DIRS := > endif > > +# Don't install utils, examples, or projects they are only used to > +# build LLVM. > +ifeq ($(MAKECMDGOALS),install) > + DIRS := $(filter-out utils, $(DIRS)) > + OPTIONAL_DIRS := > +endif > + > # Include the main makefile machinery. > include $(LLVM_SRC_ROOT)/Makefile.rules > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Feb 21 01:23:42 2007 From: clattner at apple.com (Chris Lattner) Date: Tue, 20 Feb 2007 23:23:42 -0800 Subject: [llvm-commits] CVS: llvm/Makefile In-Reply-To: <1172040810.25169.155.camel@bashful.x10sys.com> References: <200702210623.l1L6NbY8031700@zion.cs.uiuc.edu> <1172040810.25169.155.camel@bashful.x10sys.com> Message-ID: <60A1AA5C-947B-4034-8225-31240D5392EA@apple.com> >> revert r1.68. This breaks 'make install' without doing 'make' >> first, but >> fixes PR1208: http://llvm.org/PR1208 . > > This isn't correct. I'm aware of that, which is why I mentioned that in the commit message. I'm just repairing the regression by reverting the offending patch: if you'd like to refix "make install without doing a make first" (without reintroducing the regression) go for it! -Chris From rspencer at reidspencer.com Wed Feb 21 01:38:12 2007 From: rspencer at reidspencer.com (Reid Spencer) Date: Tue, 20 Feb 2007 23:38:12 -0800 Subject: [llvm-commits] CVS: llvm/Makefile In-Reply-To: <60A1AA5C-947B-4034-8225-31240D5392EA@apple.com> References: <200702210623.l1L6NbY8031700@zion.cs.uiuc.edu> <1172040810.25169.155.camel@bashful.x10sys.com> <60A1AA5C-947B-4034-8225-31240D5392EA@apple.com> Message-ID: <1172043492.25169.156.camel@bashful.x10sys.com> On Tue, 2007-02-20 at 23:23 -0800, Chris Lattner wrote: > >> revert r1.68. This breaks 'make install' without doing 'make' > >> first, but > >> fixes PR1208: http://llvm.org/PR1208 . > > > > This isn't correct. > > I'm aware of that, which is why I mentioned that in the commit > message. I'm just repairing the regression by reverting the > offending patch: if you'd like to refix "make install without doing a > make first" (without reintroducing the regression) go for it! I just explained exactly how. > > -Chris > > From reid at x10sys.com Wed Feb 21 02:22:12 2007 From: reid at x10sys.com (Reid Spencer) Date: Wed, 21 Feb 2007 02:22:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702210822.l1L8MCYm010104@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.28 -> 1.29 --- Log message: Reorganize some code to make it clearer, avoid a few uninitialized memory reads, and reduce the number of temporary APInt instances we construct. --- Diffs of the changes: (+57 -56) APInt.cpp | 113 +++++++++++++++++++++++++++++++------------------------------- 1 files changed, 57 insertions(+), 56 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.28 llvm/lib/Support/APInt.cpp:1.29 --- llvm/lib/Support/APInt.cpp:1.28 Tue Feb 20 23:44:56 2007 +++ llvm/lib/Support/APInt.cpp Wed Feb 21 02:21:52 2007 @@ -280,7 +280,7 @@ for (uint32_t i = 1; i < ylen; ++i) { uint64_t ly = y[i] & 0xffffffffULL, hy = y[i] >> 32; - uint64_t carry = 0, lx, hx; + uint64_t carry = 0, lx = 0, hx = 0; for (uint32_t j = 0; j < xlen; ++j) { lx = x[j] & 0xffffffffULL; hx = x[j] >> 32; @@ -309,29 +309,42 @@ /// given APInt& RHS and assigns the result to this APInt. APInt& APInt::operator*=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) + if (isSingleWord()) { VAL *= RHS.VAL; - else { - // one-based first non-zero bit position. - uint32_t first = getActiveBits(); - uint32_t xlen = !first ? 0 : whichWord(first - 1) + 1; - if (!xlen) - return *this; - else { - first = RHS.getActiveBits(); - uint32_t ylen = !first ? 0 : whichWord(first - 1) + 1; - if (!ylen) { - memset(pVal, 0, getNumWords() * APINT_WORD_SIZE); - return *this; - } - uint64_t *dest = getMemory(xlen+ylen); - mul(dest, pVal, xlen, RHS.pVal, ylen); - memcpy(pVal, dest, ((xlen + ylen >= getNumWords()) ? - getNumWords() : xlen + ylen) * APINT_WORD_SIZE); - delete[] dest; - } + clearUnusedBits(); + return *this; } - clearUnusedBits(); + + // Get some bit facts about LHS and check for zero + uint32_t lhsBits = getActiveBits(); + uint32_t lhsWords = !lhsBits ? 0 : whichWord(lhsBits - 1) + 1; + if (!lhsWords) + // 0 * X ===> 0 + return *this; + + // Get some bit facts about RHS and check for zero + uint32_t rhsBits = RHS.getActiveBits(); + uint32_t rhsWords = !rhsBits ? 0 : whichWord(rhsBits - 1) + 1; + if (!rhsWords) { + // X * 0 ===> 0 + clear(); + return *this; + } + + // Allocate space for the result + uint32_t destWords = rhsWords + lhsWords; + uint64_t *dest = getMemory(destWords); + + // Perform the long multiply + mul(dest, pVal, lhsWords, RHS.pVal, rhsWords); + + // Copy result back into *this + clear(); + uint32_t wordsToCopy = destWords >= getNumWords() ? getNumWords() : destWords; + memcpy(pVal, dest, wordsToCopy * APINT_WORD_SIZE); + + // delete dest array and return + delete[] dest; return *this; } @@ -1239,7 +1252,7 @@ delete Quotient->pVal; Quotient->BitWidth = LHS.BitWidth; if (!Quotient->isSingleWord()) - Quotient->pVal = getClearedMemory(lhsWords); + Quotient->pVal = getClearedMemory(Quotient->getNumWords()); } else Quotient->clear(); @@ -1270,7 +1283,7 @@ delete Remainder->pVal; Remainder->BitWidth = RHS.BitWidth; if (!Remainder->isSingleWord()) - Remainder->pVal = getClearedMemory(rhsWords); + Remainder->pVal = getClearedMemory(Remainder->getNumWords()); } else Remainder->clear(); @@ -1316,25 +1329,19 @@ uint32_t lhsBits = this->getActiveBits(); uint32_t lhsWords = !lhsBits ? 0 : (APInt::whichWord(lhsBits - 1) + 1); - // Make a temporary to hold the result - APInt Result(*this); - // Deal with some degenerate cases if (!lhsWords) - return Result; // 0 / X == 0 - else if (lhsWords < rhsWords || Result.ult(RHS)) { - // X / Y with X < Y == 0 - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - return Result; - } else if (Result == RHS) { - // X / X == 1 - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - Result.pVal[0] = 1; - return Result; + // 0 / X ===> 0 + return APInt(BitWidth, 0); + else if (lhsWords < rhsWords || this->ult(RHS)) { + // X / Y ===> 0, iff X < Y + return APInt(BitWidth, 0); + } else if (*this == RHS) { + // X / X ===> 1 + return APInt(BitWidth, 1); } else if (lhsWords == 1 && rhsWords == 1) { // All high words are zero, just use native divide - Result.pVal[0] /= RHS.pVal[0]; - return Result; + return APInt(BitWidth, this->pVal[0] / RHS.pVal[0]); } // We have to compute it the hard way. Invoke the Knuth divide algorithm. @@ -1352,34 +1359,28 @@ return APInt(BitWidth, VAL % RHS.VAL); } - // Make a temporary to hold the result - APInt Result(*this); + // Get some facts about the LHS + uint32_t lhsBits = getActiveBits(); + uint32_t lhsWords = !lhsBits ? 0 : (whichWord(lhsBits - 1) + 1); // Get some facts about the RHS uint32_t rhsBits = RHS.getActiveBits(); uint32_t rhsWords = !rhsBits ? 0 : (APInt::whichWord(rhsBits - 1) + 1); assert(rhsWords && "Performing remainder operation by zero ???"); - // Get some facts about the LHS - uint32_t lhsBits = Result.getActiveBits(); - uint32_t lhsWords = !lhsBits ? 0 : (Result.whichWord(lhsBits - 1) + 1); - // Check the degenerate cases if (lhsWords == 0) { - // 0 % Y == 0 - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - return Result; - } else if (lhsWords < rhsWords || Result.ult(RHS)) { - // X % Y == X iff X < Y - return Result; - } else if (Result == RHS) { + // 0 % Y ===> 0 + return APInt(BitWidth, 0); + } else if (lhsWords < rhsWords || this->ult(RHS)) { + // X % Y ===> X, iff X < Y + return *this; + } else if (*this == RHS) { // X % X == 0; - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); - return Result; + return APInt(BitWidth, 0); } else if (lhsWords == 1) { // All high words are zero, just use native remainder - Result.pVal[0] %= RHS.pVal[0]; - return Result; + return APInt(BitWidth, pVal[0] % RHS.pVal[0]); } // We have to compute it the hard way. Invoke the Knute divide algorithm. From reid at x10sys.com Wed Feb 21 02:28:40 2007 From: reid at x10sys.com (Reid Spencer) Date: Wed, 21 Feb 2007 02:28:40 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Message-ID: <200702210828.l1L8SeKn010229@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt: gptest.cpp updated: 1.1 -> 1.2 --- Log message: Improve this test: 1. Remove dead code (hold overs from another test). 2. Simplify communication with gp. 3. Fix a read uninitialized data bug by terminating the read buffer with 0 4. Consolidate reporting into a single function to make output consistent. 5. Add support for all arithmetic and copmarison operators. 6. Cleanup the output. 7. dup2 the stderr fd for gp so it writes errors back to test program. 8. Handle sigint so we can clean up on interrupt (shut down pipes nicely) --- Diffs of the changes: (+123 -184) gptest.cpp | 307 ++++++++++++++++++++++++------------------------------------- 1 files changed, 123 insertions(+), 184 deletions(-) Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.1 llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.2 --- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.1 Tue Feb 20 14:44:00 2007 +++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Wed Feb 21 02:28:20 2007 @@ -11,16 +11,16 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/APInt.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/System/Signals.h" #include #include #include #include -#include "llvm/System/Signals.h" using namespace llvm; -APInt x(21, 0x1fffff); -APInt y(21, 0x0fffff); +static int input = 0, output = 0; void print(const APInt& X, bool wantSigned = false, bool withNL = true) { std::string decstr = X.toString(10,wantSigned); @@ -39,210 +39,146 @@ return val; } -void test_interface(const APInt &val) { - printf("INTERFACE TEST: val = "); print(val); - unsigned bitwidth = val.getBitWidth(); - unsigned pos = rand() % bitwidth; - printf("val[%u] = %d\n", pos, val[pos]); - APInt smax(APInt::getMaxValue(bitwidth, true)); - APInt umax(APInt::getMaxValue(bitwidth, false)); - APInt smin(APInt::getMinValue(bitwidth, true)); - APInt umin(APInt::getMinValue(bitwidth, false)); - printf("APInt::getMinValue(%d, true) = ", bitwidth); print(smin,true); - printf("APInt::getMaxValue(%d, true) = ", bitwidth); print(smax,true); - printf("APInt::getMinValue(%d, false) = ", bitwidth); print(umin); - printf("APInt::getMaxValue(%d, false) = ", bitwidth); print(umax); - APInt null = APInt::getNullValue(bitwidth); - APInt allone = APInt::getAllOnesValue(bitwidth); - printf("APInt::getNullValue(%d) = ", bitwidth); print(null); - printf("APInt::getAllOnesValue(%d) = ", bitwidth); print(allone); - APInt x(val); - x.set(pos); - printf("val.set(%d) = ", pos); print(x); - x.set(); - printf("val.set() = "); print(x); - x = val; - x.clear(pos); - printf("val.clear(%d) = ", pos); print(x); - x.clear(); - printf("val.clear() = "); print(x); - x = val; - x.flip(pos); - printf("val.flip(%d) = ", pos); print(x); - x = val; - x.flip(); - printf("val.flip() = "); print(x); - unsigned bitsize = bitwidth / 2; - printf("val.getHiBits(%d) = ", bitsize); print(val.getHiBits(bitsize)); - printf("val.getLoBits(%d) = ", bitsize); print(val.getLoBits(bitsize)); - printf("val.isIntN(%d) = %d\n", bitwidth, val.isIntN(bitwidth)); -} - -void test_unops(const APInt &val) { - printf("UNARY OPERATORS TEST: val = "); print(val); - APInt x(val); - x++; - printf("val++ = "); print(x); - x = val; - ++x; - printf("++val = "); print(x); - x = val; - x--; - printf("val-- = "); print(x); - x = val; - --x; - printf("--val = "); print(x); - x = -val; - printf("-val = "); print(x); - x = ~val; - printf("~val = "); print(x); - printf("!val = %d\n", !val); - printf("val.isPowerOf2() = %d\n", val.isPowerOf2()); - printf("val.logBase2() = %d\n", val.logBase2()); - printf("val.countLeadingZeros() = %d\n", val.countLeadingZeros()); - printf("val.countTrailingZeros() = %d\n", val.countTrailingZeros()); - printf("val.countPopulation() = %d\n", val.countPopulation()); - printf("val.getBitWidth() = %d\n", val.getBitWidth()); - if (val.getBitWidth() >= 16 && val.getBitWidth() % 16 == 0) { - x = val.byteSwap(); - printf("val.byteSwap() = "); print(x); - } - printf("val.roundToDouble(false) = %f\n", val.roundToDouble(false)); - printf("val.roundToDouble(true) = %f\n", val.roundToDouble(true)); - printf("val.getValue() = "); - if (val.getBitWidth() > 64) - printf("too wide\n"); - else - printf("%lu\n", val.getValue()); -} - -void old_test_binops(const APInt &v1, const APInt &v2) { - printf("BINARY OPERATORS TEST: \n vl: "); print(v1,false,false); - printf("\n v2: "); print(v2); - APInt result(v1); - result &= v2; - printf("v1 &= v2: "); print(result); - result = v1; - result |= v2; - printf("v1 |= v2: "); print(result); - result = v1; - result ^= v2; - printf("v1 ^= v2: "); print(result); - result = v1; - result *= v2; - printf("v1 *= v2: "); print(result); - result = v1; - result += v2; - printf("v1 += v2: "); print(result); - result = v1; - result -= v2; - printf("v1 -= v2: "); print(result); - result = v1 & v2; - printf("v1 & v2: "); print(result); - result = v1 | v2; - printf("v1 | v2: "); print(result); - result = v1 ^ v2; - printf("v1 ^ v2: "); print(result); - result = v1 * v2; - printf("v1 * v2: "); print(result); - result = v1 + v2; - printf("v1 + v2: "); print(result); - result = v1 - v2; - printf("v1 - v2: "); print(result); - printf("v1 == v2: %d\n", v1 == v2); - printf("v1 != v2: %d\n", v1 != v2); - printf("v1.eq(v2): %d\n", v1.eq(v2)); - printf("v1.ne(v2): %d\n", v1.ne(v2)); - printf("v1.ult(v2): %d\n", v1.ult(v2)); - printf("v1.slt(v2): %d\n", v1.slt(v2)); - printf("v1.ule(v2): %d\n", v1.ule(v2)); - printf("v1.sle(v2): %d\n", v1.sle(v2)); - printf("v1.ugt(v2): %d\n", v1.ugt(v2)); - printf("v1.sgt(v2): %d\n", v1.sgt(v2)); - printf("v1.uge(v2): %d\n", v1.uge(v2)); - printf("v1.sge(v2): %d\n", v1.sge(v2)); - { - using namespace APIntOps; - unsigned shiftAmt = rand() % v1.getBitWidth(); - result = ashr(v1,shiftAmt); - printf("ashr(v1,%d) = ", shiftAmt); print(result); - result = lshr(v1,shiftAmt); - printf("lshr(v1,%d) = ", shiftAmt); print(result); - result = shl(v1,shiftAmt); - printf("shl(v1,%d) = ", shiftAmt); print(result); - if (v2 == APInt(v2.getBitWidth(), 0)) - printf("sdiv/udiv/srem/urem not tested, v2 == 0\n"); - else { - result = sdiv(v1,v2); - printf("sdiv(v1,v2) = "); print(result); - result = udiv(v1,v2); - printf("udiv(v1,v2) = "); print(result); - result = srem(v1,v2); - printf("srem(v1,v2) = "); print(result); - result = urem(v1,v2); - printf("urem(v1,v2) = "); print(result); - } - } -} - -static int input = 0, output = 0; - -std::string getBinopCmd(const APInt &v1, std::string op, const APInt &v2, - bool wantSigned = false) { - std::string Result; - Result += "truncate("; - Result += v1.toString(10,wantSigned); - Result += " " + op + " "; - Result += v2.toString(10,wantSigned); - Result += ")\n"; - return Result; -} - std::string getResult(const std::string& cmd) { const char *command = cmd.c_str(); if (-1 == write(output, command, cmd.size())) { std::string msg = "write: " + cmd; + msg.resize(msg.size()-1); perror(msg.c_str()); exit(1); } - usleep(1000); // try to switch contexts - char buf[1024]; - int len = read(input, buf, 1024); + usleep(1); // try to switch contexts + char buf[4096]; + int len = read(input, buf, 4095); if (-1 == len) { std::string msg = "read: " + cmd; + msg.resize(msg.size()-1); perror(msg.c_str()); exit(1); } - // We're only interested in the last line. - if (char * nl = strrchr(buf, '\n')) { + buf[len] = 0; + // Clear the trailing newline + if (char * nl = strrchr(buf, '\n')) *nl = 0; - if (char *nnl = strrchr(nl, '\n')) - return std::string(nnl+1); - } return std::string(buf); } -void doMultiply(const APInt &v1, const APInt &v2) { - std::string cmd = getBinopCmd(v1, "*", v2); +std::string getBinop(const APInt &v1, const std::string &op, + const APInt &v2, bool wantSigned = false) { + APInt mask = APInt::getAllOnesValue(v1.getBitWidth()); + std::string cmd; + cmd += "bitand(truncate("; + cmd += v1.toString(10,wantSigned); + cmd += " " + op + " "; + cmd += v2.toString(10,wantSigned); + cmd += "), bitneg(0," + utostr(unsigned(v1.getBitWidth())) + "))\n"; + return getResult(cmd); +} + + +bool getCompare(const APInt &v1, const std::string &op, + const APInt &v2, bool wantSigned = false) { + + std::string cmd = v1.toString(10, wantSigned) + op + + v2.toString(10, wantSigned) + '\n'; std::string result = getResult(cmd); + return bool(atoi(result.c_str())); +} + +void report(const APInt &v1, const APInt &v2, const std::string& op, + const std::string& result, const std::string& apresult) { + print(v1, false, false); + printf(op.c_str()); + print(v2, false, false); + printf(" = %s (not %s)\n", result.c_str(), apresult.c_str()); + fflush(stdout); +} + +void doMultiply(const APInt &v1, const APInt &v2) { + std::string result = getBinop(v1, "*", v2); APInt r = v1 * v2; std::string apresult = r.toString(10, false); - if (result != apresult) { - printf("ERROR: "); - print(v1, false, false); - printf(" * "); - print(v2, false, false); - printf(" = %s (not %s)\n", result.c_str(), apresult.c_str()); - } + if (result != apresult) + report(v1,v2," * ", result,apresult); +} + +void doDivide(const APInt &v1, const APInt &v2) { + if (v2 == APInt(v2.getBitWidth(),0)) + return; + std::string result = getBinop(v1, "/", v2); + APInt r = APIntOps::udiv(v1, v2); + std::string apresult = r.toString(10, false); + if (result != apresult) + report(v1,v2," / ", result,apresult); +} + +void doRemainder(const APInt &v1, const APInt &v2) { + if (v2 == APInt(v2.getBitWidth(),0)) + return; + std::string result = getBinop(v1, "%", v2); + APInt r = APIntOps::urem(v1, v2); + std::string apresult = r.toString(10, false); + if (result != apresult) + report(v1,v2," % ", result,apresult); +} + +void doAdd(const APInt &v1, const APInt &v2) { + std::string result = getBinop(v1, "+", v2); + APInt r = v1 + v2; + std::string apresult = r.toString(10, false); + if (result != apresult) + report(v1,v2," + ", result,apresult); +} + +void doSubtract(const APInt &v1, const APInt &v2) { + std::string result = getBinop(v1, "-", v2); + APInt r = v1 - v2; + std::string apresult = r.toString(10, false); + if (result != apresult) + report(v1,v2," - ", result,apresult); +} + +void doComparisons(const APInt &v1, const APInt &v2) { + bool result = getCompare(v1, "==", v2); + bool apresult = v1 == v2; + if (result != apresult) + report(v1,v2," == ", (result?"true":"false"), (apresult?"true":"false")); + result = getCompare(v1, "!=", v2); + apresult = v1 != v2; + if (result != apresult) + report(v1,v2," != ", (result?"true":"false"), (apresult?"true":"false")); + result = getCompare(v1, "<", v2); + apresult = v1.ult(v2); + if (result != apresult) + report(v1,v2," < ", (result?"true":"false"), (apresult?"true":"false")); + result = getCompare(v1, "<=", v2); + apresult = v1.ule(v2); + if (result != apresult) + report(v1,v2," <= ", (result?"true":"false"), (apresult?"true":"false")); + result = getCompare(v1, ">", v2); + apresult = v1.ugt(v2); + if (result != apresult) + report(v1,v2," > ", (result?"true":"false"), (apresult?"true":"false")); + result = getCompare(v1, ">=", v2); + apresult = v1.uge(v2); + if (result != apresult) + report(v1,v2," >= ", (result?"true":"false"), (apresult?"true":"false")); } void test_binops(const APInt &v1, const APInt &v2) { + doAdd(v1,v2); + doSubtract(v1,v2); doMultiply(v1, v2); + doDivide(v1, v2); + doComparisons(v1, v2); } void Shutdown() { + // Be nice and tell gp to stop + write(output, "quit\n", 5); + // Close our descriptors close(input); - close(output); + close(output); // gp will get SIGPIPE if not terminated } /* function executed by the user-interacting process. */ @@ -267,9 +203,10 @@ srand(0); // Start loop over the range of bits of interest - for (unsigned bits = 1; bits <= 256; ++bits) { + for (unsigned bits = 1; bits <= 1024; bits++) { // Indicate which test case we are running - printf("\nTEST CASE: %d BITS\n\n", bits); + printf("\nTEST CASE: %d BITS\n", bits); + fflush(stdout); // Gather some test data APInt zero(bits,0); APInt one(bits,1); @@ -312,8 +249,6 @@ char ch; /* the same - as a char. */ int rc; /* return values of functions. */ - printf("In translator\n"); - /* first, close unnecessary file descriptors */ close(input_pipe[1]); /* we don't need to write to this pipe. */ close(output_pipe[0]); /* we don't need to read from this pipe. */ @@ -327,6 +262,10 @@ perror("dup2 for stdout"); exit(1); } + if (-1 == dup2(output_pipe[1], STDERR_FILENO)) { + perror("dup2 for stderr"); + exit(1); + } // exec gp with modes: // --quiet (don't print banner), From sabre at nondot.org Wed Feb 21 12:12:08 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 21 Feb 2007 12:12:08 -0600 Subject: [llvm-commits] CVS: llvm-www/header.incl Message-ID: <200702211812.l1LIC8hL020016@zion.cs.uiuc.edu> Changes in directory llvm-www: header.incl updated: 1.51 -> 1.52 --- Log message: add new status update --- Diffs of the changes: (+15 -14) header.incl | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-) Index: llvm-www/header.incl diff -u llvm-www/header.incl:1.51 llvm-www/header.incl:1.52 --- llvm-www/header.incl:1.51 Wed Nov 29 16:15:26 2006 +++ llvm-www/header.incl Wed Feb 21 12:11:42 2007 @@ -66,26 +66,27 @@ Status Updates

    From dpatel at apple.com Wed Feb 21 13:57:50 2007 From: dpatel at apple.com (Devang Patel) Date: Wed, 21 Feb 2007 13:57:50 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ET-Forest.h Message-ID: <200702211957.l1LJvowb022231@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ET-Forest.h updated: 1.8 -> 1.9 --- Log message: Simplify --- Diffs of the changes: (+1 -2) ET-Forest.h | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/include/llvm/Analysis/ET-Forest.h diff -u llvm/include/llvm/Analysis/ET-Forest.h:1.8 llvm/include/llvm/Analysis/ET-Forest.h:1.9 --- llvm/include/llvm/Analysis/ET-Forest.h:1.8 Tue Feb 20 20:36:31 2007 +++ llvm/include/llvm/Analysis/ET-Forest.h Wed Feb 21 13:57:33 2007 @@ -141,8 +141,7 @@ // removeFromForest() ~ETNode() { delete RightmostOcc; - if (ParentOcc) - delete ParentOcc; + delete ParentOcc; } void removeFromForest() { From dpatel at apple.com Wed Feb 21 15:13:43 2007 From: dpatel at apple.com (dpatel at apple.com) Date: Wed, 21 Feb 2007 13:13:43 -0800 (PST) Subject: [llvm-commits] [124164] Backport mingw32 support from FSF GCC mainline. Message-ID: <20070221211343.40D5E59745E6@src> Revision: 124164 Author: dpatel Date: 2007-02-21 13:13:42 -0800 (Wed, 21 Feb 2007) Log Message: ----------- Backport mingw32 support from FSF GCC mainline. Patch by Anton Korobeynikov. Added Paths: ----------- apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c apple-local/branches/llvm/gcc/config/i386/winnt-stubs.c Added: apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c =================================================================== --- apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c (rev 0) +++ apple-local/branches/llvm/gcc/config/i386/winnt-cxx.c 2007-02-21 21:13:42 UTC (rev 124164) @@ -0,0 +1,167 @@ +/* Target support for C++ classes on Windows. + Contributed by Danny Smith (dannysmith at users.sourceforge.net) + Copyright (C) 2005 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC 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 2, or (at your option) any later +version. + +GCC 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 GCC; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "rtl.h" +#include "regs.h" +#include "hard-reg-set.h" +#include "output.h" +#include "tree.h" +#include "cp/cp-tree.h" /* this is why we're a separate module */ +#include "flags.h" +#include "tm_p.h" +#include "toplev.h" +#include "hashtab.h" + +bool +i386_pe_type_dllimport_p (tree decl) +{ + gcc_assert (TREE_CODE (decl) == VAR_DECL + || TREE_CODE (decl) == FUNCTION_DECL); + + if (TARGET_NOP_FUN_DLLIMPORT && TREE_CODE (decl) == FUNCTION_DECL) + return false; + + /* We ignore the dllimport attribute for inline member functions. + This differs from MSVC behavior which treats it like GNUC + 'extern inline' extension. Also ignore for template + instantiations with linkonce semantics and artificial methods. */ + if (TREE_CODE (decl) == FUNCTION_DECL + && (DECL_DECLARED_INLINE_P (decl) + || DECL_TEMPLATE_INSTANTIATION (decl) + || DECL_ARTIFICIAL (decl))) + return false; + + /* Since we can't treat a pointer to a dllimport'd symbol as a + constant address, we turn off the attribute on C++ virtual + methods to allow creation of vtables using thunks. */ + else if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE + && DECL_VIRTUAL_P (decl)) + { + /* Even though we ignore the attribute from the start, warn if we later see + an out-of class definition, as we do for other member functions in + tree.c:merge_dllimport_decl_attributes. If this is the key method, the + definition may affect the import-export status of vtables, depending + on how we handle MULTIPLE_SYMBOL_SPACES in cp/decl2.c. */ + if (DECL_INITIAL (decl)) + { + warning ("%q+D redeclared without dllimport attribute: " + "previous dllimport ignored", decl); +#ifdef PE_DLL_DEBUG + if (decl == CLASSTYPE_KEY_METHOD (DECL_CONTEXT (decl))) + warning ("key method %q+D of dllimport'd class defined" + decl); +#endif + } + return false; + } + + /* Don't mark defined functions as dllimport. This code will only be + reached if we see a non-inline function defined out-of-class. */ + else if (TREE_CODE (decl) == FUNCTION_DECL + && (DECL_INITIAL (decl))) + return false; + + /* Don't allow definitions of static data members in dllimport class, + If vtable data is marked as DECL_EXTERNAL, import it; otherwise just + ignore the class attribute. */ + else if (TREE_CODE (decl) == VAR_DECL + && TREE_STATIC (decl) && TREE_PUBLIC (decl) + && !DECL_EXTERNAL (decl)) + { + if (!DECL_VIRTUAL_P (decl)) + error ("definition of static data member %q+D of " + "dllimport'd class", decl); + return false; + } + + return true; +} + + +bool +i386_pe_type_dllexport_p (tree decl) +{ + gcc_assert (TREE_CODE (decl) == VAR_DECL + || TREE_CODE (decl) == FUNCTION_DECL); + /* Avoid exporting compiler-generated default dtors and copy ctors. + The only artificial methods that need to be exported are virtual + and non-virtual thunks. */ + if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE + && DECL_ARTIFICIAL (decl) && !DECL_THUNK_P (decl)) + return false; + return true; +} + +static inline void maybe_add_dllimport (tree decl) +{ + if (i386_pe_type_dllimport_p (decl)) + DECL_DLLIMPORT_P (decl) = 1; +} + +void +i386_pe_adjust_class_at_definition (tree t) +{ + tree member; + + gcc_assert (CLASS_TYPE_P (t)); + + /* We only look at dllimport. The only thing that dllexport does is + add stuff to a '.drectiv' section at end-of-file, so no need to do + anything for dllexport'd classes until we generate RTL. */ + if (lookup_attribute ("dllimport", TYPE_ATTRIBUTES (t)) == NULL_TREE) + return; + + /* We don't actually add the attribute to the decl, just set the flag + that signals that the address of this symbol is not a compile-time + constant. Any subsequent out-of-class declaration of members wil + cause the DECL_DLLIMPORT_P flag to be unset. + (See tree.c: merge_dllimport_decl_attributes). + That is just right since out-of class declarations can only be a + definition. We recheck the class members at RTL generation to + emit warnings if this has happened. Definition of static data member + of dllimport'd class always causes an error (as per MS compiler). + */ + + /* Check static VAR_DECL's. */ + for (member = TYPE_FIELDS (t); member; member = TREE_CHAIN (member)) + if (TREE_CODE (member) == VAR_DECL) + maybe_add_dllimport (member); + + /* Check FUNCTION_DECL's. */ + for (member = TYPE_METHODS (t); member; member = TREE_CHAIN (member)) + if (TREE_CODE (member) == FUNCTION_DECL) + maybe_add_dllimport (member); + + /* Check vtables */ + for (member = CLASSTYPE_VTABLES (t); member; member = TREE_CHAIN (member)) + if (TREE_CODE (member) == VAR_DECL) + maybe_add_dllimport (member); + +/* We leave typeinfo tables alone. We can't mark TI objects as + dllimport, since the address of a secondary VTT may be needed + for static initialization of a primary VTT. VTT's of + dllimport'd classes should always be link-once COMDAT. */ +} Added: apple-local/branches/llvm/gcc/config/i386/winnt-stubs.c =================================================================== --- apple-local/branches/llvm/gcc/config/i386/winnt-stubs.c (rev 0) +++ apple-local/branches/llvm/gcc/config/i386/winnt-stubs.c 2007-02-21 21:13:42 UTC (rev 124164) @@ -0,0 +1,53 @@ +/* Dummy subroutines for language-specific support on Windows. + Contributed by Danny Smith (dannysmith at users.sourceforge.net) + Copyright (C) 2005 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC 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 2, or (at your option) any later +version. + +GCC 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 GCC; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "rtl.h" +#include "regs.h" +#include "hard-reg-set.h" +#include "output.h" +#include "tree.h" +#include "flags.h" +#include "tm_p.h" +#include "toplev.h" +#include "hashtab.h" + +bool +i386_pe_type_dllimport_p (tree decl ATTRIBUTE_UNUSED) +{ + return false; +} + + +bool +i386_pe_type_dllexport_p (tree decl ATTRIBUTE_UNUSED) +{ + return false; +} + + +void +i386_pe_adjust_class_at_definition (tree t ATTRIBUTE_UNUSED) +{ } From evan.cheng at apple.com Wed Feb 21 15:18:31 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 21 Feb 2007 15:18:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702212118.l1LLIVr6023638@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.320 -> 1.321 --- Log message: ELF / PIC requires GOT be in the EBX register during calls via PLT GOT pointer. Add implicit uses of EBX to calls to ensure liveintervalanalysis does not treat the GOT in EBX move as dead upon definition. This should fix PR1207: http://llvm.org/PR1207 . --- Diffs of the changes: (+14 -0) X86ISelLowering.cpp | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.320 llvm/lib/Target/X86/X86ISelLowering.cpp:1.321 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.320 Thu Feb 1 02:39:52 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Wed Feb 21 15:18:14 2007 @@ -794,6 +794,8 @@ InFlag = Chain.getValue(1); } + // ELF / PIC requires GOT in the EBX register before function calls via PLT + // GOT pointer. if (getTargetMachine().getRelocationModel() == Reloc::PIC_ && Subtarget->isPICStyleGOT()) { Chain = DAG.getCopyToReg(Chain, X86::EBX, @@ -825,6 +827,11 @@ for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) Ops.push_back(DAG.getRegister(RegsToPass[i].first, RegsToPass[i].second.getValueType())); + + // Add an implicit use GOT pointer in EBX. + if (getTargetMachine().getRelocationModel() == Reloc::PIC_ && + Subtarget->isPICStyleGOT()) + Ops.push_back(DAG.getRegister(X86::EBX, getPointerTy())); if (InFlag.Val) Ops.push_back(InFlag); @@ -1788,6 +1795,8 @@ } else if (ExternalSymbolSDNode *S = dyn_cast(Callee)) Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy()); + // ELF / PIC requires GOT in the EBX register before function calls via PLT + // GOT pointer. if (getTargetMachine().getRelocationModel() == Reloc::PIC_ && Subtarget->isPICStyleGOT()) { Chain = DAG.getCopyToReg(Chain, X86::EBX, @@ -1809,6 +1818,11 @@ Ops.push_back(DAG.getRegister(RegsToPass[i].first, RegsToPass[i].second.getValueType())); + // Add an implicit use GOT pointer in EBX. + if (getTargetMachine().getRelocationModel() == Reloc::PIC_ && + Subtarget->isPICStyleGOT()) + Ops.push_back(DAG.getRegister(X86::EBX, getPointerTy())); + if (InFlag.Val) Ops.push_back(InFlag); From jlaskey at apple.com Wed Feb 21 16:36:14 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:36:14 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.td Message-ID: <200702212236.l1LMaEQ7025098@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.td updated: 1.46 -> 1.47 --- Log message: Add new intrinsics for eh support. --- Diffs of the changes: (+3 -1) Intrinsics.td | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Intrinsics.td diff -u llvm/include/llvm/Intrinsics.td:1.46 llvm/include/llvm/Intrinsics.td:1.47 --- llvm/include/llvm/Intrinsics.td:1.46 Wed Feb 14 20:26:09 2007 +++ llvm/include/llvm/Intrinsics.td Wed Feb 21 16:35:57 2007 @@ -232,7 +232,9 @@ //===------------------ Exception Handling Intrinsics----------------------===// // def int_eh_exception : Intrinsic<[llvm_ptr_ty]>; -def int_eh_handlers : Intrinsic<[llvm_i32_ty, llvm_ptr_ty, llvm_vararg_ty]>; +def int_eh_handlers : Intrinsic<[llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, + llvm_vararg_ty]>; +def int_eh_typeid_for : Intrinsic<[llvm_i32_ty, llvm_ptr_ty]>; //===----------------------------------------------------------------------===// // Target-specific intrinsics From jlaskey at apple.com Wed Feb 21 16:37:38 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:37:38 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <200702212237.l1LMbcoR025129@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.177 -> 1.178 --- Log message: Add new instructions for handling data passed into eh landing pad. --- Diffs of the changes: (+9 -1) SelectionDAGNodes.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.177 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.178 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.177 Wed Feb 14 21:39:17 2007 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Wed Feb 21 16:37:22 2007 @@ -91,6 +91,14 @@ // to the current function's frame or return address, an index of one to the // parent's frame or return address, and so on. FRAMEADDR, RETURNADDR, + + // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the + // address of the exception block on entry to an landing pad block. + EXCEPTIONADDR, + + // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents + // the selection index of the exception thrown. + EHSELECTION, // TargetConstant* - Like Constant*, but the DAG does not do any folding or // simplification of the constant. @@ -457,7 +465,7 @@ // Operand #0 : input chain. // Operand #1 : module unique number use to identify the label. LABEL, - + // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a // value, the same type as the pointer type for the system, and an output // chain. From jlaskey at apple.com Wed Feb 21 16:38:52 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:38:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineModuleInfo.cpp Message-ID: <200702212238.l1LMcqFQ025162@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineModuleInfo.cpp updated: 1.3 -> 1.4 --- Log message: Add structures used for collecting eh information. --- Diffs of the changes: (+94 -0) MachineModuleInfo.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 94 insertions(+) Index: llvm/lib/CodeGen/MachineModuleInfo.cpp diff -u llvm/lib/CodeGen/MachineModuleInfo.cpp:1.3 llvm/lib/CodeGen/MachineModuleInfo.cpp:1.4 --- llvm/lib/CodeGen/MachineModuleInfo.cpp:1.3 Thu Feb 1 10:31:34 2007 +++ llvm/lib/CodeGen/MachineModuleInfo.cpp Wed Feb 21 16:38:31 2007 @@ -1472,6 +1472,7 @@ , ScopeMap() , RootScope(NULL) , FrameMoves() +, LandingPads() {} MachineModuleInfo::~MachineModuleInfo() { @@ -1510,6 +1511,10 @@ // Clean up frame info. FrameMoves.clear(); + + // Clean up exception info. + LandingPads.clear(); + TypeInfos.clear(); } /// getDescFor - Convert a Value to a debug information descriptor. @@ -1640,6 +1645,95 @@ return Slot; } +//===-EH-------------------------------------------------------------------===// + +/// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the +/// specified MachineBasicBlock. +LandingPadInfo &MachineModuleInfo::getOrCreateLandingPadInfo + (MachineBasicBlock *LandingPad) { + unsigned N = LandingPads.size(); + for (unsigned i = 0; i < N; ++i) { + LandingPadInfo &UI = LandingPads[i]; + if (UI.LandingPadBlock == LandingPad) + return UI; + } + + LandingPads.push_back(LandingPadInfo(LandingPad)); + return LandingPads[N]; +} + +/// addInvoke - Provide the begin and end labels of an invoke style call and +/// associate it with a try landing pad block. +void MachineModuleInfo::addInvoke(MachineBasicBlock *LandingPad, + unsigned BeginLabel, unsigned EndLabel) { + LandingPadInfo &UI = getOrCreateLandingPadInfo(LandingPad); + if (!UI.BeginLabel) UI.BeginLabel = BeginLabel; + UI.EndLabel = EndLabel; +} + +/// addLandingPad - Provide the label of a try LandingPad block. +/// +unsigned MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) { + unsigned LandingPadLabel = NextLabelID(); + LandingPadInfo &UI = getOrCreateLandingPadInfo(LandingPad); + UI.LandingPadLabel = LandingPadLabel; + return LandingPadLabel; +} + +/// addPersonality - Provide the personality function for the exception +/// information. +void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad, + Function *Personality) { + LandingPadInfo &UI = getOrCreateLandingPadInfo(LandingPad); + UI.Personality = Personality; +} + +/// addCatchTypeInfo - Provide the catch typeinfo for a landing pad. +/// +void MachineModuleInfo::addCatchTypeInfo(MachineBasicBlock *LandingPad, + std::vector &TyInfo) { + LandingPadInfo &UI = getOrCreateLandingPadInfo(LandingPad); + for (unsigned N = TyInfo.size(); N; --N) + UI.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1])); +} + +/// TidyLandingPads - Remap landing pad labels and remove any deleted landing +/// pads. +void MachineModuleInfo::TidyLandingPads() { + for (unsigned i = 0; i != LandingPads.size(); ) { + LandingPadInfo &LandingPad = LandingPads[i]; + LandingPad.BeginLabel = MappedLabel(LandingPad.BeginLabel); + LandingPad.EndLabel = MappedLabel(LandingPad.EndLabel); + LandingPad.LandingPadLabel = MappedLabel(LandingPad.LandingPadLabel); + + if (!LandingPad.BeginLabel || + !LandingPad.EndLabel || + !LandingPad.LandingPadLabel) { + LandingPads.erase(LandingPads.begin() + i); + continue; + } + + ++i; + } +} + +/// getTypeIDFor - Return the type id for the specified typeinfo. This is +/// function wide. +unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) { + for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i) + if (TypeInfos[i] == TI) return i + 1; + + TypeInfos.push_back(TI); + return TypeInfos.size(); +} + +/// getLandingPadInfos - Return a reference to the landing pad info for the +/// current function. +Function *MachineModuleInfo::getPersonality() const { + return !LandingPads.empty() ? LandingPads[0].Personality : NULL; +} + + //===----------------------------------------------------------------------===// /// DebugLabelFolding pass - This pass prunes out redundant labels. This allows /// a info consumer to determine if the range of two labels is empty, by seeing From jlaskey at apple.com Wed Feb 21 16:38:52 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:38:52 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineModuleInfo.h Message-ID: <200702212238.l1LMcq9k025165@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineModuleInfo.h updated: 1.4 -> 1.5 --- Log message: Add structures used for collecting eh information. --- Diffs of the changes: (+78 -0) MachineModuleInfo.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+) Index: llvm/include/llvm/CodeGen/MachineModuleInfo.h diff -u llvm/include/llvm/CodeGen/MachineModuleInfo.h:1.4 llvm/include/llvm/CodeGen/MachineModuleInfo.h:1.5 --- llvm/include/llvm/CodeGen/MachineModuleInfo.h:1.4 Thu Feb 1 10:31:34 2007 +++ llvm/include/llvm/CodeGen/MachineModuleInfo.h Wed Feb 21 16:38:31 2007 @@ -44,6 +44,7 @@ class Constant; class DebugInfoDesc; class GlobalVariable; +class MachineBasicBlock; class MachineFunction; class MachineMove; class Module; @@ -949,6 +950,27 @@ }; //===----------------------------------------------------------------------===// +/// LandingPadInfo - This structure is used to retain landing pad info for +/// the current function. +/// +struct LandingPadInfo { + MachineBasicBlock *LandingPadBlock; // Landing pad block. + unsigned BeginLabel; // Label prior to invoke. + unsigned EndLabel; // Label after invoke. + unsigned LandingPadLabel; // Label at beginning of landing pad. + Function *Personality; // Personality function. + std::vector TypeIds; // List of type ids. + + LandingPadInfo(MachineBasicBlock *MBB) + : LandingPadBlock(MBB) + , BeginLabel(0) + , EndLabel(0) + , LandingPadLabel(0) + , TypeIds() + {} +}; + +//===----------------------------------------------------------------------===// /// MachineModuleInfo - This class contains meta information specific to a /// module. Queries can be made by different debugging and exception handling /// schemes and reformated for specific use. @@ -987,6 +1009,14 @@ // FrameMoves - List of moves done by a function's prolog. Used to construct // frame maps by debug and exception handling consumers. std::vector FrameMoves; + + // LandingPads - List of LandingPadInfo describing the landing pad information + // in the current function. + std::vector LandingPads; + + // TypeInfos - List of C++ TypeInfo used in the currect function. + // + std::vector TypeInfos; public: MachineModuleInfo(); @@ -1147,6 +1177,54 @@ /// function's prologue. Used to construct frame maps for debug and exception /// handling comsumers. std::vector &getFrameMoves() { return FrameMoves; } + + //===-EH-----------------------------------------------------------------===// + + /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the + /// specified MachineBasicBlock. + LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad); + + /// addInvoke - Provide the begin and end labels of an invoke style call and + /// associate it with a try landing pad block. + void addInvoke(MachineBasicBlock *LandingPad, unsigned BeginLabel, + unsigned EndLabel); + + /// addLandingPad - Add a new panding pad. Returns the label ID for the + /// landing pad entry. + unsigned addLandingPad(MachineBasicBlock *LandingPad); + + /// addPersonality - Provide the personality function for the exception + /// information. + void addPersonality(MachineBasicBlock *LandingPad, Function *Personality); + + /// addCatchTypeInfo - Provide the catch typeinfo for a landing pad. + /// + void addCatchTypeInfo(MachineBasicBlock *LandingPad, + std::vector &TyInfo); + + /// getTypeIDFor - Return the type id for the specified typeinfo. This is + /// function wide. + unsigned getTypeIDFor(GlobalVariable *TI); + + /// TidyLandingPads - Remap landing pad labels and remove any deleted landing + /// pads. + void TidyLandingPads(); + + /// getLandingPadInfos - Return a reference to the landing pad info for the + /// current function. + const std::vector &getLandingPads() const { + return LandingPads; + } + + /// getTypeInfos - Return a reference to the C++ typeinfo for the current + /// function. + const std::vector &getTypeInfos() const { + return TypeInfos; + } + + /// getPersonality - Return a personality function if available. The presence + /// of one is required to emit exception handling info. + Function *getPersonality() const; }; // End class MachineModuleInfo From jlaskey at apple.com Wed Feb 21 16:40:08 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:40:08 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200702212240.l1LMe8as025203@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.58 -> 1.59 --- Log message: Add a flag to MBBs to indicate whether it is an eh landing pad. --- Diffs of the changes: (+18 -1) MachineBasicBlock.h | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.58 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.59 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.58 Mon Feb 19 15:49:53 2007 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Wed Feb 21 16:39:52 2007 @@ -74,10 +74,15 @@ /// LiveIns - Keep track of the physical registers that are livein of /// the basicblock. std::vector LiveIns; + + /// IsLandingPad - Indicate that this basic block is entered via an + /// exception handler. + bool IsLandingPad; public: MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb), - Number(-1), Parent(0) { + Number(-1), Parent(0), + IsLandingPad(false) { Insts.parent = this; } @@ -152,6 +157,18 @@ const_livein_iterator livein_end() const { return LiveIns.end(); } bool livein_empty() const { return LiveIns.empty(); } + /// isLandingPad - Returns true if the block is a landing pad. That is + /// this basic block is entered via an exception handler. + bool isLandingPad() const { return IsLandingPad; } + + /// setIsLandingPad - Indicates the block is a landing pad. That is + /// this basic block is entered via an exception handler. + void setIsLandingPad() { IsLandingPad = true; } + + /// isAccessable - Returns true if the block is alive. That is, if it has + /// predecessors or is an eh landing pad. + bool isAccessable() const { return !pred_empty() || isLandingPad(); } + // Code Layout methods. /// moveBefore/moveAfter - move 'this' block before or after the specified From jlaskey at apple.com Wed Feb 21 16:41:38 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:41:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200702212241.l1LMfc3R025239@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.210 -> 1.211 --- Log message: Allow for live in registers for eh landing pads. --- Diffs of the changes: (+6 -5) LiveIntervalAnalysis.cpp | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.210 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.211 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.210 Tue Feb 20 20:27:39 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Feb 21 16:41:17 2007 @@ -658,14 +658,15 @@ } void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB, + unsigned MIIdx, LiveInterval &interval) { DOUT << "\t\tlivein register: "; DEBUG(printRegName(interval.reg)); // Look for kills, if it reaches a def before it's killed, then it shouldn't // be considered a livein. MachineBasicBlock::iterator mi = MBB->begin(); - unsigned baseIndex = 0; - unsigned start = 0; + unsigned baseIndex = MIIdx; + unsigned start = baseIndex; unsigned end = start; while (mi != MBB->end()) { if (lv_->KillsRegister(mi, interval.reg)) { @@ -690,8 +691,8 @@ assert(start < end && "did not find end of interval?"); LiveRange LR(start, end, interval.getNextValue(~0U, 0)); - interval.addRange(LR); DOUT << " +" << LR << '\n'; + interval.addRange(LR); } /// computeIntervals - computes the live intervals for virtual @@ -715,9 +716,9 @@ // Create intervals for live-ins to this BB first. for (MachineBasicBlock::const_livein_iterator LI = MBB->livein_begin(), LE = MBB->livein_end(); LI != LE; ++LI) { - handleLiveInRegister(MBB, getOrCreateInterval(*LI)); + handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*LI)); for (const unsigned* AS = mri_->getAliasSet(*LI); *AS; ++AS) - handleLiveInRegister(MBB, getOrCreateInterval(*AS)); + handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*AS)); } } From jlaskey at apple.com Wed Feb 21 16:41:38 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:41:38 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Message-ID: <200702212241.l1LMfcTW025244@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervalAnalysis.h updated: 1.71 -> 1.72 --- Log message: Allow for live in registers for eh landing pads. --- Diffs of the changes: (+3 -1) LiveIntervalAnalysis.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.71 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.72 --- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.71 Mon Feb 19 15:49:53 2007 +++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Wed Feb 21 16:41:17 2007 @@ -240,7 +240,9 @@ unsigned SrcReg); /// handleLiveInRegister - Create interval for a livein register. - void handleLiveInRegister(MachineBasicBlock* mbb, LiveInterval &interval); + void handleLiveInRegister(MachineBasicBlock* mbb, + unsigned MIIdx, + LiveInterval &interval); /// Return true if the two specified registers belong to different /// register classes. The registers may be either phys or virt regs. From jlaskey at apple.com Wed Feb 21 16:42:37 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:42:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp Message-ID: <200702212242.l1LMgbS3025272@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.42 -> 1.43 --- Log message: Make branch folding behave in the presence of landing pads. --- Diffs of the changes: (+30 -25) BranchFolding.cpp | 55 +++++++++++++++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 25 deletions(-) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.42 llvm/lib/CodeGen/BranchFolding.cpp:1.43 --- llvm/lib/CodeGen/BranchFolding.cpp:1.42 Fri Feb 16 18:44:34 2007 +++ llvm/lib/CodeGen/BranchFolding.cpp Wed Feb 21 16:42:20 2007 @@ -67,7 +67,8 @@ /// RemoveDeadBlock - Remove the specified dead machine basic block from the /// function, updating the CFG. void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) { - assert(MBB->pred_empty() && "MBB must be dead!"); + assert(!MBB->isAccessable() && "MBB must be dead!"); + DOUT << "\nRemoving MBB: " << *MBB; MachineFunction *MF = MBB->getParent(); // drop all successors. @@ -439,7 +440,7 @@ OptimizeBlock(MBB); // If it is dead, remove it. - if (MBB->pred_empty()) { + if (!MBB->isAccessable()) { RemoveDeadBlock(MBB); MadeChange = true; ++NumDeadBlocks; @@ -485,6 +486,8 @@ } else if (*SI == DestB) { DestB = 0; ++SI; + } else if ((*SI)->isLandingPad()) { + ++SI; } else { // Otherwise, this is a superfluous edge, remove it. MBB.removeSuccessor(SI); @@ -615,14 +618,14 @@ // explicitly. if (MBB->empty()) { // Dead block? Leave for cleanup later. - if (MBB->pred_empty()) return; + if (!MBB->isAccessable()) return; if (FallThrough == MBB->getParent()->end()) { // TODO: Simplify preds to not branch here if possible! } else { // Rewrite all predecessors of the old block to go to the fallthrough // instead. - while (!MBB->pred_empty()) { + while (MBB->isAccessable()) { MachineBasicBlock *Pred = *(MBB->pred_end()-1); ReplaceUsesOfBlockWith(Pred, MBB, FallThrough, TII); } @@ -855,28 +858,30 @@ bool CurFallsThru = CanFallThrough(MBB, CurUnAnalyzable, CurTBB, CurFBB, CurCond); - // Check all the predecessors of this block. If one of them has no fall - // throughs, move this block right after it. - for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), - E = MBB->pred_end(); PI != E; ++PI) { - // Analyze the branch at the end of the pred. - MachineBasicBlock *PredBB = *PI; - MachineFunction::iterator PredFallthrough = PredBB; ++PredFallthrough; - if (PredBB != MBB && !CanFallThrough(PredBB) - && (!CurFallsThru || MBB->getNumber() >= PredBB->getNumber())) { - // If the current block doesn't fall through, just move it. - // If the current block can fall through and does not end with a - // conditional branch, we need to append an unconditional jump to - // the (current) next block. To avoid a possible compile-time - // infinite loop, move blocks only backward in this case. - if (CurFallsThru) { - MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB)); - CurCond.clear(); - TII->InsertBranch(*MBB, NextBB, 0, CurCond); + if (!MBB->isLandingPad()) { + // Check all the predecessors of this block. If one of them has no fall + // throughs, move this block right after it. + for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), + E = MBB->pred_end(); PI != E; ++PI) { + // Analyze the branch at the end of the pred. + MachineBasicBlock *PredBB = *PI; + MachineFunction::iterator PredFallthrough = PredBB; ++PredFallthrough; + if (PredBB != MBB && !CanFallThrough(PredBB) + && (!CurFallsThru || MBB->getNumber() >= PredBB->getNumber())) { + // If the current block doesn't fall through, just move it. + // If the current block can fall through and does not end with a + // conditional branch, we need to append an unconditional jump to + // the (current) next block. To avoid a possible compile-time + // infinite loop, move blocks only backward in this case. + if (CurFallsThru) { + MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB)); + CurCond.clear(); + TII->InsertBranch(*MBB, NextBB, 0, CurCond); + } + MBB->moveAfter(PredBB); + MadeChange = true; + return OptimizeBlock(MBB); } - MBB->moveAfter(PredBB); - MadeChange = true; - return OptimizeBlock(MBB); } } From jlaskey at apple.com Wed Feb 21 16:43:59 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:43:59 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetAsmInfo.h Message-ID: <200702212243.l1LMhxZ2025312@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetAsmInfo.h updated: 1.25 -> 1.26 --- Log message: Add TAI field for exception table section. --- Diffs of the changes: (+8 -0) TargetAsmInfo.h | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/include/llvm/Target/TargetAsmInfo.h diff -u llvm/include/llvm/Target/TargetAsmInfo.h:1.25 llvm/include/llvm/Target/TargetAsmInfo.h:1.26 --- llvm/include/llvm/Target/TargetAsmInfo.h:1.25 Thu Feb 1 10:31:34 2007 +++ llvm/include/llvm/Target/TargetAsmInfo.h Wed Feb 21 16:43:40 2007 @@ -313,6 +313,11 @@ /// DwarfEHFrameSection - Section directive for Exception frames. /// const char *DwarfEHFrameSection; // Defaults to ".eh_frame". + + /// DwarfExceptionSection - Section directive for Exception table. + /// + const char *DwarfExceptionSection; // Defaults to ".gcc_except_table". + //===--- CBE Asm Translation Table -----------------------------------===// @@ -540,6 +545,9 @@ const char *getDwarfEHFrameSection() const { return DwarfEHFrameSection; } + const char *getDwarfExceptionSection() const { + return DwarfExceptionSection; + } const char** getAsmCBE() const { return AsmTransCBE; } From jlaskey at apple.com Wed Feb 21 16:44:01 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:44:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetAsmInfo.cpp Message-ID: <200702212244.l1LMi1qe025318@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetAsmInfo.cpp updated: 1.18 -> 1.19 --- Log message: Add TAI field for exception table section. --- Diffs of the changes: (+1 -0) TargetAsmInfo.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Target/TargetAsmInfo.cpp diff -u llvm/lib/Target/TargetAsmInfo.cpp:1.18 llvm/lib/Target/TargetAsmInfo.cpp:1.19 --- llvm/lib/Target/TargetAsmInfo.cpp:1.18 Thu Feb 1 10:31:34 2007 +++ llvm/lib/Target/TargetAsmInfo.cpp Wed Feb 21 16:43:40 2007 @@ -86,6 +86,7 @@ DwarfRangesSection(".debug_ranges"), DwarfMacInfoSection(".debug_macinfo"), DwarfEHFrameSection(".eh_frame"), + DwarfExceptionSection(".gcc_except_table"), AsmTransCBE(0) { } From jlaskey at apple.com Wed Feb 21 16:44:01 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:44:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Message-ID: <200702212244.l1LMi1Am025321@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCTargetAsmInfo.cpp updated: 1.17 -> 1.18 --- Log message: Add TAI field for exception table section. --- Diffs of the changes: (+1 -0) PPCTargetAsmInfo.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.17 llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.18 --- llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp:1.17 Thu Feb 1 10:31:34 2007 +++ llvm/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Wed Feb 21 16:43:40 2007 @@ -43,6 +43,7 @@ DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; DwarfEHFrameSection = ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support"; + DwarfExceptionSection = ".section __DATA,__gcc_except_tab"; } DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM) From jlaskey at apple.com Wed Feb 21 16:47:57 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:47:57 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp Message-ID: <200702212247.l1LMlve4025425@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: AsmPrinter.cpp updated: 1.151 -> 1.152 --- Log message: Add support for changes in DwarfWriter. --- Diffs of the changes: (+12 -0) AsmPrinter.cpp | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.151 llvm/lib/CodeGen/AsmPrinter.cpp:1.152 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.151 Thu Feb 15 19:54:53 2007 +++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb 21 16:47:38 2007 @@ -370,6 +370,14 @@ return LinkName; } +/// EmitExternalGlobal - Emit the external reference to a global variable. +/// Should be overridden if an indirect reference should be used. +void AsmPrinter::EmitExternalGlobal(const GlobalVariable *GV) { + O << getGlobalLinkName(GV); +} + + + //===----------------------------------------------------------------------===// /// LEB 128 number encoding. @@ -440,6 +448,9 @@ /// EOL - Print a newline character to asm stream. If a comment is present /// then it will be printed first. Comments should not contain '\n'. +void AsmPrinter::EOL() const { + O << "\n"; +} void AsmPrinter::EOL(const std::string &Comment) const { if (AsmVerbose && !Comment.empty()) { O << "\t" @@ -569,6 +580,7 @@ O << TAI->getAlignDirective() << NumBits << "\n"; } + /// EmitZeros - Emit a block of zeros. /// void AsmPrinter::EmitZeros(uint64_t NumZeros) const { From jlaskey at apple.com Wed Feb 21 16:48:00 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:48:00 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h Message-ID: <200702212248.l1LMm0Z0025430@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: AsmPrinter.h updated: 1.61 -> 1.62 --- Log message: Add support for changes in DwarfWriter. --- Diffs of the changes: (+5 -0) AsmPrinter.h | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/include/llvm/CodeGen/AsmPrinter.h diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.61 llvm/include/llvm/CodeGen/AsmPrinter.h:1.62 --- llvm/include/llvm/CodeGen/AsmPrinter.h:1.61 Fri Jan 26 08:34:51 2007 +++ llvm/include/llvm/CodeGen/AsmPrinter.h Wed Feb 21 16:47:38 2007 @@ -105,6 +105,10 @@ /// generate the appropriate value. virtual const std::string getGlobalLinkName(const GlobalVariable *GV) const; + /// EmitExternalGlobal - Emit the external reference to a global variable. + /// Should be overridden if an indirect reference should be used. + virtual void EmitExternalGlobal(const GlobalVariable *GV); + protected: /// doInitialization - Set up the AsmPrinter when we are working on a new /// module. If your pass overrides this, it must make sure to explicitly @@ -204,6 +208,7 @@ /// EOL - Print a newline character to asm stream. If a comment is present /// then it will be printed first. Comments should not contain '\n'. + void EOL() const; void EOL(const std::string &Comment) const; /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an From jlaskey at apple.com Wed Feb 21 16:48:00 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:48:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Message-ID: <200702212248.l1LMm0Il025432@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.233 -> 1.234 --- Log message: Add support for changes in DwarfWriter. --- Diffs of the changes: (+14 -0) PPCAsmPrinter.cpp | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.233 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.234 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.233 Wed Jan 31 18:39:08 2007 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Feb 21 16:47:38 2007 @@ -280,6 +280,8 @@ virtual bool runOnMachineFunction(MachineFunction &F) = 0; virtual bool doFinalization(Module &M) = 0; + + virtual void EmitExternalGlobal(const GlobalVariable *GV); }; /// LinuxAsmPrinter - PowerPC assembly printer, customized for Linux @@ -401,6 +403,18 @@ } } +/// EmitExternalGlobal - In this case we need to use the indirect symbol. +/// +void PPCAsmPrinter::EmitExternalGlobal(const GlobalVariable *GV) { + std::string Name = getGlobalLinkName(GV); + if (TM.getRelocationModel() != Reloc::Static) { + GVStubs.insert(Name); + O << "L" << Name << "$non_lazy_ptr"; + return; + } + O << Name; +} + /// PrintAsmOperand - Print out an operand for an inline asm expression. /// bool PPCAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, From jlaskey at apple.com Wed Feb 21 16:49:02 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:49:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp AsmPrinter.cpp Message-ID: <200702212249.l1LMn2m0025466@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: DwarfWriter.cpp updated: 1.125 -> 1.126 AsmPrinter.cpp updated: 1.152 -> 1.153 --- Log message: Exception handling support. --- Diffs of the changes: (+313 -94) AsmPrinter.cpp | 2 DwarfWriter.cpp | 405 +++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 313 insertions(+), 94 deletions(-) Index: llvm/lib/CodeGen/DwarfWriter.cpp diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.125 llvm/lib/CodeGen/DwarfWriter.cpp:1.126 --- llvm/lib/CodeGen/DwarfWriter.cpp:1.125 Thu Feb 1 11:48:20 2007 +++ llvm/lib/CodeGen/DwarfWriter.cpp Wed Feb 21 16:48:45 2007 @@ -55,7 +55,7 @@ //===----------------------------------------------------------------------===// /// DWLabel - Labels are used to track locations in the assembler file. -/// Labels appear in the form debug_, where the tag is a +/// Labels appear in the form , where the tag is a /// category of label (Ex. location) and number is a value unique in that /// category. class DWLabel { @@ -80,7 +80,7 @@ if (O) print(*O); } void print(std::ostream &O) const { - O << ".debug_" << Tag; + O << "." << Tag; if (Number) O << Number; } #endif @@ -791,14 +791,6 @@ /// MachineModuleInfo *MMI; - /// didInitial - Flag to indicate if initial emission has been done. - /// - bool didInitial; - - /// shouldEmit - Flag to indicate if debug information should be emitted. - /// - bool shouldEmit; - /// SubprogramCount - The running count of functions being compiled. /// unsigned SubprogramCount; @@ -812,8 +804,6 @@ , M(NULL) , MF(NULL) , MMI(NULL) - , didInitial(false) - , shouldEmit(false) , SubprogramCount(0) { } @@ -827,20 +817,13 @@ MachineModuleInfo *getMMI() const { return MMI; } const TargetAsmInfo *getTargetAsmInfo() const { return TAI; } - /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made. - /// - bool ShouldEmitDwarf() const { return shouldEmit; } - - /// PrintLabelName - Print label name in form used by Dwarf writer. /// void PrintLabelName(DWLabel Label) const { PrintLabelName(Label.Tag, Label.Number); } void PrintLabelName(const char *Tag, unsigned Number) const { - O << TAI->getPrivateGlobalPrefix() - << ((Tag && *Tag) ? "debug_" : "label_") - << Tag; + O << TAI->getPrivateGlobalPrefix() << Tag; if (Number) O << Number; } @@ -932,7 +915,7 @@ Asm->TM.getFrameInfo()->getStackGrowthDirection() == TargetFrameInfo::StackGrowsUp ? TAI->getAddressSize() : -TAI->getAddressSize(); - bool IsLocal = BaseLabel && strcmp(BaseLabel, "") == 0; + bool IsLocal = BaseLabel && strcmp(BaseLabel, "label") == 0; for (unsigned i = 0, N = Moves.size(); i < N; ++i) { MachineMove &Move = Moves[i]; @@ -952,11 +935,11 @@ if (BaseLabel && LabelID && (BaseLabelID != LabelID || !IsLocal)) { Asm->EmitInt8(DW_CFA_advance_loc4); Asm->EOL("DW_CFA_advance_loc4"); - EmitDifference("", LabelID, BaseLabel, BaseLabelID, true); - Asm->EOL(""); + EmitDifference("label", LabelID, BaseLabel, BaseLabelID, true); + Asm->EOL(); BaseLabelID = LabelID; - BaseLabel = ""; + BaseLabel = "label"; IsLocal = true; } @@ -1066,8 +1049,19 @@ /// std::vector > SectionSourceLines; + /// didInitial - Flag to indicate if initial emission has been done. + /// + bool didInitial; + + /// shouldEmit - Flag to indicate if debug information should be emitted. + /// + bool shouldEmit; public: + + /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made. + /// + bool ShouldEmitDwarf() const { return shouldEmit; } /// AssignAbbrevNumber - Define a unique number for the abbreviation. /// @@ -1850,14 +1844,14 @@ // Add the scope bounds. if (StartID) { AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr, - DWLabel("", StartID)); + DWLabel("label", StartID)); } else { AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr, DWLabel("func_begin", SubprogramCount)); } if (EndID) { AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr, - DWLabel("", EndID)); + DWLabel("label", EndID)); } else { AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr, DWLabel("func_end", SubprogramCount)); @@ -1944,7 +1938,7 @@ unsigned AbbrevNumber = Die->getAbbrevNumber(); const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1]; - Asm->EOL(""); + Asm->EOL(); // Emit the code (index) for the abbreviation. Asm->EmitULEB128Bytes(AbbrevNumber); @@ -2082,7 +2076,7 @@ Asm->EmitInt8(0); Asm->EOL("Extra Pad For GDB"); EmitLabel("info_end", Unit->getID()); - Asm->EOL(""); + Asm->EOL(); } /// EmitAbbreviations - Emit the abbreviation section. @@ -2107,12 +2101,12 @@ // Emit the abbreviations data. Abbrev->Emit(*this); - Asm->EOL(""); + Asm->EOL(); } EmitLabel("abbrev_end", 0); - Asm->EOL(""); + Asm->EOL(); } } @@ -2217,7 +2211,7 @@ Asm->EmitInt8(0); Asm->EOL("Extended Op"); Asm->EmitInt8(TAI->getAddressSize() + 1); Asm->EOL("Op size"); Asm->EmitInt8(DW_LNE_set_address); Asm->EOL("DW_LNE_set_address"); - EmitReference("", LabelID); Asm->EOL("Location label"); + EmitReference("label", LabelID); Asm->EOL("Location label"); // If change of source, then switch to the new source. if (Source != LineInfo.getSourceID()) { @@ -2259,13 +2253,13 @@ // Mark end of matrix. Asm->EmitInt8(0); Asm->EOL("DW_LNE_end_sequence"); - Asm->EmitULEB128Bytes(1); Asm->EOL(""); - Asm->EmitInt8(1); Asm->EOL(""); + Asm->EmitULEB128Bytes(1); Asm->EOL(); + Asm->EmitInt8(1); Asm->EOL(); } EmitLabel("line_end", 0); - Asm->EOL(""); + Asm->EOL(); } /// EmitInitialDebugFrame - Emit common frame info into a debug frame section. @@ -2308,7 +2302,7 @@ Asm->EmitAlignment(2); EmitLabel("frame_common_end", 0); - Asm->EOL(""); + Asm->EOL(); } /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame @@ -2342,7 +2336,7 @@ Asm->EmitAlignment(2); EmitLabel("frame_end", SubprogramCount); - Asm->EOL(""); + Asm->EOL(); } /// EmitDebugPubNames - Emit visible names into a debug pubnames section. @@ -2382,7 +2376,7 @@ Asm->EmitInt32(0); Asm->EOL("End Mark"); EmitLabel("pubnames_end", Unit->getID()); - Asm->EOL(""); + Asm->EOL(); } /// EmitDebugStr - Emit visible names into a debug str section. @@ -2400,10 +2394,10 @@ EmitLabel("string", StringID); // Emit the string itself. const std::string &String = StringPool[StringID]; - Asm->EmitString(String); Asm->EOL(""); + Asm->EmitString(String); Asm->EOL(); } - Asm->EOL(""); + Asm->EOL(); } } @@ -2413,7 +2407,7 @@ // Start the dwarf loc section. Asm->SwitchToDataSection(TAI->getDwarfLocSection()); - Asm->EOL(""); + Asm->EOL(); } /// EmitDebugARanges - Emit visible names into a debug aranges section. @@ -2448,7 +2442,7 @@ Asm->EmitInt32(0); Asm->EOL("EOM (1)"); Asm->EmitInt32(0); Asm->EOL("EOM (2)"); - Asm->EOL(""); + Asm->EOL(); #endif } @@ -2458,7 +2452,7 @@ // Start the dwarf ranges section. Asm->SwitchToDataSection(TAI->getDwarfRangesSection()); - Asm->EOL(""); + Asm->EOL(); } /// EmitDebugMacInfo - Emit visible names into a debug macinfo section. @@ -2467,7 +2461,7 @@ // Start the dwarf macinfo section. Asm->SwitchToDataSection(TAI->getDwarfMacInfoSection()); - Asm->EOL(""); + Asm->EOL(); } /// ConstructCompileUnitDIEs - Create a compile unit DIE for each source and @@ -2521,6 +2515,8 @@ , DescToUnitMap() , SectionMap() , SectionSourceLines() + , didInitial(false) + , shouldEmit(false) { } virtual ~DwarfDebug() { @@ -2661,41 +2657,86 @@ private: - /// EmitInitial - Emit initial exception information. + /// didInitial - Flag to indicate if initial emission has been done. + /// + bool didInitial; + + /// shouldEmit - Flag to indicate if debug information should be emitted. + /// + bool shouldEmit; + + /// EmitInitial - Emit the common eh unwind frame. /// void EmitInitial() { + // If there is a personality present then we need to indicate that + // in the common eh frame. + Function *Personality = MMI->getPersonality(); + + // Size and sign of stack growth. int stackGrowth = Asm->TM.getFrameInfo()->getStackGrowthDirection() == TargetFrameInfo::StackGrowsUp ? TAI->getAddressSize() : -TAI->getAddressSize(); + // Begin eh frame section. Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection()); O << "EH_frame:\n"; EmitLabel("section_eh_frame", 0); + // Define base labels. EmitLabel("eh_frame_common", 0); + + // Define the eh frame length. EmitDifference("eh_frame_common_end", 0, "eh_frame_common_begin", 0, true); Asm->EOL("Length of Common Information Entry"); + // EH frame header. EmitLabel("eh_frame_common_begin", 0); Asm->EmitInt32((int)0); Asm->EOL("CIE Identifier Tag"); Asm->EmitInt8(DW_CIE_VERSION); Asm->EOL("CIE Version"); - Asm->EmitString("zR"); + + // The personality presence indicates that language specific information + // will show up in the eh frame. + Asm->EmitString(Personality ? "zPLR" : "zR"); Asm->EOL("CIE Augmentation"); + + // Round out reader. Asm->EmitULEB128Bytes(1); Asm->EOL("CIE Code Alignment Factor"); Asm->EmitSLEB128Bytes(stackGrowth); Asm->EOL("CIE Data Alignment Factor"); Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister())); Asm->EOL("CIE RA Column"); - Asm->EmitULEB128Bytes(1); - Asm->EOL("Augmentation Size"); - Asm->EmitULEB128Bytes(DW_EH_PE_pcrel); - Asm->EOL("FDE Encoding (pcrel)"); + // If there is a personality, we need to indicate the functions location. + if (Personality) { + Asm->EmitULEB128Bytes(7); + Asm->EOL("Augmentation Size"); + Asm->EmitInt8(DW_EH_PE_indirect | + DW_EH_PE_pcrel | + DW_EH_PE_sdata4); + Asm->EOL("Personality (indirect pcrel sdata4)"); + + O << TAI->getData32bitsDirective(); + Asm->EmitExternalGlobal((const GlobalVariable *)(Personality)); + O << "-" << TAI->getPCSymbol(); + Asm->EOL("Personality"); + + Asm->EmitULEB128Bytes(DW_EH_PE_pcrel); + Asm->EOL("LSDA Encoding (pcrel)"); + Asm->EmitULEB128Bytes(DW_EH_PE_pcrel); + Asm->EOL("FDE Encoding (pcrel)"); + } else { + Asm->EmitULEB128Bytes(1); + Asm->EOL("Augmentation Size"); + Asm->EmitULEB128Bytes(DW_EH_PE_pcrel); + Asm->EOL("FDE Encoding (pcrel)"); + } + + // Indicate locations of general callee saved registers in frame. std::vector Moves; RI->getInitialFrameState(Moves); EmitFrameMoves(NULL, 0, Moves); @@ -2703,39 +2744,224 @@ Asm->EmitAlignment(2); EmitLabel("eh_frame_common_end", 0); - Asm->EOL(""); - + Asm->EOL(); } - /// EmitEHFrame - Emit initial exception information. /// void EmitEHFrame() { - EmitDifference("eh_frame_end", SubprogramCount, - "eh_frame_begin", SubprogramCount, true); - Asm->EOL("Length of Frame Information Entry"); - - EmitLabel("eh_frame_begin", SubprogramCount); - - EmitDifference("eh_frame_begin", SubprogramCount, - "section_eh_frame", 0, true); - Asm->EOL("FDE CIE offset"); + // If there is a personality present then we need to indicate that + // in the common eh frame. + Function *Personality = MMI->getPersonality(); + MachineFrameInfo *MFI = MF->getFrameInfo(); - EmitReference("eh_func_begin", SubprogramCount, true); - Asm->EOL("FDE initial location"); - EmitDifference("eh_func_end", SubprogramCount, - "eh_func_begin", SubprogramCount); - Asm->EOL("FDE address range"); - - Asm->EmitULEB128Bytes(0); - Asm->EOL("Augmentation size"); - - std::vector &Moves = MMI->getFrameMoves(); + Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection()); + + // Externally visible entry into the functions eh frame info. + if (const char *GlobalDirective = TAI->getGlobalDirective()) + O << GlobalDirective << getAsm()->CurrentFnName << ".eh\n"; - EmitFrameMoves("eh_func_begin", SubprogramCount, Moves); + // If there are no calls then you can't unwind. + if (!MFI->hasCalls()) { + O << getAsm()->CurrentFnName << ".eh = 0\n"; + } else { + O << getAsm()->CurrentFnName << ".eh:\n"; + + // EH frame header. + EmitDifference("eh_frame_end", SubprogramCount, + "eh_frame_begin", SubprogramCount, true); + Asm->EOL("Length of Frame Information Entry"); + + EmitLabel("eh_frame_begin", SubprogramCount); + + EmitDifference("eh_frame_begin", SubprogramCount, + "section_eh_frame", 0, true); + Asm->EOL("FDE CIE offset"); + + EmitReference("eh_func_begin", SubprogramCount, true); + Asm->EOL("FDE initial location"); + EmitDifference("eh_func_end", SubprogramCount, + "eh_func_begin", SubprogramCount); + Asm->EOL("FDE address range"); + + // If there is a personality then point to the language specific data + // area in the exception table. + if (Personality) { + Asm->EmitULEB128Bytes(4); + Asm->EOL("Augmentation size"); + EmitReference("exception", SubprogramCount, true); + Asm->EOL("Language Specific Data Area"); + } else { + Asm->EmitULEB128Bytes(0); + Asm->EOL("Augmentation size"); + } + + // Indicate locations of function specific callee saved registers in + // frame. + std::vector &Moves = MMI->getFrameMoves(); + EmitFrameMoves("eh_func_begin", SubprogramCount, Moves); + + Asm->EmitAlignment(2); + EmitLabel("eh_frame_end", SubprogramCount); + } + if (const char *UsedDirective = TAI->getUsedDirective()) + O << UsedDirective << getAsm()->CurrentFnName << ".eh\n\n"; + } + + /// EmitExceptionTable - Emit landpads and actions. + /// + /// The general organization of the table is complex, but the basic concepts + /// are easy. First there is a header which describes the location and + /// organization of the three components that follow. + /// 1. The landing pad site information describes the range of code covered + /// by the try. In our case it's an accumulation of the ranges covered + /// by the invokes in the try. There is also a reference to the landing + /// pad that handles the exception once processed. Finally an index into + /// the actions table. + /// 2. The action table, in our case, is composed of pairs of type ids + /// and next action offset. Starting with the action index from the + /// landing pad site, each type Id is checked for a match to the current + /// exception. If it matches then the exception and type id are passed + /// on to the landing pad. Otherwise the next action is looked up. This + /// chain is terminated with a next action of zero. If no type id is + /// found the the frame is unwound and handling continues. + /// 3. Type id table contains references to all the C++ typeinfo for all + /// catches in the function. This tables is reversed indexed base 1. + void EmitExceptionTable() { + // Map all labels and get rid of any dead landing pads. + MMI->TidyLandingPads(); + + const std::vector &TypeInfos = MMI->getTypeInfos(); + const std::vector &LandingPads = MMI->getLandingPads(); + if (LandingPads.empty()) return; + + // FIXME - Should fold actions for multiple landing pads. + + // Gather first action index for each landing pad site. + SmallVector Actions; + + // Compute sizes for exception table. + unsigned SizeHeader = sizeof(int8_t) + // LPStart format + sizeof(int8_t) + // TType format + sizeof(int8_t) + // TType base offset (NEED ULEB128) + sizeof(int8_t) + // Call site format + sizeof(int8_t); // Call-site table length + unsigned SizeSites = 0; + unsigned SizeActions = 0; + + // Look at each landing pad site to compute size. We need the size of each + // landing pad site info and the size of the landing pad's actions. + for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { + const LandingPadInfo &LandingPad = LandingPads[i]; + unsigned SizeSiteActions = 0; + const std::vector &TypeIds = LandingPad.TypeIds; + unsigned SizeAction = 0; + + // Gather the action sizes + for (unsigned j = 0, M = TypeIds.size(); j != M; ++j) { + unsigned TypeID = TypeIds[i]; + unsigned SizeTypeID = Asm->SizeULEB128(TypeID); + signed Action = j ? -(SizeAction + SizeTypeID) : 0; + SizeAction = SizeTypeID + Asm->SizeSLEB128(Action); + SizeSiteActions += SizeAction; + } + + // Record the first action of the landing pad site. + signed FirstAction = SizeActions + SizeSiteActions - SizeAction + 1; + Actions.push_back(FirstAction); + + // Compute this sites contribution to size. + SizeActions += SizeSiteActions; + SizeSites += sizeof(int32_t) + // Site start. + sizeof(int32_t) + // Site length. + sizeof(int32_t) + // Landing pad. + Asm->SizeULEB128(FirstAction); // Action. + } + + // Final tallies. + unsigned SizeTypes = TypeInfos.size() * TAI->getAddressSize(); + unsigned SizePreType = SizeHeader + SizeSites + SizeActions; + unsigned SizeAlign = (4 - SizePreType) & 3; + unsigned TypeOffset = SizePreType + + SizeTypes + + SizeAlign - + sizeof(int8_t) - // LPStart format + sizeof(int8_t) - // TType format + sizeof(int8_t); // TType base offset (NEED ULEB128) + + // Begin the exception table. + Asm->SwitchToDataSection(TAI->getDwarfExceptionSection()); + O << "GCC_except_table" << SubprogramCount << ":\n"; + EmitLabel("exception", SubprogramCount); + + // Emit the header. + Asm->EmitInt8(DW_EH_PE_omit); + Asm->EOL("LPStart format (DW_EH_PE_omit)"); + Asm->EmitInt8(DW_EH_PE_absptr); + Asm->EOL("TType format (DW_EH_PE_absptr)"); + Asm->EmitULEB128Bytes(TypeOffset); + Asm->EOL("TType base offset"); + Asm->EmitInt8(DW_EH_PE_udata4); + Asm->EOL("Call site format (DW_EH_PE_udata4)"); + Asm->EmitULEB128Bytes(SizeSites); + Asm->EOL("Call-site table length"); + + // Emit the landng pad site information. + for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { + const LandingPadInfo &LandingPad = LandingPads[i]; + EmitDifference("label", LandingPad.BeginLabel, + "eh_func_begin", SubprogramCount); + Asm->EOL("Region start"); + + EmitDifference("label", LandingPad.EndLabel, + "label", LandingPad.BeginLabel); + Asm->EOL("Region length"); + + EmitDifference("label", LandingPad.LandingPadLabel, + "eh_func_begin", SubprogramCount); + Asm->EOL("Landing pad"); + + Asm->EmitULEB128Bytes(Actions[i]); + Asm->EOL("Action"); + } + + // Emit the actions. + for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { + const LandingPadInfo &LandingPad = LandingPads[i]; + const std::vector &TypeIds = LandingPad.TypeIds; + unsigned SizeAction = 0; + + for (unsigned j = 0, M = TypeIds.size(); j < M; ++j) { + unsigned TypeID = TypeIds[j]; + unsigned SizeTypeID = Asm->SizeULEB128(TypeID); + Asm->EmitSLEB128Bytes(TypeID); + Asm->EOL("TypeInfo index"); + signed Action = j ? -(SizeAction + SizeTypeID) : 0; + SizeAction = SizeTypeID + Asm->SizeSLEB128(Action); + Asm->EmitSLEB128Bytes(Action); + Asm->EOL("Next action"); + } + } + + // Emit the type ids. Asm->EmitAlignment(2); - EmitLabel("eh_frame_end", SubprogramCount); + for (unsigned M = TypeInfos.size(); M; --M) { + GlobalVariable *GV = TypeInfos[M - 1]; + + if (TAI->getAddressSize() == sizeof(int32_t)) + O << TAI->getData32bitsDirective(); + else + O << TAI->getData64bitsDirective(); + + if (GV) + O << Asm->getGlobalLinkName(GV); + else + O << "0"; + + Asm->EOL("TypeInfo"); + } + } public: @@ -2744,18 +2970,24 @@ // DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T) : Dwarf(OS, A, T) + , didInitial(false) + , shouldEmit(false) {} virtual ~DwarfException() {} + /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made. + /// + bool ShouldEmitDwarf() const { return shouldEmit; } + /// SetModuleInfo - Set machine module information when it's known that pass /// manager has created it. Set by the target AsmPrinter. void SetModuleInfo(MachineModuleInfo *mmi) { -#if 1 // Not ready for prime time. - return; -#endif // Make sure initial declarations are made. - if (!MMI && ExceptionHandling && TAI->getSupportsExceptionHandling()) { + if (!MMI && + ExceptionHandling && + TAI->getSupportsExceptionHandling() && + mmi->getPersonality()) { MMI = mmi; shouldEmit = true; @@ -2794,21 +3026,8 @@ if (!ShouldEmitDwarf()) return; EmitLabel("eh_func_end", SubprogramCount); - - Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection()); - - if (const char *GlobalDirective = TAI->getGlobalDirective()) - O << GlobalDirective << getAsm()->CurrentFnName << ".eh\n"; - - if (0) { - O << getAsm()->CurrentFnName << ".eh = 0\n"; - } else { - O << getAsm()->CurrentFnName << ".eh:\n"; - EmitEHFrame(); - } - - if (const char *UsedDirective = TAI->getUsedDirective()) - O << UsedDirective << getAsm()->CurrentFnName << ".eh\n\n"; + EmitExceptionTable(); + EmitEHFrame(); } }; @@ -3004,7 +3223,7 @@ const std::vector &AbbrevData = Abbrev.getData(); for (unsigned i = 0, N = Values.size(); i < N; ++i) { - DD.getAsm()->EOL(""); + DD.getAsm()->EOL(); Values[i]->EmitValue(DD, AbbrevData[i].getForm()); } } Index: llvm/lib/CodeGen/AsmPrinter.cpp diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.152 llvm/lib/CodeGen/AsmPrinter.cpp:1.153 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.152 Wed Feb 21 16:47:38 2007 +++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb 21 16:48:45 2007 @@ -1059,7 +1059,7 @@ void AsmPrinter::printLabel(const MachineInstr *MI) const { O << "\n" << TAI->getPrivateGlobalPrefix() - << "label_" + << "label" << MI->getOperand(0).getImmedValue() << ":\n"; } From jlaskey at apple.com Wed Feb 21 16:50:07 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:50:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerInvoke.cpp Message-ID: <200702212250.l1LMo7ne025523@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: LowerInvoke.cpp updated: 1.55 -> 1.56 --- Log message: Itanium ABI exception handing support. --- Diffs of the changes: (+50 -36) LowerInvoke.cpp | 86 ++++++++++++++++++++++++++++++++------------------------ 1 files changed, 50 insertions(+), 36 deletions(-) Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.55 llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.56 --- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.55 Mon Feb 19 01:34:47 2007 +++ llvm/lib/Transforms/Utils/LowerInvoke.cpp Wed Feb 21 16:49:50 2007 @@ -57,6 +57,9 @@ static cl::opt ExpensiveEHSupport("enable-correct-eh-support", cl::desc("Make the -lowerinvoke pass insert expensive, but correct, EH code")); + +static cl::opt ItaniumEHSupport("enable-real-eh-support", + cl::desc("Make the -lowerinvoke pass insert itanium ABI EH code")); namespace { class VISIBILITY_HIDDEN LowerInvoke : public FunctionPass { @@ -94,6 +97,7 @@ void splitLiveRangesLiveAcrossInvokes(std::vector &Invokes); void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, AllocaInst *InvokeNum, SwitchInst *CatchSwitch); + bool insertItaniumEHSupport(Function &F); bool insertExpensiveEHSupport(Function &F); }; @@ -111,46 +115,50 @@ // doInitialization - Make sure that there is a prototype for abort in the // current module. bool LowerInvoke::doInitialization(Module &M) { - const Type *VoidPtrTy = PointerType::get(Type::Int8Ty); - AbortMessage = 0; - if (ExpensiveEHSupport) { - // Insert a type for the linked list of jump buffers. - unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0; - JBSize = JBSize ? JBSize : 200; - const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize); - - { // The type is recursive, so use a type holder. - std::vector Elements; - Elements.push_back(JmpBufTy); - OpaqueType *OT = OpaqueType::get(); - Elements.push_back(PointerType::get(OT)); - PATypeHolder JBLType(StructType::get(Elements)); - OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle. - JBLinkTy = JBLType.get(); - M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy); - } + if (ItaniumEHSupport) { + // Let Invoke pass through for ItaniumEHSupport support. + } else { + const Type *VoidPtrTy = PointerType::get(Type::Int8Ty); + AbortMessage = 0; + if (ExpensiveEHSupport) { + // Insert a type for the linked list of jump buffers. + unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0; + JBSize = JBSize ? JBSize : 200; + const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize); + + { // The type is recursive, so use a type holder. + std::vector Elements; + Elements.push_back(JmpBufTy); + OpaqueType *OT = OpaqueType::get(); + Elements.push_back(PointerType::get(OT)); + PATypeHolder JBLType(StructType::get(Elements)); + OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle. + JBLinkTy = JBLType.get(); + M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy); + } - const Type *PtrJBList = PointerType::get(JBLinkTy); + const Type *PtrJBList = PointerType::get(JBLinkTy); - // Now that we've done that, insert the jmpbuf list head global, unless it - // already exists. - if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) { - JBListHead = new GlobalVariable(PtrJBList, false, - GlobalValue::LinkOnceLinkage, - Constant::getNullValue(PtrJBList), - "llvm.sjljeh.jblist", &M); + // Now that we've done that, insert the jmpbuf list head global, unless it + // already exists. + if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))){ + JBListHead = new GlobalVariable(PtrJBList, false, + GlobalValue::LinkOnceLinkage, + Constant::getNullValue(PtrJBList), + "llvm.sjljeh.jblist", &M); + } + SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty, + PointerType::get(JmpBufTy), (Type *)0); + LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy, + PointerType::get(JmpBufTy), + Type::Int32Ty, (Type *)0); } - SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty, - PointerType::get(JmpBufTy), (Type *)0); - LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy, - PointerType::get(JmpBufTy), - Type::Int32Ty, (Type *)0); - } - // We need the 'write' and 'abort' functions for both models. - AbortFn = M.getOrInsertFunction("abort", Type::VoidTy, (Type *)0); - WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::Int32Ty, - VoidPtrTy, Type::Int32Ty, (Type *)0); + // We need the 'write' and 'abort' functions for both models. + AbortFn = M.getOrInsertFunction("abort", Type::VoidTy, (Type *)0); + WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::Int32Ty, + VoidPtrTy, Type::Int32Ty, (Type *)0); + } return true; } @@ -388,6 +396,10 @@ } } +bool LowerInvoke::insertItaniumEHSupport(Function &F) { + return true; +} + bool LowerInvoke::insertExpensiveEHSupport(Function &F) { std::vector Returns; std::vector Unwinds; @@ -569,6 +581,8 @@ } bool LowerInvoke::runOnFunction(Function &F) { + if (ItaniumEHSupport) + return insertItaniumEHSupport(F); if (ExpensiveEHSupport) return insertExpensiveEHSupport(F); else From jlaskey at apple.com Wed Feb 21 16:54:02 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:54:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200702212254.l1LMs2EF025642@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.67 -> 1.68 --- Log message: Selection and lowering for exception handling. --- Diffs of the changes: (+5 -0) IntrinsicLowering.cpp | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.67 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.68 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.67 Tue Feb 13 00:01:22 2007 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Wed Feb 21 16:53:45 2007 @@ -357,6 +357,11 @@ case Intrinsic::dbg_func_start: case Intrinsic::dbg_declare: break; // Simply strip out debugging intrinsics + + case Intrinsic::eh_exception: + case Intrinsic::eh_handlers: + assert(0 && "Should not have leaked through"); + break; case Intrinsic::memcpy_i32: case Intrinsic::memcpy_i64: { From jlaskey at apple.com Wed Feb 21 16:54:04 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:54:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp Message-ID: <200702212254.l1LMs4pD025651@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.476 -> 1.477 SelectionDAG.cpp updated: 1.389 -> 1.390 SelectionDAGISel.cpp updated: 1.369 -> 1.370 --- Log message: Selection and lowering for exception handling. --- Diffs of the changes: (+141 -2) LegalizeDAG.cpp | 2 SelectionDAG.cpp | 2 SelectionDAGISel.cpp | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 141 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.476 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.477 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.476 Wed Feb 14 21:39:18 2007 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Feb 21 16:53:45 2007 @@ -668,6 +668,8 @@ break; case ISD::FRAMEADDR: case ISD::RETURNADDR: + case ISD::EXCEPTIONADDR: + case ISD::EHSELECTION: // The only option for these nodes is to custom lower them. If the target // does not custom lower them, then return zero. Tmp1 = TLI.LowerOperation(Op, DAG); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.389 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.390 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.389 Sun Feb 4 02:35:21 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Feb 21 16:53:45 2007 @@ -2679,6 +2679,8 @@ case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE"; case ISD::RETURNADDR: return "RETURNADDR"; case ISD::FRAMEADDR: return "FRAMEADDR"; + case ISD::EXCEPTIONADDR: return "EXCEPTIONADDR"; + case ISD::EHSELECTION: return "EHSELECTION"; case ISD::ConstantPool: return "ConstantPool"; case ISD::ExternalSymbol: return "ExternalSymbol"; case ISD::INTRINSIC_WO_CHAIN: { Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.369 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.370 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.369 Wed Feb 14 21:39:18 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Feb 21 16:53:45 2007 @@ -496,8 +496,8 @@ void visitJumpTable(SelectionDAGISel::JumpTable &JT); // These all get lowered before this pass. - void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); } - void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); } + void visitInvoke(InvokeInst &I); + void visitUnwind(UnwindInst &I); void visitScalarBinary(User &I, unsigned OpCode); void visitVectorBinary(User &I, unsigned OpCode); @@ -1101,6 +1101,56 @@ return; } +void SelectionDAGLowering::visitInvoke(InvokeInst &I) { + // Retrieve successors. + MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)]; + MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)]; + + // Mark landing pad so that it doesn't get deleted in branch folding. + LandingPad->setIsLandingPad(); + + // Insert a label before the invoke call to mark the try range. + // This can be used to detect deletion of the invoke via the + // MachineModuleInfo. + MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + unsigned BeginLabel = MMI->NextLabelID(); + DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), + DAG.getConstant(BeginLabel, MVT::i32))); + + // Insert a normal call instruction. + std::vector Args; + for (InvokeInst::op_iterator OI = I.op_begin() + 3, E = I.op_end(); + OI != E; ++OI) { + Args.push_back(*OI); + } + CallInst *NewCall = new CallInst(I.getCalledValue(), &Args[0], Args.size(), + I.getName(), &I); + NewCall->setCallingConv(I.getCallingConv()); + I.replaceAllUsesWith(NewCall); + visitCall(*NewCall); + + // Insert a label before the invoke call to mark the try range. + // This can be used to detect deletion of the invoke via the + // MachineModuleInfo. + unsigned EndLabel = MMI->NextLabelID(); + DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), + DAG.getConstant(EndLabel, MVT::i32))); + + // Inform MachineModuleInfo of range. + MMI->addInvoke(LandingPad, BeginLabel, EndLabel); + + // Drop into normal successor. + DAG.setRoot(DAG.getNode(ISD::BR, MVT::Other, getRoot(), + DAG.getBasicBlock(Return))); + + // Update successor info + CurMBB->addSuccessor(Return); + CurMBB->addSuccessor(LandingPad); +} + +void SelectionDAGLowering::visitUnwind(UnwindInst &I) { +} + void SelectionDAGLowering::visitSwitch(SwitchInst &I) { // Figure out which block is immediately after the current one. MachineBasicBlock *NextBlock = 0; @@ -2033,6 +2083,91 @@ return 0; } + case Intrinsic::eh_exception: { + MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + + // Add a label to mark the beginning of the landing pad. Deletion of the + // landing pad can thus be detected via the MachineModuleInfo. + unsigned LabelID = MMI->addLandingPad(CurMBB); + DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, DAG.getEntryNode(), + DAG.getConstant(LabelID, MVT::i32))); + + // Mark exception register as live in. + const MRegisterInfo *MRI = DAG.getTarget().getRegisterInfo(); + unsigned Reg = MRI->getEHExceptionRegister(); + if (Reg) CurMBB->addLiveIn(Reg); + + // Insert the EXCEPTIONADDR instruction. + SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); + SDOperand Ops[1]; + Ops[0] = DAG.getRoot(); + SDOperand Op = DAG.getNode(ISD::EXCEPTIONADDR, VTs, Ops, 1); + setValue(&I, Op); + DAG.setRoot(Op.getValue(1)); + + return 0; + } + + case Intrinsic::eh_handlers: { + MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + + // Inform the MachineModuleInfo of the personality for this landing pad. + if (ConstantExpr *CE = dyn_cast(I.getOperand(2))) { + if (CE->getOpcode() == Instruction::BitCast) { + MMI->addPersonality(CurMBB, + cast(CE->getOperand(0))); + } + } + + // Gather all the type infos for this landing pad and pass them along to + // MachineModuleInfo. + std::vector TyInfo; + for (unsigned i = 3, N = I.getNumOperands(); i < N; ++i) { + if (ConstantExpr *CE = dyn_cast(I.getOperand(i))) { + if (CE->getOpcode() == Instruction::BitCast) { + TyInfo.push_back(cast(CE->getOperand(0))); + continue; + } + } + + TyInfo.push_back(NULL); + } + MMI->addCatchTypeInfo(CurMBB, TyInfo); + + // Mark exception selector register as live in. + const MRegisterInfo *MRI = DAG.getTarget().getRegisterInfo(); + unsigned Reg = MRI->getEHHandlerRegister(); + if (Reg) CurMBB->addLiveIn(Reg); + + // Insert the EHSELECTION instruction. + SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); + SDOperand Ops[2]; + Ops[0] = getValue(I.getOperand(1)); + Ops[1] = getRoot(); + SDOperand Op = DAG.getNode(ISD::EHSELECTION, VTs, Ops, 2); + setValue(&I, Op); + DAG.setRoot(Op.getValue(1)); + + return 0; + } + + case Intrinsic::eh_typeid_for: { + GlobalVariable *GV = NULL; + + // Find the type id for the given typeinfo. + MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + if (ConstantExpr *CE = dyn_cast(I.getOperand(1))) { + if (CE->getOpcode() == Instruction::BitCast) { + GV = cast(CE->getOperand(0)); + } + } + + unsigned TypeID = MMI->getTypeIDFor(GV); + setValue(&I, DAG.getConstant(TypeID, MVT::i32)); + + return 0; + } + case Intrinsic::sqrt_f32: case Intrinsic::sqrt_f64: setValue(&I, DAG.getNode(ISD::FSQRT, From jlaskey at apple.com Wed Feb 21 16:55:21 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:21 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200702212255.l1LMtLY7025717@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.94 -> 1.95 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+9 -1) MRegisterInfo.h | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.94 llvm/include/llvm/Target/MRegisterInfo.h:1.95 --- llvm/include/llvm/Target/MRegisterInfo.h:1.94 Mon Feb 19 15:49:53 2007 +++ llvm/include/llvm/Target/MRegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -469,7 +469,15 @@ /// getRARegister - This method should return the register where the return /// address can be found. virtual unsigned getRARegister() const = 0; - + + /// getEHExceptionRegister - This method should return the register containing + /// the address of the exception info on entry to a landing pad. + virtual unsigned getEHExceptionRegister() const = 0; + + /// getEHHandlerRegister - This method should return the register containing + /// the switch table selection on entry to an landing pad. + virtual unsigned getEHHandlerRegister() const = 0; + /// getLocation - This method should return the actual location of a frame /// variable given the frame index. The location is returned in ML. /// Subclasses should override this method for special handling of frame From jlaskey at apple.com Wed Feb 21 16:55:21 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp SparcRegisterInfo.cpp SparcRegisterInfo.h Message-ID: <200702212255.l1LMtLpr025726@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcISelDAGToDAG.cpp updated: 1.119 -> 1.120 SparcRegisterInfo.cpp updated: 1.54 -> 1.55 SparcRegisterInfo.h updated: 1.20 -> 1.21 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+17 -0) SparcISelDAGToDAG.cpp | 3 +++ SparcRegisterInfo.cpp | 10 ++++++++++ SparcRegisterInfo.h | 4 ++++ 3 files changed, 17 insertions(+) Index: llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp diff -u llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp:1.119 llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp:1.120 --- llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp:1.119 Mon Jan 29 16:58:52 2007 +++ llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp Wed Feb 21 16:54:50 2007 @@ -871,6 +871,9 @@ // Frame & Return address. Currently unimplemented case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; + // Exception address and exception selector. Currently unimplemented. + case ISD::EXCEPTIONADDR: break; + case ISD::EHSELECTION: break; } return SDOperand(); } Index: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.54 llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.55 --- llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.54 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Wed Feb 21 16:54:50 2007 @@ -250,5 +250,15 @@ return SP::G1; } +unsigned SparcRegisterInfo::getEHExceptionRegister() const { + assert(0 && "What is the exception register"); + return 0; +} + +unsigned SparcRegisterInfo::getEHHandlerRegister() const { + assert(0 && "What is the exception handler register"); + return 0; +} + #include "SparcGenRegisterInfo.inc" Index: llvm/lib/Target/Sparc/SparcRegisterInfo.h diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.20 llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.21 --- llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.20 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -70,6 +70,10 @@ // Debug information queries. unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; + + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; }; } // end namespace llvm From jlaskey at apple.com Wed Feb 21 16:55:22 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86RegisterInfo.cpp X86RegisterInfo.h Message-ID: <200702212255.l1LMtMm0025741@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.321 -> 1.322 X86RegisterInfo.cpp updated: 1.203 -> 1.204 X86RegisterInfo.h updated: 1.48 -> 1.49 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+18 -0) X86ISelLowering.cpp | 4 ++++ X86RegisterInfo.cpp | 10 ++++++++++ X86RegisterInfo.h | 4 ++++ 3 files changed, 18 insertions(+) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.321 llvm/lib/Target/X86/X86ISelLowering.cpp:1.322 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.321 Wed Feb 21 15:18:14 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Wed Feb 21 16:54:50 2007 @@ -4675,7 +4675,11 @@ case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG); case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG); case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG); + // Exception address and exception selector. Currently unimplemented. + case ISD::EXCEPTIONADDR: break; + case ISD::EHSELECTION: break; } + return SDOperand(); } const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const { Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.203 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.204 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.203 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Wed Feb 21 16:54:50 2007 @@ -1193,6 +1193,16 @@ Moves.push_back(MachineMove(0, Dst, Src)); } +unsigned X86RegisterInfo::getEHExceptionRegister() const { + assert(0 && "What is the exception register"); + return 0; +} + +unsigned X86RegisterInfo::getEHHandlerRegister() const { + assert(0 && "What is the exception handler register"); + return 0; +} + namespace llvm { unsigned getX86SubSuperRegister(unsigned Reg, MVT::ValueType VT, bool High) { switch (VT) { Index: llvm/lib/Target/X86/X86RegisterInfo.h diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.48 llvm/lib/Target/X86/X86RegisterInfo.h:1.49 --- llvm/lib/Target/X86/X86RegisterInfo.h:1.48 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/X86/X86RegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -101,6 +101,10 @@ unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; void getInitialFrameState(std::vector &Moves) const; + + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; }; // getX86SubSuperRegister - X86 utility function. It returns the sub or super From jlaskey at apple.com Wed Feb 21 16:55:22 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelLowering.cpp IA64RegisterInfo.cpp IA64RegisterInfo.h Message-ID: <200702212255.l1LMtMBh025739@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelLowering.cpp updated: 1.53 -> 1.54 IA64RegisterInfo.cpp updated: 1.31 -> 1.32 IA64RegisterInfo.h updated: 1.14 -> 1.15 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+17 -0) IA64ISelLowering.cpp | 3 +++ IA64RegisterInfo.cpp | 10 ++++++++++ IA64RegisterInfo.h | 4 ++++ 3 files changed, 17 insertions(+) Index: llvm/lib/Target/IA64/IA64ISelLowering.cpp diff -u llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.53 llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.54 --- llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.53 Mon Jan 29 16:58:52 2007 +++ llvm/lib/Target/IA64/IA64ISelLowering.cpp Wed Feb 21 16:54:50 2007 @@ -590,6 +590,9 @@ // Frame & Return address. Currently unimplemented case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; + // Exception address and exception selector. Currently unimplemented. + case ISD::EXCEPTIONADDR: break; + case ISD::EHSELECTION: break; } return SDOperand(); } Index: llvm/lib/Target/IA64/IA64RegisterInfo.cpp diff -u llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.31 llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.32 --- llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.31 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/IA64/IA64RegisterInfo.cpp Wed Feb 21 16:54:50 2007 @@ -360,5 +360,15 @@ return hasFP(MF) ? IA64::r5 : IA64::r12; } +unsigned IA64RegisterInfo::getEHExceptionRegister() const { + assert(0 && "What is the exception register"); + return 0; +} + +unsigned IA64RegisterInfo::getEHHandlerRegister() const { + assert(0 && "What is the exception handler register"); + return 0; +} + #include "IA64GenRegisterInfo.inc" Index: llvm/lib/Target/IA64/IA64RegisterInfo.h diff -u llvm/lib/Target/IA64/IA64RegisterInfo.h:1.14 llvm/lib/Target/IA64/IA64RegisterInfo.h:1.15 --- llvm/lib/Target/IA64/IA64RegisterInfo.h:1.14 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/IA64/IA64RegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -64,6 +64,10 @@ // Debug information queries. unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; + + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; }; } // End llvm namespace From jlaskey at apple.com Wed Feb 21 16:55:22 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelLowering.cpp ARMRegisterInfo.cpp ARMRegisterInfo.h Message-ID: <200702212255.l1LMtMIu025767@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMISelLowering.cpp updated: 1.14 -> 1.15 ARMRegisterInfo.cpp updated: 1.69 -> 1.70 ARMRegisterInfo.h updated: 1.10 -> 1.11 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+17 -0) ARMISelLowering.cpp | 3 +++ ARMRegisterInfo.cpp | 10 ++++++++++ ARMRegisterInfo.h | 4 ++++ 3 files changed, 17 insertions(+) Index: llvm/lib/Target/ARM/ARMISelLowering.cpp diff -u llvm/lib/Target/ARM/ARMISelLowering.cpp:1.14 llvm/lib/Target/ARM/ARMISelLowering.cpp:1.15 --- llvm/lib/Target/ARM/ARMISelLowering.cpp:1.14 Tue Feb 13 08:07:13 2007 +++ llvm/lib/Target/ARM/ARMISelLowering.cpp Wed Feb 21 16:54:50 2007 @@ -1190,6 +1190,9 @@ return LowerFORMAL_ARGUMENTS(Op, DAG); case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; + // Exception address and exception selector. Currently unimplemented. + case ISD::EXCEPTIONADDR: break; + case ISD::EHSELECTION: break; } return SDOperand(); } Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.69 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.70 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.69 Mon Feb 19 15:49:53 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Wed Feb 21 16:54:50 2007 @@ -1287,5 +1287,15 @@ return STI.useThumbBacktraces() ? ARM::R7 : ARM::R11; } +unsigned ARMRegisterInfo::getEHExceptionRegister() const { + assert(0 && "What is the exception register"); + return 0; +} + +unsigned ARMRegisterInfo::getEHHandlerRegister() const { + assert(0 && "What is the exception handler register"); + return 0; +} + #include "ARMGenRegisterInfo.inc" Index: llvm/lib/Target/ARM/ARMRegisterInfo.h diff -u llvm/lib/Target/ARM/ARMRegisterInfo.h:1.10 llvm/lib/Target/ARM/ARMRegisterInfo.h:1.11 --- llvm/lib/Target/ARM/ARMRegisterInfo.h:1.10 Mon Feb 19 15:49:53 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -85,6 +85,10 @@ // Debug information queries. unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; + + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; }; } // end namespace llvm From jlaskey at apple.com Wed Feb 21 16:55:22 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp PPCRegisterInfo.cpp PPCRegisterInfo.h Message-ID: <200702212255.l1LMtMrj025757@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.251 -> 1.252 PPCRegisterInfo.cpp updated: 1.108 -> 1.109 PPCRegisterInfo.h updated: 1.27 -> 1.28 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+40 -1) PPCISelLowering.cpp | 28 ++++++++++++++++++++++++++++ PPCRegisterInfo.cpp | 9 ++++++++- PPCRegisterInfo.h | 4 ++++ 3 files changed, 40 insertions(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.251 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.252 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.251 Sat Feb 17 00:57:26 2007 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Wed Feb 21 16:54:50 2007 @@ -2610,6 +2610,30 @@ } } +/// LowerEXCEPTIONADDR - Replace EXCEPTIONADDR with a copy from the exception +/// register. The register was made live in the ISel. +static SDOperand LowerEXCEPTIONADDR(SDOperand Op, SelectionDAG &DAG) { + const MRegisterInfo *MRI = DAG.getTargetLoweringInfo(). + getTargetMachine(). + getRegisterInfo(); + MVT::ValueType VT = Op.Val->getValueType(0); + unsigned Reg = MRI->getEHExceptionRegister(); + SDOperand Result = DAG.getCopyFromReg(Op.getOperand(0), Reg, VT); + return Result.getValue(Op.ResNo); +} + +/// LowerEXCEPTIONADDR - Replace EHSELECTION with a copy from the exception +/// selection register. The register was made live in the ISel. +static SDOperand LowerEHSELECTION(SDOperand Op, SelectionDAG &DAG) { + const MRegisterInfo *MRI = DAG.getTargetLoweringInfo(). + getTargetMachine(). + getRegisterInfo(); + MVT::ValueType VT = Op.Val->getValueType(0); + unsigned Reg = MRI->getEHHandlerRegister(); + SDOperand Result = DAG.getCopyFromReg(Op.getOperand(1), Reg, VT); + return Result.getValue(Op.ResNo); +} + /// LowerOperation - Provide custom lowering hooks for some operations. /// SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) { @@ -2647,6 +2671,10 @@ // Frame & Return address. Currently unimplemented case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; + + // Exception address and exception selector. + case ISD::EXCEPTIONADDR: return LowerEXCEPTIONADDR(Op, DAG); + case ISD::EHSELECTION: return LowerEHSELECTION(Op, DAG); } return SDOperand(); } Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.109 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Feb 21 16:54:50 2007 @@ -1022,7 +1022,6 @@ unsigned PPCRegisterInfo::getRARegister() const { return !Subtarget.isPPC64() ? PPC::LR : PPC::LR8; - } unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const { @@ -1040,5 +1039,13 @@ Moves.push_back(MachineMove(0, Dst, Src)); } +unsigned PPCRegisterInfo::getEHExceptionRegister() const { + return !Subtarget.isPPC64() ? PPC::R3 : PPC::X3; +} + +unsigned PPCRegisterInfo::getEHHandlerRegister() const { + return !Subtarget.isPPC64() ? PPC::R4 : PPC::X4; +} + #include "PPCGenRegisterInfo.inc" Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27 llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.28 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -89,6 +89,10 @@ unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; void getInitialFrameState(std::vector &Moves) const; + + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; }; } // end namespace llvm From jlaskey at apple.com Wed Feb 21 16:55:22 2007 From: jlaskey at apple.com (Jim Laskey) Date: Wed, 21 Feb 2007 16:55:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelLowering.cpp AlphaRegisterInfo.cpp AlphaRegisterInfo.h Message-ID: <200702212255.l1LMtM2x025759@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelLowering.cpp updated: 1.81 -> 1.82 AlphaRegisterInfo.cpp updated: 1.60 -> 1.61 AlphaRegisterInfo.h updated: 1.20 -> 1.21 --- Log message: Support to provide exception and selector registers. --- Diffs of the changes: (+18 -1) AlphaISelLowering.cpp | 5 ++++- AlphaRegisterInfo.cpp | 10 ++++++++++ AlphaRegisterInfo.h | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaISelLowering.cpp diff -u llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.81 llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.82 --- llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.81 Thu Feb 8 11:37:41 2007 +++ llvm/lib/Target/Alpha/AlphaISelLowering.cpp Wed Feb 21 16:54:50 2007 @@ -548,8 +548,11 @@ return DAG.getNode(AlphaISD::GlobalRetAddr, MVT::i64); //FIXME: implement case ISD::FRAMEADDR: break; + // Exception address and exception selector. Currently unimplemented. + case ISD::EXCEPTIONADDR: break; + case ISD::EHSELECTION: break; } - + return SDOperand(); } Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.60 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.61 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.60 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Wed Feb 21 16:54:50 2007 @@ -399,6 +399,16 @@ return hasFP(MF) ? Alpha::R15 : Alpha::R30; } +unsigned AlphaRegisterInfo::getEHExceptionRegister() const { + assert(0 && "What is the exception register"); + return 0; +} + +unsigned AlphaRegisterInfo::getEHHandlerRegister() const { + assert(0 && "What is the exception handler register"); + return 0; +} + #include "AlphaGenRegisterInfo.inc" std::string AlphaRegisterInfo::getPrettyName(unsigned reg) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.h diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.20 llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.21 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.20 Mon Feb 19 15:49:54 2007 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.h Wed Feb 21 16:54:50 2007 @@ -68,6 +68,10 @@ unsigned getRARegister() const; unsigned getFrameRegister(MachineFunction &MF) const; + // Exception handling queries. + unsigned getEHExceptionRegister() const; + unsigned getEHHandlerRegister() const; + static std::string getPrettyName(unsigned reg); }; From evan.cheng at apple.com Wed Feb 21 18:17:52 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 21 Feb 2007 16:17:52 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h In-Reply-To: <200702212240.l1LMe8as025203@zion.cs.uiuc.edu> References: <200702212240.l1LMe8as025203@zion.cs.uiuc.edu> Message-ID: On Feb 21, 2007, at 2:40 PM, Jim Laskey wrote: > + > + /// IsLandingPad - Indicate that this basic block is entered via an > + /// exception handler. > + bool IsLandingPad; Since you are touching this... :-) Seems to me there is a way to reorganize the fields within MachineBasicBlock to save some space (not to mention putting them in a more "sensible" order). Can we steal a bit from the "Number" field to indicate isLandingPad? Evan > > public: > MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), > BB(bb), > - Number(-1), Parent > (0) { > + Number(-1), Parent > (0), > + IsLandingPad(false) { > Insts.parent = this; > } > > @@ -152,6 +157,18 @@ > const_livein_iterator livein_end() const { return LiveIns.end > (); } > bool livein_empty() const { return LiveIns.empty(); } > > + /// isLandingPad - Returns true if the block is a landing pad. > That is > + /// this basic block is entered via an exception handler. > + bool isLandingPad() const { return IsLandingPad; } > + > + /// setIsLandingPad - Indicates the block is a landing pad. > That is > + /// this basic block is entered via an exception handler. > + void setIsLandingPad() { IsLandingPad = true; } > + > + /// isAccessable - Returns true if the block is alive. That is, > if it has > + /// predecessors or is an eh landing pad. > + bool isAccessable() const { return !pred_empty() || isLandingPad > (); } > + > // Code Layout methods. > > /// moveBefore/moveAfter - move 'this' block before or after the > specified > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From reid at x10sys.com Wed Feb 21 18:22:23 2007 From: reid at x10sys.com (Reid Spencer) Date: Wed, 21 Feb 2007 18:22:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702220022.l1M0MNYI027321@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.29 -> 1.30 --- Log message: Fix countLeadingZeros in the case that the bitwidth evenly divides the word size. This fixes all reads of uninitialized data (buffer over read) and makes APInt.cpp memory clean, per valgrind. The only remaining problem is division in a few cases. --- Diffs of the changes: (+4 -1) APInt.cpp | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.29 llvm/lib/Support/APInt.cpp:1.30 --- llvm/lib/Support/APInt.cpp:1.29 Wed Feb 21 02:21:52 2007 +++ llvm/lib/Support/APInt.cpp Wed Feb 21 18:22:00 2007 @@ -726,7 +726,10 @@ } } } - return Count - (APINT_BITS_PER_WORD - (BitWidth % APINT_BITS_PER_WORD)); + uint32_t remainder = BitWidth % APINT_BITS_PER_WORD; + if (remainder) + Count -= APINT_BITS_PER_WORD - remainder; + return Count; } /// countTrailingZeros - This function is a APInt version corresponding to From reid at x10sys.com Wed Feb 21 18:59:01 2007 From: reid at x10sys.com (Reid Spencer) Date: Wed, 21 Feb 2007 18:59:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702220059.l1M0x15L028265@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.30 -> 1.31 --- Log message: When converting from 64 to 32-bits, use the actual number of words to extract the value, not the number of words implied by the active bits. This fixes numerous, but not all divide bugs. --- Diffs of the changes: (+2 -2) APInt.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.30 llvm/lib/Support/APInt.cpp:1.31 --- llvm/lib/Support/APInt.cpp:1.30 Wed Feb 21 18:22:00 2007 +++ llvm/lib/Support/APInt.cpp Wed Feb 21 18:58:45 2007 @@ -1177,7 +1177,7 @@ uint32_t *U = new uint32_t[m + n + 1]; memset(U, 0, (m+n+1)*sizeof(uint32_t)); for (unsigned i = 0; i < lhsWords; ++i) { - uint64_t tmp = (lhsWords == 1 ? LHS.VAL : LHS.pVal[i]); + uint64_t tmp = (LHS.getNumWords() == 1 ? LHS.VAL : LHS.pVal[i]); U[i * 2] = tmp & mask; U[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); } @@ -1186,7 +1186,7 @@ uint32_t *V = new uint32_t[n]; memset(V, 0, (n)*sizeof(uint32_t)); for (unsigned i = 0; i < rhsWords; ++i) { - uint64_t tmp = (rhsWords == 1 ? RHS.VAL : RHS.pVal[i]); + uint64_t tmp = (RHS.getNumWords() == 1 ? RHS.VAL : RHS.pVal[i]); V[i * 2] = tmp & mask; V[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); } From reid at x10sys.com Wed Feb 21 19:03:29 2007 From: reid at x10sys.com (Reid Spencer) Date: Wed, 21 Feb 2007 19:03:29 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Message-ID: <200702220103.l1M13TdN028402@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt: gptest.cpp updated: 1.2 -> 1.3 --- Log message: Don't invoke gp with the --test flag, it causes the output lines to wrap and that causes false positives. --- Diffs of the changes: (+13 -6) gptest.cpp | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.2 llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.3 --- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.2 Wed Feb 21 02:28:20 2007 +++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Wed Feb 21 19:03:12 2007 @@ -182,7 +182,7 @@ } /* function executed by the user-interacting process. */ -void test_driver(int input_pipe[], int output_pipe[]) { +void test_driver(int low, int high, int input_pipe[], int output_pipe[]) { int c; /* user input - must be 'int', to recognize EOF (= -1). */ char ch; /* the same - as a char. */ @@ -203,7 +203,7 @@ srand(0); // Start loop over the range of bits of interest - for (unsigned bits = 1; bits <= 1024; bits++) { + for (int bits = low; bits <= high; bits++) { // Indicate which test case we are running printf("\nTEST CASE: %d BITS\n", bits); fflush(stdout); @@ -270,8 +270,7 @@ // exec gp with modes: // --quiet (don't print banner), // --fast (don't read init files) - // --test (no history, wrap long lines) - execlp("gp", "gp", "--quiet", "--fast", "--test", (char*)NULL); + execlp("gp", "gp", "--quiet", "--fast", (char*)NULL); perror("execlp"); exit(1); } @@ -285,6 +284,14 @@ int translator_to_user[2]; int pid; /* pid of child process, or 0, as returned via fork. */ int rc; /* stores return values of various routines. */ + int low_bit = 1; + int high_bit = 1024; + + // Get the arguments + if (argc > 2) { + low_bit = atoi(argv[1]); + high_bit = atoi(argv[2]); + } /* first, create one pipe. */ rc = pipe(user_to_translator); @@ -307,10 +314,10 @@ perror("main: fork"); exit(1); case 0: /* inside child process. */ - calculator(user_to_translator, translator_to_user); /* line 'A' */ + calculator(user_to_translator, translator_to_user); /* NOT REACHED */ default: /* inside parent process. */ - test_driver(translator_to_user, user_to_translator); /* line 'B' */ + test_driver(low_bit, high_bit, translator_to_user, user_to_translator); /* NOT REACHED */ } From clattner at apple.com Wed Feb 21 21:28:55 2007 From: clattner at apple.com (clattner at apple.com) Date: Wed, 21 Feb 2007 19:28:55 -0800 (PST) Subject: [llvm-commits] [124166] writable strings shouldn't be cached. Message-ID: <20070222032855.C403D5B2AD2E@src> Revision: 124166 Author: clattner Date: 2007-02-21 19:28:53 -0800 (Wed, 21 Feb 2007) Log Message: ----------- writable strings shouldn't be cached. Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-convert.cpp Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-22 01:53:25 UTC (rev 124165) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-22 03:28:53 UTC (rev 124166) @@ -5229,16 +5229,18 @@ Constant *TreeConstantToLLVM::EmitLV_STRING_CST(tree exp) { Constant *Init = TreeConstantToLLVM::ConvertSTRING_CST(exp); - - // Cache the string constants to avoid making obvious duplicate strings that - // have to be folded by the optimizer. - static std::map StringCSTCache; - GlobalVariable *&Slot = StringCSTCache[Init]; - if (Slot) return Slot; - + // Support -fwritable-strings. bool StringIsConstant = !flag_writable_strings; - + + if (StringIsConstant) { + // Cache the string constants to avoid making obvious duplicate strings that + // have to be folded by the optimizer. + static std::map StringCSTCache; + GlobalVariable *&Slot = StringCSTCache[Init]; + if (Slot) return Slot; + } + // Create a new string global. return Slot = new GlobalVariable(Init->getType(), StringIsConstant, GlobalVariable::InternalLinkage, From clattner at apple.com Wed Feb 21 22:26:08 2007 From: clattner at apple.com (clattner at apple.com) Date: Wed, 21 Feb 2007 20:26:08 -0800 (PST) Subject: [llvm-commits] [124167] refactor Message-ID: <20070222042608.F1A6E5B3BCBD@src> Revision: 124167 Author: clattner Date: 2007-02-21 20:26:05 -0800 (Wed, 21 Feb 2007) Log Message: ----------- refactor Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-convert.cpp Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-22 03:28:53 UTC (rev 124166) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-22 04:26:05 UTC (rev 124167) @@ -5233,18 +5233,23 @@ // Support -fwritable-strings. bool StringIsConstant = !flag_writable_strings; + GlobalVariable **SlotP = 0; + if (StringIsConstant) { // Cache the string constants to avoid making obvious duplicate strings that // have to be folded by the optimizer. static std::map StringCSTCache; GlobalVariable *&Slot = StringCSTCache[Init]; if (Slot) return Slot; + SlotP = &Slot; } // Create a new string global. - return Slot = new GlobalVariable(Init->getType(), StringIsConstant, - GlobalVariable::InternalLinkage, - Init, "str", TheModule); + GlobalVariable *GV = new GlobalVariable(Init->getType(), StringIsConstant, + GlobalVariable::InternalLinkage, + Init, "str", TheModule); + if (SlotP) *SlotP = GV; + return GV; } Constant *TreeConstantToLLVM::EmitLV_ARRAY_REF(tree exp) { From clattner at apple.com Wed Feb 21 23:47:26 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 21 Feb 2007 21:47:26 -0800 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp PPCRegisterInfo.cpp PPCRegisterInfo.h In-Reply-To: <200702212255.l1LMtMrj025757@zion.cs.uiuc.edu> References: <200702212255.l1LMtMrj025757@zion.cs.uiuc.edu> Message-ID: > Support to provide exception and selector registers. Hey Jim, This behavior: > +/// LowerEXCEPTIONADDR - Replace EXCEPTIONADDR with a copy from > the exception > +/// register. The register was made live in the ISel. > +static SDOperand LowerEXCEPTIONADDR(SDOperand Op, SelectionDAG > &DAG) { > + const MRegisterInfo *MRI = DAG.getTargetLoweringInfo(). > + getTargetMachine(). > + getRegisterInfo(); > + MVT::ValueType VT = Op.Val->getValueType(0); > + unsigned Reg = MRI->getEHExceptionRegister(); > + SDOperand Result = DAG.getCopyFromReg(Op.getOperand(0), Reg, VT); > + return Result.getValue(Op.ResNo); > +} Is almost certainly guaranteed to work for other targets as well (not just PPC). Can you change this code so that Legalize has this code, and invokes it when the target requests that "EXCEPTIONADDR" be expanded? Right now, all non-ppc targets abort when this happens, which isn't very nice. Please just have them lower to returning something stupid but that will compile correctly (like return a constant zero) if MRI- >getEHExceptionRegister() returns 0. With these changes, you should be able to remove the code you added to each target. -Chris > + > +/// LowerEXCEPTIONADDR - Replace EHSELECTION with a copy from the > exception > +/// selection register. The register was made live in the ISel. > +static SDOperand LowerEHSELECTION(SDOperand Op, SelectionDAG &DAG) { > + const MRegisterInfo *MRI = DAG.getTargetLoweringInfo(). > + getTargetMachine(). > + getRegisterInfo(); > + MVT::ValueType VT = Op.Val->getValueType(0); > + unsigned Reg = MRI->getEHHandlerRegister(); > + SDOperand Result = DAG.getCopyFromReg(Op.getOperand(1), Reg, VT); > + return Result.getValue(Op.ResNo); > +} > + > /// LowerOperation - Provide custom lowering hooks for some > operations. > /// > SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, > SelectionDAG &DAG) { > @@ -2647,6 +2671,10 @@ > // Frame & Return address. Currently unimplemented > case ISD::RETURNADDR: break; > case ISD::FRAMEADDR: break; > + > + // Exception address and exception selector. > + case ISD::EXCEPTIONADDR: return LowerEXCEPTIONADDR(Op, DAG); > + case ISD::EHSELECTION: return LowerEHSELECTION(Op, DAG); > } > return SDOperand(); > } > > > Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp > diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108 llvm/lib/ > Target/PowerPC/PPCRegisterInfo.cpp:1.109 > --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108 Mon Feb 19 > 15:49:54 2007 > +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Wed Feb 21 16:54:50 > 2007 > @@ -1022,7 +1022,6 @@ > > unsigned PPCRegisterInfo::getRARegister() const { > return !Subtarget.isPPC64() ? PPC::LR : PPC::LR8; > - > } > > unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) > const { > @@ -1040,5 +1039,13 @@ > Moves.push_back(MachineMove(0, Dst, Src)); > } > > +unsigned PPCRegisterInfo::getEHExceptionRegister() const { > + return !Subtarget.isPPC64() ? PPC::R3 : PPC::X3; > +} > + > +unsigned PPCRegisterInfo::getEHHandlerRegister() const { > + return !Subtarget.isPPC64() ? PPC::R4 : PPC::X4; > +} > + > #include "PPCGenRegisterInfo.inc" > > > > Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h > diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27 llvm/lib/ > Target/PowerPC/PPCRegisterInfo.h:1.28 > --- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27 Mon Feb 19 > 15:49:54 2007 > +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Wed Feb 21 16:54:50 2007 > @@ -89,6 +89,10 @@ > unsigned getRARegister() const; > unsigned getFrameRegister(MachineFunction &MF) const; > void getInitialFrameState(std::vector &Moves) const; > + > + // Exception handling queries. > + unsigned getEHExceptionRegister() const; > + unsigned getEHHandlerRegister() const; > }; > > } // end namespace llvm > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Thu Feb 22 00:04:45 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 21 Feb 2007 22:04:45 -0800 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.td In-Reply-To: <200702212236.l1LMaEQ7025098@zion.cs.uiuc.edu> References: <200702212236.l1LMaEQ7025098@zion.cs.uiuc.edu> Message-ID: > Intrinsics.td updated: 1.46 -> 1.47 > --- > Log message: > > Add new intrinsics for eh support. Please make sure to document the eh intrinsics in LangRef.html, -Chris > --- > Diffs of the changes: (+3 -1) > > Intrinsics.td | 4 +++- > 1 files changed, 3 insertions(+), 1 deletion(-) > > > Index: llvm/include/llvm/Intrinsics.td > diff -u llvm/include/llvm/Intrinsics.td:1.46 llvm/include/llvm/ > Intrinsics.td:1.47 > --- llvm/include/llvm/Intrinsics.td:1.46 Wed Feb 14 20:26:09 2007 > +++ llvm/include/llvm/Intrinsics.td Wed Feb 21 16:35:57 2007 > @@ -232,7 +232,9 @@ > //===------------------ Exception Handling > Intrinsics----------------------===// > // > def int_eh_exception : Intrinsic<[llvm_ptr_ty]>; > -def int_eh_handlers : Intrinsic<[llvm_i32_ty, llvm_ptr_ty, > llvm_vararg_ty]>; > +def int_eh_handlers : Intrinsic<[llvm_i32_ty, llvm_ptr_ty, > llvm_ptr_ty, > + llvm_vararg_ty]>; > +def int_eh_typeid_for : Intrinsic<[llvm_i32_ty, llvm_ptr_ty]>; > > // > ===------------------------------------------------------------------- > ---===// > // Target-specific intrinsics > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Thu Feb 22 00:33:40 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 22 Feb 2007 00:33:40 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702220633.l1M6XeG0001682@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.34 -> 1.35 --- Log message: clarify llvm-gcc GPL issue --- Diffs of the changes: (+6 -6) DeveloperPolicy.html | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.34 llvm/docs/DeveloperPolicy.html:1.35 --- llvm/docs/DeveloperPolicy.html:1.34 Mon Feb 19 12:32:40 2007 +++ llvm/docs/DeveloperPolicy.html Thu Feb 22 00:33:23 2007 @@ -442,13 +442,13 @@ read the License if further clarification is needed.

    -

    Note that the LLVM Project does distribute some code that includes GPL - software (notably, llvm-gcc which is based on the GCC GPL source base). +

    Note that the LLVM Project does distribute llvm-gcc, which is GPL. This means that anything "linked" into llvm-gcc must itself be compatible with the GPL, and must be releasable under the terms of the GPL. This implies - that any code linked into llvm-gcc and distributed to others may be - subject to - the viral aspects of the GPL. This is not a problem for the main LLVM + that any code linked into llvm-gcc and distributed to others may be subject + to the viral aspects of the GPL (for example, a proprietary code generator + linked into llvm-gcc must be made available under + the GPL). This is not a problem for the main LLVM distribution (which is already licensed under a more liberal license), but may be a problem if you intend to base commercial development on llvm-gcc without redistributing your source code.

    @@ -499,7 +499,7 @@ Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/19 18:32:40 $ + Last modified: $Date: 2007/02/22 06:33:23 $ From me22.ca at gmail.com Thu Feb 22 00:41:24 2007 From: me22.ca at gmail.com (me22) Date: Thu, 22 Feb 2007 01:41:24 -0500 Subject: [llvm-commits] Patch for strict alias warning in Support/Allocator.cpp Message-ID: I only saw 3 warnings compiling llvm, 2 of which looked like flex's fault, so it made me want to fix the other one: Allocator.cpp: In member function 'void* llvm::BumpPtrAllocator::Allocate(unsigned int, unsigned int)': Allocator.cpp:96: warning: dereferencing type-punned pointer will break strict-aliasing rules I'm not convinced it actually broke aliasing rules, but it's a fairly trivial fix that simplifies the code, so it seems worth it. Only possible drawback is that it (opaquely) exposes MemRegion, but that identifier is used nowhere else in llvm at the moment. HTH, Scott McMurray -------------- next part -------------- A non-text attachment was scrubbed... Name: fix_aliasing_warning_in_Allocator.patch Type: text/x-patch Size: 2972 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20070222/13f47ee9/attachment.bin From dpatel at apple.com Thu Feb 22 02:56:34 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 02:56:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702220856.l1M8uY70013251@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp added (r1.1) --- Log message: Add Loop Pass Manager. --- Diffs of the changes: (+69 -0) LoopPass.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+) Index: llvm/lib/Analysis/LoopPass.cpp diff -c /dev/null llvm/lib/Analysis/LoopPass.cpp:1.1 *** /dev/null Thu Feb 22 02:56:27 2007 --- llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 02:56:17 2007 *************** *** 0 **** --- 1,69 ---- + //===- LoopPass.cpp - Loop Pass and Loop Pass Manager ---------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Devang Patel and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements LoopPass and LPPassManager. All loop optimization + // and transformation passes are derived from LoopPass. LPPassManager is + // responsible for managing LoopPasses. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Analysis/LoopPass.h" + using namespace llvm; + + //===----------------------------------------------------------------------===// + // LPPassManager + // + /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses. + + /// run - Execute all of the passes scheduled for execution. Keep track of + /// whether any of the passes modifies the function, and if so, return true. + bool LPPassManager::runOnFunction(Function &F) { + LoopInfo &LI = getAnalysis(); + bool Changed = false; + + std::string Msg1 = "Executing Pass '"; + std::string Msg3 = "' Made Modification '"; + + // Walk Loops + for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) { + + Loop *L = *I; + // Run all passes on current SCC + for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { + + Pass *P = getContainedPass(Index); + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + + std::string Msg2 = "' on Loop ...\n'"; + dumpPassInfo(P, Msg1, Msg2); + dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet()); + + initializeAnalysisImpl(P); + + StartPassTimer(P); + LoopPass *LP = dynamic_cast(P); + assert (LP && "Invalid LPPassManager member"); + LP->runOnLoop(*L, *this); + StopPassTimer(P); + + if (Changed) + dumpPassInfo(P, Msg3, Msg2); + dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet()); + + removeNotPreservedAnalysis(P); + recordAvailableAnalysis(P); + removeDeadPasses(P, Msg2); + } + } + + return Changed; + } + + From dpatel at apple.com Thu Feb 22 02:56:36 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 02:56:36 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h Message-ID: <200702220856.l1M8ua5c013257@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopPass.h added (r1.1) --- Log message: Add Loop Pass Manager. --- Diffs of the changes: (+86 -0) LoopPass.h | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 86 insertions(+) Index: llvm/include/llvm/Analysis/LoopPass.h diff -c /dev/null llvm/include/llvm/Analysis/LoopPass.h:1.1 *** /dev/null Thu Feb 22 02:56:27 2007 --- llvm/include/llvm/Analysis/LoopPass.h Thu Feb 22 02:56:17 2007 *************** *** 0 **** --- 1,86 ---- + //===- LoopPass.h - LoopPass class ----------------------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Devang Patel and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file defines LoopPass class. All loop optimization + // and transformation passes are derived from LoopPass. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_LOOP_PASS_H + #define LLVM_LOOP_PASS_H + + #include "llvm/Analysis/LoopInfo.h" + #include "llvm/Pass.h" + #include "llvm/PassManagers.h" + #include "llvm/Function.h" + + namespace llvm { + + class LPPassManager; + class Loop; + class Function; + + class LoopPass : public Pass { + + public: + // runOnLoop - THis method should be implemented by the subclass to perform + // whatever action is necessary for the specfied Loop. + virtual bool runOnLoop (Loop &L, LPPassManager &LPM) = 0; + virtual bool runOnFunctionBody (Function &F, LPPassManager &LPM) { + return false; + } + + }; + + class LPPassManager : public FunctionPass, public PMDataManager { + + public: + LPPassManager(int Depth) : PMDataManager(Depth) { } + + /// run - Execute all of the passes scheduled for execution. Keep track of + /// whether any of the passes modifies the module, and if so, return true. + bool runOnFunction(Function &F); + + /// Pass Manager itself does not invalidate any analysis info. + void getAnalysisUsage(AnalysisUsage &Info) const { + // LPPassManager needs LoopInfo. In the long term LoopInfo class will + // be consumed by LPPassManager. + Info.addRequired(); + Info.setPreservesAll(); + } + + virtual const char *getPassName() const { + return "Loop Pass Manager"; + } + + // Print passes managed by this manager + void dumpPassStructure(unsigned Offset) { + llvm::cerr << std::string(Offset*2, ' ') << "Loop Pass Manager\n"; + for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { + Pass *P = getContainedPass(Index); + P->dumpPassStructure(Offset + 1); + dumpLastUses(P, Offset+1); + } + } + + Pass *getContainedPass(unsigned N) { + assert ( N < PassVector.size() && "Pass number out of range!"); + Pass *FP = static_cast(PassVector[N]); + return FP; + } + + virtual PassManagerType getPassManagerType() { + return PMT_LoopPassManager; + } + + }; + + } // End llvm namespace + + #endif From baldrick at free.fr Thu Feb 22 04:25:03 2007 From: baldrick at free.fr (Duncan Sands) Date: Thu, 22 Feb 2007 11:25:03 +0100 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html In-Reply-To: <200702220633.l1M6XeG0001682@zion.cs.uiuc.edu> References: <200702220633.l1M6XeG0001682@zion.cs.uiuc.edu> Message-ID: <200702221125.03626.baldrick@free.fr> > + the GPL). This is not a problem for the main LLVM > distribution (which is already licensed under a more liberal license), but may > be a problem if you intend to base commercial development on llvm-gcc without > redistributing your source code.

    Maybe you should make explicit that there is no problem using llvm-gcc to compile proprietary code - there is only a problem if parts of llvm-gcc are included in the proprietary program. You do say that more or less a few lines before, but this last sentence could great doubt in peoples minds. Maybe you could offload the problem onto gcc, and say that compiling a program with llvm-gcc is like compiling it with gcc, and give a link to http://www.gnu.org/licenses/gpl-faq.html which discusses these issues. Ciao, Duncan. From jlaskey at apple.com Thu Feb 22 08:57:04 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:04 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp Message-ID: <200702221457.l1MEv4Bk029047@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcISelDAGToDAG.cpp updated: 1.120 -> 1.121 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+0 -3) SparcISelDAGToDAG.cpp | 3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp diff -u llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp:1.120 llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp:1.121 --- llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp:1.120 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/Sparc/SparcISelDAGToDAG.cpp Thu Feb 22 08:56:36 2007 @@ -871,9 +871,6 @@ // Frame & Return address. Currently unimplemented case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; - // Exception address and exception selector. Currently unimplemented. - case ISD::EXCEPTIONADDR: break; - case ISD::EHSELECTION: break; } return SDOperand(); } From jlaskey at apple.com Thu Feb 22 08:57:08 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:08 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200702221457.l1MEv8K6029053@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMISelLowering.cpp updated: 1.15 -> 1.16 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+0 -3) ARMISelLowering.cpp | 3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/Target/ARM/ARMISelLowering.cpp diff -u llvm/lib/Target/ARM/ARMISelLowering.cpp:1.15 llvm/lib/Target/ARM/ARMISelLowering.cpp:1.16 --- llvm/lib/Target/ARM/ARMISelLowering.cpp:1.15 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/ARM/ARMISelLowering.cpp Thu Feb 22 08:56:36 2007 @@ -1190,9 +1190,6 @@ return LowerFORMAL_ARGUMENTS(Op, DAG); case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; - // Exception address and exception selector. Currently unimplemented. - case ISD::EXCEPTIONADDR: break; - case ISD::EHSELECTION: break; } return SDOperand(); } From jlaskey at apple.com Thu Feb 22 08:57:09 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:09 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200702221457.l1MEv9DH029058@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.95 -> 1.96 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+0 -8) MRegisterInfo.h | 8 -------- 1 files changed, 8 deletions(-) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.95 llvm/include/llvm/Target/MRegisterInfo.h:1.96 --- llvm/include/llvm/Target/MRegisterInfo.h:1.95 Wed Feb 21 16:54:50 2007 +++ llvm/include/llvm/Target/MRegisterInfo.h Thu Feb 22 08:56:35 2007 @@ -470,14 +470,6 @@ /// address can be found. virtual unsigned getRARegister() const = 0; - /// getEHExceptionRegister - This method should return the register containing - /// the address of the exception info on entry to a landing pad. - virtual unsigned getEHExceptionRegister() const = 0; - - /// getEHHandlerRegister - This method should return the register containing - /// the switch table selection on entry to an landing pad. - virtual unsigned getEHHandlerRegister() const = 0; - /// getLocation - This method should return the actual location of a frame /// variable given the frame index. The location is returned in ML. /// Subclasses should override this method for special handling of frame From jlaskey at apple.com Thu Feb 22 08:57:09 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelLowering.cpp Message-ID: <200702221457.l1MEv9p6029063@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelLowering.cpp updated: 1.82 -> 1.83 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+0 -3) AlphaISelLowering.cpp | 3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelLowering.cpp diff -u llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.82 llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.83 --- llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.82 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/Alpha/AlphaISelLowering.cpp Thu Feb 22 08:56:36 2007 @@ -548,9 +548,6 @@ return DAG.getNode(AlphaISD::GlobalRetAddr, MVT::i64); //FIXME: implement case ISD::FRAMEADDR: break; - // Exception address and exception selector. Currently unimplemented. - case ISD::EXCEPTIONADDR: break; - case ISD::EHSELECTION: break; } return SDOperand(); From jlaskey at apple.com Thu Feb 22 08:57:10 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200702221457.l1MEvAuc029068@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.252 -> 1.253 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+15 -34) PPCISelLowering.cpp | 49 +++++++++++++++---------------------------------- 1 files changed, 15 insertions(+), 34 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.252 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.253 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.252 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Thu Feb 22 08:56:36 2007 @@ -140,14 +140,18 @@ // We cannot sextinreg(i1). Expand to shifts. setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); - - + // Support label based line numbers. setOperationAction(ISD::LOCATION, MVT::Other, Expand); setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand); - // FIXME - use subtarget debug flags - if (!TM.getSubtarget().isDarwin()) + if (!TM.getSubtarget().isDarwin()) { setOperationAction(ISD::LABEL, MVT::Other, Expand); + } else { + setOperationAction(ISD::EXCEPTIONADDR, MVT::i64, Expand); + setOperationAction(ISD::EHSELECTION, MVT::i64, Expand); + setOperationAction(ISD::EXCEPTIONADDR, MVT::i32, Expand); + setOperationAction(ISD::EHSELECTION, MVT::i32, Expand); + } // We want to legalize GlobalAddress and ConstantPool nodes into the // appropriate instructions to materialize the address. @@ -283,10 +287,15 @@ setShiftAmountType(MVT::i32); setSetCCResultContents(ZeroOrOneSetCCResult); - if (TM.getSubtarget().isPPC64()) + if (TM.getSubtarget().isPPC64()) { setStackPointerRegisterToSaveRestore(PPC::X1); - else + setExceptionPointerRegister(PPC::X3); + setExceptionSelectorRegister(PPC::X4); + } else { setStackPointerRegisterToSaveRestore(PPC::R1); + setExceptionPointerRegister(PPC::R3); + setExceptionSelectorRegister(PPC::R4); + } // We have target-specific dag combine patterns for the following nodes: setTargetDAGCombine(ISD::SINT_TO_FP); @@ -2610,30 +2619,6 @@ } } -/// LowerEXCEPTIONADDR - Replace EXCEPTIONADDR with a copy from the exception -/// register. The register was made live in the ISel. -static SDOperand LowerEXCEPTIONADDR(SDOperand Op, SelectionDAG &DAG) { - const MRegisterInfo *MRI = DAG.getTargetLoweringInfo(). - getTargetMachine(). - getRegisterInfo(); - MVT::ValueType VT = Op.Val->getValueType(0); - unsigned Reg = MRI->getEHExceptionRegister(); - SDOperand Result = DAG.getCopyFromReg(Op.getOperand(0), Reg, VT); - return Result.getValue(Op.ResNo); -} - -/// LowerEXCEPTIONADDR - Replace EHSELECTION with a copy from the exception -/// selection register. The register was made live in the ISel. -static SDOperand LowerEHSELECTION(SDOperand Op, SelectionDAG &DAG) { - const MRegisterInfo *MRI = DAG.getTargetLoweringInfo(). - getTargetMachine(). - getRegisterInfo(); - MVT::ValueType VT = Op.Val->getValueType(0); - unsigned Reg = MRI->getEHHandlerRegister(); - SDOperand Result = DAG.getCopyFromReg(Op.getOperand(1), Reg, VT); - return Result.getValue(Op.ResNo); -} - /// LowerOperation - Provide custom lowering hooks for some operations. /// SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) { @@ -2671,10 +2656,6 @@ // Frame & Return address. Currently unimplemented case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; - - // Exception address and exception selector. - case ISD::EXCEPTIONADDR: return LowerEXCEPTIONADDR(Op, DAG); - case ISD::EHSELECTION: return LowerEHSELECTION(Op, DAG); } return SDOperand(); } From jlaskey at apple.com Thu Feb 22 08:57:10 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702221457.l1MEvAdK029070@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.322 -> 1.323 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+0 -3) X86ISelLowering.cpp | 3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.322 llvm/lib/Target/X86/X86ISelLowering.cpp:1.323 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.322 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Thu Feb 22 08:56:36 2007 @@ -4675,9 +4675,6 @@ case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG); case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG); case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG); - // Exception address and exception selector. Currently unimplemented. - case ISD::EXCEPTIONADDR: break; - case ISD::EHSELECTION: break; } return SDOperand(); } From jlaskey at apple.com Thu Feb 22 08:57:10 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 08:57:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelLowering.cpp Message-ID: <200702221457.l1MEvALx029072@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64ISelLowering.cpp updated: 1.54 -> 1.55 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+0 -3) IA64ISelLowering.cpp | 3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelLowering.cpp diff -u llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.54 llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.55 --- llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.54 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/IA64/IA64ISelLowering.cpp Thu Feb 22 08:56:36 2007 @@ -590,9 +590,6 @@ // Frame & Return address. Currently unimplemented case ISD::RETURNADDR: break; case ISD::FRAMEADDR: break; - // Exception address and exception selector. Currently unimplemented. - case ISD::EXCEPTIONADDR: break; - case ISD::EHSELECTION: break; } return SDOperand(); } From alenhar2 at cs.uiuc.edu Thu Feb 22 09:11:44 2007 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 22 Feb 2007 09:11:44 -0600 Subject: [llvm-commits] [see] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200702221511.l1MFBikT003157@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.536.2.1 -> 1.536.2.1.2.1 --- Log message: catch a missed * to int conversion --- Diffs of the changes: (+15 -0) InstructionCombining.cpp | 15 +++++++++++++++ 1 files changed, 15 insertions(+) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.1 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1 Wed Feb 7 16:32:03 2007 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Feb 22 09:11:27 2007 @@ -4837,6 +4837,21 @@ return BinaryOperator::create(I.getOpcode(), Op0, Op1); } + //Handle special case of setcc (cast T* to uint) (cast T* to uint) + //Generalize to seteq (cast T to >= T') (cast T to >= T') + //restrict to ints and pointers (so casts are sext or zext, no reinterpret) + if (CastInst* CI1 = dyn_cast(Op1)) { + Value* CastOp1 = CI1->getOperand(0); + if (I.isEquality() && CastOp0->getType() == CastOp1->getType() && + TD->getTypeSize(Op1->getType()) >= TD->getTypeSize(CastOp1->getType()) && + (CastOp1->getType()->isInteger() || isa(CastOp1->getType())) && + (Op1->getType()->isInteger() || isa(Op1->getType())) + ) { + std::cerr << "Triggered\n"; + return BinaryOperator::create(I.getOpcode(), CastOp0, CastOp1); + } + } + // Handle the special case of: setcc (cast bool to X), // This comes up when you have code like // int X = A < B; From alenhar2 at cs.uiuc.edu Thu Feb 22 09:18:02 2007 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 22 Feb 2007 09:18:02 -0600 Subject: [llvm-commits] CVS: llvm/test/Transforms/InstCombine/cast_ptr.ll Message-ID: <200702221518.l1MFI2ij009797@zion.cs.uiuc.edu> Changes in directory llvm/test/Transforms/InstCombine: cast_ptr.ll updated: 1.3 -> 1.4 --- Log message: missed cast elimination --- Diffs of the changes: (+7 -1) cast_ptr.ll | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletion(-) Index: llvm/test/Transforms/InstCombine/cast_ptr.ll diff -u llvm/test/Transforms/InstCombine/cast_ptr.ll:1.3 llvm/test/Transforms/InstCombine/cast_ptr.ll:1.4 --- llvm/test/Transforms/InstCombine/cast_ptr.ll:1.3 Fri Dec 1 22:23:09 2006 +++ llvm/test/Transforms/InstCombine/cast_ptr.ll Thu Feb 22 09:17:45 2007 @@ -1,6 +1,6 @@ ; Tests to make sure elimination of casts is working correctly ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output && -; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep '\([sz]ext\)\|\(trunc\)' +; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep '\([sz]ext\)\|\(trunc\)|\(ptrtoint\)' target pointersize = 32 @@ -13,3 +13,9 @@ ret sbyte* %tv } +bool %test2(sbyte* %a, sbyte* %b) { +%tmpa = cast sbyte* %a to uint +%tmpb = cast sbyte* %b to uint +%r = seteq uint %tmpa, %tmpb +ret bool %r +} From jlaskey at apple.com Thu Feb 22 09:37:37 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 09:37:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200702221537.l1MFbbYC010151@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.477 -> 1.478 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+26 -2) LegalizeDAG.cpp | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.477 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.478 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.477 Wed Feb 21 16:53:45 2007 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Feb 22 09:37:19 2007 @@ -668,8 +668,6 @@ break; case ISD::FRAMEADDR: case ISD::RETURNADDR: - case ISD::EXCEPTIONADDR: - case ISD::EHSELECTION: // The only option for these nodes is to custom lower them. If the target // does not custom lower them, then return zero. Tmp1 = TLI.LowerOperation(Op, DAG); @@ -678,6 +676,32 @@ else Result = DAG.getConstant(0, TLI.getPointerTy()); break; + case ISD::EHSELECTION: + LegalizeOp(Node->getOperand(1)); + // Fall Thru + case ISD::EXCEPTIONADDR: { + Tmp1 = LegalizeOp(Node->getOperand(0)); + MVT::ValueType VT = Node->getValueType(0); + switch (TLI.getOperationAction(Node->getOpcode(), VT)) { + default: assert(0 && "This action is not supported yet!"); + case TargetLowering::Expand: { + unsigned Reg = Node->getOpcode() == ISD::EXCEPTIONADDR ? + TLI.getExceptionAddressRegister() : + TLI.getExceptionSelectorRegister(); + Result = DAG.getCopyFromReg(Tmp1, Reg, VT).getValue(Op.ResNo); + } + break; + case TargetLowering::Custom: + Result = TLI.LowerOperation(Op, DAG); + if (Result.Val) break; + // Fall Thru + case TargetLowering::Legal: + Result = DAG.getNode(ISD::MERGE_VALUES, VT, DAG.getConstant(0, VT), Tmp1). + getValue(Op.ResNo); + break; + } + } + break; case ISD::AssertSext: case ISD::AssertZext: Tmp1 = LegalizeOp(Node->getOperand(0)); From jlaskey at apple.com Thu Feb 22 09:37:38 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 09:37:38 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetLowering.h Message-ID: <200702221537.l1MFbcEn010156@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetLowering.h updated: 1.109 -> 1.110 --- Log message: Simplify lowering and selection of exception ops. --- Diffs of the changes: (+38 -0) TargetLowering.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+) Index: llvm/include/llvm/Target/TargetLowering.h diff -u llvm/include/llvm/Target/TargetLowering.h:1.109 llvm/include/llvm/Target/TargetLowering.h:1.110 --- llvm/include/llvm/Target/TargetLowering.h:1.109 Wed Feb 14 21:39:17 2007 +++ llvm/include/llvm/Target/TargetLowering.h Thu Feb 22 09:37:19 2007 @@ -403,6 +403,20 @@ return StackPointerRegisterToSaveRestore; } + /// getExceptionAddressRegister - If a physical register, this returns + /// the register that receives the exception address on entry to a landing + /// pad. + unsigned getExceptionAddressRegister() const { + return ExceptionPointerRegister; + } + + /// getExceptionSelectorRegister - If a physical register, this returns + /// the register that receives the exception typeid on entry to a landing + /// pad. + unsigned getExceptionSelectorRegister() const { + return ExceptionSelectorRegister; + } + /// getJumpBufSize - returns the target's jmp_buf size in bytes (if never /// set, the default is 200) unsigned getJumpBufSize() const { @@ -604,6 +618,20 @@ StackPointerRegisterToSaveRestore = R; } + /// setExceptionPointerRegister - If set to a physical register, this sets + /// the register that receives the exception address on entry to a landing + /// pad. + void setExceptionPointerRegister(unsigned R) { + ExceptionPointerRegister = R; + } + + /// setExceptionSelectorRegister - If set to a physical register, this sets + /// the register that receives the exception typeid on entry to a landing + /// pad. + void setExceptionSelectorRegister(unsigned R) { + ExceptionSelectorRegister = R; + } + /// SelectIsExpensive - Tells the code generator not to expand operations /// into sequences that use the select operations if possible. void setSelectIsExpensive() { SelectIsExpensive = true; } @@ -956,6 +984,16 @@ /// and restore. unsigned StackPointerRegisterToSaveRestore; + /// ExceptionPointerRegister - If set to a physical register, this specifies + /// the register that receives the exception address on entry to a landing + /// pad. + unsigned ExceptionPointerRegister; + + /// ExceptionSelectorRegister - If set to a physical register, this specifies + /// the register that receives the exception typeid on entry to a landing + /// pad. + unsigned ExceptionSelectorRegister; + /// RegClassForVT - This indicates the default register class to use for /// each ValueType the target supports natively. TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE]; From jlaskey at apple.com Thu Feb 22 09:38:22 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 09:38:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702221538.l1MFcMdD010180@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.370 -> 1.371 --- Log message: Handle lowering invoke to call correctly. --- Diffs of the changes: (+97 -95) SelectionDAGISel.cpp | 192 +++++++++++++++++++++++++-------------------------- 1 files changed, 97 insertions(+), 95 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.370 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.371 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.370 Wed Feb 21 16:53:45 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Feb 22 09:38:06 2007 @@ -484,7 +484,8 @@ unsigned Opc); bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB); void ExportFromCurrentBlock(Value *V); - + void LowerCallTo(CallInst &I, SDOperand Callee, unsigned OpIdx); + // Terminator instructions. void visitRet(ReturnInst &I); void visitBr(BranchInst &I); @@ -1117,17 +1118,7 @@ DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), DAG.getConstant(BeginLabel, MVT::i32))); - // Insert a normal call instruction. - std::vector Args; - for (InvokeInst::op_iterator OI = I.op_begin() + 3, E = I.op_end(); - OI != E; ++OI) { - Args.push_back(*OI); - } - CallInst *NewCall = new CallInst(I.getCalledValue(), &Args[0], Args.size(), - I.getName(), &I); - NewCall->setCallingConv(I.getCallingConv()); - I.replaceAllUsesWith(NewCall); - visitCall(*NewCall); + LowerCallTo((CallInst&)I, getValue(I.getOperand(0)), 3); // Insert a label before the invoke call to mark the try range. // This can be used to detect deletion of the invoke via the @@ -2086,84 +2077,87 @@ case Intrinsic::eh_exception: { MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - // Add a label to mark the beginning of the landing pad. Deletion of the - // landing pad can thus be detected via the MachineModuleInfo. - unsigned LabelID = MMI->addLandingPad(CurMBB); - DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, DAG.getEntryNode(), - DAG.getConstant(LabelID, MVT::i32))); - - // Mark exception register as live in. - const MRegisterInfo *MRI = DAG.getTarget().getRegisterInfo(); - unsigned Reg = MRI->getEHExceptionRegister(); - if (Reg) CurMBB->addLiveIn(Reg); - - // Insert the EXCEPTIONADDR instruction. - SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); - SDOperand Ops[1]; - Ops[0] = DAG.getRoot(); - SDOperand Op = DAG.getNode(ISD::EXCEPTIONADDR, VTs, Ops, 1); - setValue(&I, Op); - DAG.setRoot(Op.getValue(1)); - + if (MMI) { + // Add a label to mark the beginning of the landing pad. Deletion of the + // landing pad can thus be detected via the MachineModuleInfo. + unsigned LabelID = MMI->addLandingPad(CurMBB); + DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, DAG.getEntryNode(), + DAG.getConstant(LabelID, MVT::i32))); + + // Mark exception register as live in. + unsigned Reg = TLI.getExceptionAddressRegister(); + if (Reg) CurMBB->addLiveIn(Reg); + + // Insert the EXCEPTIONADDR instruction. + SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); + SDOperand Ops[1]; + Ops[0] = DAG.getRoot(); + SDOperand Op = DAG.getNode(ISD::EXCEPTIONADDR, VTs, Ops, 1); + setValue(&I, Op); + DAG.setRoot(Op.getValue(1)); + } return 0; } case Intrinsic::eh_handlers: { MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - // Inform the MachineModuleInfo of the personality for this landing pad. - if (ConstantExpr *CE = dyn_cast(I.getOperand(2))) { - if (CE->getOpcode() == Instruction::BitCast) { - MMI->addPersonality(CurMBB, - cast(CE->getOperand(0))); - } - } - - // Gather all the type infos for this landing pad and pass them along to - // MachineModuleInfo. - std::vector TyInfo; - for (unsigned i = 3, N = I.getNumOperands(); i < N; ++i) { - if (ConstantExpr *CE = dyn_cast(I.getOperand(i))) { + if (MMI) { + // Inform the MachineModuleInfo of the personality for this landing pad. + if (ConstantExpr *CE = dyn_cast(I.getOperand(2))) { if (CE->getOpcode() == Instruction::BitCast) { - TyInfo.push_back(cast(CE->getOperand(0))); - continue; + MMI->addPersonality(CurMBB, + cast(CE->getOperand(0))); } } - TyInfo.push_back(NULL); + // Gather all the type infos for this landing pad and pass them along to + // MachineModuleInfo. + std::vector TyInfo; + for (unsigned i = 3, N = I.getNumOperands(); i < N; ++i) { + if (ConstantExpr *CE = dyn_cast(I.getOperand(i))) { + if (CE->getOpcode() == Instruction::BitCast) { + TyInfo.push_back(cast(CE->getOperand(0))); + continue; + } + } + + TyInfo.push_back(NULL); + } + MMI->addCatchTypeInfo(CurMBB, TyInfo); + + // Mark exception selector register as live in. + unsigned Reg = TLI.getExceptionSelectorRegister(); + if (Reg) CurMBB->addLiveIn(Reg); + + // Insert the EHSELECTION instruction. + SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); + SDOperand Ops[2]; + Ops[0] = getValue(I.getOperand(1)); + Ops[1] = getRoot(); + SDOperand Op = DAG.getNode(ISD::EHSELECTION, VTs, Ops, 2); + setValue(&I, Op); + DAG.setRoot(Op.getValue(1)); } - MMI->addCatchTypeInfo(CurMBB, TyInfo); - - // Mark exception selector register as live in. - const MRegisterInfo *MRI = DAG.getTarget().getRegisterInfo(); - unsigned Reg = MRI->getEHHandlerRegister(); - if (Reg) CurMBB->addLiveIn(Reg); - - // Insert the EHSELECTION instruction. - SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); - SDOperand Ops[2]; - Ops[0] = getValue(I.getOperand(1)); - Ops[1] = getRoot(); - SDOperand Op = DAG.getNode(ISD::EHSELECTION, VTs, Ops, 2); - setValue(&I, Op); - DAG.setRoot(Op.getValue(1)); return 0; } case Intrinsic::eh_typeid_for: { - GlobalVariable *GV = NULL; - - // Find the type id for the given typeinfo. MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - if (ConstantExpr *CE = dyn_cast(I.getOperand(1))) { - if (CE->getOpcode() == Instruction::BitCast) { - GV = cast(CE->getOperand(0)); + + if (MMI) { + // Find the type id for the given typeinfo. + GlobalVariable *GV = NULL; + if (ConstantExpr *CE = dyn_cast(I.getOperand(1))) { + if (CE->getOpcode() == Instruction::BitCast) { + GV = cast(CE->getOperand(0)); + } } + + unsigned TypeID = MMI->getTypeIDFor(GV); + setValue(&I, DAG.getConstant(TypeID, MVT::i32)); } - - unsigned TypeID = MMI->getTypeIDFor(GV); - setValue(&I, DAG.getConstant(TypeID, MVT::i32)); return 0; } @@ -2246,6 +2240,35 @@ } +void SelectionDAGLowering::LowerCallTo(CallInst &I, + SDOperand Callee, unsigned OpIdx) { + const PointerType *PT = cast(I.getCalledValue()->getType()); + const FunctionType *FTy = cast(PT->getElementType()); + + TargetLowering::ArgListTy Args; + TargetLowering::ArgListEntry Entry; + Args.reserve(I.getNumOperands()); + for (unsigned i = OpIdx, e = I.getNumOperands(); i != e; ++i) { + Value *Arg = I.getOperand(i); + SDOperand ArgNode = getValue(Arg); + Entry.Node = ArgNode; Entry.Ty = Arg->getType(); + Entry.isSigned = FTy->paramHasAttr(i, FunctionType::SExtAttribute); + Entry.isInReg = FTy->paramHasAttr(i, FunctionType::InRegAttribute); + Entry.isSRet = FTy->paramHasAttr(i, FunctionType::StructRetAttribute); + Args.push_back(Entry); + } + + std::pair Result = + TLI.LowerCallTo(getRoot(), I.getType(), + FTy->paramHasAttr(0,FunctionType::SExtAttribute), + FTy->isVarArg(), I.getCallingConv(), I.isTailCall(), + Callee, Args, DAG); + if (I.getType() != Type::VoidTy) + setValue(&I, Result.first); + DAG.setRoot(Result.second); +} + + void SelectionDAGLowering::visitCall(CallInst &I) { const char *RenameFn = 0; if (Function *F = I.getCalledFunction()) { @@ -2298,37 +2321,16 @@ return; } - const PointerType *PT = cast(I.getCalledValue()->getType()); - const FunctionType *FTy = cast(PT->getElementType()); - SDOperand Callee; if (!RenameFn) Callee = getValue(I.getOperand(0)); else Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy()); - TargetLowering::ArgListTy Args; - TargetLowering::ArgListEntry Entry; - Args.reserve(I.getNumOperands()); - for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i) { - Value *Arg = I.getOperand(i); - SDOperand ArgNode = getValue(Arg); - Entry.Node = ArgNode; Entry.Ty = Arg->getType(); - Entry.isSigned = FTy->paramHasAttr(i, FunctionType::SExtAttribute); - Entry.isInReg = FTy->paramHasAttr(i, FunctionType::InRegAttribute); - Entry.isSRet = FTy->paramHasAttr(i, FunctionType::StructRetAttribute); - Args.push_back(Entry); - } - - std::pair Result = - TLI.LowerCallTo(getRoot(), I.getType(), - FTy->paramHasAttr(0,FunctionType::SExtAttribute), - FTy->isVarArg(), I.getCallingConv(), I.isTailCall(), - Callee, Args, DAG); - if (I.getType() != Type::VoidTy) - setValue(&I, Result.first); - DAG.setRoot(Result.second); + + LowerCallTo(I, Callee, 1); } + SDOperand RegsForValue::getCopyFromRegs(SelectionDAG &DAG, SDOperand &Chain, SDOperand &Flag)const{ SDOperand Val = DAG.getCopyFromReg(Chain, Regs[0], RegVT, Flag); From jlaskey at apple.com Thu Feb 22 10:10:21 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:10:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702221610.l1MGALls010749@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.371 -> 1.372 --- Log message: Tighten up error checking of args. --- Diffs of the changes: (+23 -17) SelectionDAGISel.cpp | 40 +++++++++++++++++++++++----------------- 1 files changed, 23 insertions(+), 17 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.371 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.372 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.371 Thu Feb 22 09:38:06 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Feb 22 10:10:05 2007 @@ -2104,25 +2104,26 @@ if (MMI) { // Inform the MachineModuleInfo of the personality for this landing pad. - if (ConstantExpr *CE = dyn_cast(I.getOperand(2))) { - if (CE->getOpcode() == Instruction::BitCast) { - MMI->addPersonality(CurMBB, - cast(CE->getOperand(0))); - } - } + ConstantExpr *CE = dyn_cast(I.getOperand(2)); + assert(CE && CE->getOpcode() == Instruction::BitCast && + isa(CE->getOperand(0)) && + "Personality should be a function"); + MMI->addPersonality(CurMBB, cast(CE->getOperand(0))); // Gather all the type infos for this landing pad and pass them along to // MachineModuleInfo. std::vector TyInfo; for (unsigned i = 3, N = I.getNumOperands(); i < N; ++i) { - if (ConstantExpr *CE = dyn_cast(I.getOperand(i))) { - if (CE->getOpcode() == Instruction::BitCast) { - TyInfo.push_back(cast(CE->getOperand(0))); - continue; - } + ConstantExpr *CE = dyn_cast(I.getOperand(i)); + if (CE && CE->getOpcode() == Instruction::BitCast && + isa(CE->getOperand(0))) { + TyInfo.push_back(cast(CE->getOperand(0))); + } else { + ConstantInt *CI = dyn_cast(I.getOperand(i)); + assert(CI && CI->getZExtValue() == 0 && + "TypeInfo must be a global variable typeinfo or NULL"); + TyInfo.push_back(NULL); } - - TyInfo.push_back(NULL); } MMI->addCatchTypeInfo(CurMBB, TyInfo); @@ -2149,10 +2150,15 @@ if (MMI) { // Find the type id for the given typeinfo. GlobalVariable *GV = NULL; - if (ConstantExpr *CE = dyn_cast(I.getOperand(1))) { - if (CE->getOpcode() == Instruction::BitCast) { - GV = cast(CE->getOperand(0)); - } + ConstantExpr *CE = dyn_cast(I.getOperand(1)); + if (CE && CE->getOpcode() == Instruction::BitCast && + isa(CE->getOperand(0))) { + GV = cast(CE->getOperand(0)); + } else { + ConstantInt *CI = dyn_cast(I.getOperand(1)); + assert(CI && CI->getZExtValue() == 0 && + "TypeInfo must be a global variable typeinfo or NULL"); + GV = NULL; } unsigned TypeID = MMI->getTypeIDFor(GV); From jlaskey at apple.com Thu Feb 22 10:12:33 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:12:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200702221612.l1MGCXS8010806@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.68 -> 1.69 --- Log message: Remove assertion. --- Diffs of the changes: (+1 -4) IntrinsicLowering.cpp | 5 +---- 1 files changed, 1 insertion(+), 4 deletions(-) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.68 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.69 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.68 Wed Feb 21 16:53:45 2007 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Thu Feb 22 10:12:17 2007 @@ -356,12 +356,9 @@ case Intrinsic::dbg_region_end: case Intrinsic::dbg_func_start: case Intrinsic::dbg_declare: - break; // Simply strip out debugging intrinsics - case Intrinsic::eh_exception: case Intrinsic::eh_handlers: - assert(0 && "Should not have leaked through"); - break; + break; // Simply strip out debugging intrinsics case Intrinsic::memcpy_i32: case Intrinsic::memcpy_i64: { From jlaskey at apple.com Thu Feb 22 10:21:35 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:21:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerInvoke.cpp Message-ID: <200702221621.l1MGLZH2011065@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: LowerInvoke.cpp updated: 1.56 -> 1.57 --- Log message: Revert changes for a simplier solution. --- Diffs of the changes: (+36 -50) LowerInvoke.cpp | 86 +++++++++++++++++++++++--------------------------------- 1 files changed, 36 insertions(+), 50 deletions(-) Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.56 llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.57 --- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.56 Wed Feb 21 16:49:50 2007 +++ llvm/lib/Transforms/Utils/LowerInvoke.cpp Thu Feb 22 10:21:18 2007 @@ -57,9 +57,6 @@ static cl::opt ExpensiveEHSupport("enable-correct-eh-support", cl::desc("Make the -lowerinvoke pass insert expensive, but correct, EH code")); - -static cl::opt ItaniumEHSupport("enable-real-eh-support", - cl::desc("Make the -lowerinvoke pass insert itanium ABI EH code")); namespace { class VISIBILITY_HIDDEN LowerInvoke : public FunctionPass { @@ -97,7 +94,6 @@ void splitLiveRangesLiveAcrossInvokes(std::vector &Invokes); void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, AllocaInst *InvokeNum, SwitchInst *CatchSwitch); - bool insertItaniumEHSupport(Function &F); bool insertExpensiveEHSupport(Function &F); }; @@ -115,50 +111,46 @@ // doInitialization - Make sure that there is a prototype for abort in the // current module. bool LowerInvoke::doInitialization(Module &M) { - if (ItaniumEHSupport) { - // Let Invoke pass through for ItaniumEHSupport support. - } else { - const Type *VoidPtrTy = PointerType::get(Type::Int8Ty); - AbortMessage = 0; - if (ExpensiveEHSupport) { - // Insert a type for the linked list of jump buffers. - unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0; - JBSize = JBSize ? JBSize : 200; - const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize); - - { // The type is recursive, so use a type holder. - std::vector Elements; - Elements.push_back(JmpBufTy); - OpaqueType *OT = OpaqueType::get(); - Elements.push_back(PointerType::get(OT)); - PATypeHolder JBLType(StructType::get(Elements)); - OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle. - JBLinkTy = JBLType.get(); - M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy); - } + const Type *VoidPtrTy = PointerType::get(Type::Int8Ty); + AbortMessage = 0; + if (ExpensiveEHSupport) { + // Insert a type for the linked list of jump buffers. + unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0; + JBSize = JBSize ? JBSize : 200; + const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize); + + { // The type is recursive, so use a type holder. + std::vector Elements; + Elements.push_back(JmpBufTy); + OpaqueType *OT = OpaqueType::get(); + Elements.push_back(PointerType::get(OT)); + PATypeHolder JBLType(StructType::get(Elements)); + OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle. + JBLinkTy = JBLType.get(); + M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy); + } - const Type *PtrJBList = PointerType::get(JBLinkTy); + const Type *PtrJBList = PointerType::get(JBLinkTy); - // Now that we've done that, insert the jmpbuf list head global, unless it - // already exists. - if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))){ - JBListHead = new GlobalVariable(PtrJBList, false, - GlobalValue::LinkOnceLinkage, - Constant::getNullValue(PtrJBList), - "llvm.sjljeh.jblist", &M); - } - SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty, - PointerType::get(JmpBufTy), (Type *)0); - LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy, - PointerType::get(JmpBufTy), - Type::Int32Ty, (Type *)0); + // Now that we've done that, insert the jmpbuf list head global, unless it + // already exists. + if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) { + JBListHead = new GlobalVariable(PtrJBList, false, + GlobalValue::LinkOnceLinkage, + Constant::getNullValue(PtrJBList), + "llvm.sjljeh.jblist", &M); } - - // We need the 'write' and 'abort' functions for both models. - AbortFn = M.getOrInsertFunction("abort", Type::VoidTy, (Type *)0); - WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::Int32Ty, - VoidPtrTy, Type::Int32Ty, (Type *)0); + SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty, + PointerType::get(JmpBufTy), (Type *)0); + LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy, + PointerType::get(JmpBufTy), + Type::Int32Ty, (Type *)0); } + + // We need the 'write' and 'abort' functions for both models. + AbortFn = M.getOrInsertFunction("abort", Type::VoidTy, (Type *)0); + WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::Int32Ty, + VoidPtrTy, Type::Int32Ty, (Type *)0); return true; } @@ -396,10 +388,6 @@ } } -bool LowerInvoke::insertItaniumEHSupport(Function &F) { - return true; -} - bool LowerInvoke::insertExpensiveEHSupport(Function &F) { std::vector Returns; std::vector Unwinds; @@ -581,8 +569,6 @@ } bool LowerInvoke::runOnFunction(Function &F) { - if (ItaniumEHSupport) - return insertItaniumEHSupport(F); if (ExpensiveEHSupport) return insertExpensiveEHSupport(F); else From jlaskey at apple.com Thu Feb 22 10:22:32 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:22:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <200702221622.l1MGMWhX011092@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LLVMTargetMachine.cpp updated: 1.8 -> 1.9 --- Log message: Use exception flag. --- Diffs of the changes: (+2 -1) LLVMTargetMachine.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/LLVMTargetMachine.cpp diff -u llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.8 llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.9 --- llvm/lib/CodeGen/LLVMTargetMachine.cpp:1.8 Wed Feb 7 19:36:53 2007 +++ llvm/lib/CodeGen/LLVMTargetMachine.cpp Thu Feb 22 10:22:15 2007 @@ -33,7 +33,8 @@ PM.add(createLowerGCPass()); // FIXME: Implement the invoke/unwind instructions! - PM.add(createLowerInvokePass(getTargetLowering())); + if (!ExceptionHandling) + PM.add(createLowerInvokePass(getTargetLowering())); // Make sure that no unreachable blocks are instruction selected. PM.add(createUnreachableBlockEliminationPass()); From andrewl at lenharth.org Thu Feb 22 10:28:54 2007 From: andrewl at lenharth.org (Andrew Lenharth) Date: Thu, 22 Feb 2007 10:28:54 -0600 Subject: [llvm-commits] CVS: llvm/test/Transforms/InstCombine/cast_ptr.ll In-Reply-To: <200702221518.l1MFI2ij009797@zion.cs.uiuc.edu> References: <200702221518.l1MFI2ij009797@zion.cs.uiuc.edu> Message-ID: <85dfcd7f0702220828v5bb093a1hab43141eeb1295df@mail.gmail.com> I won't get a chance to fix this before the nightly testers start. Should I x-fail this until it is handled? Andrew On 2/22/07, Andrew Lenharth wrote: > > > > Changes in directory llvm/test/Transforms/InstCombine: > > cast_ptr.ll updated: 1.3 -> 1.4 > --- > Log message: > > missed cast elimination > > --- > Diffs of the changes: (+7 -1) > > cast_ptr.ll | 8 +++++++- > 1 files changed, 7 insertions(+), 1 deletion(-) > > > Index: llvm/test/Transforms/InstCombine/cast_ptr.ll > diff -u llvm/test/Transforms/InstCombine/cast_ptr.ll:1.3llvm/test/Transforms/InstCombine/cast_ptr.ll: > 1.4 > --- llvm/test/Transforms/InstCombine/cast_ptr.ll:1.3 Fri Dec 1 > 22:23:09 2006 > +++ llvm/test/Transforms/InstCombine/cast_ptr.ll Thu Feb 22 > 09:17:45 2007 > @@ -1,6 +1,6 @@ > ; Tests to make sure elimination of casts is working correctly > ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output && > -; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not > grep '\([sz]ext\)\|\(trunc\)' > +; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not > grep '\([sz]ext\)\|\(trunc\)|\(ptrtoint\)' > > target pointersize = 32 > > @@ -13,3 +13,9 @@ > ret sbyte* %tv > } > > +bool %test2(sbyte* %a, sbyte* %b) { > +%tmpa = cast sbyte* %a to uint > +%tmpb = cast sbyte* %b to uint > +%r = seteq uint %tmpa, %tmpb > +ret bool %r > +} > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20070222/20d14dbe/attachment.html From jlaskey at apple.com Thu Feb 22 10:39:24 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:39:24 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200702221639.l1MGdOBo011465@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.59 -> 1.60 --- Log message: Remove isAccessable. --- Diffs of the changes: (+0 -4) MachineBasicBlock.h | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.59 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.60 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.59 Wed Feb 21 16:39:52 2007 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Thu Feb 22 10:39:03 2007 @@ -165,10 +165,6 @@ /// this basic block is entered via an exception handler. void setIsLandingPad() { IsLandingPad = true; } - /// isAccessable - Returns true if the block is alive. That is, if it has - /// predecessors or is an eh landing pad. - bool isAccessable() const { return !pred_empty() || isLandingPad(); } - // Code Layout methods. /// moveBefore/moveAfter - move 'this' block before or after the specified From jlaskey at apple.com Thu Feb 22 10:39:24 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:39:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/BranchFolding.cpp Message-ID: <200702221639.l1MGdOjB011470@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: BranchFolding.cpp updated: 1.43 -> 1.44 --- Log message: Remove isAccessable. --- Diffs of the changes: (+4 -4) BranchFolding.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/BranchFolding.cpp diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.43 llvm/lib/CodeGen/BranchFolding.cpp:1.44 --- llvm/lib/CodeGen/BranchFolding.cpp:1.43 Wed Feb 21 16:42:20 2007 +++ llvm/lib/CodeGen/BranchFolding.cpp Thu Feb 22 10:39:03 2007 @@ -67,7 +67,7 @@ /// RemoveDeadBlock - Remove the specified dead machine basic block from the /// function, updating the CFG. void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) { - assert(!MBB->isAccessable() && "MBB must be dead!"); + assert(MBB->pred_empty() && "MBB must be dead!"); DOUT << "\nRemoving MBB: " << *MBB; MachineFunction *MF = MBB->getParent(); @@ -440,7 +440,7 @@ OptimizeBlock(MBB); // If it is dead, remove it. - if (!MBB->isAccessable()) { + if (MBB->pred_empty()) { RemoveDeadBlock(MBB); MadeChange = true; ++NumDeadBlocks; @@ -618,14 +618,14 @@ // explicitly. if (MBB->empty()) { // Dead block? Leave for cleanup later. - if (!MBB->isAccessable()) return; + if (MBB->pred_empty()) return; if (FallThrough == MBB->getParent()->end()) { // TODO: Simplify preds to not branch here if possible! } else { // Rewrite all predecessors of the old block to go to the fallthrough // instead. - while (MBB->isAccessable()) { + while (!MBB->pred_empty()) { MachineBasicBlock *Pred = *(MBB->pred_end()-1); ReplaceUsesOfBlockWith(Pred, MBB, FallThrough, TII); } From jlaskey at apple.com Thu Feb 22 10:40:27 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 10:40:27 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineModuleInfo.h Message-ID: <200702221640.l1MGeRio011503@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineModuleInfo.h updated: 1.5 -> 1.6 --- Log message: Typo. --- Diffs of the changes: (+1 -1) MachineModuleInfo.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/CodeGen/MachineModuleInfo.h diff -u llvm/include/llvm/CodeGen/MachineModuleInfo.h:1.5 llvm/include/llvm/CodeGen/MachineModuleInfo.h:1.6 --- llvm/include/llvm/CodeGen/MachineModuleInfo.h:1.5 Wed Feb 21 16:38:31 2007 +++ llvm/include/llvm/CodeGen/MachineModuleInfo.h Thu Feb 22 10:40:10 2007 @@ -1014,7 +1014,7 @@ // in the current function. std::vector LandingPads; - // TypeInfos - List of C++ TypeInfo used in the currect function. + // TypeInfos - List of C++ TypeInfo used in the current function. // std::vector TypeInfos; From jlaskey at apple.com Thu Feb 22 12:05:06 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 12:05:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200702221805.l1MI56Pd012965@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: TargetLowering.cpp updated: 1.92 -> 1.93 --- Log message: Need to init. --- Diffs of the changes: (+2 -0) TargetLowering.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp diff -u llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.92 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.93 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.92 Sat Feb 17 00:00:35 2007 +++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Thu Feb 22 12:04:49 2007 @@ -151,6 +151,8 @@ IntDivIsCheap = false; Pow2DivIsCheap = false; StackPointerRegisterToSaveRestore = 0; + ExceptionPointerRegister = 0; + ExceptionSelectorRegister = 0; SchedPreferenceInfo = SchedulingForLatency; JumpBufSize = 0; JumpBufAlignment = 0; From jlaskey at apple.com Thu Feb 22 12:22:59 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 12:22:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp Message-ID: <200702221822.l1MIMxxJ013265@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: DwarfWriter.cpp updated: 1.126 -> 1.127 --- Log message: Missing end of abbreviations. --- Diffs of the changes: (+3 -0) DwarfWriter.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/CodeGen/DwarfWriter.cpp diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.126 llvm/lib/CodeGen/DwarfWriter.cpp:1.127 --- llvm/lib/CodeGen/DwarfWriter.cpp:1.126 Wed Feb 21 16:48:45 2007 +++ llvm/lib/CodeGen/DwarfWriter.cpp Thu Feb 22 12:22:42 2007 @@ -2104,6 +2104,9 @@ Asm->EOL(); } + // Mark end of abbreviations. + DD.getAsm()->EmitULEB128Bytes(0); DD.getAsm()->EOL("EOM(3)"); + EmitLabel("abbrev_end", 0); Asm->EOL(); From jlaskey at apple.com Thu Feb 22 12:49:09 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 12:49:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp Message-ID: <200702221849.l1MIn9uh013974@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: DwarfWriter.cpp updated: 1.127 -> 1.128 --- Log message: Missing end of abbreviations - correction --- Diffs of the changes: (+1 -1) DwarfWriter.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/DwarfWriter.cpp diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.127 llvm/lib/CodeGen/DwarfWriter.cpp:1.128 --- llvm/lib/CodeGen/DwarfWriter.cpp:1.127 Thu Feb 22 12:22:42 2007 +++ llvm/lib/CodeGen/DwarfWriter.cpp Thu Feb 22 12:48:52 2007 @@ -2105,7 +2105,7 @@ } // Mark end of abbreviations. - DD.getAsm()->EmitULEB128Bytes(0); DD.getAsm()->EOL("EOM(3)"); + Asm->EmitULEB128Bytes(0); Asm->EOL("EOM(3)"); EmitLabel("abbrev_end", 0); From jlaskey at apple.com Thu Feb 22 12:51:35 2007 From: jlaskey at apple.com (Jim Laskey) Date: Thu, 22 Feb 2007 12:51:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200702221851.l1MIpZr7014037@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.69 -> 1.70 --- Log message: Update comment. --- Diffs of the changes: (+1 -1) IntrinsicLowering.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.69 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.70 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.69 Thu Feb 22 10:12:17 2007 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Thu Feb 22 12:51:19 2007 @@ -358,7 +358,7 @@ case Intrinsic::dbg_declare: case Intrinsic::eh_exception: case Intrinsic::eh_handlers: - break; // Simply strip out debugging intrinsics + break; // Simply strip out debugging and eh intrinsics case Intrinsic::memcpy_i32: case Intrinsic::memcpy_i64: { From bwendlin at apple.com Thu Feb 22 15:25:15 2007 From: bwendlin at apple.com (bwendlin at apple.com) Date: Thu, 22 Feb 2007 13:25:15 -0800 (PST) Subject: [llvm-commits] [124197] Add a "LLVM_MINOR_VERSION" macro to Version.h. Message-ID: <20070222212515.7ABA75DA68F1@src> Revision: 124197 Author: bwendlin Date: 2007-02-22 13:25:13 -0800 (Thu, 22 Feb 2007) Log Message: ----------- Add a "LLVM_MINOR_VERSION" macro to Version.h. Modified Paths: -------------- apple-local/branches/llvm/build_gcc Modified: apple-local/branches/llvm/build_gcc =================================================================== --- apple-local/branches/llvm/build_gcc 2007-02-22 12:30:12 UTC (rev 124196) +++ apple-local/branches/llvm/build_gcc 2007-02-22 21:25:13 UTC (rev 124197) @@ -565,7 +565,25 @@ make $MAKEFLAGS ENABLE_OPTIMIZED=1 UNIVERSAL=1 OPTIMIZE_OPTION='-O2' install ## Install Version.h + if [ "x$LLVM_SUBMIT_SUBVERSION" = "x00" -o "x$LLVM_SUBMIT_SUBVERSION" = "x0" ]; then + RC_ProjectSourceSubversion=0 + else + case "$LLVM_SUBMIT_SUBVERSION" in + 01) RC_ProjectSourceSubversion=1 ;; + 02) RC_ProjectSourceSubversion=2 ;; + 03) RC_ProjectSourceSubversion=3 ;; + 04) RC_ProjectSourceSubversion=4 ;; + 05) RC_ProjectSourceSubversion=5 ;; + 06) RC_ProjectSourceSubversion=6 ;; + 07) RC_ProjectSourceSubversion=7 ;; + 08) RC_ProjectSourceSubversion=8 ;; + 09) RC_ProjectSourceSubversion=9 ;; + *) RC_ProjectSourceSubversion=$LLVM_SUBMIT_SUBVERSION ;; + esac + fi + echo "#define LLVM_VERSION ${RC_ProjectSourceVersion}" > $DEST_DIR$LLVM_INSTALL_PREFIX/include/llvm/Version.h + echo "#define LLVM_MINOR_VERSION ${RC_ProjectSourceSubversion}" >> $DEST_DIR$LLVM_INSTALL_PREFIX/include/llvm/Version.h ## Strip local symbols from llvm libraries. strip -S $DEST_DIR$LLVM_INSTALL_PREFIX/lib/*.[oa] From evan.cheng at apple.com Thu Feb 22 17:04:03 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 17:04:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200702222304.l1MN43pU023213@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.211 -> 1.212 --- Log message: Remove unnecessary isKill properties if a live range has been lengthened due to coalescing. --- Diffs of the changes: (+24 -1) LiveIntervalAnalysis.cpp | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.211 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.212 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.211 Wed Feb 21 16:41:17 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Feb 22 17:03:39 2007 @@ -959,10 +959,22 @@ DOUT << "\n\t\tJoined. Result = "; DestInt.print(DOUT, mri_); DOUT << "\n"; - + // If the intervals were swapped by Join, swap them back so that the register // mapping (in the r2i map) is correct. if (Swapped) SrcInt.swap(DestInt); + + // Live range has been lengthened due to colaescing, eliminate the + // unnecessary kills at the end of the source live ranges. + LiveVariables::VarInfo& vi = lv_->getVarInfo(repSrcReg); + for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { + MachineInstr *Kill = vi.Kills[i]; + if (Kill == CopyMI || isRemoved(Kill)) + continue; + if (DestInt.liveAt(getInstructionIndex(Kill) + InstrSlots::NUM)) + unsetRegisterKill(Kill, repSrcReg); + } + removeInterval(repSrcReg); r2rMap_[repSrcReg] = repDstReg; @@ -1471,6 +1483,17 @@ return false; } +/// unsetRegisterKill - Unset IsKill property of all uses of specific register +/// of the specific instruction. +void LiveIntervals::unsetRegisterKill(MachineInstr *MI, unsigned Reg) { + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.isUse() && MO.isKill() && MO.getReg() && + mri_->regsOverlap(rep(MO.getReg()), Reg)) + MO.unsetIsKill(); + } +} + LiveInterval LiveIntervals::createInterval(unsigned reg) { float Weight = MRegisterInfo::isPhysicalRegister(reg) ? HUGE_VALF : 0.0F; From evan.cheng at apple.com Thu Feb 22 17:04:03 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 17:04:03 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Message-ID: <200702222304.l1MN43S4023214@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervalAnalysis.h updated: 1.72 -> 1.73 --- Log message: Remove unnecessary isKill properties if a live range has been lengthened due to coalescing. --- Diffs of the changes: (+11 -0) LiveIntervalAnalysis.h | 11 +++++++++++ 1 files changed, 11 insertions(+) Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.72 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.73 --- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.72 Wed Feb 21 16:41:17 2007 +++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Thu Feb 22 17:03:39 2007 @@ -172,6 +172,13 @@ } private: + /// isRemoved - returns true if the specified machine instr has been + /// removed. + bool isRemoved(MachineInstr* instr) const { + Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); + return it == mi2iMap_.end(); + } + /// RemoveMachineInstrFromMaps - This marks the specified machine instr as /// deleted. void RemoveMachineInstrFromMaps(MachineInstr *MI) { @@ -256,6 +263,10 @@ /// reg between indexes Start and End. bool hasRegisterUse(unsigned Reg, unsigned Start, unsigned End); + /// unsetRegisterKill - Unset IsKill property of all uses of specific + /// register of the specific instruction. + void unsetRegisterKill(MachineInstr *MI, unsigned Reg); + static LiveInterval createInterval(unsigned Reg); void removeInterval(unsigned Reg) { From dpatel at apple.com Thu Feb 22 17:30:23 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 17:30:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702222330.l1MNUNcS023694@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.1 -> 1.2 --- Log message: Add LoopQueue. This is used by loop pass manager to manage loop nest. --- Diffs of the changes: (+36 -0) LoopPass.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.1 llvm/lib/Analysis/LoopPass.cpp:1.2 --- llvm/lib/Analysis/LoopPass.cpp:1.1 Thu Feb 22 02:56:17 2007 +++ llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 17:30:07 2007 @@ -14,13 +14,49 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" +#include using namespace llvm; //===----------------------------------------------------------------------===// +// LoopQueue + +namespace llvm { + +// Compare Two loops based on their depth in loop nest. +class LoopCompare { +public: + bool operator()( Loop *L1, Loop *L2) const { + return L1->getLoopDepth() > L2->getLoopDepth(); + } +}; + +// Loop queue used by Loop Pass Manager. This is a wrapper class +// that hides implemenation detail (use of priority_queue) inside .cpp file. +class LoopQueue { + + inline void push(Loop *L) { LPQ.push(L); } + inline void pop() { LPQ.pop(); } + inline Loop *top() { return LPQ.top(); } + +private: + std::priority_queue, LoopCompare> LPQ; +}; + +} // End of LLVM namespace + +//===----------------------------------------------------------------------===// // LPPassManager // /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses. +LPPassManager::LPPassManager(int Depth) : PMDataManager(Depth) { + LQ = new LoopQueue(); +} + +LPPassManager::~LPPassManager() { + delete LQ; +} + /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the function, and if so, return true. bool LPPassManager::runOnFunction(Function &F) { From dpatel at apple.com Thu Feb 22 17:30:25 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 17:30:25 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h Message-ID: <200702222330.l1MNUPxv023699@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopPass.h updated: 1.1 -> 1.2 --- Log message: Add LoopQueue. This is used by loop pass manager to manage loop nest. --- Diffs of the changes: (+6 -1) LoopPass.h | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Analysis/LoopPass.h diff -u llvm/include/llvm/Analysis/LoopPass.h:1.1 llvm/include/llvm/Analysis/LoopPass.h:1.2 --- llvm/include/llvm/Analysis/LoopPass.h:1.1 Thu Feb 22 02:56:17 2007 +++ llvm/include/llvm/Analysis/LoopPass.h Thu Feb 22 17:30:07 2007 @@ -25,6 +25,7 @@ class LPPassManager; class Loop; class Function; +class LoopQueue; class LoopPass : public Pass { @@ -41,7 +42,8 @@ class LPPassManager : public FunctionPass, public PMDataManager { public: - LPPassManager(int Depth) : PMDataManager(Depth) { } + LPPassManager(int Depth); + ~LPPassManager(); /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. @@ -79,6 +81,9 @@ return PMT_LoopPassManager; } + private: + LoopQueue *LQ; + }; } // End llvm namespace From dpatel at apple.com Thu Feb 22 17:45:32 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 17:45:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702222345.l1MNjWTg024011@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.2 -> 1.3 --- Log message: Populate and walk loop queue. --- Diffs of the changes: (+20 -6) LoopPass.cpp | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.2 llvm/lib/Analysis/LoopPass.cpp:1.3 --- llvm/lib/Analysis/LoopPass.cpp:1.2 Thu Feb 22 17:30:07 2007 +++ llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 17:45:15 2007 @@ -33,11 +33,11 @@ // Loop queue used by Loop Pass Manager. This is a wrapper class // that hides implemenation detail (use of priority_queue) inside .cpp file. class LoopQueue { - +public: inline void push(Loop *L) { LPQ.push(L); } inline void pop() { LPQ.pop(); } inline Loop *top() { return LPQ.top(); } - + inline bool empty() { return LPQ.empty(); } private: std::priority_queue, LoopCompare> LPQ; }; @@ -57,22 +57,33 @@ delete LQ; } +// Recurse through all subloops and all loops into LQ. +static void addLoopIntoQueue(Loop *L, LoopQueue *LQ) { + for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) + addLoopIntoQueue(*I, LQ); + LQ->push(L); +} + /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the function, and if so, return true. bool LPPassManager::runOnFunction(Function &F) { LoopInfo &LI = getAnalysis(); bool Changed = false; + // Populate Loop Queue + for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) + addLoopIntoQueue(*I, LQ); + std::string Msg1 = "Executing Pass '"; std::string Msg3 = "' Made Modification '"; // Walk Loops - for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) { - - Loop *L = *I; + while (!LQ->empty()) { + + Loop *L = LQ->top(); // Run all passes on current SCC for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - + Pass *P = getContainedPass(Index); AnalysisUsage AnUsage; P->getAnalysisUsage(AnUsage); @@ -97,6 +108,9 @@ recordAvailableAnalysis(P); removeDeadPasses(P, Msg2); } + + // Pop the loop from queue after running all passes. + LQ->pop(); } return Changed; From lattner at cs.uiuc.edu Thu Feb 22 17:49:00 2007 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 22 Feb 2007 17:49:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/LICENSE.TXT Message-ID: <200702222349.l1MNn0hr024164@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: LICENSE.TXT (r1.2) removed --- Log message: remove obsolete file --- Diffs of the changes: (+0 -0) 0 files changed From evan.cheng at apple.com Thu Feb 22 17:52:39 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 17:52:39 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Message-ID: <200702222352.l1MNqdRb024239@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervalAnalysis.h updated: 1.73 -> 1.74 --- Log message: Copy and paste silliness. --- Diffs of the changes: (+1 -2) LiveIntervalAnalysis.h | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.73 llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.74 --- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.73 Thu Feb 22 17:03:39 2007 +++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h Thu Feb 22 17:52:23 2007 @@ -175,8 +175,7 @@ /// isRemoved - returns true if the specified machine instr has been /// removed. bool isRemoved(MachineInstr* instr) const { - Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); - return it == mi2iMap_.end(); + return !mi2iMap_.count(instr); } /// RemoveMachineInstrFromMaps - This marks the specified machine instr as From dpatel at apple.com Thu Feb 22 18:10:38 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 18:10:38 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h Message-ID: <200702230010.l1N0AcR8024555@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopPass.h updated: 1.2 -> 1.3 --- Log message: Add LPPassManager interface that LoopPass can use to skip rest of the passes in the queue for a loop. --- Diffs of the changes: (+6 -1) LoopPass.h | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Analysis/LoopPass.h diff -u llvm/include/llvm/Analysis/LoopPass.h:1.2 llvm/include/llvm/Analysis/LoopPass.h:1.3 --- llvm/include/llvm/Analysis/LoopPass.h:1.2 Thu Feb 22 17:30:07 2007 +++ llvm/include/llvm/Analysis/LoopPass.h Thu Feb 22 18:10:16 2007 @@ -81,8 +81,13 @@ return PMT_LoopPassManager; } - private: +public: + // Delete loop from the loop queue. This is used by Loop pass to inform + // Loop Pass Manager that it should skip rest of the passes for this loop. + void deleteLoopFromQueue(Loop *L); +private: LoopQueue *LQ; + bool skipThisLoop; }; From dpatel at apple.com Thu Feb 22 18:10:38 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 18:10:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702230010.l1N0AcKX024560@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.3 -> 1.4 --- Log message: Add LPPassManager interface that LoopPass can use to skip rest of the passes in the queue for a loop. --- Diffs of the changes: (+13 -0) LoopPass.cpp | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.3 llvm/lib/Analysis/LoopPass.cpp:1.4 --- llvm/lib/Analysis/LoopPass.cpp:1.3 Thu Feb 22 17:45:15 2007 +++ llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 18:10:16 2007 @@ -57,6 +57,13 @@ delete LQ; } +/// Delete loop from the loop queue. This is used by Loop pass to inform +/// Loop Pass Manager that it should skip rest of the passes for this loop. +void LPPassManager::deleteLoopFromQueue(Loop *L) { + // Do not pop loop from LQ here. It will be done by runOnFunction while loop. + skipThisLoop = true; +} + // Recurse through all subloops and all loops into LQ. static void addLoopIntoQueue(Loop *L, LoopQueue *LQ) { for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) @@ -81,6 +88,8 @@ while (!LQ->empty()) { Loop *L = LQ->top(); + skipThisLoop = false; + // Run all passes on current SCC for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { @@ -107,6 +116,10 @@ removeNotPreservedAnalysis(P); recordAvailableAnalysis(P); removeDeadPasses(P, Msg2); + + if (skipThisLoop) + // Do not run other passes on this loop. + break; } // Pop the loop from queue after running all passes. From dpatel at apple.com Thu Feb 22 18:17:01 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 18:17:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702230017.l1N0H1eB024667@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.4 -> 1.5 --- Log message: Add facility that allows LoopPass to re-insert a loop into Loop Pass Manager's queue. --- Diffs of the changes: (+13 -0) LoopPass.cpp | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.4 llvm/lib/Analysis/LoopPass.cpp:1.5 --- llvm/lib/Analysis/LoopPass.cpp:1.4 Thu Feb 22 18:10:16 2007 +++ llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 18:16:44 2007 @@ -50,6 +50,8 @@ /// LPPassManager manages FPPassManagers and CalLGraphSCCPasses. LPPassManager::LPPassManager(int Depth) : PMDataManager(Depth) { + skipThisLoop = false; + redoThisLoop = false; LQ = new LoopQueue(); } @@ -64,6 +66,13 @@ skipThisLoop = true; } +// Reoptimize this loop. LPPassManager will re-insert this loop into the +// queue. This allows LoopPass to change loop nest for the loop. This +// utility may send LPPassManager into infinite loops so use caution. +void LPPassManager::redoLoop(Loop *L) { + redoThisLoop = true; +} + // Recurse through all subloops and all loops into LQ. static void addLoopIntoQueue(Loop *L, LoopQueue *LQ) { for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) @@ -89,6 +98,7 @@ Loop *L = LQ->top(); skipThisLoop = false; + redoThisLoop = false; // Run all passes on current SCC for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { @@ -124,6 +134,9 @@ // Pop the loop from queue after running all passes. LQ->pop(); + + if (redoThisLoop) + LQ->push(L); } return Changed; From dpatel at apple.com Thu Feb 22 18:17:03 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 18:17:03 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h Message-ID: <200702230017.l1N0H3ex024674@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopPass.h updated: 1.3 -> 1.4 --- Log message: Add facility that allows LoopPass to re-insert a loop into Loop Pass Manager's queue. --- Diffs of the changes: (+6 -1) LoopPass.h | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/include/llvm/Analysis/LoopPass.h diff -u llvm/include/llvm/Analysis/LoopPass.h:1.3 llvm/include/llvm/Analysis/LoopPass.h:1.4 --- llvm/include/llvm/Analysis/LoopPass.h:1.3 Thu Feb 22 18:10:16 2007 +++ llvm/include/llvm/Analysis/LoopPass.h Thu Feb 22 18:16:44 2007 @@ -85,10 +85,15 @@ // Delete loop from the loop queue. This is used by Loop pass to inform // Loop Pass Manager that it should skip rest of the passes for this loop. void deleteLoopFromQueue(Loop *L); + + // Reoptimize this loop. LPPassManager will re-insert this loop into the + // queue. This allows LoopPass to change loop nest for the loop. This + // utility may send LPPassManager into infinite loops so use caution. + void redoLoop(Loop *L); private: LoopQueue *LQ; bool skipThisLoop; - + bool redoThisLoop; }; } // End llvm namespace From dpatel at apple.com Thu Feb 22 18:37:19 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 18:37:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702230037.l1N0bJWD025011@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.5 -> 1.6 --- Log message: Teach LoopPass to assign itself one Loop Pass Manager. --- Diffs of the changes: (+41 -0) LoopPass.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.5 llvm/lib/Analysis/LoopPass.cpp:1.6 --- llvm/lib/Analysis/LoopPass.cpp:1.5 Thu Feb 22 18:16:44 2007 +++ llvm/lib/Analysis/LoopPass.cpp Thu Feb 22 18:36:57 2007 @@ -143,3 +143,44 @@ } +//===----------------------------------------------------------------------===// +// LoopPass + +/// Assign pass manager to manage this pass. +void LoopPass::assignPassManager(PMStack &PMS, + PassManagerType PreferredType) { + // Find LPPassManager + while (!PMS.empty()) { + if (PMS.top()->getPassManagerType() > PMT_LoopPassManager) + PMS.pop(); + else; + break; + } + + LPPassManager *LPPM = dynamic_cast(PMS.top()); + + // Create new Loop Pass Manager if it does not exist. + if (!LPPM) { + + assert (!PMS.empty() && "Unable to create Loop Pass Manager"); + PMDataManager *PMD = PMS.top(); + + // [1] Create new Call Graph Pass Manager + LPPM = new LPPassManager(PMD->getDepth() + 1); + + // [2] Set up new manager's top level manager + PMTopLevelManager *TPM = PMD->getTopLevelManager(); + TPM->addIndirectPassManager(LPPM); + + // [3] Assign manager to manage this new manager. This may create + // and push new managers into PMS + Pass *P = dynamic_cast(LPPM); + P->assignPassManager(PMS); + + // [4] Push new manager into PMS + PMS.push(LPPM); + } + + LPPM->add(this); +} + From dpatel at apple.com Thu Feb 22 18:37:19 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 22 Feb 2007 18:37:19 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h Message-ID: <200702230037.l1N0bICD025008@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopPass.h updated: 1.4 -> 1.5 --- Log message: Teach LoopPass to assign itself one Loop Pass Manager. --- Diffs of the changes: (+4 -0) LoopPass.h | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/include/llvm/Analysis/LoopPass.h diff -u llvm/include/llvm/Analysis/LoopPass.h:1.4 llvm/include/llvm/Analysis/LoopPass.h:1.5 --- llvm/include/llvm/Analysis/LoopPass.h:1.4 Thu Feb 22 18:16:44 2007 +++ llvm/include/llvm/Analysis/LoopPass.h Thu Feb 22 18:36:57 2007 @@ -37,6 +37,10 @@ return false; } + /// Assign pass manager to manager this pass + virtual void assignPassManager(PMStack &PMS, + PassManagerType PMT = PMT_LoopPassManager); + }; class LPPassManager : public FunctionPass, public PMDataManager { From evan.cheng at apple.com Thu Feb 22 19:01:37 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:01:37 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/RegisterScavenging.h Message-ID: <200702230101.l1N11bCA025547@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: RegisterScavenging.h added (r1.1) --- Log message: Initial check in of register scavenger. Its only current functionality is tracking live registers per MBB. --- Diffs of the changes: (+75 -0) RegisterScavenging.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 75 insertions(+) Index: llvm/include/llvm/CodeGen/RegisterScavenging.h diff -c /dev/null llvm/include/llvm/CodeGen/RegisterScavenging.h:1.1 *** /dev/null Thu Feb 22 19:01:29 2007 --- llvm/include/llvm/CodeGen/RegisterScavenging.h Thu Feb 22 19:01:19 2007 *************** *** 0 **** --- 1,75 ---- + //===-- RegisterScavenging.h - Machine register scavenging ------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the Evan Cheng and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file declares the machine register scavenger class. It can provide + // information such as unused register at any point in a machine basic block. + // It also provides a mechanism to make registers availbale by evicting them + // to spill slots. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_CODEGEN_REGISTER_SCAVENGING_H + #define LLVM_CODEGEN_REGISTER_SCAVENGING_H + + #include "llvm/CodeGen/MachineBasicBlock.h" + #include "llvm/ADT/BitVector.h" + + namespace llvm { + + class TargetRegisterClass; + + class RegScavenger { + MachineBasicBlock *MBB; + MachineBasicBlock::iterator MBBI; + unsigned NumPhysRegs; + + /// RegStates - The current state of all the physical registers immediately + /// before MBBI. One bit per physical register. If bit is set that means it's + /// available, unset means the register is currently being used. + BitVector RegStates; + + public: + RegScavenger(MachineBasicBlock *mbb); + + /// forward / backward - Move the internal MBB iterator and update register + /// states. + void forward(); + void backward(); + + /// isReserved - Returns true if a register is reserved. It is never "unused". + bool isReserved(unsigned Reg) const { return ReservedRegs[Reg]; } + + /// isUsed / isUsed - Test if a register is currently being used. + /// + bool isUsed(unsigned Reg) const { return !RegStates[Reg]; } + bool isUnused(unsigned Reg) const { return RegStates[Reg]; } + + /// setUsed / setUnused - Mark the state of one or a number of registers. + /// + void setUsed(unsigned Reg) { RegStates.reset(Reg); } + void setUsed(BitVector Regs) { RegStates &= ~Regs; } + void setUnused(unsigned Reg) { RegStates.set(Reg); } + void setUnused(BitVector Regs) { RegStates |= Regs; } + + /// FindUnusedReg - Find a unused register of the specified register class. + /// Exclude callee saved registers if directed. It return 0 is none is found. + unsigned FindUnusedReg(const TargetRegisterClass *RegClass, + bool ExCalleeSaved = false) const; + + private: + /// CalleeSavedrRegs - A bitvector of callee saved registers for the target. + BitVector CalleeSavedRegs; + + /// ReservedRegs - A bitvector of reserved registers. + BitVector ReservedRegs; + }; + + } // End llvm namespace + + #endif From evan.cheng at apple.com Thu Feb 22 19:01:37 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:01:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegisterScavenging.cpp Message-ID: <200702230101.l1N11bcg025553@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegisterScavenging.cpp added (r1.1) --- Log message: Initial check in of register scavenger. Its only current functionality is tracking live registers per MBB. --- Diffs of the changes: (+140 -0) RegisterScavenging.cpp | 140 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 140 insertions(+) Index: llvm/lib/CodeGen/RegisterScavenging.cpp diff -c /dev/null llvm/lib/CodeGen/RegisterScavenging.cpp:1.1 *** /dev/null Thu Feb 22 19:01:29 2007 --- llvm/lib/CodeGen/RegisterScavenging.cpp Thu Feb 22 19:01:19 2007 *************** *** 0 **** --- 1,140 ---- + //===-- RegisterScavenging.cpp - Machine register scavenging --------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the Evan Cheng and is distributed under the + // University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the machine register scavenger. It can provide + // information such as unused register at any point in a machine basic block. + // It also provides a mechanism to make registers availbale by evicting them + // to spill slots. + // + //===----------------------------------------------------------------------===// + + #define DEBUG_TYPE "reg-scavenging" + #include "llvm/CodeGen/RegisterScavenging.h" + #include "llvm/CodeGen/MachineFunction.h" + #include "llvm/CodeGen/MachineBasicBlock.h" + #include "llvm/CodeGen/MachineInstr.h" + #include "llvm/Target/MRegisterInfo.h" + #include "llvm/Target/TargetInstrInfo.h" + #include "llvm/Target/TargetMachine.h" + using namespace llvm; + + RegScavenger::RegScavenger(MachineBasicBlock *mbb) + : MBB(mbb), MBBI(mbb->begin()) { + const MachineFunction &MF = *MBB->getParent(); + const TargetMachine &TM = MF.getTarget(); + const MRegisterInfo *RegInfo = TM.getRegisterInfo(); + + NumPhysRegs = RegInfo->getNumRegs(); + RegStates.resize(NumPhysRegs, true); + + // Create reserved registers bitvector. + ReservedRegs = RegInfo->getReservedRegs(MF); + RegStates ^= ReservedRegs; + + // Create callee-saved registers bitvector. + CalleeSavedRegs.resize(NumPhysRegs); + const unsigned *CSRegs = RegInfo->getCalleeSavedRegs(); + if (CSRegs != NULL) + for (unsigned i = 0; CSRegs[i]; ++i) + CalleeSavedRegs.set(CSRegs[i]); + } + + void RegScavenger::forward() { + MachineInstr *MI = MBBI; + // Process uses first. + BitVector ChangedRegs(NumPhysRegs); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isUse()) + continue; + unsigned Reg = MO.getReg(); + if (Reg == 0) + continue; + assert(isUsed(Reg)); + if (MO.isKill() && !isReserved(Reg)) + ChangedRegs.set(Reg); + } + // Change states of all registers after all the uses are processed to guard + // against multiple uses. + setUnused(ChangedRegs); + + // Process defs. + const TargetInstrDescriptor *TID = MI->getInstrDescriptor(); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + // Skip two-address destination operand. + if (TID->findTiedToSrcOperand(i) != -1) + continue; + unsigned Reg = MO.getReg(); + assert(isUnused(Reg) || isReserved(Reg)); + if (!MO.isDead()) + setUsed(Reg); + } + + ++MBBI; + } + + void RegScavenger::backward() { + MachineInstr *MI = --MBBI; + // Process defs first. + const TargetInstrDescriptor *TID = MI->getInstrDescriptor(); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + // Skip two-address destination operand. + if (TID->findTiedToSrcOperand(i) != -1) + continue; + unsigned Reg = MO.getReg(); + assert(isUsed(Reg)); + if (!isReserved(Reg)) + setUnused(Reg); + } + + // Process uses. + BitVector ChangedRegs(NumPhysRegs); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isUse()) + continue; + unsigned Reg = MO.getReg(); + if (Reg == 0) + continue; + assert(isUnused(Reg) || isReserved(Reg)); + ChangedRegs.set(Reg); + } + setUsed(ChangedRegs); + } + + /// CreateRegClassMask - Set the bits that represent the registers in the + /// TargetRegisterClass. + static void CreateRegClassMask(const TargetRegisterClass *RC, BitVector &Mask) { + for (TargetRegisterClass::iterator I = RC->begin(), E = RC->end(); I != E; + ++I) + Mask.set(*I); + } + + unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RegClass, + bool ExCalleeSaved) const { + // Mask off the registers which are not in the TargetRegisterClass. + BitVector RegStatesCopy(NumPhysRegs, false); + CreateRegClassMask(RegClass, RegStatesCopy); + RegStatesCopy &= RegStates; + + // If looking for a non-callee-saved register, mask off all the callee-saved + // registers. + if (ExCalleeSaved) + RegStatesCopy &= ~CalleeSavedRegs; + + // Returns the first unused (bit is set) register, or 0 is none is found. + int Reg = RegStatesCopy.find_first(); + return (Reg == -1) ? 0 : Reg; + } From evan.cheng at apple.com Thu Feb 22 19:03:56 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:03:56 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineInstr.h Message-ID: <200702230103.l1N13uD2025611@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineInstr.h updated: 1.212 -> 1.213 --- Log message: Use findRegisterUseOperand to find a kill of particular register. --- Diffs of the changes: (+3 -2) MachineInstr.h | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/include/llvm/CodeGen/MachineInstr.h diff -u llvm/include/llvm/CodeGen/MachineInstr.h:1.212 llvm/include/llvm/CodeGen/MachineInstr.h:1.213 --- llvm/include/llvm/CodeGen/MachineInstr.h:1.212 Mon Feb 19 15:49:53 2007 +++ llvm/include/llvm/CodeGen/MachineInstr.h Thu Feb 22 19:03:39 2007 @@ -390,8 +390,9 @@ } /// findRegisterUseOperand() - Returns the MachineOperand that is a use of - /// the specific register or NULL if it is not found. - MachineOperand *findRegisterUseOperand(unsigned Reg); + /// the specific register or NULL if it is not found. It further tightening + /// the search criteria to a use that kills the register if isKill is true. + MachineOperand *findRegisterUseOperand(unsigned Reg, bool isKill = false); /// findRegisterDefOperand() - Returns the MachineOperand that is a def of /// the specific register or NULL if it is not found. From evan.cheng at apple.com Thu Feb 22 19:04:42 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:04:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200702230104.l1N14gcX025644@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.144 -> 1.145 --- Log message: Use findRegisterUseOperand to find a kill of particular register. --- Diffs of the changes: (+5 -3) MachineInstr.cpp | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.144 llvm/lib/CodeGen/MachineInstr.cpp:1.145 --- llvm/lib/CodeGen/MachineInstr.cpp:1.144 Mon Feb 19 15:49:53 2007 +++ llvm/lib/CodeGen/MachineInstr.cpp Thu Feb 22 19:04:26 2007 @@ -170,12 +170,14 @@ } /// findRegisterUseOperand() - Returns the MachineOperand that is a use of -/// the specific register or NULL if it is not found. -MachineOperand *MachineInstr::findRegisterUseOperand(unsigned Reg) { +/// the specific register or NULL if it is not found. It further tightening +/// the search criteria to a use that kills the register if isKill is true. +MachineOperand *MachineInstr::findRegisterUseOperand(unsigned Reg, bool isKill){ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { MachineOperand &MO = getOperand(i); if (MO.isReg() && MO.isUse() && MO.getReg() == Reg) - return &MO; + if (!isKill || MO.isKill()) + return &MO; } return NULL; } From evan.cheng at apple.com Thu Feb 22 19:07:21 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:07:21 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h Message-ID: <200702230107.l1N17Lhx025705@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: MRegisterInfo.h updated: 1.96 -> 1.97 --- Log message: Temporay hook to enable register scavening for specific targets only. --- Diffs of the changes: (+6 -0) MRegisterInfo.h | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/include/llvm/Target/MRegisterInfo.h diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.96 llvm/include/llvm/Target/MRegisterInfo.h:1.97 --- llvm/include/llvm/Target/MRegisterInfo.h:1.96 Thu Feb 22 08:56:35 2007 +++ llvm/include/llvm/Target/MRegisterInfo.h Thu Feb 22 19:07:04 2007 @@ -391,6 +391,12 @@ return false; } + /// requiresRegisterScavenging - returns true if the target requires (and + /// can make use of) the register scavenger. + virtual bool requiresRegisterScavenging() const { + return false; + } + /// hasFP - Return true if the specified function should have a dedicated frame /// pointer register. For most targets this is true only if the function has /// variable sized allocas or if frame pointer elimination is disabled. From evan.cheng at apple.com Thu Feb 22 19:09:28 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:09:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMRegisterInfo.cpp ARMRegisterInfo.h Message-ID: <200702230109.l1N19SIn025763@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMRegisterInfo.cpp updated: 1.70 -> 1.71 ARMRegisterInfo.h updated: 1.11 -> 1.12 --- Log message: Add option to turn on register scavenger; By default, spills kills the register being stored. --- Diffs of the changes: (+20 -6) ARMRegisterInfo.cpp | 24 ++++++++++++++++++------ ARMRegisterInfo.h | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.70 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.71 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.70 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Thu Feb 22 19:09:11 2007 @@ -31,9 +31,13 @@ #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; +static cl::opt EnableScavenging("enable-arm-reg-scavenging", cl::Hidden, + cl::desc("Enable register scavenging on ARM")); + unsigned ARMRegisterInfo::getRegisterNumbering(unsigned RegEnum) { using namespace ARM; switch (RegEnum) { @@ -91,8 +95,12 @@ return false; MachineInstrBuilder MIB = BuildMI(MBB, MI, TII.get(ARM::tPUSH)); - for (unsigned i = CSI.size(); i != 0; --i) - MIB.addReg(CSI[i-1].getReg()); + for (unsigned i = CSI.size(); i != 0; --i) { + unsigned Reg = CSI[i-1].getReg(); + // Add the callee-saved register as live-in. It's killed at the spill. + MBB.addLiveIn(Reg); + MIB.addReg(Reg, false/*isDef*/,false/*isImp*/,true/*isKill*/); + } return true; } @@ -130,17 +138,17 @@ MachineFunction &MF = *MBB.getParent(); ARMFunctionInfo *AFI = MF.getInfo(); if (AFI->isThumbFunction()) - BuildMI(MBB, I, TII.get(ARM::tSpill)).addReg(SrcReg) + BuildMI(MBB, I, TII.get(ARM::tSpill)).addReg(SrcReg, false, false, true) .addFrameIndex(FI).addImm(0); else - BuildMI(MBB, I, TII.get(ARM::STR)).addReg(SrcReg) + BuildMI(MBB, I, TII.get(ARM::STR)).addReg(SrcReg, false, false, true) .addFrameIndex(FI).addReg(0).addImm(0); } else if (RC == ARM::DPRRegisterClass) { - BuildMI(MBB, I, TII.get(ARM::FSTD)).addReg(SrcReg) + BuildMI(MBB, I, TII.get(ARM::FSTD)).addReg(SrcReg, false, false, true) .addFrameIndex(FI).addImm(0); } else { assert(RC == ARM::SPRRegisterClass && "Unknown regclass!"); - BuildMI(MBB, I, TII.get(ARM::FSTS)).addReg(SrcReg) + BuildMI(MBB, I, TII.get(ARM::FSTS)).addReg(SrcReg, false, false, true) .addFrameIndex(FI).addImm(0); } } @@ -320,6 +328,10 @@ return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects(); } +bool ARMRegisterInfo::requiresRegisterScavenging() const { + return EnableScavenging; +} + /// emitARMRegPlusImmediate - Emits a series of instructions to materialize /// a destreg = basereg + immediate in ARM code. static Index: llvm/lib/Target/ARM/ARMRegisterInfo.h diff -u llvm/lib/Target/ARM/ARMRegisterInfo.h:1.11 llvm/lib/Target/ARM/ARMRegisterInfo.h:1.12 --- llvm/lib/Target/ARM/ARMRegisterInfo.h:1.11 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.h Thu Feb 22 19:09:11 2007 @@ -69,6 +69,8 @@ BitVector getReservedRegs(const MachineFunction &MF) const; + bool requiresRegisterScavenging() const; + bool hasFP(const MachineFunction &MF) const; void eliminateCallFramePseudoInstr(MachineFunction &MF, From evan.cheng at apple.com Thu Feb 22 19:10:28 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:10:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Message-ID: <200702230110.l1N1ASEH025826@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Sparc: SparcRegisterInfo.cpp updated: 1.55 -> 1.56 --- Log message: By default, spills kills the register being stored. --- Diffs of the changes: (+3 -3) SparcRegisterInfo.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.55 llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.56 --- llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.55 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Thu Feb 22 19:10:04 2007 @@ -37,13 +37,13 @@ // On the order of operands here: think "[FrameIdx + 0] = SrcReg". if (RC == SP::IntRegsRegisterClass) BuildMI(MBB, I, TII.get(SP::STri)).addFrameIndex(FI).addImm(0) - .addReg(SrcReg); + .addReg(SrcReg, false, false, true); else if (RC == SP::FPRegsRegisterClass) BuildMI(MBB, I, TII.get(SP::STFri)).addFrameIndex(FI).addImm(0) - .addReg(SrcReg); + .addReg(SrcReg, false, false, true); else if (RC == SP::DFPRegsRegisterClass) BuildMI(MBB, I, TII.get(SP::STDFri)).addFrameIndex(FI).addImm(0) - .addReg(SrcReg); + .addReg(SrcReg, false, false, true); else assert(0 && "Can't store this register to stack slot"); } From evan.cheng at apple.com Thu Feb 22 19:10:31 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:10:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64RegisterInfo.cpp Message-ID: <200702230110.l1N1AVaX025831@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/IA64: IA64RegisterInfo.cpp updated: 1.32 -> 1.33 --- Log message: By default, spills kills the register being stored. --- Diffs of the changes: (+6 -5) IA64RegisterInfo.cpp | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) Index: llvm/lib/Target/IA64/IA64RegisterInfo.cpp diff -u llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.32 llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.33 --- llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.32 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/IA64/IA64RegisterInfo.cpp Thu Feb 22 19:10:03 2007 @@ -42,17 +42,18 @@ const TargetRegisterClass *RC) const{ if (RC == IA64::FPRegisterClass) { - BuildMI(MBB, MI, TII.get(IA64::STF_SPILL)).addFrameIndex(FrameIdx).addReg(SrcReg); + BuildMI(MBB, MI, TII.get(IA64::STF_SPILL)).addFrameIndex(FrameIdx) + .addReg(SrcReg, false, false, true); } else if (RC == IA64::GRRegisterClass) { - BuildMI(MBB, MI, TII.get(IA64::ST8)).addFrameIndex(FrameIdx).addReg(SrcReg); - } - else if (RC == IA64::PRRegisterClass) { + BuildMI(MBB, MI, TII.get(IA64::ST8)).addFrameIndex(FrameIdx) + .addReg(SrcReg, false, false, true); + } else if (RC == IA64::PRRegisterClass) { /* we use IA64::r2 as a temporary register for doing this hackery. */ // first we load 0: BuildMI(MBB, MI, TII.get(IA64::MOV), IA64::r2).addReg(IA64::r0); // then conditionally add 1: BuildMI(MBB, MI, TII.get(IA64::CADDIMM22), IA64::r2).addReg(IA64::r2) - .addImm(1).addReg(SrcReg); + .addImm(1).addReg(SrcReg, false, false, true); // and then store it to the stack BuildMI(MBB, MI, TII.get(IA64::ST8)).addFrameIndex(FrameIdx).addReg(IA64::r2); } else assert(0 && From evan.cheng at apple.com Thu Feb 22 19:10:31 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:10:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Message-ID: <200702230110.l1N1AVEw025834@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCRegisterInfo.cpp updated: 1.109 -> 1.110 --- Log message: By default, spills kills the register being stored. --- Diffs of the changes: (+15 -15) PPCRegisterInfo.cpp | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-) Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.109 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.110 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.109 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Thu Feb 22 19:10:03 2007 @@ -104,34 +104,34 @@ const TargetRegisterClass *RC) const { if (RC == PPC::GPRCRegisterClass) { if (SrcReg != PPC::LR) { - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STW)).addReg(SrcReg), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STW)) + .addReg(SrcReg, false, false, true), FrameIdx); } else { // FIXME: this spills LR immediately to memory in one step. To do this, // we use R11, which we know cannot be used in the prolog/epilog. This is // a hack. BuildMI(MBB, MI, TII.get(PPC::MFLR), PPC::R11); - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STW)).addReg(PPC::R11), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STW)) + .addReg(PPC::R11, false, false, true), FrameIdx); } } else if (RC == PPC::G8RCRegisterClass) { if (SrcReg != PPC::LR8) { - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STD)).addReg(SrcReg), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STD)) + .addReg(SrcReg, false, false, true), FrameIdx); } else { // FIXME: this spills LR immediately to memory in one step. To do this, // we use R11, which we know cannot be used in the prolog/epilog. This is // a hack. BuildMI(MBB, MI, TII.get(PPC::MFLR8), PPC::X11); - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STD)).addReg(PPC::X11), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STD)) + .addReg(PPC::X11, false, false, true), FrameIdx); } } else if (RC == PPC::F8RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STFD)).addReg(SrcReg), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STFD)) + .addReg(SrcReg, false, false, true), FrameIdx); } else if (RC == PPC::F4RCRegisterClass) { - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STFS)).addReg(SrcReg), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STFS)) + .addReg(SrcReg, false, false, true), FrameIdx); } else if (RC == PPC::CRRCRegisterClass) { // FIXME: We use R0 here, because it isn't available for RA. // We need to store the CR in the low 4-bits of the saved value. First, @@ -147,8 +147,8 @@ .addReg(PPC::R0).addImm(ShiftBits).addImm(0).addImm(31); } - addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STW)).addReg(PPC::R0), - FrameIdx); + addFrameReference(BuildMI(MBB, MI, TII.get(PPC::STW)) + .addReg(PPC::R0, false, false, true), FrameIdx); } else if (RC == PPC::VRRCRegisterClass) { // We don't have indexed addressing for vector loads. Emit: // R11 = ADDI FI# @@ -158,7 +158,7 @@ addFrameReference(BuildMI(MBB, MI, TII.get(PPC::ADDI), PPC::R0), FrameIdx, 0, 0); BuildMI(MBB, MI, TII.get(PPC::STVX)) - .addReg(SrcReg).addReg(PPC::R0).addReg(PPC::R0); + .addReg(SrcReg, false, false, true).addReg(PPC::R0).addReg(PPC::R0); } else { assert(0 && "Unknown regclass!"); abort(); From evan.cheng at apple.com Thu Feb 22 19:10:32 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:10:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200702230110.l1N1AWhL025841@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.204 -> 1.205 --- Log message: By default, spills kills the register being stored. --- Diffs of the changes: (+2 -1) X86RegisterInfo.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.204 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.205 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.204 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Thu Feb 22 19:10:04 2007 @@ -93,7 +93,8 @@ assert(0 && "Unknown regclass"); abort(); } - addFrameReference(BuildMI(MBB, MI, TII.get(Opc)), FrameIdx).addReg(SrcReg); + addFrameReference(BuildMI(MBB, MI, TII.get(Opc)), FrameIdx) + .addReg(SrcReg, false, false, true); } void X86RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, From evan.cheng at apple.com Thu Feb 22 19:10:32 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:10:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200702230110.l1N1AWAq025846@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.61 -> 1.62 --- Log message: By default, spills kills the register being stored. --- Diffs of the changes: (+6 -3) AlphaRegisterInfo.cpp | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.61 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.62 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.61 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Thu Feb 22 19:10:03 2007 @@ -68,13 +68,16 @@ //BuildMI(MBB, MI, Alpha::WTF, 0).addReg(SrcReg); if (RC == Alpha::F4RCRegisterClass) BuildMI(MBB, MI, TII.get(Alpha::STS)) - .addReg(SrcReg).addFrameIndex(FrameIdx).addReg(Alpha::F31); + .addReg(SrcReg, false, false, true) + .addFrameIndex(FrameIdx).addReg(Alpha::F31); else if (RC == Alpha::F8RCRegisterClass) BuildMI(MBB, MI, TII.get(Alpha::STT)) - .addReg(SrcReg).addFrameIndex(FrameIdx).addReg(Alpha::F31); + .addReg(SrcReg, false, false, true) + .addFrameIndex(FrameIdx).addReg(Alpha::F31); else if (RC == Alpha::GPRCRegisterClass) BuildMI(MBB, MI, TII.get(Alpha::STQ)) - .addReg(SrcReg).addFrameIndex(FrameIdx).addReg(Alpha::F31); + .addReg(SrcReg, false, false, true) + .addFrameIndex(FrameIdx).addReg(Alpha::F31); else abort(); } From evan.cheng at apple.com Thu Feb 22 19:11:43 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:11:43 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PrologEpilogInserter.cpp Message-ID: <200702230111.l1N1Bhvc025885@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: PrologEpilogInserter.cpp updated: 1.68 -> 1.69 --- Log message: First potential client of register scavenger. --- Diffs of the changes: (+13 -4) PrologEpilogInserter.cpp | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.68 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.69 --- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.68 Fri Jan 26 15:22:28 2007 +++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Thu Feb 22 19:11:26 2007 @@ -20,6 +20,7 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/RegisterScavenging.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetFrameInfo.h" @@ -231,10 +232,12 @@ MachineBasicBlock::iterator I = MBB->begin(); if (!RegInfo->spillCalleeSavedRegisters(*MBB, I, CSI)) { for (unsigned i = 0, e = CSI.size(); i != e; ++i) { + // Add the callee-saved register as live-in. It's killed at the spill. + MBB->addLiveIn(CSI[i].getReg()); + // Insert the spill to the stack frame. RegInfo->storeRegToStackSlot(*MBB, I, CSI[i].getReg(), - CSI[i].getFrameIdx(), - CSI[i].getRegClass()); + CSI[i].getFrameIdx(), CSI[i].getRegClass()); } } @@ -440,8 +443,9 @@ assert(TM.getRegisterInfo() && "TM::getRegisterInfo() must be implemented!"); const MRegisterInfo &MRI = *TM.getRegisterInfo(); - for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) - for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) + for (MachineFunction::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) { + RegScavenger RS(BB); + for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) { for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) if (I->getOperand(i).isFrameIndex()) { // If this instruction has a FrameIndex operand, we need to use that @@ -449,4 +453,9 @@ MRI.eliminateFrameIndex(I); break; } + // Update register states. + if (MRI.requiresRegisterScavenging()) + RS.forward(); + } + } } From evan.cheng at apple.com Thu Feb 22 19:13:42 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 19:13:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp Message-ID: <200702230113.l1N1Dgm2025929@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.97 -> 1.98 --- Log message: A spill kills the register being stored. But it is later being reused by spiller, its live range has to be extended. --- Diffs of the changes: (+39 -25) VirtRegMap.cpp | 64 ++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 39 insertions(+), 25 deletions(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.97 llvm/lib/CodeGen/VirtRegMap.cpp:1.98 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.97 Tue Feb 20 20:22:03 2007 +++ llvm/lib/CodeGen/VirtRegMap.cpp Thu Feb 22 19:13:26 2007 @@ -255,7 +255,8 @@ // SpillSlotsAvailable - This map keeps track of all of the spilled virtual // register values that are still available, due to being loaded or stored to, // but not invalidated yet. - std::map SpillSlotsAvailable; + typedef std::pair SSInfo; + std::map SpillSlotsAvailable; // PhysRegsAvailable - This is the inverse of SpillSlotsAvailable, indicating // which stack slot values are currently held by a physreg. This is used to @@ -270,27 +271,33 @@ : MRI(mri), TII(tii) { } + const MRegisterInfo *getRegInfo() const { return MRI; } + /// getSpillSlotPhysReg - If the specified stack slot is available in a - /// physical register, return that PhysReg, otherwise return 0. - unsigned getSpillSlotPhysReg(int Slot) const { - std::map::const_iterator I = SpillSlotsAvailable.find(Slot); - if (I != SpillSlotsAvailable.end()) - return I->second >> 1; // Remove the CanClobber bit. + /// physical register, return that PhysReg, otherwise return 0. It also + /// returns by reference the instruction that either defines or last uses + /// the register. + unsigned getSpillSlotPhysReg(int Slot, MachineInstr *&SSMI) const { + std::map::const_iterator I = SpillSlotsAvailable.find(Slot); + if (I != SpillSlotsAvailable.end()) { + SSMI = I->second.second; + return I->second.first >> 1; // Remove the CanClobber bit. + } return 0; } - const MRegisterInfo *getRegInfo() const { return MRI; } - /// addAvailable - Mark that the specified stack slot is available in the /// specified physreg. If CanClobber is true, the physreg can be modified at /// any time without changing the semantics of the program. - void addAvailable(int Slot, unsigned Reg, bool CanClobber = true) { + void addAvailable(int Slot, MachineInstr *MI, unsigned Reg, + bool CanClobber = true) { // If this stack slot is thought to be available in some other physreg, // remove its record. ModifyStackSlot(Slot); PhysRegsAvailable.insert(std::make_pair(Reg, Slot)); - SpillSlotsAvailable[Slot] = (Reg << 1) | (unsigned)CanClobber; + SpillSlotsAvailable[Slot] = + std::make_pair((Reg << 1) | (unsigned)CanClobber, MI); DOUT << "Remembering SS#" << Slot << " in physreg " << MRI->getName(Reg) << "\n"; @@ -301,7 +308,7 @@ /// stack slot must be available in a physreg for this query to make sense. bool canClobberPhysReg(int Slot) const { assert(SpillSlotsAvailable.count(Slot) && "Slot not available!"); - return SpillSlotsAvailable.find(Slot)->second & 1; + return SpillSlotsAvailable.find(Slot)->second.first & 1; } /// disallowClobberPhysReg - Unset the CanClobber bit of the specified @@ -330,9 +337,9 @@ while (I != PhysRegsAvailable.end() && I->first == PhysReg) { int Slot = I->second; I++; - assert((SpillSlotsAvailable[Slot] >> 1) == PhysReg && + assert((SpillSlotsAvailable[Slot].first >> 1) == PhysReg && "Bidirectional map mismatch!"); - SpillSlotsAvailable[Slot] &= ~1; + SpillSlotsAvailable[Slot].first &= ~1; DOUT << "PhysReg " << MRI->getName(PhysReg) << " copied, it is available for use but can no longer be modified\n"; } @@ -355,7 +362,7 @@ while (I != PhysRegsAvailable.end() && I->first == PhysReg) { int Slot = I->second; PhysRegsAvailable.erase(I++); - assert((SpillSlotsAvailable[Slot] >> 1) == PhysReg && + assert((SpillSlotsAvailable[Slot].first >> 1) == PhysReg && "Bidirectional map mismatch!"); SpillSlotsAvailable.erase(Slot); DOUT << "PhysReg " << MRI->getName(PhysReg) @@ -376,9 +383,9 @@ /// changes. This removes information about which register the previous value /// for this slot lives in (as the previous value is dead now). void AvailableSpills::ModifyStackSlot(int Slot) { - std::map::iterator It = SpillSlotsAvailable.find(Slot); + std::map::iterator It = SpillSlotsAvailable.find(Slot); if (It == SpillSlotsAvailable.end()) return; - unsigned Reg = It->second >> 1; + unsigned Reg = It->second.first >> 1; SpillSlotsAvailable.erase(It); // This register may hold the value of multiple stack slots, only remove this @@ -514,7 +521,7 @@ MI->getOperand(NewOp.Operand).setReg(NewPhysReg); - Spills.addAvailable(NewOp.StackSlot, NewPhysReg); + Spills.addAvailable(NewOp.StackSlot, MI, NewPhysReg); ++NumLoads; DEBUG(MachineBasicBlock::iterator MII = MI; DOUT << '\t' << *prior(MII)); @@ -628,8 +635,8 @@ unsigned PhysReg; // Check to see if this stack slot is available. - if ((PhysReg = Spills.getSpillSlotPhysReg(StackSlot))) { - + MachineInstr *SSMI = NULL; + if ((PhysReg = Spills.getSpillSlotPhysReg(StackSlot, SSMI))) { // This spilled operand might be part of a two-address operand. If this // is the case, then changing it will necessarily require changing the // def part of the instruction as well. However, in some cases, we @@ -655,6 +662,12 @@ << MRI->getName(VRM.getPhys(VirtReg)) << "\n"; MI.getOperand(i).setReg(PhysReg); + // Extend the live range of the MI that last kill the register if + // necessary. + MachineOperand *MOK = SSMI->findRegisterUseOperand(PhysReg, true); + if (MOK) + MOK->unsetIsKill(); + // The only technical detail we have is that we don't know that // PhysReg won't be clobbered by a reloaded stack slot that occurs // later in the instruction. In particular, consider 'op V1, V2'. @@ -723,7 +736,7 @@ // This invalidates DesignatedReg. Spills.ClobberPhysReg(DesignatedReg); - Spills.addAvailable(StackSlot, DesignatedReg); + Spills.addAvailable(StackSlot, &MI, DesignatedReg); MI.getOperand(i).setReg(DesignatedReg); DOUT << '\t' << *prior(MII); ++NumReused; @@ -752,7 +765,7 @@ // Any stores to this stack slot are not dead anymore. MaybeDeadStores.erase(StackSlot); - Spills.addAvailable(StackSlot, PhysReg); + Spills.addAvailable(StackSlot, &MI, PhysReg); ++NumLoads; MI.getOperand(i).setReg(PhysReg); DOUT << '\t' << *prior(MII); @@ -784,7 +797,8 @@ if (FrameIdx == SS) { // If this spill slot is available, turn it into a copy (or nothing) // instead of leaving it as a load! - if (unsigned InReg = Spills.getSpillSlotPhysReg(SS)) { + MachineInstr *Dummy = NULL; + if (unsigned InReg = Spills.getSpillSlotPhysReg(SS, Dummy)) { DOUT << "Promoted Load To Copy: " << MI; MachineFunction &MF = *MBB.getParent(); if (DestReg != InReg) { @@ -844,7 +858,7 @@ // If the stack slot value was previously available in some other // register, change it now. Otherwise, make the register available, // in PhysReg. - Spills.addAvailable(StackSlot, SrcReg, false /*don't clobber*/); + Spills.addAvailable(StackSlot, &MI, SrcReg, false/*don't clobber*/); } } } @@ -880,7 +894,7 @@ assert(DestReg == VirtReg && "Unknown load situation!"); // Otherwise, if it wasn't available, remember that it is now! - Spills.addAvailable(FrameIdx, DestReg); + Spills.addAvailable(FrameIdx, &MI, DestReg); goto ProcessNextInst; } @@ -929,7 +943,7 @@ // in PhysReg. Spills.ModifyStackSlot(StackSlot); Spills.ClobberPhysReg(PhysReg); - Spills.addAvailable(StackSlot, PhysReg); + Spills.addAvailable(StackSlot, LastStore, PhysReg); ++NumStores; // Check to see if this is a noop copy. If so, eliminate the From reid at x10sys.com Thu Feb 22 19:57:30 2007 From: reid at x10sys.com (Reid Spencer) Date: Thu, 22 Feb 2007 19:57:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702230157.l1N1vUvS026764@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.31 -> 1.32 --- Log message: 1. Fix a carry out problem in add if destination and x point to the same memory (as done in fromString). 2. Implement Knuth divide more closely to what is recommended in his book. 3. Fix computation of the remainder for Knuth Divide (bad shifting). 4. Remove some cruft from the file --- Diffs of the changes: (+43 -92) APInt.cpp | 135 +++++++++++++++++++------------------------------------------- 1 files changed, 43 insertions(+), 92 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.31 llvm/lib/Support/APInt.cpp:1.32 --- llvm/lib/Support/APInt.cpp:1.31 Wed Feb 21 18:58:45 2007 +++ llvm/lib/Support/APInt.cpp Thu Feb 22 19:57:13 2007 @@ -190,10 +190,10 @@ /// add - This function adds the integer array x[] by integer array /// y[] and returns the carry. static uint64_t add(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) { - uint64_t carry = 0; + bool carry = 0; for (uint32_t i = 0; i< len; ++i) { + uint64_t limit = std::min(x[i],y[i]); // must come first in case dest == x dest[i] = x[i] + y[i] + carry; - uint64_t limit = std::min(x[i],y[i]); carry = dest[i] < limit || (carry && dest[i] == limit); } return carry; @@ -979,65 +979,6 @@ return API; } -#if 0 -/// subMul - This function substracts x[len-1:0] * y from -/// dest[offset+len-1:offset], and returns the most significant -/// word of the product, minus the borrow-out from the subtraction. -static uint32_t subMul(uint32_t dest[], uint32_t offset, - uint32_t x[], uint32_t len, uint32_t y) { - uint64_t yl = (uint64_t) y & 0xffffffffL; - uint32_t carry = 0; - uint32_t j = 0; - do { - uint64_t prod = ((uint64_t) x[j] & 0xffffffffUL) * yl; - uint32_t prod_low = (uint32_t) prod; - uint32_t prod_high = (uint32_t) (prod >> 32); - prod_low += carry; - carry = (prod_low < carry ? 1 : 0) + prod_high; - uint32_t x_j = dest[offset+j]; - prod_low = x_j - prod_low; - if (prod_low > x_j) ++carry; - dest[offset+j] = prod_low; - } while (++j < len); - return carry; -} - -/// unitDiv - This function divides N by D, -/// and returns (remainder << 32) | quotient. -/// Assumes (N >> 32) < D. -static uint64_t unitDiv(uint64_t N, uint32_t D) { - uint64_t q, r; // q: quotient, r: remainder. - uint64_t a1 = N >> 32; // a1: high 32-bit part of N. - uint64_t a0 = N & 0xffffffffL; // a0: low 32-bit part of N - if (a1 < ((D - a1 - (a0 >> 31)) & 0xffffffffL)) { - q = N / D; - r = N % D; - } - else { - // Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d - uint64_t c = N - ((uint64_t) D << 31); - // Divide (c1*2^32 + c0) by d - q = c / D; - r = c % D; - // Add 2^31 to quotient - q += 1 << 31; - } - - return (r << 32) | (q & 0xFFFFFFFFl); -} - -#endif - -/// div - This is basically Knuth's formulation of the classical algorithm. -/// Correspondance with Knuth's notation: -/// Knuth's u[0:m+n] == zds[nx:0]. -/// Knuth's v[1:n] == y[ny-1:0] -/// Knuth's n == ny. -/// Knuth's m == nx-ny. -/// Our nx == Knuth's m+n. -/// Could be re-implemented using gmp's mpn_divrem: -/// zds[nx] = mpn_divrem (&zds[ny], 0, zds, nx, y, ny). - /// Implementation of Knuth's Algorithm D (Division of nonnegative integers) /// from "Art of Computer Programming, Volume 2", section 4.3.1, p. 272. The /// variables here have the same names as in the algorithm. Comments explain @@ -1089,32 +1030,42 @@ // on v[n-2] determines at high speed most of the cases in which the trial // value qp is one too large, and it eliminates all cases where qp is two // too large. - uint64_t qp = ((uint64_t(u[j+n]) << 32) | uint64_t(u[j+n-1])) / v[n-1]; - uint64_t rp = ((uint64_t(u[j+n]) << 32) | uint64_t(u[j+n-1])) % v[n-1]; + uint64_t dividend = ((uint64_t(u[j+n]) << 32) + u[j+n-1]); + uint64_t qp = dividend / v[n-1]; + uint64_t rp = dividend % v[n-1]; if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { qp--; rp += v[n-1]; - } - if (rp < b) - if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { - qp--; - rp += v[n-1]; + if (rp < b) { + if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { + qp--; + rp += v[n-1]; + } } + } - // D4. [Multiply and subtract.] Replace u with u - q*v (for each word). - uint32_t borrow = 0; - for (uint32_t i = 0; i < n; i++) { - uint32_t save = u[j+i]; - u[j+i] = uint64_t(u[j+i]) - (qp * v[i]) - borrow; - if (u[j+i] > save) { - borrow = 1; - u[j+i+1] += b; - } else { - borrow = 0; - } + // D4. [Multiply and subtract.] Replace (u[j+n]u[j+n-1]...u[j]) with + // (u[j+n]u[j+n-1]..u[j]) - qp * (v[n-1]...v[1]v[0]). This computation + // consists of a simple multiplication by a one-place number, combined with + // a subtraction. The digits (u[j+n]...u[j]) should be kept positive; + bool borrow = 0; + for (uint32_t i = 0; i < n; ++i) { + uint64_t u_tmp = borrow ? u[j+i] - 1 : u[j+i]; + uint64_t subtrahend = qp * v[i]; + borrow = subtrahend > u_tmp || (borrow && u[j+i] == 0); + u[j+i] = u_tmp - subtrahend; + } + // if the result of this step is actually negative, (u[j+n]...u[j]) should + // be left as the true value plus b**(n+1), names as the b's complement of + // the true value, and a "borrow" to the left should be remembered. + // + if (borrow) { + borrow = u[j+n] == 0; + u[j+n]--; +// for (uint32_t i = 0; i < n; ++i) { +// u[j+i] = ~u[j+i] + 1; // b's complement +// } } - if (borrow) - u[j+n] += 1; // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was // negative, go to step D6; otherwise go on to step D7. @@ -1122,20 +1073,22 @@ if (borrow) { // D6. [Add back]. The probability that this step is necessary is very // small, on the order of only 2/b. Make sure that test data accounts for - // this possibility. Decreate qj by 1 and add v[...] to u[...]. A carry - // will occur to the left of u[j+n], and it should be ignored since it - // cancels with the borrow that occurred in D4. - uint32_t carry = 0; + // this possibility. Decrease q[j] by 1 + q[j]--; + // and add (0v[n-1]...v[1]v[0]) to (u[j+n]u[j+n-1]...u[j+1]u[j]). + // A carry will occur to the left of u[j+n], and it should be ignored + // since it cancels with the borrow that occurred in D4. + bool carry = false; for (uint32_t i = 0; i < n; i++) { uint32_t save = u[j+i]; u[j+i] += v[i] + carry; - carry = u[j+i] < save; + uint32_t limit = std::min(save,v[i]); + carry = u[j+i] < limit || (carry && u[j+1] == limit); } } - // D7. [Loop on j.] Decreate j by one. Now if j >= 0, go back to D3. - j--; - } while (j >= 0); + // D7. [Loop on j.] Decrease j by one. Now if j >= 0, go back to D3. + } while (--j >= 0); // D8. [Unnormalize]. Now q[...] is the desired quotient, and the desired // remainder may be obtained by dividing u[...] by d. If r is non-null we @@ -1144,12 +1097,10 @@ // The value d is expressed by the "shift" value above since we avoided // multiplication by d by using a shift left. So, all we have to do is // shift right here. In order to mak - uint32_t mask = ~0u >> (32 - shift); uint32_t carry = 0; for (int i = n-1; i >= 0; i--) { - uint32_t save = u[i] & mask; r[i] = (u[i] >> shift) | carry; - carry = save; + carry = u[i] << shift; } } } From asl at math.spbu.ru Thu Feb 22 19:59:07 2007 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 22 Feb 2007 19:59:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86TargetAsmInfo.cpp Message-ID: <200702230159.l1N1x745026801@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ATTAsmPrinter.cpp updated: 1.96 -> 1.97 X86TargetAsmInfo.cpp updated: 1.31 -> 1.32 --- Log message: External weak linkage is supported by recent binutils on mingw32. --- Diffs of the changes: (+2 -1) X86ATTAsmPrinter.cpp | 2 +- X86TargetAsmInfo.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.96 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.97 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.96 Tue Jan 30 14:08:38 2007 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Thu Feb 22 19:58:50 2007 @@ -117,8 +117,8 @@ O << "\t.weak_definition\t" << CurrentFnName << "\n"; } else if (Subtarget->isTargetCygMing()) { EmitAlignment(4, F); // FIXME: This should be parameterized somewhere. - O << "\t.linkonce discard\n"; O << "\t.globl " << CurrentFnName << "\n"; + O << "\t.linkonce discard\n"; } else { EmitAlignment(4, F); // FIXME: This should be parameterized somewhere. O << "\t.weak " << CurrentFnName << "\n"; Index: llvm/lib/Target/X86/X86TargetAsmInfo.cpp diff -u llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.31 llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.32 --- llvm/lib/Target/X86/X86TargetAsmInfo.cpp:1.31 Tue Jan 30 02:04:53 2007 +++ llvm/lib/Target/X86/X86TargetAsmInfo.cpp Thu Feb 22 19:58:50 2007 @@ -131,6 +131,7 @@ // Set up DWARF directives HasLEB128 = true; // Target asm supports leb128 directives (little-endian) PrivateGlobalPrefix = "L"; // Prefix for private global symbols + WeakRefDirective = "\t.weak\t"; DwarfRequiresFrameSection = false; DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\""; DwarfInfoSection = "\t.section\t.debug_info,\"dr\""; From evan.cheng at apple.com Thu Feb 22 21:03:32 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 21:03:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200702230303.l1N33WkS027979@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.142 -> 1.143 --- Log message: 80 col. violation. --- Diffs of the changes: (+2 -1) X86TargetMachine.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.142 llvm/lib/Target/X86/X86TargetMachine.cpp:1.143 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.142 Tue Feb 13 23:52:17 2007 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Thu Feb 22 21:03:16 2007 @@ -106,7 +106,8 @@ /// X86TargetMachine ctor - Create an ILP32 architecture model /// -X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit) +X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS, + bool is64Bit) : Subtarget(M, FS, is64Bit), DataLayout(Subtarget.is64Bit() ? std::string("e-p:64:64-f64:32:64-i64:32:64") : From evan.cheng at apple.com Thu Feb 22 21:14:47 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 21:14:47 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMSubtarget.cpp ARMSubtarget.h ARMTargetMachine.cpp ARMTargetMachine.h Message-ID: <200702230314.l1N3ElOk028178@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMSubtarget.cpp updated: 1.3 -> 1.4 ARMSubtarget.h updated: 1.3 -> 1.4 ARMTargetMachine.cpp updated: 1.24 -> 1.25 ARMTargetMachine.h updated: 1.7 -> 1.8 --- Log message: Added -march=thumb; removed -enable-thumb. --- Diffs of the changes: (+36 -20) ARMSubtarget.cpp | 10 ++-------- ARMSubtarget.h | 2 +- ARMTargetMachine.cpp | 33 +++++++++++++++++++++++---------- ARMTargetMachine.h | 11 ++++++++++- 4 files changed, 36 insertions(+), 20 deletions(-) Index: llvm/lib/Target/ARM/ARMSubtarget.cpp diff -u llvm/lib/Target/ARM/ARMSubtarget.cpp:1.3 llvm/lib/Target/ARM/ARMSubtarget.cpp:1.4 --- llvm/lib/Target/ARM/ARMSubtarget.cpp:1.3 Tue Feb 13 13:52:28 2007 +++ llvm/lib/Target/ARM/ARMSubtarget.cpp Thu Feb 22 21:14:31 2007 @@ -14,16 +14,12 @@ #include "ARMSubtarget.h" #include "ARMGenSubtarget.inc" #include "llvm/Module.h" -#include "llvm/Support/CommandLine.h" using namespace llvm; -// FIXME: this is temporary. -static cl::opt Thumb("enable-thumb", - cl::desc("Switch to thumb mode in ARM backend")); - -ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS) +ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb) : ARMArchVersion(V4T) , HasVFP2(false) + , IsThumb(thumb) , UseThumbBacktraces(false) , IsR9Reserved(false) , stackAlignment(4) @@ -36,8 +32,6 @@ // Parse features string. ParseSubtargetFeatures(FS, CPU); - IsThumb = Thumb; - // Set the boolean corresponding to the current target triple, or the default // if one cannot be determined, to true. const std::string& TT = M.getTargetTriple(); Index: llvm/lib/Target/ARM/ARMSubtarget.h diff -u llvm/lib/Target/ARM/ARMSubtarget.h:1.3 llvm/lib/Target/ARM/ARMSubtarget.h:1.4 --- llvm/lib/Target/ARM/ARMSubtarget.h:1.3 Tue Feb 13 13:52:28 2007 +++ llvm/lib/Target/ARM/ARMSubtarget.h Thu Feb 22 21:14:31 2007 @@ -60,7 +60,7 @@ /// This constructor initializes the data members to match that /// of the specified module. /// - ARMSubtarget(const Module &M, const std::string &FS); + ARMSubtarget(const Module &M, const std::string &FS, bool thumb); /// ParseSubtargetFeatures - Parses features string setting specified /// subtarget options. Definition of function is auto generated by tblgen. Index: llvm/lib/Target/ARM/ARMTargetMachine.cpp diff -u llvm/lib/Target/ARM/ARMTargetMachine.cpp:1.24 llvm/lib/Target/ARM/ARMTargetMachine.cpp:1.25 --- llvm/lib/Target/ARM/ARMTargetMachine.cpp:1.24 Tue Feb 13 23:52:17 2007 +++ llvm/lib/Target/ARM/ARMTargetMachine.cpp Thu Feb 22 21:14:31 2007 @@ -27,21 +27,37 @@ namespace { // Register the target. - RegisterTarget X("arm", " ARM"); + RegisterTarget X("arm", " ARM"); + RegisterTarget Y("thumb", " Thumb"); } -/// TargetMachine ctor - Create an ILP32 architecture model +/// ThumbTargetMachine - Create an Thumb architecture model. /// -ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS) - : Subtarget(M, FS), +unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) { + std::string TT = M.getTargetTriple(); + if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "thumb-") + return 20; + + return M.getPointerSize() == Module::Pointer32; +} + +ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS) + : ARMTargetMachine(M, FS, true) { +} + +/// TargetMachine ctor - Create an ARM architecture model. +/// +ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS, + bool isThumb) + : Subtarget(M, FS, isThumb), DataLayout(Subtarget.isAPCS_ABI() ? // APCS ABI - (Subtarget.isThumb() ? + (isThumb ? std::string("e-p:32:32-f64:32:32-i64:32:32-" "i16:16:32-i8:8:32-i1:8:32-a:0:32") : std::string("e-p:32:32-f64:32:32-i64:32:32")) : // AAPCS ABI - (Subtarget.isThumb() ? + (isThumb ? std::string("e-p:32:32-f64:64:64-i64:64:64-" "i16:16:32-i8:8:32-i1:8:32-a:0:32") : std::string("e-p:32:32-f64:64:64-i64:64:64"))), @@ -53,10 +69,7 @@ if (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "arm-") return 20; - if (M.getPointerSize() == Module::Pointer32) - return 1; - else - return 0; + return M.getPointerSize() == Module::Pointer32; } Index: llvm/lib/Target/ARM/ARMTargetMachine.h diff -u llvm/lib/Target/ARM/ARMTargetMachine.h:1.7 llvm/lib/Target/ARM/ARMTargetMachine.h:1.8 --- llvm/lib/Target/ARM/ARMTargetMachine.h:1.7 Fri Jan 19 01:51:42 2007 +++ llvm/lib/Target/ARM/ARMTargetMachine.h Thu Feb 22 21:14:31 2007 @@ -32,7 +32,7 @@ ARMInstrInfo InstrInfo; ARMFrameInfo FrameInfo; public: - ARMTargetMachine(const Module &M, const std::string &FS); + ARMTargetMachine(const Module &M, const std::string &FS, bool isThumb = false); virtual const ARMInstrInfo *getInstrInfo() const { return &InstrInfo; } virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } @@ -52,6 +52,15 @@ std::ostream &Out); }; +/// ThumbTargetMachine - Thumb target machine. +/// +class ThumbTargetMachine : public ARMTargetMachine { +public: + ThumbTargetMachine(const Module &M, const std::string &FS); + + static unsigned getModuleMatchQuality(const Module &M); +}; + } // end namespace llvm #endif From evan.cheng at apple.com Thu Feb 22 21:15:56 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 22 Feb 2007 21:15:56 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/ARM/2007-01-31-RegInfoAssert.ll 2007-02-02-JoinIntervalsCrash.ll dyn-stackalloc.ll large-stack.ll ldr_ext.ll ldr_frame.ll long-setcc.ll long.ll long_shift.ll mul.ll select.ll stack-frame.ll thumb-imm.ll unord.ll vargs2.ll Message-ID: <200702230315.l1N3FuOW028246@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/ARM: 2007-01-31-RegInfoAssert.ll updated: 1.2 -> 1.3 2007-02-02-JoinIntervalsCrash.ll updated: 1.1 -> 1.2 dyn-stackalloc.ll updated: 1.2 -> 1.3 large-stack.ll updated: 1.5 -> 1.6 ldr_ext.ll updated: 1.3 -> 1.4 ldr_frame.ll updated: 1.2 -> 1.3 long-setcc.ll updated: 1.1 -> 1.2 long.ll updated: 1.12 -> 1.13 long_shift.ll updated: 1.3 -> 1.4 mul.ll updated: 1.5 -> 1.6 select.ll updated: 1.12 -> 1.13 stack-frame.ll updated: 1.1 -> 1.2 thumb-imm.ll updated: 1.2 -> 1.3 unord.ll updated: 1.2 -> 1.3 vargs2.ll updated: 1.6 -> 1.7 --- Log message: -march=arm -enable-thumb => -march=thumb --- Diffs of the changes: (+40 -40) 2007-01-31-RegInfoAssert.ll | 2 +- 2007-02-02-JoinIntervalsCrash.ll | 2 +- dyn-stackalloc.ll | 8 ++++---- large-stack.ll | 4 ++-- ldr_ext.ll | 8 ++++---- ldr_frame.ll | 4 ++-- long-setcc.ll | 4 ++-- long.ll | 10 +++++----- long_shift.ll | 2 +- mul.ll | 4 ++-- select.ll | 14 +++++++------- stack-frame.ll | 4 ++-- thumb-imm.ll | 4 ++-- unord.ll | 6 +++--- vargs2.ll | 4 ++-- 15 files changed, 40 insertions(+), 40 deletions(-) Index: llvm/test/CodeGen/ARM/2007-01-31-RegInfoAssert.ll diff -u llvm/test/CodeGen/ARM/2007-01-31-RegInfoAssert.ll:1.2 llvm/test/CodeGen/ARM/2007-01-31-RegInfoAssert.ll:1.3 --- llvm/test/CodeGen/ARM/2007-01-31-RegInfoAssert.ll:1.2 Thu Feb 1 20:16:22 2007 +++ llvm/test/CodeGen/ARM/2007-01-31-RegInfoAssert.ll Thu Feb 22 21:15:39 2007 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin -enable-thumb +; RUN: llvm-as < %s | llc -mtriple=thumb-apple-darwin %struct.rtx_def = type { i8 } @str = external global [7 x i8] Index: llvm/test/CodeGen/ARM/2007-02-02-JoinIntervalsCrash.ll diff -u llvm/test/CodeGen/ARM/2007-02-02-JoinIntervalsCrash.ll:1.1 llvm/test/CodeGen/ARM/2007-02-02-JoinIntervalsCrash.ll:1.2 --- llvm/test/CodeGen/ARM/2007-02-02-JoinIntervalsCrash.ll:1.1 Sat Feb 3 03:14:10 2007 +++ llvm/test/CodeGen/ARM/2007-02-02-JoinIntervalsCrash.ll Thu Feb 22 21:15:39 2007 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin -enable-thumb +; RUN: llvm-as < %s | llc -mtriple=thumb-apple-darwin %struct.color_sample = type { i32 } %struct.ref = type { %struct.color_sample, i16, i16 } Index: llvm/test/CodeGen/ARM/dyn-stackalloc.ll diff -u llvm/test/CodeGen/ARM/dyn-stackalloc.ll:1.2 llvm/test/CodeGen/ARM/dyn-stackalloc.ll:1.3 --- llvm/test/CodeGen/ARM/dyn-stackalloc.ll:1.2 Wed Feb 7 03:24:03 2007 +++ llvm/test/CodeGen/ARM/dyn-stackalloc.ll Thu Feb 22 21:15:39 2007 @@ -1,8 +1,8 @@ ; RUN: llvm-as < %s | llc -march=arm && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | not grep "ldr sp" && -; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-apple-darwin -enable-thumb | not grep "sub.*r7" && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep 4294967280 +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | not grep "ldr sp" && +; RUN: llvm-as < %s | llc -mtriple=thumb-apple-darwin | not grep "sub.*r7" && +; RUN: llvm-as < %s | llc -march=thumb | grep 4294967280 %struct.state = type { i32, %struct.info*, float**, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i8* } %struct.info = type { i32, i32, i32, i32, i32, i32, i32, i8* } Index: llvm/test/CodeGen/ARM/large-stack.ll diff -u llvm/test/CodeGen/ARM/large-stack.ll:1.5 llvm/test/CodeGen/ARM/large-stack.ll:1.6 --- llvm/test/CodeGen/ARM/large-stack.ll:1.5 Thu Feb 1 16:26:42 2007 +++ llvm/test/CodeGen/ARM/large-stack.ll Thu Feb 22 21:15:39 2007 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=arm && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | \ +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | \ ; RUN: grep 'ldr.*LCP' | wc -l | grep 5 define void @test1() { Index: llvm/test/CodeGen/ARM/ldr_ext.ll diff -u llvm/test/CodeGen/ARM/ldr_ext.ll:1.3 llvm/test/CodeGen/ARM/ldr_ext.ll:1.4 --- llvm/test/CodeGen/ARM/ldr_ext.ll:1.3 Fri Jan 26 02:25:05 2007 +++ llvm/test/CodeGen/ARM/ldr_ext.ll Thu Feb 22 21:15:39 2007 @@ -3,10 +3,10 @@ ; RUN: llvm-as < %s | llc -march=arm | grep "ldrh" | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm | grep "ldrsb" | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm | grep "ldrsh" | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep "ldrb" | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep "ldrh" | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep "ldrsb" | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep "ldrsh" | wc -l | grep 1 +; RUN: llvm-as < %s | llc -march=thumb | grep "ldrb" | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep "ldrh" | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep "ldrsb" | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep "ldrsh" | wc -l | grep 1 define i32 @test1(i8* %v.pntr.s0.u1) { %tmp.u = load i8* %v.pntr.s0.u1 Index: llvm/test/CodeGen/ARM/ldr_frame.ll diff -u llvm/test/CodeGen/ARM/ldr_frame.ll:1.2 llvm/test/CodeGen/ARM/ldr_frame.ll:1.3 --- llvm/test/CodeGen/ARM/ldr_frame.ll:1.2 Fri Jan 26 02:25:05 2007 +++ llvm/test/CodeGen/ARM/ldr_frame.ll Thu Feb 22 21:15:39 2007 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=arm && ; RUN: llvm-as < %s | llc -march=arm | not grep mov && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep cpy | wc -l | grep 2 +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | grep cpy | wc -l | grep 2 define i32 @f1() { %buf = alloca [32 x i32], align 4 Index: llvm/test/CodeGen/ARM/long-setcc.ll diff -u llvm/test/CodeGen/ARM/long-setcc.ll:1.1 llvm/test/CodeGen/ARM/long-setcc.ll:1.2 --- llvm/test/CodeGen/ARM/long-setcc.ll:1.1 Thu Feb 8 16:27:55 2007 +++ llvm/test/CodeGen/ARM/long-setcc.ll Thu Feb 22 21:15:39 2007 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=arm && ; RUN: llvm-as < %s | llc -march=arm | grep cmp | wc -l | grep 2 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep cmp | wc -l | grep 2 +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | grep cmp | wc -l | grep 2 define i1 @t1(i64 %x) { Index: llvm/test/CodeGen/ARM/long.ll diff -u llvm/test/CodeGen/ARM/long.ll:1.12 llvm/test/CodeGen/ARM/long.ll:1.13 --- llvm/test/CodeGen/ARM/long.ll:1.12 Wed Jan 31 17:51:35 2007 +++ llvm/test/CodeGen/ARM/long.ll Thu Feb 22 21:15:39 2007 @@ -7,11 +7,11 @@ ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "sbc" | wc -l | grep 1 && ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "smull" | wc -l | grep 1 && ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm | grep "umull" | wc -l | grep 1 && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb | grep "mvn" | wc -l | grep 1 && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb | grep "adc" | wc -l | grep 1 && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb | grep "sbc" | wc -l | grep 1 && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb | grep "__muldi3" +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb | grep "mvn" | wc -l | grep 1 && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb | grep "adc" | wc -l | grep 1 && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb | grep "sbc" | wc -l | grep 1 && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb | grep "__muldi3" long %f1() { entry: Index: llvm/test/CodeGen/ARM/long_shift.ll diff -u llvm/test/CodeGen/ARM/long_shift.ll:1.3 llvm/test/CodeGen/ARM/long_shift.ll:1.4 --- llvm/test/CodeGen/ARM/long_shift.ll:1.3 Thu Feb 1 20:16:22 2007 +++ llvm/test/CodeGen/ARM/long_shift.ll Thu Feb 22 21:15:39 2007 @@ -3,7 +3,7 @@ ; RUN: llvm-as < %s | llc -march=arm | grep __ashldi3 && ; RUN: llvm-as < %s | llc -march=arm | grep __ashrdi3 && ; RUN: llvm-as < %s | llc -march=arm | grep __lshrdi3 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb +; RUN: llvm-as < %s | llc -march=thumb define i64 @f0(i64 %A, i64 %B) { %tmp = bitcast i64 %A to i64 Index: llvm/test/CodeGen/ARM/mul.ll diff -u llvm/test/CodeGen/ARM/mul.ll:1.5 llvm/test/CodeGen/ARM/mul.ll:1.6 --- llvm/test/CodeGen/ARM/mul.ll:1.5 Fri Jan 26 02:25:05 2007 +++ llvm/test/CodeGen/ARM/mul.ll Thu Feb 22 21:15:39 2007 @@ -1,8 +1,8 @@ ; RUN: llvm-as < %s | llc -march=arm && ; RUN: llvm-as < %s | llc -march=arm | grep mul | wc -l | grep 2 && ; RUN: llvm-as < %s | llc -march=arm | grep lsl | wc -l | grep 2 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep mul | wc -l | grep 3 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep lsl | wc -l | grep 1 +; RUN: llvm-as < %s | llc -march=thumb | grep mul | wc -l | grep 3 && +; RUN: llvm-as < %s | llc -march=thumb | grep lsl | wc -l | grep 1 define i32 @f1(i32 %u) { %tmp = mul i32 %u, %u Index: llvm/test/CodeGen/ARM/select.ll diff -u llvm/test/CodeGen/ARM/select.ll:1.12 llvm/test/CodeGen/ARM/select.ll:1.13 --- llvm/test/CodeGen/ARM/select.ll:1.12 Fri Jan 26 02:25:05 2007 +++ llvm/test/CodeGen/ARM/select.ll Thu Feb 22 21:15:39 2007 @@ -6,13 +6,13 @@ ; RUN: llvm-as < %s | llc -march=arm | grep movls | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm | grep movhi | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep fcpydmi | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep beq | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep bgt | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep blt | wc -l | grep 3 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep ble | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep bls | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep bhi | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep __ltdf2 +; RUN: llvm-as < %s | llc -march=thumb | grep beq | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep bgt | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep blt | wc -l | grep 3 && +; RUN: llvm-as < %s | llc -march=thumb | grep ble | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep bls | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep bhi | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep __ltdf2 define i32 @f1(i32 %a.s) { entry: Index: llvm/test/CodeGen/ARM/stack-frame.ll diff -u llvm/test/CodeGen/ARM/stack-frame.ll:1.1 llvm/test/CodeGen/ARM/stack-frame.ll:1.2 --- llvm/test/CodeGen/ARM/stack-frame.ll:1.1 Mon Jan 29 21:06:19 2007 +++ llvm/test/CodeGen/ARM/stack-frame.ll Thu Feb 22 21:15:39 2007 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=arm && ; RUN: llvm-as < %s | llc -march=arm | grep add | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep add | wc -l | grep 1 +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | grep add | wc -l | grep 1 define void @f1() { %c = alloca i8, align 1 Index: llvm/test/CodeGen/ARM/thumb-imm.ll diff -u llvm/test/CodeGen/ARM/thumb-imm.ll:1.2 llvm/test/CodeGen/ARM/thumb-imm.ll:1.3 --- llvm/test/CodeGen/ARM/thumb-imm.ll:1.2 Fri Jan 26 02:25:05 2007 +++ llvm/test/CodeGen/ARM/thumb-imm.ll Thu Feb 22 21:15:39 2007 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | not grep CPI +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | not grep CPI define i32 @test1() { Index: llvm/test/CodeGen/ARM/unord.ll diff -u llvm/test/CodeGen/ARM/unord.ll:1.2 llvm/test/CodeGen/ARM/unord.ll:1.3 --- llvm/test/CodeGen/ARM/unord.ll:1.2 Mon Feb 5 10:33:56 2007 +++ llvm/test/CodeGen/ARM/unord.ll Thu Feb 22 21:15:39 2007 @@ -1,9 +1,9 @@ ; RUN: llvm-as < %s | llc -march=arm && ; RUN: llvm-as < %s | llc -march=arm | grep movne | wc -l | grep 1 && ; RUN: llvm-as < %s | llc -march=arm | grep moveq | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep bne | wc -l | grep 1 && -; RUN: llvm-as < %s | llc -march=arm -enable-thumb | grep beq | wc -l | grep 1 +; RUN: llvm-as < %s | llc -march=thumb && +; RUN: llvm-as < %s | llc -march=thumb | grep bne | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=thumb | grep beq | wc -l | grep 1 define i32 @f1(float %X, float %Y) { %tmp = fcmp uno float %X, %Y Index: llvm/test/CodeGen/ARM/vargs2.ll diff -u llvm/test/CodeGen/ARM/vargs2.ll:1.6 llvm/test/CodeGen/ARM/vargs2.ll:1.7 --- llvm/test/CodeGen/ARM/vargs2.ll:1.6 Wed Jan 31 19:56:43 2007 +++ llvm/test/CodeGen/ARM/vargs2.ll Thu Feb 22 21:15:39 2007 @@ -1,6 +1,6 @@ ; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm %% -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb && -; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm -enable-thumb | grep pop | wc -l | grep 2 +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb && +; RUN: llvm-upgrade < %s | llvm-as | llc -march=thumb | grep pop | wc -l | grep 2 %str = internal constant [4 x sbyte] c"%d\0A\00" ; <[4 x sbyte]*> [#uses=1] From dalej at apple.com Thu Feb 22 23:02:53 2007 From: dalej at apple.com (Dale Johannesen) Date: Thu, 22 Feb 2007 23:02:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp README.txt Message-ID: <200702230502.l1N52r3T029872@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.26 -> 1.27 README.txt updated: 1.11 -> 1.12 --- Log message: rewrite of constant islands --- Diffs of the changes: (+275 -86) ARMConstantIslandPass.cpp | 335 +++++++++++++++++++++++++++++++++++----------- README.txt | 26 +-- 2 files changed, 275 insertions(+), 86 deletions(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.26 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.27 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.26 Fri Feb 9 17:59:14 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Feb 22 23:02:36 2007 @@ -35,10 +35,10 @@ STATISTIC(NumUBrFixed, "Number of uncond branches fixed"); namespace { - /// ARMConstantIslands - Due to limited pc-relative displacements, ARM + /// ARMConstantIslands - Due to limited PC-relative displacements, ARM /// requires constant pool entries to be scattered among the instructions /// inside a function. To do this, it completely ignores the normal LLVM - /// constant pool, instead, it places constants where-ever it feels like with + /// constant pool; instead, it places constants wherever it feels like with /// special instructions. /// /// The terminology used in this pass includes: @@ -59,6 +59,11 @@ /// to a return, unreachable, or unconditional branch). std::vector WaterList; + // WaterListOffsets - the offset of the beginning of each WaterList block. + // This is computed as needed in HandleConstantPoolUser; not necessarily + // valid at arbitrary times. + std::vector WaterListOffsets; + /// CPUser - One user of a constant pool, keeping the machine instruction /// pointer, the constant pool being referenced, and the max displacement /// allowed from the instruction to the CP. @@ -86,7 +91,10 @@ }; /// CPEntries - Keep track of all of the constant pool entry machine - /// instructions. For each constpool index, it keeps a vector of entries. + /// instructions. For each original constpool index (i.e. those that + /// existed upon entry to this pass), it keeps a vector of entries. + /// Original elements are cloned as we go along; the clones are + /// put in the vector of the original element, but have distinct CPIs. std::vector > CPEntries; /// ImmBranch - One per immediate branch, keeping the machine instruction @@ -131,8 +139,16 @@ const std::vector &CPEMIs); MachineBasicBlock *SplitBlockBeforeInstr(MachineInstr *MI); void UpdateForInsertedWaterBlock(MachineBasicBlock *NewBB); + bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI, unsigned Size); + void ComputeWaterListOffsets(MachineFunction &Fn); + int LookForExistingCPEntry(CPUser& U, unsigned UserOffset); bool HandleConstantPoolUser(MachineFunction &Fn, CPUser &U); - bool CPEIsInRange(MachineInstr *MI, MachineInstr *CPEMI, unsigned Disp); + bool CPEIsInRange(MachineInstr *MI, unsigned UserOffset, + MachineInstr *CPEMI, unsigned Disp, + bool DoDump); + bool WaterIsInRange(unsigned UserOffset, + std::vector::iterator IP, + unsigned Disp); bool BBIsInRange(MachineInstr *MI, MachineBasicBlock *BB, unsigned Disp); bool FixUpImmediateBr(MachineFunction &Fn, ImmBranch &Br); bool FixUpConditionalBr(MachineFunction &Fn, ImmBranch &Br); @@ -240,7 +256,7 @@ } } -/// BBHasFallthrough - Return true of the specified basic block can fallthrough +/// BBHasFallthrough - Return true if the specified basic block can fallthrough /// into the block immediately after it. static bool BBHasFallthrough(MachineBasicBlock *MBB) { // Get the next machine basic block in the function. @@ -394,8 +410,9 @@ } } - // In thumb mode, if this block is a constpool island, pessmisticly assume - // it needs to be padded by two byte so it's aligned on 4 byte boundary. + // In thumb mode, if this block is a constpool island, pessimistically + // assume it needs to be padded by two byte so it's aligned on 4 byte + // boundary. if (AFI->isThumbFunction() && !MBB.empty() && MBB.begin()->getOpcode() == ARM::CONSTPOOL_ENTRY) @@ -503,8 +520,27 @@ OrigBB->addSuccessor(NewBB); // Update internal data structures to account for the newly inserted MBB. - UpdateForInsertedWaterBlock(NewBB); + // This is almost the same as UpdateForInsertedWaterBlock, except that + // the Water goes after OrigBB, not NewBB. + NewBB->getParent()->RenumberBlocks(NewBB); + // Insert a size into BBSizes to align it properly with the (newly + // renumbered) block numbers. + BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); + + // Next, update WaterList. Specifically, we need to add OrigMBB as having + // available water after it (but not if it's already there, which happens + // when splitting before a conditional branch that is followed by an + // unconditional branch - in that case we want to insert NewBB). + std::vector::iterator IP = + std::lower_bound(WaterList.begin(), WaterList.end(), OrigBB, + CompareMBBNumbers); + MachineBasicBlock* WaterBB = *IP; + if (WaterBB == OrigBB) + WaterList.insert(next(IP), NewBB); + else + WaterList.insert(IP, OrigBB); + // Figure out how large the first NewMBB is. unsigned NewBBSize = 0; for (MachineBasicBlock::iterator I = NewBB->begin(), E = NewBB->end(); @@ -521,20 +557,53 @@ return NewBB; } -/// CPEIsInRange - Returns true is the distance between specific MI and +/// WaterIsInRange - Returns true if a CPE placed after the specified +/// Water (a basic block) will be in range for the specific MI. + +bool ARMConstantIslands::WaterIsInRange(unsigned UserOffset, + std::vector::iterator IP, + unsigned MaxDisp) +{ + MachineBasicBlock *Water = *IP; + unsigned Index = IP - WaterList.begin(); + unsigned CPEOffset = WaterListOffsets[Index] + + BBSizes[Water->getNumber()]; + // If the Water is a constpool island, it has already been aligned. + // If not, align it. + if (AFI->isThumbFunction() && + (Water->empty() || + Water->begin()->getOpcode() != ARM::CONSTPOOL_ENTRY)) + CPEOffset += 2; + + if (UserOffset <= CPEOffset) { + // User before the CPE. + if (CPEOffset-UserOffset <= MaxDisp) + return true; + } else if (!AFI->isThumbFunction()) { + // Thumb LDR cannot encode negative offset. + if (UserOffset-CPEOffset <= MaxDisp) + return true; + } + return false; +} + +/// CPEIsInRange - Returns true if the distance between specific MI and /// specific ConstPool entry instruction can fit in MI's displacement field. -bool ARMConstantIslands::CPEIsInRange(MachineInstr *MI, MachineInstr *CPEMI, - unsigned MaxDisp) { - unsigned PCAdj = AFI->isThumbFunction() ? 4 : 8; - unsigned UserOffset = GetOffsetOf(MI) + PCAdj; - // In thumb mode, pessmisticly assumes the .align 2 before the first CPE +bool ARMConstantIslands::CPEIsInRange(MachineInstr *MI, unsigned UserOffset, + MachineInstr *CPEMI, + unsigned MaxDisp, bool DoDump) { + // In thumb mode, pessimistically assumes the .align 2 before the first CPE // in the island adds two byte padding. unsigned AlignAdj = AFI->isThumbFunction() ? 2 : 0; unsigned CPEOffset = GetOffsetOf(CPEMI) + AlignAdj; - DOUT << "User of CPE#" << CPEMI->getOperand(0).getImm() - << " max delta=" << MaxDisp - << " at offset " << int(CPEOffset-UserOffset) << "\t" << *MI; + if (DoDump) { + DOUT << "User of CPE#" << CPEMI->getOperand(0).getImm() + << " max delta=" << MaxDisp + << " insn address=" << UserOffset + << " CPE address=" << CPEOffset + << " offset=" << int(CPEOffset-UserOffset) << "\t" << *MI; + } if (UserOffset <= CPEOffset) { // User before the CPE. @@ -562,52 +631,13 @@ return false; } -/// HandleConstantPoolUser - Analyze the specified user, checking to see if it -/// is out-of-range. If so, pick it up the constant pool value and move it some -/// place in-range. -bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction &Fn, CPUser &U){ - MachineInstr *UserMI = U.MI; - MachineInstr *CPEMI = U.CPEMI; - - // Check to see if the CPE is already in-range. - if (CPEIsInRange(UserMI, CPEMI, U.MaxDisp)) - return false; - - // Solution guaranteed to work: split the user's MBB right after the user and - // insert a clone the CPE into the newly created water. - - MachineBasicBlock *UserMBB = UserMI->getParent(); - MachineBasicBlock *NewMBB; - - // TODO: Search for the best place to split the code. In practice, using - // loop nesting information to insert these guys outside of loops would be - // sufficient. - bool isThumb = AFI->isThumbFunction(); - if (&UserMBB->back() == UserMI) { - assert(BBHasFallthrough(UserMBB) && "Expected a fallthrough BB!"); - NewMBB = next(MachineFunction::iterator(UserMBB)); - // Add an unconditional branch from UserMBB to fallthrough block. - // Note the new unconditional branch is not being recorded. - BuildMI(UserMBB, TII->get(isThumb ? ARM::tB : ARM::B)).addMBB(NewMBB); - BBSizes[UserMBB->getNumber()] += isThumb ? 2 : 4; - } else { - MachineInstr *NextMI = next(MachineBasicBlock::iterator(UserMI)); - NewMBB = SplitBlockBeforeInstr(NextMI); - } - - // Okay, we know we can put an island before UserMBB now, do it! - MachineBasicBlock *NewIsland = new MachineBasicBlock(); - Fn.getBasicBlockList().insert(NewMBB, NewIsland); - - // Update internal data structures to account for the newly inserted MBB. - UpdateForInsertedWaterBlock(NewIsland); - - // Now that we have an island to add the CPE to, clone the original CPE and - // add it to the island. - unsigned ID = NextUID++; - unsigned CPI = CPEMI->getOperand(1).getConstantPoolIndex(); - unsigned Size = CPEMI->getOperand(2).getImm(); +/// DecrementOldEntry - find the constant pool entry with index CPI +/// and instruction CPEMI, and decrement its refcount. If the refcount +/// becomes 0 remove the entry and instruction. Returns true if we removed +/// the entry, false if we didn't. +bool ARMConstantIslands::DecrementOldEntry(unsigned CPI, MachineInstr *CPEMI, + unsigned Size) { // Find the old entry. Eliminate it if it is no longer used. CPEntry *OldCPE = findConstPoolEntry(CPI, CPEMI); assert(OldCPE && "Unexpected!"); @@ -615,7 +645,8 @@ MachineBasicBlock *OldCPEBB = OldCPE->CPEMI->getParent(); if (OldCPEBB->empty()) { // In thumb mode, the size of island is padded by two to compensate for - // the alignment requirement. + // the alignment requirement. Thus it will now be 2 when the block is + // empty, so fix this. BBSizes[OldCPEBB->getNumber()] = 0; // An island has only one predecessor BB and one successor BB. Check if // this BB's predecessor jumps directly to this BB's successor. This @@ -627,12 +658,171 @@ OldCPE->CPEMI->eraseFromParent(); OldCPE->CPEMI = NULL; NumCPEs--; + return true; + } + return false; +} + +/// ComputeWaterListOffsets - just what you think. +/// This vector is built to avoid re-adding BBSizes for each WaterBB under test +/// (which would cause the algorithm to be n^2). +void ARMConstantIslands::ComputeWaterListOffsets(MachineFunction &Fn) { + unsigned WaterListIndex = 0; + unsigned Offset = 0; + unsigned BB = 0; + WaterListOffsets.clear(); + for (MachineFunction::iterator MBBI = Fn.begin(), E = Fn.end(); + MBBI != E; ++BB, ++MBBI) { + MachineBasicBlock *MBB = MBBI; + if (MBB == WaterList[WaterListIndex]) { + WaterListOffsets.push_back(Offset); + WaterListIndex++; + } + Offset += BBSizes[BB]; + } +} + +/// LookForCPEntryInRange - see if the currently referenced CPE is in range; +/// if not, see if an in-range clone of the CPE is in range, and if so, +/// change the data structures so the user references the clone. Returns: +/// 0 = no existing entry found +/// 1 = entry found, and there were no code insertions or deletions +/// 2 = entry found, and there were code insertions or deletions +int ARMConstantIslands::LookForExistingCPEntry(CPUser& U, unsigned UserOffset) +{ + MachineInstr *UserMI = U.MI; + MachineInstr *CPEMI = U.CPEMI; + + // Check to see if the CPE is already in-range. + if (CPEIsInRange(UserMI, UserOffset, CPEMI, U.MaxDisp, true)) { + DOUT << "In range\n"; + return 1; + } + + // No. Look for previously created clones of the CPE that are in range. + unsigned CPI = CPEMI->getOperand(1).getConstantPoolIndex(); + std::vector &CPEs = CPEntries[CPI]; + for (unsigned i = 0, e = CPEs.size(); i != e; ++i) { + // We already tried this one + if (CPEs[i].CPEMI == CPEMI) + continue; + // Removing CPEs can leave empty entries, skip + if (CPEs[i].CPEMI == NULL) + continue; + if (CPEIsInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.MaxDisp, false)) { + DOUT << "Replacing CPE#" << CPI << " with CPE#" << CPEs[i].CPI << "\n"; + // Point the CPUser node to the replacement + U.CPEMI = CPEs[i].CPEMI; + // Change the CPI in the instruction operand to refer to the clone. + for (unsigned j = 0, e = UserMI->getNumOperands(); j != e; ++j) + if (UserMI->getOperand(j).isConstantPoolIndex()) { + UserMI->getOperand(j).setConstantPoolIndex(CPEs[i].CPI); + break; + } + // Adjust the refcount of the clone... + CPEs[i].RefCount++; + // ...and the original. If we didn't remove the old entry, none of the + // addresses changed, so we don't need another pass. + unsigned Size = CPEMI->getOperand(2).getImm(); + return DecrementOldEntry(CPI, CPEMI, Size) ? 2 : 1; + } + } + return 0; +} + +/// HandleConstantPoolUser - Analyze the specified user, checking to see if it +/// is out-of-range. If so, pick it up the constant pool value and move it some +/// place in-range. Return true if we changed any addresses (thus must run +/// another pass of branch lengthening), false otherwise. +bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction &Fn, CPUser &U){ + MachineInstr *UserMI = U.MI; + MachineInstr *CPEMI = U.CPEMI; + unsigned CPI = CPEMI->getOperand(1).getConstantPoolIndex(); + unsigned Size = CPEMI->getOperand(2).getImm(); + bool isThumb = AFI->isThumbFunction(); + MachineBasicBlock *NewMBB; + // Compute this only once, it's expensive + unsigned UserOffset = GetOffsetOf(UserMI) + (isThumb ? 4 : 8); + + // See if the current entry is within range, or there is a clone of it + // in range. + int result = LookForExistingCPEntry(U, UserOffset); + if (result==1) return false; + else if (result==2) return true; + + // No existing clone of this CPE is within range. + // We will be generating a new clone. Get a UID for it. + unsigned ID = NextUID++; + + // Look for water where we can place this CPE. We look for the farthest one + // away that will work. Forward references only for now (although later + // we might find some that are backwards). + bool WaterFound = false; + if (!WaterList.empty()) { + // Compute offsets for the blocks in the current WaterList. + // It is a big compile-time speed win to do this only once + // rather than for each WaterList entry. + ComputeWaterListOffsets(Fn); + assert(WaterList.size() == WaterListOffsets.size()); + for (std::vector::iterator IP = prior(WaterList.end()), + B = WaterList.begin();; --IP) { + MachineBasicBlock* WaterBB = *IP; + if (WaterIsInRange(UserOffset, IP, U.MaxDisp)) { + WaterFound = true; + DOUT << "found water in range\n"; + // CPE goes before following block (NewMBB). + NewMBB = next(MachineFunction::iterator(WaterBB)); + // Remove the original WaterList entry; we want subsequent + // insertions in this vicinity to go after the one we're + // about to insert. This considerably reduces the number + // of times we have to move the same CPE more than once. + WaterList.erase(IP); + break; + } + if (IP == B) + break; + } } - // Build a new CPE for this user. + if (!WaterFound) { + // No water found. + // Solution of last resort: split the user's MBB right after the user + // and insert a clone of the CPE into the newly created water. + + DOUT << "No water found\n"; + MachineBasicBlock *UserMBB = UserMI->getParent(); + + // TODO: Search for the best place to split the code. In practice, using + // loop nesting information to insert these guys outside of loops would be + // sufficient. + if (&UserMBB->back() == UserMI) { + assert(BBHasFallthrough(UserMBB) && "Expected a fallthrough BB!"); + NewMBB = next(MachineFunction::iterator(UserMBB)); + // Add an unconditional branch from UserMBB to fallthrough block. + // Note the new unconditional branch is not being recorded. + BuildMI(UserMBB, TII->get(isThumb ? ARM::tB : ARM::B)).addMBB(NewMBB); + BBSizes[UserMBB->getNumber()] += isThumb ? 2 : 4; + } else { + MachineInstr *NextMI = next(MachineBasicBlock::iterator(UserMI)); + NewMBB = SplitBlockBeforeInstr(NextMI); + } + } + + // Okay, we know we can put an island before NewMBB now, do it! + MachineBasicBlock *NewIsland = new MachineBasicBlock(); + Fn.getBasicBlockList().insert(NewMBB, NewIsland); + + // Update internal data structures to account for the newly inserted MBB. + UpdateForInsertedWaterBlock(NewIsland); + + // Decrement the old entry, and remove it if refcount becomes 0. + DecrementOldEntry(CPI, CPEMI, Size); + + // Now that we have an island to add the CPE to, clone the original CPE and + // add it to the island. U.CPEMI = BuildMI(NewIsland, TII->get(ARM::CONSTPOOL_ENTRY)) .addImm(ID).addConstantPoolIndex(CPI).addImm(Size); - CPEntries[CPI].push_back(CPEntry(U.CPEMI, CPI, 1)); + CPEntries[CPI].push_back(CPEntry(U.CPEMI, ID, 1)); NumCPEs++; // Compensate for .align 2 in thumb mode. @@ -652,7 +842,7 @@ return true; } -/// BBIsInRange - Returns true is the distance between specific MI and +/// BBIsInRange - Returns true if the distance between specific MI and /// specific BB can fit in MI's displacement field. bool ARMConstantIslands::BBIsInRange(MachineInstr *MI,MachineBasicBlock *DestBB, unsigned MaxDisp) { @@ -690,10 +880,10 @@ return FixUpConditionalBr(Fn, Br); } -/// FixUpUnconditionalBr - Fix up an unconditional branches whose destination is -/// too far away to fit in its displacement field. If LR register ha been +/// FixUpUnconditionalBr - Fix up an unconditional branch whose destination is +/// too far away to fit in its displacement field. If the LR register has been /// spilled in the epilogue, then we can use BL to implement a far jump. -/// Otherwise, add a intermediate branch instruction to to a branch. +/// Otherwise, add an intermediate branch instruction to to a branch. bool ARMConstantIslands::FixUpUnconditionalBr(MachineFunction &Fn, ImmBranch &Br) { MachineInstr *MI = Br.MI; @@ -712,13 +902,13 @@ return true; } -/// getUnconditionalBrDisp - Returns the maximum displacement that can fit in the -/// specific unconditional branch instruction. +/// getUnconditionalBrDisp - Returns the maximum displacement that can fit in +/// the specific unconditional branch instruction. static inline unsigned getUnconditionalBrDisp(int Opc) { return (Opc == ARM::tB) ? (1<<10)*2 : (1<<23)*4; } -/// FixUpConditionalBr - Fix up a conditional branches whose destination is too +/// FixUpConditionalBr - Fix up a conditional branch whose destination is too /// far away to fit in its displacement field. It is converted to an inverse /// conditional branch + an unconditional branch to the destination. bool @@ -791,7 +981,6 @@ return true; } - /// UndoLRSpillRestore - Remove Thumb push / pop instructions that only spills /// LR / restores LR to pc. bool ARMConstantIslands::UndoLRSpillRestore() { Index: llvm/lib/Target/ARM/README.txt diff -u llvm/lib/Target/ARM/README.txt:1.11 llvm/lib/Target/ARM/README.txt:1.12 --- llvm/lib/Target/ARM/README.txt:1.11 Thu Feb 1 22:36:46 2007 +++ llvm/lib/Target/ARM/README.txt Thu Feb 22 23:02:36 2007 @@ -17,20 +17,20 @@ //===---------------------------------------------------------------------===// -The constant island pass is extremely naive. If a constant pool entry is -out of range, it *always* splits a block and inserts a copy of the cp -entry inline. It should: - -1. Check to see if there is already a copy of this constant nearby. If so, - reuse it. -2. Instead of always splitting blocks to insert the constant, insert it in - nearby 'water'. -3. Constant island references should be ref counted. If a constant reference - is out-of-range, and the last reference to a constant is relocated, the - dead constant should be removed. +The constant island pass has been much improved; all the todo items in the +previous version of this document have been addressed. However, there are still +things that can be done: + +1. When there isn't an existing water, the current MBB is split right after the +use. It would be profitable to look farther forward, especially on Thumb, +where negative offsets won't work. + +2. WaterBlockListOffsets might be maintained throughout, rather than computed +when it is needed. This would probably lead to faster compile times. +Similarly, the offsets of blocks might be maintained throughout. -This pass has all the framework needed to implement this, but it hasn't -been done. +3. There may be some advantage to trying to be smarter about the initial +placement, rather than putting everything at the end. //===---------------------------------------------------------------------===// From sabre at nondot.org Fri Feb 23 00:53:22 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 00:53:22 -0600 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html Message-ID: <200702230653.l1N6rMNx031680@zion.cs.uiuc.edu> Changes in directory llvm/docs: DeveloperPolicy.html updated: 1.35 -> 1.36 --- Log message: clarify. --- Diffs of the changes: (+5 -5) DeveloperPolicy.html | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/docs/DeveloperPolicy.html diff -u llvm/docs/DeveloperPolicy.html:1.35 llvm/docs/DeveloperPolicy.html:1.36 --- llvm/docs/DeveloperPolicy.html:1.35 Thu Feb 22 00:33:23 2007 +++ llvm/docs/DeveloperPolicy.html Fri Feb 23 00:53:06 2007 @@ -447,10 +447,10 @@ with the GPL, and must be releasable under the terms of the GPL. This implies that any code linked into llvm-gcc and distributed to others may be subject to the viral aspects of the GPL (for example, a proprietary code generator - linked into llvm-gcc must be made available under - the GPL). This is not a problem for the main LLVM - distribution (which is already licensed under a more liberal license), but may - be a problem if you intend to base commercial development on llvm-gcc without + linked into llvm-gcc must be made available under the GPL). This is not a + problem for code already distributed under a more liberal license (like the + UIUC license), and does not affect code generated by llvm-gcc. It may be a + problem if you intend to base commercial development on llvm-gcc without redistributing your source code.

    We have no plans to change the license of LLVM. If you have questions @@ -499,7 +499,7 @@ Written by the LLVM Oversight Group
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2007/02/22 06:33:23 $ + Last modified: $Date: 2007/02/23 06:53:06 $ From clattner at apple.com Fri Feb 23 00:54:23 2007 From: clattner at apple.com (Chris Lattner) Date: Thu, 22 Feb 2007 22:54:23 -0800 Subject: [llvm-commits] CVS: llvm/docs/DeveloperPolicy.html In-Reply-To: <200702221125.03626.baldrick@free.fr> References: <200702220633.l1M6XeG0001682@zion.cs.uiuc.edu> <200702221125.03626.baldrick@free.fr> Message-ID: On Feb 22, 2007, at 2:25 AM, Duncan Sands wrote: >> + the GPL). This is not a problem for the main LLVM >> distribution (which is already licensed under a more liberal >> license), but may >> be a problem if you intend to base commercial development on >> llvm-gcc without >> redistributing your source code.

    > > Maybe you should make explicit that there is no problem using llvm- > gcc to compile > proprietary code - there is only a problem if parts of llvm-gcc are > included in > the proprietary program. You do say that more or less a few lines > before, but this > last sentence could great doubt in peoples minds. Maybe you could > offload the > problem onto gcc, and say that compiling a program with llvm-gcc is > like compiling > it with gcc, and give a link to http://www.gnu.org/licenses/gpl- > faq.html which > discusses these issues. Done, thanks! -Chris From evan.cheng at apple.com Fri Feb 23 02:41:37 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 23 Feb 2007 02:41:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegisterScavenging.cpp Message-ID: <200702230841.l1N8fbjn010032@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegisterScavenging.cpp updated: 1.1 -> 1.2 --- Log message: Mark livein registers as being in used. --- Diffs of the changes: (+6 -0) RegisterScavenging.cpp | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/lib/CodeGen/RegisterScavenging.cpp diff -u llvm/lib/CodeGen/RegisterScavenging.cpp:1.1 llvm/lib/CodeGen/RegisterScavenging.cpp:1.2 --- llvm/lib/CodeGen/RegisterScavenging.cpp:1.1 Thu Feb 22 19:01:19 2007 +++ llvm/lib/CodeGen/RegisterScavenging.cpp Fri Feb 23 02:41:19 2007 @@ -43,6 +43,12 @@ if (CSRegs != NULL) for (unsigned i = 0; CSRegs[i]; ++i) CalleeSavedRegs.set(CSRegs[i]); + + // Live-in registers are in use. + if (!MBB->livein_empty()) + for (MachineBasicBlock::const_livein_iterator I = MBB->livein_begin(), + E = MBB->livein_end(); I != E; ++I) + setUsed(*I); } void RegScavenger::forward() { From alenhar2 at cs.uiuc.edu Fri Feb 23 11:24:50 2007 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 23 Feb 2007 11:24:50 -0600 Subject: [llvm-commits] [see] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200702231724.l1NHOoLN013913@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.536.2.1.2.1 -> 1.536.2.1.2.2 --- Log message: remove debug output --- Diffs of the changes: (+1 -3) InstructionCombining.cpp | 4 +--- 1 files changed, 1 insertion(+), 3 deletions(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.1 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.2 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.536.2.1.2.1 Thu Feb 22 09:11:27 2007 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Feb 23 11:24:11 2007 @@ -4846,10 +4846,8 @@ TD->getTypeSize(Op1->getType()) >= TD->getTypeSize(CastOp1->getType()) && (CastOp1->getType()->isInteger() || isa(CastOp1->getType())) && (Op1->getType()->isInteger() || isa(Op1->getType())) - ) { - std::cerr << "Triggered\n"; + ) return BinaryOperator::create(I.getOpcode(), CastOp0, CastOp1); - } } // Handle the special case of: setcc (cast bool to X), From dpatel at apple.com Fri Feb 23 11:53:41 2007 From: dpatel at apple.com (Devang Patel) Date: Fri, 23 Feb 2007 11:53:41 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702231753.l1NHrfYv020946@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.6 -> 1.7 --- Log message: Loop passes are set up to accept pointer. --- Diffs of the changes: (+1 -1) LoopPass.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.6 llvm/lib/Analysis/LoopPass.cpp:1.7 --- llvm/lib/Analysis/LoopPass.cpp:1.6 Thu Feb 22 18:36:57 2007 +++ llvm/lib/Analysis/LoopPass.cpp Fri Feb 23 11:53:17 2007 @@ -116,7 +116,7 @@ StartPassTimer(P); LoopPass *LP = dynamic_cast(P); assert (LP && "Invalid LPPassManager member"); - LP->runOnLoop(*L, *this); + LP->runOnLoop(L, *this); StopPassTimer(P); if (Changed) From dpatel at apple.com Fri Feb 23 11:53:41 2007 From: dpatel at apple.com (Devang Patel) Date: Fri, 23 Feb 2007 11:53:41 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h Message-ID: <200702231753.l1NHrfWb020947@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopPass.h updated: 1.5 -> 1.6 --- Log message: Loop passes are set up to accept pointer. --- Diffs of the changes: (+1 -1) LoopPass.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Analysis/LoopPass.h diff -u llvm/include/llvm/Analysis/LoopPass.h:1.5 llvm/include/llvm/Analysis/LoopPass.h:1.6 --- llvm/include/llvm/Analysis/LoopPass.h:1.5 Thu Feb 22 18:36:57 2007 +++ llvm/include/llvm/Analysis/LoopPass.h Fri Feb 23 11:53:16 2007 @@ -32,7 +32,7 @@ public: // runOnLoop - THis method should be implemented by the subclass to perform // whatever action is necessary for the specfied Loop. - virtual bool runOnLoop (Loop &L, LPPassManager &LPM) = 0; + virtual bool runOnLoop (Loop *L, LPPassManager &LPM) = 0; virtual bool runOnFunctionBody (Function &F, LPPassManager &LPM) { return false; } From dpatel at apple.com Fri Feb 23 12:06:12 2007 From: dpatel at apple.com (Devang Patel) Date: Fri, 23 Feb 2007 12:06:12 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp Message-ID: <200702231806.l1NI6CQM022754@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: LoopPass.cpp updated: 1.7 -> 1.8 --- Log message: Fix thinko. --- Diffs of the changes: (+2 -1) LoopPass.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Analysis/LoopPass.cpp diff -u llvm/lib/Analysis/LoopPass.cpp:1.7 llvm/lib/Analysis/LoopPass.cpp:1.8 --- llvm/lib/Analysis/LoopPass.cpp:1.7 Fri Feb 23 11:53:17 2007 +++ llvm/lib/Analysis/LoopPass.cpp Fri Feb 23 12:05:55 2007 @@ -26,7 +26,8 @@ class LoopCompare { public: bool operator()( Loop *L1, Loop *L2) const { - return L1->getLoopDepth() > L2->getLoopDepth(); + // Loops with highest depth has the highest priority. + return L1->getLoopDepth() < L2->getLoopDepth(); } }; From sabre at nondot.org Fri Feb 23 13:34:31 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 13:34:31 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/Makefile Message-ID: <200702231934.l1NJYVTj031891@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries: Makefile updated: 1.10 -> 1.11 --- Log message: crtend is only for llvm-gcc3, remove it. --- Diffs of the changes: (+1 -1) Makefile | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/runtime/GCCLibraries/Makefile diff -u llvm/runtime/GCCLibraries/Makefile:1.10 llvm/runtime/GCCLibraries/Makefile:1.11 --- llvm/runtime/GCCLibraries/Makefile:1.10 Thu Nov 16 21:32:33 2006 +++ llvm/runtime/GCCLibraries/Makefile Fri Feb 23 13:34:09 2007 @@ -8,5 +8,5 @@ ##===----------------------------------------------------------------------===## LEVEL := ../.. -PARALLEL_DIRS := crtend libc libgcc libm +PARALLEL_DIRS := libc libgcc libm include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Fri Feb 23 13:35:42 2007 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 23 Feb 2007 13:35:42 -0600 Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/crtend/Exception.cpp Exception.h Makefile README.txt SJLJ-Exception.cpp SJLJ-Exception.h comp_genericeh.lst comp_main.lst comp_sjljeh.lst crtend.c Message-ID: <200702231935.l1NJZgMS032446@zion.cs.uiuc.edu> Changes in directory llvm/runtime/GCCLibraries/crtend: Exception.cpp (r1.4) removed Exception.h (r1.12) removed Makefile (r1.36) removed README.txt (r1.4) removed SJLJ-Exception.cpp (r1.7) removed SJLJ-Exception.h (r1.7) removed comp_genericeh.lst (r1.3) removed comp_main.lst (r1.3) removed comp_sjljeh.lst (r1.3) removed crtend.c (r1.8) removed --- Log message: crtend is only for llvm-gcc3, remove it. --- Diffs of the changes: (+0 -0) 0 files changed From sabre at nondot.org Fri Feb 23 13:39:45 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 13:39:45 -0600 Subject: [llvm-commits] CVS: llvm/test/Transforms/InstCombine/cast_ptr.ll Message-ID: <200702231939.l1NJdj3l001956@zion.cs.uiuc.edu> Changes in directory llvm/test/Transforms/InstCombine: cast_ptr.ll updated: 1.4 -> 1.5 --- Log message: fix this testcase --- Diffs of the changes: (+2 -1) cast_ptr.ll | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/test/Transforms/InstCombine/cast_ptr.ll diff -u llvm/test/Transforms/InstCombine/cast_ptr.ll:1.4 llvm/test/Transforms/InstCombine/cast_ptr.ll:1.5 --- llvm/test/Transforms/InstCombine/cast_ptr.ll:1.4 Thu Feb 22 09:17:45 2007 +++ llvm/test/Transforms/InstCombine/cast_ptr.ll Fri Feb 23 13:39:24 2007 @@ -1,6 +1,7 @@ ; Tests to make sure elimination of casts is working correctly ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output && -; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep '\([sz]ext\)\|\(trunc\)|\(ptrtoint\)' +; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast +; XFAIL: * target pointersize = 32 From clattner at apple.com Fri Feb 23 13:40:13 2007 From: clattner at apple.com (Chris Lattner) Date: Fri, 23 Feb 2007 11:40:13 -0800 Subject: [llvm-commits] CVS: llvm/test/Transforms/InstCombine/cast_ptr.ll In-Reply-To: <85dfcd7f0702220828v5bb093a1hab43141eeb1295df@mail.gmail.com> References: <200702221518.l1MFI2ij009797@zion.cs.uiuc.edu> <85dfcd7f0702220828v5bb093a1hab43141eeb1295df@mail.gmail.com> Message-ID: On Feb 22, 2007, at 8:28 AM, Andrew Lenharth wrote: > I won't get a chance to fix this before the nightly testers start. > Should I x-fail this until it is handled? I took care of this. The run line was wrong, so it didn't fail. Please add a fix to mainline when you can, Thanks! -Chris From sabre at nondot.org Fri Feb 23 13:54:47 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 13:54:47 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/ValueMapper.cpp Message-ID: <200702231954.l1NJsl7w002369@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: ValueMapper.cpp updated: 1.30 -> 1.31 --- Log message: fix an obscure and tricky bug the inliner can hit sometimes. --- Diffs of the changes: (+1 -1) ValueMapper.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/Utils/ValueMapper.cpp diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.30 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.31 --- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.30 Wed Feb 14 20:26:10 2007 +++ llvm/lib/Transforms/Utils/ValueMapper.cpp Fri Feb 23 13:54:30 2007 @@ -95,7 +95,7 @@ return VM[V] = ConstantVector::get(Values); } } - return VMSlot = C; + return VM[V] = C; } else { assert(0 && "Unknown type of constant!"); From bwendlin at apple.com Fri Feb 23 13:54:34 2007 From: bwendlin at apple.com (bwendlin at apple.com) Date: Fri, 23 Feb 2007 11:54:34 -0800 (PST) Subject: [llvm-commits] [124232] Stop the "buildit" if a "make" of LLVM fails. Message-ID: <20070223195434.DDCEF607A2BC@src> Revision: 124232 Author: bwendlin Date: 2007-02-23 11:54:33 -0800 (Fri, 23 Feb 2007) Log Message: ----------- Stop the "buildit" if a "make" of LLVM fails. Modified Paths: -------------- apple-local/branches/llvm/build_gcc Modified: apple-local/branches/llvm/build_gcc =================================================================== --- apple-local/branches/llvm/build_gcc 2007-02-23 11:08:39 UTC (rev 124231) +++ apple-local/branches/llvm/build_gcc 2007-02-23 19:54:33 UTC (rev 124232) @@ -197,6 +197,11 @@ make ENABLE_OPTIMIZED=1 UNIVERSAL=1 UNIVERSAL_ARCH="$LLVM_ARCHS" \ OPTIMIZE_OPTION='-O2' \ CXXFLAGS="-DLLVM_VERSION_INFO='\" Apple Build #$LLVM_VERSION\"'" + + if ! test $? == 0 ; then + echo "error: LLVM 'make' failed!" + exit 1 + fi fi # APPLE LOCAL LLVM end @@ -564,6 +569,11 @@ ## Install the tree into the destination directory. make $MAKEFLAGS ENABLE_OPTIMIZED=1 UNIVERSAL=1 OPTIMIZE_OPTION='-O2' install + if ! test $? == 0 ; then + echo "error: LLVM 'make install' failed!" + exit 1 + fi + ## Install Version.h if [ "x$LLVM_SUBMIT_SUBVERSION" = "x00" -o "x$LLVM_SUBMIT_SUBVERSION" = "x0" ]; then RC_ProjectSourceSubversion=0 From bwendlin at apple.com Fri Feb 23 14:14:45 2007 From: bwendlin at apple.com (bwendlin at apple.com) Date: Fri, 23 Feb 2007 12:14:45 -0800 (PST) Subject: [llvm-commits] [124233] Clear out the target builtin cache before reading a PCH file. Message-ID: <20070223201445.800F6608C462@src> Revision: 124233 Author: bwendlin Date: 2007-02-23 12:14:43 -0800 (Fri, 23 Feb 2007) Log Message: ----------- Clear out the target builtin cache before reading a PCH file. Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-backend.cpp apple-local/branches/llvm/gcc/llvm-convert.cpp apple-local/branches/llvm/gcc/llvm-internal.h Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-23 19:54:33 UTC (rev 124232) +++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-23 20:14:43 UTC (rev 124233) @@ -195,6 +195,7 @@ fclose (asm_out_file); std::string ErrMsg; + clearTargetBuiltinCache(); TheModule = ParseBytecodeFile(asm_file_name, Compressor::decompressToNewBuffer, &ErrMsg); Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-23 19:54:33 UTC (rev 124232) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-23 20:14:43 UTC (rev 124233) @@ -187,10 +187,10 @@ Constant *LLVMValuesNameTable = ConstantStruct::get(LLVMValuesNames, false); // Create variable to hold this string table. - GlobalVariable *GV = new GlobalVariable(LLVMValuesNameTable->getType(), true, - GlobalValue::ExternalLinkage, - LLVMValuesNameTable, - "llvm.pch.values", TheModule); + new GlobalVariable(LLVMValuesNameTable->getType(), true, + GlobalValue::ExternalLinkage, + LLVMValuesNameTable, + "llvm.pch.values", TheModule); } /// isGCC_SSA_Temporary - Return true if this is an SSA temporary that we can @@ -3454,7 +3454,14 @@ return false; } +/// TargetBuiltinCache - A cache of builtin intrisics indexed by the GCC builtin +/// number. +static std::vector TargetBuiltinCache; +void clearTargetBuiltinCache() { + TargetBuiltinCache.clear(); +} + /// EmitBuiltinCall - exp is a call to fndecl, a builtin function. Try to emit /// the call in a special way, setting Result to the scalar result if necessary. /// If we can't handle the builtin, return false, otherwise return true. @@ -3462,7 +3469,6 @@ Value *DestLoc, Value *&Result) { if (DECL_BUILT_IN_CLASS(fndecl) == BUILT_IN_MD) { unsigned FnCode = DECL_FUNCTION_CODE(fndecl); - static std::vector TargetBuiltinCache; if (TargetBuiltinCache.size() <= FnCode) TargetBuiltinCache.resize(FnCode+1); Modified: apple-local/branches/llvm/gcc/llvm-internal.h =================================================================== --- apple-local/branches/llvm/gcc/llvm-internal.h 2007-02-23 19:54:33 UTC (rev 124232) +++ apple-local/branches/llvm/gcc/llvm-internal.h 2007-02-23 20:14:43 UTC (rev 124233) @@ -91,6 +91,7 @@ extern void writeLLVMTypesStringTable(); extern void readLLVMValuesStringTable(); extern void writeLLVMValuesStringTable(); +extern void clearTargetBuiltinCache(); struct StructTypeConversionInfo; From lauro.venancio at gmail.com Fri Feb 23 14:33:21 2007 From: lauro.venancio at gmail.com (Lauro Ramos Venancio) Date: Fri, 23 Feb 2007 14:33:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200702232033.l1NKXLjM005286@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMISelLowering.cpp updated: 1.16 -> 1.17 --- Log message: Fix stack alignment in functions with varargs. --- Diffs of the changes: (+5 -2) ARMISelLowering.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/lib/Target/ARM/ARMISelLowering.cpp diff -u llvm/lib/Target/ARM/ARMISelLowering.cpp:1.16 llvm/lib/Target/ARM/ARMISelLowering.cpp:1.17 --- llvm/lib/Target/ARM/ARMISelLowering.cpp:1.16 Thu Feb 22 08:56:36 2007 +++ llvm/lib/Target/ARM/ARMISelLowering.cpp Fri Feb 23 14:32:57 2007 @@ -831,13 +831,16 @@ SSARegMap *RegMap = MF.getSSARegMap(); MachineFrameInfo *MFI = MF.getFrameInfo(); ARMFunctionInfo *AFI = MF.getInfo(); - unsigned VARegSaveSize = (4 - NumGPRs) * 4; + unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment(); + unsigned VARegSize = (4 - NumGPRs) * 4; + unsigned VARegSaveSize = (VARegSize + Align - 1) & ~(Align - 1); if (VARegSaveSize) { // If this function is vararg, store any remaining integer argument regs // to their spots on the stack so that they may be loaded by deferencing // the result of va_next. AFI->setVarArgsRegSaveSize(VARegSaveSize); - VarArgsFrameIndex = MFI->CreateFixedObject(VARegSaveSize, ArgOffset); + VarArgsFrameIndex = MFI->CreateFixedObject(VARegSaveSize, ArgOffset + + VARegSaveSize - VARegSize); SDOperand FIN = DAG.getFrameIndex(VarArgsFrameIndex, getPointerTy()); SmallVector MemOps; From lauro.venancio at gmail.com Fri Feb 23 14:33:21 2007 From: lauro.venancio at gmail.com (Lauro Ramos Venancio) Date: Fri, 23 Feb 2007 14:33:21 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/ARM/vargs_align.ll Message-ID: <200702232033.l1NKXLdf005283@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/ARM: vargs_align.ll added (r1.1) --- Log message: Fix stack alignment in functions with varargs. --- Diffs of the changes: (+20 -0) vargs_align.ll | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+) Index: llvm/test/CodeGen/ARM/vargs_align.ll diff -c /dev/null llvm/test/CodeGen/ARM/vargs_align.ll:1.1 *** /dev/null Fri Feb 23 14:33:07 2007 --- llvm/test/CodeGen/ARM/vargs_align.ll Fri Feb 23 14:32:57 2007 *************** *** 0 **** --- 1,20 ---- + ; RUN: llvm-as < %s | llc -march=arm && + ; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-linux-gnueabi -disable-fp-elim | grep "add sp, sp, #16" && + ; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-linux-gnu -disable-fp-elim | grep "add sp, sp, #12" + + define i32 @f(i32 %a, ...) { + entry: + %a_addr = alloca i32 ; [#uses=1] + %retval = alloca i32, align 4 ; [#uses=2] + %tmp = alloca i32, align 4 ; [#uses=2] + "alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i32 %a, i32* %a_addr + store i32 0, i32* %tmp + %tmp1 = load i32* %tmp ; [#uses=1] + store i32 %tmp1, i32* %retval + br label %return + + return: ; preds = %entry + %retval2 = load i32* %retval ; [#uses=1] + ret i32 %retval2 + } From jlaskey at apple.com Fri Feb 23 14:34:33 2007 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 23 Feb 2007 14:34:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h PPCRegisterInfo.cpp PPCRegisterInfo.h Message-ID: <200702232034.l1NKYXb1005377@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCMachineFunctionInfo.h updated: 1.2 -> 1.3 PPCRegisterInfo.cpp updated: 1.110 -> 1.111 PPCRegisterInfo.h updated: 1.28 -> 1.29 --- Log message: Don't spill LR as a callee saved register. --- Diffs of the changes: (+19 -2) PPCMachineFunctionInfo.h | 7 +++++++ PPCRegisterInfo.cpp | 13 +++++++++++-- PPCRegisterInfo.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h diff -u llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h:1.2 llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h:1.3 --- llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h:1.2 Fri Nov 24 23:41:02 2006 +++ llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h Fri Feb 23 14:34:16 2007 @@ -26,6 +26,10 @@ /// stored. Also used as an anchor for instructions that need to be altered /// when using frame pointers (dyna_add, dyna_sub.) int FramePointerSaveIndex; + + /// UsesLR - Indicates whether LR is used in the current function. + /// + bool UsesLR; public: PPCFunctionInfo(MachineFunction& MF) @@ -34,6 +38,9 @@ int getFramePointerSaveIndex() const { return FramePointerSaveIndex; } void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; } + + void setUsesLR(bool U) { UsesLR = U; } + bool usesLR() { return UsesLR; } }; Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.110 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.111 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.110 Thu Feb 22 19:10:03 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Fri Feb 23 14:34:16 2007 @@ -439,8 +439,8 @@ /// usesLR - Returns if the link registers (LR) has been used in the function. /// bool PPCRegisterInfo::usesLR(MachineFunction &MF) const { - const bool *PhysRegsUsed = MF.getUsedPhysregs(); - return PhysRegsUsed[getRARegister()]; + PPCFunctionInfo *FI = MF.getInfo(); + return FI->usesLR(); } void PPCRegisterInfo:: @@ -774,6 +774,15 @@ MFI->setStackSize(FrameSize); } +void PPCRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF) + const { + // Save and clear the LR state. + PPCFunctionInfo *FI = MF.getInfo(); + unsigned LR = getRARegister(); + FI->setUsesLR(MF.isPhysRegUsed(LR)); + MF.changePhyRegUsed(LR, false); +} + void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const { MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB MachineBasicBlock::iterator MBBI = MBB.begin(); Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.28 llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.29 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.28 Wed Feb 21 16:54:50 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h Fri Feb 23 14:34:16 2007 @@ -82,6 +82,7 @@ /// frame size. void determineFrameLayout(MachineFunction &MF) const; + void processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const; void emitPrologue(MachineFunction &MF) const; void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; From evan.cheng at apple.com Fri Feb 23 14:40:32 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 23 Feb 2007 14:40:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200702232040.l1NKeWSB006743@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.212 -> 1.213 --- Log message: Handle cases when joining live intervals of two virtual registers. --- Diffs of the changes: (+17 -7) LiveIntervalAnalysis.cpp | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.212 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.213 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.212 Thu Feb 22 17:03:39 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Feb 23 14:40:13 2007 @@ -960,21 +960,31 @@ DOUT << "\n\t\tJoined. Result = "; DestInt.print(DOUT, mri_); DOUT << "\n"; - // If the intervals were swapped by Join, swap them back so that the register - // mapping (in the r2i map) is correct. - if (Swapped) SrcInt.swap(DestInt); - // Live range has been lengthened due to colaescing, eliminate the // unnecessary kills at the end of the source live ranges. - LiveVariables::VarInfo& vi = lv_->getVarInfo(repSrcReg); - for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { - MachineInstr *Kill = vi.Kills[i]; + LiveVariables::VarInfo& svi = lv_->getVarInfo(repSrcReg); + for (unsigned i = 0, e = svi.Kills.size(); i != e; ++i) { + MachineInstr *Kill = svi.Kills[i]; if (Kill == CopyMI || isRemoved(Kill)) continue; if (DestInt.liveAt(getInstructionIndex(Kill) + InstrSlots::NUM)) unsetRegisterKill(Kill, repSrcReg); } + if (MRegisterInfo::isVirtualRegister(repDstReg)) { + // If both are virtual registers... + LiveVariables::VarInfo& dvi = lv_->getVarInfo(repDstReg); + for (unsigned i = 0, e = dvi.Kills.size(); i != e; ++i) { + MachineInstr *Kill = dvi.Kills[i]; + if (Kill == CopyMI || isRemoved(Kill)) + continue; + if (DestInt.liveAt(getInstructionIndex(Kill) + InstrSlots::NUM)) + unsetRegisterKill(Kill, repDstReg); + } + } + // If the intervals were swapped by Join, swap them back so that the register + // mapping (in the r2i map) is correct. + if (Swapped) SrcInt.swap(DestInt); removeInterval(repSrcReg); r2rMap_[repSrcReg] = repDstReg; From jlaskey at apple.com Fri Feb 23 15:45:26 2007 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 23 Feb 2007 15:45:26 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702232145.l1NLjQIF008747@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.372 -> 1.373 --- Log message: Handle improper cast. --- Diffs of the changes: (+19 -6) SelectionDAGISel.cpp | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.372 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.373 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.372 Thu Feb 22 10:10:05 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Feb 23 15:45:01 2007 @@ -484,7 +484,9 @@ unsigned Opc); bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB); void ExportFromCurrentBlock(Value *V); - void LowerCallTo(CallInst &I, SDOperand Callee, unsigned OpIdx); + void LowerCallTo(Instruction &I, + const Type *CalledValueTy, unsigned CallingConv, + bool IsTailCall, SDOperand Callee, unsigned OpIdx); // Terminator instructions. void visitRet(ReturnInst &I); @@ -1118,7 +1120,11 @@ DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), DAG.getConstant(BeginLabel, MVT::i32))); - LowerCallTo((CallInst&)I, getValue(I.getOperand(0)), 3); + LowerCallTo(I, I.getCalledValue()->getType(), + I.getCallingConv(), + false, + getValue(I.getOperand(0)), + 3); // Insert a label before the invoke call to mark the try range. // This can be used to detect deletion of the invoke via the @@ -2246,9 +2252,12 @@ } -void SelectionDAGLowering::LowerCallTo(CallInst &I, +void SelectionDAGLowering::LowerCallTo(Instruction &I, + const Type *CalledValueTy, + unsigned CallingConv, + bool IsTailCall, SDOperand Callee, unsigned OpIdx) { - const PointerType *PT = cast(I.getCalledValue()->getType()); + const PointerType *PT = cast(CalledValueTy); const FunctionType *FTy = cast(PT->getElementType()); TargetLowering::ArgListTy Args; @@ -2267,7 +2276,7 @@ std::pair Result = TLI.LowerCallTo(getRoot(), I.getType(), FTy->paramHasAttr(0,FunctionType::SExtAttribute), - FTy->isVarArg(), I.getCallingConv(), I.isTailCall(), + FTy->isVarArg(), CallingConv, IsTailCall, Callee, Args, DAG); if (I.getType() != Type::VoidTy) setValue(&I, Result.first); @@ -2333,7 +2342,11 @@ else Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy()); - LowerCallTo(I, Callee, 1); + LowerCallTo(I, I.getCalledValue()->getType(), + I.getCallingConv(), + I.isTailCall(), + Callee, + 1); } From evan.cheng at apple.com Fri Feb 23 15:48:07 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 23 Feb 2007 15:48:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp Message-ID: <200702232148.l1NLm79F008797@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.98 -> 1.99 --- Log message: Reuse extends the liveness of a register. Transfer the kill to the operand that reuse it. --- Diffs of the changes: (+6 -1) VirtRegMap.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.98 llvm/lib/CodeGen/VirtRegMap.cpp:1.99 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.98 Thu Feb 22 19:13:26 2007 +++ llvm/lib/CodeGen/VirtRegMap.cpp Fri Feb 23 15:47:50 2007 @@ -665,8 +665,13 @@ // Extend the live range of the MI that last kill the register if // necessary. MachineOperand *MOK = SSMI->findRegisterUseOperand(PhysReg, true); - if (MOK) + if (MOK) { MOK->unsetIsKill(); + if (ti == -1) + // Unless it's the use of a two-address code, transfer the kill + // of the reused register to this use. + MI.getOperand(i).setIsKill(); + } // The only technical detail we have is that we don't know that // PhysReg won't be clobbered by a reloaded stack slot that occurs From lauro.venancio at gmail.com Fri Feb 23 15:54:06 2007 From: lauro.venancio at gmail.com (Lauro Ramos Venancio) Date: Fri, 23 Feb 2007 15:54:06 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/ARM/vargs_align.ll Message-ID: <200702232154.l1NLs60N008918@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/ARM: vargs_align.ll updated: 1.1 -> 1.2 --- Log message: bugfix: SP wasn't updated for varargs when frame pointer was eliminated. --- Diffs of the changes: (+2 -2) vargs_align.ll | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/test/CodeGen/ARM/vargs_align.ll diff -u llvm/test/CodeGen/ARM/vargs_align.ll:1.1 llvm/test/CodeGen/ARM/vargs_align.ll:1.2 --- llvm/test/CodeGen/ARM/vargs_align.ll:1.1 Fri Feb 23 14:32:57 2007 +++ llvm/test/CodeGen/ARM/vargs_align.ll Fri Feb 23 15:53:48 2007 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=arm && -; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-linux-gnueabi -disable-fp-elim | grep "add sp, sp, #16" && -; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-linux-gnu -disable-fp-elim | grep "add sp, sp, #12" +; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-linux-gnueabi | grep "add sp, sp, #16" | wc -l | grep 1 && +; RUN: llvm-as < %s | llc -march=arm -mtriple=arm-linux-gnu | grep "add sp, sp, #12" | wc -l | grep 2 define i32 @f(i32 %a, ...) { entry: From lauro.venancio at gmail.com Fri Feb 23 15:54:07 2007 From: lauro.venancio at gmail.com (Lauro Ramos Venancio) Date: Fri, 23 Feb 2007 15:54:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMRegisterInfo.cpp Message-ID: <200702232154.l1NLs7wY008923@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMRegisterInfo.cpp updated: 1.71 -> 1.72 --- Log message: bugfix: SP wasn't updated for varargs when frame pointer was eliminated. --- Diffs of the changes: (+65 -65) ARMRegisterInfo.cpp | 130 ++++++++++++++++++++++++++-------------------------- 1 files changed, 65 insertions(+), 65 deletions(-) Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.71 llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.72 --- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.71 Thu Feb 22 19:09:11 2007 +++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Fri Feb 23 15:53:48 2007 @@ -1086,15 +1086,16 @@ // belongs to which callee-save spill areas. unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0; int FramePtrSpillFI = 0; + + if (VARegSaveSize) + emitSPUpdate(MBB, MBBI, -VARegSaveSize, isThumb, TII); + if (!AFI->hasStackFrame()) { if (NumBytes != 0) emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII); return; } - if (VARegSaveSize) - emitSPUpdate(MBB, MBBI, -VARegSaveSize, isThumb, TII); - for (unsigned i = 0, e = CSI.size(); i != e; ++i) { unsigned Reg = CSI[i].getReg(); int FI = CSI[i].getFrameIdx(); @@ -1208,72 +1209,71 @@ if (!AFI->hasStackFrame()) { if (NumBytes != 0) emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII); - return; - } - - // Unwind MBBI to point to first LDR / FLDD. - const unsigned *CSRegs = getCalleeSavedRegs(); - if (MBBI != MBB.begin()) { - do - --MBBI; - while (MBBI != MBB.begin() && isCSRestore(MBBI, CSRegs)); - if (!isCSRestore(MBBI, CSRegs)) - ++MBBI; - } - - // Move SP to start of FP callee save spill area. - NumBytes -= (AFI->getGPRCalleeSavedArea1Size() + - AFI->getGPRCalleeSavedArea2Size() + - AFI->getDPRCalleeSavedAreaSize()); - if (isThumb) { - if (hasFP(MF)) { - NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; - // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. - if (NumBytes) - emitThumbRegPlusImmediate(MBB, MBBI, ARM::SP, FramePtr, -NumBytes, TII); - else - BuildMI(MBB, MBBI, TII.get(ARM::tMOVrr), ARM::SP).addReg(FramePtr); - } else { - if (MBBI->getOpcode() == ARM::tBX_RET && - &MBB.front() != MBBI && - prior(MBBI)->getOpcode() == ARM::tPOP) { - MachineBasicBlock::iterator PMBBI = prior(MBBI); - emitSPUpdate(MBB, PMBBI, NumBytes, isThumb, TII); - } else - emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII); - } } else { - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { - NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; - // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. - if (AFI->getGPRCalleeSavedArea2Size() || - AFI->getDPRCalleeSavedAreaSize() || - AFI->getDPRCalleeSavedAreaOffset()|| - hasFP(MF)) + // Unwind MBBI to point to first LDR / FLDD. + const unsigned *CSRegs = getCalleeSavedRegs(); + if (MBBI != MBB.begin()) { + do + --MBBI; + while (MBBI != MBB.begin() && isCSRestore(MBBI, CSRegs)); + if (!isCSRestore(MBBI, CSRegs)) + ++MBBI; + } + + // Move SP to start of FP callee save spill area. + NumBytes -= (AFI->getGPRCalleeSavedArea1Size() + + AFI->getGPRCalleeSavedArea2Size() + + AFI->getDPRCalleeSavedAreaSize()); + if (isThumb) { + if (hasFP(MF)) { + NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; + // Reset SP based on frame pointer only if the stack frame extends beyond + // frame pointer stack slot or target is ELF and the function has FP. if (NumBytes) - BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr) - .addImm(NumBytes); + emitThumbRegPlusImmediate(MBB, MBBI, ARM::SP, FramePtr, -NumBytes, TII); else - BuildMI(MBB, MBBI, TII.get(ARM::MOVrr), ARM::SP).addReg(FramePtr); - } else if (NumBytes) { - emitSPUpdate(MBB, MBBI, NumBytes, false, TII); - } + BuildMI(MBB, MBBI, TII.get(ARM::tMOVrr), ARM::SP).addReg(FramePtr); + } else { + if (MBBI->getOpcode() == ARM::tBX_RET && + &MBB.front() != MBBI && + prior(MBBI)->getOpcode() == ARM::tPOP) { + MachineBasicBlock::iterator PMBBI = prior(MBBI); + emitSPUpdate(MBB, PMBBI, NumBytes, isThumb, TII); + } else + emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII); + } + } else { + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + if (STI.isTargetDarwin() || hasFP(MF)) { + NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; + // Reset SP based on frame pointer only if the stack frame extends beyond + // frame pointer stack slot or target is ELF and the function has FP. + if (AFI->getGPRCalleeSavedArea2Size() || + AFI->getDPRCalleeSavedAreaSize() || + AFI->getDPRCalleeSavedAreaOffset()|| + hasFP(MF)) + if (NumBytes) + BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr) + .addImm(NumBytes); + else + BuildMI(MBB, MBBI, TII.get(ARM::MOVrr), ARM::SP).addReg(FramePtr); + } else if (NumBytes) { + emitSPUpdate(MBB, MBBI, NumBytes, false, TII); + } - // Move SP to start of integer callee save spill area 2. - movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI); - emitSPUpdate(MBB, MBBI, AFI->getDPRCalleeSavedAreaSize(), false, TII); - - // Move SP to start of integer callee save spill area 1. - movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 2, STI); - emitSPUpdate(MBB, MBBI, AFI->getGPRCalleeSavedArea2Size(), false, TII); - - // Move SP to SP upon entry to the function. - movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 1, STI); - emitSPUpdate(MBB, MBBI, AFI->getGPRCalleeSavedArea1Size(), false, TII); + // Move SP to start of integer callee save spill area 2. + movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI); + emitSPUpdate(MBB, MBBI, AFI->getDPRCalleeSavedAreaSize(), false, TII); + + // Move SP to start of integer callee save spill area 1. + movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 2, STI); + emitSPUpdate(MBB, MBBI, AFI->getGPRCalleeSavedArea2Size(), false, TII); + + // Move SP to SP upon entry to the function. + movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 1, STI); + emitSPUpdate(MBB, MBBI, AFI->getGPRCalleeSavedArea1Size(), false, TII); + } } if (VARegSaveSize) { From jlaskey at apple.com Fri Feb 23 16:12:29 2007 From: jlaskey at apple.com (Jim Laskey) Date: Fri, 23 Feb 2007 16:12:29 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/PowerPC/2007-02-23-lr-saved-twice.ll Message-ID: <200702232212.l1NMCTae011220@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/PowerPC: 2007-02-23-lr-saved-twice.ll added (r1.1) --- Log message: New test - practically wrote itself. --- Diffs of the changes: (+15 -0) 2007-02-23-lr-saved-twice.ll | 15 +++++++++++++++ 1 files changed, 15 insertions(+) Index: llvm/test/CodeGen/PowerPC/2007-02-23-lr-saved-twice.ll diff -c /dev/null llvm/test/CodeGen/PowerPC/2007-02-23-lr-saved-twice.ll:1.1 *** /dev/null Fri Feb 23 16:12:18 2007 --- llvm/test/CodeGen/PowerPC/2007-02-23-lr-saved-twice.ll Fri Feb 23 16:12:08 2007 *************** *** 0 **** --- 1,15 ---- + ; RUN: llvm-as < %s | llc | grep mflr | wc -l | grep 1 + + target datalayout = "e-p:32:32" + target triple = "powerpc-apple-darwin8" + @str = internal constant [18 x i8] c"hello world!, %d\0A\00" ; <[18 x i8]*> [#uses=1] + + implementation ; Functions: + + define i32 @main() { + entry: + %tmp = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([18 x i8]* @str, i32 0, i32 0) ) ; [#uses=0] + ret i32 0 + } + + declare i32 @printf(i8*, ...) From sabre at nondot.org Fri Feb 23 16:31:49 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 16:31:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/Allocator.cpp Message-ID: <200702232231.l1NMVnV3013062@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Allocator.cpp updated: 1.5 -> 1.6 --- Log message: Avoid TBAA issue. --- Diffs of the changes: (+4 -1) Allocator.cpp | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/lib/Support/Allocator.cpp diff -u llvm/lib/Support/Allocator.cpp:1.5 llvm/lib/Support/Allocator.cpp:1.6 --- llvm/lib/Support/Allocator.cpp:1.5 Thu Dec 7 17:41:45 2006 +++ llvm/lib/Support/Allocator.cpp Fri Feb 23 16:31:24 2007 @@ -93,7 +93,10 @@ } void *BumpPtrAllocator::Allocate(unsigned Size, unsigned Align) { - return ((MemRegion*)TheMemory)->Allocate(Size, Align,(MemRegion**)&TheMemory); + MemRegion *MRP = (MemRegion*)TheMemory; + void *Ptr = MRP->Allocate(Size, Align, &MRP); + TheMemory = MRP; + return Ptr; } void BumpPtrAllocator::PrintStats() const { From isanbard at gmail.com Fri Feb 23 16:45:30 2007 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 23 Feb 2007 16:45:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/CBackend.cpp Message-ID: <200702232245.l1NMjUvN013854@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: CBackend.cpp updated: 1.327 -> 1.328 --- Log message: PR1164: http://llvm.org/PR1164 : Generate local names with a "llvm_cbe_" prefix using the actual name of the variable instead of a temporary name. --- Diffs of the changes: (+52 -22) CBackend.cpp | 74 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 52 insertions(+), 22 deletions(-) Index: llvm/lib/Target/CBackend/CBackend.cpp diff -u llvm/lib/Target/CBackend/CBackend.cpp:1.327 llvm/lib/Target/CBackend/CBackend.cpp:1.328 --- llvm/lib/Target/CBackend/CBackend.cpp:1.327 Wed Feb 14 21:39:18 2007 +++ llvm/lib/Target/CBackend/CBackend.cpp Fri Feb 23 16:45:08 2007 @@ -239,7 +239,7 @@ } void outputLValue(Instruction *I) { - Out << " " << Mang->getValueName(I) << " = "; + Out << " " << GetValueName(I) << " = "; } bool isGotoCodeNecessary(BasicBlock *From, BasicBlock *To); @@ -249,6 +249,8 @@ unsigned Indent); void printIndexingExpression(Value *Ptr, gep_type_iterator I, gep_type_iterator E); + + std::string GetValueName(const Value *Operand); }; } @@ -1080,6 +1082,34 @@ printConstant(CPV); } +std::string CWriter::GetValueName(const Value *Operand) { + std::string Name; + + if (!isa(Operand) && Operand->getName() != "") { + std::string VarName; + + Name = Operand->getName(); + VarName.reserve(Name.capacity()); + + for (std::string::iterator I = Name.begin(), E = Name.end(); + I != E; ++I) { + char ch = *I; + + if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || + (ch >= '0' && ch <= '9') || ch == '_')) + VarName += '_'; + else + VarName += ch; + } + + Name = "llvm_cbe_" + VarName; + } else { + Name = Mang->getValueName(Operand); + } + + return Name; +} + void CWriter::writeOperandInternal(Value *Operand) { if (Instruction *I = dyn_cast(Operand)) if (isInlinableInst(*I) && !isDirectAlloca(I)) { @@ -1091,11 +1121,11 @@ } Constant* CPV = dyn_cast(Operand); - if (CPV && !isa(CPV)) { + + if (CPV && !isa(CPV)) printConstant(CPV); - } else { - Out << Mang->getValueName(Operand); - } + else + Out << GetValueName(Operand); } void CWriter::writeOperandRaw(Value *Operand) { @@ -1103,7 +1133,7 @@ if (CPV && !isa(CPV)) { printConstant(CPV); } else { - Out << Mang->getValueName(Operand); + Out << GetValueName(Operand); } } @@ -1472,17 +1502,17 @@ if (I->hasExternalLinkage()) { Out << "extern "; printType(Out, I->getType()->getElementType(), false, - Mang->getValueName(I)); + GetValueName(I)); Out << ";\n"; } else if (I->hasDLLImportLinkage()) { Out << "__declspec(dllimport) "; printType(Out, I->getType()->getElementType(), false, - Mang->getValueName(I)); + GetValueName(I)); Out << ";\n"; } else if (I->hasExternalWeakLinkage()) { Out << "extern "; printType(Out, I->getType()->getElementType(), false, - Mang->getValueName(I)); + GetValueName(I)); Out << " __EXTERNAL_WEAK__ ;\n"; } } @@ -1533,7 +1563,7 @@ else Out << "extern "; printType(Out, I->getType()->getElementType(), false, - Mang->getValueName(I)); + GetValueName(I)); if (I->hasLinkOnceLinkage()) Out << " __attribute__((common))"; @@ -1565,7 +1595,7 @@ Out << "__declspec(dllexport) "; printType(Out, I->getType()->getElementType(), false, - Mang->getValueName(I)); + GetValueName(I)); if (I->hasLinkOnceLinkage()) Out << " __attribute__((common))"; else if (I->hasWeakLinkage()) @@ -1772,7 +1802,7 @@ std::stringstream FunctionInnards; // Print out the name... - FunctionInnards << Mang->getValueName(F) << '('; + FunctionInnards << GetValueName(F) << '('; bool PrintedArg = false; if (!F->isDeclaration()) { @@ -1791,7 +1821,7 @@ for (; I != E; ++I) { if (PrintedArg) FunctionInnards << ", "; if (I->hasName() || !Prototype) - ArgName = Mang->getValueName(I); + ArgName = GetValueName(I); else ArgName = ""; printType(FunctionInnards, I->getType(), @@ -1874,7 +1904,7 @@ Out << " "; printType(Out, F.arg_begin()->getType(), false, - Mang->getValueName(F.arg_begin())); + GetValueName(F.arg_begin())); Out << " = &StructReturn;\n"; } @@ -1884,18 +1914,18 @@ for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) { if (const AllocaInst *AI = isDirectAlloca(&*I)) { Out << " "; - printType(Out, AI->getAllocatedType(), false, Mang->getValueName(AI)); + printType(Out, AI->getAllocatedType(), false, GetValueName(AI)); Out << "; /* Address-exposed local */\n"; PrintedVar = true; } else if (I->getType() != Type::VoidTy && !isInlinableInst(*I)) { Out << " "; - printType(Out, I->getType(), false, Mang->getValueName(&*I)); + printType(Out, I->getType(), false, GetValueName(&*I)); Out << ";\n"; if (isa(*I)) { // Print out PHI node temporaries as well... Out << " "; printType(Out, I->getType(), false, - Mang->getValueName(&*I)+"__PHI_TEMPORARY"); + GetValueName(&*I)+"__PHI_TEMPORARY"); Out << ";\n"; } PrintedVar = true; @@ -1904,7 +1934,7 @@ // of a union to do the BitCast. This is separate from the need for a // variable to hold the result of the BitCast. if (isFPIntBitCast(*I)) { - Out << " llvmBitCastUnion " << Mang->getValueName(&*I) + Out << " llvmBitCastUnion " << GetValueName(&*I) << "__BITCAST_TEMPORARY;\n"; PrintedVar = true; } @@ -1958,7 +1988,7 @@ break; } - if (NeedsLabel) Out << Mang->getValueName(BB) << ":\n"; + if (NeedsLabel) Out << GetValueName(BB) << ":\n"; // Output all of the instructions in the basic block... for (BasicBlock::iterator II = BB->begin(), E = --BB->end(); II != E; @@ -2054,7 +2084,7 @@ Value *IV = PN->getIncomingValueForBlock(CurBlock); if (!isa(IV)) { Out << std::string(Indent, ' '); - Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = "; + Out << " " << GetValueName(I) << "__PHI_TEMPORARY = "; writeOperand(IV); Out << "; /* for PHI node */\n"; } @@ -2281,10 +2311,10 @@ Out << '('; if (isFPIntBitCast(I)) { // These int<->float and long<->double casts need to be handled specially - Out << Mang->getValueName(&I) << "__BITCAST_TEMPORARY." + Out << GetValueName(&I) << "__BITCAST_TEMPORARY." << getFloatBitCastField(I.getOperand(0)->getType()) << " = "; writeOperand(I.getOperand(0)); - Out << ", " << Mang->getValueName(&I) << "__BITCAST_TEMPORARY." + Out << ", " << GetValueName(&I) << "__BITCAST_TEMPORARY." << getFloatBitCastField(I.getType()); } else { printCast(I.getOpcode(), SrcTy, DstTy); From isanbard at gmail.com Fri Feb 23 16:45:30 2007 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 23 Feb 2007 16:45:30 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/CBackend/2007-01-08-ParamAttr-ICmp.ll Message-ID: <200702232245.l1NMjURM013851@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/CBackend: 2007-01-08-ParamAttr-ICmp.ll updated: 1.3 -> 1.4 --- Log message: PR1164: http://llvm.org/PR1164 : Generate local names with a "llvm_cbe_" prefix using the actual name of the variable instead of a temporary name. --- Diffs of the changes: (+1 -1) 2007-01-08-ParamAttr-ICmp.ll | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/test/CodeGen/CBackend/2007-01-08-ParamAttr-ICmp.ll diff -u llvm/test/CodeGen/CBackend/2007-01-08-ParamAttr-ICmp.ll:1.3 llvm/test/CodeGen/CBackend/2007-01-08-ParamAttr-ICmp.ll:1.4 --- llvm/test/CodeGen/CBackend/2007-01-08-ParamAttr-ICmp.ll:1.3 Thu Feb 15 15:01:58 2007 +++ llvm/test/CodeGen/CBackend/2007-01-08-ParamAttr-ICmp.ll Fri Feb 23 16:45:08 2007 @@ -1,6 +1,6 @@ ; For PR1099 ; RUN: llvm-as < %s | llc -march=c | \ -; RUN: grep 'return ((((ltmp_2_2 == ltmp_1_2)) ? (1) : (0)))' +; RUN: grep 'return ((((llvm_cbe_tmp2 == llvm_cbe_b_0_0_val)) ? (1) : (0)))' target datalayout = "e-p:32:32" target triple = "i686-apple-darwin8" From pmeredit at cs.uiuc.edu Fri Feb 23 16:49:49 2007 From: pmeredit at cs.uiuc.edu (Patrick Meredith) Date: Fri, 23 Feb 2007 16:49:49 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/DSA/BottomUpClosure.cpp CallTargets.cpp CompleteBottomUp.cpp DataStructure.cpp DataStructureAA.cpp DataStructureOpt.cpp EquivClassGraphs.cpp Local.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200702232249.l1NMnnmY014927@zion.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/DSA: BottomUpClosure.cpp updated: 1.129 -> 1.130 CallTargets.cpp updated: 1.10 -> 1.11 CompleteBottomUp.cpp updated: 1.41 -> 1.42 DataStructure.cpp updated: 1.258 -> 1.259 DataStructureAA.cpp updated: 1.41 -> 1.42 DataStructureOpt.cpp updated: 1.17 -> 1.18 EquivClassGraphs.cpp updated: 1.55 -> 1.56 Local.cpp updated: 1.167 -> 1.168 Steensgaard.cpp updated: 1.68 -> 1.69 TopDownClosure.cpp updated: 1.97 -> 1.98 --- Log message: Made to compile with newest version of llvm tree --- Diffs of the changes: (+52 -51) BottomUpClosure.cpp | 10 +++++----- CallTargets.cpp | 2 +- CompleteBottomUp.cpp | 12 ++++++------ DataStructure.cpp | 18 +++++++++--------- DataStructureAA.cpp | 3 ++- DataStructureOpt.cpp | 2 +- EquivClassGraphs.cpp | 18 +++++++++--------- Local.cpp | 18 +++++++++--------- Steensgaard.cpp | 6 +++--- TopDownClosure.cpp | 14 +++++++------- 10 files changed, 52 insertions(+), 51 deletions(-) Index: llvm-poolalloc/lib/DSA/BottomUpClosure.cpp diff -u llvm-poolalloc/lib/DSA/BottomUpClosure.cpp:1.129 llvm-poolalloc/lib/DSA/BottomUpClosure.cpp:1.130 --- llvm-poolalloc/lib/DSA/BottomUpClosure.cpp:1.129 Wed Jan 10 12:10:32 2007 +++ llvm-poolalloc/lib/DSA/BottomUpClosure.cpp Fri Feb 23 16:49:32 2007 @@ -163,13 +163,13 @@ hash_map ValMap; unsigned NextID = 1; - Function *MainFunc = M.getMainFunction(); + Function *MainFunc = M.getFunction("main"); if (MainFunc) calculateGraphs(MainFunc, Stack, NextID, ValMap); // Calculate the graphs for any functions that are unreachable from main... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal() && !DSInfo.count(I)) { + if (!I->isDeclaration() && !DSInfo.count(I)) { if (MainFunc) DOUT << "*** BU: Function unreachable from main: " << I->getName() << "\n"; @@ -212,7 +212,7 @@ // Merge the globals variables (not the calls) from the globals graph back // into the main function's graph so that the main function contains all of // the information about global pools and GV usage in the program. - if (MainFunc && !MainFunc->isExternal()) { + if (MainFunc && !MainFunc->isDeclaration()) { DSGraph &MainGraph = getOrCreateGraph(MainFunc); const DSGraph &GG = *MainGraph.getGlobalsGraph(); ReachabilityCloner RC(MainGraph, GG, @@ -280,7 +280,7 @@ } static bool isResolvableFunc(const Function* callee) { - return !callee->isExternal() || isVAHackFn(callee); + return !callee->isDeclaration() || isVAHackFn(callee); } static void GetAllCallees(const DSCallSite &CS, @@ -349,7 +349,7 @@ // FIXME! This test should be generalized to be any function that we have // already processed, in the case when there isn't a main or there are // unreachable functions! - if (F->isExternal()) { // sprintf, fprintf, sscanf, etc... + if (F->isDeclaration()) { // sprintf, fprintf, sscanf, etc... // No callees! Stack.pop_back(); ValMap[F] = ~0; Index: llvm-poolalloc/lib/DSA/CallTargets.cpp diff -u llvm-poolalloc/lib/DSA/CallTargets.cpp:1.10 llvm-poolalloc/lib/DSA/CallTargets.cpp:1.11 --- llvm-poolalloc/lib/DSA/CallTargets.cpp:1.10 Wed Jan 10 13:59:52 2007 +++ llvm-poolalloc/lib/DSA/CallTargets.cpp Fri Feb 23 16:49:32 2007 @@ -42,7 +42,7 @@ { TDDataStructures* T = &getAnalysis(); for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal()) + if (!I->isDeclaration()) for (Function::iterator F = I->begin(), FE = I->end(); F != FE; ++F) for (BasicBlock::iterator B = F->begin(), BE = F->end(); B != BE; ++B) if (isa(B) || isa(B)) { Index: llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp diff -u llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp:1.41 llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp:1.42 --- llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp:1.41 Wed Jan 10 12:10:32 2007 +++ llvm-poolalloc/lib/DSA/CompleteBottomUp.cpp Fri Feb 23 16:49:32 2007 @@ -46,16 +46,16 @@ hash_map ValMap; unsigned NextID = 1; - Function *MainFunc = M.getMainFunction(); + Function *MainFunc = M.getFunction("main"); if (MainFunc) { - if (!MainFunc->isExternal()) + if (!MainFunc->isDeclaration()) calculateSCCGraphs(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); } else { DOUT << "CBU-DSA: No 'main' function found!\n"; } for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal() && !DSInfo.count(I)) { + if (!I->isDeclaration() && !DSInfo.count(I)) { if (MainFunc) { DOUT << "*** CBU: Function unreachable from main: " << I->getName() << "\n"; @@ -69,7 +69,7 @@ // Merge the globals variables (not the calls) from the globals graph back // into the main function's graph so that the main function contains all of // the information about global pools and GV usage in the program. - if (MainFunc && !MainFunc->isExternal()) { + if (MainFunc && !MainFunc->isDeclaration()) { DSGraph &MainGraph = getOrCreateGraph(*MainFunc); const DSGraph &GG = *MainGraph.getGlobalsGraph(); ReachabilityCloner RC(MainGraph, GG, @@ -129,7 +129,7 @@ callee_iterator I = callee_begin(Call), E = callee_end(Call); for (; I != E && I->first == Call; ++I) { assert(I->first == Call && "Bad callee construction!"); - if (!I->second->isExternal()) { + if (!I->second->isDeclaration()) { DSGraph &Callee = getOrCreateGraph(*I->second); unsigned M; // Have we visited the destination function yet? @@ -209,7 +209,7 @@ for (; I != E; ++I, ++TNum) { assert(I->first == TheCall && "Bad callee construction!"); Function *CalleeFunc = I->second; - if (!CalleeFunc->isExternal()) { + if (!CalleeFunc->isDeclaration()) { // Merge the callee's graph into this graph. This works for normal // calls or for self recursion within an SCC. DSGraph &GI = getOrCreateGraph(*CalleeFunc); Index: llvm-poolalloc/lib/DSA/DataStructure.cpp diff -u llvm-poolalloc/lib/DSA/DataStructure.cpp:1.258 llvm-poolalloc/lib/DSA/DataStructure.cpp:1.259 --- llvm-poolalloc/lib/DSA/DataStructure.cpp:1.258 Mon Jan 22 11:03:41 2007 +++ llvm-poolalloc/lib/DSA/DataStructure.cpp Fri Feb 23 16:49:32 2007 @@ -392,7 +392,7 @@ if (SS.Idx != ST->getNumElements()) { const StructLayout *SL = TD.getStructLayout(ST); SS.Offset += - unsigned(SL->MemberOffsets[SS.Idx]-SL->MemberOffsets[SS.Idx-1]); + unsigned(SL->getElementOffset(SS.Idx)-SL->getElementOffset(SS.Idx-1)); return; } Stack.pop_back(); // At the end of the structure @@ -423,7 +423,7 @@ assert(SS.Idx < ST->getNumElements()); const StructLayout *SL = TD.getStructLayout(ST); Stack.push_back(StackState(ST->getElementType(SS.Idx), - SS.Offset+unsigned(SL->MemberOffsets[SS.Idx]))); + SS.Offset+unsigned(SL->getElementOffset(SS.Idx)))); } } else { const ArrayType *AT = cast(SS.Ty); @@ -576,7 +576,7 @@ const StructLayout &SL = *TD.getStructLayout(STy); unsigned i = SL.getElementContainingOffset(Offset); //Either we hit it exactly or give up - if (SL.MemberOffsets[i] != Offset) { + if (SL.getElementOffset(i) != Offset) { if (FoldIfIncompatible) foldNodeCompletely(); return true; } @@ -601,7 +601,7 @@ const StructLayout &SL = *TD.getStructLayout(STy); unsigned i = SL.getElementContainingOffset(Offset); //Either we hit it exactly or give up - if (SL.MemberOffsets[i] != Offset) { + if (SL.getElementOffset(i) != Offset) { if (FoldIfIncompatible) foldNodeCompletely(); return true; } @@ -665,7 +665,7 @@ // The offset we are looking for must be in the i'th element... SubType = STy->getElementType(i); - O += (unsigned)SL.MemberOffsets[i]; + O += (unsigned)SL.getElementOffset(i); break; } case Type::ArrayTyID: { @@ -715,8 +715,8 @@ case Type::StructTyID: { const StructType *STy = cast(SubType); const StructLayout &SL = *TD.getStructLayout(STy); - if (SL.MemberOffsets.size() > 1) - NextPadSize = (unsigned)SL.MemberOffsets[1]; + if (STy->getNumElements() > 1) + NextPadSize = (unsigned)SL.getElementOffset(1); else NextPadSize = SubTypeSize; NextSubType = STy->getElementType(0); @@ -1998,7 +1998,7 @@ // them specially for (std::list::iterator I = FunctionCalls.begin(), E = FunctionCalls.end(); I != E; ++I) - if(I->isDirectCall() && I->getCalleeFunc()->isExternal()) + if(I->isDirectCall() && I->getCalleeFunc()->isDeclaration()) markIncomplete(*I); // Mark all global nodes as incomplete. @@ -2023,7 +2023,7 @@ std::vector Funcs; N->addFullFunctionList(Funcs); for (unsigned i = 0, e = Funcs.size(); i != e; ++i) - if (Funcs[i]->isExternal()) return true; + if (Funcs[i]->isDeclaration()) return true; return false; } Index: llvm-poolalloc/lib/DSA/DataStructureAA.cpp diff -u llvm-poolalloc/lib/DSA/DataStructureAA.cpp:1.41 llvm-poolalloc/lib/DSA/DataStructureAA.cpp:1.42 --- llvm-poolalloc/lib/DSA/DataStructureAA.cpp:1.41 Wed Dec 13 23:51:06 2006 +++ llvm-poolalloc/lib/DSA/DataStructureAA.cpp Fri Feb 23 16:49:32 2007 @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// + #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -220,7 +221,7 @@ if (!F) return AliasAnalysis::getModRefInfo(CS, P, Size); - if (F->isExternal()) { + if (F->isDeclaration()) { // If we are calling an external function, and if this global doesn't escape // the portion of the program we have analyzed, we can draw conclusions // based on whether the global escapes the program. Index: llvm-poolalloc/lib/DSA/DataStructureOpt.cpp diff -u llvm-poolalloc/lib/DSA/DataStructureOpt.cpp:1.17 llvm-poolalloc/lib/DSA/DataStructureOpt.cpp:1.18 --- llvm-poolalloc/lib/DSA/DataStructureOpt.cpp:1.17 Wed Jan 10 13:59:52 2007 +++ llvm-poolalloc/lib/DSA/DataStructureOpt.cpp Fri Feb 23 16:49:32 2007 @@ -60,7 +60,7 @@ bool Changed = false; for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) - if (!I->isExternal()) { // Loop over all of the non-external globals... + if (!I->isDeclaration()) { // Loop over all of the non-external globals... // Look up the node corresponding to this global, if it exists. DSNode *GNode = 0; DSGraph::ScalarMapTy::const_iterator SMI = SM.find(I); Index: llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp diff -u llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp:1.55 llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp:1.56 --- llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp:1.55 Wed Jan 10 12:10:32 2007 +++ llvm-poolalloc/lib/DSA/EquivClassGraphs.cpp Fri Feb 23 16:49:32 2007 @@ -41,7 +41,7 @@ template static void CheckAllGraphs(Module *M, GT &ECGraphs) { for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - if (!I->isExternal()) { + if (!I->isDeclaration()) { DSGraph &G = ECGraphs.getDSGraph(*I); if (G.retnodes_begin()->first != I) continue; // Only check a graph once. @@ -86,15 +86,15 @@ std::map ValMap; unsigned NextID = 1; - Function *MainFunc = M.getMainFunction(); - if (MainFunc && !MainFunc->isExternal()) { + Function *MainFunc = M.getFunction("main"); + if (MainFunc && !MainFunc->isDeclaration()) { processSCC(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); } else { cerr << "Fold Graphs: No 'main' function found!\n"; } for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal()) + if (!I->isDeclaration()) processSCC(getOrCreateGraph(*I), Stack, NextID, ValMap); DEBUG(CheckAllGraphs(&M, *this)); @@ -105,7 +105,7 @@ // Merge the globals variables (not the calls) from the globals graph back // into the main function's graph so that the main function contains all of // the information about global pools and GV usage in the program. - if (MainFunc && !MainFunc->isExternal()) { + if (MainFunc && !MainFunc->isDeclaration()) { DSGraph &MainGraph = getOrCreateGraph(*MainFunc); const DSGraph &GG = *MainGraph.getGlobalsGraph(); ReachabilityCloner RC(MainGraph, GG, @@ -163,7 +163,7 @@ Instruction *LastInst = 0; Function *FirstFunc = 0; for (ActualCalleesTy::const_iterator I=AC.begin(), E=AC.end(); I != E; ++I) { - if (I->second->isExternal()) + if (I->second->isDeclaration()) continue; // Ignore functions we cannot modify CallSite CS = CallSite::get(I->first); @@ -335,7 +335,7 @@ // Loop over all of the actually called functions... for (callee_iterator I = callee_begin(Call), E = callee_end(Call); I != E; ++I) - if (!I->second->isExternal()) { + if (!I->second->isDeclaration()) { // Process the callee as necessary. unsigned M = processSCC(getOrCreateGraph(*I->second), Stack, NextID, ValMap); @@ -412,7 +412,7 @@ // Loop over all potential callees to find the first non-external callee. for (TNum = 0, Num = std::distance(I, E); I != E; ++I, ++TNum) - if (!I->second->isExternal()) + if (!I->second->isDeclaration()) break; // Now check if the graph has changed and if so, clone and inline it. @@ -448,7 +448,7 @@ // same graph as the one inlined above. if (CalleeGraph) for (++I, ++TNum; I != E; ++I, ++TNum) - if (!I->second->isExternal()) + if (!I->second->isDeclaration()) assert(CalleeGraph == &getOrCreateGraph(*I->second) && "Callees at a call site have different graphs?"); #endif Index: llvm-poolalloc/lib/DSA/Local.cpp diff -u llvm-poolalloc/lib/DSA/Local.cpp:1.167 llvm-poolalloc/lib/DSA/Local.cpp:1.168 --- llvm-poolalloc/lib/DSA/Local.cpp:1.167 Mon Jan 22 10:40:38 2007 +++ llvm-poolalloc/lib/DSA/Local.cpp Fri Feb 23 16:49:32 2007 @@ -246,7 +246,7 @@ for (DSScalarMap::global_iterator I = ScalarMap.global_begin(); I != ScalarMap.global_end(); ++I) if (GlobalVariable *GV = dyn_cast(*I)) - if (!GV->isExternal() && GV->isConstant()) + if (!GV->isDeclaration() && GV->isConstant()) RC.merge(ScalarMap[GV], GG->ScalarMap[GV]); } @@ -495,7 +495,7 @@ #else int FieldNo = CUI->getSExtValue(); #endif - Offset += (unsigned)TD.getStructLayout(STy)->MemberOffsets[FieldNo]; + Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo); } else if (isa(*I)) { if (!isa(I.getOperand()) || !cast(I.getOperand())->isNullValue()) @@ -1430,7 +1430,7 @@ return; } #endif - if (F->isExternal()) + if (F->isDeclaration()) if (F->isIntrinsic() && visitIntrinsic(CS, F)) return; else { @@ -1581,10 +1581,10 @@ for (unsigned i = 0, e = CS->getNumOperands(); i != e; ++i) { DSNode *NHN = NH.getNode(); //Some programmers think ending a structure with a [0 x sbyte] is cute - if (SL->MemberOffsets[i] < SL->StructSize) { - DSNodeHandle NewNH(NHN, NH.getOffset()+(unsigned)SL->MemberOffsets[i]); + if (SL->getElementOffset(i) < SL->getSizeInBytes()) { + DSNodeHandle NewNH(NHN, NH.getOffset()+(unsigned)SL->getElementOffset(i)); MergeConstantInitIntoNode(NewNH, cast(CS->getOperand(i))); - } else if (SL->MemberOffsets[i] == SL->StructSize) { + } else if (SL->getElementOffset(i) == SL->getSizeInBytes()) { DOUT << "Zero size element at end of struct\n"; NHN->foldNodeCompletely(); } else { @@ -1599,7 +1599,7 @@ } void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) { - assert(!GV->isExternal() && "Cannot merge in external global!"); + assert(!GV->isDeclaration() && "Cannot merge in external global!"); // Get a node handle to the global node and merge the initializer into it. DSNodeHandle NH = getValueDest(*GV); MergeConstantInitIntoNode(NH, GV->getInitializer()); @@ -1699,7 +1699,7 @@ // Add initializers for all of the globals to the globals graph. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) - if (!I->isExternal()) + if (!I->isDeclaration()) GGB.mergeInGlobalInitializer(I); } @@ -1712,7 +1712,7 @@ // Calculate all of the graphs... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal()) + if (!I->isDeclaration()) DSInfo.insert(std::make_pair(I, new DSGraph(GlobalECs, TD, *I, GlobalsGraph))); GlobalsGraph->removeTriviallyDeadNodes(); Index: llvm-poolalloc/lib/DSA/Steensgaard.cpp diff -u llvm-poolalloc/lib/DSA/Steensgaard.cpp:1.68 llvm-poolalloc/lib/DSA/Steensgaard.cpp:1.69 --- llvm-poolalloc/lib/DSA/Steensgaard.cpp:1.68 Wed Dec 13 23:51:06 2006 +++ llvm-poolalloc/lib/DSA/Steensgaard.cpp Fri Feb 23 16:49:32 2007 @@ -127,7 +127,7 @@ // into this graph. // for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal()) + if (!I->isDeclaration()) ResultGraph->spliceFrom(LDS.getDSGraph(*I)); ResultGraph->removeTriviallyDeadNodes(); @@ -157,7 +157,7 @@ for (unsigned c = 0; c != CallTargets.size(); ) { // If we can eliminate this function call, do so! Function *F = CallTargets[c]; - if (!F->isExternal()) { + if (!F->isDeclaration()) { ResolveFunctionCall(F, CurCall, ResultGraph->getReturnNodes()[F]); CallTargets[c] = CallTargets.back(); CallTargets.pop_back(); @@ -257,7 +257,7 @@ // points to a complete node, the external function cannot modify or read // the value (we know it's not passed out of the program!). if (Function *F = CS.getCalledFunction()) - if (F->isExternal()) + if (F->isDeclaration()) return NoModRef; // Otherwise, if the node is complete, but it is only M or R, return this. Index: llvm-poolalloc/lib/DSA/TopDownClosure.cpp diff -u llvm-poolalloc/lib/DSA/TopDownClosure.cpp:1.97 llvm-poolalloc/lib/DSA/TopDownClosure.cpp:1.98 --- llvm-poolalloc/lib/DSA/TopDownClosure.cpp:1.97 Wed Jan 10 12:10:32 2007 +++ llvm-poolalloc/lib/DSA/TopDownClosure.cpp Fri Feb 23 16:49:32 2007 @@ -89,7 +89,7 @@ // Functions without internal linkage also have unknown incoming arguments! for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal() && !I->hasInternalLinkage()) + if (!I->isDeclaration() && !I->hasInternalLinkage()) ArgsRemainIncomplete.insert(I); // We want to traverse the call graph in reverse post-order. To do this, we @@ -102,7 +102,7 @@ // Visit each of the graphs in reverse post-order now! for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isExternal()) + if (!I->isDeclaration()) getOrCreateDSGraph(*I); return false; } @@ -112,7 +112,7 @@ {TIME_REGION(XXX, "td:Compute postorder"); // Calculate top-down from main... - if (Function *F = M.getMainFunction()) + if (Function *F = M.getFunction("main")) ComputePostOrder(*F, VisitedGraph, PostOrder); // Next calculate the graphs for each unreachable function... @@ -167,7 +167,7 @@ void TDDataStructures::ComputePostOrder(Function &F,hash_set &Visited, std::vector &PostOrder) { - if (F.isExternal()) return; + if (F.isDeclaration()) return; DSGraph &G = getOrCreateDSGraph(F); if (Visited.count(&G)) return; Visited.insert(&G); @@ -312,7 +312,7 @@ // Handle direct calls efficiently. if (CI->isDirectCall()) { - if (!CI->getCalleeFunc()->isExternal() && + if (!CI->getCalleeFunc()->isDeclaration() && !DSG.getReturnNodes().count(CI->getCalleeFunc())) CallerEdges[&getDSGraph(*CI->getCalleeFunc())] .push_back(CallerCallEdge(&DSG, &*CI, CI->getCalleeFunc())); @@ -341,7 +341,7 @@ // If there is exactly one callee from this call site, remember the edge in // CallerEdges. if (IPI == IPE) { - if (!FirstCallee->isExternal()) + if (!FirstCallee->isDeclaration()) CallerEdges[&getDSGraph(*FirstCallee)] .push_back(CallerCallEdge(&DSG, &*CI, FirstCallee)); continue; @@ -356,7 +356,7 @@ for (BUDataStructures::ActualCalleesTy::const_iterator I = BUInfo->callee_begin(CallI), E = BUInfo->callee_end(CallI); I != E; ++I) - if (!I->second->isExternal()) + if (!I->second->isDeclaration()) Callees.push_back(I->second); std::sort(Callees.begin(), Callees.end()); From isanbard at gmail.com Fri Feb 23 17:19:49 2007 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 23 Feb 2007 17:19:49 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll Message-ID: <200702232319.l1NNJnP3017736@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/CBackend: 2007-02-23-NameConflicts.ll added (r1.1) --- Log message: Testcase for PR1164: http://llvm.org/PR1164 --- Diffs of the changes: (+13 -0) 2007-02-23-NameConflicts.ll | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll diff -c /dev/null llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll:1.1 *** /dev/null Fri Feb 23 17:19:42 2007 --- llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll Fri Feb 23 17:19:32 2007 *************** *** 0 **** --- 1,13 ---- + ; RUN: llvm-as < %s | llc -march=c | grep 'llvm_cbe_A = *llvm_cbe_G;' && + ; RUN: llvm-as < %s | llc -march=c | grep 'llvm_cbe_B = *(<mp_0_1);' && + ; RUN: llvm-as < %s | llc -march=c | grep 'return (llvm_cbe_A + llvm_cbe_B);' + ; PR1164 + @G = global i32 123 + @ltmp_0_1 = global i32 123 + + define i32 @test(i32 *%G) { + %A = load i32* %G + %B = load i32* @ltmp_0_1 + %C = add i32 %A, %B + ret i32 %C + } From isanbard at gmail.com Fri Feb 23 17:23:57 2007 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 23 Feb 2007 17:23:57 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll Message-ID: <200702232323.l1NNNvXR017811@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/CBackend: 2007-02-23-NameConflicts.ll updated: 1.1 -> 1.2 --- Log message: Make the testcase correct. --- Diffs of the changes: (+2 -2) 2007-02-23-NameConflicts.ll | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll diff -u llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll:1.1 llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll:1.2 --- llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll:1.1 Fri Feb 23 17:19:32 2007 +++ llvm/test/CodeGen/CBackend/2007-02-23-NameConflicts.ll Fri Feb 23 17:23:41 2007 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | llc -march=c | grep 'llvm_cbe_A = *llvm_cbe_G;' && -; RUN: llvm-as < %s | llc -march=c | grep 'llvm_cbe_B = *(<mp_0_1);' && +; RUN: llvm-as < %s | llc -march=c | grep 'llvm_cbe_A = \*llvm_cbe_G;' && +; RUN: llvm-as < %s | llc -march=c | grep 'llvm_cbe_B = \*(<mp_0_1);' && ; RUN: llvm-as < %s | llc -march=c | grep 'return (llvm_cbe_A + llvm_cbe_B);' ; PR1164 @G = global i32 123 From sabre at nondot.org Fri Feb 23 18:56:10 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 18:56:10 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/InstrTypes.h Instruction.h Instructions.h Message-ID: <200702240056.l1O0uAN1019312@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: InstrTypes.h updated: 1.62 -> 1.63 Instruction.h updated: 1.81 -> 1.82 Instructions.h updated: 1.61 -> 1.62 --- Log message: Refactor the setName stuff, moving it down the inheritance hierarchy, to solve a crash in -instcombine -debug that was hit while investigating PR1217: http://llvm.org/PR1217 --- Diffs of the changes: (+42 -116) InstrTypes.h | 46 +++++++------------------ Instruction.h | 8 +--- Instructions.h | 104 ++++++++++++++------------------------------------------- 3 files changed, 42 insertions(+), 116 deletions(-) Index: llvm/include/llvm/InstrTypes.h diff -u llvm/include/llvm/InstrTypes.h:1.62 llvm/include/llvm/InstrTypes.h:1.63 --- llvm/include/llvm/InstrTypes.h:1.62 Tue Feb 13 03:26:04 2007 +++ llvm/include/llvm/InstrTypes.h Fri Feb 23 18:55:48 2007 @@ -29,19 +29,14 @@ /// class TerminatorInst : public Instruction { protected: - TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps, - Instruction *InsertBefore = 0); TerminatorInst(const Type *Ty, Instruction::TermOps iType, - Use *Ops, unsigned NumOps, - const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(Ty, iType, Ops, NumOps, Name, InsertBefore) {} + Use *Ops, unsigned NumOps, + Instruction *InsertBefore = 0) + : Instruction(Ty, iType, Ops, NumOps, InsertBefore) {} - TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps, - BasicBlock *InsertAtEnd); TerminatorInst(const Type *Ty, Instruction::TermOps iType, - Use *Ops, unsigned NumOps, - const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, Ops, NumOps, Name, InsertAtEnd) {} + Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd) + : Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {} // Out of line virtual method, so the vtable, etc has a home. ~TerminatorInst(); @@ -90,13 +85,11 @@ class UnaryInstruction : public Instruction { Use Op; protected: - UnaryInstruction(const Type *Ty, unsigned iType, Value *V, - const char *Name = 0, Instruction *IB = 0) - : Instruction(Ty, iType, &Op, 1, Name, IB), Op(V, this) { - } - UnaryInstruction(const Type *Ty, unsigned iType, Value *V, - const char *Name, BasicBlock *IAE) - : Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) { + UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0) + : Instruction(Ty, iType, &Op, 1, IB), Op(V, this) { + } + UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE) + : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this) { } public: // Out of line virtual method, so the vtable, etc has a home. @@ -123,20 +116,9 @@ protected: void init(BinaryOps iType); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, - const std::string &Name, Instruction *InsertBefore) - : Instruction(Ty, iType, Ops, 2, Name, InsertBefore) { - Ops[0].init(S1, this); - Ops[1].init(S2, this); - init(iType); - } + const std::string &Name, Instruction *InsertBefore); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, - const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, Ops, 2, Name, InsertAtEnd) { - Ops[0].init(S1, this); - Ops[1].init(S2, this); - init(iType); - } - + const std::string &Name, BasicBlock *InsertAtEnd); public: /// Transparently provide more efficient getOperand methods. @@ -264,13 +246,13 @@ /// @brief Constructor with insert-before-instruction semantics for subclasses CastInst(const Type *Ty, unsigned iType, Value *S, const std::string &Name = "", Instruction *InsertBefore = 0) - : UnaryInstruction(Ty, iType, S, 0, InsertBefore) { + : UnaryInstruction(Ty, iType, S, InsertBefore) { setName(Name); } /// @brief Constructor with insert-at-end-of-block semantics for subclasses CastInst(const Type *Ty, unsigned iType, Value *S, const std::string &Name, BasicBlock *InsertAtEnd) - : UnaryInstruction(Ty, iType, S, 0, InsertAtEnd) { + : UnaryInstruction(Ty, iType, S, InsertAtEnd) { setName(Name); } public: Index: llvm/include/llvm/Instruction.h diff -u llvm/include/llvm/Instruction.h:1.81 llvm/include/llvm/Instruction.h:1.82 --- llvm/include/llvm/Instruction.h:1.81 Thu Feb 15 17:15:00 2007 +++ llvm/include/llvm/Instruction.h Fri Feb 23 18:55:48 2007 @@ -41,13 +41,9 @@ void setParent(BasicBlock *P); protected: Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, - const std::string &Name, Instruction *InsertBefore = 0); + Instruction *InsertBefore = 0); Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, - const std::string &Name, BasicBlock *InsertAtEnd); - Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, - const char *Name = 0, Instruction *InsertBefore = 0); - Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, - const char *Name, BasicBlock *InsertAtEnd); + BasicBlock *InsertAtEnd); public: // Out of line virtual method, so the vtable, etc has a home. ~Instruction(); Index: llvm/include/llvm/Instructions.h diff -u llvm/include/llvm/Instructions.h:1.61 llvm/include/llvm/Instructions.h:1.62 --- llvm/include/llvm/Instructions.h:1.61 Thu Feb 15 17:15:00 2007 +++ llvm/include/llvm/Instructions.h Fri Feb 23 18:55:48 2007 @@ -773,15 +773,15 @@ public: SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(S1->getType(), Instruction::Select, Ops, 3, - Name, InsertBefore) { + : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) { init(C, S1, S2); + setName(Name); } SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(S1->getType(), Instruction::Select, Ops, 3, - Name, InsertAtEnd) { + : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) { init(C, S1, S2); + setName(Name); } Value *getCondition() const { return Ops[0]; } @@ -828,12 +828,12 @@ public: VAArgInst(Value *List, const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) - : UnaryInstruction(Ty, VAArg, List, 0, InsertBefore) { + : UnaryInstruction(Ty, VAArg, List, InsertBefore) { setName(Name); } VAArgInst(Value *List, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : UnaryInstruction(Ty, VAArg, List, 0, InsertAtEnd) { + : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) { setName(Name); } @@ -1022,13 +1022,15 @@ public: explicit PHINode(const Type *Ty, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertBefore), + : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore), ReservedSpace(0) { + setName(Name); } PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertAtEnd), + : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd), ReservedSpace(0) { + setName(Name); } ~PHINode(); @@ -1143,13 +1145,8 @@ /// does not continue in this function any longer. /// class ReturnInst : public TerminatorInst { - Use RetVal; // Possibly null retval. - ReturnInst(const ReturnInst &RI) : TerminatorInst(Instruction::Ret, &RetVal, - RI.getNumOperands()) { - if (RI.getNumOperands()) - RetVal.init(RI.RetVal, this); - } - + Use RetVal; // Return Value: null if 'void'. + ReturnInst(const ReturnInst &RI); void init(Value *RetVal); public: @@ -1164,17 +1161,9 @@ // // NOTE: If the Value* passed is of type void then the constructor behaves as // if it was passed NULL. - explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertBefore) { - init(retVal); - } - ReturnInst(Value *retVal, BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) { - init(retVal); - } - explicit ReturnInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) { - } + explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0); + ReturnInst(Value *retVal, BasicBlock *InsertAtEnd); + explicit ReturnInst(BasicBlock *InsertAtEnd); virtual ReturnInst *clone() const; @@ -1228,39 +1217,12 @@ // BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I // BranchInst(BB* B, BB *I) - 'br B' insert at end // BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end - explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Br, Ops, 1, InsertBefore) { - assert(IfTrue != 0 && "Branch destination may not be null!"); - Ops[0].init(reinterpret_cast(IfTrue), this); - } + explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0); BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, - Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Br, Ops, 3, InsertBefore) { - Ops[0].init(reinterpret_cast(IfTrue), this); - Ops[1].init(reinterpret_cast(IfFalse), this); - Ops[2].init(Cond, this); -#ifndef NDEBUG - AssertOK(); -#endif - } - - BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Br, Ops, 1, InsertAtEnd) { - assert(IfTrue != 0 && "Branch destination may not be null!"); - Ops[0].init(reinterpret_cast(IfTrue), this); - } - + Instruction *InsertBefore = 0); + BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd); BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, - BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Br, Ops, 3, InsertAtEnd) { - Ops[0].init(reinterpret_cast(IfTrue), this); - Ops[1].init(reinterpret_cast(IfFalse), this); - Ops[2].init(Cond, this); -#ifndef NDEBUG - AssertOK(); -#endif - } - + BasicBlock *InsertAtEnd); /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { @@ -1348,20 +1310,14 @@ /// be specified here to make memory allocation more efficient. This /// constructor can also autoinsert before another instruction. SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, - Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Switch, 0, 0, InsertBefore) { - init(Value, Default, NumCases); - } - + Instruction *InsertBefore = 0); + /// SwitchInst ctor - Create a new switch instruction, specifying a value to /// switch on and a default destination. The number of additional cases can /// be specified here to make memory allocation more efficient. This /// constructor also autoinserts at the end of the specified BasicBlock. SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, - BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Switch, 0, 0, InsertAtEnd) { - init(Value, Default, NumCases); - } + BasicBlock *InsertAtEnd); ~SwitchInst(); @@ -1554,12 +1510,8 @@ /// class UnwindInst : public TerminatorInst { public: - explicit UnwindInst(Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Unwind, 0, 0, InsertBefore) { - } - explicit UnwindInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Unwind, 0, 0, InsertAtEnd) { - } + explicit UnwindInst(Instruction *InsertBefore = 0); + explicit UnwindInst(BasicBlock *InsertAtEnd); virtual UnwindInst *clone() const; @@ -1590,12 +1542,8 @@ /// class UnreachableInst : public TerminatorInst { public: - explicit UnreachableInst(Instruction *InsertBefore = 0) - : TerminatorInst(Instruction::Unreachable, 0, 0, InsertBefore) { - } - explicit UnreachableInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Instruction::Unreachable, 0, 0, InsertAtEnd) { - } + explicit UnreachableInst(Instruction *InsertBefore = 0); + explicit UnreachableInst(BasicBlock *InsertAtEnd); virtual UnreachableInst *clone() const; From sabre at nondot.org Fri Feb 23 18:56:10 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 18:56:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp Message-ID: <200702240056.l1O0uAPA019305@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.69 -> 1.70 Instructions.cpp updated: 1.77 -> 1.78 --- Log message: Refactor the setName stuff, moving it down the inheritance hierarchy, to solve a crash in -instcombine -debug that was hit while investigating PR1217: http://llvm.org/PR1217 --- Diffs of the changes: (+199 -98) Instruction.cpp | 33 ------ Instructions.cpp | 264 +++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 199 insertions(+), 98 deletions(-) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.69 llvm/lib/VMCore/Instruction.cpp:1.70 --- llvm/lib/VMCore/Instruction.cpp:1.69 Mon Feb 19 13:46:17 2007 +++ llvm/lib/VMCore/Instruction.cpp Fri Feb 23 18:55:48 2007 @@ -19,7 +19,7 @@ using namespace llvm; Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const std::string &Name, Instruction *InsertBefore) + Instruction *InsertBefore) : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -30,11 +30,10 @@ "Instruction to insert before is not in a basic block!"); InsertBefore->getParent()->getInstList().insert(InsertBefore, this); } - setName(Name); } Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const std::string &Name, BasicBlock *InsertAtEnd) + BasicBlock *InsertAtEnd) : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -42,34 +41,6 @@ // append this instruction into the basic block assert(InsertAtEnd && "Basic block to append to may not be NULL!"); InsertAtEnd->getInstList().push_back(this); - setName(Name); -} - -Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const char *Name, Instruction *InsertBefore) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { - // Make sure that we get added to a basicblock - LeakDetector::addGarbageObject(this); - - // If requested, insert this instruction into a basic block... - if (InsertBefore) { - assert(InsertBefore->getParent() && - "Instruction to insert before is not in a basic block!"); - InsertBefore->getParent()->getInstList().insert(InsertBefore, this); - } - if (Name && *Name) setName(Name); -} - -Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const char *Name, BasicBlock *InsertAtEnd) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { - // Make sure that we get added to a basicblock - LeakDetector::addGarbageObject(this); - - // append this instruction into the basic block - assert(InsertAtEnd && "Basic block to append to may not be NULL!"); - InsertAtEnd->getInstList().push_back(this); - if (Name && *Name) setName(Name); } Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.77 llvm/lib/VMCore/Instructions.cpp:1.78 --- llvm/lib/VMCore/Instructions.cpp:1.77 Wed Feb 14 21:39:18 2007 +++ llvm/lib/VMCore/Instructions.cpp Fri Feb 23 18:55:48 2007 @@ -40,16 +40,6 @@ // TerminatorInst Class //===----------------------------------------------------------------------===// -TerminatorInst::TerminatorInst(Instruction::TermOps iType, - Use *Ops, unsigned NumOps, Instruction *IB) - : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IB) { -} - -TerminatorInst::TerminatorInst(Instruction::TermOps iType, - Use *Ops, unsigned NumOps, BasicBlock *IAE) - : Instruction(Type::VoidTy, iType, Ops, NumOps, "", IAE) { -} - // Out of line virtual method, so the vtable, etc has a home. TerminatorInst::~TerminatorInst() { } @@ -272,63 +262,71 @@ const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertAtEnd) { + Instruction::Call, 0, 0, InsertAtEnd) { init(Func, Args, NumArgs); + setName(Name); } CallInst::CallInst(Value *Func, Value* const *Args, unsigned NumArgs, const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertBefore) { + Instruction::Call, 0, 0, InsertBefore) { init(Func, Args, NumArgs); + setName(Name); } CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2, const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertBefore) { + Instruction::Call, 0, 0, InsertBefore) { init(Func, Actual1, Actual2); + setName(Name); } CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2, const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertAtEnd) { + Instruction::Call, 0, 0, InsertAtEnd) { init(Func, Actual1, Actual2); + setName(Name); } CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name, - Instruction *InsertBefore) + Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertBefore) { + Instruction::Call, 0, 0, InsertBefore) { init(Func, Actual); + setName(Name); } CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertAtEnd) { + Instruction::Call, 0, 0, InsertAtEnd) { init(Func, Actual); + setName(Name); } CallInst::CallInst(Value *Func, const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertBefore) { + Instruction::Call, 0, 0, InsertBefore) { init(Func); + setName(Name); } CallInst::CallInst(Value *Func, const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, Name, InsertAtEnd) { + Instruction::Call, 0, 0, InsertAtEnd) { init(Func); + setName(Name); } CallInst::CallInst(const CallInst &CI) @@ -380,8 +378,9 @@ const std::string &Name, Instruction *InsertBefore) : TerminatorInst(cast(cast(Fn->getType()) ->getElementType())->getReturnType(), - Instruction::Invoke, 0, 0, Name, InsertBefore) { + Instruction::Invoke, 0, 0, InsertBefore) { init(Fn, IfNormal, IfException, Args, NumArgs); + setName(Name); } InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal, @@ -390,8 +389,9 @@ const std::string &Name, BasicBlock *InsertAtEnd) : TerminatorInst(cast(cast(Fn->getType()) ->getElementType())->getReturnType(), - Instruction::Invoke, 0, 0, Name, InsertAtEnd) { + Instruction::Invoke, 0, 0, InsertAtEnd) { init(Fn, IfNormal, IfException, Args, NumArgs); + setName(Name); } InvokeInst::InvokeInst(const InvokeInst &II) @@ -418,6 +418,27 @@ // ReturnInst Implementation //===----------------------------------------------------------------------===// +ReturnInst::ReturnInst(const ReturnInst &RI) + : TerminatorInst(Type::VoidTy, Instruction::Ret, + &RetVal, RI.getNumOperands()) { + if (RI.getNumOperands()) + RetVal.init(RI.RetVal, this); +} + +ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore) + : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) { + init(retVal); +} +ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) { + init(retVal); +} +ReturnInst::ReturnInst(BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) { +} + + + void ReturnInst::init(Value *retVal) { if (retVal && retVal->getType() != Type::VoidTy) { assert(!isa(retVal) && @@ -448,6 +469,14 @@ // UnwindInst Implementation //===----------------------------------------------------------------------===// +UnwindInst::UnwindInst(Instruction *InsertBefore) + : TerminatorInst(Type::VoidTy, Instruction::Unwind, 0, 0, InsertBefore) { +} +UnwindInst::UnwindInst(BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Unwind, 0, 0, InsertAtEnd) { +} + + unsigned UnwindInst::getNumSuccessorsV() const { return getNumSuccessors(); } @@ -466,6 +495,13 @@ // UnreachableInst Implementation //===----------------------------------------------------------------------===// +UnreachableInst::UnreachableInst(Instruction *InsertBefore) + : TerminatorInst(Type::VoidTy, Instruction::Unreachable, 0, 0, InsertBefore) { +} +UnreachableInst::UnreachableInst(BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Unreachable, 0, 0, InsertAtEnd) { +} + unsigned UnreachableInst::getNumSuccessorsV() const { return getNumSuccessors(); } @@ -490,8 +526,42 @@ "May only branch on boolean predicates!"); } +BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore) + : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertBefore) { + assert(IfTrue != 0 && "Branch destination may not be null!"); + Ops[0].init(reinterpret_cast(IfTrue), this); +} +BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, + Instruction *InsertBefore) +: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertBefore) { + Ops[0].init(reinterpret_cast(IfTrue), this); + Ops[1].init(reinterpret_cast(IfFalse), this); + Ops[2].init(Cond, this); +#ifndef NDEBUG + AssertOK(); +#endif +} + +BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertAtEnd) { + assert(IfTrue != 0 && "Branch destination may not be null!"); + Ops[0].init(reinterpret_cast(IfTrue), this); +} + +BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, + BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertAtEnd) { + Ops[0].init(reinterpret_cast(IfTrue), this); + Ops[1].init(reinterpret_cast(IfFalse), this); + Ops[2].init(Cond, this); +#ifndef NDEBUG + AssertOK(); +#endif +} + + BranchInst::BranchInst(const BranchInst &BI) : - TerminatorInst(Instruction::Br, Ops, BI.getNumOperands()) { + TerminatorInst(Type::VoidTy, Instruction::Br, Ops, BI.getNumOperands()) { OperandList[0].init(BI.getOperand(0), this); if (BI.getNumOperands() != 1) { assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!"); @@ -531,7 +601,7 @@ unsigned Align, const std::string &Name, Instruction *InsertBefore) : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), - 0, InsertBefore), Alignment(Align) { + InsertBefore), Alignment(Align) { assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); assert(Ty != Type::VoidTy && "Cannot allocate void!"); setName(Name); @@ -541,7 +611,7 @@ unsigned Align, const std::string &Name, BasicBlock *InsertAtEnd) : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), - 0, InsertAtEnd), Alignment(Align) { + InsertAtEnd), Alignment(Align) { assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); assert(Ty != Type::VoidTy && "Cannot allocate void!"); setName(Name); @@ -581,12 +651,12 @@ } FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore) - : UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertBefore) { + : UnaryInstruction(Type::VoidTy, Free, Ptr, InsertBefore) { AssertOK(); } FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd) - : UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertAtEnd) { + : UnaryInstruction(Type::VoidTy, Free, Ptr, InsertAtEnd) { AssertOK(); } @@ -602,7 +672,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) : UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, 0, InsertBef) { + Load, Ptr, InsertBef) { setVolatile(false); AssertOK(); setName(Name); @@ -610,7 +680,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE) : UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, 0, InsertAE) { + Load, Ptr, InsertAE) { setVolatile(false); AssertOK(); setName(Name); @@ -619,7 +689,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, Instruction *InsertBef) : UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, 0, InsertBef) { + Load, Ptr, InsertBef) { setVolatile(isVolatile); AssertOK(); setName(Name); @@ -628,7 +698,7 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, BasicBlock *InsertAE) : UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, 0, InsertAE) { + Load, Ptr, InsertAE) { setVolatile(isVolatile); AssertOK(); setName(Name); @@ -637,33 +707,37 @@ LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef) -: UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, Name, InsertBef) { + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, InsertBef) { setVolatile(false); AssertOK(); + if (Name && Name[0]) setName(Name); } LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE) -: UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, Name, InsertAE) { + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, InsertAE) { setVolatile(false); AssertOK(); + if (Name && Name[0]) setName(Name); } LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile, Instruction *InsertBef) : UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, Name, InsertBef) { + Load, Ptr, InsertBef) { setVolatile(isVolatile); AssertOK(); + if (Name && Name[0]) setName(Name); } LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile, BasicBlock *InsertAE) -: UnaryInstruction(cast(Ptr->getType())->getElementType(), - Load, Ptr, Name, InsertAE) { + : UnaryInstruction(cast(Ptr->getType())->getElementType(), + Load, Ptr, InsertAE) { setVolatile(isVolatile); AssertOK(); + if (Name && Name[0]) setName(Name); } @@ -681,7 +755,7 @@ StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore) { + : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { Ops[0].init(val, this); Ops[1].init(addr, this); setVolatile(false); @@ -689,7 +763,7 @@ } StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd) { + : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { Ops[0].init(val, this); Ops[1].init(addr, this); setVolatile(false); @@ -698,7 +772,7 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertBefore) { + : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { Ops[0].init(val, this); Ops[1].init(addr, this); setVolatile(isVolatile); @@ -707,7 +781,7 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, "", InsertAtEnd) { + : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { Ops[0].init(val, this); Ops[1].init(addr, this); setVolatile(isVolatile); @@ -756,8 +830,9 @@ const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, NumIdx, true))), - GetElementPtr, 0, 0, Name, InBe) { + GetElementPtr, 0, 0, InBe) { init(Ptr, Idx, NumIdx); + setName(Name); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx, @@ -765,40 +840,43 @@ const std::string &Name, BasicBlock *IAE) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, NumIdx, true))), - GetElementPtr, 0, 0, Name, IAE) { + GetElementPtr, 0, 0, IAE) { init(Ptr, Idx, NumIdx); + setName(Name); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, Instruction *InBe) - : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), - Idx))), - GetElementPtr, 0, 0, Name, InBe) { + : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx))), + GetElementPtr, 0, 0, InBe) { init(Ptr, Idx); + setName(Name); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, BasicBlock *IAE) - : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), - Idx))), - GetElementPtr, 0, 0, Name, IAE) { + : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx))), + GetElementPtr, 0, 0, IAE) { init(Ptr, Idx); + setName(Name); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx0, Idx1, true))), - GetElementPtr, 0, 0, Name, InBe) { + GetElementPtr, 0, 0, InBe) { init(Ptr, Idx0, Idx1); + setName(Name); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, const std::string &Name, BasicBlock *IAE) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx0, Idx1, true))), - GetElementPtr, 0, 0, Name, IAE) { + GetElementPtr, 0, 0, IAE) { init(Ptr, Idx0, Idx1); + setName(Name); } GetElementPtrInst::~GetElementPtrInst() { @@ -885,23 +963,25 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, Name, InsertBef) { + ExtractElement, Ops, 2, InsertBef) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); Ops[0].init(Val, this); Ops[1].init(Index, this); + setName(Name); } ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV, const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, Name, InsertBef) { + ExtractElement, Ops, 2, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); Ops[0].init(Val, this); Ops[1].init(Index, this); + setName(Name); } @@ -909,25 +989,27 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, Name, InsertAE) { + ExtractElement, Ops, 2, InsertAE) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); Ops[0].init(Val, this); Ops[1].init(Index, this); + setName(Name); } ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV, const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, Name, InsertAE) { + ExtractElement, Ops, 2, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); Ops[0].init(Val, this); Ops[1].init(Index, this); + setName(Name); } @@ -951,43 +1033,46 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) { + : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); Ops[0].init(Vec, this); Ops[1].init(Elt, this); Ops[2].init(Index, this); + setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertBef) { + : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); Ops[0].init(Vec, this); Ops[1].init(Elt, this); Ops[2].init(Index, this); + setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, BasicBlock *InsertAE) - : Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) { + : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); Ops[0].init(Vec, this); Ops[1].init(Elt, this); Ops[2].init(Index, this); + setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, BasicBlock *InsertAE) -: Instruction(Vec->getType(), InsertElement, Ops, 3, Name, InsertAE) { +: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); @@ -995,6 +1080,7 @@ Ops[0].init(Vec, this); Ops[1].init(Elt, this); Ops[2].init(Index, this); + setName(Name); } bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt, @@ -1025,24 +1111,26 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name, Instruction *InsertBefore) - : Instruction(V1->getType(), ShuffleVector, Ops, 3, Name, InsertBefore) { + : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertBefore) { assert(isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"); Ops[0].init(V1, this); Ops[1].init(V2, this); Ops[2].init(Mask, this); + setName(Name); } ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(V1->getType(), ShuffleVector, Ops, 3, Name, InsertAtEnd) { + : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertAtEnd) { assert(isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"); Ops[0].init(V1, this); Ops[1].init(V2, this); Ops[2].init(Mask, this); + setName(Name); } bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2, @@ -1062,8 +1150,28 @@ // BinaryOperator Class //===----------------------------------------------------------------------===// -void BinaryOperator::init(BinaryOps iType) -{ +BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, + const Type *Ty, const std::string &Name, + Instruction *InsertBefore) + : Instruction(Ty, iType, Ops, 2, InsertBefore) { + Ops[0].init(S1, this); + Ops[1].init(S2, this); + init(iType); + setName(Name); +} + +BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, + const Type *Ty, const std::string &Name, + BasicBlock *InsertAtEnd) + : Instruction(Ty, iType, Ops, 2, InsertAtEnd) { + Ops[0].init(S1, this); + Ops[1].init(S2, this); + init(iType); + setName(Name); +} + + +void BinaryOperator::init(BinaryOps iType) { Value *LHS = getOperand(0), *RHS = getOperand(1); LHS = LHS; RHS = RHS; // Silence warnings. assert(LHS->getType() == RHS->getType() && @@ -1947,7 +2055,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, Instruction *InsertBefore) - : Instruction(Type::Int1Ty, op, Ops, 2, Name, InsertBefore) { + : Instruction(Type::Int1Ty, op, Ops, 2, InsertBefore) { Ops[0].init(LHS, this); Ops[1].init(RHS, this); SubclassData = predicate; @@ -1974,11 +2082,12 @@ // Check that the operands are the right type assert(Op0Ty->isFloatingPoint() && "Invalid operand types for FCmp instruction"); + setName(Name); } CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Type::Int1Ty, op, Ops, 2, Name, InsertAtEnd) { + : Instruction(Type::Int1Ty, op, Ops, 2, InsertAtEnd) { Ops[0].init(LHS, this); Ops[1].init(RHS, this); SubclassData = predicate; @@ -2006,6 +2115,7 @@ // Check that the operands are the right type assert(Op0Ty->isFloatingPoint() && "Invalid operand types for FCmp instruction"); + setName(Name); } CmpInst * @@ -2197,9 +2307,29 @@ OperandList[1].init(Default, this); } +/// SwitchInst ctor - Create a new switch instruction, specifying a value to +/// switch on and a default destination. The number of additional cases can +/// be specified here to make memory allocation more efficient. This +/// constructor can also autoinsert before another instruction. +SwitchInst::SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, + Instruction *InsertBefore) + : TerminatorInst(Type::VoidTy, Instruction::Switch, 0, 0, InsertBefore) { + init(Value, Default, NumCases); +} + +/// SwitchInst ctor - Create a new switch instruction, specifying a value to +/// switch on and a default destination. The number of additional cases can +/// be specified here to make memory allocation more efficient. This +/// constructor also autoinserts at the end of the specified BasicBlock. +SwitchInst::SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases, + BasicBlock *InsertAtEnd) + : TerminatorInst(Type::VoidTy, Instruction::Switch, 0, 0, InsertAtEnd) { + init(Value, Default, NumCases); +} + SwitchInst::SwitchInst(const SwitchInst &SI) - : TerminatorInst(Instruction::Switch, new Use[SI.getNumOperands()], - SI.getNumOperands()) { + : TerminatorInst(Type::VoidTy, Instruction::Switch, + new Use[SI.getNumOperands()], SI.getNumOperands()) { Use *OL = OperandList, *InOL = SI.OperandList; for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) { OL[i].init(InOL[i], this); From sabre at nondot.org Fri Feb 23 19:03:28 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 19:03:28 -0600 Subject: [llvm-commits] CVS: llvm/test/Transforms/InstCombine/2007-02-23-PhiFoldInfLoop.ll Message-ID: <200702240103.l1O13SA3019508@zion.cs.uiuc.edu> Changes in directory llvm/test/Transforms/InstCombine: 2007-02-23-PhiFoldInfLoop.ll added (r1.1) --- Log message: testcase for pr1217: http://llvm.org/PR1217 --- Diffs of the changes: (+32 -0) 2007-02-23-PhiFoldInfLoop.ll | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+) Index: llvm/test/Transforms/InstCombine/2007-02-23-PhiFoldInfLoop.ll diff -c /dev/null llvm/test/Transforms/InstCombine/2007-02-23-PhiFoldInfLoop.ll:1.1 *** /dev/null Fri Feb 23 19:03:21 2007 --- llvm/test/Transforms/InstCombine/2007-02-23-PhiFoldInfLoop.ll Fri Feb 23 19:03:11 2007 *************** *** 0 **** --- 1,32 ---- + ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep ret + ; PR1217 + + target datalayout = "e-p:32:32" + target triple = "i686-pc-linux-gnu" + %struct.termbox = type { %struct.termbox*, i32, i32, i32, i32, i32 } + + implementation ; Functions: + + define void @ggenorien() { + entry: + %tmp68 = icmp eq %struct.termbox* null, null ; [#uses=1] + br i1 %tmp68, label %cond_next448, label %bb80 + + bb80: ; preds = %entry + ret void + + cond_next448: ; preds = %entry + br i1 false, label %bb756, label %bb595 + + bb595: ; preds = %cond_next448 + br label %bb609 + + bb609: ; preds = %bb756, %bb595 + %termnum.6240.0 = phi i32 [ 2, %bb595 ], [ %termnum.6, %bb756 ] ; [#uses=1] + %tmp755 = add i32 %termnum.6240.0, 1 ; [#uses=1] + br label %bb756 + + bb756: ; preds = %bb609, %cond_next448 + %termnum.6 = phi i32 [ %tmp755, %bb609 ], [ 2, %cond_next448 ] ; [#uses=1] + br label %bb609 + } From sabre at nondot.org Fri Feb 23 19:04:02 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 19:04:02 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200702240104.l1O142LF019545@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.636 -> 1.637 --- Log message: Fix InstCombine/2007-02-23-PhiFoldInfLoop.ll and PR1217: http://llvm.org/PR1217 --- Diffs of the changes: (+2 -1) InstructionCombining.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.636 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.637 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.636 Thu Feb 15 16:52:10 2007 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Feb 23 19:03:45 2007 @@ -1641,11 +1641,12 @@ // Check to see if all of the operands of the PHI are constants. If there is // one non-constant value, remember the BB it is. If there is more than one - // bail out. + // or if *it* is a PHI, bail out. BasicBlock *NonConstBB = 0; for (unsigned i = 0; i != NumPHIValues; ++i) if (!isa(PN->getIncomingValue(i))) { if (NonConstBB) return 0; // More than one non-const value. + if (isa(PN->getIncomingValue(i))) return 0; // Itself a phi. NonConstBB = PN->getIncomingBlock(i); // If the incoming non-constant value is in I's block, we have an infinite From sabre at nondot.org Fri Feb 23 19:16:56 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 19:16:56 -0600 Subject: [llvm-commits] CVS: llvm/test/Transforms/ConstProp/2007-02-23-sdiv.ll Message-ID: <200702240116.l1O1GuoU019847@zion.cs.uiuc.edu> Changes in directory llvm/test/Transforms/ConstProp: 2007-02-23-sdiv.ll added (r1.1) --- Log message: testcase for pr1215: http://llvm.org/PR1215 --- Diffs of the changes: (+5 -0) 2007-02-23-sdiv.ll | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/test/Transforms/ConstProp/2007-02-23-sdiv.ll diff -c /dev/null llvm/test/Transforms/ConstProp/2007-02-23-sdiv.ll:1.1 *** /dev/null Fri Feb 23 19:16:49 2007 --- llvm/test/Transforms/ConstProp/2007-02-23-sdiv.ll Fri Feb 23 19:16:39 2007 *************** *** 0 **** --- 1,5 ---- + ; RUN: llvm-as < %s | llvm-dis | grep 'global i32 0' + ; PR1215 + + @G = global i32 sdiv (i32 0, i32 -1) + From sabre at nondot.org Fri Feb 23 19:20:07 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 19:20:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Message-ID: <200702240120.l1O1K7fG019940@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.137 -> 1.138 --- Log message: Fix Transforms/ConstProp/2007-02-23-sdiv.ll and PR1215: http://llvm.org/PR1215 --- Diffs of the changes: (+2 -1) ConstantFolding.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.137 llvm/lib/VMCore/ConstantFolding.cpp:1.138 --- llvm/lib/VMCore/ConstantFolding.cpp:1.137 Wed Feb 14 21:39:18 2007 +++ llvm/lib/VMCore/ConstantFolding.cpp Fri Feb 23 19:19:50 2007 @@ -574,7 +574,8 @@ if (CI2->isAllOnesValue() && (((CI1->getType()->getPrimitiveSizeInBits() == 64) && (CI1->getSExtValue() == INT64_MIN)) || - (CI1->getSExtValue() == -CI1->getSExtValue()))) + (CI1->getSExtValue() == -CI1->getSExtValue() && + CI1->getSExtValue()))) return 0; // MIN_INT / -1 -> overflow return ConstantInt::get(C1->getType(), CI1->getSExtValue() / CI2->getSExtValue()); From sabre at nondot.org Fri Feb 23 19:42:05 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 19:42:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/FoldingSet.cpp Message-ID: <200702240142.l1O1g5Iu020839@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: FoldingSet.cpp updated: 1.16 -> 1.17 --- Log message: remove folding set debug output --- Diffs of the changes: (+0 -4) FoldingSet.cpp | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/lib/Support/FoldingSet.cpp diff -u llvm/lib/Support/FoldingSet.cpp:1.16 llvm/lib/Support/FoldingSet.cpp:1.17 --- llvm/lib/Support/FoldingSet.cpp:1.16 Sat Feb 3 19:48:10 2007 +++ llvm/lib/Support/FoldingSet.cpp Fri Feb 23 19:41:48 2007 @@ -14,10 +14,8 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "foldingset" #include "llvm/ADT/FoldingSet.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/Debug.h" #include using namespace llvm; @@ -231,7 +229,6 @@ void FoldingSetImpl::InsertNode(Node *N, void *InsertPos) { assert(N->getNextInBucket() == 0); // Do we need to grow the hashtable? - DEBUG(DOUT << "INSERT: " << N << '\n'); if (NumNodes+1 > NumBuckets*2) { GrowHashTable(); NodeID ID; @@ -261,7 +258,6 @@ bool FoldingSetImpl::RemoveNode(Node *N) { // Because each bucket is a circular list, we don't need to compute N's hash // to remove it. - DEBUG(DOUT << "REMOVE: " << N << '\n'); void *Ptr = N->getNextInBucket(); if (Ptr == 0) return false; // Not in folding set. From sabre at nondot.org Fri Feb 23 20:08:16 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 20:08:16 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/Generic/2007-02-23-DAGCombine-Miscompile.ll Message-ID: <200702240208.l1O28GhK021595@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/Generic: 2007-02-23-DAGCombine-Miscompile.ll added (r1.1) --- Log message: testcase for PR1219: http://llvm.org/PR1219 --- Diffs of the changes: (+13 -0) 2007-02-23-DAGCombine-Miscompile.ll | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/test/CodeGen/Generic/2007-02-23-DAGCombine-Miscompile.ll diff -c /dev/null llvm/test/CodeGen/Generic/2007-02-23-DAGCombine-Miscompile.ll:1.1 *** /dev/null Fri Feb 23 20:08:10 2007 --- llvm/test/CodeGen/Generic/2007-02-23-DAGCombine-Miscompile.ll Fri Feb 23 20:08:00 2007 *************** *** 0 **** --- 1,13 ---- + ; RUN: llvm-as < %s | llc -march=x86 | grep 'movl $1, %eax' + ; PR1219 + + define i32 @test(i1 %X) { + old_entry1: + %hvar2 = zext i1 %X to i32 + %C = icmp sgt i32 %hvar2, -1 + br i1 %C, label %cond_true15, label %cond_true + cond_true15: + ret i32 1 + cond_true: + ret i32 2 + } From sabre at nondot.org Fri Feb 23 20:09:45 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 20:09:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200702240209.l1O29jIx021683@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: TargetLowering.cpp updated: 1.93 -> 1.94 --- Log message: Fix CodeGen/Generic/2007-02-23-DAGCombine-Miscompile.ll and PR1219: http://llvm.org/PR1219 --- Diffs of the changes: (+2 -2) TargetLowering.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp diff -u llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.93 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.94 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.93 Thu Feb 22 12:04:49 2007 +++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Fri Feb 23 20:09:29 2007 @@ -1459,11 +1459,11 @@ case ISD::SETGT: case ISD::SETGE: // True if the sign bit of C1 is set. - return DAG.getConstant((C1 & (1ULL << VSize)) != 0, VT); + return DAG.getConstant((C1 & (1ULL << (VSize-1))) != 0, VT); case ISD::SETLT: case ISD::SETLE: // True if the sign bit of C1 isn't set. - return DAG.getConstant((C1 & (1ULL << VSize)) == 0, VT); + return DAG.getConstant((C1 & (1ULL << (VSize-1))) == 0, VT); default: break; } From sabre at nondot.org Fri Feb 23 20:57:19 2007 From: sabre at nondot.org (Chris Lattner) Date: Fri, 23 Feb 2007 20:57:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.h JITEmitter.cpp Message-ID: <200702240257.l1O2vJPh022826@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: JIT.h updated: 1.29 -> 1.30 JITEmitter.cpp updated: 1.129 -> 1.130 --- Log message: Fix PR1216: http://llvm.org/PR1216 by cleaning up the ownership of JITResolver. --- Diffs of the changes: (+42 -29) JIT.h | 2 + JITEmitter.cpp | 69 +++++++++++++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 29 deletions(-) Index: llvm/lib/ExecutionEngine/JIT/JIT.h diff -u llvm/lib/ExecutionEngine/JIT/JIT.h:1.29 llvm/lib/ExecutionEngine/JIT/JIT.h:1.30 --- llvm/lib/ExecutionEngine/JIT/JIT.h:1.29 Wed Mar 22 23:22:51 2006 +++ llvm/lib/ExecutionEngine/JIT/JIT.h Fri Feb 23 20:57:03 2007 @@ -118,6 +118,8 @@ /// void freeMachineCodeForFunction(Function *F); + /// getCodeEmitter - Return the code emitter this JIT is emitting into. + MachineCodeEmitter *getCodeEmitter() const { return MCE; } private: static MachineCodeEmitter *createEmitter(JIT &J); void runJITOnFunction (Function *F); Index: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp diff -u llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.129 llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.130 --- llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.129 Tue Jan 30 14:08:37 2007 +++ llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp Fri Feb 23 20:57:03 2007 @@ -457,9 +457,6 @@ /// JITResolver - Keep track of, and resolve, call sites for functions that /// have not yet been compiled. class JITResolver { - /// MCE - The MachineCodeEmitter to use to emit stubs with. - MachineCodeEmitter &MCE; - /// LazyResolverFn - The target lazy resolver function that we actually /// rewrite instructions to use. TargetJITInfo::LazyResolverFn LazyResolverFn; @@ -474,10 +471,18 @@ std::map revGOTMap; unsigned nextGOTIndex; + static JITResolver *TheJITResolver; public: - JITResolver(MachineCodeEmitter &mce) : MCE(mce), nextGOTIndex(0) { - LazyResolverFn = - TheJIT->getJITInfo().getLazyResolverFunction(JITCompilerFn); + JITResolver(JIT &jit) : nextGOTIndex(0) { + TheJIT = &jit; + + LazyResolverFn = jit.getJITInfo().getLazyResolverFunction(JITCompilerFn); + assert(TheJITResolver == 0 && "Multiple JIT resolvers?"); + TheJITResolver = this; + } + + ~JITResolver() { + TheJITResolver = 0; } /// getFunctionStub - This returns a pointer to a function stub, creating @@ -510,12 +515,7 @@ }; } -/// getJITResolver - This function returns the one instance of the JIT resolver. -/// -static JITResolver &getJITResolver(MachineCodeEmitter *MCE = 0) { - static JITResolver TheJITResolver(*MCE); - return TheJITResolver; -} +JITResolver *JITResolver::TheJITResolver = 0; #if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \ defined(__APPLE__) @@ -548,7 +548,8 @@ // Otherwise, codegen a new stub. For now, the stub will call the lazy // resolver function. - Stub = TheJIT->getJITInfo().emitFunctionStub(Actual, MCE); + Stub = TheJIT->getJITInfo().emitFunctionStub(Actual, + *TheJIT->getCodeEmitter()); if (Actual != (void*)(intptr_t)LazyResolverFn) { // If we are getting the stub for an external function, we really want the @@ -558,7 +559,8 @@ } // Invalidate the icache if necessary. - synchronizeICache(Stub, MCE.getCurrentPCValue()-(intptr_t)Stub); + synchronizeICache(Stub, TheJIT->getCodeEmitter()->getCurrentPCValue() - + (intptr_t)Stub); DOUT << "JIT: Stub emitted at [" << Stub << "] for function '" << F->getName() << "'\n"; @@ -576,10 +578,12 @@ void *&Stub = ExternalFnToStubMap[FnAddr]; if (Stub) return Stub; - Stub = TheJIT->getJITInfo().emitFunctionStub(FnAddr, MCE); + Stub = TheJIT->getJITInfo().emitFunctionStub(FnAddr, + *TheJIT->getCodeEmitter()); // Invalidate the icache if necessary. - synchronizeICache(Stub, MCE.getCurrentPCValue()-(intptr_t)Stub); + synchronizeICache(Stub, TheJIT->getCodeEmitter()->getCurrentPCValue() - + (intptr_t)Stub); DOUT << "JIT: Stub emitted at [" << Stub << "] for external function at '" << FnAddr << "'\n"; @@ -602,7 +606,7 @@ /// been entered. It looks up which function this stub corresponds to, compiles /// it if necessary, then returns the resultant function pointer. void *JITResolver::JITCompilerFn(void *Stub) { - JITResolver &JR = getJITResolver(); + JITResolver &JR = *TheJITResolver; MutexGuard locked(TheJIT->lock); @@ -688,11 +692,16 @@ /// JumpTableBase - A pointer to the first entry in the jump table. /// void *JumpTableBase; -public: - JITEmitter(JIT &jit) : MemMgr(jit.getJITInfo().needsGOT()) { - TheJIT = &jit; + + /// Resolver - This contains info about the currently resolved functions. + JITResolver Resolver; + public: + JITEmitter(JIT &jit) + : MemMgr(jit.getJITInfo().needsGOT()), Resolver(jit) { if (MemMgr.isManagingGOT()) DOUT << "JIT is managing a GOT\n"; } + + JITResolver &getJITResolver() { return Resolver; } virtual void startFunction(MachineFunction &F); virtual bool finishFunction(MachineFunction &F); @@ -752,17 +761,17 @@ if (DoesntNeedStub) return TheJIT->getPointerToFunction(F); - return getJITResolver(this).getFunctionStub(F); + return Resolver.getFunctionStub(F); } // Okay, the function has not been compiled yet, if the target callback // mechanism is capable of rewriting the instruction directly, prefer to do // that instead of emitting a stub. if (DoesntNeedStub) - return getJITResolver(this).AddCallbackAtLocation(F, Reference); + return Resolver.AddCallbackAtLocation(F, Reference); // Otherwise, we have to emit a lazy resolving stub. - return getJITResolver(this).getFunctionStub(F); + return Resolver.getFunctionStub(F); } void JITEmitter::startFunction(MachineFunction &F) { @@ -813,7 +822,7 @@ // If the target REALLY wants a stub for this function, emit it now. if (!MR.doesntNeedFunctionStub()) - ResultPtr = getJITResolver(this).getExternalFunctionStub(ResultPtr); + ResultPtr = Resolver.getExternalFunctionStub(ResultPtr); } else if (MR.isGlobalValue()) { ResultPtr = getPointerToGlobal(MR.getGlobalValue(), BufferBegin+MR.getMachineCodeOffset(), @@ -832,7 +841,7 @@ // if we are managing the GOT and the relocation wants an index, // give it one if (MemMgr.isManagingGOT() && MR.isGOTRelative()) { - unsigned idx = getJITResolver(this).getGOTIndexForAddr(ResultPtr); + unsigned idx = Resolver.getGOTIndexForAddr(ResultPtr); MR.setGOTIndex(idx); if (((void**)MemMgr.getGOTBase())[idx] != ResultPtr) { DOUT << "GOT was out of date for " << ResultPtr @@ -849,7 +858,7 @@ // Update the GOT entry for F to point to the new code. if (MemMgr.isManagingGOT()) { - unsigned idx = getJITResolver(this).getGOTIndexForAddr((void*)BufferBegin); + unsigned idx = Resolver.getGOTIndexForAddr((void*)BufferBegin); if (((void**)MemMgr.getGOTBase())[idx] != (void*)BufferBegin) { DOUT << "GOT was out of date for " << (void*)BufferBegin << " pointing at " << ((void**)MemMgr.getGOTBase())[idx] << "\n"; @@ -1030,8 +1039,10 @@ if (void *Addr = getPointerToGlobalIfAvailable(F)) return Addr; - // Get a stub if the target supports it - return getJITResolver(MCE).getFunctionStub(F); + // Get a stub if the target supports it. + assert(dynamic_cast(MCE) && "Unexpected MCE?"); + JITEmitter *JE = static_cast(getCodeEmitter()); + return JE->getJITResolver().getFunctionStub(F); } /// freeMachineCodeForFunction - release machine code memory for given Function. @@ -1043,6 +1054,6 @@ // Free the actual memory for the function body and related stuff. assert(dynamic_cast(MCE) && "Unexpected MCE?"); - dynamic_cast(MCE)->deallocateMemForFunction(F); + static_cast(MCE)->deallocateMemForFunction(F); } From isanbard at gmail.com Fri Feb 23 21:46:59 2007 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 23 Feb 2007 21:46:59 -0600 Subject: [llvm-commits] CVS: llvm/docs/HowToSubmitABug.html Message-ID: <200702240346.l1O3kxTV024751@zion.cs.uiuc.edu> Changes in directory llvm/docs: HowToSubmitABug.html updated: 1.27 -> 1.28 --- Log message: Added some more information on how to use "delta" to reduce testcases. --- Diffs of the changes: (+11 -7) HowToSubmitABug.html | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) Index: llvm/docs/HowToSubmitABug.html diff -u llvm/docs/HowToSubmitABug.html:1.27 llvm/docs/HowToSubmitABug.html:1.28 --- llvm/docs/HowToSubmitABug.html:1.27 Sun Aug 27 19:34:18 2006 +++ llvm/docs/HowToSubmitABug.html Fri Feb 23 21:46:42 2007 @@ -81,7 +81,7 @@
    -

    More often than not, bugs in the compiler cause it to crash - often due to an +

    More often than not, bugs in the compiler cause it to crash—often due to an assertion failure of some sort. If you are running opt directly, and something crashes, jump to the section on bugs in LLVM passes. Otherwise, the most important @@ -126,12 +126,16 @@ llvm-gcc command that resulted in the crash, but add the -save-temps option. The compiler will crash again, but it will leave behind a foo.i file (containing preprocessed C source code) and -possibly foo.s (containing LLVM assembly code), for each +possibly foo.s (containing LLVM assembly code) for each compiled foo.c file. Send us the foo.i file, -along with a brief description of the error it caused. A tool that might help -you reduce a front-end testcase to a more manageable size is -delta. -

    +along with a brief description of the error it caused.

    + +

    The delta tool helps to reduce the +preprocessed file down to the smallest amount of code that still replicates the +problem. You're encouraged to use delta to reduce the code to make the +developers' lives easier. This website +has instructions on the best way to use delta.

    @@ -352,7 +356,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2006/08/28 00:34:18 $ + Last modified: $Date: 2007/02/24 03:46:42 $ From reid at x10sys.com Fri Feb 23 21:59:03 2007 From: reid at x10sys.com (Reid Spencer) Date: Fri, 23 Feb 2007 21:59:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702240359.l1O3x3nM024941@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.32 -> 1.33 --- Log message: 1. Make internal functions take const arguments where they should, just to be safe. 2. Make internal functions that return a carry/borrow return bool instead of uint64_t because the carry/borrow can only be in range [0,1]. 3. Assert that the pointers to KnuthDiv are all different so that the result and operands can't overlap. 4. Add debug output to KnuthDiv function. 5. Fix a problem with KnuthDiv by separating the b's complement operation from the subtraction borrow operation. This fixes a wide range of division problems, but alas, not all of them. --- Diffs of the changes: (+61 -21) APInt.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 61 insertions(+), 21 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.32 llvm/lib/Support/APInt.cpp:1.33 --- llvm/lib/Support/APInt.cpp:1.32 Thu Feb 22 19:57:13 2007 +++ llvm/lib/Support/APInt.cpp Fri Feb 23 21:58:46 2007 @@ -12,8 +12,10 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "apint" #include "llvm/ADT/APInt.h" #include "llvm/DerivedTypes.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" #include #include @@ -189,8 +191,9 @@ /// add - This function adds the integer array x[] by integer array /// y[] and returns the carry. -static uint64_t add(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) { - bool carry = 0; +static bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, + uint32_t len) { + bool carry = false; for (uint32_t i = 0; i< len; ++i) { uint64_t limit = std::min(x[i],y[i]); // must come first in case dest == x dest[i] = x[i] + y[i] + carry; @@ -214,8 +217,8 @@ /// sub - This function subtracts the integer array x[] by /// integer array y[], and returns the borrow-out carry. -static uint64_t sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, - uint32_t len) { +static bool sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, + uint32_t len) { bool borrow = false; for (uint32_t i = 0; i < len; ++i) { uint64_t x_tmp = borrow ? x[i] - 1 : x[i]; @@ -988,12 +991,19 @@ assert(u && "Must provide dividend"); assert(v && "Must provide divisor"); assert(q && "Must provide quotient"); + assert(u != v && u != q && v != q && "Must us different memory"); assert(n>1 && "n must be > 1"); // Knuth uses the value b as the base of the number system. In our case b // is 2^31 so we just set it to -1u. uint64_t b = uint64_t(1) << 32; + DEBUG(cerr << "KnuthDiv: m=" << m << " n=" << n << '\n'); + DEBUG(cerr << "KnuthDiv: original:"); + DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << std::setbase(16) << u[i]); + DEBUG(cerr << " by"); + DEBUG(for (int i = n; i >0; i--) cerr << " " << std::setbase(16) << v[i-1]); + DEBUG(cerr << '\n'); // D1. [Normalize.] Set d = b / (v[n-1] + 1) and multiply all the digits of // u and v by d. Note that we have taken Knuth's advice here to use a power // of 2 value for d such that d * v[n-1] >= b/2 (b is the base). A power of @@ -1018,10 +1028,16 @@ } } u[m+n] = u_carry; + DEBUG(cerr << "KnuthDiv: normal:"); + DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << std::setbase(16) << u[i]); + DEBUG(cerr << " by"); + DEBUG(for (int i = n; i >0; i--) cerr << " " << std::setbase(16) << v[i-1]); + DEBUG(cerr << '\n'); // D2. [Initialize j.] Set j to m. This is the loop counter over the places. int j = m; do { + DEBUG(cerr << "KnuthDiv: quotient digit #" << j << '\n'); // D3. [Calculate q'.]. // Set qp = (u[j+n]*b + u[j+n-1]) / v[n-1]. (qp=qprime=q') // Set rp = (u[j+n]*b + u[j+n-1]) % v[n-1]. (rp=rprime=r') @@ -1031,41 +1047,54 @@ // value qp is one too large, and it eliminates all cases where qp is two // too large. uint64_t dividend = ((uint64_t(u[j+n]) << 32) + u[j+n-1]); + DEBUG(cerr << "KnuthDiv: dividend == " << dividend << '\n'); uint64_t qp = dividend / v[n-1]; uint64_t rp = dividend % v[n-1]; if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { qp--; rp += v[n-1]; - if (rp < b) { - if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { - qp--; - rp += v[n-1]; - } + if (rp < b && (qp == b || qp*v[n-2] > b*rp + u[j+n-2])) { + qp--; + //rp += v[n-1]; } } + DEBUG(cerr << "KnuthDiv: qp == " << qp << ", rp == " << rp << '\n'); // D4. [Multiply and subtract.] Replace (u[j+n]u[j+n-1]...u[j]) with // (u[j+n]u[j+n-1]..u[j]) - qp * (v[n-1]...v[1]v[0]). This computation // consists of a simple multiplication by a one-place number, combined with // a subtraction. The digits (u[j+n]...u[j]) should be kept positive; - bool borrow = 0; + bool borrow = false; for (uint32_t i = 0; i < n; ++i) { - uint64_t u_tmp = borrow ? u[j+i] - 1 : u[j+i]; - uint64_t subtrahend = qp * v[i]; + uint64_t u_tmp = borrow ? uint64_t(u[j+i] - 1) : uint64_t(u[j+i]); + uint64_t subtrahend = uint64_t(qp) * uint64_t(v[i]); + DEBUG(cerr << "KnuthDiv: u_tmp == " << u_tmp + << ", subtrahend == " << subtrahend << '\n'); + borrow = subtrahend > u_tmp || (borrow && u[j+i] == 0); u[j+i] = u_tmp - subtrahend; } + if (borrow) { + borrow = u[j+n] == 0; // Was result negative? + u[j+n]--; // handle the borrow + } + DEBUG(cerr << "KnuthDiv: after subtraction:"); + DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << u[i]); + DEBUG(cerr << '\n'); // if the result of this step is actually negative, (u[j+n]...u[j]) should - // be left as the true value plus b**(n+1), names as the b's complement of + // be left as the true value plus b**(n+1), namely as the b's complement of // the true value, and a "borrow" to the left should be remembered. // if (borrow) { - borrow = u[j+n] == 0; - u[j+n]--; -// for (uint32_t i = 0; i < n; ++i) { -// u[j+i] = ~u[j+i] + 1; // b's complement -// } + bool carry = true; + for (uint32_t i = 0; i <= n; ++i) { + u[j+i] = ~u[j+i] + carry; // b's complement + carry = u[j+i] == 0; + } } + DEBUG(cerr << "KnuthDiv: after complement:"); + DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << u[i]); + DEBUG(cerr << '\n'); // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was // negative, go to step D6; otherwise go on to step D7. @@ -1080,16 +1109,23 @@ // since it cancels with the borrow that occurred in D4. bool carry = false; for (uint32_t i = 0; i < n; i++) { - uint32_t save = u[j+i]; + uint32_t limit = std::min(u[j+i],v[i]); u[j+i] += v[i] + carry; - uint32_t limit = std::min(save,v[i]); - carry = u[j+i] < limit || (carry && u[j+1] == limit); + carry = u[j+i] < limit || (carry && u[j+i] == limit); } + u[j+n] += carry; } + DEBUG(cerr << "KnuthDiv: after correction:"); + DEBUG(for (int i = m+n; i >=0; i--) cerr <<" " << u[i]); + DEBUG(cerr << "\nKnuthDiv: digit result = " << q[j] << '\n'); // D7. [Loop on j.] Decrease j by one. Now if j >= 0, go back to D3. } while (--j >= 0); + DEBUG(cerr << "KnuthDiv: quotient:"); + DEBUG(for (int i = m; i >=0; i--) cerr <<" " << q[i]); + DEBUG(cerr << '\n'); + // D8. [Unnormalize]. Now q[...] is the desired quotient, and the desired // remainder may be obtained by dividing u[...] by d. If r is non-null we // compute the remainder (urem uses this). @@ -1098,11 +1134,15 @@ // multiplication by d by using a shift left. So, all we have to do is // shift right here. In order to mak uint32_t carry = 0; + DEBUG(cerr << "KnuthDiv: remainder:"); for (int i = n-1; i >= 0; i--) { r[i] = (u[i] >> shift) | carry; carry = u[i] << shift; + DEBUG(cerr << " " << r[i]); } + DEBUG(cerr << '\n'); } + DEBUG(cerr << std::setbase(10) << '\n'); } // This function makes calling KnuthDiv a little more convenient. It uses From clattner at apple.com Fri Feb 23 22:31:38 2007 From: clattner at apple.com (clattner at apple.com) Date: Fri, 23 Feb 2007 20:31:38 -0800 (PST) Subject: [llvm-commits] [124235] emit useful error messages if bad immediates are used Message-ID: <20070224043138.E57C56203810@src> Revision: 124235 Author: clattner Date: 2007-02-23 20:31:35 -0800 (Fri, 23 Feb 2007) Log Message: ----------- emit useful error messages if bad immediates are used Modified Paths: -------------- apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp Modified: apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp =================================================================== --- apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp 2007-02-24 04:15:35 UTC (rev 124234) +++ apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp 2007-02-24 04:31:35 UTC (rev 124235) @@ -114,7 +114,7 @@ * invocation into normal LLVM code. If the target can handle the builtin, this * function should emit the expanded code and return true. */ -bool TreeToLLVM::TargetIntrinsicLower(tree_node *exp, +bool TreeToLLVM::TargetIntrinsicLower(tree exp, unsigned FnCode, Value *DestLoc, Value *&Result, @@ -232,47 +232,59 @@ Elt = ConstantExpr::getIntegerCast(Elt, Type::Int8Ty, true); Result = BuildVector(Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, NULL); - return true; + } else { + error("%Helement must be an immediate", &EXPR_LOCATION(exp)); + Result = UndefValue::get(VectorType::get(Type::Int8Ty, 16)); } - return false; + return true; case ALTIVEC_BUILTIN_VSPLTISH: if (Constant *Elt = dyn_cast(Ops[0])) { Elt = ConstantExpr::getIntegerCast(Elt, Type::Int16Ty, true); Result = BuildVector(Elt, Elt, Elt, Elt, Elt, Elt, Elt, Elt, NULL); - return true; + } else { + error("%Helement must be an immediate", &EXPR_LOCATION(exp)); + Result = UndefValue::get(VectorType::get(Type::Int16Ty, 8)); } - return false; + return true; case ALTIVEC_BUILTIN_VSPLTISW: if (Constant *Elt = dyn_cast(Ops[0])) { Elt = ConstantExpr::getIntegerCast(Elt, Type::Int32Ty, true); Result = BuildVector(Elt, Elt, Elt, Elt, NULL); - return true; + } else { + error("%Hmask must be an immediate", &EXPR_LOCATION(exp)); + Result = UndefValue::get(VectorType::get(Type::Int32Ty, 4)); } - return false; + return true; case ALTIVEC_BUILTIN_VSPLTB: if (ConstantInt *Elt = dyn_cast(Ops[1])) { int EV = Elt->getZExtValue(); Result = BuildVectorShuffle(Ops[0], Ops[0], EV, EV, EV, EV, EV, EV, EV, EV, EV, EV, EV, EV, EV, EV, EV, EV); - return true; + } else { + error("%Helement number must be an immediate", &EXPR_LOCATION(exp)); + Result = Ops[0]; } - return false; + return true; case ALTIVEC_BUILTIN_VSPLTH: if (ConstantInt *Elt = dyn_cast(Ops[1])) { int EV = Elt->getZExtValue(); Result = BuildVectorShuffle(Ops[0], Ops[0], EV, EV, EV, EV, EV, EV, EV, EV); - return true; + } else { + error("%Helement number must be an immediate", &EXPR_LOCATION(exp)); + Result = Ops[0]; } - return false; + return true; case ALTIVEC_BUILTIN_VSPLTW: if (ConstantInt *Elt = dyn_cast(Ops[1])) { int EV = Elt->getZExtValue(); Result = BuildVectorShuffle(Ops[0], Ops[0], EV, EV, EV, EV); - return true; + } else { + error("%Helement number must be an immediate", &EXPR_LOCATION(exp)); + Result = Ops[0]; } - return false; + return true; case ALTIVEC_BUILTIN_VSLDOI_16QI: case ALTIVEC_BUILTIN_VSLDOI_8HI: case ALTIVEC_BUILTIN_VSLDOI_4SI: @@ -294,9 +306,11 @@ Amt+4, Amt+5, Amt+6, Amt+7, Amt+8, Amt+9, Amt+10, Amt+11, Amt+12, Amt+13, Amt+14, Amt+15); - return true; + } else { + error("%Hshift amount must be an immediate", &EXPR_LOCATION(exp)); + Result = Ops[0]; } - return false; + return true; case ALTIVEC_BUILTIN_VPKUHUM: { Value *Op0 = Ops[0]; Instruction::CastOps opc = CastInst::getCastOpcode(Op0, From clattner at apple.com Fri Feb 23 22:36:02 2007 From: clattner at apple.com (clattner at apple.com) Date: Fri, 23 Feb 2007 20:36:02 -0800 (PST) Subject: [llvm-commits] [124236] add missing #include Message-ID: <20070224043602.71ECE6204494@src> Revision: 124236 Author: clattner Date: 2007-02-23 20:35:59 -0800 (Fri, 23 Feb 2007) Log Message: ----------- add missing #include Modified Paths: -------------- apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp Modified: apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp =================================================================== --- apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp 2007-02-24 04:31:35 UTC (rev 124235) +++ apple-local/branches/llvm/gcc/config/rs6000/llvm-rs6000.cpp 2007-02-24 04:35:59 UTC (rev 124236) @@ -30,6 +30,10 @@ #include "llvm/Intrinsics.h" #include "llvm/Module.h" +extern "C" { +#include "toplev.h" +} + /* MergeIntPtrOperand - This merges the int and pointer operands of a GCC * intrinsic into a single operand for the LLVM intrinsic. For example, this * turns LVX(4, p) -> llvm.lvx(gep P, 4). OPNUM specifies the operand number From jlaskey at apple.com Sat Feb 24 03:44:35 2007 From: jlaskey at apple.com (Jim Laskey) Date: Sat, 24 Feb 2007 03:44:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Message-ID: <200702240944.l1O9iZJT006873@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.478 -> 1.479 --- Log message: Drop unused operand. --- Diffs of the changes: (+0 -2) LegalizeDAG.cpp | 2 -- 1 files changed, 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.478 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.479 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.478 Thu Feb 22 09:37:19 2007 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Feb 24 03:44:17 2007 @@ -677,8 +677,6 @@ Result = DAG.getConstant(0, TLI.getPointerTy()); break; case ISD::EHSELECTION: - LegalizeOp(Node->getOperand(1)); - // Fall Thru case ISD::EXCEPTIONADDR: { Tmp1 = LegalizeOp(Node->getOperand(0)); MVT::ValueType VT = Node->getValueType(0); From jlaskey at apple.com Sat Feb 24 03:46:01 2007 From: jlaskey at apple.com (Jim Laskey) Date: Sat, 24 Feb 2007 03:46:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702240946.l1O9k19S006903@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.373 -> 1.374 --- Log message: Deal with cases when MMI is not requested. --- Diffs of the changes: (+14 -0) SelectionDAGISel.cpp | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.373 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.374 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.373 Fri Feb 23 15:45:01 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sat Feb 24 03:45:44 2007 @@ -2101,6 +2101,12 @@ SDOperand Op = DAG.getNode(ISD::EXCEPTIONADDR, VTs, Ops, 1); setValue(&I, Op); DAG.setRoot(Op.getValue(1)); + } else { + SDOperand Op = DAG.getNode(ISD::MERGE_VALUES, TLI.getPointerTy(), + DAG.getConstant(0, TLI.getPointerTy()), + DAG.getRoot()); + setValue(&I, Op); + DAG.setRoot(Op.getValue(1)); } return 0; } @@ -2145,6 +2151,12 @@ SDOperand Op = DAG.getNode(ISD::EHSELECTION, VTs, Ops, 2); setValue(&I, Op); DAG.setRoot(Op.getValue(1)); + } else { + SDOperand Op = DAG.getNode(ISD::MERGE_VALUES, TLI.getPointerTy(), + DAG.getConstant(0, TLI.getPointerTy()), + getValue(I.getOperand(1))); + setValue(&I, Op); + DAG.setRoot(Op.getValue(1)); } return 0; @@ -2169,6 +2181,8 @@ unsigned TypeID = MMI->getTypeIDFor(GV); setValue(&I, DAG.getConstant(TypeID, MVT::i32)); + } else { + setValue(&I, DAG.getConstant(0, MVT::i32)); } return 0; From reid at x10sys.com Sat Feb 24 03:50:30 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 03:50:30 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h Message-ID: <200702240950.l1O9oUsE006985@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.16 -> 1.17 --- Log message: Improve documentation. Make divide function internal (it was briefly external for testing). --- Diffs of the changes: (+16 -12) APInt.h | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.16 llvm/include/llvm/ADT/APInt.h:1.17 --- llvm/include/llvm/ADT/APInt.h:1.16 Tue Feb 20 21:56:12 2007 +++ llvm/include/llvm/ADT/APInt.h Sat Feb 24 03:50:13 2007 @@ -107,8 +107,8 @@ } /// This method is used internally to clear the to "N" bits that are not used - /// by the APInt. This is needed after a word is assigned a value to ensure - /// that those bits are zero'd out. + /// by the APInt. This is needed after the most significant word is assigned + /// a value to ensure that those bits are zero'd out. /// @brief Clear high order bits inline void clearUnusedBits() { if (isSingleWord()) @@ -119,31 +119,35 @@ } /// @returns the corresponding word for the specified bit position. - /// This is a constant version. + /// @brief Get the word corresponding to a bit position inline uint64_t getWord(uint32_t bitPosition) const { return isSingleWord() ? VAL : pVal[whichWord(bitPosition)]; } - /// @brief Converts a char array into an integer. + /// This is used by the constructors that take string arguments. + /// @brief Converts a char array into an APInt void fromString(uint32_t numBits, const char *StrStart, uint32_t slen, uint8_t radix); + /// This is used by the toString method to divide by the radix. It simply + /// provides a more convenient form of divide for internal use. + /// @brief An internal division function for dividing APInts. + static void divide(const APInt LHS, uint32_t lhsWords, + const APInt &RHS, uint32_t rhsWords, + APInt *Quotient, APInt *Remainder); + #ifndef NDEBUG /// @brief debug method void dump() const; #endif public: - /// @brief An internal division function for dividing APInts. - static void divide(const APInt LHS, uint32_t lhsWords, - const APInt &RHS, uint32_t rhsWords, - APInt *Quotient, APInt *Remainder); - - /// @brief Create a new APInt of numBits bit-width, and initialized as val. + /// @brief Create a new APInt of numBits width, initialized as val. APInt(uint32_t numBits, uint64_t val); - /// @brief Create a new APInt of numBits bit-width, and initialized as - /// bigVal[]. + /// Note that numWords can be smaller or larger than the corresponding bit + /// width but any extraneous bits will be dropped. + /// @brief Create a new APInt of numBits width, initialized as bigVal[]. APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[]); /// @brief Create a new APInt by translating the string represented From reid at x10sys.com Sat Feb 24 03:52:04 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 03:52:04 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Message-ID: <200702240952.l1O9q4jw007023@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt: gptest.cpp updated: 1.3 -> 1.4 --- Log message: Add logical operators, shift, and index tests. --- Diffs of the changes: (+133 -8) gptest.cpp | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 133 insertions(+), 8 deletions(-) Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.3 llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.4 --- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.3 Wed Feb 21 19:03:12 2007 +++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Sat Feb 24 03:51:47 2007 @@ -40,6 +40,10 @@ } std::string getResult(const std::string& cmd) { +#if 0 + printf("Command: %s", cmd.c_str()); + fflush(stdout); +#endif const char *command = cmd.c_str(); if (-1 == write(output, command, cmd.size())) { std::string msg = "write: " + cmd; @@ -47,7 +51,6 @@ perror(msg.c_str()); exit(1); } - usleep(1); // try to switch contexts char buf[4096]; int len = read(input, buf, 4095); if (-1 == len) { @@ -76,13 +79,9 @@ } -bool getCompare(const APInt &v1, const std::string &op, - const APInt &v2, bool wantSigned = false) { - - std::string cmd = v1.toString(10, wantSigned) + op + - v2.toString(10, wantSigned) + '\n'; - std::string result = getResult(cmd); - return bool(atoi(result.c_str())); +void report(const std::string& cmd, + const std::string& result, const std::string& apresult) { + printf("%s = %s (not %s)\n", cmd.c_str(), result.c_str(), apresult.c_str()); } void report(const APInt &v1, const APInt &v2, const std::string& op, @@ -94,6 +93,14 @@ fflush(stdout); } +void report(const APInt &v1, const std::string &op, + const std::string& result, const std::string& apresult) { + printf(op.c_str()); + print(v1, false, false); + printf(" = %s (not %s)\n", result.c_str(), apresult.c_str()); + fflush(stdout); +} + void doMultiply(const APInt &v1, const APInt &v2) { std::string result = getBinop(v1, "*", v2); APInt r = v1 * v2; @@ -138,6 +145,117 @@ report(v1,v2," - ", result,apresult); } +void doAnd(const APInt &v1, const APInt &v2) { + std::string cmd; + cmd += "bitand("; + cmd += v1.toString(10,false); + cmd += ","; + cmd += v2.toString(10,false); + cmd += ")\n"; + std::string result = getResult(cmd); + APInt r = v1 & v2; + std::string apresult = r.toString(10, false); + if (result != apresult) + report(cmd, result,apresult); +} + +void doOr(const APInt &v1, const APInt &v2) { + std::string cmd; + cmd += "bitor("; + cmd += v1.toString(10,false); + cmd += ","; + cmd += v2.toString(10,false); + cmd += ")\n"; + std::string result = getResult(cmd); + APInt r = v1 | v2; + std::string apresult = r.toString(10, false); + if (result != apresult) + report(cmd, result,apresult); +} + +void doXor(const APInt &v1, const APInt &v2) { + std::string cmd; + cmd += "bitxor("; + cmd += v1.toString(10,false); + cmd += ","; + cmd += v2.toString(10,false); + cmd += ")\n"; + std::string result = getResult(cmd); + APInt r = v1 ^ v2; + std::string apresult = r.toString(10, false); + if (result != apresult) + report(cmd, result,apresult); +} + +void doComplement(const APInt &v1) { + std::string cmd; + cmd += "bitneg("; + cmd += v1.toString(10,false); + cmd += "," + utostr(v1.getBitWidth()) + ")\n"; + std::string result = getResult(cmd); + APInt r = ~v1; + std::string apresult = r.toString(10, false); + if (result != apresult) + report(v1," ~ ", result,apresult); +} + +void doBitTest(const APInt &v1) { + for (int i = 0; i < v1.getBitWidth(); i++) { + std::string cmd; + cmd += "bittest("; + cmd += v1.toString(10,false); + cmd += "," + utostr(i) + ")\n"; + bool gpresult = atoi(getResult(cmd).c_str()); + bool apresult = v1[i]; + if (gpresult != apresult) { + print(v1, false, false); + printf("[%d] = %s (not %s)\n", i, + (gpresult?"true":"false"), (apresult?"true":"false")); + fflush(stdout); + } + } +} + +void doShift(const APInt &v1) { + APInt mask = APInt::getAllOnesValue(v1.getBitWidth()); + for (int i = 1; i <= v1.getBitWidth(); i++) { + std::string cmd; + cmd += "bitand(truncate(shift("; + cmd += v1.toString(10,false); + cmd += "," + utostr(unsigned(i)) + ")), "; + cmd += "bitneg(0," + utostr(unsigned(v1.getBitWidth())) + "))\n"; + std::string gpresult = getResult(cmd); + APInt R1 = v1.shl(i); + std::string apresult = R1.toString(10,false); + if (gpresult != apresult) { + print(v1, false, false); + printf(" << %d = %s (not %s)\n", i, gpresult.c_str(), apresult.c_str()); + fflush(stdout); + } + cmd = "bitand(truncate(shift("; + cmd += v1.toString(10,false); + cmd += ",-" + utostr(i) + ")), "; + cmd += "bitneg(0," + utostr(unsigned(v1.getBitWidth())) + "))\n"; + gpresult = getResult(cmd); + R1 = v1.lshr(i); + apresult = R1.toString(10,false); + if (gpresult != apresult) { + print(v1, false, false); + printf(" s>> %d = %s (not %s)\n", i, gpresult.c_str(), apresult.c_str()); + fflush(stdout); + } + } +} + +bool getCompare(const APInt &v1, const std::string &op, + const APInt &v2, bool wantSigned = false) { + + std::string cmd = v1.toString(10, wantSigned) + op + + v2.toString(10, wantSigned) + '\n'; + std::string result = getResult(cmd); + return bool(atoi(result.c_str())); +} + void doComparisons(const APInt &v1, const APInt &v2) { bool result = getCompare(v1, "==", v2); bool apresult = v1 == v2; @@ -170,6 +288,10 @@ doSubtract(v1,v2); doMultiply(v1, v2); doDivide(v1, v2); + doRemainder(v1,v2); + doAnd(v1,v2); + doOr(v1,v2); + doXor(v1,v2); doComparisons(v1, v2); } @@ -234,6 +356,9 @@ for (unsigned j = 0; j < 9; ++j) { test_binops(*(list[i]), *(list[j])); } + doComplement(*(list[i])); + doBitTest(*(list[i])); + doShift(*(list[i])); } } From reid at x10sys.com Sat Feb 24 04:01:59 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 04:01:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702241001.l1OA1xuo007196@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.33 -> 1.34 --- Log message: 1. Fix last bug in KnuthDiv. All divide tests pass up to 1024 bits now. 2. Clean up comments, style, coding standards, etc. 3. Simplify a constructor. Extended testing revealed some additional bugs in shifting. I'll fix these tomorrow. --- Diffs of the changes: (+54 -62) APInt.cpp | 116 ++++++++++++++++++++++++++++---------------------------------- 1 files changed, 54 insertions(+), 62 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.33 llvm/lib/Support/APInt.cpp:1.34 --- llvm/lib/Support/APInt.cpp:1.33 Fri Feb 23 21:58:46 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 04:01:42 2007 @@ -2,8 +2,9 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Sheng Zhou and is distributed under the -// University of Illinois Open Source License. See LICENSE.TXT for details. +// This file was developed by Sheng Zhou and Reid Spencer and is distributed +// under the // University of Illinois Open Source License. See LICENSE.TXT +// for details. // //===----------------------------------------------------------------------===// // @@ -20,14 +21,13 @@ #include #include #ifndef NDEBUG -#include #include #endif using namespace llvm; // A utility function for allocating memory, checking for allocation failures, -// and ensuring the contents is zeroed. +// and ensuring the contents are zeroed. inline static uint64_t* getClearedMemory(uint32_t numWords) { uint64_t * result = new uint64_t[numWords]; assert(result && "APInt memory allocation fails!"); @@ -36,6 +36,7 @@ } // A utility function for allocating memory and checking for allocation failure. +// The content is not zero'd inline static uint64_t* getMemory(uint32_t numWords) { uint64_t * result = new uint64_t[numWords]; assert(result && "APInt memory allocation fails!"); @@ -60,38 +61,31 @@ assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); assert(bigVal && "Null pointer detected!"); if (isSingleWord()) - VAL = bigVal[0] & (~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth)); + VAL = bigVal[0]; else { - pVal = getMemory(getNumWords()); - // Calculate the actual length of bigVal[]. - uint32_t maxN = std::max(numWords, getNumWords()); - uint32_t minN = std::min(numWords, getNumWords()); - memcpy(pVal, bigVal, (minN - 1) * APINT_WORD_SIZE); - pVal[minN-1] = bigVal[minN-1] & - (~uint64_t(0ULL) >> - (APINT_BITS_PER_WORD - BitWidth % APINT_BITS_PER_WORD)); - if (maxN == getNumWords()) - memset(pVal+numWords, 0, (getNumWords() - numWords) * APINT_WORD_SIZE); + // Get memory, cleared to 0 + pVal = getClearedMemory(getNumWords()); + // Calculate the number of words to copy + uint32_t words = std::min(numWords, getNumWords()); + // Copy the words from bigVal to pVal + memcpy(pVal, bigVal, words * APINT_WORD_SIZE); } + // Make sure unused high bits are cleared + clearUnusedBits(); } -/// @brief Create a new APInt by translating the char array represented -/// integer value. APInt::APInt(uint32_t numbits, const char StrStart[], uint32_t slen, uint8_t radix) : BitWidth(numbits), VAL(0) { fromString(numbits, StrStart, slen, radix); } -/// @brief Create a new APInt by translating the string represented -/// integer value. APInt::APInt(uint32_t numbits, const std::string& Val, uint8_t radix) : BitWidth(numbits), VAL(0) { assert(!Val.empty() && "String empty?"); fromString(numbits, Val.c_str(), Val.size(), radix); } -/// @brief Copy constructor APInt::APInt(const APInt& that) : BitWidth(that.BitWidth), VAL(0) { if (isSingleWord()) @@ -107,8 +101,6 @@ delete[] pVal; } -/// @brief Copy assignment operator. Create a new object from the given -/// APInt one by initialization. APInt& APInt::operator=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) @@ -118,8 +110,6 @@ return *this; } -/// @brief Assignment operator. Assigns a common case integer value to -/// the APInt. APInt& APInt::operator=(uint64_t RHS) { if (isSingleWord()) VAL = RHS; @@ -134,15 +124,13 @@ /// "digit" integer array, x[]. x[] is modified to reflect the addition and /// 1 is returned if there is a carry out, otherwise 0 is returned. /// @returns the carry of the addition. -static uint64_t add_1(uint64_t dest[], - uint64_t x[], uint32_t len, - uint64_t y) { +static uint64_t add_1(uint64_t dest[], uint64_t x[], uint32_t len, uint64_t y) { for (uint32_t i = 0; i < len; ++i) { dest[i] = y + x[i]; if (dest[i] < y) - y = 1; + y = 1; // Carry one to next digit. else { - y = 0; + y = 0; // No need to carry so exit early break; } } @@ -216,7 +204,7 @@ } /// sub - This function subtracts the integer array x[] by -/// integer array y[], and returns the borrow-out carry. +/// integer array y[], and returns the borrow-out. static bool sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, uint32_t len) { bool borrow = false; @@ -243,10 +231,8 @@ /// mul_1 - This function performs the multiplication operation on a /// large integer (represented as an integer array) and a uint64_t integer. /// @returns the carry of the multiplication. -static uint64_t mul_1(uint64_t dest[], - uint64_t x[], uint32_t len, - uint64_t y) { - // Split y into high 32-bit part and low 32-bit part. +static uint64_t mul_1(uint64_t dest[], uint64_t x[], uint32_t len, uint64_t y) { + // Split y into high 32-bit part (hy) and low 32-bit part (ly) uint64_t ly = y & 0xffffffffULL, hy = y >> 32; uint64_t carry = 0, lx, hx; for (uint32_t i = 0; i < len; ++i) { @@ -277,10 +263,9 @@ /// mul - This function multiplies integer array x[] by integer array y[] and /// stores the result into integer array dest[]. /// Note the array dest[]'s size should no less than xlen + ylen. -static void mul(uint64_t dest[], uint64_t x[], uint32_t xlen, - uint64_t y[], uint32_t ylen) { +static void mul(uint64_t dest[], uint64_t x[], uint32_t xlen, uint64_t y[], + uint32_t ylen) { dest[xlen] = mul_1(dest, x, xlen, y[0]); - for (uint32_t i = 1; i < ylen; ++i) { uint64_t ly = y[i] & 0xffffffffULL, hy = y[i] >> 32; uint64_t carry = 0, lx = 0, hx = 0; @@ -1053,43 +1038,50 @@ if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { qp--; rp += v[n-1]; - if (rp < b && (qp == b || qp*v[n-2] > b*rp + u[j+n-2])) { + if (rp < b && (qp == b || qp*v[n-2] > b*rp + u[j+n-2])) qp--; - //rp += v[n-1]; - } } DEBUG(cerr << "KnuthDiv: qp == " << qp << ", rp == " << rp << '\n'); // D4. [Multiply and subtract.] Replace (u[j+n]u[j+n-1]...u[j]) with // (u[j+n]u[j+n-1]..u[j]) - qp * (v[n-1]...v[1]v[0]). This computation // consists of a simple multiplication by a one-place number, combined with - // a subtraction. The digits (u[j+n]...u[j]) should be kept positive; - bool borrow = false; + // a subtraction. + bool isNegative = false; for (uint32_t i = 0; i < n; ++i) { - uint64_t u_tmp = borrow ? uint64_t(u[j+i] - 1) : uint64_t(u[j+i]); + uint64_t u_tmp = uint64_t(u[j+i]) | (uint64_t(u[j+i+1]) << 32); uint64_t subtrahend = uint64_t(qp) * uint64_t(v[i]); + bool borrow = subtrahend > u_tmp; DEBUG(cerr << "KnuthDiv: u_tmp == " << u_tmp - << ", subtrahend == " << subtrahend << '\n'); + << ", subtrahend == " << subtrahend + << ", borrow = " << borrow << '\n'); - borrow = subtrahend > u_tmp || (borrow && u[j+i] == 0); - u[j+i] = u_tmp - subtrahend; - } - if (borrow) { - borrow = u[j+n] == 0; // Was result negative? - u[j+n]--; // handle the borrow + uint64_t result = u_tmp - subtrahend; + uint32_t k = j + i; + u[k++] = result & (b-1); // subtract low word + u[k++] = result >> 32; // subtract high word + while (borrow && k <= m+n) { // deal with borrow to the left + borrow = u[k] == 0; + u[k]--; + k++; + } + isNegative |= borrow; + DEBUG(cerr << "KnuthDiv: u[j+i] == " << u[j+i] << ", u[j+i+1] == " << + u[j+i+1] << '\n'); } DEBUG(cerr << "KnuthDiv: after subtraction:"); DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << u[i]); DEBUG(cerr << '\n'); - // if the result of this step is actually negative, (u[j+n]...u[j]) should - // be left as the true value plus b**(n+1), namely as the b's complement of + // The digits (u[j+n]...u[j]) should be kept positive; if the result of + // this step is actually negative, (u[j+n]...u[j]) should be left as the + // true value plus b**(n+1), namely as the b's complement of // the true value, and a "borrow" to the left should be remembered. // - if (borrow) { - bool carry = true; - for (uint32_t i = 0; i <= n; ++i) { - u[j+i] = ~u[j+i] + carry; // b's complement - carry = u[j+i] == 0; + if (isNegative) { + bool carry = true; // true because b's complement is "complement + 1" + for (uint32_t i = 0; i <= m+n; ++i) { + u[i] = ~u[i] + carry; // b's complement + carry = carry && u[i] == 0; } } DEBUG(cerr << "KnuthDiv: after complement:"); @@ -1099,7 +1091,7 @@ // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was // negative, go to step D6; otherwise go on to step D7. q[j] = qp; - if (borrow) { + if (isNegative) { // D6. [Add back]. The probability that this step is necessary is very // small, on the order of only 2/b. Make sure that test data accounts for // this possibility. Decrease q[j] by 1 @@ -1516,12 +1508,12 @@ #ifndef NDEBUG void APInt::dump() const { - std::cerr << "APInt(" << BitWidth << ")=" << std::setbase(16); + cerr << "APInt(" << BitWidth << ")=" << std::setbase(16); if (isSingleWord()) - std::cerr << VAL; + cerr << VAL; else for (unsigned i = getNumWords(); i > 0; i--) { - std::cerr << pVal[i-1] << " "; + cerr << pVal[i-1] << " "; } - std::cerr << " (" << this->toString(10, false) << ")\n" << std::setbase(10); + cerr << " (" << this->toString(10, false) << ")\n" << std::setbase(10); } #endif From reid at x10sys.com Sat Feb 24 14:19:54 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 14:19:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702242019.l1OKJsSh018227@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.34 -> 1.35 --- Log message: 1. Fix a bug in fromString for the <= 64bits case 2. Fix shl when shiftAmount == BitWidth. --- Diffs of the changes: (+30 -18) APInt.cpp | 48 ++++++++++++++++++++++++++++++------------------ 1 files changed, 30 insertions(+), 18 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.34 llvm/lib/Support/APInt.cpp:1.35 --- llvm/lib/Support/APInt.cpp:1.34 Sat Feb 24 04:01:42 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 14:19:37 2007 @@ -945,24 +945,33 @@ /// Left-shift this APInt by shiftAmt. /// @brief Left-shift function. APInt APInt::shl(uint32_t shiftAmt) const { + assert(shiftAmt <= BitWidth && "Invalid shift amount"); APInt API(*this); - if (API.isSingleWord()) - API.VAL <<= shiftAmt; - else if (shiftAmt >= API.BitWidth) - memset(API.pVal, 0, API.getNumWords() * APINT_WORD_SIZE); - else { - if (uint32_t offset = shiftAmt / APINT_BITS_PER_WORD) { - for (uint32_t i = API.getNumWords() - 1; i > offset - 1; --i) - API.pVal[i] = API.pVal[i-offset]; - memset(API.pVal, 0, offset * APINT_WORD_SIZE); - } - shiftAmt %= APINT_BITS_PER_WORD; - uint32_t i; - for (i = API.getNumWords() - 1; i > 0; --i) - API.pVal[i] = (API.pVal[i] << shiftAmt) | - (API.pVal[i-1] >> (APINT_BITS_PER_WORD - shiftAmt)); - API.pVal[i] <<= shiftAmt; - } + if (API.isSingleWord()) { + if (shiftAmt == BitWidth) + API.VAL = 0; + else + API.VAL <<= shiftAmt; + API.clearUnusedBits(); + return API; + } + + if (shiftAmt == BitWidth) { + memset(API.pVal, 0, getNumWords() * APINT_WORD_SIZE); + return API; + } + + if (uint32_t offset = shiftAmt / APINT_BITS_PER_WORD) { + for (uint32_t i = API.getNumWords() - 1; i > offset - 1; --i) + API.pVal[i] = API.pVal[i-offset]; + memset(API.pVal, 0, offset * APINT_WORD_SIZE); + } + shiftAmt %= APINT_BITS_PER_WORD; + uint32_t i; + for (i = API.getNumWords() - 1; i > 0; --i) + API.pVal[i] = (API.pVal[i] << shiftAmt) | + (API.pVal[i-1] >> (APINT_BITS_PER_WORD - shiftAmt)); + API.pVal[i] <<= shiftAmt; API.clearUnusedBits(); return API; } @@ -1423,7 +1432,10 @@ *this *= apradix; // Add in the digit we just interpreted - apdigit.pVal[0] = digit; + if (apdigit.isSingleWord()) + apdigit.VAL = digit; + else + apdigit.pVal[0] = digit; *this += apdigit; } } From reid at x10sys.com Sat Feb 24 14:21:03 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 14:21:03 -0600 Subject: [llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Message-ID: <200702242021.l1OKL3hY018273@zion.cs.uiuc.edu> Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt: gptest.cpp updated: 1.4 -> 1.5 --- Log message: Consolidate reporting. Consolidate comparison tests. Fix output for remainder. --- Diffs of the changes: (+24 -56) gptest.cpp | 80 ++++++++++++++++++------------------------------------------- 1 files changed, 24 insertions(+), 56 deletions(-) Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.4 llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.5 --- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.4 Sat Feb 24 03:51:47 2007 +++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp Sat Feb 24 14:20:46 2007 @@ -78,12 +78,6 @@ return getResult(cmd); } - -void report(const std::string& cmd, - const std::string& result, const std::string& apresult) { - printf("%s = %s (not %s)\n", cmd.c_str(), result.c_str(), apresult.c_str()); -} - void report(const APInt &v1, const APInt &v2, const std::string& op, const std::string& result, const std::string& apresult) { print(v1, false, false); @@ -93,14 +87,6 @@ fflush(stdout); } -void report(const APInt &v1, const std::string &op, - const std::string& result, const std::string& apresult) { - printf(op.c_str()); - print(v1, false, false); - printf(" = %s (not %s)\n", result.c_str(), apresult.c_str()); - fflush(stdout); -} - void doMultiply(const APInt &v1, const APInt &v2) { std::string result = getBinop(v1, "*", v2); APInt r = v1 * v2; @@ -126,7 +112,7 @@ APInt r = APIntOps::urem(v1, v2); std::string apresult = r.toString(10, false); if (result != apresult) - report(v1,v2," % ", result,apresult); + report(v1,v2," %% ", result,apresult); } void doAdd(const APInt &v1, const APInt &v2) { @@ -156,7 +142,7 @@ APInt r = v1 & v2; std::string apresult = r.toString(10, false); if (result != apresult) - report(cmd, result,apresult); + report(v1, v2, " and ", result,apresult); } void doOr(const APInt &v1, const APInt &v2) { @@ -170,7 +156,7 @@ APInt r = v1 | v2; std::string apresult = r.toString(10, false); if (result != apresult) - report(cmd, result,apresult); + report(v1, v2, " or ", result,apresult); } void doXor(const APInt &v1, const APInt &v2) { @@ -184,7 +170,7 @@ APInt r = v1 ^ v2; std::string apresult = r.toString(10, false); if (result != apresult) - report(cmd, result,apresult); + report(v1, v2, " xor ", result,apresult); } void doComplement(const APInt &v1) { @@ -195,8 +181,12 @@ std::string result = getResult(cmd); APInt r = ~v1; std::string apresult = r.toString(10, false); - if (result != apresult) - report(v1," ~ ", result,apresult); + if (result != apresult) { + printf("~ "); + print(v1, false, false); + printf(" = %s (not %s)\n", result.c_str(), apresult.c_str()); + fflush(stdout); + } } void doBitTest(const APInt &v1) { @@ -241,46 +231,19 @@ apresult = R1.toString(10,false); if (gpresult != apresult) { print(v1, false, false); - printf(" s>> %d = %s (not %s)\n", i, gpresult.c_str(), apresult.c_str()); + printf(" u>> %d = %s (not %s)\n", i, gpresult.c_str(), apresult.c_str()); fflush(stdout); } } } -bool getCompare(const APInt &v1, const std::string &op, - const APInt &v2, bool wantSigned = false) { - - std::string cmd = v1.toString(10, wantSigned) + op + - v2.toString(10, wantSigned) + '\n'; - std::string result = getResult(cmd); - return bool(atoi(result.c_str())); -} - -void doComparisons(const APInt &v1, const APInt &v2) { - bool result = getCompare(v1, "==", v2); - bool apresult = v1 == v2; - if (result != apresult) - report(v1,v2," == ", (result?"true":"false"), (apresult?"true":"false")); - result = getCompare(v1, "!=", v2); - apresult = v1 != v2; - if (result != apresult) - report(v1,v2," != ", (result?"true":"false"), (apresult?"true":"false")); - result = getCompare(v1, "<", v2); - apresult = v1.ult(v2); - if (result != apresult) - report(v1,v2," < ", (result?"true":"false"), (apresult?"true":"false")); - result = getCompare(v1, "<=", v2); - apresult = v1.ule(v2); - if (result != apresult) - report(v1,v2," <= ", (result?"true":"false"), (apresult?"true":"false")); - result = getCompare(v1, ">", v2); - apresult = v1.ugt(v2); - if (result != apresult) - report(v1,v2," > ", (result?"true":"false"), (apresult?"true":"false")); - result = getCompare(v1, ">=", v2); - apresult = v1.uge(v2); - if (result != apresult) - report(v1,v2," >= ", (result?"true":"false"), (apresult?"true":"false")); +void doCompare(const APInt &v1, const std::string &op, + const APInt &v2, bool apresult) { + std::string cmd = v1.toString(10, false) + op + + v2.toString(10, false) + '\n'; + bool gpresult = atoi(getResult(cmd).c_str()); + if (gpresult != apresult) + report(v1,v2, op, (apresult?"true":"false"), (apresult?"true":"false")); } void test_binops(const APInt &v1, const APInt &v2) { @@ -292,7 +255,12 @@ doAnd(v1,v2); doOr(v1,v2); doXor(v1,v2); - doComparisons(v1, v2); + doCompare(v1, "==", v2, v1 == v2); + doCompare(v1, "!=", v2, v1 != v2); + doCompare(v1, "< ", v2, v1.ult(v2)); + doCompare(v1, "<=", v2, v1.ule(v2)); + doCompare(v1, "> ", v2, v1.ugt(v2)); + doCompare(v1, ">=", v2, v1.uge(v2)); } void Shutdown() { From reid at x10sys.com Sat Feb 24 14:38:17 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 14:38:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702242038.l1OKcHSl018643@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.35 -> 1.36 --- Log message: Fix the remainder shifting in KnuthDiv. --- Diffs of the changes: (+13 -6) APInt.cpp | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.35 llvm/lib/Support/APInt.cpp:1.36 --- llvm/lib/Support/APInt.cpp:1.35 Sat Feb 24 14:19:37 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 14:38:01 2007 @@ -1134,12 +1134,19 @@ // The value d is expressed by the "shift" value above since we avoided // multiplication by d by using a shift left. So, all we have to do is // shift right here. In order to mak - uint32_t carry = 0; - DEBUG(cerr << "KnuthDiv: remainder:"); - for (int i = n-1; i >= 0; i--) { - r[i] = (u[i] >> shift) | carry; - carry = u[i] << shift; - DEBUG(cerr << " " << r[i]); + if (shift) { + uint32_t carry = 0; + DEBUG(cerr << "KnuthDiv: remainder:"); + for (int i = n-1; i >= 0; i--) { + r[i] = (u[i] >> shift) | carry; + carry = u[i] << (32 - shift); + DEBUG(cerr << " " << r[i]); + } + } else { + for (int i = n-1; i >= 0; i--) { + r[i] = u[i]; + DEBUG(cerr << " " << r[i]); + } } DEBUG(cerr << '\n'); } From dalej at apple.com Sat Feb 24 18:47:19 2007 From: dalej at apple.com (Dale Johannesen) Date: Sat, 24 Feb 2007 18:47:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp README.txt Message-ID: <200702250047.l1P0lJ8u023754@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.27 -> 1.28 README.txt updated: 1.12 -> 1.13 --- Log message: Removed WaterListOffset, inserted BBOffsets. Remove TODO item about this from README. When no water available, use end of block if in range. (More to do here.) --- Diffs of the changes: (+114 -109) ARMConstantIslandPass.cpp | 207 +++++++++++++++++++++++----------------------- README.txt | 16 ++- 2 files changed, 114 insertions(+), 109 deletions(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.27 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.28 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.27 Thu Feb 22 23:02:36 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Sat Feb 24 18:47:03 2007 @@ -4,6 +4,7 @@ // // This file was developed by Chris Lattner and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. +// Substantial modifications by Evan Cheng and Dale Johannesen. // //===----------------------------------------------------------------------===// // @@ -49,21 +50,19 @@ class VISIBILITY_HIDDEN ARMConstantIslands : public MachineFunctionPass { /// NextUID - Assign unique ID's to CPE's. unsigned NextUID; - + /// BBSizes - The size of each MachineBasicBlock in bytes of code, indexed /// by MBB Number. std::vector BBSizes; + /// BBOffsets - the offset of each MBB in bytes, starting from 0. + std::vector BBOffsets; + /// WaterList - A sorted list of basic blocks where islands could be placed /// (i.e. blocks that don't fall through to the following block, due /// to a return, unreachable, or unconditional branch). std::vector WaterList; - // WaterListOffsets - the offset of the beginning of each WaterList block. - // This is computed as needed in HandleConstantPoolUser; not necessarily - // valid at arbitrary times. - std::vector WaterListOffsets; - /// CPUser - One user of a constant pool, keeping the machine instruction /// pointer, the constant pool being referenced, and the max displacement /// allowed from the instruction to the CP. @@ -139,16 +138,17 @@ const std::vector &CPEMIs); MachineBasicBlock *SplitBlockBeforeInstr(MachineInstr *MI); void UpdateForInsertedWaterBlock(MachineBasicBlock *NewBB); + void AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta); bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI, unsigned Size); - void ComputeWaterListOffsets(MachineFunction &Fn); int LookForExistingCPEntry(CPUser& U, unsigned UserOffset); bool HandleConstantPoolUser(MachineFunction &Fn, CPUser &U); bool CPEIsInRange(MachineInstr *MI, unsigned UserOffset, MachineInstr *CPEMI, unsigned Disp, bool DoDump); - bool WaterIsInRange(unsigned UserOffset, - std::vector::iterator IP, + bool WaterIsInRange(unsigned UserOffset, MachineBasicBlock *Water, unsigned Disp); + bool OffsetIsInRange(unsigned UserOffset, unsigned TrialOffset, + unsigned Disp, bool NegativeOK); bool BBIsInRange(MachineInstr *MI, MachineBasicBlock *BB, unsigned Disp); bool FixUpImmediateBr(MachineFunction &Fn, ImmBranch &Br); bool FixUpConditionalBr(MachineFunction &Fn, ImmBranch &Br); @@ -156,7 +156,6 @@ bool UndoLRSpillRestore(); unsigned GetOffsetOf(MachineInstr *MI) const; - unsigned GetOffsetOf(MachineBasicBlock *MBB) const; }; } @@ -213,6 +212,7 @@ MadeChange |= UndoLRSpillRestore(); BBSizes.clear(); + BBOffsets.clear(); WaterList.clear(); CPUsers.clear(); CPEntries.clear(); @@ -293,6 +293,7 @@ /// and finding all of the constant pool users. void ARMConstantIslands::InitialFunctionScan(MachineFunction &Fn, const std::vector &CPEMIs) { + unsigned Offset = 0; for (MachineFunction::iterator MBBI = Fn.begin(), E = Fn.end(); MBBI != E; ++MBBI) { MachineBasicBlock &MBB = *MBBI; @@ -419,6 +420,8 @@ MBBSize += 2; BBSizes.push_back(MBBSize); + BBOffsets.push_back(Offset); + Offset += MBBSize; } } @@ -431,11 +434,7 @@ // The offset is composed of two things: the sum of the sizes of all MBB's // before this instruction's block, and the offset from the start of the block // it is in. - unsigned Offset = 0; - - // Sum block sizes before MBB. - for (unsigned BB = 0, e = MBB->getNumber(); BB != e; ++BB) - Offset += BBSizes[BB]; + unsigned Offset = BBOffsets[MBB->getNumber()]; // Sum instructions before MI in MBB. for (MachineBasicBlock::iterator I = MBB->begin(); ; ++I) { @@ -445,18 +444,6 @@ } } -/// GetOffsetOf - Return the current offset of the specified machine BB -/// from the start of the function. This offset changes as stuff is moved -/// around inside the function. -unsigned ARMConstantIslands::GetOffsetOf(MachineBasicBlock *MBB) const { - // Sum block sizes before MBB. - unsigned Offset = 0; - for (unsigned BB = 0, e = MBB->getNumber(); BB != e; ++BB) - Offset += BBSizes[BB]; - - return Offset; -} - /// CompareMBBNumbers - Little predicate function to sort the WaterList by MBB /// ID. static bool CompareMBBNumbers(const MachineBasicBlock *LHS, @@ -474,6 +461,9 @@ // Insert a size into BBSizes to align it properly with the (newly // renumbered) block numbers. BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); + + // Likewise for BBOffsets. + BBOffsets.insert(BBOffsets.begin()+NewBB->getNumber(), 0); // Next, update WaterList. Specifically, we need to add NewMBB as having // available water after it. @@ -528,6 +518,9 @@ // renumbered) block numbers. BBSizes.insert(BBSizes.begin()+NewBB->getNumber(), 0); + // Likewise for BBOffsets. + BBOffsets.insert(BBOffsets.begin()+NewBB->getNumber(), 0); + // Next, update WaterList. Specifically, we need to add OrigMBB as having // available water after it (but not if it's already there, which happens // when splitting before a conditional branch that is followed by an @@ -547,44 +540,57 @@ I != E; ++I) NewBBSize += ARM::GetInstSize(I); + unsigned OrigBBI = OrigBB->getNumber(); + unsigned NewBBI = NewBB->getNumber(); // Set the size of NewBB in BBSizes. - BBSizes[NewBB->getNumber()] = NewBBSize; + BBSizes[NewBBI] = NewBBSize; // We removed instructions from UserMBB, subtract that off from its size. // Add 2 or 4 to the block to count the unconditional branch we added to it. - BBSizes[OrigBB->getNumber()] -= NewBBSize - (isThumb ? 2 : 4); + unsigned delta = isThumb ? 2 : 4; + BBSizes[OrigBBI] -= NewBBSize - delta; + + // ...and adjust BBOffsets for NewBB accordingly. + BBOffsets[NewBBI] = BBOffsets[OrigBBI] + BBSizes[OrigBBI]; + + // All BBOffsets following these blocks must be modified. + AdjustBBOffsetsAfter(NewBB, delta); return NewBB; } +//// OffsetIsInRange - Checks whether UserOffset is within MaxDisp of +/// TrialOffset. +bool ARMConstantIslands::OffsetIsInRange(unsigned UserOffset, + unsigned TrialOffset, unsigned MaxDisp, bool NegativeOK) { + if (UserOffset <= TrialOffset) { + // User before the Trial. + if (TrialOffset-UserOffset <= MaxDisp) + return true; + } else if (NegativeOK) { + if (UserOffset-TrialOffset <= MaxDisp) + return true; + } + return false; +} + /// WaterIsInRange - Returns true if a CPE placed after the specified /// Water (a basic block) will be in range for the specific MI. bool ARMConstantIslands::WaterIsInRange(unsigned UserOffset, - std::vector::iterator IP, - unsigned MaxDisp) + MachineBasicBlock* Water, unsigned MaxDisp) { - MachineBasicBlock *Water = *IP; - unsigned Index = IP - WaterList.begin(); - unsigned CPEOffset = WaterListOffsets[Index] + + bool isThumb = AFI->isThumbFunction(); + unsigned CPEOffset = BBOffsets[Water->getNumber()] + BBSizes[Water->getNumber()]; // If the Water is a constpool island, it has already been aligned. // If not, align it. - if (AFI->isThumbFunction() && + if (isThumb && (Water->empty() || Water->begin()->getOpcode() != ARM::CONSTPOOL_ENTRY)) CPEOffset += 2; - if (UserOffset <= CPEOffset) { - // User before the CPE. - if (CPEOffset-UserOffset <= MaxDisp) - return true; - } else if (!AFI->isThumbFunction()) { - // Thumb LDR cannot encode negative offset. - if (UserOffset-CPEOffset <= MaxDisp) - return true; - } - return false; + return OffsetIsInRange (UserOffset, CPEOffset, MaxDisp, !isThumb); } /// CPEIsInRange - Returns true if the distance between specific MI and @@ -594,7 +600,8 @@ unsigned MaxDisp, bool DoDump) { // In thumb mode, pessimistically assumes the .align 2 before the first CPE // in the island adds two byte padding. - unsigned AlignAdj = AFI->isThumbFunction() ? 2 : 0; + bool isThumb = AFI->isThumbFunction(); + unsigned AlignAdj = isThumb ? 2 : 0; unsigned CPEOffset = GetOffsetOf(CPEMI) + AlignAdj; if (DoDump) { @@ -605,16 +612,7 @@ << " offset=" << int(CPEOffset-UserOffset) << "\t" << *MI; } - if (UserOffset <= CPEOffset) { - // User before the CPE. - if (CPEOffset-UserOffset <= MaxDisp) - return true; - } else if (!AFI->isThumbFunction()) { - // Thumb LDR cannot encode negative offset. - if (UserOffset-CPEOffset <= MaxDisp) - return true; - } - return false; + return OffsetIsInRange(UserOffset, CPEOffset, MaxDisp, !isThumb); } /// BBIsJumpedOver - Return true of the specified basic block's only predecessor @@ -631,6 +629,13 @@ return false; } +void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta) +{ + MachineFunction::iterator MBBI = BB->getParent()->end(); + for(int i=BB->getNumber()+1; i<=prior(MBBI)->getNumber(); i++) + BBOffsets[i] += delta; +} + /// DecrementOldEntry - find the constant pool entry with index CPI /// and instruction CPEMI, and decrement its refcount. If the refcount /// becomes 0 remove the entry and instruction. Returns true if we removed @@ -647,14 +652,21 @@ // In thumb mode, the size of island is padded by two to compensate for // the alignment requirement. Thus it will now be 2 when the block is // empty, so fix this. - BBSizes[OldCPEBB->getNumber()] = 0; + // All succeeding offsets have the current size value added in, fix this. + if (BBSizes[OldCPEBB->getNumber()] != 0) { + AdjustBBOffsetsAfter(OldCPEBB, -BBSizes[OldCPEBB->getNumber()]); + BBSizes[OldCPEBB->getNumber()] = 0; + } // An island has only one predecessor BB and one successor BB. Check if // this BB's predecessor jumps directly to this BB's successor. This // shouldn't happen currently. assert(!BBIsJumpedOver(OldCPEBB) && "How did this happen?"); // FIXME: remove the empty blocks after all the work is done? - } else + } else { BBSizes[OldCPEBB->getNumber()] -= Size; + // All succeeding offsets have the current size value added in, fix this. + AdjustBBOffsetsAfter(OldCPEBB, -Size); + } OldCPE->CPEMI->eraseFromParent(); OldCPE->CPEMI = NULL; NumCPEs--; @@ -663,25 +675,6 @@ return false; } -/// ComputeWaterListOffsets - just what you think. -/// This vector is built to avoid re-adding BBSizes for each WaterBB under test -/// (which would cause the algorithm to be n^2). -void ARMConstantIslands::ComputeWaterListOffsets(MachineFunction &Fn) { - unsigned WaterListIndex = 0; - unsigned Offset = 0; - unsigned BB = 0; - WaterListOffsets.clear(); - for (MachineFunction::iterator MBBI = Fn.begin(), E = Fn.end(); - MBBI != E; ++BB, ++MBBI) { - MachineBasicBlock *MBB = MBBI; - if (MBB == WaterList[WaterListIndex]) { - WaterListOffsets.push_back(Offset); - WaterListIndex++; - } - Offset += BBSizes[BB]; - } -} - /// LookForCPEntryInRange - see if the currently referenced CPE is in range; /// if not, see if an in-range clone of the CPE is in range, and if so, /// change the data structures so the user references the clone. Returns: @@ -759,15 +752,10 @@ // we might find some that are backwards). bool WaterFound = false; if (!WaterList.empty()) { - // Compute offsets for the blocks in the current WaterList. - // It is a big compile-time speed win to do this only once - // rather than for each WaterList entry. - ComputeWaterListOffsets(Fn); - assert(WaterList.size() == WaterListOffsets.size()); for (std::vector::iterator IP = prior(WaterList.end()), B = WaterList.begin();; --IP) { MachineBasicBlock* WaterBB = *IP; - if (WaterIsInRange(UserOffset, IP, U.MaxDisp)) { + if (WaterIsInRange(UserOffset, WaterBB, U.MaxDisp)) { WaterFound = true; DOUT << "found water in range\n"; // CPE goes before following block (NewMBB). @@ -786,23 +774,40 @@ if (!WaterFound) { // No water found. - // Solution of last resort: split the user's MBB right after the user - // and insert a clone of the CPE into the newly created water. DOUT << "No water found\n"; MachineBasicBlock *UserMBB = UserMI->getParent(); - - // TODO: Search for the best place to split the code. In practice, using - // loop nesting information to insert these guys outside of loops would be - // sufficient. - if (&UserMBB->back() == UserMI) { - assert(BBHasFallthrough(UserMBB) && "Expected a fallthrough BB!"); + unsigned TrialOffset = BBOffsets[UserMBB->getNumber()] + + BBSizes[UserMBB->getNumber()] + + isThumb ? 2 : 4; /* for branch to be added */ + + // If the use is at the end of the block, or the end of the block + // is within range, make new water there. (If the block ends in + // an unconditional branch already, it is water, and is known to + // be out of range; so it's OK to assume above we'll be adding a Br.) + if (&UserMBB->back() == UserMI || + OffsetIsInRange(UserOffset, TrialOffset, U.MaxDisp, !isThumb)) { + if (&UserMBB->back() == UserMI) + assert(BBHasFallthrough(UserMBB) && "Expected a fallthrough BB!"); NewMBB = next(MachineFunction::iterator(UserMBB)); // Add an unconditional branch from UserMBB to fallthrough block. // Note the new unconditional branch is not being recorded. BuildMI(UserMBB, TII->get(isThumb ? ARM::tB : ARM::B)).addMBB(NewMBB); - BBSizes[UserMBB->getNumber()] += isThumb ? 2 : 4; + int delta = isThumb ? 2 : 4; + BBSizes[UserMBB->getNumber()] += delta; + AdjustBBOffsetsAfter(UserMBB, delta); } else { + // What a big block. Find a place within the block to split it. + // This is a little tricky on Thumb since instructions are 2 bytes + // and constant pool entries are 4 bytes: if instruction I references + // island CPE, and instruction I+1 references CPE', it will + // not work well to put CPE as far forward as possible, since then + // CPE' cannot immediately follow it (that location is 2 bytes + // farther away from I+1 than CPE was from I) and we'd need to create + // a new island. + + // Solution of last resort: split the user's MBB right after the user + // and insert a clone of the CPE into the newly created water. MachineInstr *NextMI = next(MachineBasicBlock::iterator(UserMI)); NewMBB = SplitBlockBeforeInstr(NextMI); } @@ -829,6 +834,8 @@ if (isThumb) Size += 2; // Increase the size of the island block to account for the new entry. BBSizes[NewIsland->getNumber()] += Size; + BBOffsets[NewIsland->getNumber()] = BBOffsets[NewMBB->getNumber()]; + AdjustBBOffsetsAfter(NewIsland, Size); // Finally, change the CPI in the instruction operand to be ID. for (unsigned i = 0, e = UserMI->getNumOperands(); i != e; ++i) @@ -848,21 +855,14 @@ unsigned MaxDisp) { unsigned PCAdj = AFI->isThumbFunction() ? 4 : 8; unsigned BrOffset = GetOffsetOf(MI) + PCAdj; - unsigned DestOffset = GetOffsetOf(DestBB); + unsigned DestOffset = BBOffsets[DestBB->getNumber()]; DOUT << "Branch of destination BB#" << DestBB->getNumber() << " from BB#" << MI->getParent()->getNumber() << " max delta=" << MaxDisp << " at offset " << int(DestOffset-BrOffset) << "\t" << *MI; - if (BrOffset <= DestOffset) { - if (DestOffset - BrOffset <= MaxDisp) - return true; - } else { - if (BrOffset - DestOffset <= MaxDisp) - return true; - } - return false; + return OffsetIsInRange(BrOffset, DestOffset, MaxDisp, true); } /// FixUpImmediateBr - Fix up an immediate branch whose destination is too far @@ -894,6 +894,7 @@ Br.MaxDisp = (1 << 21) * 2; MI->setInstrDescriptor(TII->get(ARM::tBfar)); BBSizes[MBB->getNumber()] += 2; + AdjustBBOffsetsAfter(MBB, 2); HasFarJump = true; NumUBrFixed++; @@ -977,7 +978,9 @@ MI->eraseFromParent(); // Increase the size of MBB to account for the new unconditional branch. - BBSizes[MBB->getNumber()] += ARM::GetInstSize(&MBB->back()); + int delta = ARM::GetInstSize(&MBB->back()); + BBSizes[MBB->getNumber()] += delta; + AdjustBBOffsetsAfter(MBB, delta); return true; } Index: llvm/lib/Target/ARM/README.txt diff -u llvm/lib/Target/ARM/README.txt:1.12 llvm/lib/Target/ARM/README.txt:1.13 --- llvm/lib/Target/ARM/README.txt:1.12 Thu Feb 22 23:02:36 2007 +++ llvm/lib/Target/ARM/README.txt Sat Feb 24 18:47:03 2007 @@ -21,17 +21,19 @@ previous version of this document have been addressed. However, there are still things that can be done: -1. When there isn't an existing water, the current MBB is split right after the -use. It would be profitable to look farther forward, especially on Thumb, +1. When there isn't an existing water, the current MBB is split right after +the use. It would be profitable to look farther forward, especially on Thumb, where negative offsets won't work. +Now it will put the island at the end of the block if that is in range. If it +is not in range things still work as above, which is poor on Thumb. -2. WaterBlockListOffsets might be maintained throughout, rather than computed -when it is needed. This would probably lead to faster compile times. -Similarly, the offsets of blocks might be maintained throughout. - -3. There may be some advantage to trying to be smarter about the initial +2. There may be some advantage to trying to be smarter about the initial placement, rather than putting everything at the end. +3. The handling of 2-byte padding for Thumb is overly conservative. There +would be a small gain to keeping accurate track of the padding (which would +require aligning functions containing constant pools to 4-byte boundaries). + //===---------------------------------------------------------------------===// We need to start generating predicated instructions. The .td files have a way From reid at x10sys.com Sat Feb 24 18:57:01 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 18:57:01 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702250057.l1P0v1j8023913@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.36 -> 1.37 --- Log message: Fix the > 64 bits case for left shift. --- Diffs of the changes: (+52 -27) APInt.cpp | 79 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 52 insertions(+), 27 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.36 llvm/lib/Support/APInt.cpp:1.37 --- llvm/lib/Support/APInt.cpp:1.36 Sat Feb 24 14:38:01 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 18:56:44 2007 @@ -946,34 +946,59 @@ /// @brief Left-shift function. APInt APInt::shl(uint32_t shiftAmt) const { assert(shiftAmt <= BitWidth && "Invalid shift amount"); - APInt API(*this); - if (API.isSingleWord()) { + if (isSingleWord()) { if (shiftAmt == BitWidth) - API.VAL = 0; - else - API.VAL <<= shiftAmt; - API.clearUnusedBits(); - return API; - } - - if (shiftAmt == BitWidth) { - memset(API.pVal, 0, getNumWords() * APINT_WORD_SIZE); - return API; - } - - if (uint32_t offset = shiftAmt / APINT_BITS_PER_WORD) { - for (uint32_t i = API.getNumWords() - 1; i > offset - 1; --i) - API.pVal[i] = API.pVal[i-offset]; - memset(API.pVal, 0, offset * APINT_WORD_SIZE); - } - shiftAmt %= APINT_BITS_PER_WORD; - uint32_t i; - for (i = API.getNumWords() - 1; i > 0; --i) - API.pVal[i] = (API.pVal[i] << shiftAmt) | - (API.pVal[i-1] >> (APINT_BITS_PER_WORD - shiftAmt)); - API.pVal[i] <<= shiftAmt; - API.clearUnusedBits(); - return API; + return APInt(BitWidth, 0); // avoid undefined shift results + return APInt(BitWidth, (VAL << shiftAmt) & + (~uint64_t(0ULL) >> + (APINT_BITS_PER_WORD - BitWidth))); + } + + // If all the bits were shifted out, the result is 0. This avoids issues + // with shifting by the size of the integer type, which produces undefined + // results. We define these "undefined results" to always be 0. + if (shiftAmt == BitWidth) + return APInt(BitWidth, 0); + + // Create some space for the result. + uint64_t * val = new uint64_t[getNumWords()]; + + // If we are shifting less than a word, do it the easy way + if (shiftAmt < APINT_BITS_PER_WORD) { + uint64_t carry = 0; + shiftAmt %= APINT_BITS_PER_WORD; + for (uint32_t i = 0; i < getNumWords(); i++) { + val[i] = pVal[i] << shiftAmt | carry; + carry = pVal[i] >> (APINT_BITS_PER_WORD - shiftAmt); + } + val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); + return APInt(val, BitWidth); + } + + // Compute some values needed by the remaining shift algorithms + uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD; + uint32_t offset = shiftAmt / APINT_BITS_PER_WORD; + + // If we are shifting whole words, just move whole words + if (wordShift == 0) { + for (uint32_t i = 0; i < offset; i++) + val[i] = 0; + for (uint32_t i = offset; i < getNumWords(); i++) + val[i] = pVal[i-offset]; + val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); + return APInt(val,BitWidth); + } + + // Copy whole words from this to Result. + uint32_t i = getNumWords() - 1; + for (; i > offset; --i) + val[i] = pVal[i-offset] << wordShift | + pVal[i-offset-1] >> (APINT_BITS_PER_WORD - wordShift); + val[offset] = pVal[offset-1] << wordShift; + for (i = 0; i < offset; ++i) + val[i] = 0; + val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); + return APInt(val, BitWidth); } /// Implementation of Knuth's Algorithm D (Division of nonnegative integers) From reid at x10sys.com Sat Feb 24 19:09:15 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 19:09:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702250109.l1P19FAl024099@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.37 -> 1.38 --- Log message: Whoops, last word with bits in large shift left wasn't correct. --- Diffs of the changes: (+1 -1) APInt.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.37 llvm/lib/Support/APInt.cpp:1.38 --- llvm/lib/Support/APInt.cpp:1.37 Sat Feb 24 18:56:44 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 19:08:58 2007 @@ -994,7 +994,7 @@ for (; i > offset; --i) val[i] = pVal[i-offset] << wordShift | pVal[i-offset-1] >> (APINT_BITS_PER_WORD - wordShift); - val[offset] = pVal[offset-1] << wordShift; + val[offset] = pVal[0] << wordShift; for (i = 0; i < offset; ++i) val[i] = 0; val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); From sabre at nondot.org Sat Feb 24 19:11:53 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 19:11:53 -0600 Subject: [llvm-commits] CVS: llvm/docs/HowToSubmitABug.html Message-ID: <200702250111.l1P1BrRe024187@zion.cs.uiuc.edu> Changes in directory llvm/docs: HowToSubmitABug.html updated: 1.28 -> 1.29 --- Log message: update this for llvm-gcc4 --- Diffs of the changes: (+78 -94) HowToSubmitABug.html | 172 +++++++++++++++++++++++---------------------------- 1 files changed, 78 insertions(+), 94 deletions(-) Index: llvm/docs/HowToSubmitABug.html diff -u llvm/docs/HowToSubmitABug.html:1.28 llvm/docs/HowToSubmitABug.html:1.29 --- llvm/docs/HowToSubmitABug.html:1.28 Fri Feb 23 21:46:42 2007 +++ llvm/docs/HowToSubmitABug.html Sat Feb 24 19:11:36 2007 @@ -19,9 +19,8 @@
  • Crashing Bugs
  • Miscompilations
  • Incorrect code generation (JIT and LLC)
  • @@ -51,15 +50,18 @@

    Basically you have to do two things at a minimum. First, decide whether the bug crashes the compiler (or an LLVM pass), or if the -compiler is miscompiling the program. Based on +compiler is miscompiling the program (i.e., the +compiler successfully produces an executable, but it doesn't run right). Based +on what type of bug it is, follow the instructions in the linked section to narrow down the bug so that the person who fixes it will be able to find the problem more easily.

    Once you have a reduced test-case, go to the LLVM Bug Tracking -System, select the category in which the bug falls, and fill out the form -with the necessary details. The bug description should contain the following +System and fill out the form with the necessary details (note that you don't +need to pick a catagory, just use the "new-bugs" catagory if you're not sure). +The bug description should contain the following information:

      @@ -81,35 +83,29 @@
      -

      More often than not, bugs in the compiler cause it to crash—often due to an -assertion failure of some sort. If you are running opt -directly, and something crashes, jump to the section on -bugs in LLVM passes. Otherwise, the most important -piece of the puzzle is to figure out if it is the GCC-based front-end that is -buggy or if it's one of the LLVM tools that has problems.

      +

      More often than not, bugs in the compiler cause it to crash—often due +to an assertion failure of some sort. The most important +piece of the puzzle is to figure out if it is crashing in the GCC front-end +or if it is one of the LLVM libraries (e.g. the optimizer or code generator) +that has problems.

      -

      To figure out which program is crashing (the front-end, -gccas, or gccld), run the +

      To figure out which component is crashing (the front-end, +optimizer or code generator), run the llvm-gcc command line as you were when the crash occurred, but -add a -v option to the command line. The compiler will print out a -bunch of stuff, and should end with telling you that one of -cc1/cc1plus, gccas, or -gccld crashed.

      +with the following extra command line options:

        +
      • -O0 -emit-llvm: If llvm-gcc still crashes when + passed these options (which disable the optimizer and code generator), then + the crash is in the front-end. Jump ahead to the section on front-end bugs.
      • + +
      • -emit-llvm: If llvm-gcc crashes with this option + (which disables the code generator), you found an optimizer bug. Jump ahead + to compile-time optimization bugs.
      • -
      • If cc1 or cc1plus crashed, you found a - problem with the front-end. - Jump ahead to the section on front-end bugs.
      • - -
      • If gccas crashed, you found a bug in one - of the passes in gccas.
      • - -
      • If gccld crashed, you found a bug in one - of the passes in gccld.
      • - -
      • Otherwise, something really weird happened. Email the list with what you - have at this point.
      • +
      • Otherwise, you have a code generator crash. Jump ahead to code generator bugs.
      @@ -126,9 +122,10 @@ llvm-gcc command that resulted in the crash, but add the -save-temps option. The compiler will crash again, but it will leave behind a foo.i file (containing preprocessed C source code) and -possibly foo.s (containing LLVM assembly code) for each +possibly foo.s for each compiled foo.c file. Send us the foo.i file, -along with a brief description of the error it caused.

      +along with the options you passed to llvm-gcc, and a brief description of the +error it caused.

      The delta tool helps to reduce the preprocessed file down to the smallest amount of code that still replicates the @@ -141,81 +138,72 @@

      -

      If you find that a bug crashes in the gccas stage of -compilation, compile your test-case to a .s file with the --save-temps option to llvm-gcc. Then run:

      +

      If you find that a bug crashes in the optimizer, compile your test-case to a +.bc file by passing "-emit-llvm -O0 -c -o foo.bc". +Then run:

      -

      gccas -debug-pass=Arguments < /dev/null -o - > /dev/null

      -
      - -

      ... which will print a list of arguments, indicating the list of passes that -gccas runs. Once you have the input file and the list of -passes, go to the section on debugging bugs in LLVM -passes.

      - +

      opt -std-compile-opts -debug-pass=Arguments foo.bc + -disable-output

      - - - -
      +

      This command should do two things: it should print out a list of passes, and +then it should crash in the same was as llvm-gcc. If it doesn't crash, please +follow the instructions for a front-end bug.

      -

      If you find that a bug crashes in the gccld stage of -compilation, gather all of the .o bytecode files and libraries that are -being linked together (the "llvm-gcc -v" output should include -the full list of objects linked). Then run:

      +

      If this does crash, then you should be able to debug this with the following +bugpoint command:

      -

      llvm-as < /dev/null > null.bc
      -gccld -debug-pass=Arguments null.bc
      -

      +

      bugpoint foo.bc <list of passes printed by +opt>

      -

      ... which will print a list of arguments, indicating the list of passes that -gccld runs. Once you have the input files and the list of -passes, go to the section on debugging bugs in LLVM -passes.

      +

      Please run this, then file a bug with the instructions and reduced .bc files +that bugpoint emits. If something goes wrong with bugpoint, please submit the +"foo.bc" file and the list of passes printed by opt.

      -

      At this point, you should have some number of LLVM assembly files or bytecode -files and a list of passes which crash when run on the specified input. In -order to reduce the list of passes (which is probably large) and the input to -something tractable, use the bugpoint tool as follows:

      +

      If you find a bug that crashes llvm-gcc in the code generator, compile your +source file to a .bc file by passing "-emit-llvm -c -o foo.bc" +to llvm-gcc (in addition to the options you already pass). Once your have +foo.bc, one of the following commands should fail:

      -
      -

      bugpoint <input files> <list of passes>

      -
      +
        +
      1. llc foo.bc -f
      2. +
      3. llc foo.bc -f -relocation-model=pic
      4. +
      5. llc foo.bc -f -relocation-model=static
      6. +
      -

      bugpoint will print a bunch of output as it reduces the -test-case, but it should eventually print something like this:

      +

      If none of these crash, please follow the instructions for a +front-end bug. If one of these do crash, you should +be able to reduce this with one of the following bugpoint command lines (use +the one corresponding to the command above that failed):

      -
      -

      -...
      -Emitted bytecode to 'bugpoint-reduced-simplified.bc'
      -
      -*** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -licm
      -

      -
      +
        +
      1. bugpoint -run-llc foo.bc --tool-args
      2. +
      3. bugpoint -run-llc foo.bc --tool-args + -relocation-model=pic
      4. +
      5. bugpoint -run-llc foo.bc --tool-args + -relocation-model=static
      6. +
      -

      Once you complete this, please send the LLVM bytecode file and the command -line to reproduce the problem to the llvmbugs mailing list.

      +

      Please run this, then file a bug with the instructions and reduced .bc file +that bugpoint emits. If something goes wrong with bugpoint, please submit the +"foo.bc" file and the option that llc crashes with.

      @@ -227,18 +215,14 @@
      -

      A miscompilation occurs when a pass does not correctly transform a program, -thus producing errors that are only noticed during execution. This is different -from producing invalid LLVM code (i.e., code not in SSA form, using values -before defining them, etc.) which the verifier will check for after a pass -finishes its run.

      - -

      If it looks like the LLVM compiler is miscompiling a program, the very first -thing to check is to make sure it is not using undefined behavior. In -particular, check to see if the program valgrinds clean, passes purify, or some -other memory checker tool. Many of the "LLVM bugs" that we have chased down -ended up being bugs in the program being compiled, not LLVM.

      +

      If llvm-gcc successfully produces an executable, but that executable doesn't +run right, this is either a bug in the code or a bug in the +compiler. The first thing to check is to make sure it is not using undefined +behavior (e.g. reading a variable before it is defined). In particular, check +to see if the program valgrinds clean, +passes purify, or some other memory checker tool. Many of the "LLVM bugs" that +we have chased down ended up being bugs in the program being compiled, not + LLVM.

      Once you determine that the program itself is not buggy, you should choose which code generator you wish to compile the program with (e.g. C backend, the @@ -356,7 +340,7 @@ Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2007/02/24 03:46:42 $ + Last modified: $Date: 2007/02/25 01:11:36 $ From clattner at apple.com Sat Feb 24 19:23:23 2007 From: clattner at apple.com (clattner at apple.com) Date: Sat, 24 Feb 2007 17:23:23 -0800 (PST) Subject: [llvm-commits] [124287] Fix PR1221, which is subtle fallout from the symtab change. Message-ID: <20070225012323.6CB68636E940@src> Revision: 124287 Author: clattner Date: 2007-02-24 17:23:21 -0800 (Sat, 24 Feb 2007) Log Message: ----------- Fix PR1221, which is subtle fallout from the symtab change. "getName().c_str()" now cannot be used, because the string returned by getName() is temporary and is destroyed when the expression is fully evaluated. Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-backend.cpp Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-24 22:46:38 UTC (rev 124286) +++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 01:23:21 UTC (rev 124287) @@ -45,6 +45,7 @@ #include "llvm/Analysis/LoadValueNumbering.h" #include "llvm/Transforms/IPO.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" #include "llvm/Support/Streams.h" #include "llvm/Support/ManagedStatic.h" #include @@ -860,7 +861,7 @@ /// llvm_get_decl_name - Used by varasm.c, returns the specified declaration's /// name. const char *llvm_get_decl_name(void *LLVM) { - return ((Value*)LLVM)->getName().c_str(); + return ((Value*)LLVM)->getValueName()->getKeyData(); } // llvm_mark_decl_weak - Used by varasm.c, called when a decl is found to be From sabre at nondot.org Sat Feb 24 19:28:21 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 19:28:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200702250128.l1P1SLna024544@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: TargetLowering.cpp updated: 1.94 -> 1.95 --- Log message: initialize a instance variable --- Diffs of the changes: (+1 -0) TargetLowering.cpp | 1 + 1 files changed, 1 insertion(+) Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp diff -u llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.94 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.95 --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:1.94 Fri Feb 23 20:09:29 2007 +++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Sat Feb 24 19:28:05 2007 @@ -148,6 +148,7 @@ allowUnalignedMemoryAccesses = false; UseUnderscoreSetJmp = false; UseUnderscoreLongJmp = false; + SelectIsExpensive = false; IntDivIsCheap = false; Pow2DivIsCheap = false; StackPointerRegisterToSaveRestore = 0; From dalej at apple.com Sat Feb 24 19:42:53 2007 From: dalej at apple.com (Dale Johannesen) Date: Sat, 24 Feb 2007 19:42:53 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <200702250142.l1P1grPd024969@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.28 -> 1.29 --- Log message: remove crediting of Evan Cheng and me. --- Diffs of the changes: (+0 -1) ARMConstantIslandPass.cpp | 1 - 1 files changed, 1 deletion(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.28 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.29 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.28 Sat Feb 24 18:47:03 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Sat Feb 24 19:42:36 2007 @@ -4,7 +4,6 @@ // // This file was developed by Chris Lattner and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// Substantial modifications by Evan Cheng and Dale Johannesen. // //===----------------------------------------------------------------------===// // From reid at x10sys.com Sat Feb 24 19:56:24 2007 From: reid at x10sys.com (Reid Spencer) Date: Sat, 24 Feb 2007 19:56:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702250156.l1P1uOWf025296@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.38 -> 1.39 --- Log message: Clean up lshr and ashr to coding standards. Handle the single word cases for shiftAmt == BitWidth. --- Diffs of the changes: (+79 -53) APInt.cpp | 132 +++++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 79 insertions(+), 53 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.38 llvm/lib/Support/APInt.cpp:1.39 --- llvm/lib/Support/APInt.cpp:1.38 Sat Feb 24 19:08:58 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 19:56:07 2007 @@ -894,52 +894,59 @@ /// Arithmetic right-shift this APInt by shiftAmt. /// @brief Arithmetic right-shift function. APInt APInt::ashr(uint32_t shiftAmt) const { - APInt API(*this); - if (API.isSingleWord()) - API.VAL = - (((int64_t(API.VAL) << (APINT_BITS_PER_WORD - API.BitWidth)) >> - (APINT_BITS_PER_WORD - API.BitWidth)) >> shiftAmt) & - (~uint64_t(0UL) >> (APINT_BITS_PER_WORD - API.BitWidth)); - else { - if (shiftAmt >= API.BitWidth) { - memset(API.pVal, API[API.BitWidth-1] ? 1 : 0, - (API.getNumWords()-1) * APINT_WORD_SIZE); - API.pVal[API.getNumWords() - 1] = - ~uint64_t(0UL) >> - (APINT_BITS_PER_WORD - API.BitWidth % APINT_BITS_PER_WORD); - } else { - uint32_t i = 0; - for (; i < API.BitWidth - shiftAmt; ++i) - if (API[i+shiftAmt]) - API.set(i); - else - API.clear(i); - for (; i < API.BitWidth; ++i) - if (API[API.BitWidth-1]) - API.set(i); - else API.clear(i); - } + if (isSingleWord()) { + if (shiftAmt == BitWidth) + return APInt(BitWidth, -1ull); + else + return APInt(BitWidth, + (((int64_t(VAL) << (APINT_BITS_PER_WORD - BitWidth)) >> + (APINT_BITS_PER_WORD - BitWidth)) >> shiftAmt) & + (~uint64_t(0UL) >> (APINT_BITS_PER_WORD - BitWidth))); + } + + APInt Result(*this); + if (shiftAmt >= BitWidth) { + memset(Result.pVal, Result[BitWidth-1] ? 1 : 0, + (getNumWords()-1) * APINT_WORD_SIZE); + Result.pVal[getNumWords() - 1] = ~uint64_t(0UL) >> + (APINT_BITS_PER_WORD - BitWidth % APINT_BITS_PER_WORD); + } else { + uint32_t i = 0; + for (; i < BitWidth - shiftAmt; ++i) + if (Result[i+shiftAmt]) + Result.set(i); + else + Result.clear(i); + for (; i < BitWidth; ++i) + if (Result[BitWidth-1]) + Result.set(i); + else + Result.clear(i); } - return API; + return Result; } /// Logical right-shift this APInt by shiftAmt. /// @brief Logical right-shift function. APInt APInt::lshr(uint32_t shiftAmt) const { - APInt API(*this); - if (API.isSingleWord()) - API.VAL >>= shiftAmt; - else { - if (shiftAmt >= API.BitWidth) - memset(API.pVal, 0, API.getNumWords() * APINT_WORD_SIZE); - uint32_t i = 0; - for (i = 0; i < API.BitWidth - shiftAmt; ++i) - if (API[i+shiftAmt]) API.set(i); - else API.clear(i); - for (; i < API.BitWidth; ++i) - API.clear(i); - } - return API; + if (isSingleWord()) + if (shiftAmt == BitWidth) + return APInt(BitWidth, 0); + else + return APInt(BitWidth, this->VAL >> shiftAmt); + + APInt Result(*this); + if (shiftAmt >= Result.BitWidth) + memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); + uint32_t i = 0; + for (i = 0; i < Result.BitWidth - shiftAmt; ++i) + if (Result[i+shiftAmt]) + Result.set(i); + else + Result.clear(i); + for (; i < Result.BitWidth; ++i) + Result.clear(i); + return Result; } /// Left-shift this APInt by shiftAmt. @@ -1197,8 +1204,29 @@ uint64_t mask = ~0ull >> (sizeof(uint32_t)*8); uint32_t n = rhsWords * 2; uint32_t m = (lhsWords * 2) - n; - // FIXME: allocate space on stack if m and n are sufficiently small. - uint32_t *U = new uint32_t[m + n + 1]; + + // Allocate space for the temporary values we need either on the stack, if + // it will fit, or on the heap if it won't. + uint32_t SPACE[128]; + uint32_t *U = 0; + uint32_t *V = 0; + uint32_t *Q = 0; + uint32_t *R = 0; + if ((Remainder?4:3)*n+2*m+1 <= 128) { + U = &SPACE[0]; + V = &SPACE[m+n+1]; + Q = &SPACE[(m+n+1) + n]; + if (Remainder) + R = &SPACE[(m+n+1) + n + (m+n)]; + } else { + U = new uint32_t[m + n + 1]; + V = new uint32_t[n]; + Q = new uint32_t[m+n]; + if (Remainder) + R = new uint32_t[n]; + } + + // Initialize the dividend memset(U, 0, (m+n+1)*sizeof(uint32_t)); for (unsigned i = 0; i < lhsWords; ++i) { uint64_t tmp = (LHS.getNumWords() == 1 ? LHS.VAL : LHS.pVal[i]); @@ -1207,7 +1235,7 @@ } U[m+n] = 0; // this extra word is for "spill" in the Knuth algorithm. - uint32_t *V = new uint32_t[n]; + // Initialize the divisor memset(V, 0, (n)*sizeof(uint32_t)); for (unsigned i = 0; i < rhsWords; ++i) { uint64_t tmp = (RHS.getNumWords() == 1 ? RHS.VAL : RHS.pVal[i]); @@ -1215,14 +1243,10 @@ V[i * 2 + 1] = tmp >> (sizeof(uint32_t)*8); } - // Set up the quotient and remainder - uint32_t *Q = new uint32_t[m+n]; + // initialize the quotient and remainder memset(Q, 0, (m+n) * sizeof(uint32_t)); - uint32_t *R = 0; - if (Remainder) { - R = new uint32_t[n]; + if (Remainder) memset(R, 0, n * sizeof(uint32_t)); - } // Now, adjust m and n for the Knuth division. n is the number of words in // the divisor. m is the number of words by which the dividend exceeds the @@ -1332,10 +1356,12 @@ } // Clean up the memory we allocated. - delete [] U; - delete [] V; - delete [] Q; - delete [] R; + if (U != &SPACE[0]) { + delete [] U; + delete [] V; + delete [] Q; + delete [] R; + } } /// Unsigned divide this APInt by APInt RHS. From clattner at apple.com Sat Feb 24 19:59:16 2007 From: clattner at apple.com (Chris Lattner) Date: Sat, 24 Feb 2007 17:59:16 -0800 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp In-Reply-To: <200702250156.l1P1uOWf025296@zion.cs.uiuc.edu> References: <200702250156.l1P1uOWf025296@zion.cs.uiuc.edu> Message-ID: <2C32D05D-2B8D-4384-9D8C-714FBF7969E8@apple.com> > / Clean up the memory we allocated. > - delete [] U; > - delete [] V; > - delete [] Q; > - delete [] R; > + if (U != &SPACE[0]) { > + delete [] U; > + delete [] V; > + delete [] Q; > + delete [] R; > + } > } Please just use SmallVector instead of explicitly doing it yourself. -Chris From sabre at nondot.org Sat Feb 24 20:28:38 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 20:28:38 -0600 Subject: [llvm-commits] CVS: llvm/LICENSE.TXT Message-ID: <200702250228.l1P2Sc9Z025813@zion.cs.uiuc.edu> Changes in directory llvm: LICENSE.TXT updated: 1.29 -> 1.30 --- Log message: remove these. --- Diffs of the changes: (+0 -1) LICENSE.TXT | 1 - 1 files changed, 1 deletion(-) Index: llvm/LICENSE.TXT diff -u llvm/LICENSE.TXT:1.29 llvm/LICENSE.TXT:1.30 --- llvm/LICENSE.TXT:1.29 Thu Jan 18 15:22:36 2007 +++ llvm/LICENSE.TXT Sat Feb 24 20:28:21 2007 @@ -63,7 +63,6 @@ ------- --------- System Library llvm/lib/System Compiler Driver llvm/tools/llvmc -PowerPC Backend llvm/lib/Target/PowerPC bzip2 llvm/lib/Support/bzip2/LICENSE Autoconf llvm/autoconf llvm/projects/ModuleMaker/autoconf From sabre at nondot.org Sat Feb 24 20:33:00 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 20:33:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702250233.l1P2X05I025999@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.39 -> 1.40 --- Log message: this doesn't compile, disable it --- Diffs of the changes: (+4 -0) APInt.cpp | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.39 llvm/lib/Support/APInt.cpp:1.40 --- llvm/lib/Support/APInt.cpp:1.39 Sat Feb 24 19:56:07 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 20:32:44 2007 @@ -26,6 +26,8 @@ using namespace llvm; +#if 0 + // A utility function for allocating memory, checking for allocation failures, // and ensuring the contents are zeroed. inline static uint64_t* getClearedMemory(uint32_t numWords) { @@ -1587,3 +1589,5 @@ cerr << " (" << this->toString(10, false) << ")\n" << std::setbase(10); } #endif + +#endif From sabre at nondot.org Sat Feb 24 23:04:30 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 23:04:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCJITInfo.cpp PPCSubtarget.h PPCTargetMachine.cpp Message-ID: <200702250504.l1P54UEF028879@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCJITInfo.cpp updated: 1.36 -> 1.37 PPCSubtarget.h updated: 1.24 -> 1.25 PPCTargetMachine.cpp updated: 1.116 -> 1.117 --- Log message: Improve JIT support for linux/ppc: Patch by Nicolas Geoffray! --- Diffs of the changes: (+70 -2) PPCJITInfo.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ PPCSubtarget.h | 3 ++ PPCTargetMachine.cpp | 4 +-- 3 files changed, 70 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PPCJITInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCJITInfo.cpp:1.36 llvm/lib/Target/PowerPC/PPCJITInfo.cpp:1.37 --- llvm/lib/Target/PowerPC/PPCJITInfo.cpp:1.36 Mon Dec 11 12:10:54 2006 +++ llvm/lib/Target/PowerPC/PPCJITInfo.cpp Sat Feb 24 23:04:13 2007 @@ -134,6 +134,71 @@ "mtlr r2\n" "bctr\n" ); + +#elif defined(__PPC__) && !defined(__ppc64__) +// Linux/PPC support + +// CompilationCallback stub - We can't use a C function with inline assembly in +// it, because we the prolog/epilog inserted by GCC won't work for us. Instead, +// write our own wrapper, which does things our way, so we have complete control +// over register saving and restoring. +asm( + ".text\n" + ".align 2\n" + ".globl PPC32CompilationCallback\n" +"PPC32CompilationCallback:\n" + // Make space for 8 ints r[3-10] and 13 doubles f[1-13] and the + // FIXME: need to save v[0-19] for altivec? + // FIXME: could shrink frame + // Set up a proper stack frame + // FIXME Layout + // PowerPC64 ABI linkage - 24 bytes + // parameters - 32 bytes + // 13 double registers - 104 bytes + // 8 int registers - 32 bytes + "mflr 0\n" + "stw 0, 4(1)\n" + "stwu 1, -180(1)\n" + // Save all int arg registers + "stw 10, 176(1)\n" "stw 9, 172(1)\n" + "stw 8, 168(1)\n" "stw 7, 164(1)\n" + "stw 6, 160(1)\n" "stw 5, 156(1)\n" + "stw 4, 152(1)\n" "stw 3, 148(1)\n" + // Save all call-clobbered FP regs. + "stfd 10, 144(1)\n" + "stfd 9, 136(1)\n" "stfd 8, 128(1)\n" + "stfd 7, 120(1)\n" "stfd 6, 112(1)\n" + "stfd 5, 104(1)\n" "stfd 4, 96(1)\n" + "stfd 3, 88(1)\n" "stfd 2, 80(1)\n" + "stfd 1, 72(1)\n" + // Arguments to Compilation Callback: + // r3 - our lr (address of the call instruction in stub plus 4) + // r4 - stub's lr (address of instruction that called the stub plus 4) + // r5 - is64Bit - always 0. + "mr 3, 0\n" + "lwz 11, 180(1)\n" // stub's frame + "lwz 4, 4(11)\n" // stub's lr + "li 5, 0\n" // 0 == 32 bit + "bl PPCCompilationCallbackC\n" + "mtctr 3\n" + // Restore all int arg registers + "lwz 10, 176(1)\n" "lwz 9, 172(1)\n" + "lwz 8, 168(1)\n" "lwz 7, 164(1)\n" + "lwz 6, 160(1)\n" "lwz 5, 156(1)\n" + "lwz 4, 152(1)\n" "lwz 3, 148(1)\n" + // Restore all FP arg registers + "lfd 10, 144(1)\n" + "lfd 9, 136(1)\n" "lfd 8, 128(1)\n" + "lfd 7, 120(1)\n" "lfd 6, 112(1)\n" + "lfd 5, 104(1)\n" "lfd 4, 96(1)\n" + "lfd 3, 88(1)\n" "lfd 2, 80(1)\n" + "lfd 1, 72(1)\n" + // Pop 3 frames off the stack and branch to target + "lwz 1, 184(1)\n" + "lwz 11, 4(1)\n" + "mtlr 11\n" + "bctr\n" + ); #else void PPC32CompilationCallback() { assert(0 && "This is not a power pc, you can't execute this!"); Index: llvm/lib/Target/PowerPC/PPCSubtarget.h diff -u llvm/lib/Target/PowerPC/PPCSubtarget.h:1.24 llvm/lib/Target/PowerPC/PPCSubtarget.h:1.25 --- llvm/lib/Target/PowerPC/PPCSubtarget.h:1.24 Tue Feb 13 23:52:17 2007 +++ llvm/lib/Target/PowerPC/PPCSubtarget.h Sat Feb 24 23:04:13 2007 @@ -134,6 +134,9 @@ bool isDarwin() const { return IsDarwin; } + bool isMachoABI() const { return IsDarwin; } + bool isELF_ABI() const { return !IsDarwin; } + unsigned getAsmFlavor() const { return AsmFlavor != Unset ? unsigned(AsmFlavor) : 0; } Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.116 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.117 --- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.116 Wed Feb 7 19:39:44 2007 +++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Sat Feb 24 23:04:13 2007 @@ -35,14 +35,14 @@ } unsigned PPC32TargetMachine::getJITMatchQuality() { -#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) +#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__) if (sizeof(void*) == 4) return 10; #endif return 0; } unsigned PPC64TargetMachine::getJITMatchQuality() { -#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) +#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__) if (sizeof(void*) == 8) return 10; #endif From sabre at nondot.org Sat Feb 24 23:08:06 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 23:08:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstrFormats.td Message-ID: <200702250508.l1P5867v028980@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstrFormats.td updated: 1.88 -> 1.89 --- Log message: Add XLForm_1_ext template, patch by Nicolas Geoffray. --- Diffs of the changes: (+24 -14) PPCInstrFormats.td | 38 ++++++++++++++++++++++++-------------- 1 files changed, 24 insertions(+), 14 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstrFormats.td diff -u llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.88 llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.89 --- llvm/lib/Target/PowerPC/PPCInstrFormats.td:1.88 Wed Dec 6 15:35:10 2006 +++ llvm/lib/Target/PowerPC/PPCInstrFormats.td Sat Feb 24 23:07:49 2007 @@ -349,21 +349,31 @@ // 1.7.7 XL-Form class XLForm_1 opcode, bits<10> xo, dag OL, string asmstr, - InstrItinClass itin> + InstrItinClass itin, list pattern> + : I { + bits<5> CRD; + bits<5> CRA; + bits<5> CRB; + + let Pattern = pattern; + + let Inst{6-10} = CRD; + let Inst{11-15} = CRA; + let Inst{16-20} = CRB; + let Inst{21-30} = xo; + let Inst{31} = 0; +} + +class XLForm_1_ext opcode, bits<10> xo, dag OL, string asmstr, + InstrItinClass itin, list pattern> : I { - bits<3> CRD; - bits<2> CRDb; - bits<3> CRA; - bits<2> CRAb; - bits<3> CRB; - bits<2> CRBb; - - let Inst{6-8} = CRD; - let Inst{9-10} = CRDb; - let Inst{11-13} = CRA; - let Inst{14-15} = CRAb; - let Inst{16-18} = CRB; - let Inst{19-20} = CRBb; + bits<5> CRD; + + let Pattern = pattern; + + let Inst{6-10} = CRD; + let Inst{11-15} = CRD; + let Inst{16-20} = CRD; let Inst{21-30} = xo; let Inst{31} = 0; } From sabre at nondot.org Sat Feb 24 23:34:49 2007 From: sabre at nondot.org (Chris Lattner) Date: Sat, 24 Feb 2007 23:34:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp PPCFrameInfo.h PPCHazardRecognizers.cpp PPCISelLowering.cpp PPCISelLowering.h PPCInstr64Bit.td PPCInstrInfo.td PPCRegisterInfo.cpp Message-ID: <200702250534.l1P5YnLa029490@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCCodeEmitter.cpp updated: 1.74 -> 1.75 PPCFrameInfo.h updated: 1.12 -> 1.13 PPCHazardRecognizers.cpp updated: 1.18 -> 1.19 PPCISelLowering.cpp updated: 1.253 -> 1.254 PPCISelLowering.h updated: 1.58 -> 1.59 PPCInstr64Bit.td updated: 1.38 -> 1.39 PPCInstrInfo.td updated: 1.272 -> 1.273 PPCRegisterInfo.cpp updated: 1.111 -> 1.112 --- Log message: implement support for the linux/ppc function call ABI. Patch by Nicolas Geoffray! --- Diffs of the changes: (+343 -102) PPCCodeEmitter.cpp | 7 +- PPCFrameInfo.h | 50 +++++++++++---- PPCHazardRecognizers.cpp | 2 PPCISelLowering.cpp | 149 ++++++++++++++++++++++++++++++----------------- PPCISelLowering.h | 2 PPCInstr64Bit.td | 44 +++++++++++-- PPCInstrInfo.td | 64 ++++++++++++++++---- PPCRegisterInfo.cpp | 127 ++++++++++++++++++++++++++++++++++++---- 8 files changed, 343 insertions(+), 102 deletions(-) Index: llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp diff -u llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.74 llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.75 --- llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp:1.74 Fri Dec 15 10:44:10 2006 +++ llvm/lib/Target/PowerPC/PPCCodeEmitter.cpp Sat Feb 24 23:34:32 2007 @@ -133,7 +133,8 @@ } else if (MO.isGlobalAddress() || MO.isExternalSymbol() || MO.isConstantPoolIndex() || MO.isJumpTableIndex()) { unsigned Reloc = 0; - if (MI.getOpcode() == PPC::BL || MI.getOpcode() == PPC::BL8) + if (MI.getOpcode() == PPC::BL_Macho || MI.getOpcode() == PPC::BL8_Macho || + MI.getOpcode() == PPC::BL_ELF || MI.getOpcode() == PPC::BL8_ELF) Reloc = PPC::reloc_pcrel_bx; else { if (TM.getRelocationModel() == Reloc::PIC_) { @@ -213,7 +214,9 @@ } else if (MO.isMachineBasicBlock()) { unsigned Reloc = 0; unsigned Opcode = MI.getOpcode(); - if (Opcode == PPC::B || Opcode == PPC::BL || Opcode == PPC::BLA) + if (Opcode == PPC::B || Opcode == PPC::BL_Macho || + Opcode == PPC::BLA_Macho || Opcode == PPC::BL_ELF || + Opcode == PPC::BLA_ELF) Reloc = PPC::reloc_pcrel_bx; else // BCC instruction Reloc = PPC::reloc_pcrel_bcx; Index: llvm/lib/Target/PowerPC/PPCFrameInfo.h diff -u llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.12 llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.13 --- llvm/lib/Target/PowerPC/PPCFrameInfo.h:1.12 Wed Dec 6 11:42:06 2006 +++ llvm/lib/Target/PowerPC/PPCFrameInfo.h Sat Feb 24 23:34:32 2007 @@ -29,41 +29,61 @@ /// getReturnSaveOffset - Return the previous frame offset to save the /// return address. - static unsigned getReturnSaveOffset(bool LP64) { - return LP64 ? 16 : 8; + static unsigned getReturnSaveOffset(bool LP64, bool isMacho) { + if (isMacho) + return LP64 ? 16 : 8; + // For ELF ABI: + return LP64 ? 8 : 4; } /// getFramePointerSaveOffset - Return the previous frame offset to save the /// frame pointer. - static unsigned getFramePointerSaveOffset(bool LP64) { + static unsigned getFramePointerSaveOffset(bool LP64, bool isMacho) { + // For MachO ABI: // Use the TOC save slot in the PowerPC linkage area for saving the frame // pointer (if needed.) LLVM does not generate code that uses the TOC (R2 // is treated as a caller saved register.) - return LP64 ? 40 : 20; + if (isMacho) + return LP64 ? 40 : 20; + + // For ELF ABI: + // Save it right before the link register + return LP64 ? -8 : -4; } /// getLinkageSize - Return the size of the PowerPC ABI linkage area. /// - static unsigned getLinkageSize(bool LP64) { - return 6 * (LP64 ? 8 : 4); + static unsigned getLinkageSize(bool LP64, bool isMacho) { + if (isMacho) + return 6 * (LP64 ? 8 : 4); + + // For ELF ABI: + return LP64 ? 16 : 8; } /// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI /// argument area. - static unsigned getMinCallArgumentsSize(bool LP64) { - // The prolog code of the callee may store up to 8 GPR argument registers to - // the stack, allowing va_start to index over them in memory if its varargs. - // Because we cannot tell if this is needed on the caller side, we have to - // conservatively assume that it is needed. As such, make sure we have at - // least enough stack space for the caller to store the 8 GPRs. - return 8 * (LP64 ? 8 : 4); + static unsigned getMinCallArgumentsSize(bool LP64, bool isMacho) { + // For Macho ABI: + // The prolog code of the callee may store up to 8 GPR argument registers to + // the stack, allowing va_start to index over them in memory if its varargs. + // Because we cannot tell if this is needed on the caller side, we have to + // conservatively assume that it is needed. As such, make sure we have at + // least enough stack space for the caller to store the 8 GPRs. + if (isMacho) + return 8 * (LP64 ? 8 : 4); + + // For Linux ABI: + // There is no default stack allocated for the 8 first GPR arguments. + return 0; } /// getMinCallFrameSize - Return the minimum size a call frame can be using /// the PowerPC ABI. - static unsigned getMinCallFrameSize(bool LP64) { + static unsigned getMinCallFrameSize(bool LP64, bool isMacho) { // The call frame needs to be at least big enough for linkage and 8 args. - return getLinkageSize(LP64) + getMinCallArgumentsSize(LP64); + return getLinkageSize(LP64, isMacho) + + getMinCallArgumentsSize(LP64, isMacho); } }; Index: llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp diff -u llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.18 llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.19 --- llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp:1.18 Thu Dec 7 16:21:48 2006 +++ llvm/lib/Target/PowerPC/PPCHazardRecognizers.cpp Sat Feb 24 23:34:32 2007 @@ -157,7 +157,7 @@ } // Do not allow MTCTR and BCTRL to be in the same dispatch group. - if (HasCTRSet && Opcode == PPC::BCTRL) + if (HasCTRSet && Opcode == PPC::BCTRL_Macho || Opcode == PPC::BCTRL_ELF) return NoopHazard; // If this is a load following a store, make sure it's not to the same or Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.253 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.254 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.253 Thu Feb 22 08:56:36 2007 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Sat Feb 24 23:34:32 2007 @@ -328,7 +328,8 @@ case PPCISD::STD_32: return "PPCISD::STD_32"; case PPCISD::CALL: return "PPCISD::CALL"; case PPCISD::MTCTR: return "PPCISD::MTCTR"; - case PPCISD::BCTRL: return "PPCISD::BCTRL"; + case PPCISD::BCTRL_Macho: return "PPCISD::BCTRL_Macho"; + case PPCISD::BCTRL_ELF: return "PPCISD::BCTRL_ELF"; case PPCISD::RET_FLAG: return "PPCISD::RET_FLAG"; case PPCISD::MFCR: return "PPCISD::MFCR"; case PPCISD::VCMP: return "PPCISD::VCMP"; @@ -1094,8 +1095,28 @@ SV->getOffset()); } +/// GetFPR - Get the set of FP registers that should be allocated for arguments, +/// depending on which subtarget is selected. +static const unsigned *GetFPR(const PPCSubtarget &Subtarget) { + if (Subtarget.isMachoABI()) { + static const unsigned FPR[] = { + PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, + PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13 + }; + return FPR; + } + + + static const unsigned FPR[] = { + PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, + PPC::F8, PPC::F9, PPC::F10 + }; + return FPR; +} + static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG, - int &VarArgsFrameIndex) { + int &VarArgsFrameIndex, + const PPCSubtarget &Subtarget) { // TODO: add description of PPC stack frame format, or at least some docs. // MachineFunction &MF = DAG.getMachineFunction(); @@ -1106,9 +1127,10 @@ MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); bool isPPC64 = PtrVT == MVT::i64; + bool isMachoABI = Subtarget.isMachoABI(); unsigned PtrByteSize = isPPC64 ? 8 : 4; - unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64); + unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64, isMachoABI); static const unsigned GPR_32[] = { // 32-bit registers. PPC::R3, PPC::R4, PPC::R5, PPC::R6, @@ -1118,17 +1140,16 @@ PPC::X3, PPC::X4, PPC::X5, PPC::X6, PPC::X7, PPC::X8, PPC::X9, PPC::X10, }; - static const unsigned FPR[] = { - PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, - PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13 - }; + + static const unsigned *FPR = GetFPR(Subtarget); + static const unsigned VR[] = { PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8, PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13 }; const unsigned Num_GPR_Regs = sizeof(GPR_32)/sizeof(GPR_32[0]); - const unsigned Num_FPR_Regs = sizeof(FPR)/sizeof(FPR[0]); + const unsigned Num_FPR_Regs = isMachoABI ? 13 : 10; const unsigned Num_VR_Regs = sizeof( VR)/sizeof( VR[0]); unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0; @@ -1149,9 +1170,6 @@ switch (ObjectVT) { default: assert(0 && "Unhandled argument type!"); case MVT::i32: - // All int arguments reserve stack space. - ArgOffset += PtrByteSize; - if (GPR_idx != Num_GPR_Regs) { unsigned VReg = RegMap->createVirtualRegister(&PPC::GPRCRegClass); MF.addLiveIn(GPR[GPR_idx], VReg); @@ -1161,11 +1179,11 @@ needsLoad = true; ArgSize = PtrByteSize; } + // All int arguments reserve stack space in Macho ABI. + if (isMachoABI || needsLoad) ArgOffset += PtrByteSize; break; - case MVT::i64: // PPC64 - // All int arguments reserve stack space. - ArgOffset += 8; + case MVT::i64: // PPC64 if (GPR_idx != Num_GPR_Regs) { unsigned VReg = RegMap->createVirtualRegister(&PPC::G8RCRegClass); MF.addLiveIn(GPR[GPR_idx], VReg); @@ -1174,12 +1192,12 @@ } else { needsLoad = true; } + // All int arguments reserve stack space in Macho ABI. + if (isMachoABI || needsLoad) ArgOffset += 8; break; + case MVT::f32: case MVT::f64: - // All FP arguments reserve stack space. - ArgOffset += isPPC64 ? 8 : ObjSize; - // Every 4 bytes of argument space consumes one of the GPRs available for // argument passing. if (GPR_idx != Num_GPR_Regs) { @@ -1199,6 +1217,9 @@ } else { needsLoad = true; } + + // All FP arguments reserve stack space in Macho ABI. + if (isMachoABI || needsLoad) ArgOffset += isPPC64 ? 8 : ObjSize; break; case MVT::v4f32: case MVT::v4i32: @@ -1290,11 +1311,15 @@ return DAG.getConstant((int)C->getValue() >> 2, MVT::i32).Val; } -static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) { - SDOperand Chain = Op.getOperand(0); - bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; - SDOperand Callee = Op.getOperand(4); - unsigned NumOps = (Op.getNumOperands() - 5) / 2; + +static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG, + const PPCSubtarget &Subtarget) { + SDOperand Chain = Op.getOperand(0); + bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; + SDOperand Callee = Op.getOperand(4); + unsigned NumOps = (Op.getNumOperands() - 5) / 2; + + bool isMachoABI = Subtarget.isMachoABI(); MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); bool isPPC64 = PtrVT == MVT::i64; @@ -1307,7 +1332,7 @@ // Count how many bytes are to be pushed on the stack, including the linkage // area, and parameter passing area. We start with 24/48 bytes, which is // prereserved space for [SP][CR][LR][3 x unused]. - unsigned NumBytes = PPCFrameInfo::getLinkageSize(isPPC64); + unsigned NumBytes = PPCFrameInfo::getLinkageSize(isPPC64, isMachoABI); // Add up all the space actually used. for (unsigned i = 0; i != NumOps; ++i) { @@ -1321,7 +1346,8 @@ // Because we cannot tell if this is needed on the caller side, we have to // conservatively assume that it is needed. As such, make sure we have at // least enough stack space for the caller to store the 8 GPRs. - NumBytes = std::max(NumBytes, PPCFrameInfo::getMinCallFrameSize(isPPC64)); + NumBytes = std::max(NumBytes, + PPCFrameInfo::getMinCallFrameSize(isPPC64, isMachoABI)); // Adjust the stack pointer for the new arguments... // These operations are automatically eliminated by the prolog/epilog pass @@ -1341,7 +1367,7 @@ // memory. Also, if this is a vararg function, floating point operations // must be stored to our stack, and loaded into integer regs as well, if // any integer regs are available for argument passing. - unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64); + unsigned ArgOffset = PPCFrameInfo::getLinkageSize(isPPC64, isMachoABI); unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0; static const unsigned GPR_32[] = { // 32-bit registers. @@ -1352,16 +1378,14 @@ PPC::X3, PPC::X4, PPC::X5, PPC::X6, PPC::X7, PPC::X8, PPC::X9, PPC::X10, }; - static const unsigned FPR[] = { - PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7, - PPC::F8, PPC::F9, PPC::F10, PPC::F11, PPC::F12, PPC::F13 - }; + static const unsigned *FPR = GetFPR(Subtarget); + static const unsigned VR[] = { PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8, PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13 }; const unsigned NumGPRs = sizeof(GPR_32)/sizeof(GPR_32[0]); - const unsigned NumFPRs = sizeof(FPR)/sizeof(FPR[0]); + const unsigned NumFPRs = isMachoABI ? 13 : 10; const unsigned NumVRs = sizeof( VR)/sizeof( VR[0]); const unsigned *GPR = isPPC64 ? GPR_64 : GPR_32; @@ -1369,6 +1393,7 @@ std::vector > RegsToPass; SmallVector MemOpChains; for (unsigned i = 0; i != NumOps; ++i) { + bool inMem = false; SDOperand Arg = Op.getOperand(5+2*i); // PtrOff will be used to store the current argument to the stack if a @@ -1392,8 +1417,9 @@ RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg)); } else { MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); + inMem = true; } - ArgOffset += PtrByteSize; + if (inMem || isMachoABI) ArgOffset += PtrByteSize; break; case MVT::f32: case MVT::f64: @@ -1414,31 +1440,39 @@ if (GPR_idx != NumGPRs) { SDOperand Load = DAG.getLoad(PtrVT, Store, PtrOff, NULL, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + if (isMachoABI) RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], + Load)); } if (GPR_idx != NumGPRs && Arg.getValueType() == MVT::f64 && !isPPC64){ SDOperand ConstFour = DAG.getConstant(4, PtrOff.getValueType()); PtrOff = DAG.getNode(ISD::ADD, PtrVT, PtrOff, ConstFour); SDOperand Load = DAG.getLoad(PtrVT, Store, PtrOff, NULL, 0); MemOpChains.push_back(Load.getValue(1)); - RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); + if (isMachoABI) RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], + Load)); } } else { // If we have any FPRs remaining, we may also have GPRs remaining. // Args passed in FPRs consume either 1 (f32) or 2 (f64) available // GPRs. - if (GPR_idx != NumGPRs) - ++GPR_idx; - if (GPR_idx != NumGPRs && Arg.getValueType() == MVT::f64 && !isPPC64) - ++GPR_idx; + if (isMachoABI) { + if (GPR_idx != NumGPRs) + ++GPR_idx; + if (GPR_idx != NumGPRs && Arg.getValueType() == MVT::f64 && + !isPPC64) // PPC64 has 64-bit GPR's obviously :) + ++GPR_idx; + } } } else { MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); + inMem = true; + } + if (inMem || isMachoABI) { + if (isPPC64) + ArgOffset += 8; + else + ArgOffset += Arg.getValueType() == MVT::f32 ? 4 : 8; } - if (isPPC64) - ArgOffset += 8; - else - ArgOffset += Arg.getValueType() == MVT::f32 ? 4 : 8; break; case MVT::v4f32: case MVT::v4i32: @@ -1463,7 +1497,14 @@ InFlag); InFlag = Chain.getValue(1); } - + + // With the ELF ABI, set CR6 to true if this is a vararg call. + if (isVarArg && !isMachoABI) { + SDOperand SetCR(DAG.getTargetNode(PPC::SETCR, MVT::i32), 0); + Chain = DAG.getCopyToReg(Chain, PPC::CR6, SetCR, InFlag); + InFlag = Chain.getValue(1); + } + std::vector NodeTys; NodeTys.push_back(MVT::Other); // Returns a chain NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. @@ -1489,14 +1530,16 @@ InFlag = Chain.getValue(1); // Copy the callee address into R12 on darwin. - Chain = DAG.getCopyToReg(Chain, PPC::R12, Callee, InFlag); - InFlag = Chain.getValue(1); + if (isMachoABI) { + Chain = DAG.getCopyToReg(Chain, PPC::R12, Callee, InFlag); + InFlag = Chain.getValue(1); + } NodeTys.clear(); NodeTys.push_back(MVT::Other); NodeTys.push_back(MVT::Flag); Ops.push_back(Chain); - CallOpc = PPCISD::BCTRL; + CallOpc = isMachoABI ? PPCISD::BCTRL_Macho : PPCISD::BCTRL_ELF; Callee.Val = 0; } @@ -1656,18 +1699,20 @@ const PPCSubtarget &Subtarget) { MachineFunction &MF = DAG.getMachineFunction(); bool IsPPC64 = Subtarget.isPPC64(); + bool isMachoABI = Subtarget.isMachoABI(); // Get current frame pointer save index. The users of this index will be // primarily DYNALLOC instructions. PPCFunctionInfo *FI = MF.getInfo(); int FPSI = FI->getFramePointerSaveIndex(); - + // If the frame pointer save index hasn't been defined yet. if (!FPSI) { // Find out what the fix offset of the frame pointer save area. - int Offset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64); + int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, isMachoABI); + // Allocate the frame index for frame pointer save area. - FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, Offset); + FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, FPOffset); // Save the result. FI->setFramePointerSaveIndex(FPSI); } @@ -2630,12 +2675,12 @@ case ISD::SETCC: return LowerSETCC(Op, DAG); case ISD::VASTART: return LowerVASTART(Op, DAG, VarArgsFrameIndex); case ISD::FORMAL_ARGUMENTS: - return LowerFORMAL_ARGUMENTS(Op, DAG, VarArgsFrameIndex); - case ISD::CALL: return LowerCALL(Op, DAG); + return LowerFORMAL_ARGUMENTS(Op, DAG, VarArgsFrameIndex, PPCSubTarget); + case ISD::CALL: return LowerCALL(Op, DAG, PPCSubTarget); case ISD::RET: return LowerRET(Op, DAG); case ISD::STACKRESTORE: return LowerSTACKRESTORE(Op, DAG, PPCSubTarget); - case ISD::DYNAMIC_STACKALLOC: return LowerDYNAMIC_STACKALLOC(Op, DAG, - PPCSubTarget); + case ISD::DYNAMIC_STACKALLOC: + return LowerDYNAMIC_STACKALLOC(Op, DAG, PPCSubTarget); case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); case ISD::FP_TO_SINT: return LowerFP_TO_SINT(Op, DAG); Index: llvm/lib/Target/PowerPC/PPCISelLowering.h diff -u llvm/lib/Target/PowerPC/PPCISelLowering.h:1.58 llvm/lib/Target/PowerPC/PPCISelLowering.h:1.59 --- llvm/lib/Target/PowerPC/PPCISelLowering.h:1.58 Fri Jan 26 16:40:50 2007 +++ llvm/lib/Target/PowerPC/PPCISelLowering.h Sat Feb 24 23:34:32 2007 @@ -90,7 +90,7 @@ /// CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a /// BCTRL instruction. - BCTRL, + BCTRL_Macho, BCTRL_ELF, /// Return with a flag operand, matched by 'blr' RET_FLAG, Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.38 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.39 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.38 Fri Dec 15 15:39:31 2006 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Sat Feb 24 23:34:32 2007 @@ -69,6 +69,7 @@ def MovePCtoLR8 : Pseudo<(ops piclabel:$label), "bl $label", []>, PPC970_Unit_BRU; +// Macho ABI Calls. let isCall = 1, noResults = 1, PPC970_Unit = 7, // All calls clobber the PPC64 non-callee saved registers. Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12, @@ -77,18 +78,45 @@ LR8,CTR8, CR0,CR1,CR5,CR6,CR7] in { // Convenient aliases for call instructions - def BL8 : IForm<18, 0, 1, (ops calltarget:$func, variable_ops), - "bl $func", BrB, []>; // See Pat patterns below. + def BL8_Macho : IForm<18, 0, 1, + (ops calltarget:$func, variable_ops), + "bl $func", BrB, []>; // See Pat patterns below. - def BLA8 : IForm<18, 1, 1, (ops aaddr:$func, variable_ops), - "bla $func", BrB, [(PPCcall (i64 imm:$func))]>; + def BLA8_Macho : IForm<18, 1, 1, + (ops aaddr:$func, variable_ops), + "bla $func", BrB, [(PPCcall_Macho (i64 imm:$func))]>; } +// ELF ABI Calls. +let isCall = 1, noResults = 1, PPC970_Unit = 7, + // All calls clobber the PPC64 non-callee saved registers. + Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12, + F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10, + V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19, + LR8,CTR8, + CR0,CR1,CR5,CR6,CR7] in { + // Convenient aliases for call instructions + def BL8_ELF : IForm<18, 0, 1, + (ops calltarget:$func, variable_ops), + "bl $func", BrB, []>; // See Pat patterns below. + + def BLA8_ELF : IForm<18, 1, 1, + (ops aaddr:$func, variable_ops), + "bla $func", BrB, [(PPCcall_ELF (i64 imm:$func))]>; +} + + // Calls -def : Pat<(PPCcall (i64 tglobaladdr:$dst)), - (BL8 tglobaladdr:$dst)>; -def : Pat<(PPCcall (i64 texternalsym:$dst)), - (BL8 texternalsym:$dst)>; +def : Pat<(PPCcall_Macho (i64 tglobaladdr:$dst)), + (BL8_Macho tglobaladdr:$dst)>; +def : Pat<(PPCcall_Macho (i64 texternalsym:$dst)), + (BL8_Macho texternalsym:$dst)>; + +def : Pat<(PPCcall_ELF (i64 tglobaladdr:$dst)), + (BL8_ELF tglobaladdr:$dst)>; +def : Pat<(PPCcall_ELF (i64 texternalsym:$dst)), + (BL8_ELF texternalsym:$dst)>; + //===----------------------------------------------------------------------===// // 64-bit SPR manipulation instrs. Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.272 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.273 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.272 Fri Jan 26 08:34:51 2007 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Sat Feb 24 23:34:32 2007 @@ -81,11 +81,16 @@ [SDNPHasChain, SDNPOutFlag]>; def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>; -def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall, +def PPCcall_Macho : SDNode<"PPCISD::CALL", SDT_PPCCall, + [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; +def PPCcall_ELF : SDNode<"PPCISD::CALL", SDT_PPCCall, [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall, [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; -def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTRet, +def PPCbctrl_Macho : SDNode<"PPCISD::BCTRL_Macho", SDTRet, + [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; + +def PPCbctrl_ELF : SDNode<"PPCISD::BCTRL_ELF", SDTRet, [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; def retflag : SDNode<"PPCISD::RET_FLAG", SDTRet, @@ -366,6 +371,7 @@ /*[(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]*/>; } +// Macho ABI Calls. let isCall = 1, noResults = 1, PPC970_Unit = 7, // All calls clobber the non-callee saved registers... Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12, @@ -374,12 +380,38 @@ LR,CTR, CR0,CR1,CR5,CR6,CR7] in { // Convenient aliases for call instructions - def BL : IForm<18, 0, 1, (ops calltarget:$func, variable_ops), - "bl $func", BrB, []>; // See Pat patterns below. - def BLA : IForm<18, 1, 1, (ops aaddr:$func, variable_ops), - "bla $func", BrB, [(PPCcall (i32 imm:$func))]>; - def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (ops variable_ops), "bctrl", BrB, - [(PPCbctrl)]>; + def BL_Macho : IForm<18, 0, 1, + (ops calltarget:$func, variable_ops), + "bl $func", BrB, []>; // See Pat patterns below. + def BLA_Macho : IForm<18, 1, 1, + (ops aaddr:$func, variable_ops), + "bla $func", BrB, [(PPCcall_Macho (i32 imm:$func))]>; + def BCTRL_Macho : XLForm_2_ext<19, 528, 20, 0, 1, + (ops variable_ops), + "bctrl", BrB, + [(PPCbctrl_Macho)]>; +} + +// ELF ABI Calls. +let isCall = 1, noResults = 1, PPC970_Unit = 7, + // All calls clobber the non-callee saved registers... + Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12, + F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10, + V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19, + LR,CTR, + CR0,CR1,CR5,CR6,CR7] in { + // Convenient aliases for call instructions + def BL_ELF : IForm<18, 0, 1, + (ops calltarget:$func, variable_ops), + "bl $func", BrB, []>; // See Pat patterns below. + def BLA_ELF : IForm<18, 1, 1, + (ops aaddr:$func, variable_ops), + "bla $func", BrB, + [(PPCcall_ELF (i32 imm:$func))]>; + def BCTRL_ELF : XLForm_2_ext<19, 528, 20, 0, 1, + (ops variable_ops), + "bctrl", BrB, + [(PPCbctrl_ELF)]>; } // DCB* instructions. @@ -791,6 +823,14 @@ "mcrf $BF, $BFA", BrMCR>, PPC970_DGroup_First, PPC970_Unit_CRU; +def CREQV : XLForm_1<19, 289, (ops CRRC:$CRD, CRRC:$CRA, CRRC:$CRB), + "creqv $CRD, $CRA, $CRB", BrCR, + []>; + +def SETCR : XLForm_1_ext<19, 289, (ops CRRC:$dst), + "creqv $dst, $dst, $dst", BrCR, + []>; + // XFX-Form instructions. Instructions that deal with SPRs. // def MFCTR : XFXForm_1_ext<31, 339, 9, (ops GPRC:$rT), "mfctr $rT", SprMFSPR>, @@ -1060,10 +1100,10 @@ (RLWNM GPRC:$in, GPRC:$sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>; // Calls -def : Pat<(PPCcall (i32 tglobaladdr:$dst)), - (BL tglobaladdr:$dst)>; -def : Pat<(PPCcall (i32 texternalsym:$dst)), - (BL texternalsym:$dst)>; +def : Pat<(PPCcall_Macho (i32 tglobaladdr:$dst)), + (BL_Macho tglobaladdr:$dst)>; +def : Pat<(PPCcall_ELF (i32 texternalsym:$dst)), + (BL_ELF texternalsym:$dst)>; // Hi and Lo for Darwin Global Addresses. def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>; Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.111 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.112 --- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.111 Fri Feb 23 14:34:16 2007 +++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Sat Feb 24 23:34:32 2007 @@ -261,6 +261,28 @@ PPC::LR, 0 }; + + static const unsigned ELF32_CalleeSavedRegs[] = { + PPC::R13, PPC::R14, PPC::R15, + PPC::R16, PPC::R17, PPC::R18, PPC::R19, + PPC::R20, PPC::R21, PPC::R22, PPC::R23, + PPC::R24, PPC::R25, PPC::R26, PPC::R27, + PPC::R28, PPC::R29, PPC::R30, PPC::R31, + + PPC::F11, PPC::F12, PPC::F13, + PPC::F14, PPC::F15, PPC::F16, PPC::F17, + PPC::F18, PPC::F19, PPC::F20, PPC::F21, + PPC::F22, PPC::F23, PPC::F24, PPC::F25, + PPC::F26, PPC::F27, PPC::F28, PPC::F29, + PPC::F30, PPC::F31, + + PPC::CR2, PPC::CR3, PPC::CR4, + PPC::V20, PPC::V21, PPC::V22, PPC::V23, + PPC::V24, PPC::V25, PPC::V26, PPC::V27, + PPC::V28, PPC::V29, PPC::V30, PPC::V31, + + PPC::LR, 0 + }; // 64-bit Darwin calling convention. static const unsigned Darwin64_CalleeSavedRegs[] = { PPC::X14, PPC::X15, @@ -283,8 +305,34 @@ PPC::LR8, 0 }; - return Subtarget.isPPC64() ? Darwin64_CalleeSavedRegs : - Darwin32_CalleeSavedRegs; + static const unsigned ELF64_CalleeSavedRegs[] = { + PPC::X14, PPC::X15, + PPC::X16, PPC::X17, PPC::X18, PPC::X19, + PPC::X20, PPC::X21, PPC::X22, PPC::X23, + PPC::X24, PPC::X25, PPC::X26, PPC::X27, + PPC::X28, PPC::X29, PPC::X30, PPC::X31, + + PPC::F11, PPC::F12, PPC::F13, + PPC::F14, PPC::F15, PPC::F16, PPC::F17, + PPC::F18, PPC::F19, PPC::F20, PPC::F21, + PPC::F22, PPC::F23, PPC::F24, PPC::F25, + PPC::F26, PPC::F27, PPC::F28, PPC::F29, + PPC::F30, PPC::F31, + + PPC::CR2, PPC::CR3, PPC::CR4, + PPC::V20, PPC::V21, PPC::V22, PPC::V23, + PPC::V24, PPC::V25, PPC::V26, PPC::V27, + PPC::V28, PPC::V29, PPC::V30, PPC::V31, + + PPC::LR8, 0 + }; + + if (Subtarget.isMachoABI()) + return Subtarget.isPPC64() ? Darwin64_CalleeSavedRegs : + Darwin32_CalleeSavedRegs; + + // ELF. + return Subtarget.isPPC64() ? ELF64_CalleeSavedRegs : ELF32_CalleeSavedRegs; } const TargetRegisterClass* const* @@ -312,6 +360,29 @@ &PPC::GPRCRegClass, 0 }; + static const TargetRegisterClass * const ELF32_CalleeSavedRegClasses[] = { + &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, + &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, + &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, + &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, + &PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass,&PPC::GPRCRegClass, + + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass, + + &PPC::CRRCRegClass,&PPC::CRRCRegClass,&PPC::CRRCRegClass, + + &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, + &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, + &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, + + &PPC::GPRCRegClass, 0 + }; + // 64-bit Darwin calling convention. static const TargetRegisterClass * const Darwin64_CalleeSavedRegClasses[] = { &PPC::G8RCRegClass,&PPC::G8RCRegClass, @@ -334,9 +405,37 @@ &PPC::G8RCRegClass, 0 }; + + static const TargetRegisterClass * const ELF64_CalleeSavedRegClasses[] = { + &PPC::G8RCRegClass,&PPC::G8RCRegClass, + &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, + &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, + &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, + &PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass,&PPC::G8RCRegClass, + + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass,&PPC::F8RCRegClass, + &PPC::F8RCRegClass,&PPC::F8RCRegClass, + + &PPC::CRRCRegClass,&PPC::CRRCRegClass,&PPC::CRRCRegClass, + + &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, + &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, + &PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass,&PPC::VRRCRegClass, + + &PPC::G8RCRegClass, 0 + }; - return Subtarget.isPPC64() ? Darwin64_CalleeSavedRegClasses : - Darwin32_CalleeSavedRegClasses; + if (Subtarget.isMachoABI()) + return Subtarget.isPPC64() ? Darwin64_CalleeSavedRegClasses : + Darwin32_CalleeSavedRegClasses; + + // ELF. + return Subtarget.isPPC64() ? ELF64_CalleeSavedRegClasses : + ELF32_CalleeSavedRegClasses; } // needsFP - Return true if the specified function should have a dedicated frame @@ -753,7 +852,8 @@ // Maximum call frame needs to be at least big enough for linkage and 8 args. unsigned minCallFrameSize = - PPCFrameInfo::getMinCallFrameSize(Subtarget.isPPC64()); + PPCFrameInfo::getMinCallFrameSize(Subtarget.isPPC64(), + Subtarget.isMachoABI()); maxCallFrameSize = std::max(maxCallFrameSize, minCallFrameSize); // If we have dynamic alloca then maxCallFrameSize needs to be aligned so @@ -766,7 +866,7 @@ // Include call frame size in total. FrameSize += maxCallFrameSize; - + // Make sure the frame is aligned. FrameSize = (FrameSize + AlignMask) & ~AlignMask; @@ -815,13 +915,15 @@ // Get processor type. bool IsPPC64 = Subtarget.isPPC64(); + // Get operating system + bool IsMachoABI = Subtarget.isMachoABI(); // Check if the link register (LR) has been used. bool UsesLR = MFI->hasCalls() || usesLR(MF); // Do we have a frame pointer for this function? bool HasFP = hasFP(MF); - int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64); - int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64); + int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64, IsMachoABI); + int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, IsMachoABI); if (IsPPC64) { if (UsesLR) @@ -976,11 +1078,16 @@ // Get processor type. bool IsPPC64 = Subtarget.isPPC64(); + // Get operating system + bool IsMachoABI = Subtarget.isMachoABI(); // Check if the link register (LR) has been used. bool UsesLR = MFI->hasCalls() || usesLR(MF); // Do we have a frame pointer for this function? bool HasFP = hasFP(MF); - + + int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64, IsMachoABI); + int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64, IsMachoABI); + // The loaded (or persistent) stack pointer value is offset by the 'stwu' // on entry to the function. Add this offset back now. if (!Subtarget.isPPC64()) { @@ -1001,8 +1108,6 @@ } } - int LROffset = PPCFrameInfo::getReturnSaveOffset(IsPPC64); - int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64); if (IsPPC64) { if (UsesLR) From sabre at nondot.org Sun Feb 25 00:07:06 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 00:07:06 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/i128-ret.ll Message-ID: <200702250607.l1P676La030034@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: i128-ret.ll added (r1.1) --- Log message: verify i128 return on x86-64 continues to codegen optimally. --- Diffs of the changes: (+8 -0) i128-ret.ll | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/test/CodeGen/X86/i128-ret.ll diff -c /dev/null llvm/test/CodeGen/X86/i128-ret.ll:1.1 *** /dev/null Sun Feb 25 00:06:59 2007 --- llvm/test/CodeGen/X86/i128-ret.ll Sun Feb 25 00:06:49 2007 *************** *** 0 **** --- 1,8 ---- + ; RUN: llvm-as < %s | llc -march=x86-64 | grep 'movq 8(%rdi), %rdx' && + ; RUN: llvm-as < %s | llc -march=x86-64 | grep 'movq (%rdi), %rax' + + define i128 @test(i128 *%P) { + %A = load i128* %P + ret i128 %A + } + From sabre at nondot.org Sun Feb 25 00:22:14 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 00:22:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250622.l1P6MEkK030297@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.323 -> 1.324 --- Log message: remove std::vector's in RET lowering. --- Diffs of the changes: (+11 -22) X86ISelLowering.cpp | 33 +++++++++++---------------------- 1 files changed, 11 insertions(+), 22 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.323 llvm/lib/Target/X86/X86ISelLowering.cpp:1.324 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.323 Thu Feb 22 08:56:36 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 00:21:57 2007 @@ -4014,13 +4014,9 @@ if (DAG.getMachineFunction().liveout_empty()) DAG.getMachineFunction().addLiveOut(X86::ST0); - std::vector Tys; - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); - std::vector Ops; - Ops.push_back(Op.getOperand(0)); - Ops.push_back(Op.getOperand(1)); - Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, &Ops[0], Ops.size()); + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); + SDOperand Ops[] = { Op.getOperand(0), Op.getOperand(1) }; + Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); } else { // FP return with ScalarSSE (return on fp-stack). if (DAG.getMachineFunction().liveout_empty()) @@ -4042,21 +4038,14 @@ MemLoc = DAG.getFrameIndex(SSFI, getPointerTy()); Chain = DAG.getStore(Op.getOperand(0), Value, MemLoc, NULL, 0); } - std::vector Tys; - Tys.push_back(MVT::f64); - Tys.push_back(MVT::Other); - std::vector Ops; - Ops.push_back(Chain); - Ops.push_back(MemLoc); - Ops.push_back(DAG.getValueType(ArgVT)); - Copy = DAG.getNode(X86ISD::FLD, Tys, &Ops[0], Ops.size()); - Tys.clear(); - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); - Ops.clear(); - Ops.push_back(Copy.getValue(1)); - Ops.push_back(Copy); - Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, &Ops[0], Ops.size()); + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other); + SDOperand Ops[] = { Chain, MemLoc, DAG.getValueType(ArgVT) }; + Copy = DAG.getNode(X86ISD::FLD, Tys, Ops, 3); + + Tys = DAG.getVTList(MVT::Other, MVT::Flag); + Ops[0] = Copy.getValue(1); + Ops[1] = Copy; + Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); } break; } From sabre at nondot.org Sun Feb 25 00:40:32 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 00:40:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250640.l1P6eWEh030654@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.324 -> 1.325 --- Log message: eliminate temporary vectors created during X86 lowering. --- Diffs of the changes: (+47 -70) X86ISelLowering.cpp | 117 ++++++++++++++++++++-------------------------------- 1 files changed, 47 insertions(+), 70 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.324 llvm/lib/Target/X86/X86ISelLowering.cpp:1.325 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.324 Sun Feb 25 00:21:57 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 00:40:16 2007 @@ -815,9 +815,8 @@ } else if (ExternalSymbolSDNode *S = dyn_cast(Callee)) Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy()); - std::vector NodeTys; - NodeTys.push_back(MVT::Other); // Returns a chain - NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + // Returns a chain & a flag for retval copy to use. + SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); std::vector Ops; Ops.push_back(Chain); Ops.push_back(Callee); @@ -856,10 +855,10 @@ NumBytesForCalleeToPush = NumSRetBytes; } - NodeTys.clear(); - NodeTys.push_back(MVT::Other); // Returns a chain if (RetVT != MVT::Other) - NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); + else + NodeTys = DAG.getVTList(MVT::Other); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); @@ -870,19 +869,18 @@ InFlag = Chain.getValue(1); std::vector ResultVals; - NodeTys.clear(); switch (RetVT) { default: assert(0 && "Unknown value type to return!"); case MVT::Other: break; case MVT::i8: Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i8); + NodeTys = DAG.getVTList(MVT::i8, MVT::Other); break; case MVT::i16: Chain = DAG.getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i16); + NodeTys = DAG.getVTList(MVT::i16, MVT::Other); break; case MVT::i32: if (Op.Val->getValueType(1) == MVT::i32) { @@ -891,12 +889,12 @@ Chain = DAG.getCopyFromReg(Chain, X86::EDX, MVT::i32, Chain.getValue(2)).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i32); + NodeTys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); } else { Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); + NodeTys = DAG.getVTList(MVT::i32, MVT::Other); } - NodeTys.push_back(MVT::i32); break; case MVT::v16i8: case MVT::v8i16: @@ -907,7 +905,7 @@ assert(!isStdCall && "Unknown value type to return!"); Chain = DAG.getCopyFromReg(Chain, X86::XMM0, RetVT, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(RetVT); + NodeTys = DAG.getVTList(RetVT, MVT::Other); break; case MVT::f32: case MVT::f64: { @@ -947,7 +945,7 @@ // operation is okay to eliminate if we allow excess FP precision. RetVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, RetVal); ResultVals.push_back(RetVal); - NodeTys.push_back(RetVT); + NodeTys = DAG.getVTList(RetVT, MVT::Other); break; } } @@ -957,7 +955,6 @@ return Chain; // Otherwise, merge everything together with a MERGE_VALUES node. - NodeTys.push_back(MVT::Other); ResultVals.push_back(Chain); SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0], ResultVals.size()); @@ -1367,9 +1364,8 @@ } else if (ExternalSymbolSDNode *S = dyn_cast(Callee)) Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy()); - std::vector NodeTys; - NodeTys.push_back(MVT::Other); // Returns a chain - NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + // Returns a chain & a flag for retval copy to use. + SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); std::vector Ops; Ops.push_back(Chain); Ops.push_back(Callee); @@ -1388,10 +1384,11 @@ NodeTys, &Ops[0], Ops.size()); InFlag = Chain.getValue(1); - NodeTys.clear(); - NodeTys.push_back(MVT::Other); // Returns a chain if (RetVT != MVT::Other) - NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + // Returns a flag for retval copy to use. + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); + else + NodeTys = DAG.getVTList(MVT::Other); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); @@ -1402,24 +1399,23 @@ InFlag = Chain.getValue(1); std::vector ResultVals; - NodeTys.clear(); switch (RetVT) { default: assert(0 && "Unknown value type to return!"); case MVT::Other: break; case MVT::i8: Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i8); + NodeTys = DAG.getVTList(MVT::i8, MVT::Other); break; case MVT::i16: Chain = DAG.getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i16); + NodeTys = DAG.getVTList(MVT::i16, MVT::Other); break; case MVT::i32: Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i32); + NodeTys = DAG.getVTList(MVT::i32, MVT::Other); break; case MVT::i64: if (Op.Val->getValueType(1) == MVT::i64) { @@ -1429,12 +1425,12 @@ Chain = DAG.getCopyFromReg(Chain, X86::RDX, MVT::i64, Chain.getValue(2)).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i64); + NodeTys = DAG.getVTList(MVT::i64, MVT::i64, MVT::Other); } else { Chain = DAG.getCopyFromReg(Chain, X86::RAX, MVT::i64, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); + NodeTys = DAG.getVTList(MVT::i64, MVT::Other); } - NodeTys.push_back(MVT::i64); break; case MVT::f32: case MVT::f64: @@ -1447,7 +1443,7 @@ // FIXME: long double support? Chain = DAG.getCopyFromReg(Chain, X86::XMM0, RetVT, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(RetVT); + NodeTys = DAG.getVTList(RetVT, MVT::Other); break; } @@ -1456,7 +1452,6 @@ return Chain; // Otherwise, merge everything together with a MERGE_VALUES node. - NodeTys.push_back(MVT::Other); ResultVals.push_back(Chain); SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0], ResultVals.size()); @@ -1805,9 +1800,8 @@ InFlag = Chain.getValue(1); } - std::vector NodeTys; - NodeTys.push_back(MVT::Other); // Returns a chain - NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + // Returns a chain & a flag for retval copy to use. + SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); std::vector Ops; Ops.push_back(Chain); Ops.push_back(Callee); @@ -1831,10 +1825,11 @@ NodeTys, &Ops[0], Ops.size()); InFlag = Chain.getValue(1); - NodeTys.clear(); - NodeTys.push_back(MVT::Other); // Returns a chain if (RetVT != MVT::Other) - NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + // Returns a flag for retval copy to use. + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); + else + NodeTys = DAG.getVTList(MVT::Other); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); @@ -1845,19 +1840,18 @@ InFlag = Chain.getValue(1); std::vector ResultVals; - NodeTys.clear(); switch (RetVT) { default: assert(0 && "Unknown value type to return!"); case MVT::Other: break; case MVT::i8: Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i8); + NodeTys = DAG.getVTList(MVT::i8, MVT::Other); break; case MVT::i16: Chain = DAG.getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i16); + NodeTys = DAG.getVTList(MVT::i16, MVT::Other); break; case MVT::i32: if (Op.Val->getValueType(1) == MVT::i32) { @@ -1866,12 +1860,12 @@ Chain = DAG.getCopyFromReg(Chain, X86::EDX, MVT::i32, Chain.getValue(2)).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(MVT::i32); + NodeTys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); } else { Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); + NodeTys = DAG.getVTList(MVT::i32, MVT::Other); } - NodeTys.push_back(MVT::i32); break; case MVT::v16i8: case MVT::v8i16: @@ -1884,7 +1878,7 @@ } else { Chain = DAG.getCopyFromReg(Chain, X86::XMM0, RetVT, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); - NodeTys.push_back(RetVT); + NodeTys = DAG.getVTList(RetVT, MVT::Other); } break; case MVT::f32: @@ -1925,7 +1919,8 @@ // operation is okay to eliminate if we allow excess FP precision. RetVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, RetVal); ResultVals.push_back(RetVal); - NodeTys.push_back(RetVT); + NodeTys = DAG.getVTList(RetVT, MVT::Other); + break; } } @@ -1936,7 +1931,6 @@ return Chain; // Otherwise, merge everything together with a MERGE_VALUES node. - NodeTys.push_back(MVT::Other); ResultVals.push_back(Chain); SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0], ResultVals.size()); @@ -3771,9 +3765,7 @@ } Constant *CS = ConstantStruct::get(CV); SDOperand CPIdx = DAG.getConstantPool(CS, getPointerTy(), 4); - std::vector Tys; - Tys.push_back(SrcVT); - Tys.push_back(MVT::Other); + SDVTList Tys = DAG.getVTList(SrcVT, MVT::Other); SmallVector Ops; Ops.push_back(DAG.getEntryNode()); Ops.push_back(CPIdx); @@ -3805,9 +3797,7 @@ } CS = ConstantStruct::get(CV); CPIdx = DAG.getConstantPool(CS, getPointerTy(), 4); - Tys.clear(); - Tys.push_back(VT); - Tys.push_back(MVT::Other); + Tys = DAG.getVTList(VT, MVT::Other); Ops.clear(); Ops.push_back(DAG.getEntryNode()); Ops.push_back(CPIdx); @@ -4202,9 +4192,7 @@ Op.getOperand(1), InFlag); InFlag = Chain.getValue(1); - std::vector Tys; - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); std::vector Ops; Ops.push_back(Chain); Ops.push_back(DAG.getValueType(AVT)); @@ -4220,9 +4208,7 @@ Chain = DAG.getCopyToReg(Chain, (CVT == MVT::i64) ? X86::RCX : X86::ECX, Left, InFlag); InFlag = Chain.getValue(1); - Tys.clear(); - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); + Tys = DAG.getVTList(MVT::Other, MVT::Flag); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getValueType(MVT::i8)); @@ -4338,9 +4324,7 @@ Op.getOperand(2), InFlag); InFlag = Chain.getValue(1); - std::vector Tys; - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); std::vector Ops; Ops.push_back(Chain); Ops.push_back(DAG.getValueType(AVT)); @@ -4356,9 +4340,7 @@ Chain = DAG.getCopyToReg(Chain, (CVT == MVT::i64) ? X86::RCX : X86::ECX, Left, InFlag); InFlag = Chain.getValue(1); - Tys.clear(); - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); + Tys = DAG.getVTList(MVT::Other, MVT::Flag); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getValueType(MVT::i8)); @@ -4417,9 +4399,7 @@ SDOperand X86TargetLowering::LowerREADCYCLCECOUNTER(SDOperand Op, SelectionDAG &DAG) { - std::vector Tys; - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); std::vector Ops; Ops.push_back(Op.getOperand(0)); SDOperand rd = DAG.getNode(X86ISD::RDTSC_DAG, Tys, &Ops[0], Ops.size()); @@ -4432,8 +4412,8 @@ DAG.getConstant(32, MVT::i8)); Ops.push_back(DAG.getNode(ISD::OR, MVT::i64, Copy1, Tmp)); Ops.push_back(Copy2.getValue(1)); - Tys[0] = MVT::i64; - Tys[1] = MVT::Other; + + Tys = DAG.getVTList(MVT::i64, MVT::Other); } else { SDOperand Copy1 = DAG.getCopyFromReg(rd, X86::EAX, MVT::i32, rd.getValue(1)); SDOperand Copy2 = DAG.getCopyFromReg(Copy1.getValue(1), X86::EDX, @@ -4441,8 +4421,7 @@ Ops.push_back(Copy1); Ops.push_back(Copy2); Ops.push_back(Copy2.getValue(1)); - Tys[0] = Tys[1] = MVT::i32; - Tys.push_back(MVT::Other); + Tys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); } return DAG.getNode(ISD::MERGE_VALUES, Tys, &Ops[0], Ops.size()); } @@ -5058,9 +5037,7 @@ LD->getSrcValueOffset()); } else { // Just use movups, it's shorter. - std::vector Tys; - Tys.push_back(MVT::v4f32); - Tys.push_back(MVT::Other); + SDVTList Tys = DAG.getVTList(MVT::v4f32, MVT::Other); SmallVector Ops; Ops.push_back(Base->getOperand(0)); Ops.push_back(Base->getOperand(1)); From sabre at nondot.org Sun Feb 25 01:10:17 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 01:10:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250710.l1P7AHbI031169@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.325 -> 1.326 --- Log message: eliminate a bunch more temporary vectors from X86 lowering. --- Diffs of the changes: (+141 -176) X86ISelLowering.cpp | 317 +++++++++++++++++++++++----------------------------- 1 files changed, 141 insertions(+), 176 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.325 llvm/lib/Target/X86/X86ISelLowering.cpp:1.326 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.325 Sun Feb 25 00:40:16 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 01:10:00 2007 @@ -520,7 +520,7 @@ MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); - std::vector ArgValues; + SmallVector ArgValues; bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; // Add DAG nodes to load the arguments... On entry to a function on the X86, @@ -549,8 +549,8 @@ }; // Handle regparm attribute - std::vector ArgInRegs(NumArgs, false); - std::vector SRetArgs(NumArgs, false); + SmallVector ArgInRegs(NumArgs, false); + SmallVector SRetArgs(NumArgs, false); if (!isVarArg) { for (unsigned i = 0; i(Op.getOperand(3+i))->getValue(); @@ -642,9 +642,8 @@ MF.getInfo()->setBytesToPopOnReturn(BytesToPopOnReturn); // Return the new list of results. - std::vector RetVTs(Op.Val->value_begin(), - Op.Val->value_end()); - return DAG.getNode(ISD::MERGE_VALUES, RetVTs, &ArgValues[0],ArgValues.size()); + return DAG.getNode(ISD::MERGE_VALUES, Op.Val->getVTList(), + &ArgValues[0], ArgValues.size()); } SDOperand X86TargetLowering::LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, @@ -673,8 +672,8 @@ unsigned NumSRetBytes= 0; // Handle regparm attribute - std::vector ArgInRegs(NumOps, false); - std::vector SRetArgs(NumOps, false); + SmallVector ArgInRegs(NumOps, false); + SmallVector SRetArgs(NumOps, false); for (unsigned i = 0; i(Op.getOperand(5+2*i+1))->getValue(); @@ -714,8 +713,8 @@ unsigned ArgOffset = 0; NumXMMRegs = 0; NumIntRegs = 0; - std::vector > RegsToPass; - std::vector MemOpChains; + SmallVector, 8> RegsToPass; + SmallVector MemOpChains; SDOperand StackPtr = DAG.getRegister(X86StackPtr, getPointerTy()); for (unsigned i = 0; i != NumOps; ++i) { SDOperand Arg = Op.getOperand(5+2*i); @@ -817,7 +816,7 @@ // Returns a chain & a flag for retval copy to use. SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); - std::vector Ops; + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(Callee); @@ -868,7 +867,7 @@ if (RetVT != MVT::Other) InFlag = Chain.getValue(1); - std::vector ResultVals; + SmallVector ResultVals; switch (RetVT) { default: assert(0 && "Unknown value type to return!"); case MVT::Other: break; @@ -909,15 +908,9 @@ break; case MVT::f32: case MVT::f64: { - std::vector Tys; - Tys.push_back(MVT::f64); - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); - std::vector Ops; - Ops.push_back(Chain); - Ops.push_back(InFlag); - SDOperand RetVal = DAG.getNode(X86ISD::FP_GET_RESULT, Tys, - &Ops[0], Ops.size()); + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other, MVT::Flag); + SDOperand GROps[] = { Chain, InFlag }; + SDOperand RetVal = DAG.getNode(X86ISD::FP_GET_RESULT, Tys, GROps, 2); Chain = RetVal.getValue(1); InFlag = RetVal.getValue(2); if (X86ScalarSSE) { @@ -927,15 +920,11 @@ MachineFunction &MF = DAG.getMachineFunction(); int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); - Tys.clear(); - Tys.push_back(MVT::Other); - Ops.clear(); - Ops.push_back(Chain); - Ops.push_back(RetVal); - Ops.push_back(StackSlot); - Ops.push_back(DAG.getValueType(RetVT)); - Ops.push_back(InFlag); - Chain = DAG.getNode(X86ISD::FST, Tys, &Ops[0], Ops.size()); + Tys = DAG.getVTList(MVT::Other); + SDOperand Ops[] = { + Chain, RetVal, StackSlot, DAG.getValueType(RetVT), InFlag + }; + Chain = DAG.getNode(X86ISD::FST, Tys, Ops, 5); RetVal = DAG.getLoad(RetVT, Chain, StackSlot, NULL, 0); Chain = RetVal.getValue(1); } @@ -1031,7 +1020,7 @@ MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; - std::vector ArgValues; + SmallVector ArgValues; // Add DAG nodes to load the arguments... On entry to a function on the X86, // the stack frame looks like this: @@ -1153,7 +1142,7 @@ RegSaveFrameIndex = MFI->CreateStackObject(6 * 8 + 8 * 16, 16); // Store the integer parameter registers. - std::vector MemOps; + SmallVector MemOps; SDOperand RSFIN = DAG.getFrameIndex(RegSaveFrameIndex, getPointerTy()); SDOperand FIN = DAG.getNode(ISD::ADD, getPointerTy(), RSFIN, DAG.getConstant(VarArgsGPOffset, getPointerTy())); @@ -1191,9 +1180,8 @@ BytesCallerReserves = ArgOffset; // Return the new list of results. - std::vector RetVTs(Op.Val->value_begin(), - Op.Val->value_end()); - return DAG.getNode(ISD::MERGE_VALUES, RetVTs, &ArgValues[0],ArgValues.size()); + return DAG.getNode(ISD::MERGE_VALUES, Op.Val->getVTList(), + &ArgValues[0], ArgValues.size()); } SDOperand @@ -1269,8 +1257,8 @@ unsigned ArgOffset = 0; NumIntRegs = 0; NumXMMRegs = 0; - std::vector > RegsToPass; - std::vector MemOpChains; + SmallVector, 8> RegsToPass; + SmallVector MemOpChains; SDOperand StackPtr = DAG.getRegister(X86StackPtr, getPointerTy()); for (unsigned i = 0; i != NumOps; ++i) { SDOperand Arg = Op.getOperand(5+2*i); @@ -1366,7 +1354,7 @@ // Returns a chain & a flag for retval copy to use. SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); - std::vector Ops; + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(Callee); @@ -1398,7 +1386,7 @@ if (RetVT != MVT::Other) InFlag = Chain.getValue(1); - std::vector ResultVals; + SmallVector ResultVals; switch (RetVT) { default: assert(0 && "Unknown value type to return!"); case MVT::Other: break; @@ -1492,7 +1480,7 @@ MachineFunction &MF = DAG.getMachineFunction(); MachineFrameInfo *MFI = MF.getFrameInfo(); SDOperand Root = Op.getOperand(0); - std::vector ArgValues; + SmallVector ArgValues; // Add DAG nodes to load the arguments... On entry to a function the stack // frame looks like this: @@ -1630,9 +1618,8 @@ } // Return the new list of results. - std::vector RetVTs(Op.Val->value_begin(), - Op.Val->value_end()); - return DAG.getNode(ISD::MERGE_VALUES, RetVTs, &ArgValues[0],ArgValues.size()); + return DAG.getNode(ISD::MERGE_VALUES, Op.Val->getVTList(), + &ArgValues[0], ArgValues.size()); } SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, @@ -1710,8 +1697,8 @@ // Arguments go on the stack in reverse order, as specified by the ABI. unsigned ArgOffset = 0; NumIntRegs = 0; - std::vector > RegsToPass; - std::vector MemOpChains; + SmallVector, 8> RegsToPass; + SmallVector MemOpChains; SDOperand StackPtr = DAG.getRegister(X86StackPtr, getPointerTy()); for (unsigned i = 0; i != NumOps; ++i) { SDOperand Arg = Op.getOperand(5+2*i); @@ -1802,7 +1789,7 @@ // Returns a chain & a flag for retval copy to use. SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); - std::vector Ops; + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(Callee); @@ -1839,7 +1826,7 @@ if (RetVT != MVT::Other) InFlag = Chain.getValue(1); - std::vector ResultVals; + SmallVector ResultVals; switch (RetVT) { default: assert(0 && "Unknown value type to return!"); case MVT::Other: break; @@ -1883,11 +1870,8 @@ break; case MVT::f32: case MVT::f64: { - std::vector Tys; - Tys.push_back(MVT::f64); - Tys.push_back(MVT::Other); - Tys.push_back(MVT::Flag); - std::vector Ops; + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other, MVT::Flag); + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(InFlag); SDOperand RetVal = DAG.getNode(X86ISD::FP_GET_RESULT, Tys, @@ -1901,8 +1885,7 @@ MachineFunction &MF = DAG.getMachineFunction(); int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); - Tys.clear(); - Tys.push_back(MVT::Other); + Tys = DAG.getVTList(MVT::Other); Ops.clear(); Ops.push_back(Chain); Ops.push_back(RetVal); @@ -2133,16 +2116,15 @@ /// isSHUFPMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to SHUFP*. -static bool isSHUFPMask(std::vector &N) { - unsigned NumElems = N.size(); +static bool isSHUFPMask(const SDOperand *Elems, unsigned NumElems) { if (NumElems != 2 && NumElems != 4) return false; unsigned Half = NumElems / 2; for (unsigned i = 0; i < Half; ++i) - if (!isUndefOrInRange(N[i], 0, NumElems)) + if (!isUndefOrInRange(Elems[i], 0, NumElems)) return false; for (unsigned i = Half; i < NumElems; ++i) - if (!isUndefOrInRange(N[i], NumElems, NumElems*2)) + if (!isUndefOrInRange(Elems[i], NumElems, NumElems*2)) return false; return true; @@ -2150,32 +2132,29 @@ bool X86::isSHUFPMask(SDNode *N) { assert(N->getOpcode() == ISD::BUILD_VECTOR); - std::vector Ops(N->op_begin(), N->op_end()); - return ::isSHUFPMask(Ops); + return ::isSHUFPMask(N->op_begin(), N->getNumOperands()); } /// isCommutedSHUFP - Returns true if the shuffle mask is except /// the reverse of what x86 shuffles want. x86 shuffles requires the lower /// half elements to come from vector 1 (which would equal the dest.) and /// the upper half to come from vector 2. -static bool isCommutedSHUFP(std::vector &Ops) { - unsigned NumElems = Ops.size(); - if (NumElems != 2 && NumElems != 4) return false; +static bool isCommutedSHUFP(const SDOperand *Ops, unsigned NumOps) { + if (NumOps != 2 && NumOps != 4) return false; - unsigned Half = NumElems / 2; + unsigned Half = NumOps / 2; for (unsigned i = 0; i < Half; ++i) - if (!isUndefOrInRange(Ops[i], NumElems, NumElems*2)) + if (!isUndefOrInRange(Ops[i], NumOps, NumOps*2)) return false; - for (unsigned i = Half; i < NumElems; ++i) - if (!isUndefOrInRange(Ops[i], 0, NumElems)) + for (unsigned i = Half; i < NumOps; ++i) + if (!isUndefOrInRange(Ops[i], 0, NumOps)) return false; return true; } static bool isCommutedSHUFP(SDNode *N) { assert(N->getOpcode() == ISD::BUILD_VECTOR); - std::vector Ops(N->op_begin(), N->op_end()); - return isCommutedSHUFP(Ops); + return isCommutedSHUFP(N->op_begin(), N->getNumOperands()); } /// isMOVHLPSMask - Return true if the specified VECTOR_SHUFFLE operand @@ -2254,21 +2233,21 @@ /// isUNPCKLMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to UNPCKL. -bool static isUNPCKLMask(std::vector &N, bool V2IsSplat = false) { - unsigned NumElems = N.size(); - if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) +bool static isUNPCKLMask(const SDOperand *Elts, unsigned NumElts, + bool V2IsSplat = false) { + if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) return false; - for (unsigned i = 0, j = 0; i != NumElems; i += 2, ++j) { - SDOperand BitI = N[i]; - SDOperand BitI1 = N[i+1]; + for (unsigned i = 0, j = 0; i != NumElts; i += 2, ++j) { + SDOperand BitI = Elts[i]; + SDOperand BitI1 = Elts[i+1]; if (!isUndefOrEqual(BitI, j)) return false; if (V2IsSplat) { - if (isUndefOrEqual(BitI1, NumElems)) + if (isUndefOrEqual(BitI1, NumElts)) return false; } else { - if (!isUndefOrEqual(BitI1, j + NumElems)) + if (!isUndefOrEqual(BitI1, j + NumElts)) return false; } } @@ -2278,27 +2257,26 @@ bool X86::isUNPCKLMask(SDNode *N, bool V2IsSplat) { assert(N->getOpcode() == ISD::BUILD_VECTOR); - std::vector Ops(N->op_begin(), N->op_end()); - return ::isUNPCKLMask(Ops, V2IsSplat); + return ::isUNPCKLMask(N->op_begin(), N->getNumOperands(), V2IsSplat); } /// isUNPCKHMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to UNPCKH. -bool static isUNPCKHMask(std::vector &N, bool V2IsSplat = false) { - unsigned NumElems = N.size(); - if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) +bool static isUNPCKHMask(const SDOperand *Elts, unsigned NumElts, + bool V2IsSplat = false) { + if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) return false; - for (unsigned i = 0, j = 0; i != NumElems; i += 2, ++j) { - SDOperand BitI = N[i]; - SDOperand BitI1 = N[i+1]; - if (!isUndefOrEqual(BitI, j + NumElems/2)) + for (unsigned i = 0, j = 0; i != NumElts; i += 2, ++j) { + SDOperand BitI = Elts[i]; + SDOperand BitI1 = Elts[i+1]; + if (!isUndefOrEqual(BitI, j + NumElts/2)) return false; if (V2IsSplat) { - if (isUndefOrEqual(BitI1, NumElems)) + if (isUndefOrEqual(BitI1, NumElts)) return false; } else { - if (!isUndefOrEqual(BitI1, j + NumElems/2 + NumElems)) + if (!isUndefOrEqual(BitI1, j + NumElts/2 + NumElts)) return false; } } @@ -2308,8 +2286,7 @@ bool X86::isUNPCKHMask(SDNode *N, bool V2IsSplat) { assert(N->getOpcode() == ISD::BUILD_VECTOR); - std::vector Ops(N->op_begin(), N->op_end()); - return ::isUNPCKHMask(Ops, V2IsSplat); + return ::isUNPCKHMask(N->op_begin(), N->getNumOperands(), V2IsSplat); } /// isUNPCKL_v_undef_Mask - Special case of isUNPCKLMask for canonical form @@ -2338,17 +2315,15 @@ /// isMOVLMask - Return true if the specified VECTOR_SHUFFLE operand /// specifies a shuffle of elements that is suitable for input to MOVSS, /// MOVSD, and MOVD, i.e. setting the lowest element. -static bool isMOVLMask(std::vector &N) { - unsigned NumElems = N.size(); - if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) +static bool isMOVLMask(const SDOperand *Elts, unsigned NumElts) { + if (NumElts != 2 && NumElts != 4 && NumElts != 8 && NumElts != 16) return false; - if (!isUndefOrEqual(N[0], NumElems)) + if (!isUndefOrEqual(Elts[0], NumElts)) return false; - for (unsigned i = 1; i < NumElems; ++i) { - SDOperand Arg = N[i]; - if (!isUndefOrEqual(Arg, i)) + for (unsigned i = 1; i < NumElts; ++i) { + if (!isUndefOrEqual(Elts[i], i)) return false; } @@ -2357,27 +2332,26 @@ bool X86::isMOVLMask(SDNode *N) { assert(N->getOpcode() == ISD::BUILD_VECTOR); - std::vector Ops(N->op_begin(), N->op_end()); - return ::isMOVLMask(Ops); + return ::isMOVLMask(N->op_begin(), N->getNumOperands()); } /// isCommutedMOVL - Returns true if the shuffle mask is except the reverse /// of what x86 movss want. X86 movs requires the lowest element to be lowest /// element of vector 2 and the other elements to come from vector 1 in order. -static bool isCommutedMOVL(std::vector &Ops, bool V2IsSplat = false, +static bool isCommutedMOVL(const SDOperand *Ops, unsigned NumOps, + bool V2IsSplat = false, bool V2IsUndef = false) { - unsigned NumElems = Ops.size(); - if (NumElems != 2 && NumElems != 4 && NumElems != 8 && NumElems != 16) + if (NumOps != 2 && NumOps != 4 && NumOps != 8 && NumOps != 16) return false; if (!isUndefOrEqual(Ops[0], 0)) return false; - for (unsigned i = 1; i < NumElems; ++i) { + for (unsigned i = 1; i < NumOps; ++i) { SDOperand Arg = Ops[i]; - if (!(isUndefOrEqual(Arg, i+NumElems) || - (V2IsUndef && isUndefOrInRange(Arg, NumElems, NumElems*2)) || - (V2IsSplat && isUndefOrEqual(Arg, NumElems)))) + if (!(isUndefOrEqual(Arg, i+NumOps) || + (V2IsUndef && isUndefOrInRange(Arg, NumOps, NumOps*2)) || + (V2IsSplat && isUndefOrEqual(Arg, NumOps)))) return false; } @@ -2387,8 +2361,8 @@ static bool isCommutedMOVL(SDNode *N, bool V2IsSplat = false, bool V2IsUndef = false) { assert(N->getOpcode() == ISD::BUILD_VECTOR); - std::vector Ops(N->op_begin(), N->op_end()); - return isCommutedMOVL(Ops, V2IsSplat, V2IsUndef); + return isCommutedMOVL(N->op_begin(), N->getNumOperands(), + V2IsSplat, V2IsUndef); } /// isMOVSHDUPMask - Return true if the specified VECTOR_SHUFFLE operand @@ -2607,7 +2581,7 @@ MVT::ValueType MaskVT = Mask.getValueType(); MVT::ValueType EltVT = MVT::getVectorBaseType(MaskVT); unsigned NumElems = Mask.getNumOperands(); - std::vector MaskVec; + SmallVector MaskVec; for (unsigned i = 0; i != NumElems; ++i) { SDOperand Arg = Mask.getOperand(i); @@ -2722,7 +2696,7 @@ assert(Mask.getOpcode() == ISD::BUILD_VECTOR); bool Changed = false; - std::vector MaskVec; + SmallVector MaskVec; unsigned NumElems = Mask.getNumOperands(); for (unsigned i = 0; i != NumElems; ++i) { SDOperand Arg = Mask.getOperand(i); @@ -2748,7 +2722,7 @@ MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType BaseVT = MVT::getVectorBaseType(MaskVT); - std::vector MaskVec; + SmallVector MaskVec; MaskVec.push_back(DAG.getConstant(NumElems, BaseVT)); for (unsigned i = 1; i != NumElems; ++i) MaskVec.push_back(DAG.getConstant(i, BaseVT)); @@ -2760,7 +2734,7 @@ static SDOperand getUnpacklMask(unsigned NumElems, SelectionDAG &DAG) { MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType BaseVT = MVT::getVectorBaseType(MaskVT); - std::vector MaskVec; + SmallVector MaskVec; for (unsigned i = 0, e = NumElems/2; i != e; ++i) { MaskVec.push_back(DAG.getConstant(i, BaseVT)); MaskVec.push_back(DAG.getConstant(i + NumElems, BaseVT)); @@ -2774,7 +2748,7 @@ MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType BaseVT = MVT::getVectorBaseType(MaskVT); unsigned Half = NumElems/2; - std::vector MaskVec; + SmallVector MaskVec; for (unsigned i = 0; i != Half; ++i) { MaskVec.push_back(DAG.getConstant(i + Half, BaseVT)); MaskVec.push_back(DAG.getConstant(i + NumElems + Half, BaseVT)); @@ -2790,7 +2764,7 @@ MVT::ValueType EVT = MVT::getVectorBaseType(VT); bool isFP = MVT::isFloatingPoint(EVT); SDOperand Zero = isFP ? DAG.getConstantFP(0.0, EVT) : DAG.getConstant(0, EVT); - std::vector ZeroVec(NumElems, Zero); + SmallVector ZeroVec(NumElems, Zero); return DAG.getNode(ISD::BUILD_VECTOR, VT, &ZeroVec[0], ZeroVec.size()); } @@ -2833,7 +2807,7 @@ MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType EVT = MVT::getVectorBaseType(MaskVT); SDOperand Zero = DAG.getConstant(0, EVT); - std::vector MaskVec(NumElems, Zero); + SmallVector MaskVec(NumElems, Zero); MaskVec[Idx] = DAG.getConstant(NumElems, EVT); SDOperand Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT, &MaskVec[0], MaskVec.size()); @@ -2968,7 +2942,7 @@ DAG); MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType MaskEVT = MVT::getVectorBaseType(MaskVT); - std::vector MaskVec; + SmallVector MaskVec; for (unsigned i = 0; i < NumElems; i++) MaskVec.push_back(DAG.getConstant((i == Idx) ? 0 : 1, MaskEVT)); SDOperand Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT, @@ -2996,7 +2970,8 @@ } // If element VT is == 32 bits, turn it into a number of shuffles. - std::vector V(NumElems); + SmallVector V; + V.resize(NumElems); if (NumElems == 4 && NumZero > 0) { for (unsigned i = 0; i < 4; ++i) { bool isZero = !(NonZeros & (1 << i)); @@ -3036,7 +3011,7 @@ return V[0]; MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType EVT = MVT::getVectorBaseType(MaskVT); - std::vector MaskVec; + SmallVector MaskVec; bool Reverse = (NonZeros & 0x3) == 2; for (unsigned i = 0; i < 2; ++i) if (Reverse) @@ -3187,7 +3162,7 @@ if (VT == MVT::v8i16 && isPSHUFHW_PSHUFLWMask(PermMask.Val)) { MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(NumElems); MVT::ValueType BaseVT = MVT::getVectorBaseType(MaskVT); - std::vector MaskVec; + SmallVector MaskVec; for (unsigned i = 0; i != 4; ++i) MaskVec.push_back(PermMask.getOperand(i)); for (unsigned i = 4; i != 8; ++i) @@ -3220,10 +3195,10 @@ if (NumElems == 4) { MVT::ValueType MaskVT = PermMask.getValueType(); MVT::ValueType MaskEVT = MVT::getVectorBaseType(MaskVT); - std::vector > Locs; + SmallVector, 8> Locs; Locs.reserve(NumElems); - std::vector Mask1(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); - std::vector Mask2(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); + SmallVector Mask1(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); + SmallVector Mask2(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); unsigned NumHi = 0; unsigned NumLo = 0; // If no more than two elements come from either vector. This can be @@ -3269,9 +3244,9 @@ // Break it into (shuffle shuffle_hi, shuffle_lo). Locs.clear(); - std::vector LoMask(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); - std::vector HiMask(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); - std::vector *MaskPtr = &LoMask; + SmallVector LoMask(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); + SmallVector HiMask(NumElems, DAG.getNode(ISD::UNDEF, MaskEVT)); + SmallVector *MaskPtr = &LoMask; unsigned MaskIdx = 0; unsigned LoIdx = 0; unsigned HiIdx = NumElems/2; @@ -3304,7 +3279,7 @@ DAG.getNode(ISD::VECTOR_SHUFFLE, VT, V1, V2, DAG.getNode(ISD::BUILD_VECTOR, MaskVT, &HiMask[0], HiMask.size())); - std::vector MaskOps; + SmallVector MaskOps; for (unsigned i = 0; i != NumElems; ++i) { if (Locs[i].first == -1) { MaskOps.push_back(DAG.getNode(ISD::UNDEF, MaskEVT)); @@ -3343,7 +3318,7 @@ return Op; // SHUFPS the element to the lowest double word, then movss. MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(4); - std::vector IdxVec; + SmallVector IdxVec; IdxVec.push_back(DAG.getConstant(Idx, MVT::getVectorBaseType(MaskVT))); IdxVec.push_back(DAG.getNode(ISD::UNDEF, MVT::getVectorBaseType(MaskVT))); IdxVec.push_back(DAG.getNode(ISD::UNDEF, MVT::getVectorBaseType(MaskVT))); @@ -3364,7 +3339,7 @@ // Note if the lower 64 bits of the result of the UNPCKHPD is then stored // to a f64mem, the whole operation is folded into a single MOVHPDmr. MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(4); - std::vector IdxVec; + SmallVector IdxVec; IdxVec.push_back(DAG.getConstant(1, MVT::getVectorBaseType(MaskVT))); IdxVec.push_back(DAG.getNode(ISD::UNDEF, MVT::getVectorBaseType(MaskVT))); SDOperand Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT, @@ -3400,7 +3375,7 @@ N1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, N1); MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(4); MVT::ValueType BaseVT = MVT::getVectorBaseType(MaskVT); - std::vector MaskVec; + SmallVector MaskVec; MaskVec.push_back(DAG.getConstant(4, BaseVT)); for (unsigned i = 1; i <= 3; ++i) MaskVec.push_back(DAG.getConstant(i, BaseVT)); @@ -3604,11 +3579,12 @@ StackSlot, NULL, 0); // Build the FILD - std::vector Tys; - Tys.push_back(MVT::f64); - Tys.push_back(MVT::Other); - if (X86ScalarSSE) Tys.push_back(MVT::Flag); - std::vector Ops; + SDVTList Tys; + if (X86ScalarSSE) + Tys = DAG.getVTList(MVT::f64, MVT::Other, MVT::Flag); + else + Tys = DAG.getVTList(MVT::f64, MVT::Other); + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(StackSlot); Ops.push_back(DAG.getValueType(SrcVT)); @@ -3625,9 +3601,8 @@ MachineFunction &MF = DAG.getMachineFunction(); int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); - std::vector Tys; - Tys.push_back(MVT::Other); - std::vector Ops; + Tys = DAG.getVTList(MVT::Other); + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(Result); Ops.push_back(StackSlot); @@ -3663,25 +3638,19 @@ if (X86ScalarSSE) { assert(Op.getValueType() == MVT::i64 && "Invalid FP_TO_SINT to lower!"); Chain = DAG.getStore(Chain, Value, StackSlot, NULL, 0); - std::vector Tys; - Tys.push_back(MVT::f64); - Tys.push_back(MVT::Other); - std::vector Ops; - Ops.push_back(Chain); - Ops.push_back(StackSlot); - Ops.push_back(DAG.getValueType(Op.getOperand(0).getValueType())); - Value = DAG.getNode(X86ISD::FLD, Tys, &Ops[0], Ops.size()); + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other); + SDOperand Ops[] = { + Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType()) + }; + Value = DAG.getNode(X86ISD::FLD, Tys, Ops, 3); Chain = Value.getValue(1); SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize); StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); } // Build the FP_TO_INT*_IN_MEM - std::vector Ops; - Ops.push_back(Chain); - Ops.push_back(Value); - Ops.push_back(StackSlot); - SDOperand FIST = DAG.getNode(Opc, MVT::Other, &Ops[0], Ops.size()); + SDOperand Ops[] = { Chain, Value, StackSlot }; + SDOperand FIST = DAG.getNode(Opc, MVT::Other, Ops, 3); // Load the result. return DAG.getLoad(Op.getValueType(), FIST, StackSlot, NULL, 0); @@ -3702,9 +3671,7 @@ } Constant *CS = ConstantStruct::get(CV); SDOperand CPIdx = DAG.getConstantPool(CS, getPointerTy(), 4); - std::vector Tys; - Tys.push_back(VT); - Tys.push_back(MVT::Other); + SDVTList Tys = DAG.getVTList(VT, MVT::Other); SmallVector Ops; Ops.push_back(DAG.getEntryNode()); Ops.push_back(CPIdx); @@ -3728,9 +3695,7 @@ } Constant *CS = ConstantStruct::get(CV); SDOperand CPIdx = DAG.getConstantPool(CS, getPointerTy(), 4); - std::vector Tys; - Tys.push_back(VT); - Tys.push_back(MVT::Other); + SDVTList Tys = DAG.getVTList(VT, MVT::Other); SmallVector Ops; Ops.push_back(DAG.getEntryNode()); Ops.push_back(CPIdx); @@ -4193,7 +4158,7 @@ InFlag = Chain.getValue(1); SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); - std::vector Ops; + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(DAG.getValueType(AVT)); Ops.push_back(InFlag); @@ -4325,7 +4290,7 @@ InFlag = Chain.getValue(1); SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); - std::vector Ops; + SmallVector Ops; Ops.push_back(Chain); Ops.push_back(DAG.getValueType(AVT)); Ops.push_back(InFlag); @@ -4400,30 +4365,28 @@ SDOperand X86TargetLowering::LowerREADCYCLCECOUNTER(SDOperand Op, SelectionDAG &DAG) { SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); - std::vector Ops; - Ops.push_back(Op.getOperand(0)); - SDOperand rd = DAG.getNode(X86ISD::RDTSC_DAG, Tys, &Ops[0], Ops.size()); - Ops.clear(); + SDOperand TheOp = Op.getOperand(0); + SDOperand rd = DAG.getNode(X86ISD::RDTSC_DAG, Tys, &TheOp, 1); if (Subtarget->is64Bit()) { SDOperand Copy1 = DAG.getCopyFromReg(rd, X86::RAX, MVT::i64, rd.getValue(1)); SDOperand Copy2 = DAG.getCopyFromReg(Copy1.getValue(1), X86::RDX, MVT::i64, Copy1.getValue(2)); SDOperand Tmp = DAG.getNode(ISD::SHL, MVT::i64, Copy2, DAG.getConstant(32, MVT::i8)); - Ops.push_back(DAG.getNode(ISD::OR, MVT::i64, Copy1, Tmp)); - Ops.push_back(Copy2.getValue(1)); + SDOperand Ops[] = { + DAG.getNode(ISD::OR, MVT::i64, Copy1, Tmp), Copy2.getValue(1) + }; Tys = DAG.getVTList(MVT::i64, MVT::Other); - } else { - SDOperand Copy1 = DAG.getCopyFromReg(rd, X86::EAX, MVT::i32, rd.getValue(1)); - SDOperand Copy2 = DAG.getCopyFromReg(Copy1.getValue(1), X86::EDX, - MVT::i32, Copy1.getValue(2)); - Ops.push_back(Copy1); - Ops.push_back(Copy2); - Ops.push_back(Copy2.getValue(1)); - Tys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); + return DAG.getNode(ISD::MERGE_VALUES, Tys, Ops, 2); } - return DAG.getNode(ISD::MERGE_VALUES, Tys, &Ops[0], Ops.size()); + + SDOperand Copy1 = DAG.getCopyFromReg(rd, X86::EAX, MVT::i32, rd.getValue(1)); + SDOperand Copy2 = DAG.getCopyFromReg(Copy1.getValue(1), X86::EDX, + MVT::i32, Copy1.getValue(2)); + SDOperand Ops[] = { Copy1, Copy2, Copy2.getValue(1) }; + Tys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); + return DAG.getNode(ISD::MERGE_VALUES, Tys, Ops, 3); } SDOperand X86TargetLowering::LowerVASTART(SDOperand Op, SelectionDAG &DAG) { @@ -4442,7 +4405,7 @@ // fp_offset (48 - 48 + 8 * 16) // overflow_arg_area (point to parameters coming in memory). // reg_save_area - std::vector MemOps; + SmallVector MemOps; SDOperand FIN = Op.getOperand(1); // Store gp_offset SDOperand Store = DAG.getStore(Op.getOperand(0), @@ -4730,8 +4693,10 @@ if (MVT::getSizeInBits(EVT) * NumElts == 64) return false; if (NumElts == 2) return true; if (NumElts == 4) { - return (isMOVLMask(BVOps) || isCommutedMOVL(BVOps, true) || - isSHUFPMask(BVOps) || isCommutedSHUFP(BVOps)); + return (isMOVLMask(&BVOps[0], 4) || + isCommutedMOVL(&BVOps[0], 4, true) || + isSHUFPMask(&BVOps[0], 4) || + isCommutedSHUFP(&BVOps[0], 4)); } return false; } From sabre at nondot.org Sun Feb 25 01:18:55 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 01:18:55 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250718.l1P7ItB4031332@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.326 -> 1.327 --- Log message: make void-return not a special case --- Diffs of the changes: (+17 -33) X86ISelLowering.cpp | 50 +++++++++++++++++--------------------------------- 1 files changed, 17 insertions(+), 33 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.326 llvm/lib/Target/X86/X86ISelLowering.cpp:1.327 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.326 Sun Feb 25 01:10:00 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 01:18:38 2007 @@ -854,10 +854,7 @@ NumBytesForCalleeToPush = NumSRetBytes; } - if (RetVT != MVT::Other) - NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); - else - NodeTys = DAG.getVTList(MVT::Other); + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); @@ -870,7 +867,9 @@ SmallVector ResultVals; switch (RetVT) { default: assert(0 && "Unknown value type to return!"); - case MVT::Other: break; + case MVT::Other: + NodeTys = DAG.getVTList(MVT::Other); + break; case MVT::i8: Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); @@ -939,11 +938,7 @@ } } - // If the function returns void, just return the chain. - if (ResultVals.empty()) - return Chain; - - // Otherwise, merge everything together with a MERGE_VALUES node. + // Merge everything together with a MERGE_VALUES node. ResultVals.push_back(Chain); SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0], ResultVals.size()); @@ -1372,11 +1367,8 @@ NodeTys, &Ops[0], Ops.size()); InFlag = Chain.getValue(1); - if (RetVT != MVT::Other) - // Returns a flag for retval copy to use. - NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); - else - NodeTys = DAG.getVTList(MVT::Other); + // Returns a flag for retval copy to use. + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); @@ -1389,7 +1381,9 @@ SmallVector ResultVals; switch (RetVT) { default: assert(0 && "Unknown value type to return!"); - case MVT::Other: break; + case MVT::Other: + NodeTys = DAG.getVTList(MVT::Other); + break; case MVT::i8: Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); @@ -1435,11 +1429,7 @@ break; } - // If the function returns void, just return the chain. - if (ResultVals.empty()) - return Chain; - - // Otherwise, merge everything together with a MERGE_VALUES node. + // Merge everything together with a MERGE_VALUES node. ResultVals.push_back(Chain); SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0], ResultVals.size()); @@ -1812,11 +1802,8 @@ NodeTys, &Ops[0], Ops.size()); InFlag = Chain.getValue(1); - if (RetVT != MVT::Other) - // Returns a flag for retval copy to use. - NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); - else - NodeTys = DAG.getVTList(MVT::Other); + // Returns a flag for retval copy to use. + NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); Ops.clear(); Ops.push_back(Chain); Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); @@ -1829,7 +1816,9 @@ SmallVector ResultVals; switch (RetVT) { default: assert(0 && "Unknown value type to return!"); - case MVT::Other: break; + case MVT::Other: + NodeTys = DAG.getVTList(MVT::Other); + break; case MVT::i8: Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); ResultVals.push_back(Chain.getValue(0)); @@ -1908,12 +1897,7 @@ } } - - // If the function returns void, just return the chain. - if (ResultVals.empty()) - return Chain; - - // Otherwise, merge everything together with a MERGE_VALUES node. + // Merge everything together with a MERGE_VALUES node. ResultVals.push_back(Chain); SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0], ResultVals.size()); From reid at x10sys.com Sun Feb 25 01:29:20 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 01:29:20 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h Message-ID: <200702250729.l1P7TKfF031511@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.17 -> 1.18 --- Log message: Add a private constructor for efficiency. --- Diffs of the changes: (+4 -0) APInt.h | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.17 llvm/include/llvm/ADT/APInt.h:1.18 --- llvm/include/llvm/ADT/APInt.h:1.17 Sat Feb 24 03:50:13 2007 +++ llvm/include/llvm/ADT/APInt.h Sun Feb 25 01:29:03 2007 @@ -60,6 +60,7 @@ /// @brief Class for arbitrary precision integers. class APInt { public: + uint32_t BitWidth; ///< The number of bits in this APInt. /// This union is used to store the integer value. When the @@ -76,6 +77,9 @@ APINT_WORD_SIZE = sizeof(uint64_t) }; + // Fast internal constructor + APInt(uint64_t* val, uint32_t bits) : BitWidth(bits), pVal(val) { } + /// Here one word's bitwidth equals to that of uint64_t. /// @returns the number of words to hold the integer value of this APInt. /// @brief Get the number of words. From reid at x10sys.com Sun Feb 25 01:30:30 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 01:30:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702250730.l1P7UUmq031550@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.40 -> 1.41 --- Log message: Allow this to compile now that the header file is checked in. --- Diffs of the changes: (+0 -4) APInt.cpp | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.40 llvm/lib/Support/APInt.cpp:1.41 --- llvm/lib/Support/APInt.cpp:1.40 Sat Feb 24 20:32:44 2007 +++ llvm/lib/Support/APInt.cpp Sun Feb 25 01:30:14 2007 @@ -26,8 +26,6 @@ using namespace llvm; -#if 0 - // A utility function for allocating memory, checking for allocation failures, // and ensuring the contents are zeroed. inline static uint64_t* getClearedMemory(uint32_t numWords) { @@ -1589,5 +1587,3 @@ cerr << " (" << this->toString(10, false) << ")\n" << std::setbase(10); } #endif - -#endif From sabre at nondot.org Sun Feb 25 02:15:30 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 02:15:30 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86ISelLowering.h Message-ID: <200702250815.l1P8FUue005315@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.327 -> 1.328 X86ISelLowering.h updated: 1.85 -> 1.86 --- Log message: simplify result value lowering by splitting the selection of *where* to return registers out from the logic of *how* to return them. This changes X86-64 to mark EAX live out when returning a 32-bit value, where before it marked RAX liveout. --- Diffs of the changes: (+111 -91) X86ISelLowering.cpp | 190 ++++++++++++++++++++++++++++------------------------ X86ISelLowering.h | 12 +-- 2 files changed, 111 insertions(+), 91 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.327 llvm/lib/Target/X86/X86ISelLowering.cpp:1.328 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.327 Sun Feb 25 01:18:38 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 02:15:11 2007 @@ -3915,96 +3915,116 @@ } } -SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) { - SDOperand Copy; +/// GetRetValueLocs - If we are returning a set of values with the specified +/// value types, determine the set of registers each one will land in. This +/// sets one element of the ResultRegs array for each element in the VTs array. +static void GetRetValueLocs(const MVT::ValueType *VTs, unsigned NumVTs, + unsigned *ResultRegs, + const X86Subtarget *Subtarget) { + if (NumVTs == 0) return; + + if (NumVTs == 2) { + ResultRegs[0] = VTs[0] == MVT::i64 ? X86::RAX : X86::EAX; + ResultRegs[1] = VTs[1] == MVT::i64 ? X86::RDX : X86::EDX; + return; + } + + // Otherwise, NumVTs is 1. + MVT::ValueType ArgVT = VTs[0]; + + if (MVT::isVector(ArgVT)) // Integer or FP vector result -> XMM0. + ResultRegs[0] = X86::XMM0; + else if (MVT::isFloatingPoint(ArgVT) && Subtarget->is64Bit()) + // FP values in X86-64 go in XMM0. + ResultRegs[0] = X86::XMM0; + else if (MVT::isFloatingPoint(ArgVT)) + // FP values in X86-32 go in ST0. + ResultRegs[0] = X86::ST0; + else { + assert(MVT::isInteger(ArgVT) && "Unknown return value type!"); + + // Integer result -> EAX / RAX. + // The C calling convention guarantees the return value has been + // promoted to at least MVT::i32. The X86-64 ABI doesn't require the + // value to be promoted MVT::i64. So we don't have to extend it to + // 64-bit. + ResultRegs[0] = (ArgVT == MVT::i64) ? X86::RAX : X86::EAX; + } +} - switch(Op.getNumOperands()) { - default: - assert(0 && "Do not know how to return this many arguments!"); - abort(); - case 1: // ret void. - return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Op.getOperand(0), - DAG.getConstant(getBytesToPopOnReturn(), MVT::i16)); - case 3: { - MVT::ValueType ArgVT = Op.getOperand(1).getValueType(); - - if (MVT::isVector(ArgVT) || - (Subtarget->is64Bit() && MVT::isFloatingPoint(ArgVT))) { - // Integer or FP vector result -> XMM0. - if (DAG.getMachineFunction().liveout_empty()) - DAG.getMachineFunction().addLiveOut(X86::XMM0); - Copy = DAG.getCopyToReg(Op.getOperand(0), X86::XMM0, Op.getOperand(1), - SDOperand()); - } else if (MVT::isInteger(ArgVT)) { - // Integer result -> EAX / RAX. - // The C calling convention guarantees the return value has been - // promoted to at least MVT::i32. The X86-64 ABI doesn't require the - // value to be promoted MVT::i64. So we don't have to extend it to - // 64-bit. Return the value in EAX, but mark RAX as liveout. - unsigned Reg = Subtarget->is64Bit() ? X86::RAX : X86::EAX; - if (DAG.getMachineFunction().liveout_empty()) - DAG.getMachineFunction().addLiveOut(Reg); - - Reg = (ArgVT == MVT::i64) ? X86::RAX : X86::EAX; - Copy = DAG.getCopyToReg(Op.getOperand(0), Reg, Op.getOperand(1), - SDOperand()); - } else if (!X86ScalarSSE) { - // FP return with fp-stack value. - if (DAG.getMachineFunction().liveout_empty()) - DAG.getMachineFunction().addLiveOut(X86::ST0); - - SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); - SDOperand Ops[] = { Op.getOperand(0), Op.getOperand(1) }; - Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); - } else { - // FP return with ScalarSSE (return on fp-stack). - if (DAG.getMachineFunction().liveout_empty()) - DAG.getMachineFunction().addLiveOut(X86::ST0); - - SDOperand MemLoc; - SDOperand Chain = Op.getOperand(0); - SDOperand Value = Op.getOperand(1); - - if (ISD::isNON_EXTLoad(Value.Val) && - (Chain == Value.getValue(1) || Chain == Value.getOperand(0))) { - Chain = Value.getOperand(0); - MemLoc = Value.getOperand(1); - } else { - // Spill the value to memory and reload it into top of stack. - unsigned Size = MVT::getSizeInBits(ArgVT)/8; - MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size); - MemLoc = DAG.getFrameIndex(SSFI, getPointerTy()); - Chain = DAG.getStore(Op.getOperand(0), Value, MemLoc, NULL, 0); - } - SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other); - SDOperand Ops[] = { Chain, MemLoc, DAG.getValueType(ArgVT) }; - Copy = DAG.getNode(X86ISD::FLD, Tys, Ops, 3); - - Tys = DAG.getVTList(MVT::Other, MVT::Flag); - Ops[0] = Copy.getValue(1); - Ops[1] = Copy; - Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); - } - break; + +SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) { + assert((Op.getNumOperands() & 1) == 1 && "ISD::RET should have odd # args"); + + // Support up returning up to two registers. + MVT::ValueType VTs[2]; + unsigned DestRegs[2]; + unsigned NumRegs = Op.getNumOperands() / 2; + assert(NumRegs <= 2 && "Can only return up to two regs!"); + + for (unsigned i = 0; i != NumRegs; ++i) + VTs[i] = Op.getOperand(i*2+1).getValueType(); + + // Determine which register each value should be copied into. + GetRetValueLocs(VTs, NumRegs, DestRegs, Subtarget); + + // If this is the first return lowered for this function, add the regs to the + // liveout set for the function. + if (DAG.getMachineFunction().liveout_empty()) { + for (unsigned i = 0; i != NumRegs; ++i) + DAG.getMachineFunction().addLiveOut(DestRegs[i]); + } + + SDOperand Chain = Op.getOperand(0); + SDOperand Flag; + + // Copy the result values into the output registers. + if (NumRegs != 1 || DestRegs[0] != X86::ST0) { + for (unsigned i = 0; i != NumRegs; ++i) { + Chain = DAG.getCopyToReg(Chain, DestRegs[i], Op.getOperand(i*2+1), Flag); + Flag = Chain.getValue(1); } - case 5: { - unsigned Reg1 = Subtarget->is64Bit() ? X86::RAX : X86::EAX; - unsigned Reg2 = Subtarget->is64Bit() ? X86::RDX : X86::EDX; - if (DAG.getMachineFunction().liveout_empty()) { - DAG.getMachineFunction().addLiveOut(Reg1); - DAG.getMachineFunction().addLiveOut(Reg2); + } else { + // We need to handle a destination of ST0 specially, because it isn't really + // a register. + SDOperand Value = Op.getOperand(1); + + // If this is an FP return with ScalarSSE, we need to move the value from + // an XMM register onto the fp-stack. + if (X86ScalarSSE) { + SDOperand MemLoc; + + // If this is a load into a scalarsse value, don't store the loaded value + // back to the stack, only to reload it: just replace the scalar-sse load. + if (ISD::isNON_EXTLoad(Value.Val) && + (Chain == Value.getValue(1) || Chain == Value.getOperand(0))) { + Chain = Value.getOperand(0); + MemLoc = Value.getOperand(1); + } else { + // Spill the value to memory and reload it into top of stack. + unsigned Size = MVT::getSizeInBits(VTs[0])/8; + MachineFunction &MF = DAG.getMachineFunction(); + int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size); + MemLoc = DAG.getFrameIndex(SSFI, getPointerTy()); + Chain = DAG.getStore(Op.getOperand(0), Value, MemLoc, NULL, 0); } - - Copy = DAG.getCopyToReg(Op.getOperand(0), Reg2, Op.getOperand(3), - SDOperand()); - Copy = DAG.getCopyToReg(Copy, Reg1, Op.getOperand(1), Copy.getValue(1)); - break; + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other); + SDOperand Ops[] = { Chain, MemLoc, DAG.getValueType(VTs[0]) }; + Value = DAG.getNode(X86ISD::FLD, Tys, Ops, 3); + Chain = Value.getValue(1); } + + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); + SDOperand Ops[] = { Chain, Value }; + Chain = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); + Flag = Chain.getValue(1); } - return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, - Copy, DAG.getConstant(getBytesToPopOnReturn(), MVT::i16), - Copy.getValue(1)); + + SDOperand BytesToPop = DAG.getConstant(getBytesToPopOnReturn(), MVT::i16); + if (Flag.Val) + return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Chain, BytesToPop, Flag); + else + return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Chain, BytesToPop); } SDOperand Index: llvm/lib/Target/X86/X86ISelLowering.h diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.85 llvm/lib/Target/X86/X86ISelLowering.h:1.86 --- llvm/lib/Target/X86/X86ISelLowering.h:1.85 Mon Jan 29 16:58:52 2007 +++ llvm/lib/Target/X86/X86ISelLowering.h Sun Feb 25 02:15:11 2007 @@ -76,14 +76,14 @@ /// as. FST, - /// FP_SET_RESULT - This corresponds to FpGETRESULT pseudo instrcuction - /// which copies from ST(0) to the destination. It takes a chain and writes - /// a RFP result and a chain. + /// FP_GET_RESULT - This corresponds to FpGETRESULT pseudo instruction + /// which copies from ST(0) to the destination. It takes a chain and + /// writes a RFP result and a chain. FP_GET_RESULT, - /// FP_SET_RESULT - This corresponds to FpSETRESULT pseudo instrcuction - /// which copies the source operand to ST(0). It takes a chain and writes - /// a chain and a flag. + /// FP_SET_RESULT - This corresponds to FpSETRESULT pseudo instruction + /// which copies the source operand to ST(0). It takes a chain+value and + /// returns a chain and a flag. FP_SET_RESULT, /// CALL/TAILCALL - These operations represent an abstract X86 call From sabre at nondot.org Sun Feb 25 02:23:18 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 02:23:18 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/fp-stack-ret.ll Message-ID: <200702250823.l1P8NIjn009114@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: fp-stack-ret.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+12 -0) fp-stack-ret.ll | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/test/CodeGen/X86/fp-stack-ret.ll diff -c /dev/null llvm/test/CodeGen/X86/fp-stack-ret.ll:1.1 *** /dev/null Sun Feb 25 02:23:11 2007 --- llvm/test/CodeGen/X86/fp-stack-ret.ll Sun Feb 25 02:23:01 2007 *************** *** 0 **** --- 1,12 ---- + ; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -march=x86 | grep fldl && + ; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -march=x86 | not grep xmm && + ; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -march=x86 | not grep 'sub.*esp' + + ; These testcases shouldn't require loading into an XMM register then storing + ; to memory, then reloading into an FPStack reg. + + define double @test1(double *%P) { + %A = load double* %P + ret double %A + } + From sabre at nondot.org Sun Feb 25 02:24:44 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 02:24:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200702250824.l1P8Oi9a009146@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAG.cpp updated: 1.390 -> 1.391 --- Log message: fold trivial token factor nodes. This allows us to compile test/CodeGen/X86/fp-stack-ret.ll into: movl 4(%esp), %eax fldl (%eax) ret instead of: subl $12, %esp movl 16(%esp), %eax movsd (%eax), %xmm0 movsd %xmm0, (%esp) fldl (%esp) addl $12, %esp ret by eliminating a token factor that blocked a check. --- Diffs of the changes: (+6 -0) SelectionDAG.cpp | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.390 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.391 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.390 Wed Feb 21 16:53:45 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Feb 25 02:24:27 2007 @@ -1351,6 +1351,12 @@ // Fold operations. switch (Opcode) { + case ISD::TokenFactor: + // Fold trivial token factors. + if (N1.getOpcode() == ISD::EntryToken) return N2; + if (N2.getOpcode() == ISD::EntryToken) return N1; + break; + case ISD::AND: // (X & 0) -> 0. This commonly occurs when legalizing i64 values, so it's // worth handling here. From sabre at nondot.org Sun Feb 25 02:29:17 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 02:29:17 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250829.l1P8THCN009273@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.328 -> 1.329 --- Log message: move some code around, pass in calling conv, even though it is unused --- Diffs of the changes: (+46 -39) X86ISelLowering.cpp | 85 ++++++++++++++++++++++++++++------------------------ 1 files changed, 46 insertions(+), 39 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.328 llvm/lib/Target/X86/X86ISelLowering.cpp:1.329 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.328 Sun Feb 25 02:15:11 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 02:29:00 2007 @@ -423,6 +423,50 @@ allowUnalignedMemoryAccesses = true; // x86 supports it! } + +//===----------------------------------------------------------------------===// +// Return Value Calling Convention Implementation +//===----------------------------------------------------------------------===// + +/// GetRetValueLocs - If we are returning a set of values with the specified +/// value types, determine the set of registers each one will land in. This +/// sets one element of the ResultRegs array for each element in the VTs array. +static void GetRetValueLocs(const MVT::ValueType *VTs, unsigned NumVTs, + unsigned *ResultRegs, + const X86Subtarget *Subtarget, + unsigned CallingConv) { + if (NumVTs == 0) return; + + if (NumVTs == 2) { + ResultRegs[0] = VTs[0] == MVT::i64 ? X86::RAX : X86::EAX; + ResultRegs[1] = VTs[1] == MVT::i64 ? X86::RDX : X86::EDX; + return; + } + + // Otherwise, NumVTs is 1. + MVT::ValueType ArgVT = VTs[0]; + + if (MVT::isVector(ArgVT)) // Integer or FP vector result -> XMM0. + ResultRegs[0] = X86::XMM0; + else if (MVT::isFloatingPoint(ArgVT) && Subtarget->is64Bit()) + // FP values in X86-64 go in XMM0. + ResultRegs[0] = X86::XMM0; + else if (MVT::isFloatingPoint(ArgVT)) + // FP values in X86-32 go in ST0. + ResultRegs[0] = X86::ST0; + else { + assert(MVT::isInteger(ArgVT) && "Unknown return value type!"); + + // Integer result -> EAX / RAX. + // The C calling convention guarantees the return value has been + // promoted to at least MVT::i32. The X86-64 ABI doesn't require the + // value to be promoted MVT::i64. So we don't have to extend it to + // 64-bit. + ResultRegs[0] = (ArgVT == MVT::i64) ? X86::RAX : X86::EAX; + } +} + + //===----------------------------------------------------------------------===// // C & StdCall Calling Convention implementation //===----------------------------------------------------------------------===// @@ -3915,44 +3959,6 @@ } } -/// GetRetValueLocs - If we are returning a set of values with the specified -/// value types, determine the set of registers each one will land in. This -/// sets one element of the ResultRegs array for each element in the VTs array. -static void GetRetValueLocs(const MVT::ValueType *VTs, unsigned NumVTs, - unsigned *ResultRegs, - const X86Subtarget *Subtarget) { - if (NumVTs == 0) return; - - if (NumVTs == 2) { - ResultRegs[0] = VTs[0] == MVT::i64 ? X86::RAX : X86::EAX; - ResultRegs[1] = VTs[1] == MVT::i64 ? X86::RDX : X86::EDX; - return; - } - - // Otherwise, NumVTs is 1. - MVT::ValueType ArgVT = VTs[0]; - - if (MVT::isVector(ArgVT)) // Integer or FP vector result -> XMM0. - ResultRegs[0] = X86::XMM0; - else if (MVT::isFloatingPoint(ArgVT) && Subtarget->is64Bit()) - // FP values in X86-64 go in XMM0. - ResultRegs[0] = X86::XMM0; - else if (MVT::isFloatingPoint(ArgVT)) - // FP values in X86-32 go in ST0. - ResultRegs[0] = X86::ST0; - else { - assert(MVT::isInteger(ArgVT) && "Unknown return value type!"); - - // Integer result -> EAX / RAX. - // The C calling convention guarantees the return value has been - // promoted to at least MVT::i32. The X86-64 ABI doesn't require the - // value to be promoted MVT::i64. So we don't have to extend it to - // 64-bit. - ResultRegs[0] = (ArgVT == MVT::i64) ? X86::RAX : X86::EAX; - } -} - - SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) { assert((Op.getNumOperands() & 1) == 1 && "ISD::RET should have odd # args"); @@ -3966,7 +3972,8 @@ VTs[i] = Op.getOperand(i*2+1).getValueType(); // Determine which register each value should be copied into. - GetRetValueLocs(VTs, NumRegs, DestRegs, Subtarget); + GetRetValueLocs(VTs, NumRegs, DestRegs, Subtarget, + DAG.getMachineFunction().getFunction()->getCallingConv()); // If this is the first return lowered for this function, add the regs to the // liveout set for the function. From sabre at nondot.org Sun Feb 25 02:59:39 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 02:59:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86ISelLowering.h Message-ID: <200702250859.l1P8xdUB009830@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.329 -> 1.330 X86ISelLowering.h updated: 1.86 -> 1.87 --- Log message: factor a bunch of code out of LowerCCCCallTo into a new LowerCallResult function. This function now uses GetRetValueLocs to determine *where* the result values are located and concerns itself with *how* to pull the values out. --- Diffs of the changes: (+97 -100) X86ISelLowering.cpp | 194 +++++++++++++++++++++++++--------------------------- X86ISelLowering.h | 3 2 files changed, 97 insertions(+), 100 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.329 llvm/lib/Target/X86/X86ISelLowering.cpp:1.330 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.329 Sun Feb 25 02:29:00 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 02:59:22 2007 @@ -446,24 +446,96 @@ // Otherwise, NumVTs is 1. MVT::ValueType ArgVT = VTs[0]; - if (MVT::isVector(ArgVT)) // Integer or FP vector result -> XMM0. - ResultRegs[0] = X86::XMM0; - else if (MVT::isFloatingPoint(ArgVT) && Subtarget->is64Bit()) - // FP values in X86-64 go in XMM0. - ResultRegs[0] = X86::XMM0; - else if (MVT::isFloatingPoint(ArgVT)) - // FP values in X86-32 go in ST0. - ResultRegs[0] = X86::ST0; - else { - assert(MVT::isInteger(ArgVT) && "Unknown return value type!"); + unsigned Reg; + switch (ArgVT) { + case MVT::i8: Reg = X86::AL; break; + case MVT::i16: Reg = X86::AX; break; + case MVT::i32: Reg = X86::EAX; break; + case MVT::i64: Reg = X86::RAX; break; + case MVT::f32: + case MVT::f64: + if (Subtarget->is64Bit()) + Reg = X86::XMM0; // FP values in X86-64 go in XMM0. + else + Reg = X86::ST0; // FP values in X86-32 go in ST0. + break; + default: + assert(MVT::isVector(ArgVT) && "Unknown return value type!"); + Reg = X86::XMM0; // Int/FP vector result -> XMM0. + break; + } + ResultRegs[0] = Reg; +} + +/// LowerCallResult - Lower the result values of an ISD::CALL into the +/// appropriate copies out of appropriate physical registers. This assumes that +/// Chain/InFlag are the input chain/flag to use, and that TheCall is the call +/// being lowered. The returns a SDNode with the same number of values as the +/// ISD::CALL. +SDNode *X86TargetLowering:: +LowerCallResult(SDOperand Chain, SDOperand InFlag, SDNode *TheCall, + unsigned CallingConv, SelectionDAG &DAG) { + SmallVector ResultVals; + + // We support returning up to two registers. + MVT::ValueType VTs[2]; + unsigned DestRegs[2]; + unsigned NumRegs = TheCall->getNumValues() - 1; + assert(NumRegs <= 2 && "Can only return up to two regs!"); + + for (unsigned i = 0; i != NumRegs; ++i) + VTs[i] = TheCall->getValueType(i); + + // Determine which register each value should be copied into. + GetRetValueLocs(VTs, NumRegs, DestRegs, Subtarget, CallingConv); + + // Copy all of the result registers out of their specified physreg. + if (NumRegs != 1 || DestRegs[0] != X86::ST0) { + for (unsigned i = 0; i != NumRegs; ++i) { + Chain = DAG.getCopyFromReg(Chain, DestRegs[i], VTs[i], + InFlag).getValue(1); + InFlag = Chain.getValue(2); + ResultVals.push_back(Chain.getValue(0)); + } + } else { + // Copies from the FP stack are special, as ST0 isn't a valid register + // before the fp stackifier runs. - // Integer result -> EAX / RAX. - // The C calling convention guarantees the return value has been - // promoted to at least MVT::i32. The X86-64 ABI doesn't require the - // value to be promoted MVT::i64. So we don't have to extend it to - // 64-bit. - ResultRegs[0] = (ArgVT == MVT::i64) ? X86::RAX : X86::EAX; + // Copy ST0 into an RFP register with FP_GET_RESULT. + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other, MVT::Flag); + SDOperand GROps[] = { Chain, InFlag }; + SDOperand RetVal = DAG.getNode(X86ISD::FP_GET_RESULT, Tys, GROps, 2); + Chain = RetVal.getValue(1); + InFlag = RetVal.getValue(2); + + // If we are using ScalarSSE, store ST(0) to the stack and reload it into + // an XMM register. + if (X86ScalarSSE) { + // FIXME: Currently the FST is flagged to the FP_GET_RESULT. This + // shouldn't be necessary except that RFP cannot be live across + // multiple blocks. When stackifier is fixed, they can be uncoupled. + MachineFunction &MF = DAG.getMachineFunction(); + int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); + SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); + SDOperand Ops[] = { + Chain, RetVal, StackSlot, DAG.getValueType(VTs[0]), InFlag + }; + Chain = DAG.getNode(X86ISD::FST, MVT::Other, Ops, 5); + RetVal = DAG.getLoad(VTs[0], Chain, StackSlot, NULL, 0); + Chain = RetVal.getValue(1); + } + + if (VTs[0] == MVT::f32 && !X86ScalarSSE) + // FIXME: we would really like to remember that this FP_ROUND + // operation is okay to eliminate if we allow excess FP precision. + RetVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, RetVal); + ResultVals.push_back(RetVal); } + + // Merge everything together with a MERGE_VALUES node. + ResultVals.push_back(Chain); + return DAG.getNode(ISD::MERGE_VALUES, TheCall->getVTList(), + &ResultVals[0], ResultVals.size()).Val; } @@ -696,7 +768,6 @@ bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; SDOperand Callee = Op.getOperand(4); - MVT::ValueType RetVT= Op.Val->getValueType(0); unsigned NumOps = (Op.getNumOperands() - 5) / 2; static const unsigned XMMArgRegs[] = { @@ -905,88 +976,12 @@ Ops.push_back(DAG.getConstant(NumBytesForCalleeToPush, getPointerTy())); Ops.push_back(InFlag); Chain = DAG.getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], Ops.size()); - if (RetVT != MVT::Other) - InFlag = Chain.getValue(1); - - SmallVector ResultVals; - switch (RetVT) { - default: assert(0 && "Unknown value type to return!"); - case MVT::Other: - NodeTys = DAG.getVTList(MVT::Other); - break; - case MVT::i8: - Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i8, MVT::Other); - break; - case MVT::i16: - Chain = DAG.getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i16, MVT::Other); - break; - case MVT::i32: - if (Op.Val->getValueType(1) == MVT::i32) { - Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - Chain = DAG.getCopyFromReg(Chain, X86::EDX, MVT::i32, - Chain.getValue(2)).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); - } else { - Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i32, MVT::Other); - } - break; - case MVT::v16i8: - case MVT::v8i16: - case MVT::v4i32: - case MVT::v2i64: - case MVT::v4f32: - case MVT::v2f64: - assert(!isStdCall && "Unknown value type to return!"); - Chain = DAG.getCopyFromReg(Chain, X86::XMM0, RetVT, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(RetVT, MVT::Other); - break; - case MVT::f32: - case MVT::f64: { - SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other, MVT::Flag); - SDOperand GROps[] = { Chain, InFlag }; - SDOperand RetVal = DAG.getNode(X86ISD::FP_GET_RESULT, Tys, GROps, 2); - Chain = RetVal.getValue(1); - InFlag = RetVal.getValue(2); - if (X86ScalarSSE) { - // FIXME: Currently the FST is flagged to the FP_GET_RESULT. This - // shouldn't be necessary except that RFP cannot be live across - // multiple blocks. When stackifier is fixed, they can be uncoupled. - MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); - SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); - Tys = DAG.getVTList(MVT::Other); - SDOperand Ops[] = { - Chain, RetVal, StackSlot, DAG.getValueType(RetVT), InFlag - }; - Chain = DAG.getNode(X86ISD::FST, Tys, Ops, 5); - RetVal = DAG.getLoad(RetVT, Chain, StackSlot, NULL, 0); - Chain = RetVal.getValue(1); - } - - if (RetVT == MVT::f32 && !X86ScalarSSE) - // FIXME: we would really like to remember that this FP_ROUND - // operation is okay to eliminate if we allow excess FP precision. - RetVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, RetVal); - ResultVals.push_back(RetVal); - NodeTys = DAG.getVTList(RetVT, MVT::Other); - break; - } - } + InFlag = Chain.getValue(1); - // Merge everything together with a MERGE_VALUES node. - ResultVals.push_back(Chain); - SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, - &ResultVals[0], ResultVals.size()); - return Res.getValue(Op.ResNo); + // Handle result values, copying them out of physregs into vregs that we + // return. + return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CallingConv::C, DAG), + Op.ResNo); } @@ -3946,9 +3941,8 @@ default: assert(0 && "Unsupported calling convention"); case CallingConv::Fast: - if (EnableFastCC) { + if (EnableFastCC) return LowerFastCCCallTo(Op, DAG); - } // Falls through case CallingConv::C: return LowerCCCCallTo(Op, DAG); Index: llvm/lib/Target/X86/X86ISelLowering.h diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.86 llvm/lib/Target/X86/X86ISelLowering.h:1.87 --- llvm/lib/Target/X86/X86ISelLowering.h:1.86 Sun Feb 25 02:15:11 2007 +++ llvm/lib/Target/X86/X86ISelLowering.h Sun Feb 25 02:59:22 2007 @@ -360,6 +360,9 @@ /// X86ScalarSSE - Select between SSE2 or x87 floating point ops. bool X86ScalarSSE; + SDNode *LowerCallResult(SDOperand Chain, SDOperand InFlag, SDNode*TheCall, + unsigned CallingConv, SelectionDAG &DAG); + // C and StdCall Calling Convention implementation. SDOperand LowerCCCArguments(SDOperand Op, SelectionDAG &DAG, bool isStdCall = false); From sabre at nondot.org Sun Feb 25 03:06:32 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 03:06:32 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86ISelLowering.h Message-ID: <200702250906.l1P96WGp010028@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.330 -> 1.331 X86ISelLowering.h updated: 1.87 -> 1.88 --- Log message: pass the calling convention into Lower*CallTo, instead of using ad-hoc flags. --- Diffs of the changes: (+19 -23) X86ISelLowering.cpp | 34 ++++++++++++++++------------------ X86ISelLowering.h | 8 +++----- 2 files changed, 19 insertions(+), 23 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.330 llvm/lib/Target/X86/X86ISelLowering.cpp:1.331 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.330 Sun Feb 25 02:59:22 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 03:06:15 2007 @@ -763,7 +763,7 @@ } SDOperand X86TargetLowering::LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, - bool isStdCall) { + unsigned CC) { SDOperand Chain = Op.getOperand(0); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; @@ -808,7 +808,7 @@ ArgInRegs[i], NumIntRegs, NumXMMRegs, 3, ObjSize, ObjIntRegs, ObjXMMRegs, - !isStdCall); + CC != CallingConv::X86_StdCall); if (ObjSize > 4) ArgIncrement = ObjSize; @@ -842,7 +842,7 @@ ArgInRegs[i], NumIntRegs, NumXMMRegs, 3, ObjSize, ObjIntRegs, ObjXMMRegs, - !isStdCall); + CC != CallingConv::X86_StdCall); if (ObjSize > 4) ArgIncrement = ObjSize; @@ -868,7 +868,6 @@ case MVT::v2i64: case MVT::v4f32: case MVT::v2f64: - assert(!isStdCall && "Unhandled argument type!"); RegsToPass.push_back(std::make_pair(XMMArgRegs[NumXMMRegs], Arg)); break; } @@ -956,12 +955,11 @@ // Create the CALLSEQ_END node. unsigned NumBytesForCalleeToPush = 0; - if (isStdCall) { - if (isVarArg) { + if (CC == CallingConv::X86_StdCall) { + if (isVarArg) NumBytesForCalleeToPush = NumSRetBytes; - } else { + else NumBytesForCalleeToPush = NumBytes; - } } else { // If this is is a call to a struct-return function, the callee // pops the hidden struct pointer, so we have to push it back. @@ -980,8 +978,7 @@ // Handle result values, copying them out of physregs into vregs that we // return. - return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CallingConv::C, DAG), - Op.ResNo); + return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo); } @@ -1219,7 +1216,8 @@ } SDOperand -X86TargetLowering::LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG) { +X86TargetLowering::LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG, + unsigned CallingConv) { SDOperand Chain = Op.getOperand(0); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; @@ -1652,7 +1650,7 @@ } SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, - bool isFastCall) { + unsigned CC) { SDOperand Chain = Op.getOperand(0); bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; SDOperand Callee = Op.getOperand(4); @@ -1677,7 +1675,8 @@ X86::XMM0, X86::XMM1, X86::XMM2, X86::XMM3 }; - unsigned GPRInd = (isFastCall ? 1 : 0); + bool isFastCall = CC == CallingConv::X86_FastCall; + unsigned GPRInd = isFastCall ? 1 : 0; for (unsigned i = 0; i != NumOps; ++i) { SDOperand Arg = Op.getOperand(5+2*i); @@ -3935,21 +3934,20 @@ unsigned CallingConv= cast(Op.getOperand(1))->getValue(); if (Subtarget->is64Bit()) - return LowerX86_64CCCCallTo(Op, DAG); + return LowerX86_64CCCCallTo(Op, DAG, CallingConv); else switch (CallingConv) { default: assert(0 && "Unsupported calling convention"); case CallingConv::Fast: if (EnableFastCC) - return LowerFastCCCallTo(Op, DAG); + return LowerFastCCCallTo(Op, DAG, CallingConv); // Falls through case CallingConv::C: - return LowerCCCCallTo(Op, DAG); case CallingConv::X86_StdCall: - return LowerCCCCallTo(Op, DAG, true); + return LowerCCCCallTo(Op, DAG, CallingConv); case CallingConv::X86_FastCall: - return LowerFastCCCallTo(Op, DAG, true); + return LowerFastCCCallTo(Op, DAG, CallingConv); } } Index: llvm/lib/Target/X86/X86ISelLowering.h diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.87 llvm/lib/Target/X86/X86ISelLowering.h:1.88 --- llvm/lib/Target/X86/X86ISelLowering.h:1.87 Sun Feb 25 02:59:22 2007 +++ llvm/lib/Target/X86/X86ISelLowering.h Sun Feb 25 03:06:15 2007 @@ -366,18 +366,16 @@ // C and StdCall Calling Convention implementation. SDOperand LowerCCCArguments(SDOperand Op, SelectionDAG &DAG, bool isStdCall = false); - SDOperand LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, - bool isStdCall = false); + SDOperand LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC); // X86-64 C Calling Convention implementation. SDOperand LowerX86_64CCCArguments(SDOperand Op, SelectionDAG &DAG); - SDOperand LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG); + SDOperand LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG,unsigned CC); // Fast and FastCall Calling Convention implementation. SDOperand LowerFastCCArguments(SDOperand Op, SelectionDAG &DAG, bool isFastCall = false); - SDOperand LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, - bool isFastCall = false); + SDOperand LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC); SDOperand LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG); SDOperand LowerVECTOR_SHUFFLE(SDOperand Op, SelectionDAG &DAG); From sabre at nondot.org Sun Feb 25 03:10:22 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 03:10:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250910.l1P9AM7s010137@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.331 -> 1.332 --- Log message: make all Lower*CallTo implementations use LowerCallResult to handle their result value stuff. This eliminates a bunch of duplicated code and now GetRetValueLocs is the sole place that decides where a value is returned. --- Diffs of the changes: (+10 -153) X86ISelLowering.cpp | 163 +++------------------------------------------------- 1 files changed, 10 insertions(+), 153 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.331 llvm/lib/Target/X86/X86ISelLowering.cpp:1.332 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.331 Sun Feb 25 03:06:15 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 03:10:05 2007 @@ -1217,12 +1217,11 @@ SDOperand X86TargetLowering::LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG, - unsigned CallingConv) { + unsigned CC) { SDOperand Chain = Op.getOperand(0); bool isVarArg = cast(Op.getOperand(2))->getValue() != 0; bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; SDOperand Callee = Op.getOperand(4); - MVT::ValueType RetVT= Op.Val->getValueType(0); unsigned NumOps = (Op.getNumOperands() - 5) / 2; // Count how many bytes are to be pushed on the stack. @@ -1412,65 +1411,11 @@ Ops.push_back(DAG.getConstant(0, getPointerTy())); Ops.push_back(InFlag); Chain = DAG.getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], Ops.size()); - if (RetVT != MVT::Other) - InFlag = Chain.getValue(1); - - SmallVector ResultVals; - switch (RetVT) { - default: assert(0 && "Unknown value type to return!"); - case MVT::Other: - NodeTys = DAG.getVTList(MVT::Other); - break; - case MVT::i8: - Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i8, MVT::Other); - break; - case MVT::i16: - Chain = DAG.getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i16, MVT::Other); - break; - case MVT::i32: - Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i32, MVT::Other); - break; - case MVT::i64: - if (Op.Val->getValueType(1) == MVT::i64) { - // FIXME: __int128 support? - Chain = DAG.getCopyFromReg(Chain, X86::RAX, MVT::i64, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - Chain = DAG.getCopyFromReg(Chain, X86::RDX, MVT::i64, - Chain.getValue(2)).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i64, MVT::i64, MVT::Other); - } else { - Chain = DAG.getCopyFromReg(Chain, X86::RAX, MVT::i64, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i64, MVT::Other); - } - break; - case MVT::f32: - case MVT::f64: - case MVT::v16i8: - case MVT::v8i16: - case MVT::v4i32: - case MVT::v2i64: - case MVT::v4f32: - case MVT::v2f64: - // FIXME: long double support? - Chain = DAG.getCopyFromReg(Chain, X86::XMM0, RetVT, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(RetVT, MVT::Other); - break; - } - - // Merge everything together with a MERGE_VALUES node. - ResultVals.push_back(Chain); - SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, - &ResultVals[0], ResultVals.size()); - return Res.getValue(Op.ResNo); + InFlag = Chain.getValue(1); + + // Handle result values, copying them out of physregs into vregs that we + // return. + return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo); } //===----------------------------------------------------------------------===// @@ -1654,7 +1599,6 @@ SDOperand Chain = Op.getOperand(0); bool isTailCall = cast(Op.getOperand(3))->getValue() != 0; SDOperand Callee = Op.getOperand(4); - MVT::ValueType RetVT= Op.Val->getValueType(0); unsigned NumOps = (Op.getNumOperands() - 5) / 2; // Count how many bytes are to be pushed on the stack. @@ -1848,98 +1792,11 @@ Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); Ops.push_back(InFlag); Chain = DAG.getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], Ops.size()); - if (RetVT != MVT::Other) - InFlag = Chain.getValue(1); - - SmallVector ResultVals; - switch (RetVT) { - default: assert(0 && "Unknown value type to return!"); - case MVT::Other: - NodeTys = DAG.getVTList(MVT::Other); - break; - case MVT::i8: - Chain = DAG.getCopyFromReg(Chain, X86::AL, MVT::i8, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i8, MVT::Other); - break; - case MVT::i16: - Chain = DAG.getCopyFromReg(Chain, X86::AX, MVT::i16, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i16, MVT::Other); - break; - case MVT::i32: - if (Op.Val->getValueType(1) == MVT::i32) { - Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - Chain = DAG.getCopyFromReg(Chain, X86::EDX, MVT::i32, - Chain.getValue(2)).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other); - } else { - Chain = DAG.getCopyFromReg(Chain, X86::EAX, MVT::i32, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(MVT::i32, MVT::Other); - } - break; - case MVT::v16i8: - case MVT::v8i16: - case MVT::v4i32: - case MVT::v2i64: - case MVT::v4f32: - case MVT::v2f64: - if (isFastCall) { - assert(0 && "Unknown value type to return!"); - } else { - Chain = DAG.getCopyFromReg(Chain, X86::XMM0, RetVT, InFlag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - NodeTys = DAG.getVTList(RetVT, MVT::Other); - } - break; - case MVT::f32: - case MVT::f64: { - SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other, MVT::Flag); - SmallVector Ops; - Ops.push_back(Chain); - Ops.push_back(InFlag); - SDOperand RetVal = DAG.getNode(X86ISD::FP_GET_RESULT, Tys, - &Ops[0], Ops.size()); - Chain = RetVal.getValue(1); - InFlag = RetVal.getValue(2); - if (X86ScalarSSE) { - // FIXME: Currently the FST is flagged to the FP_GET_RESULT. This - // shouldn't be necessary except that RFP cannot be live across - // multiple blocks. When stackifier is fixed, they can be uncoupled. - MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); - SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); - Tys = DAG.getVTList(MVT::Other); - Ops.clear(); - Ops.push_back(Chain); - Ops.push_back(RetVal); - Ops.push_back(StackSlot); - Ops.push_back(DAG.getValueType(RetVT)); - Ops.push_back(InFlag); - Chain = DAG.getNode(X86ISD::FST, Tys, &Ops[0], Ops.size()); - RetVal = DAG.getLoad(RetVT, Chain, StackSlot, NULL, 0); - Chain = RetVal.getValue(1); - } - - if (RetVT == MVT::f32 && !X86ScalarSSE) - // FIXME: we would really like to remember that this FP_ROUND - // operation is okay to eliminate if we allow excess FP precision. - RetVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, RetVal); - ResultVals.push_back(RetVal); - NodeTys = DAG.getVTList(RetVT, MVT::Other); - - break; - } - } + InFlag = Chain.getValue(1); - // Merge everything together with a MERGE_VALUES node. - ResultVals.push_back(Chain); - SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, - &ResultVals[0], ResultVals.size()); - return Res.getValue(Op.ResNo); + // Handle result values, copying them out of physregs into vregs that we + // return. + return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo); } SDOperand X86TargetLowering::getReturnAddressFrameIndex(SelectionDAG &DAG) { From sabre at nondot.org Sun Feb 25 03:12:56 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 03:12:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250912.l1P9CuSi010228@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.332 -> 1.333 --- Log message: move LowerRET into the 'Return Value Calling Convention Implementation' section of the file. --- Diffs of the changes: (+77 -75) X86ISelLowering.cpp | 152 ++++++++++++++++++++++++++-------------------------- 1 files changed, 77 insertions(+), 75 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.332 llvm/lib/Target/X86/X86ISelLowering.cpp:1.333 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.332 Sun Feb 25 03:10:05 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 03:12:39 2007 @@ -467,6 +467,83 @@ ResultRegs[0] = Reg; } +/// LowerRET - Lower an ISD::RET node. +SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) { + assert((Op.getNumOperands() & 1) == 1 && "ISD::RET should have odd # args"); + + // Support up returning up to two registers. + MVT::ValueType VTs[2]; + unsigned DestRegs[2]; + unsigned NumRegs = Op.getNumOperands() / 2; + assert(NumRegs <= 2 && "Can only return up to two regs!"); + + for (unsigned i = 0; i != NumRegs; ++i) + VTs[i] = Op.getOperand(i*2+1).getValueType(); + + // Determine which register each value should be copied into. + GetRetValueLocs(VTs, NumRegs, DestRegs, Subtarget, + DAG.getMachineFunction().getFunction()->getCallingConv()); + + // If this is the first return lowered for this function, add the regs to the + // liveout set for the function. + if (DAG.getMachineFunction().liveout_empty()) { + for (unsigned i = 0; i != NumRegs; ++i) + DAG.getMachineFunction().addLiveOut(DestRegs[i]); + } + + SDOperand Chain = Op.getOperand(0); + SDOperand Flag; + + // Copy the result values into the output registers. + if (NumRegs != 1 || DestRegs[0] != X86::ST0) { + for (unsigned i = 0; i != NumRegs; ++i) { + Chain = DAG.getCopyToReg(Chain, DestRegs[i], Op.getOperand(i*2+1), Flag); + Flag = Chain.getValue(1); + } + } else { + // We need to handle a destination of ST0 specially, because it isn't really + // a register. + SDOperand Value = Op.getOperand(1); + + // If this is an FP return with ScalarSSE, we need to move the value from + // an XMM register onto the fp-stack. + if (X86ScalarSSE) { + SDOperand MemLoc; + + // If this is a load into a scalarsse value, don't store the loaded value + // back to the stack, only to reload it: just replace the scalar-sse load. + if (ISD::isNON_EXTLoad(Value.Val) && + (Chain == Value.getValue(1) || Chain == Value.getOperand(0))) { + Chain = Value.getOperand(0); + MemLoc = Value.getOperand(1); + } else { + // Spill the value to memory and reload it into top of stack. + unsigned Size = MVT::getSizeInBits(VTs[0])/8; + MachineFunction &MF = DAG.getMachineFunction(); + int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size); + MemLoc = DAG.getFrameIndex(SSFI, getPointerTy()); + Chain = DAG.getStore(Op.getOperand(0), Value, MemLoc, NULL, 0); + } + SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other); + SDOperand Ops[] = { Chain, MemLoc, DAG.getValueType(VTs[0]) }; + Value = DAG.getNode(X86ISD::FLD, Tys, Ops, 3); + Chain = Value.getValue(1); + } + + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); + SDOperand Ops[] = { Chain, Value }; + Chain = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); + Flag = Chain.getValue(1); + } + + SDOperand BytesToPop = DAG.getConstant(getBytesToPopOnReturn(), MVT::i16); + if (Flag.Val) + return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Chain, BytesToPop, Flag); + else + return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Chain, BytesToPop); +} + + /// LowerCallResult - Lower the result values of an ISD::CALL into the /// appropriate copies out of appropriate physical registers. This assumes that /// Chain/InFlag are the input chain/flag to use, and that TheCall is the call @@ -3808,81 +3885,6 @@ } } -SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) { - assert((Op.getNumOperands() & 1) == 1 && "ISD::RET should have odd # args"); - - // Support up returning up to two registers. - MVT::ValueType VTs[2]; - unsigned DestRegs[2]; - unsigned NumRegs = Op.getNumOperands() / 2; - assert(NumRegs <= 2 && "Can only return up to two regs!"); - - for (unsigned i = 0; i != NumRegs; ++i) - VTs[i] = Op.getOperand(i*2+1).getValueType(); - - // Determine which register each value should be copied into. - GetRetValueLocs(VTs, NumRegs, DestRegs, Subtarget, - DAG.getMachineFunction().getFunction()->getCallingConv()); - - // If this is the first return lowered for this function, add the regs to the - // liveout set for the function. - if (DAG.getMachineFunction().liveout_empty()) { - for (unsigned i = 0; i != NumRegs; ++i) - DAG.getMachineFunction().addLiveOut(DestRegs[i]); - } - - SDOperand Chain = Op.getOperand(0); - SDOperand Flag; - - // Copy the result values into the output registers. - if (NumRegs != 1 || DestRegs[0] != X86::ST0) { - for (unsigned i = 0; i != NumRegs; ++i) { - Chain = DAG.getCopyToReg(Chain, DestRegs[i], Op.getOperand(i*2+1), Flag); - Flag = Chain.getValue(1); - } - } else { - // We need to handle a destination of ST0 specially, because it isn't really - // a register. - SDOperand Value = Op.getOperand(1); - - // If this is an FP return with ScalarSSE, we need to move the value from - // an XMM register onto the fp-stack. - if (X86ScalarSSE) { - SDOperand MemLoc; - - // If this is a load into a scalarsse value, don't store the loaded value - // back to the stack, only to reload it: just replace the scalar-sse load. - if (ISD::isNON_EXTLoad(Value.Val) && - (Chain == Value.getValue(1) || Chain == Value.getOperand(0))) { - Chain = Value.getOperand(0); - MemLoc = Value.getOperand(1); - } else { - // Spill the value to memory and reload it into top of stack. - unsigned Size = MVT::getSizeInBits(VTs[0])/8; - MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size); - MemLoc = DAG.getFrameIndex(SSFI, getPointerTy()); - Chain = DAG.getStore(Op.getOperand(0), Value, MemLoc, NULL, 0); - } - SDVTList Tys = DAG.getVTList(MVT::f64, MVT::Other); - SDOperand Ops[] = { Chain, MemLoc, DAG.getValueType(VTs[0]) }; - Value = DAG.getNode(X86ISD::FLD, Tys, Ops, 3); - Chain = Value.getValue(1); - } - - SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); - SDOperand Ops[] = { Chain, Value }; - Chain = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops, 2); - Flag = Chain.getValue(1); - } - - SDOperand BytesToPop = DAG.getConstant(getBytesToPopOnReturn(), MVT::i16); - if (Flag.Val) - return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Chain, BytesToPop, Flag); - else - return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Chain, BytesToPop); -} - SDOperand X86TargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) { MachineFunction &MF = DAG.getMachineFunction(); From sabre at nondot.org Sun Feb 25 03:14:42 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 03:14:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250914.l1P9EgRw010306@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.333 -> 1.334 --- Log message: allow vectors to be passed to stdcall/fastcall functions --- Diffs of the changes: (+10 -18) X86ISelLowering.cpp | 28 ++++++++++------------------ 1 files changed, 10 insertions(+), 18 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.333 llvm/lib/Target/X86/X86ISelLowering.cpp:1.334 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.333 Sun Feb 25 03:12:39 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 03:14:25 2007 @@ -645,8 +645,7 @@ unsigned NumIntRegs, unsigned NumXMMRegs, unsigned MaxNumIntRegs, unsigned &ObjSize, unsigned &ObjIntRegs, - unsigned &ObjXMMRegs, - bool AllowVectors = true) { + unsigned &ObjXMMRegs) { ObjSize = 0; ObjIntRegs = 0; ObjXMMRegs = 0; @@ -696,14 +695,11 @@ case MVT::v2i64: case MVT::v4f32: case MVT::v2f64: - if (AllowVectors) { - if (NumXMMRegs < 4) - ObjXMMRegs = 1; - else - ObjSize = 16; - break; - } else - assert(0 && "Unhandled argument type [vector]!"); + if (NumXMMRegs < 4) + ObjXMMRegs = 1; + else + ObjSize = 16; + break; } } @@ -764,8 +760,7 @@ HowToPassCallArgument(ObjectVT, ArgInRegs[i], NumIntRegs, NumXMMRegs, 3, - ObjSize, ObjIntRegs, ObjXMMRegs, - !isStdCall); + ObjSize, ObjIntRegs, ObjXMMRegs); if (ObjSize > 4) ArgIncrement = ObjSize; @@ -884,8 +879,7 @@ HowToPassCallArgument(Arg.getValueType(), ArgInRegs[i], NumIntRegs, NumXMMRegs, 3, - ObjSize, ObjIntRegs, ObjXMMRegs, - CC != CallingConv::X86_StdCall); + ObjSize, ObjIntRegs, ObjXMMRegs); if (ObjSize > 4) ArgIncrement = ObjSize; @@ -918,8 +912,7 @@ HowToPassCallArgument(Arg.getValueType(), ArgInRegs[i], NumIntRegs, NumXMMRegs, 3, - ObjSize, ObjIntRegs, ObjXMMRegs, - CC != CallingConv::X86_StdCall); + ObjSize, ObjIntRegs, ObjXMMRegs); if (ObjSize > 4) ArgIncrement = ObjSize; @@ -1574,8 +1567,7 @@ true, // Use as much registers as possible NumIntRegs, NumXMMRegs, (isFastCall ? 2 : FASTCC_NUM_INT_ARGS_INREGS), - ObjSize, ObjIntRegs, ObjXMMRegs, - !isFastCall); + ObjSize, ObjIntRegs, ObjXMMRegs); if (ObjSize > 4) ArgIncrement = ObjSize; From sabre at nondot.org Sun Feb 25 03:30:20 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 03:30:20 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/fp-stack-ret.ll Message-ID: <200702250930.l1P9UKrg010610@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: fp-stack-ret.ll updated: 1.1 -> 1.2 --- Log message: verify that double is returned in XMM0 if the function is fastcc. --- Diffs of the changes: (+16 -3) fp-stack-ret.ll | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) Index: llvm/test/CodeGen/X86/fp-stack-ret.ll diff -u llvm/test/CodeGen/X86/fp-stack-ret.ll:1.1 llvm/test/CodeGen/X86/fp-stack-ret.ll:1.2 --- llvm/test/CodeGen/X86/fp-stack-ret.ll:1.1 Sun Feb 25 02:23:01 2007 +++ llvm/test/CodeGen/X86/fp-stack-ret.ll Sun Feb 25 03:30:03 2007 @@ -1,6 +1,7 @@ -; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -march=x86 | grep fldl && -; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -march=x86 | not grep xmm && -; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -march=x86 | not grep 'sub.*esp' +; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin8 -mcpu=yonah -march=x86 > %t && +; RUN: grep fldl %t | wc -l | grep 1 && +; RUN: not grep xmm %t && +; RUN: grep 'sub.*esp' %t | wc -l | grep 1 ; These testcases shouldn't require loading into an XMM register then storing ; to memory, then reloading into an FPStack reg. @@ -10,3 +11,15 @@ ret double %A } +; fastcc should return a value +define fastcc double @test2(<2 x double> %A) { + %B = extractelement <2 x double> %A, i32 0 + ret double %B +} + +define fastcc double @test3(<4 x float> %A) { + %B = bitcast <4 x float> %A to <2 x double> + %C = call fastcc double @test2(<2 x double> %B) + ret double %C +} + From sabre at nondot.org Sun Feb 25 03:31:33 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 03:31:33 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702250931.l1P9VXJC010657@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.334 -> 1.335 --- Log message: fastcc functions that return double values now return them in xmm0 on x86-32. This implements CodeGen/X86/fp-stack-ret.ll:test[23] --- Diffs of the changes: (+3 -1) X86ISelLowering.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.334 llvm/lib/Target/X86/X86ISelLowering.cpp:1.335 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.334 Sun Feb 25 03:14:25 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 03:31:16 2007 @@ -434,7 +434,7 @@ static void GetRetValueLocs(const MVT::ValueType *VTs, unsigned NumVTs, unsigned *ResultRegs, const X86Subtarget *Subtarget, - unsigned CallingConv) { + unsigned CC) { if (NumVTs == 0) return; if (NumVTs == 2) { @@ -456,6 +456,8 @@ case MVT::f64: if (Subtarget->is64Bit()) Reg = X86::XMM0; // FP values in X86-64 go in XMM0. + else if (CC == CallingConv::Fast) + Reg = X86::XMM0; // FP values in X86-32 with fastcc go in XMM0. else Reg = X86::ST0; // FP values in X86-32 go in ST0. break; From evan.cheng at apple.com Sun Feb 25 03:39:19 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 25 Feb 2007 03:39:19 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200702250939.l1P9dJY6010782@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.140 -> 1.141 --- Log message: Only add liveinterval to livein set if it isn't assigned a stack slot. --- Diffs of the changes: (+4 -4) RegAllocLinearScan.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.140 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.141 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.140 Mon Feb 19 15:49:53 2007 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Feb 25 03:39:02 2007 @@ -303,10 +303,10 @@ for (unsigned i = 0, e = handled_.size(); i != e; ++i) { LiveInterval *HI = handled_[i]; - if (HI->liveAt(StartIdx)) { - unsigned Reg = HI->reg; - if (MRegisterInfo::isVirtualRegister(Reg)) - Reg = vrm_->getPhys(Reg); + unsigned Reg = HI->reg; + if (!vrm_->hasStackSlot(Reg) && HI->liveAt(StartIdx)) { + assert(MRegisterInfo::isVirtualRegister(Reg)); + Reg = vrm_->getPhys(Reg); MBB->addLiveIn(Reg); } } From evan.cheng at apple.com Sun Feb 25 03:42:16 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 25 Feb 2007 03:42:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200702250942.l1P9gG3J010852@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.213 -> 1.214 --- Log message: If the liveinterval of the source instruction has been extended, remove the IsKill marker. --- Diffs of the changes: (+6 -0) LiveIntervalAnalysis.cpp | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.213 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.214 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.213 Fri Feb 23 14:40:13 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Feb 25 03:41:59 2007 @@ -828,6 +828,12 @@ IntB.MergeValueNumberInto(BValNo, ValLR->ValId); DOUT << " result = "; IntB.print(DOUT, mri_); DOUT << "\n"; + + // If the source instruction was killing the source register before the + // merge, unset the isKill marker given the live range has been extended. + MachineOperand *MOK = ValLREndInst->findRegisterUseOperand(IntB.reg, true); + if (MOK) + MOK->unsetIsKill(); // Finally, delete the copy instruction. RemoveMachineInstrFromMaps(CopyMI); From evan.cheng at apple.com Sun Feb 25 03:46:47 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 25 Feb 2007 03:46:47 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200702250946.l1P9kl3f010926@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervalAnalysis.cpp updated: 1.214 -> 1.215 --- Log message: Fix a couple of bugs related IsDead back propagation during coalescing. --- Diffs of the changes: (+10 -5) LiveIntervalAnalysis.cpp | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.214 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.215 --- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.214 Sun Feb 25 03:41:59 2007 +++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Sun Feb 25 03:46:31 2007 @@ -903,11 +903,16 @@ unsigned SrcStart = 0; unsigned SrcEnd = 0; if (isDead) { - unsigned CopyIdx = getDefIndex(getInstructionIndex(CopyMI)); - LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(CopyIdx-1); + unsigned CopyIdx = getInstructionIndex(CopyMI); + LiveInterval::iterator SrcLR = + SrcInt.FindLiveRangeContaining(getUseIndex(CopyIdx)); SrcStart = SrcLR->start; SrcEnd = SrcLR->end; - if (hasRegisterUse(repSrcReg, SrcStart, SrcEnd)) + // The instruction which defines the src is only truly dead if there are + // no intermediate uses and there isn't a use beyond the copy. + // FIXME: find the last use, mark is kill and shorten the live range. + if (SrcEnd > getDefIndex(CopyIdx) || + hasRegisterUse(repSrcReg, SrcStart, CopyIdx)) isDead = false; } @@ -918,10 +923,10 @@ if (JoinIntervals(DestInt, SrcInt)) { if (isDead) { // Result of the copy is dead. Propagate this property. - if (SrcStart == 0) { + if (SrcStart == 0 && MRegisterInfo::isPhysicalRegister(SrcReg)) { // Live-in to the function but dead. Remove it from MBB live-in set. // JoinIntervals may end up swapping the two intervals. - LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt:SrcInt; + LiveInterval &LiveInInt = (repSrcReg == DestInt.reg) ? DestInt : SrcInt; LiveInInt.removeRange(SrcStart, SrcEnd); MachineBasicBlock *MBB = CopyMI->getParent(); MBB->removeLiveIn(SrcReg); From evan.cheng at apple.com Sun Feb 25 03:47:47 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 25 Feb 2007 03:47:47 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegisterScavenging.cpp Message-ID: <200702250947.l1P9llth010967@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegisterScavenging.cpp updated: 1.2 -> 1.3 --- Log message: Add an assertion. --- Diffs of the changes: (+4 -2) RegisterScavenging.cpp | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/RegisterScavenging.cpp diff -u llvm/lib/CodeGen/RegisterScavenging.cpp:1.2 llvm/lib/CodeGen/RegisterScavenging.cpp:1.3 --- llvm/lib/CodeGen/RegisterScavenging.cpp:1.2 Fri Feb 23 02:41:19 2007 +++ llvm/lib/CodeGen/RegisterScavenging.cpp Sun Feb 25 03:47:31 2007 @@ -76,10 +76,12 @@ const MachineOperand &MO = MI->getOperand(i); if (!MO.isReg() || !MO.isDef()) continue; + unsigned Reg = MO.getReg(); // Skip two-address destination operand. - if (TID->findTiedToSrcOperand(i) != -1) + if (TID->findTiedToSrcOperand(i) != -1) { + assert(isUsed(Reg)); continue; - unsigned Reg = MO.getReg(); + } assert(isUnused(Reg) || isReserved(Reg)); if (!MO.isDead()) setUsed(Reg); From evan.cheng at apple.com Sun Feb 25 03:51:44 2007 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 25 Feb 2007 03:51:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp Message-ID: <200702250951.l1P9pi9m011060@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.99 -> 1.100 --- Log message: A couple of more places where a register liveness has been extended and its last kill should be updated accordingly. --- Diffs of the changes: (+57 -5) VirtRegMap.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 57 insertions(+), 5 deletions(-) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.99 llvm/lib/CodeGen/VirtRegMap.cpp:1.100 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.99 Fri Feb 23 15:47:50 2007 +++ llvm/lib/CodeGen/VirtRegMap.cpp Sun Feb 25 03:51:27 2007 @@ -254,7 +254,8 @@ // SpillSlotsAvailable - This map keeps track of all of the spilled virtual // register values that are still available, due to being loaded or stored to, - // but not invalidated yet. + // but not invalidated yet. It also tracks the instruction that last defined + // or used the register. typedef std::pair SSInfo; std::map SpillSlotsAvailable; @@ -285,6 +286,24 @@ } return 0; } + + /// UpdateLastUses - Update the last use information of all stack slots whose + /// values are available in the specific register. + void UpdateLastUse(unsigned PhysReg, MachineInstr *Use) { + std::multimap::iterator I = + PhysRegsAvailable.lower_bound(PhysReg); + while (I != PhysRegsAvailable.end() && I->first == PhysReg) { + int Slot = I->second; + I++; + + std::map::iterator II = SpillSlotsAvailable.find(Slot); + assert(II != SpillSlotsAvailable.end() && "Slot not available!"); + unsigned Val = II->second.first; + assert((Val >> 1) == PhysReg && "Bidirectional map mismatch!"); + SpillSlotsAvailable.erase(Slot); + SpillSlotsAvailable[Slot] = std::make_pair(Val, Use); + } + } /// addAvailable - Mark that the specified stack slot is available in the /// specified physreg. If CanClobber is true, the physreg can be modified at @@ -667,10 +686,12 @@ MachineOperand *MOK = SSMI->findRegisterUseOperand(PhysReg, true); if (MOK) { MOK->unsetIsKill(); - if (ti == -1) + if (ti == -1) { // Unless it's the use of a two-address code, transfer the kill // of the reused register to this use. MI.getOperand(i).setIsKill(); + Spills.UpdateLastUse(PhysReg, &MI); + } } // The only technical detail we have is that we don't know that @@ -737,7 +758,20 @@ PhysRegsUsed[DesignatedReg] = true; ReusedOperands.markClobbered(DesignatedReg); MRI->copyRegToReg(MBB, &MI, DesignatedReg, PhysReg, RC); - + + // Extend the live range of the MI that last kill the register if + // necessary. + if (SSMI) { + MachineOperand *MOK = SSMI->findRegisterUseOperand(PhysReg, true); + if (MOK) { + MachineInstr *CopyMI = prior(MII); + MachineOperand *MOU = CopyMI->findRegisterUseOperand(PhysReg); + MOU->setIsKill(); + MOK->unsetIsKill(); + Spills.UpdateLastUse(PhysReg, &MI); + } + } + // This invalidates DesignatedReg. Spills.ClobberPhysReg(DesignatedReg); @@ -771,6 +805,10 @@ // Any stores to this stack slot are not dead anymore. MaybeDeadStores.erase(StackSlot); Spills.addAvailable(StackSlot, &MI, PhysReg); + // Assumes this is the last use. IsKill will be unset if reg is reused + // unless it's a two-address operand. + if (TID->getOperandConstraint(i, TOI::TIED_TO) == -1) + MI.getOperand(i).setIsKill(); ++NumLoads; MI.getOperand(i).setReg(PhysReg); DOUT << '\t' << *prior(MII); @@ -802,8 +840,8 @@ if (FrameIdx == SS) { // If this spill slot is available, turn it into a copy (or nothing) // instead of leaving it as a load! - MachineInstr *Dummy = NULL; - if (unsigned InReg = Spills.getSpillSlotPhysReg(SS, Dummy)) { + MachineInstr *SSMI = NULL; + if (unsigned InReg = Spills.getSpillSlotPhysReg(SS, SSMI)) { DOUT << "Promoted Load To Copy: " << MI; MachineFunction &MF = *MBB.getParent(); if (DestReg != InReg) { @@ -814,7 +852,21 @@ // virtual or needing to clobber any values if it's physical). NextMII = &MI; --NextMII; // backtrack to the copy. + } else + DOUT << "Removing now-noop copy: " << MI; + + // Extend the live range of the MI that last kill the register if + // the next MI reuse it. + MachineOperand *MOK = SSMI->findRegisterUseOperand(InReg, true); + if (MOK && NextMII != MBB.end()) { + MachineOperand *MOU = NextMII->findRegisterUseOperand(InReg); + if (MOU) { + MOU->setIsKill(); + MOK->unsetIsKill(); + Spills.UpdateLastUse(InReg, &(*NextMII)); + } } + VRM.RemoveFromFoldedVirtMap(&MI); MBB.erase(&MI); goto ProcessNextInst; From dalej at apple.com Sun Feb 25 12:31:50 2007 From: dalej at apple.com (Dale Johannesen) Date: Sun, 25 Feb 2007 12:31:50 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp README.txt Message-ID: <200702251831.l1PIVoQn013028@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/ARM: ARMConstantIslandPass.cpp updated: 1.29 -> 1.30 README.txt updated: 1.13 -> 1.14 --- Log message: cosmetic changes from review of last patch. obvious --- Diffs of the changes: (+5 -4) ARMConstantIslandPass.cpp | 4 ++-- README.txt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.29 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.30 --- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.29 Sat Feb 24 19:42:36 2007 +++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp Sun Feb 25 12:31:31 2007 @@ -558,7 +558,7 @@ return NewBB; } -//// OffsetIsInRange - Checks whether UserOffset is within MaxDisp of +/// OffsetIsInRange - Checks whether UserOffset is within MaxDisp of /// TrialOffset. bool ARMConstantIslands::OffsetIsInRange(unsigned UserOffset, unsigned TrialOffset, unsigned MaxDisp, bool NegativeOK) { @@ -631,7 +631,7 @@ void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta) { MachineFunction::iterator MBBI = BB->getParent()->end(); - for(int i=BB->getNumber()+1; i<=prior(MBBI)->getNumber(); i++) + for(unsigned i=BB->getNumber()+1; igetParent()->getNumBlockIDs(); i++) BBOffsets[i] += delta; } Index: llvm/lib/Target/ARM/README.txt diff -u llvm/lib/Target/ARM/README.txt:1.13 llvm/lib/Target/ARM/README.txt:1.14 --- llvm/lib/Target/ARM/README.txt:1.13 Sat Feb 24 18:47:03 2007 +++ llvm/lib/Target/ARM/README.txt Sun Feb 25 12:31:31 2007 @@ -24,8 +24,9 @@ 1. When there isn't an existing water, the current MBB is split right after the use. It would be profitable to look farther forward, especially on Thumb, where negative offsets won't work. -Now it will put the island at the end of the block if that is in range. If it -is not in range things still work as above, which is poor on Thumb. +(Partially fixed: it will put the island at the end of the block if that is +in range. If it is not in range things still work as above, which is poor on +Thumb.) 2. There may be some advantage to trying to be smarter about the initial placement, rather than putting everything at the end. From sabre at nondot.org Sun Feb 25 12:40:49 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 12:40:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702251840.l1PIenRZ013244@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.374 -> 1.375 --- Log message: optimize duplicate ValueMap lookups --- Diffs of the changes: (+6 -9) SelectionDAGISel.cpp | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.374 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.375 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.374 Sat Feb 24 03:45:44 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Feb 25 12:40:32 2007 @@ -661,17 +661,14 @@ return DAG.getFrameIndex(SI->second, TLI.getPointerTy()); } - DenseMap::iterator VMI = - FuncInfo.ValueMap.find(V); - assert(VMI != FuncInfo.ValueMap.end() && "Value not in map!"); - - unsigned InReg = VMI->second; + unsigned InReg = FuncInfo.ValueMap[V]; + assert(InReg && "Value not in map!"); // If this type is not legal, make it so now. if (VT != MVT::Vector) { if (TLI.getTypeAction(VT) == TargetLowering::Expand) { // Source must be expanded. This input value is actually coming from the - // register pair VMI->second and VMI->second+1. + // register pair InReg and InReg+1. MVT::ValueType DestVT = TLI.getTypeToExpandTo(VT); unsigned NumVals = TLI.getNumElements(VT); N = DAG.getCopyFromReg(DAG.getEntryNode(), InReg, DestVT); @@ -4189,9 +4186,9 @@ // If this argument is live outside of the entry block, insert a copy from // whereever we got it to the vreg that other BB's will reference it as. - if (FuncInfo.ValueMap.count(AI)) { - SDOperand Copy = - SDL.CopyValueToVirtualRegister(AI, FuncInfo.ValueMap[AI]); + DenseMap::iterator VMI=FuncInfo.ValueMap.find(AI); + if (VMI != FuncInfo.ValueMap.end()) { + SDOperand Copy = SDL.CopyValueToVirtualRegister(AI, VMI->second); UnorderedChains.push_back(Copy); } } From clattner at apple.com Sun Feb 25 12:44:41 2007 From: clattner at apple.com (clattner at apple.com) Date: Sun, 25 Feb 2007 10:44:41 -0800 (PST) Subject: [llvm-commits] [124302] work around PR1224 for now Message-ID: <20070225184441.DBE7C64752BB@src> Revision: 124302 Author: clattner Date: 2007-02-25 10:44:39 -0800 (Sun, 25 Feb 2007) Log Message: ----------- work around PR1224 for now Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-backend.cpp Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 12:26:16 UTC (rev 124301) +++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 18:44:39 UTC (rev 124302) @@ -104,8 +104,9 @@ Args.push_back("--disable-fp-elim"); if (!flag_zero_initialized_in_bss) Args.push_back("--nozero-initialized-in-bss"); - if (flag_exceptions) - Args.push_back("--enable-eh"); +// Disabled until PR1224 is resolved. + //if (flag_exceptions) + // Args.push_back("--enable-eh"); // If there are options that should be passed through to the LLVM backend // directly from the command line, do so now. This is mainly for debugging From sabre at nondot.org Sun Feb 25 12:51:05 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 12:51:05 -0600 Subject: [llvm-commits] CVS: llvm/docs/HowToSubmitABug.html Message-ID: <200702251851.l1PIp5n5013470@zion.cs.uiuc.edu> Changes in directory llvm/docs: HowToSubmitABug.html updated: 1.29 -> 1.30 --- Log message: add -enable-eh --- Diffs of the changes: (+10 -2) HowToSubmitABug.html | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) Index: llvm/docs/HowToSubmitABug.html diff -u llvm/docs/HowToSubmitABug.html:1.29 llvm/docs/HowToSubmitABug.html:1.30 --- llvm/docs/HowToSubmitABug.html:1.29 Sat Feb 24 19:11:36 2007 +++ llvm/docs/HowToSubmitABug.html Sun Feb 25 12:50:48 2007 @@ -186,6 +186,9 @@

    • llc foo.bc -f
    • llc foo.bc -f -relocation-model=pic
    • llc foo.bc -f -relocation-model=static
    • +
    • llc foo.bc -f -enable-eh
    • +
    • llc foo.bc -f -relocation-model=pic -enable-eh
    • +
    • llc foo.bc -f -relocation-model=static -enable-eh
    • If none of these crash, please follow the instructions for a @@ -194,11 +197,16 @@ the one corresponding to the command above that failed):

        -
      1. bugpoint -run-llc foo.bc --tool-args
      2. +
      3. bugpoint -run-llc foo.bc
      4. bugpoint -run-llc foo.bc --tool-args -relocation-model=pic
      5. bugpoint -run-llc foo.bc --tool-args -relocation-model=static
      6. +
      7. bugpoint -run-llc foo.bc --tool-args -enable-eh
      8. +
      9. bugpoint -run-llc foo.bc --tool-args + -relocation-model=pic -enable-eh
      10. +
      11. bugpoint -run-llc foo.bc --tool-args + -relocation-model=static -enable-eh

      Please run this, then file a bug with the instructions and reduced .bc file @@ -340,7 +348,7 @@ Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2007/02/25 01:11:36 $ + Last modified: $Date: 2007/02/25 18:50:48 $ From sabre at nondot.org Sun Feb 25 13:21:10 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 13:21:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCInstr64Bit.td PPCInstrInfo.td Message-ID: <200702251921.l1PJLA8a014142@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCInstr64Bit.td updated: 1.39 -> 1.40 PPCInstrInfo.td updated: 1.273 -> 1.274 --- Log message: one important bugfix: PPC32 didn't have both elf and macho support for external symbols and global addresses. Add the missing ones. one important workaround: PPCISD::CALL is matched by both PPCcall_ELF and PPCcall_Macho, disable the _ELF patterns for now. --- Diffs of the changes: (+10 -6) PPCInstr64Bit.td | 6 +++--- PPCInstrInfo.td | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) Index: llvm/lib/Target/PowerPC/PPCInstr64Bit.td diff -u llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.39 llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.40 --- llvm/lib/Target/PowerPC/PPCInstr64Bit.td:1.39 Sat Feb 24 23:34:32 2007 +++ llvm/lib/Target/PowerPC/PPCInstr64Bit.td Sun Feb 25 13:20:53 2007 @@ -102,7 +102,7 @@ def BLA8_ELF : IForm<18, 1, 1, (ops aaddr:$func, variable_ops), - "bla $func", BrB, [(PPCcall_ELF (i64 imm:$func))]>; + "bla $func", BrB, [/*(PPCcall_ELF (i64 imm:$func))*/]>; } @@ -111,12 +111,12 @@ (BL8_Macho tglobaladdr:$dst)>; def : Pat<(PPCcall_Macho (i64 texternalsym:$dst)), (BL8_Macho texternalsym:$dst)>; - +/* def : Pat<(PPCcall_ELF (i64 tglobaladdr:$dst)), (BL8_ELF tglobaladdr:$dst)>; def : Pat<(PPCcall_ELF (i64 texternalsym:$dst)), (BL8_ELF texternalsym:$dst)>; - +*/ //===----------------------------------------------------------------------===// // 64-bit SPR manipulation instrs. Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.273 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.274 --- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.273 Sat Feb 24 23:34:32 2007 +++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Sun Feb 25 13:20:53 2007 @@ -407,11 +407,11 @@ def BLA_ELF : IForm<18, 1, 1, (ops aaddr:$func, variable_ops), "bla $func", BrB, - [(PPCcall_ELF (i32 imm:$func))]>; + [/*(PPCcall_ELF (i32 imm:$func))*/]>; def BCTRL_ELF : XLForm_2_ext<19, 528, 20, 0, 1, (ops variable_ops), "bctrl", BrB, - [(PPCbctrl_ELF)]>; + [/*(PPCbctrl_ELF)*/]>; } // DCB* instructions. @@ -1102,8 +1102,12 @@ // Calls def : Pat<(PPCcall_Macho (i32 tglobaladdr:$dst)), (BL_Macho tglobaladdr:$dst)>; +def : Pat<(PPCcall_Macho (i32 texternalsym:$dst)), + (BL_Macho texternalsym:$dst)>; +/*def : Pat<(PPCcall_ELF (i32 tglobaladdr:$dst)), + (BL_ELF tglobaladdr:$dst)>; def : Pat<(PPCcall_ELF (i32 texternalsym:$dst)), - (BL_ELF texternalsym:$dst)>; + (BL_ELF texternalsym:$dst)>;*/ // Hi and Lo for Darwin Global Addresses. def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>; From reid at x10sys.com Sun Feb 25 13:26:17 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 13:26:17 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h Message-ID: <200702251926.l1PJQHes014235@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.18 -> 1.19 --- Log message: Fix clearUnusedBits to not depend on "undefined behavior" of >> operator when the bit size is equal to the word size. This happens to work out okay on x86, but might not on other platforms. The change just detects when there are no bits to clear (because BitWidth is a multiple of the word size) and returns early. Also, move some comments from .cpp file into header. --- Diffs of the changes: (+40 -9) APInt.h | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 40 insertions(+), 9 deletions(-) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.18 llvm/include/llvm/ADT/APInt.h:1.19 --- llvm/include/llvm/ADT/APInt.h:1.18 Sun Feb 25 01:29:03 2007 +++ llvm/include/llvm/ADT/APInt.h Sun Feb 25 13:26:01 2007 @@ -114,12 +114,22 @@ /// by the APInt. This is needed after the most significant word is assigned /// a value to ensure that those bits are zero'd out. /// @brief Clear high order bits - inline void clearUnusedBits() { + inline APInt& clearUnusedBits() { + // Compute how many bits are used in the final word + uint32_t wordBits = BitWidth % APINT_BITS_PER_WORD; + if (wordBits == 0) + // If all bits are used, we want to leave the value alone. This also + // avoids the undefined behavior of >> when the shfit is the same size as + // the word size (64). + return *this; + + // Mask out the hight bits. + uint64_t mask = ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - wordBits); if (isSingleWord()) - VAL &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); + VAL &= mask; else - pVal[getNumWords() - 1] &= ~uint64_t(0ULL) >> - (APINT_BITS_PER_WORD - (whichBit(BitWidth - 1) + 1)); + pVal[getNumWords() - 1] &= mask; + return *this; } /// @returns the corresponding word for the specified bit position. @@ -134,7 +144,9 @@ uint8_t radix); /// This is used by the toString method to divide by the radix. It simply - /// provides a more convenient form of divide for internal use. + /// provides a more convenient form of divide for internal use since KnuthDiv + /// has specific constraints on its inputs. If those constraints are not met + /// then it provides a simpler form of divide. /// @brief An internal division function for dividing APInts. static void divide(const APInt LHS, uint32_t lhsWords, const APInt &RHS, uint32_t rhsWords, @@ -481,15 +493,30 @@ /// @returns true if the argument APInt value is a power of two > 0. bool isPowerOf2() const; + /// countLeadingZeros - This function is an APInt version of the + /// countLeadingZeros_{32,64} functions in MathExtras.h. It counts the number + /// of zeros from the most significant bit to the first one bit. + /// @returns getNumWords() * APINT_BITS_PER_WORD if the value is zero. /// @returns the number of zeros from the most significant bit to the first /// one bits. + /// @brief Count the number of trailing one bits. uint32_t countLeadingZeros() const; + /// countTrailingZeros - This function is an APInt version of the + /// countTrailingZoers_{32,64} functions in MathExtras.h. It counts + /// the number of zeros from the least significant bit to the first one bit. + /// @returns getNumWords() * APINT_BITS_PER_WORD if the value is zero. /// @returns the number of zeros from the least significant bit to the first /// one bit. + /// @brief Count the number of trailing zero bits. uint32_t countTrailingZeros() const; + /// countPopulation - This function is an APInt version of the + /// countPopulation_{32,64} functions in MathExtras.h. It counts the number + /// of 1 bits in the APInt value. + /// @returns 0 if the value is zero. /// @returns the number of set bits. + /// @brief Count the number of bits set. uint32_t countPopulation() const; /// @returns the total number of bits. @@ -550,9 +577,11 @@ return APIVal.logBase2(); } -/// @returns the greatest common divisor of the two values -/// using Euclid's algorithm. -APInt GreatestCommonDivisor(const APInt& API1, const APInt& API2); +/// GreatestCommonDivisor - This function returns the greatest common +/// divisor of the two APInt values using Enclid's algorithm. +/// @returns the greatest common divisor of Val1 and Val2 +/// @brief Compute GCD of two APInt values. +APInt GreatestCommonDivisor(const APInt& Val1, const APInt& Val2); /// @brief Converts the given APInt to a double value. inline double RoundAPIntToDouble(const APInt& APIVal, bool isSigned = false) { @@ -564,10 +593,12 @@ return float(RoundAPIntToDouble(APIVal)); } +/// RoundDoubleToAPInt - This function convert a double value to an APInt value. /// @brief Converts the given double value into a APInt. APInt RoundDoubleToAPInt(double Double); -/// @brief Converts the given float value into a APInt. +/// RoundFloatToAPInt - Converts a float value into an APInt value. +/// @brief Converts a float value into a APInt. inline APInt RoundFloatToAPInt(float Float) { return RoundDoubleToAPInt(double(Float)); } From reid at x10sys.com Sun Feb 25 13:32:20 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 13:32:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702251932.l1PJWKNN014337@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.41 -> 1.42 --- Log message: 1. Provide more detail in file comment. 2. Move comments for methods to .h file, delete them in .cpp file. 3. All places that were doing manual clear of high order bits now call the clearUnusedBits() method in order to not depend on undefined behavior of the >> operator when the number of bits shifted equals the word size. 4. Reduced # of loc by using the new result of clearUnusedBits() method. 5. Simplified logic (decreased indentation) in a few places. 6. Added code comments to larger functions that needed them. 7. Added FIXME notes about weak implementations of things (e.g. bit-by-bit shift right is sub-optimal). --- Diffs of the changes: (+145 -189) APInt.cpp | 334 ++++++++++++++++++++++++++------------------------------------ 1 files changed, 145 insertions(+), 189 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.41 llvm/lib/Support/APInt.cpp:1.42 --- llvm/lib/Support/APInt.cpp:1.41 Sun Feb 25 01:30:14 2007 +++ llvm/lib/Support/APInt.cpp Sun Feb 25 13:32:03 2007 @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// // -// This file implements a class to represent arbitrary precision integral -// constant values. +// This file implements a class to represent arbitrary precision integer +// constant values and provide a variety of arithmetic operations on them. // //===----------------------------------------------------------------------===// @@ -26,8 +26,8 @@ using namespace llvm; -// A utility function for allocating memory, checking for allocation failures, -// and ensuring the contents are zeroed. +/// A utility function for allocating memory, checking for allocation failures, +/// and ensuring the contents are zeroed. inline static uint64_t* getClearedMemory(uint32_t numWords) { uint64_t * result = new uint64_t[numWords]; assert(result && "APInt memory allocation fails!"); @@ -35,8 +35,8 @@ return result; } -// A utility function for allocating memory and checking for allocation failure. -// The content is not zero'd +/// A utility function for allocating memory and checking for allocation +/// failure. The content is not zeroed. inline static uint64_t* getMemory(uint32_t numWords) { uint64_t * result = new uint64_t[numWords]; assert(result && "APInt memory allocation fails!"); @@ -47,12 +47,13 @@ : BitWidth(numBits), VAL(0) { assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); - if (isSingleWord()) - VAL = val & (~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth)); + if (isSingleWord()) + VAL = val; else { pVal = getClearedMemory(getNumWords()); pVal[0] = val; } + clearUnusedBits(); } APInt::APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[]) @@ -124,7 +125,7 @@ /// "digit" integer array, x[]. x[] is modified to reflect the addition and /// 1 is returned if there is a carry out, otherwise 0 is returned. /// @returns the carry of the addition. -static uint64_t add_1(uint64_t dest[], uint64_t x[], uint32_t len, uint64_t y) { +static bool add_1(uint64_t dest[], uint64_t x[], uint32_t len, uint64_t y) { for (uint32_t i = 0; i < len; ++i) { dest[i] = y + x[i]; if (dest[i] < y) @@ -143,8 +144,7 @@ ++VAL; else add_1(pVal, pVal, getNumWords(), 1); - clearUnusedBits(); - return *this; + return clearUnusedBits(); } /// sub_1 - This function subtracts a single "digit" (64-bit word), y, from @@ -152,8 +152,8 @@ /// no further borrowing is neeeded or it runs out of "digits" in x. The result /// is 1 if "borrowing" exhausted the digits in x, or 0 if x was not exhausted. /// In other words, if y > x then this function returns 1, otherwise 0. -static uint64_t sub_1(uint64_t x[], uint32_t len, - uint64_t y) { +/// @returns the borrow out of the subtraction +static bool sub_1(uint64_t x[], uint32_t len, uint64_t y) { for (uint32_t i = 0; i < len; ++i) { uint64_t X = x[i]; x[i] -= y; @@ -164,7 +164,7 @@ break; // Remaining digits are unchanged so exit early } } - return y; + return bool(y); } /// @brief Prefix decrement operator. Decrements the APInt by one. @@ -173,12 +173,13 @@ --VAL; else sub_1(pVal, getNumWords(), 1); - clearUnusedBits(); - return *this; + return clearUnusedBits(); } -/// add - This function adds the integer array x[] by integer array -/// y[] and returns the carry. +/// add - This function adds the integer array x to the integer array Y and +/// places the result in dest. +/// @returns the carry out from the addition +/// @brief General addition of 64-bit integer arrays static bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, uint32_t len) { bool carry = false; @@ -190,8 +191,9 @@ return carry; } -/// @brief Addition assignment operator. Adds this APInt by the given APInt& -/// RHS and assigns the result to this APInt. +/// Adds the RHS APint to this APInt. +/// @returns this, after addition of RHS. +/// @brief Addition assignment operator. APInt& APInt::operator+=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) @@ -199,12 +201,12 @@ else { add(pVal, pVal, RHS.pVal, getNumWords()); } - clearUnusedBits(); - return *this; + return clearUnusedBits(); } -/// sub - This function subtracts the integer array x[] by -/// integer array y[], and returns the borrow-out. +/// Subtracts the integer array y from the integer array x +/// @returns returns the borrow out. +/// @brief Generalized subtraction of 64-bit integer arrays. static bool sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, uint32_t len) { bool borrow = false; @@ -216,29 +218,33 @@ return borrow; } -/// @brief Subtraction assignment operator. Subtracts this APInt by the given -/// APInt &RHS and assigns the result to this APInt. +/// Subtracts the RHS APInt from this APInt +/// @returns this, after subtraction +/// @brief Subtraction assignment operator. APInt& APInt::operator-=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) VAL -= RHS.VAL; else sub(pVal, pVal, RHS.pVal, getNumWords()); - clearUnusedBits(); - return *this; + return clearUnusedBits(); } -/// mul_1 - This function performs the multiplication operation on a -/// large integer (represented as an integer array) and a uint64_t integer. -/// @returns the carry of the multiplication. +/// Multiplies an integer array, x by a a uint64_t integer and places the result +/// into dest. +/// @returns the carry out of the multiplication. +/// @brief Multiply a multi-digit APInt by a single digit (64-bit) integer. static uint64_t mul_1(uint64_t dest[], uint64_t x[], uint32_t len, uint64_t y) { // Split y into high 32-bit part (hy) and low 32-bit part (ly) uint64_t ly = y & 0xffffffffULL, hy = y >> 32; - uint64_t carry = 0, lx, hx; + uint64_t carry = 0; + + // For each digit of x. for (uint32_t i = 0; i < len; ++i) { - lx = x[i] & 0xffffffffULL; - hx = x[i] >> 32; - // hasCarry - A flag to indicate if has carry. + // Split x into high and low words + uint64_t lx = x[i] & 0xffffffffULL; + uint64_t hx = x[i] >> 32; + // hasCarry - A flag to indicate if there is a carry to the next digit. // hasCarry == 0, no carry // hasCarry == 1, has carry // hasCarry == 2, no carry and the calculation result == 0. @@ -256,13 +262,12 @@ carry = (((!carry && hasCarry != 2) || hasCarry == 1) ? (1ULL << 32) : 0) + (carry >> 32) + ((lx * hy) >> 32) + hx * hy; } - return carry; } -/// mul - This function multiplies integer array x[] by integer array y[] and -/// stores the result into integer array dest[]. -/// Note the array dest[]'s size should no less than xlen + ylen. +/// Multiplies integer array x by integer array y and stores the result into +/// the integer array dest. Note that dest's size must be >= xlen + ylen. +/// @brief Generalized multiplicate of integer arrays. static void mul(uint64_t dest[], uint64_t x[], uint32_t xlen, uint64_t y[], uint32_t ylen) { dest[xlen] = mul_1(dest, x, xlen, y[0]); @@ -293,8 +298,6 @@ } } -/// @brief Multiplication assignment operator. Multiplies this APInt by the -/// given APInt& RHS and assigns the result to this APInt. APInt& APInt::operator*=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) { @@ -336,8 +339,6 @@ return *this; } -/// @brief Bitwise AND assignment operator. Performs bitwise AND operation on -/// this APInt and the given APInt& RHS, assigns the result to this APInt. APInt& APInt::operator&=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) { @@ -350,8 +351,6 @@ return *this; } -/// @brief Bitwise OR assignment operator. Performs bitwise OR operation on -/// this APInt and the given APInt& RHS, assigns the result to this APInt. APInt& APInt::operator|=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) { @@ -364,8 +363,6 @@ return *this; } -/// @brief Bitwise XOR assignment operator. Performs bitwise XOR operation on -/// this APInt and the given APInt& RHS, assigns the result to this APInt. APInt& APInt::operator^=(const APInt& RHS) { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) { @@ -376,56 +373,47 @@ uint32_t numWords = getNumWords(); for (uint32_t i = 0; i < numWords; ++i) pVal[i] ^= RHS.pVal[i]; - this->clearUnusedBits(); - return *this; + return clearUnusedBits(); } -/// @brief Bitwise AND operator. Performs bitwise AND operation on this APInt -/// and the given APInt& RHS. APInt APInt::operator&(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) return APInt(getBitWidth(), VAL & RHS.VAL); - APInt Result(*this); uint32_t numWords = getNumWords(); + uint64_t* val = getMemory(numWords); for (uint32_t i = 0; i < numWords; ++i) - Result.pVal[i] &= RHS.pVal[i]; - return Result; + val[i] = pVal[i] & RHS.pVal[i]; + return APInt(val, getBitWidth()); } -/// @brief Bitwise OR operator. Performs bitwise OR operation on this APInt -/// and the given APInt& RHS. APInt APInt::operator|(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) return APInt(getBitWidth(), VAL | RHS.VAL); - APInt Result(*this); uint32_t numWords = getNumWords(); + uint64_t *val = getMemory(numWords); for (uint32_t i = 0; i < numWords; ++i) - Result.pVal[i] |= RHS.pVal[i]; - return Result; + val[i] = pVal[i] | RHS.pVal[i]; + return APInt(val, getBitWidth()); } -/// @brief Bitwise XOR operator. Performs bitwise XOR operation on this APInt -/// and the given APInt& RHS. APInt APInt::operator^(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) { - APInt Result(BitWidth, VAL ^ RHS.VAL); - Result.clearUnusedBits(); - return Result; - } - APInt Result(*this); + if (isSingleWord()) + return APInt(BitWidth, VAL ^ RHS.VAL).clearUnusedBits(); + uint32_t numWords = getNumWords(); + uint64_t *val = getMemory(numWords); for (uint32_t i = 0; i < numWords; ++i) - Result.pVal[i] ^= RHS.pVal[i]; - return Result; + val[i] = pVal[i] ^ RHS.pVal[i]; + + // 0^0==1 so clear the high bits in case they got set. + return APInt(val, getBitWidth()).clearUnusedBits(); } -/// @brief Logical negation operator. Performs logical negation operation on -/// this APInt. bool APInt::operator !() const { if (isSingleWord()) return !VAL; @@ -436,77 +424,61 @@ return true; } -/// @brief Multiplication operator. Multiplies this APInt by the given APInt& -/// RHS. APInt APInt::operator*(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) { - APInt Result(BitWidth, VAL * RHS.VAL); - Result.clearUnusedBits(); - return Result; - } + if (isSingleWord()) + return APInt(BitWidth, VAL * RHS.VAL).clearUnusedBits(); APInt Result(*this); Result *= RHS; - Result.clearUnusedBits(); - return Result; + return Result.clearUnusedBits(); } -/// @brief Addition operator. Adds this APInt by the given APInt& RHS. APInt APInt::operator+(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) { - APInt Result(BitWidth, VAL + RHS.VAL); - Result.clearUnusedBits(); - return Result; - } + if (isSingleWord()) + return APInt(BitWidth, VAL + RHS.VAL).clearUnusedBits(); APInt Result(BitWidth, 0); add(Result.pVal, this->pVal, RHS.pVal, getNumWords()); - Result.clearUnusedBits(); - return Result; + return Result.clearUnusedBits(); } -/// @brief Subtraction operator. Subtracts this APInt by the given APInt& RHS APInt APInt::operator-(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); - if (isSingleWord()) { - APInt Result(BitWidth, VAL - RHS.VAL); - Result.clearUnusedBits(); - return Result; - } + if (isSingleWord()) + return APInt(BitWidth, VAL - RHS.VAL).clearUnusedBits(); APInt Result(BitWidth, 0); sub(Result.pVal, this->pVal, RHS.pVal, getNumWords()); - Result.clearUnusedBits(); - return Result; + return Result.clearUnusedBits(); } -/// @brief Array-indexing support. bool APInt::operator[](uint32_t bitPosition) const { - return (maskBit(bitPosition) & (isSingleWord() ? - VAL : pVal[whichWord(bitPosition)])) != 0; + return (maskBit(bitPosition) & + (isSingleWord() ? VAL : pVal[whichWord(bitPosition)])) != 0; } -/// @brief Equality operator. Compare this APInt with the given APInt& RHS -/// for the validity of the equality relationship. bool APInt::operator==(const APInt& RHS) const { if (isSingleWord()) return VAL == RHS.VAL; + // Get some facts about the number of bits used in the two operands. uint32_t n1 = getActiveBits(); uint32_t n2 = RHS.getActiveBits(); + + // If the number of bits isn't the same, they aren't equal if (n1 != n2) return false; + // If the number of bits fits in a word, we only need to compare the low word. if (n1 <= APINT_BITS_PER_WORD) return pVal[0] == RHS.pVal[0]; + // Otherwise, compare everything for (int i = whichWord(n1 - 1); i >= 0; --i) if (pVal[i] != RHS.pVal[i]) return false; return true; } -/// @brief Equality operator. Compare this APInt with the given uint64_t value -/// for the validity of the equality relationship. bool APInt::operator==(uint64_t Val) const { if (isSingleWord()) return VAL == Val; @@ -518,29 +490,37 @@ return false; } -/// @brief Unsigned less than comparison bool APInt::ult(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) return VAL < RHS.VAL; - else { - uint32_t n1 = getActiveBits(); - uint32_t n2 = RHS.getActiveBits(); - if (n1 < n2) - return true; - else if (n2 < n1) + + // Get active bit length of both operands + uint32_t n1 = getActiveBits(); + uint32_t n2 = RHS.getActiveBits(); + + // If magnitude of LHS is less than RHS, return true. + if (n1 < n2) + return true; + + // If magnitude of RHS is greather than LHS, return false. + if (n2 < n1) + return false; + + // If they bot fit in a word, just compare the low order word + if (n1 <= APINT_BITS_PER_WORD && n2 <= APINT_BITS_PER_WORD) + return pVal[0] < RHS.pVal[0]; + + // Otherwise, compare all words + for (int i = whichWord(n1 - 1); i >= 0; --i) { + if (pVal[i] > RHS.pVal[i]) return false; - else if (n1 <= APINT_BITS_PER_WORD && n2 <= APINT_BITS_PER_WORD) - return pVal[0] < RHS.pVal[0]; - for (int i = whichWord(n1 - 1); i >= 0; --i) { - if (pVal[i] > RHS.pVal[i]) return false; - else if (pVal[i] < RHS.pVal[i]) return true; - } + if (pVal[i] < RHS.pVal[i]) + return true; } return false; } -/// @brief Signed less than comparison bool APInt::slt(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"); if (isSingleWord()) { @@ -554,15 +534,20 @@ bool lhsNegative = false; bool rhsNegative = false; if (lhs[BitWidth-1]) { + // Sign bit is set so make a note of it and perform two's complement lhsNegative = true; lhs.flip(); lhs++; } if (rhs[BitWidth-1]) { + // Sign bit is set so make a note of it and perform two's complement rhsNegative = true; rhs.flip(); rhs++; } + + // Now we have unsigned values to compare so do the comparison if necessary + // based on the negativeness of the values. if (lhsNegative) if (rhsNegative) return !lhs.ult(rhs); @@ -574,25 +559,25 @@ return lhs.ult(rhs); } -/// Set the given bit to 1 whose poition is given as "bitPosition". -/// @brief Set a given bit to 1. APInt& APInt::set(uint32_t bitPosition) { - if (isSingleWord()) VAL |= maskBit(bitPosition); - else pVal[whichWord(bitPosition)] |= maskBit(bitPosition); + if (isSingleWord()) + VAL |= maskBit(bitPosition); + else + pVal[whichWord(bitPosition)] |= maskBit(bitPosition); return *this; } -/// @brief Set every bit to 1. APInt& APInt::set() { - if (isSingleWord()) - VAL = ~0ULL >> (APINT_BITS_PER_WORD - BitWidth); - else { - for (uint32_t i = 0; i < getNumWords() - 1; ++i) - pVal[i] = -1ULL; - pVal[getNumWords() - 1] = ~0ULL >> - (APINT_BITS_PER_WORD - BitWidth % APINT_BITS_PER_WORD); + if (isSingleWord()) { + VAL = -1ULL; + return clearUnusedBits(); } - return *this; + + // Set all the bits in all the words. + for (uint32_t i = 0; i < getNumWords() - 1; ++i) + pVal[i] = -1ULL; + // Clear the unused ones + return clearUnusedBits(); } /// Set the given bit to 0 whose position is given as "bitPosition". @@ -695,11 +680,6 @@ return (!!*this) && !(*this & (*this - APInt(BitWidth,1))); } -/// countLeadingZeros - This function is a APInt version corresponding to -/// llvm/include/llvm/Support/MathExtras.h's function -/// countLeadingZeros_{32, 64}. It performs platform optimal form of counting -/// the number of zeros from the most significant bit to the first one bit. -/// @returns numWord() * 64 if the value is zero. uint32_t APInt::countLeadingZeros() const { uint32_t Count = 0; if (isSingleWord()) @@ -720,11 +700,6 @@ return Count; } -/// countTrailingZeros - This function is a APInt version corresponding to -/// llvm/include/llvm/Support/MathExtras.h's function -/// countTrailingZeros_{32, 64}. It performs platform optimal form of counting -/// the number of zeros from the least significant bit to the first one bit. -/// @returns numWord() * 64 if the value is zero. uint32_t APInt::countTrailingZeros() const { if (isSingleWord()) return CountTrailingZeros_64(VAL); @@ -732,10 +707,6 @@ return getNumWords() * APINT_BITS_PER_WORD - Tmp.countLeadingZeros(); } -/// countPopulation - This function is a APInt version corresponding to -/// llvm/include/llvm/Support/MathExtras.h's function -/// countPopulation_{32, 64}. It counts the number of set bits in a value. -/// @returns 0 if the value is zero. uint32_t APInt::countPopulation() const { if (isSingleWord()) return CountPopulation_64(VAL); @@ -745,9 +716,6 @@ return Count; } - -/// byteSwap - This function returns a byte-swapped representation of the -/// this APInt. APInt APInt::byteSwap() const { assert(BitWidth >= 16 && BitWidth % 16 == 0 && "Cannot byteswap!"); if (BitWidth == 16) @@ -776,8 +744,6 @@ } } -/// GreatestCommonDivisor - This function returns the greatest common -/// divisor of the two APInt values using Enclid's algorithm. APInt llvm::APIntOps::GreatestCommonDivisor(const APInt& API1, const APInt& API2) { APInt A = API1, B = API2; @@ -789,8 +755,6 @@ return A; } -/// DoubleRoundToAPInt - This function convert a double value to -/// a APInt value. APInt llvm::APIntOps::RoundDoubleToAPInt(double Double) { union { double D; @@ -879,16 +843,19 @@ // Truncate to new width. void APInt::trunc(uint32_t width) { assert(width < BitWidth && "Invalid APInt Truncate request"); + // FIXME: implement } // Sign extend to a new width. void APInt::sext(uint32_t width) { assert(width > BitWidth && "Invalid APInt SignExtend request"); + // FIXME: implement } // Zero extend to a new width. void APInt::zext(uint32_t width) { assert(width > BitWidth && "Invalid APInt ZeroExtend request"); + // FIXME: implement } /// Arithmetic right-shift this APInt by shiftAmt. @@ -896,33 +863,32 @@ APInt APInt::ashr(uint32_t shiftAmt) const { if (isSingleWord()) { if (shiftAmt == BitWidth) - return APInt(BitWidth, -1ull); + return APInt(BitWidth, -1ULL); else return APInt(BitWidth, (((int64_t(VAL) << (APINT_BITS_PER_WORD - BitWidth)) >> - (APINT_BITS_PER_WORD - BitWidth)) >> shiftAmt) & - (~uint64_t(0UL) >> (APINT_BITS_PER_WORD - BitWidth))); + (APINT_BITS_PER_WORD - BitWidth)) >> shiftAmt)).clearUnusedBits(); } APInt Result(*this); if (shiftAmt >= BitWidth) { memset(Result.pVal, Result[BitWidth-1] ? 1 : 0, (getNumWords()-1) * APINT_WORD_SIZE); - Result.pVal[getNumWords() - 1] = ~uint64_t(0UL) >> - (APINT_BITS_PER_WORD - BitWidth % APINT_BITS_PER_WORD); - } else { - uint32_t i = 0; - for (; i < BitWidth - shiftAmt; ++i) - if (Result[i+shiftAmt]) - Result.set(i); - else - Result.clear(i); - for (; i < BitWidth; ++i) - if (Result[BitWidth-1]) - Result.set(i); - else - Result.clear(i); - } + return Result.clearUnusedBits(); + } + + // FIXME: bit-at-a-time shift is really slow. + uint32_t i = 0; + for (; i < BitWidth - shiftAmt; ++i) + if (Result[i+shiftAmt]) + Result.set(i); + else + Result.clear(i); + for (; i < BitWidth; ++i) + if (Result[BitWidth-1]) + Result.set(i); + else + Result.clear(i); return Result; } @@ -936,8 +902,12 @@ return APInt(BitWidth, this->VAL >> shiftAmt); APInt Result(*this); - if (shiftAmt >= Result.BitWidth) - memset(Result.pVal, 0, Result.getNumWords() * APINT_WORD_SIZE); + if (shiftAmt >= BitWidth) { + Result.clear(); + return Result; + } + + // FIXME: bit at a time shift is really slow uint32_t i = 0; for (i = 0; i < Result.BitWidth - shiftAmt; ++i) if (Result[i+shiftAmt]) @@ -956,9 +926,7 @@ if (isSingleWord()) { if (shiftAmt == BitWidth) return APInt(BitWidth, 0); // avoid undefined shift results - return APInt(BitWidth, (VAL << shiftAmt) & - (~uint64_t(0ULL) >> - (APINT_BITS_PER_WORD - BitWidth))); + return APInt(BitWidth, VAL << shiftAmt).clearUnusedBits(); } // If all the bits were shifted out, the result is 0. This avoids issues @@ -978,8 +946,7 @@ val[i] = pVal[i] << shiftAmt | carry; carry = pVal[i] >> (APINT_BITS_PER_WORD - shiftAmt); } - val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); - return APInt(val, BitWidth); + return APInt(val, BitWidth).clearUnusedBits(); } // Compute some values needed by the remaining shift algorithms @@ -992,8 +959,7 @@ val[i] = 0; for (uint32_t i = offset; i < getNumWords(); i++) val[i] = pVal[i-offset]; - val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); - return APInt(val,BitWidth); + return APInt(val,BitWidth).clearUnusedBits(); } // Copy whole words from this to Result. @@ -1004,8 +970,7 @@ val[offset] = pVal[0] << wordShift; for (i = 0; i < offset; ++i) val[i] = 0; - val[getNumWords()-1] &= ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - BitWidth); - return APInt(val, BitWidth); + return APInt(val, BitWidth).clearUnusedBits(); } /// Implementation of Knuth's Algorithm D (Division of nonnegative integers) @@ -1185,9 +1150,6 @@ DEBUG(cerr << std::setbase(10) << '\n'); } -// This function makes calling KnuthDiv a little more convenient. It uses -// APInt parameters instead of uint32_t* parameters. It can also divide APInt -// values of different widths. void APInt::divide(const APInt LHS, uint32_t lhsWords, const APInt &RHS, uint32_t rhsWords, APInt *Quotient, APInt *Remainder) @@ -1364,8 +1326,6 @@ } } -/// Unsigned divide this APInt by APInt RHS. -/// @brief Unsigned division function for APInt. APInt APInt::udiv(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); @@ -1403,8 +1363,6 @@ return Quotient; } -/// Unsigned remainder operation on APInt. -/// @brief Function for unsigned remainder operation. APInt APInt::urem(const APInt& RHS) const { assert(BitWidth == RHS.BitWidth && "Bit widths must be the same"); if (isSingleWord()) { @@ -1442,7 +1400,6 @@ return Remainder; } -/// @brief Converts a char array into an integer. void APInt::fromString(uint32_t numbits, const char *str, uint32_t slen, uint8_t radix) { // Check our assumptions here @@ -1498,7 +1455,6 @@ } } -/// to_string - This function translates the APInt into a string. std::string APInt::toString(uint8_t radix, bool wantSigned) const { assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); From sabre at nondot.org Sun Feb 25 13:59:35 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 13:59:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200702251959.l1PJxZu7014780@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.254 -> 1.255 --- Log message: always promote float varargs to double. --- Diffs of the changes: (+1 -1) PPCISelLowering.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.254 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.255 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.254 Sat Feb 24 23:34:32 2007 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Sun Feb 25 13:59:18 2007 @@ -1423,7 +1423,7 @@ break; case MVT::f32: case MVT::f64: - if (isVarArg && isPPC64) { + if (isVarArg || isPPC64) { // Float varargs need to be promoted to double. if (Arg.getValueType() == MVT::f32) Arg = DAG.getNode(ISD::FP_EXTEND, MVT::f64, Arg); From sabre at nondot.org Sun Feb 25 14:01:57 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 14:01:57 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200702252001.l1PK1vNk014896@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.255 -> 1.256 --- Log message: no really, this is the right patch --- Diffs of the changes: (+1 -1) PPCISelLowering.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.255 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.256 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.255 Sun Feb 25 13:59:18 2007 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Sun Feb 25 14:01:40 2007 @@ -1423,7 +1423,7 @@ break; case MVT::f32: case MVT::f64: - if (isVarArg || isPPC64) { + if (isVarArg) { // Float varargs need to be promoted to double. if (Arg.getValueType() == MVT::f32) Arg = DAG.getNode(ISD::FP_EXTEND, MVT::f64, Arg); From sabre at nondot.org Sun Feb 25 14:43:15 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 14:43:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ValueSymbolTable.cpp Message-ID: <200702252043.l1PKhF4t015603@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ValueSymbolTable.cpp updated: 1.11 -> 1.12 --- Log message: disable some noisy debug output --- Diffs of the changes: (+12 -12) ValueSymbolTable.cpp | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-) Index: llvm/lib/VMCore/ValueSymbolTable.cpp diff -u llvm/lib/VMCore/ValueSymbolTable.cpp:1.11 llvm/lib/VMCore/ValueSymbolTable.cpp:1.12 --- llvm/lib/VMCore/ValueSymbolTable.cpp:1.11 Sun Feb 11 23:18:08 2007 +++ llvm/lib/VMCore/ValueSymbolTable.cpp Sun Feb 25 14:42:59 2007 @@ -23,9 +23,9 @@ ValueSymbolTable::~ValueSymbolTable() { #ifndef NDEBUG // Only do this in -g mode... for (iterator VI = vmap.begin(), VE = vmap.end(); VI != VE; ++VI) - DEBUG(DOUT << "Value still in symbol table! Type = '" - << VI->getValue()->getType()->getDescription() << "' Name = '" - << VI->getKeyData() << "'\n"); + cerr << "Value still in symbol table! Type = '" + << VI->getValue()->getType()->getDescription() << "' Name = '" + << VI->getKeyData() << "'\n"; assert(vmap.empty() && "Values remain in symbol table!"); #endif } @@ -61,7 +61,7 @@ // Try inserting the name, assuming it won't conflict. if (vmap.insert(V->Name)) { - DOUT << " Inserted value: " << V->Name << ": " << *V << "\n"; + //DOUT << " Inserted value: " << V->Name << ": " << *V << "\n"; return; } @@ -84,14 +84,14 @@ // Newly inserted name. Success! NewName.setValue(V); V->Name = &NewName; - DEBUG(DOUT << " Inserted value: " << UniqueName << ": " << *V << "\n"); + //DEBUG(DOUT << " Inserted value: " << UniqueName << ": " << *V << "\n"); return; } } } void ValueSymbolTable::removeValueName(ValueName *V) { - DEBUG(DOUT << " Removing Value: " << V->getKeyData() << "\n"); + //DEBUG(DOUT << " Removing Value: " << V->getKeyData() << "\n"); // Remove the value from the plane. vmap.remove(V); } @@ -104,8 +104,8 @@ ValueName &Entry = vmap.GetOrCreateValue(NameStart, NameStart+NameLen); if (Entry.getValue() == 0) { Entry.setValue(V); - DEBUG(DOUT << " Inserted value: " << Entry.getKeyData() << ": " - << *V << "\n"); + //DEBUG(DOUT << " Inserted value: " << Entry.getKeyData() << ": " + // << *V << "\n"); return &Entry; } @@ -123,7 +123,7 @@ if (NewName.getValue() == 0) { // Newly inserted name. Success! NewName.setValue(V); - DEBUG(DOUT << " Inserted value: " << UniqueName << ": " << *V << "\n"); + //DEBUG(DOUT << " Inserted value: " << UniqueName << ": " << *V << "\n"); return &NewName; } } @@ -133,10 +133,10 @@ // dump - print out the symbol table // void ValueSymbolTable::dump() const { - DOUT << "ValueSymbolTable:\n"; + //DOUT << "ValueSymbolTable:\n"; for (const_iterator I = begin(), E = end(); I != E; ++I) { - DOUT << " '" << I->getKeyData() << "' = "; + //DOUT << " '" << I->getKeyData() << "' = "; I->getValue()->dump(); - DOUT << "\n"; + //DOUT << "\n"; } } From sabre at nondot.org Sun Feb 25 15:04:56 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 15:04:56 -0600 Subject: [llvm-commits] CVS: llvm/test/Transforms/GlobalOpt/constantexpr-dangle.ll Message-ID: <200702252104.l1PL4uXm015982@zion.cs.uiuc.edu> Changes in directory llvm/test/Transforms/GlobalOpt: constantexpr-dangle.ll added (r1.1) --- Log message: new testcase. @foo should be marked fastcc by globalopt --- Diffs of the changes: (+11 -0) constantexpr-dangle.ll | 11 +++++++++++ 1 files changed, 11 insertions(+) Index: llvm/test/Transforms/GlobalOpt/constantexpr-dangle.ll diff -c /dev/null llvm/test/Transforms/GlobalOpt/constantexpr-dangle.ll:1.1 *** /dev/null Sun Feb 25 15:04:49 2007 --- llvm/test/Transforms/GlobalOpt/constantexpr-dangle.ll Sun Feb 25 15:04:39 2007 *************** *** 0 **** --- 1,11 ---- + ; RUN: llvm-as < %s | opt -instcombine -globalopt | llvm-dis | grep 'internal fastcc float @foo' + define internal float @foo() { + ret float 0.000000e+00 + } + + define float @bar() { + %tmp1 = call float (...)* bitcast (float ()* @foo to float (...)*)( ) + %tmp2 = mul float %tmp1, 1.000000e+01 ; [#uses=1] + ret float %tmp2 + } + From sabre at nondot.org Sun Feb 25 15:06:35 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 15:06:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp Message-ID: <200702252106.l1PL6ZSF016058@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Globals.cpp updated: 1.15 -> 1.16 --- Log message: Rework GlobalValue::removeDeadConstantUsers to always remove dead constant exprs hanging off a global, even if the global is not otherwise dead. This requires some tricky iterator gymnastics. This implements Transforms/GlobalOpt/constantexpr-dangle.ll by deleting a constantexpr that made it appear that the address of the function was taken. --- Diffs of the changes: (+29 -21) Globals.cpp | 50 +++++++++++++++++++++++++++++--------------------- 1 files changed, 29 insertions(+), 21 deletions(-) Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.15 llvm/lib/VMCore/Globals.cpp:1.16 --- llvm/lib/VMCore/Globals.cpp:1.15 Mon Feb 5 14:47:20 2007 +++ llvm/lib/VMCore/Globals.cpp Sun Feb 25 15:06:13 2007 @@ -22,20 +22,18 @@ // GlobalValue Class //===----------------------------------------------------------------------===// -/// This could be named "SafeToDestroyGlobalValue". It just makes sure that -/// there are no non-constant uses of this GlobalValue. If there aren't then -/// this and the transitive closure of the constants can be deleted. See the -/// destructor for details. -static bool removeDeadConstantUsers(Constant* C) { +/// removeDeadUsersOfConstant - If the specified constantexpr is dead, remove +/// it. This involves recursively eliminating any dead users of the +/// constantexpr. +static bool removeDeadUsersOfConstant(Constant *C) { if (isa(C)) return false; // Cannot remove this - while (!C->use_empty()) - if (Constant *User = dyn_cast(C->use_back())) { - if (!removeDeadConstantUsers(User)) - return false; // Constant wasn't dead - } else { - return false; // Non-constant usage; - } + while (!C->use_empty()) { + Constant *User = dyn_cast(C->use_back()); + if (!User) return false; // Non-constant usage; + if (!removeDeadUsersOfConstant(User)) + return false; // Constant wasn't dead + } C->destroyConstant(); return true; @@ -45,17 +43,27 @@ /// off of this global value, remove them. This method is useful for clients /// that want to check to see if a global is unused, but don't want to deal /// with potentially dead constants hanging off of the globals. -/// -/// This function returns true if the global value is now dead. If all -/// users of this global are not dead, this method may return false and -/// leave some of them around. void GlobalValue::removeDeadConstantUsers() { - while(!use_empty()) { - if (Constant* User = dyn_cast(use_back())) { - if (!::removeDeadConstantUsers(User)) - return; // Constant wasn't dead + + Value::use_iterator I = use_begin(), E = use_end(); + Value::use_iterator LastNonDeadUser = E; + for (; I != E; ++I) { + if (Constant *User = dyn_cast(*I)) { + if (!removeDeadUsersOfConstant(User)) { + // If the constant wasn't dead, remember that this was the last live use + // and move on to the next constant. + LastNonDeadUser = I; + } else { + // If the constant was dead, then the iterator is invalidated. + if (LastNonDeadUser == E) { + I = use_begin(); + if (I == E) break; + } else { + I = LastNonDeadUser; + } + } } else { - return; // Non-constant usage; + LastNonDeadUser = I; } } } From sabre at nondot.org Sun Feb 25 15:06:35 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 15:06:35 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalValue.h Message-ID: <200702252106.l1PL6ZAV016061@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalValue.h updated: 1.33 -> 1.34 --- Log message: Rework GlobalValue::removeDeadConstantUsers to always remove dead constant exprs hanging off a global, even if the global is not otherwise dead. This requires some tricky iterator gymnastics. This implements Transforms/GlobalOpt/constantexpr-dangle.ll by deleting a constantexpr that made it appear that the address of the function was taken. --- Diffs of the changes: (+0 -4) GlobalValue.h | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/include/llvm/GlobalValue.h diff -u llvm/include/llvm/GlobalValue.h:1.33 llvm/include/llvm/GlobalValue.h:1.34 --- llvm/include/llvm/GlobalValue.h:1.33 Sun Feb 11 23:18:08 2007 +++ llvm/include/llvm/GlobalValue.h Sun Feb 25 15:06:13 2007 @@ -128,10 +128,6 @@ /// off of this global value, remove them. This method is useful for clients /// that want to check to see if a global is unused, but don't want to deal /// with potentially dead constants hanging off of the globals. - /// - /// This method tries to make the global dead. If it detects a user that - /// would prevent it from becoming completely dead, it gives up early, - /// potentially leaving some dead constant users around. void removeDeadConstantUsers(); // Methods for support type inquiry through isa, cast, and dyn_cast: From jlaskey at apple.com Sun Feb 25 15:43:38 2007 From: jlaskey at apple.com (Jim Laskey) Date: Sun, 25 Feb 2007 15:43:38 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/Generic/2007-02-25-invoke.ll Message-ID: <200702252143.l1PLhcqo016647@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/Generic: 2007-02-25-invoke.ll added (r1.1) --- Log message: Test for PR1224: http://llvm.org/PR1224 . --- Diffs of the changes: (+12 -0) 2007-02-25-invoke.ll | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/test/CodeGen/Generic/2007-02-25-invoke.ll diff -c /dev/null llvm/test/CodeGen/Generic/2007-02-25-invoke.ll:1.1 *** /dev/null Sun Feb 25 15:43:31 2007 --- llvm/test/CodeGen/Generic/2007-02-25-invoke.ll Sun Feb 25 15:43:21 2007 *************** *** 0 **** --- 1,12 ---- + ; RUN: llvm-as < %s | llc + + ; PR1224 + + declare i32 @test() + define i32 @test2() { + %A = invoke i32 @test() to label %invcont unwind label %blat + invcont: + ret i32 %A + blat: + ret i32 0 + } From jlaskey at apple.com Sun Feb 25 15:44:16 2007 From: jlaskey at apple.com (Jim Laskey) Date: Sun, 25 Feb 2007 15:44:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702252144.l1PLiGxs016671@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.375 -> 1.376 --- Log message: Fix for PR1224: http://llvm.org/PR1224 . --- Diffs of the changes: (+50 -35) SelectionDAGISel.cpp | 85 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 50 insertions(+), 35 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.375 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.376 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.375 Sun Feb 25 12:40:32 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Feb 25 15:43:59 2007 @@ -500,6 +500,7 @@ // These all get lowered before this pass. void visitInvoke(InvokeInst &I); + void visitInvoke(InvokeInst &I, bool AsTerminator); void visitUnwind(UnwindInst &I); void visitScalarBinary(User &I, unsigned OpCode); @@ -1102,44 +1103,49 @@ } void SelectionDAGLowering::visitInvoke(InvokeInst &I) { + assert(0 && "Should never be visited directly"); +} +void SelectionDAGLowering::visitInvoke(InvokeInst &I, bool AsTerminator) { // Retrieve successors. MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)]; MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)]; - // Mark landing pad so that it doesn't get deleted in branch folding. - LandingPad->setIsLandingPad(); - - // Insert a label before the invoke call to mark the try range. - // This can be used to detect deletion of the invoke via the - // MachineModuleInfo. - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - unsigned BeginLabel = MMI->NextLabelID(); - DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), - DAG.getConstant(BeginLabel, MVT::i32))); - - LowerCallTo(I, I.getCalledValue()->getType(), - I.getCallingConv(), - false, - getValue(I.getOperand(0)), - 3); - - // Insert a label before the invoke call to mark the try range. - // This can be used to detect deletion of the invoke via the - // MachineModuleInfo. - unsigned EndLabel = MMI->NextLabelID(); - DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), - DAG.getConstant(EndLabel, MVT::i32))); - - // Inform MachineModuleInfo of range. - MMI->addInvoke(LandingPad, BeginLabel, EndLabel); - - // Drop into normal successor. - DAG.setRoot(DAG.getNode(ISD::BR, MVT::Other, getRoot(), - DAG.getBasicBlock(Return))); - - // Update successor info - CurMBB->addSuccessor(Return); - CurMBB->addSuccessor(LandingPad); + if (!AsTerminator) { + // Mark landing pad so that it doesn't get deleted in branch folding. + LandingPad->setIsLandingPad(); + + // Insert a label before the invoke call to mark the try range. + // This can be used to detect deletion of the invoke via the + // MachineModuleInfo. + MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + unsigned BeginLabel = MMI->NextLabelID(); + DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), + DAG.getConstant(BeginLabel, MVT::i32))); + + LowerCallTo(I, I.getCalledValue()->getType(), + I.getCallingConv(), + false, + getValue(I.getOperand(0)), + 3); + + // Insert a label before the invoke call to mark the try range. + // This can be used to detect deletion of the invoke via the + // MachineModuleInfo. + unsigned EndLabel = MMI->NextLabelID(); + DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), + DAG.getConstant(EndLabel, MVT::i32))); + + // Inform MachineModuleInfo of range. + MMI->addInvoke(LandingPad, BeginLabel, EndLabel); + + // Update successor info + CurMBB->addSuccessor(Return); + CurMBB->addSuccessor(LandingPad); + } else { + // Drop into normal successor. + DAG.setRoot(DAG.getNode(ISD::BR, MVT::Other, getRoot(), + DAG.getBasicBlock(Return))); + } } void SelectionDAGLowering::visitUnwind(UnwindInst &I) { @@ -4216,6 +4222,10 @@ for (BasicBlock::iterator I = LLVMBB->begin(), E = --LLVMBB->end(); I != E; ++I) SDL.visit(*I); + + // Lower call part of invoke. + InvokeInst *Invoke = dyn_cast(LLVMBB->getTerminator()); + if (Invoke) SDL.visitInvoke(*Invoke, false); // Ensure that all instructions which are used outside of their defining // blocks are available as virtual registers. @@ -4328,7 +4338,12 @@ } // Lower the terminator after the copies are emitted. - SDL.visit(*LLVMBB->getTerminator()); + if (Invoke) { + // Just the branch part of invoke. + SDL.visitInvoke(*Invoke, true); + } else { + SDL.visit(*LLVMBB->getTerminator()); + } // Copy over any CaseBlock records that may now exist due to SwitchInst // lowering, as well as any jump table information. From sabre at nondot.org Sun Feb 25 16:02:18 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 16:02:18 -0600 Subject: [llvm-commits] CVS: llvm/test/CFrontend/2007-02-25-C-DotDotDot.c Message-ID: <200702252202.l1PM2I7M017025@zion.cs.uiuc.edu> Changes in directory llvm/test/CFrontend: 2007-02-25-C-DotDotDot.c added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+11 -0) 2007-02-25-C-DotDotDot.c | 11 +++++++++++ 1 files changed, 11 insertions(+) Index: llvm/test/CFrontend/2007-02-25-C-DotDotDot.c diff -c /dev/null llvm/test/CFrontend/2007-02-25-C-DotDotDot.c:1.1 *** /dev/null Sun Feb 25 16:02:11 2007 --- llvm/test/CFrontend/2007-02-25-C-DotDotDot.c Sun Feb 25 16:02:01 2007 *************** *** 0 **** --- 1,11 ---- + // RUN: %llvmgcc -O0 -S -o - -emit-llvm -fno-inline -fno-unit-at-a-time %s | grep 'call float @foo' + + // Make sure the call to foo is compiled as: + // call float @foo() + // not + // call float (...)* bitcast (float ()* @foo to float (...)*)( ) + + static float foo() { return 0.0; } + float bar() { return foo()*10.0;} + + From clattner at apple.com Sun Feb 25 16:01:14 2007 From: clattner at apple.com (clattner at apple.com) Date: Sun, 25 Feb 2007 14:01:14 -0800 (PST) Subject: [llvm-commits] [124303] Lower calls to "implicit ..." functions more carefully. Message-ID: <20070225220114.D746964C1F6D@src> Revision: 124303 Author: clattner Date: 2007-02-25 14:01:13 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Lower calls to "implicit ..." functions more carefully. This implements test/CFrontend/2007-02-25-C-DotDotDot.c Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-convert.cpp Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-25 18:44:39 UTC (rev 124302) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-02-25 22:01:13 UTC (rev 124303) @@ -2190,7 +2190,7 @@ // Pass the static chain, if any, as the first parameter. if (TREE_OPERAND(exp, 2)) - CallOperands.push_back (Emit(TREE_OPERAND(exp, 2), 0)); + CallOperands.push_back(Emit(TREE_OPERAND(exp, 2), 0)); // Loop over the arguments, expanding them and adding them to the op list. const PointerType *PFTy = cast(Callee->getType()); @@ -2226,8 +2226,28 @@ } } - // TODO: Check to see if the arguments and callee types disagree. If so, - // insert a cast of the callee to a type that will work. + // Compile stuff like: + // %tmp = call float (...)* bitcast (float ()* @foo to float (...)*)( ) + // to: + // %tmp = call float @foo( ) + // This commonly occurs due to C "implicit ..." semantics. + if (ConstantExpr *CE = dyn_cast(Callee)) { + if (CallOperands.empty() && CE->getOpcode() == Instruction::BitCast) { + Constant *RealCallee = CE->getOperand(0); + assert(isa(RealCallee->getType()) && + "Bitcast to ptr not from ptr?"); + const PointerType *RealPT = cast(RealCallee->getType()); + if (const FunctionType *RealFT = + dyn_cast(RealPT->getElementType())) { + const PointerType *ActualPT = cast(Callee->getType()); + const FunctionType *ActualFT = + cast(ActualPT->getElementType()); + if (RealFT->getReturnType() == ActualFT->getReturnType() && + ActualFT->getNumParams() == 0) + Callee = RealCallee; + } + } + } Value *Call; if (!UnwindBlock) { From sabre at nondot.org Sun Feb 25 16:23:31 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 16:23:31 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/2007-02-25-FastCCStack.ll Message-ID: <200702252223.l1PMNVqr017407@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: 2007-02-25-FastCCStack.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+5 -0) 2007-02-25-FastCCStack.ll | 5 +++++ 1 files changed, 5 insertions(+) Index: llvm/test/CodeGen/X86/2007-02-25-FastCCStack.ll diff -c /dev/null llvm/test/CodeGen/X86/2007-02-25-FastCCStack.ll:1.1 *** /dev/null Sun Feb 25 16:23:25 2007 --- llvm/test/CodeGen/X86/2007-02-25-FastCCStack.ll Sun Feb 25 16:23:15 2007 *************** *** 0 **** --- 1,5 ---- + ; RUN: llvm-as < %s | llc -march=x86 -mcpu=pentium3 + + define internal fastcc double @ggc_rlimit_bound(double %limit) { + ret double %limit + } From sabre at nondot.org Sun Feb 25 16:24:03 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 16:24:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702252224.l1PMO3ao017426@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.335 -> 1.336 --- Log message: fix CodeGen/X86/2007-02-25-FastCCStack.ll, a regression from my patch last night: fastcc returns should only go in XMM0 if we have SSE2 or above. --- Diffs of the changes: (+1 -1) X86ISelLowering.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.335 llvm/lib/Target/X86/X86ISelLowering.cpp:1.336 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.335 Sun Feb 25 03:31:16 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 16:23:46 2007 @@ -456,7 +456,7 @@ case MVT::f64: if (Subtarget->is64Bit()) Reg = X86::XMM0; // FP values in X86-64 go in XMM0. - else if (CC == CallingConv::Fast) + else if (CC == CallingConv::Fast && Subtarget->hasSSE2()) Reg = X86::XMM0; // FP values in X86-32 with fastcc go in XMM0. else Reg = X86::ST0; // FP values in X86-32 go in ST0. From clattner at apple.com Sun Feb 25 16:58:45 2007 From: clattner at apple.com (clattner at apple.com) Date: Sun, 25 Feb 2007 14:58:45 -0800 (PST) Subject: [llvm-commits] [124304] Make debug_tree(type) print the LLVM type if it exists. Message-ID: <20070225225845.3FC8564D05B4@src> Revision: 124304 Author: clattner Date: 2007-02-25 14:58:44 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Make debug_tree(type) print the LLVM type if it exists. Patch contributed by Duncan Sands! Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-backend.cpp apple-local/branches/llvm/gcc/llvm-types.cpp apple-local/branches/llvm/gcc/llvm.h apple-local/branches/llvm/gcc/print-tree.c apple-local/branches/llvm/gcc/tree.h Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 22:01:13 UTC (rev 124303) +++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-02-25 22:58:44 UTC (rev 124304) @@ -920,4 +920,13 @@ WriteAsOperand(FS, (Value*)LLVM, true, TheModule); } +// print_llvm_type - Print the specified LLVM type symbolically, called by +// print-tree.c for tree dumps. +// +void print_llvm_type(FILE *file, void *LLVM) { + oFILEstream FS(file); + FS << "LLVM: "; + WriteTypeSymbolic(FS, (const Type*)LLVM, TheModule); +} + /* APPLE LOCAL end LLVM (ENTIRE FILE!) */ Modified: apple-local/branches/llvm/gcc/llvm-types.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-25 22:01:13 UTC (rev 124303) +++ apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-25 22:58:44 UTC (rev 124304) @@ -64,8 +64,7 @@ static LTypesMapTy LTypesMap; // GET_TYPE_LLVM/SET_TYPE_LLVM - Associate an LLVM type with each TREE type. -// These are lazily computed by ConvertType, accessors available only to C++ -// code. +// These are lazily computed by ConvertType. #define SET_TYPE_SYMTAB_LLVM(NODE, index) (TYPE_CHECK (NODE)->type.symtab.llvm = index) @@ -92,7 +91,7 @@ // Get LLVM Type for the GCC tree node based on LTypes vector index. // When GCC tree node is initialized, it has 0 as the index value. This is // why all recorded indexes are offset by 1. -static inline const Type *llvm_get_type(unsigned Index) { +extern "C" inline const Type *llvm_get_type(unsigned Index) { if (Index == 0) return NULL; Modified: apple-local/branches/llvm/gcc/llvm.h =================================================================== --- apple-local/branches/llvm/gcc/llvm.h 2007-02-25 22:01:13 UTC (rev 124303) +++ apple-local/branches/llvm/gcc/llvm.h 2007-02-25 22:58:44 UTC (rev 124304) @@ -80,6 +80,11 @@ */ void print_llvm(FILE *file, void *LLVM); +/* print_llvm_type - Print the specified LLVM type symbolically, called by + * print-tree.c for tree dumps. + */ +void print_llvm_type(FILE *file, void *LLVM); + /* Init pch writing. */ void llvm_pch_write_init(void); Modified: apple-local/branches/llvm/gcc/print-tree.c =================================================================== --- apple-local/branches/llvm/gcc/print-tree.c 2007-02-25 22:01:13 UTC (rev 124303) +++ apple-local/branches/llvm/gcc/print-tree.c 2007-02-25 22:58:44 UTC (rev 124304) @@ -603,6 +603,16 @@ lang_hooks.print_type (file, node, indent); + /* APPLE LOCAL begin LLVM */ +#ifdef ENABLE_LLVM + if (GET_TYPE_LLVM (node)) + { + indent_to (file, indent + 4); + print_llvm_type (file, GET_TYPE_LLVM (node)); + } +#endif + /* APPLE LOCAL end LLVM */ + if (TYPE_POINTER_TO (node) || TREE_CHAIN (node)) indent_to (file, indent + 3); Modified: apple-local/branches/llvm/gcc/tree.h =================================================================== --- apple-local/branches/llvm/gcc/tree.h 2007-02-25 22:01:13 UTC (rev 124303) +++ apple-local/branches/llvm/gcc/tree.h 2007-02-25 22:58:44 UTC (rev 124304) @@ -2095,7 +2095,15 @@ /* The DECL_LLVM for NODE, if it is set, or NULL, if it is not set. */ #define DECL_LLVM_IF_SET(NODE) \ (DECL_LLVM_SET_P (NODE) ? DECL_LLVM (NODE) : NULL) + +#ifndef __cplusplus +/* C version, for debugging */ +extern void *llvm_get_type(unsigned); +#define GET_TYPE_LLVM(NODE) \ + (void *)llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm) #endif + +#endif /* APPLE LOCAL end LLVM */ /* For PARM_DECL, holds an RTL for the stack slot or register From sabre at nondot.org Sun Feb 25 17:08:46 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 17:08:46 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/x86-64-shortint.ll Message-ID: <200702252308.l1PN8kaH018281@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: x86-64-shortint.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+13 -0) x86-64-shortint.ll | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/test/CodeGen/X86/x86-64-shortint.ll diff -c /dev/null llvm/test/CodeGen/X86/x86-64-shortint.ll:1.1 *** /dev/null Sun Feb 25 17:08:39 2007 --- llvm/test/CodeGen/X86/x86-64-shortint.ll Sun Feb 25 17:08:29 2007 *************** *** 0 **** --- 1,13 ---- + ; RUN: llvm-as < %s | llc | grep movswl + + target datalayout = "e-p:64:64" + target triple = "x86_64-apple-darwin8" + + implementation ; Functions: + + define void @bar(i16 zext %A) { + tail call void @foo( i16 %A sext ) + ret void + } + declare void @foo(i16 sext ) + From sabre at nondot.org Sun Feb 25 17:11:03 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 17:11:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702252311.l1PNB3an018489@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.336 -> 1.337 --- Log message: Fix an X86-64 abi bug. We now compile: void foo(short); void bar(unsigned short A) { foo(A); } into: _bar: subq $8, %rsp movswl %di, %edi call _foo addq $8, %rsp ret instead of: _bar: subq $8, %rsp call _foo addq $8, %rsp ret Testcase here: test/CodeGen/X86/x86-64-shortint.ll --- Diffs of the changes: (+13 -10) X86ISelLowering.cpp | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.336 llvm/lib/Target/X86/X86ISelLowering.cpp:1.337 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.336 Sun Feb 25 16:23:46 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 17:10:46 2007 @@ -1301,12 +1301,6 @@ unsigned NumIntRegs = 0; // Int regs used for parameter passing. unsigned NumXMMRegs = 0; // XMM regs used for parameter passing. - static const unsigned GPR8ArgRegs[] = { - X86::DIL, X86::SIL, X86::DL, X86::CL, X86::R8B, X86::R9B - }; - static const unsigned GPR16ArgRegs[] = { - X86::DI, X86::SI, X86::DX, X86::CX, X86::R8W, X86::R9W - }; static const unsigned GPR32ArgRegs[] = { X86::EDI, X86::ESI, X86::EDX, X86::ECX, X86::R8D, X86::R9D }; @@ -1366,7 +1360,16 @@ for (unsigned i = 0; i != NumOps; ++i) { SDOperand Arg = Op.getOperand(5+2*i); MVT::ValueType ArgVT = Arg.getValueType(); + unsigned ArgFlags =cast(Op.getOperand(5+2*i+1))->getValue(); + if (MVT::isInteger(ArgVT) && ArgVT < MVT::i32) { + // Promote the integer to 32 bits. If the input type is signed use a + // sign extend, otherwise use a zero extend. + unsigned ExtOpc = (ArgFlags & 1) ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND; + Arg = DAG.getNode(ExtOpc, MVT::i32, Arg); + ArgVT = MVT::i32; + } + switch (ArgVT) { default: assert(0 && "Unexpected ValueType for argument!"); case MVT::i8: @@ -1376,10 +1379,10 @@ if (NumIntRegs < 6) { unsigned Reg = 0; switch (ArgVT) { - default: break; - case MVT::i8: Reg = GPR8ArgRegs[NumIntRegs]; break; - case MVT::i16: Reg = GPR16ArgRegs[NumIntRegs]; break; - case MVT::i32: Reg = GPR32ArgRegs[NumIntRegs]; break; + default: assert(0 && "Unknown integer size!"); + case MVT::i32: + Reg = GPR32ArgRegs[NumIntRegs]; + break; case MVT::i64: Reg = GPR64ArgRegs[NumIntRegs]; break; } RegsToPass.push_back(std::make_pair(Reg, Arg)); From reid at x10sys.com Sun Feb 25 17:45:10 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 17:45:10 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702252345.l1PNjA2O019581@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.42 -> 1.43 --- Log message: 1. Fix the flip() method to correctly flip all words of the APInt. 2. Implement the trunc, sext, and zext operations. 3. Improve fromString to accept negative values as input. --- Diffs of the changes: (+89 -13) APInt.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 89 insertions(+), 13 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.42 llvm/lib/Support/APInt.cpp:1.43 --- llvm/lib/Support/APInt.cpp:1.42 Sun Feb 25 13:32:03 2007 +++ llvm/lib/Support/APInt.cpp Sun Feb 25 17:44:53 2007 @@ -609,17 +609,13 @@ /// @brief Toggle every bit to its opposite value. APInt& APInt::flip() { - if (isSingleWord()) VAL = (~(VAL << - (APINT_BITS_PER_WORD - BitWidth))) >> (APINT_BITS_PER_WORD - BitWidth); - else { - uint32_t i = 0; - for (; i < getNumWords() - 1; ++i) - pVal[i] = ~pVal[i]; - uint32_t offset = - APINT_BITS_PER_WORD - (BitWidth - APINT_BITS_PER_WORD * (i - 1)); - pVal[i] = (~(pVal[i] << offset)) >> offset; + if (isSingleWord()) { + VAL = ~VAL; + return clearUnusedBits(); } - return *this; + for (uint32_t i = 0; i < getNumWords(); ++i) + pVal[i] = ~pVal[i]; + return clearUnusedBits(); } /// Toggle a given bit to its opposite value whose position is given @@ -843,19 +839,91 @@ // Truncate to new width. void APInt::trunc(uint32_t width) { assert(width < BitWidth && "Invalid APInt Truncate request"); - // FIXME: implement + assert(width >= IntegerType::MIN_INT_BITS && "Can't truncate to 0 bits"); + uint32_t wordsBefore = getNumWords(); + BitWidth = width; + uint32_t wordsAfter = getNumWords(); + if (wordsBefore != wordsAfter) { + if (wordsAfter == 1) { + uint64_t *tmp = pVal; + VAL = pVal[0]; + delete tmp; + } else { + uint64_t *newVal = getClearedMemory(wordsAfter); + for (uint32_t i = 0; i < wordsAfter; ++i) + newVal[i] = pVal[i]; + delete pVal; + pVal = newVal; + } + } + clearUnusedBits(); } // Sign extend to a new width. void APInt::sext(uint32_t width) { assert(width > BitWidth && "Invalid APInt SignExtend request"); - // FIXME: implement + assert(width <= IntegerType::MAX_INT_BITS && "Too many bits"); + bool isNegative = (*this)[BitWidth-1]; + // If the sign bit isn't set, this is the same as zext. + if (!isNegative) { + zext(width); + return; + } + + // The sign bit is set. First, get some facts + uint32_t wordsBefore = getNumWords(); + uint32_t wordBits = BitWidth % APINT_BITS_PER_WORD; + BitWidth = width; + uint32_t wordsAfter = getNumWords(); + + // Mask the high order word appropriately + if (wordsBefore == wordsAfter) { + uint32_t newWordBits = width % APINT_BITS_PER_WORD; + // The extension is contained to the wordsBefore-1th word. + uint64_t mask = (~0ULL >> (APINT_BITS_PER_WORD - newWordBits)) << wordBits; + if (wordsBefore == 1) + VAL |= mask; + else + pVal[wordsBefore-1] |= mask; + clearUnusedBits(); + return; + } + + uint64_t mask = ~0ULL << wordBits; + uint64_t *newVal = getMemory(wordsAfter); + if (wordsBefore == 1) + newVal[0] = VAL | mask; + else { + for (uint32_t i = 0; i < wordsBefore; ++i) + newVal[i] = pVal[i]; + newVal[wordsBefore-1] |= mask; + } + for (uint32_t i = wordsBefore; i < wordsAfter; i++) + newVal[i] = -1ULL; + if (wordsBefore != 1) + delete pVal; + pVal = newVal; + clearUnusedBits(); } // Zero extend to a new width. void APInt::zext(uint32_t width) { assert(width > BitWidth && "Invalid APInt ZeroExtend request"); - // FIXME: implement + assert(width <= IntegerType::MAX_INT_BITS && "Too many bits"); + uint32_t wordsBefore = getNumWords(); + BitWidth = width; + uint32_t wordsAfter = getNumWords(); + if (wordsBefore != wordsAfter) { + uint64_t *newVal = getClearedMemory(wordsAfter); + if (wordsBefore == 1) + newVal[0] = VAL; + else + for (uint32_t i = 0; i < wordsBefore; ++i) + newVal[i] = pVal[i]; + if (wordsBefore != 1) + delete pVal; + pVal = newVal; + } } /// Arithmetic right-shift this APInt by shiftAmt. @@ -1406,6 +1474,9 @@ assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); assert(str && "String is null?"); + bool isNegative = str[0] == '-'; + if (isNegative) + str++, slen--; assert(slen <= numbits || radix != 2 && "Insufficient bit width"); assert(slen*3 <= numbits || radix != 8 && "Insufficient bit width"); assert(slen*4 <= numbits || radix != 16 && "Insufficient bit width"); @@ -1453,6 +1524,11 @@ apdigit.pVal[0] = digit; *this += apdigit; } + // If its negative, put it in two's complement form + if (isNegative) { + this->flip(); + (*this)++; + } } std::string APInt::toString(uint8_t radix, bool wantSigned) const { From reid at x10sys.com Sun Feb 25 17:54:16 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 17:54:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702252354.l1PNsGbY019821@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.43 -> 1.44 --- Log message: Fix sext operation. Shifting by zero would leave an incorrect mask. --- Diffs of the changes: (+1 -1) APInt.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.43 llvm/lib/Support/APInt.cpp:1.44 --- llvm/lib/Support/APInt.cpp:1.43 Sun Feb 25 17:44:53 2007 +++ llvm/lib/Support/APInt.cpp Sun Feb 25 17:54:00 2007 @@ -889,7 +889,7 @@ return; } - uint64_t mask = ~0ULL << wordBits; + uint64_t mask = wordBits == 0 ? 0 : ~0ULL << wordBits; uint64_t *newVal = getMemory(wordsAfter); if (wordsBefore == 1) newVal[0] = VAL | mask; From reid at x10sys.com Sun Feb 25 19:20:05 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 19:20:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Support/APInt.cpp Message-ID: <200702260120.l1Q1K5Za021459@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: APInt.cpp updated: 1.44 -> 1.45 --- Log message: Rewrite lshr to not do bit by bit copy but to copy and shift whole words. This makes it much more efficient. --- Diffs of the changes: (+44 -17) APInt.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 44 insertions(+), 17 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.44 llvm/lib/Support/APInt.cpp:1.45 --- llvm/lib/Support/APInt.cpp:1.44 Sun Feb 25 17:54:00 2007 +++ llvm/lib/Support/APInt.cpp Sun Feb 25 19:19:48 2007 @@ -969,22 +969,50 @@ else return APInt(BitWidth, this->VAL >> shiftAmt); - APInt Result(*this); - if (shiftAmt >= BitWidth) { - Result.clear(); - return Result; - } - - // FIXME: bit at a time shift is really slow - uint32_t i = 0; - for (i = 0; i < Result.BitWidth - shiftAmt; ++i) - if (Result[i+shiftAmt]) - Result.set(i); - else - Result.clear(i); - for (; i < Result.BitWidth; ++i) - Result.clear(i); - return Result; + // If all the bits were shifted out, the result is 0. This avoids issues + // with shifting by the size of the integer type, which produces undefined + // results. We define these "undefined results" to always be 0. + if (shiftAmt == BitWidth) + return APInt(BitWidth, 0); + + // Create some space for the result. + uint64_t * val = new uint64_t[getNumWords()]; + + // If we are shifting less than a word, compute the shift with a simple carry + if (shiftAmt < APINT_BITS_PER_WORD) { + uint64_t carry = 0; + for (int i = getNumWords()-1; i >= 0; --i) { + val[i] = pVal[i] >> shiftAmt | carry; + carry = pVal[i] << (APINT_BITS_PER_WORD - shiftAmt); + } + return APInt(val, BitWidth).clearUnusedBits(); + } + + // Compute some values needed by the remaining shift algorithms + uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD; + uint32_t offset = shiftAmt / APINT_BITS_PER_WORD; + + // If we are shifting whole words, just move whole words + if (wordShift == 0) { + for (uint32_t i = 0; i < getNumWords() - offset; ++i) + val[i] = pVal[i+offset]; + for (uint32_t i = getNumWords()-offset; i < getNumWords(); i++) + val[i] = 0; + return APInt(val,BitWidth).clearUnusedBits(); + } + + // Shift the low order words + uint32_t breakWord = getNumWords() - offset -1; + for (uint32_t i = 0; i < breakWord; ++i) + val[i] = pVal[i+offset] >> wordShift | + pVal[i+offset+1] << (APINT_BITS_PER_WORD - wordShift); + // Shift the break word. + val[breakWord] = pVal[breakWord+offset] >> wordShift; + + // Remaining words are 0 + for (uint32_t i = breakWord+1; i < getNumWords(); ++i) + val[i] = 0; + return APInt(val, BitWidth).clearUnusedBits(); } /// Left-shift this APInt by shiftAmt. @@ -1009,7 +1037,6 @@ // If we are shifting less than a word, do it the easy way if (shiftAmt < APINT_BITS_PER_WORD) { uint64_t carry = 0; - shiftAmt %= APINT_BITS_PER_WORD; for (uint32_t i = 0; i < getNumWords(); i++) { val[i] = pVal[i] << shiftAmt | carry; carry = pVal[i] >> (APINT_BITS_PER_WORD - shiftAmt); From reid at x10sys.com Sun Feb 25 19:21:16 2007 From: reid at x10sys.com (Reid Spencer) Date: Sun, 25 Feb 2007 19:21:16 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h Message-ID: <200702260121.l1Q1LGWB021520@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/ADT: APInt.h updated: 1.19 -> 1.20 --- Log message: Add an isNegative method to determine if the APInt's value is negative. This is much less expensive than a test against zero. --- Diffs of the changes: (+7 -0) APInt.h | 7 +++++++ 1 files changed, 7 insertions(+) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.19 llvm/include/llvm/ADT/APInt.h:1.20 --- llvm/include/llvm/ADT/APInt.h:1.19 Sun Feb 25 13:26:01 2007 +++ llvm/include/llvm/ADT/APInt.h Sun Feb 25 19:20:59 2007 @@ -352,6 +352,13 @@ return !slt(RHS); } + /// This just tests the high bit of this APInt to determine if it is negative. + /// @returns true if this APInt is negative, false otherwise + /// @brief Determine sign of this APInt. + bool isNegative() { + return (*this)[BitWidth - 1]; + } + /// Arithmetic right-shift this APInt by shiftAmt. /// @brief Arithmetic right-shift function. APInt ashr(uint32_t shiftAmt) const; From sabre at nondot.org Sun Feb 25 20:57:14 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 20:57:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200702260257.l1Q2vE7a023206@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: SelectionDAGISel.cpp updated: 1.376 -> 1.377 --- Log message: track signedness of formal argument, though we have a fixme here. --- Diffs of the changes: (+8 -0) SelectionDAGISel.cpp | 8 ++++++++ 1 files changed, 8 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.376 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.377 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.376 Sun Feb 25 15:43:59 2007 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Feb 25 20:56:58 2007 @@ -3111,8 +3111,16 @@ // Flags[31:27] -> OriginalAlignment // Flags[2] -> isSRet // Flags[1] -> isInReg + // Flags[0] -> isSigned unsigned Flags = (isInReg << 1) | (isSRet << 2) | (OriginalAlignment << 27); + // FIXME: Distinguish between a formal with no [sz]ext attribute from one + // that is zero extended! + if (FTy->paramHasAttr(j, FunctionType::ZExtAttribute)) + Flags |= 0; + if (FTy->paramHasAttr(j, FunctionType::SExtAttribute)) + Flags |= 1; + switch (getTypeAction(VT)) { default: assert(0 && "Unknown type action!"); case Legal: From sabre at nondot.org Sun Feb 25 21:14:16 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 21:14:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <200702260314.l1Q3EGDF023500@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp updated: 1.270 -> 1.271 --- Log message: Fold (sext (truncate x)) more aggressively, by avoiding creation of a sextinreg if not needed. This is useful in two cases: before legalize, it avoids creating a sextinreg that will be trivially removed. After legalize if the target doesn't support sextinreg, the trunc/sext would not have been removed before. --- Diffs of the changes: (+34 -10) DAGCombiner.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 files changed, 34 insertions(+), 10 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.270 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.271 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.270 Thu Feb 8 16:13:59 2007 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun Feb 25 21:13:59 2007 @@ -1940,18 +1940,42 @@ if (N0.getOpcode() == ISD::SIGN_EXTEND || N0.getOpcode() == ISD::ANY_EXTEND) return DAG.getNode(ISD::SIGN_EXTEND, VT, N0.getOperand(0)); - // fold (sext (truncate x)) -> (sextinreg x). - if (N0.getOpcode() == ISD::TRUNCATE && - (!AfterLegalize || TLI.isOperationLegal(ISD::SIGN_EXTEND_INREG, - N0.getValueType()))) { + if (N0.getOpcode() == ISD::TRUNCATE) { + // See if the value being truncated is already sign extended. If so, just + // eliminate the trunc/sext pair. SDOperand Op = N0.getOperand(0); - if (Op.getValueType() < VT) { - Op = DAG.getNode(ISD::ANY_EXTEND, VT, Op); - } else if (Op.getValueType() > VT) { - Op = DAG.getNode(ISD::TRUNCATE, VT, Op); + unsigned OpBits = MVT::getSizeInBits(Op.getValueType()); + unsigned MidBits = MVT::getSizeInBits(N0.getValueType()); + unsigned DestBits = MVT::getSizeInBits(VT); + unsigned NumSignBits = TLI.ComputeNumSignBits(Op); + + if (OpBits == DestBits) { + // Op is i32, Mid is i8, and Dest is i32. If Op has more than 24 sign + // bits, it is already ready. + if (NumSignBits > DestBits-MidBits) + return Op; + } else if (OpBits < DestBits) { + // Op is i32, Mid is i8, and Dest is i64. If Op has more than 24 sign + // bits, just sext from i32. + if (NumSignBits > OpBits-MidBits) + return DAG.getNode(ISD::SIGN_EXTEND, VT, Op); + } else { + // Op is i64, Mid is i8, and Dest is i32. If Op has more than 56 sign + // bits, just truncate to i32. + if (NumSignBits > OpBits-MidBits) + return DAG.getNode(ISD::TRUNCATE, VT, Op); + } + + // fold (sext (truncate x)) -> (sextinreg x). + if (!AfterLegalize || TLI.isOperationLegal(ISD::SIGN_EXTEND_INREG, + N0.getValueType())) { + if (Op.getValueType() < VT) + Op = DAG.getNode(ISD::ANY_EXTEND, VT, Op); + else if (Op.getValueType() > VT) + Op = DAG.getNode(ISD::TRUNCATE, VT, Op); + return DAG.getNode(ISD::SIGN_EXTEND_INREG, VT, Op, + DAG.getValueType(N0.getValueType())); } - return DAG.getNode(ISD::SIGN_EXTEND_INREG, VT, Op, - DAG.getValueType(N0.getValueType())); } // fold (sext (load x)) -> (sext (truncate (sextload x))) From sabre at nondot.org Sun Feb 25 21:16:36 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 21:16:36 -0600 Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/x86-64-arg.ll Message-ID: <200702260316.l1Q3Gaq7023586@zion.cs.uiuc.edu> Changes in directory llvm/test/CodeGen/X86: x86-64-arg.ll added (r1.1) --- Log message: new testcase --- Diffs of the changes: (+16 -0) x86-64-arg.ll | 16 ++++++++++++++++ 1 files changed, 16 insertions(+) Index: llvm/test/CodeGen/X86/x86-64-arg.ll diff -c /dev/null llvm/test/CodeGen/X86/x86-64-arg.ll:1.1 *** /dev/null Sun Feb 25 21:16:30 2007 --- llvm/test/CodeGen/X86/x86-64-arg.ll Sun Feb 25 21:16:20 2007 *************** *** 0 **** --- 1,16 ---- + ; RUN: llvm-as < %s | llc | grep 'movl %edi, %eax' + ; The input value is already sign extended, don't re-extend it. + ; This testcase corresponds to: + ; int test(short X) { return (int)X; } + + target datalayout = "e-p:64:64" + target triple = "x86_64-apple-darwin8" + + implementation ; Functions: + + define i32 @test(i16 sext %X) { + entry: + %tmp12 = sext i16 %X to i32 ; [#uses=1] + ret i32 %tmp12 + } + From sabre at nondot.org Sun Feb 25 21:19:13 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 21:19:13 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702260319.l1Q3JDmU023670@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.337 -> 1.338 --- Log message: in X86-64 CCC, i8/i16 arguments are already properly zext/sext'd on input. Capture this so that downstream zext/sext's are optimized out. This compiles: int test(short X) { return (int)X; } to: _test: movl %edi, %eax ret instead of: _test: movswl %di, %eax ret GCC produces this bizarre code: _test: movw %di, -12(%rsp) movswl -12(%rsp),%eax ret --- Diffs of the changes: (+19 -14) X86ISelLowering.cpp | 33 +++++++++++++++++++-------------- 1 files changed, 19 insertions(+), 14 deletions(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.337 llvm/lib/Target/X86/X86ISelLowering.cpp:1.338 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.337 Sun Feb 25 17:10:46 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 21:18:56 2007 @@ -1137,12 +1137,6 @@ unsigned NumIntRegs = 0; // Int regs used for parameter passing. unsigned NumXMMRegs = 0; // XMM regs used for parameter passing. - static const unsigned GPR8ArgRegs[] = { - X86::DIL, X86::SIL, X86::DL, X86::CL, X86::R8B, X86::R9B - }; - static const unsigned GPR16ArgRegs[] = { - X86::DI, X86::SI, X86::DX, X86::CX, X86::R8W, X86::R9W - }; static const unsigned GPR32ArgRegs[] = { X86::EDI, X86::ESI, X86::EDX, X86::ECX, X86::R8D, X86::R9D }; @@ -1156,6 +1150,7 @@ for (unsigned i = 0; i < NumArgs; ++i) { MVT::ValueType ObjectVT = Op.getValue(i).getValueType(); + unsigned ArgFlags = cast(Op.getOperand(3+i))->getValue(); unsigned ArgIncrement = 8; unsigned ObjSize = 0; unsigned ObjIntRegs = 0; @@ -1178,26 +1173,36 @@ case MVT::i64: { TargetRegisterClass *RC = NULL; switch (ObjectVT) { - default: break; + default: assert(0 && "Unknown integer VT!"); case MVT::i8: - RC = X86::GR8RegisterClass; - Reg = GPR8ArgRegs[NumIntRegs]; - break; case MVT::i16: - RC = X86::GR16RegisterClass; - Reg = GPR16ArgRegs[NumIntRegs]; - break; case MVT::i32: RC = X86::GR32RegisterClass; Reg = GPR32ArgRegs[NumIntRegs]; + ArgValue = DAG.getCopyFromReg(Root, Reg, MVT::i32); break; case MVT::i64: RC = X86::GR64RegisterClass; Reg = GPR64ArgRegs[NumIntRegs]; + ArgValue = DAG.getCopyFromReg(Root, Reg, MVT::i64); break; } Reg = AddLiveIn(MF, Reg, RC); - ArgValue = DAG.getCopyFromReg(Root, Reg, ObjectVT); + + // If this is an 8 or 16-bit value, it is really passed promoted to 32 + // bits. Insert an assert[sz]ext to capture this, then truncate to the + // right size. + if (ObjectVT == MVT::i8 || ObjectVT == MVT::i16) { + // FIXME: FORMAL_ARGUMENTS can't currently distinguish between an + // argument with undefined high bits, so we can't insert a assertzext + // yet. + if (ArgFlags & 1) { + unsigned ExtOpc = (ArgFlags & 1) ? ISD::AssertSext :ISD::AssertZext; + ArgValue = DAG.getNode(ExtOpc, MVT::i32, ArgValue, + DAG.getValueType(ObjectVT)); + ArgValue = DAG.getNode(ISD::TRUNCATE, ObjectVT, ArgValue); + } + } break; } case MVT::f32: From sabre at nondot.org Sun Feb 25 21:34:54 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 21:34:54 -0600 Subject: [llvm-commits] CVS: llvm/utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <200702260334.l1Q3YsH6023945@zion.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: RegisterInfoEmitter.cpp updated: 1.49 -> 1.50 --- Log message: emit an enum value for the # of target registers. --- Diffs of the changes: (+2 -2) RegisterInfoEmitter.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp diff -u llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.49 llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.50 --- llvm/utils/TableGen/RegisterInfoEmitter.cpp:1.49 Thu Dec 7 16:21:48 2006 +++ llvm/utils/TableGen/RegisterInfoEmitter.cpp Sun Feb 25 21:34:38 2007 @@ -38,8 +38,8 @@ OS << " enum {\n NoRegister,\n"; for (unsigned i = 0, e = Registers.size(); i != e; ++i) - OS << " " << Registers[i].getName() << (i != (e-1) ? ", \t// " : " \t// ") << i+1 << "\n"; - + OS << " " << Registers[i].getName() << ", \t// " << i+1 << "\n"; + OS << " NUM_TARGET_REGS \t// " << Registers.size()+1 << "\n"; OS << " };\n"; if (!Namespace.empty()) OS << "}\n"; From sabre at nondot.org Sun Feb 25 22:01:42 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 22:01:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.h Message-ID: <200702260401.l1Q41gg5025366@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.h updated: 1.88 -> 1.89 --- Log message: add an accessor. --- Diffs of the changes: (+4 -0) X86ISelLowering.h | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm/lib/Target/X86/X86ISelLowering.h diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.88 llvm/lib/Target/X86/X86ISelLowering.h:1.89 --- llvm/lib/Target/X86/X86ISelLowering.h:1.88 Sun Feb 25 03:06:15 2007 +++ llvm/lib/Target/X86/X86ISelLowering.h Sun Feb 25 22:01:25 2007 @@ -288,6 +288,10 @@ // to this function. unsigned getBytesCallerReserves() const { return BytesCallerReserves; } + /// getStackPtrReg - Return the stack pointer register we are using: either + /// ESP or RSP. + unsigned getStackPtrReg() const { return X86StackPtr; } + /// LowerOperation - Provide custom lowering hooks for some operations. /// virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG); From sabre at nondot.org Sun Feb 25 22:43:35 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 22:43:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp Message-ID: <200702260443.l1Q4hZfP028105@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Globals.cpp updated: 1.16 -> 1.17 --- Log message: revert my previous change, something strange is happening. --- Diffs of the changes: (+21 -29) Globals.cpp | 50 +++++++++++++++++++++----------------------------- 1 files changed, 21 insertions(+), 29 deletions(-) Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.16 llvm/lib/VMCore/Globals.cpp:1.17 --- llvm/lib/VMCore/Globals.cpp:1.16 Sun Feb 25 15:06:13 2007 +++ llvm/lib/VMCore/Globals.cpp Sun Feb 25 22:43:19 2007 @@ -22,18 +22,20 @@ // GlobalValue Class //===----------------------------------------------------------------------===// -/// removeDeadUsersOfConstant - If the specified constantexpr is dead, remove -/// it. This involves recursively eliminating any dead users of the -/// constantexpr. -static bool removeDeadUsersOfConstant(Constant *C) { +/// This could be named "SafeToDestroyGlobalValue". It just makes sure that +/// there are no non-constant uses of this GlobalValue. If there aren't then +/// this and the transitive closure of the constants can be deleted. See the +/// destructor for details. +static bool removeDeadConstantUsers(Constant* C) { if (isa(C)) return false; // Cannot remove this - while (!C->use_empty()) { - Constant *User = dyn_cast(C->use_back()); - if (!User) return false; // Non-constant usage; - if (!removeDeadUsersOfConstant(User)) - return false; // Constant wasn't dead - } + while (!C->use_empty()) + if (Constant *User = dyn_cast(C->use_back())) { + if (!removeDeadConstantUsers(User)) + return false; // Constant wasn't dead + } else { + return false; // Non-constant usage; + } C->destroyConstant(); return true; @@ -43,27 +45,17 @@ /// off of this global value, remove them. This method is useful for clients /// that want to check to see if a global is unused, but don't want to deal /// with potentially dead constants hanging off of the globals. +/// +/// This function returns true if the global value is now dead. If all +/// users of this global are not dead, this method may return false and +/// leave some of them around. void GlobalValue::removeDeadConstantUsers() { - - Value::use_iterator I = use_begin(), E = use_end(); - Value::use_iterator LastNonDeadUser = E; - for (; I != E; ++I) { - if (Constant *User = dyn_cast(*I)) { - if (!removeDeadUsersOfConstant(User)) { - // If the constant wasn't dead, remember that this was the last live use - // and move on to the next constant. - LastNonDeadUser = I; - } else { - // If the constant was dead, then the iterator is invalidated. - if (LastNonDeadUser == E) { - I = use_begin(); - if (I == E) break; - } else { - I = LastNonDeadUser; - } - } + while(!use_empty()) { + if (Constant* User = dyn_cast(use_back())) { + if (!::removeDeadConstantUsers(User)) + return; // Constant wasn't dead } else { - LastNonDeadUser = I; + return; // Non-constant usage; } } } From sabre at nondot.org Sun Feb 25 23:02:56 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 23:02:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp Message-ID: <200702260502.l1Q52u5m029324@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Globals.cpp updated: 1.17 -> 1.18 --- Log message: reapply my previous patch with a bugfix. --- Diffs of the changes: (+31 -21) Globals.cpp | 52 +++++++++++++++++++++++++++++++--------------------- 1 files changed, 31 insertions(+), 21 deletions(-) Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.17 llvm/lib/VMCore/Globals.cpp:1.18 --- llvm/lib/VMCore/Globals.cpp:1.17 Sun Feb 25 22:43:19 2007 +++ llvm/lib/VMCore/Globals.cpp Sun Feb 25 23:02:39 2007 @@ -22,20 +22,18 @@ // GlobalValue Class //===----------------------------------------------------------------------===// -/// This could be named "SafeToDestroyGlobalValue". It just makes sure that -/// there are no non-constant uses of this GlobalValue. If there aren't then -/// this and the transitive closure of the constants can be deleted. See the -/// destructor for details. -static bool removeDeadConstantUsers(Constant* C) { +/// removeDeadUsersOfConstant - If the specified constantexpr is dead, remove +/// it. This involves recursively eliminating any dead users of the +/// constantexpr. +static bool removeDeadUsersOfConstant(Constant *C) { if (isa(C)) return false; // Cannot remove this - while (!C->use_empty()) - if (Constant *User = dyn_cast(C->use_back())) { - if (!removeDeadConstantUsers(User)) - return false; // Constant wasn't dead - } else { - return false; // Non-constant usage; - } + while (!C->use_empty()) { + Constant *User = dyn_cast(C->use_back()); + if (!User) return false; // Non-constant usage; + if (!removeDeadUsersOfConstant(User)) + return false; // Constant wasn't dead + } C->destroyConstant(); return true; @@ -45,17 +43,29 @@ /// off of this global value, remove them. This method is useful for clients /// that want to check to see if a global is unused, but don't want to deal /// with potentially dead constants hanging off of the globals. -/// -/// This function returns true if the global value is now dead. If all -/// users of this global are not dead, this method may return false and -/// leave some of them around. void GlobalValue::removeDeadConstantUsers() { - while(!use_empty()) { - if (Constant* User = dyn_cast(use_back())) { - if (!::removeDeadConstantUsers(User)) - return; // Constant wasn't dead + Value::use_iterator I = use_begin(), E = use_end(); + Value::use_iterator LastNonDeadUser = E; + while (I != E) { + if (Constant *User = dyn_cast(*I)) { + if (!removeDeadUsersOfConstant(User)) { + // If the constant wasn't dead, remember that this was the last live use + // and move on to the next constant. + LastNonDeadUser = I; + ++I; + } else { + // If the constant was dead, then the iterator is invalidated. + if (LastNonDeadUser == E) { + I = use_begin(); + if (I == E) break; + } else { + I = LastNonDeadUser; + ++I; + } + } } else { - return; // Non-constant usage; + LastNonDeadUser = I; + ++I; } } } From sabre at nondot.org Sun Feb 25 23:21:22 2007 From: sabre at nondot.org (Chris Lattner) Date: Sun, 25 Feb 2007 23:21:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200702260521.l1Q5LMM5030475@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.338 -> 1.339 --- Log message: the truncate must always be done, it's only the assert that is conditional. --- Diffs of the changes: (+1 -1) X86ISelLowering.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.338 llvm/lib/Target/X86/X86ISelLowering.cpp:1.339 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.338 Sun Feb 25 21:18:56 2007 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Sun Feb 25 23:21:05 2007 @@ -1200,8 +1200,8 @@ unsigned ExtOpc = (ArgFlags & 1) ? ISD::AssertSext :ISD::AssertZext; ArgValue = DAG.getNode(ExtOpc, MVT::i32, ArgValue, DAG.getValueType(ObjectVT)); - ArgValue = DAG.getNode(ISD::TRUNCATE, ObjectVT, ArgValue); } + ArgValue = DAG.getNode(ISD::TRUNCATE, ObjectVT, ArgValue); } break; }